From f2d78089ba9ac13d7c963cabc9d5acd919196fbc Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Thu, 18 Jul 2024 16:47:46 -0400 Subject: [PATCH 1/6] Update G4DarkBreM to track forked repo --- .gitmodules | 2 +- SimCore/G4DarkBreM | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index a3c6d9717..dd778b955 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ url = https://github.com/jothepro/doxygen-awesome-css [submodule "SimCore/G4DarkBreM"] path = SimCore/G4DarkBreM - url = https://github.com/LDMX-Software/G4DarkBreM.git + url = git@github.com:RobMina/G4DarkBreM_visdecay.git [submodule "Tracking/acts"] path = Tracking/acts url = https://github.com/acts-project/acts diff --git a/SimCore/G4DarkBreM b/SimCore/G4DarkBreM index 88ad65046..3c91aa433 160000 --- a/SimCore/G4DarkBreM +++ b/SimCore/G4DarkBreM @@ -1 +1 @@ -Subproject commit 88ad65046ed4db2680883d9499289d1052deeb25 +Subproject commit 3c91aa43327c835c927d89f61c0d9e64ff754762 From 68b98be5230eca6fac6d133197e41725dfc80b18 Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Thu, 18 Jul 2024 19:21:42 -0400 Subject: [PATCH 2/6] Update ldmx-sw to use new parameters of G4DarkBreM --- SimCore/include/SimCore/APrimePhysics.h | 6 +++++ SimCore/src/SimCore/APrimePhysics.cxx | 32 ++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/SimCore/include/SimCore/APrimePhysics.h b/SimCore/include/SimCore/APrimePhysics.h index 6c766c585..407c5c4d2 100644 --- a/SimCore/include/SimCore/APrimePhysics.h +++ b/SimCore/include/SimCore/APrimePhysics.h @@ -91,6 +91,12 @@ class APrimePhysics : public G4VPhysicsConstructor { /// is dark brem enabled for this run? bool enable_; + /// the decay mode (see G4DarkBreM/G4APrime.h) + std::string decay_mode_; + + /// the proper decay lifetime (seconds) for the A' + G4double ap_tau_; + /** * Dark brem parameters to pass to the process (if enabled) * diff --git a/SimCore/src/SimCore/APrimePhysics.cxx b/SimCore/src/SimCore/APrimePhysics.cxx index f360c1ef4..21caabea9 100644 --- a/SimCore/src/SimCore/APrimePhysics.cxx +++ b/SimCore/src/SimCore/APrimePhysics.cxx @@ -42,18 +42,36 @@ APrimePhysics::APrimePhysics(const framework::config::Parameters& params) process_{nullptr} { ap_mass_ = parameters_.getParameter("ap_mass", 0.) * MeV; enable_ = parameters_.getParameter("enable", false); + decay_mode_ = parameters_.getParameter("decay_mode", "no_decay"); + ap_tau_ = parameters_.getParameter("ap_tau", -1.0) * s; } void APrimePhysics::ConstructParticle() { + static const std::map + decay_lut = { + {"no_decay", + G4APrime::DecayMode::NoDecay}, + {"flat_decay", G4APrime::DecayMode::FlatDecay}, + {"geant_decay", G4APrime::DecayMode::GeantDecay}}; + auto decay_it{ + decay_lut.find(decay_mode_)}; + if (decay_it == decay_lut.end()) { + EXCEPTION_RAISE( + "BadConf", + "Unrecognized decay mode '" + + decay_mode_ + + "'," + " options are 'no_decay', 'flat_decay', or 'geant_decay'."); + } + /** * Insert A-prime into the Geant4 particle table. - * For now we flag it as stable. * * Geant4 registers all instances derived from G4ParticleDefinition and * deletes them at the end of the run. We configure the A' to have * the input mass and the PDG ID number of 622. */ - G4APrime::Initialize(ap_mass_, 622); + G4APrime::Initialize(ap_mass_, 622, ap_tau_, decay_it->second); } void APrimePhysics::ConstructProcess() { @@ -88,7 +106,15 @@ void APrimePhysics::ConstructProcess() { always DB off electrons here */ , model.getParameter("threshold"), - model.getParameter("epsilon"), scaling_method_it->second), + model.getParameter("epsilon"), + scaling_method_it->second, + g4db::G4DarkBreMModel::XsecMethod::Auto, + model.getParameter("max_R_for_full", 50.0), + model.getParameter("aprime_lhe_id", 622), + true, // always load the library + model.getParameter("scale_APrime", false), + model.getParameter("dist_decay_min", 0.0), + model.getParameter("dist_decay_max", 1.0)), parameters_.getParameter("only_one_per_event"), 1., /* global bias - should use bias operator instead */ parameters_.getParameter("cache_xsec")); From 0fa0380bf7e83cde8aa64f9d6f12aa6e3e1a01e7 Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Fri, 19 Jul 2024 11:08:21 -0400 Subject: [PATCH 3/6] Fixes in handling A' decay in G4DarkBreM --- Biasing/python/eat.py | 25 ++++++++++++++++++++++--- SimCore/G4DarkBreM | 2 +- SimCore/include/SimCore/APrimePhysics.h | 6 ------ SimCore/src/SimCore/APrimePhysics.cxx | 17 +++++++++-------- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Biasing/python/eat.py b/Biasing/python/eat.py index f7f3140e2..cb000720b 100644 --- a/Biasing/python/eat.py +++ b/Biasing/python/eat.py @@ -165,7 +165,10 @@ def midshower_dimuon( detector , generator, bias_factor , bias_threshold , min_d return sim -def dark_brem( ap_mass , lhe, detector, generator) : +def dark_brem(ap_mass, db_event_lib, detector, generator, + scale_APrime = False, decay_mode = 'no_decay', + ap_tau = -1.0, dist_decay_min = 0.0, + dist_decay_max = 1.0) : """Example configuration for producing dark brem interactions in the ECal. This configures the simulator to fire a 4 GeV electron upstream of the @@ -177,7 +180,7 @@ def dark_brem( ap_mass , lhe, detector, generator) : ---------- ap_mass : float The mass of the A' in MeV. - lhe : str + db_event_lib : str The path to the reference library to use as vertices of the dark brem. detector : str Path to the detector. @@ -185,6 +188,16 @@ def dark_brem( ap_mass , lhe, detector, generator) : Beam generator for this simulation which should be a ParticleGun so we can configure the PrimaryToEcalFilter to select events where beam electrons retain 87.5% of their energy. + scale_APrime : bool + Whether to scale the A' momentum along with the recoil electron. + decay_mode : str + The A' decay mode. Either no_decay, flat_decay, or geant_decay + ap_tau : float + The A' decay lifetime in seconds + dist_decay_min : float + The minimum lab-frame distance at which to decay the A' + dist_decay_max : float + The maximum lab-frame distance at which to decay the A' Return ------ @@ -213,9 +226,14 @@ def dark_brem( ap_mass , lhe, detector, generator) : #Activiate dark bremming with a certain A' mass and LHE library from LDMX.SimCore import dark_brem - db_model = dark_brem.G4DarkBreMModel( lhe ) + db_model = dark_brem.G4DarkBreMModel( db_event_lib ) db_model.threshold = 0.5*generator.energy #GeV - minimum energy electron needs to have to dark brem db_model.epsilon = 0.01 #decrease epsilon from one to help with Geant4 biasing calculations + db_model.scale_APrime = scale_APrime + db_model.decay_mode = decay_mode + db_model.ap_tau = ap_tau + db_model.dist_decay_min = dist_decay_min + db_model.dist_decay_max = dist_decay_max sim.dark_brem.activate( ap_mass , db_model ) #Biasing dark brem up inside of the ecal volumes @@ -229,6 +247,7 @@ def dark_brem( ap_mass , lhe, detector, generator) : beam_energy = generator.energy*1000 sim.actions = [ + util.DecayChildrenKeeper([622]), # keep children of A' decay util.PartialEnergySorter(0.5*beam_energy), filters.PrimaryToEcalFilter(0.875*beam_energy), filters.EcalDarkBremFilter(0.5*beam_energy) diff --git a/SimCore/G4DarkBreM b/SimCore/G4DarkBreM index 3c91aa433..0e2adfd31 160000 --- a/SimCore/G4DarkBreM +++ b/SimCore/G4DarkBreM @@ -1 +1 @@ -Subproject commit 3c91aa43327c835c927d89f61c0d9e64ff754762 +Subproject commit 0e2adfd317348f2abb85bbe6b85a5785a29e0632 diff --git a/SimCore/include/SimCore/APrimePhysics.h b/SimCore/include/SimCore/APrimePhysics.h index 407c5c4d2..6c766c585 100644 --- a/SimCore/include/SimCore/APrimePhysics.h +++ b/SimCore/include/SimCore/APrimePhysics.h @@ -91,12 +91,6 @@ class APrimePhysics : public G4VPhysicsConstructor { /// is dark brem enabled for this run? bool enable_; - /// the decay mode (see G4DarkBreM/G4APrime.h) - std::string decay_mode_; - - /// the proper decay lifetime (seconds) for the A' - G4double ap_tau_; - /** * Dark brem parameters to pass to the process (if enabled) * diff --git a/SimCore/src/SimCore/APrimePhysics.cxx b/SimCore/src/SimCore/APrimePhysics.cxx index 21caabea9..6e47da522 100644 --- a/SimCore/src/SimCore/APrimePhysics.cxx +++ b/SimCore/src/SimCore/APrimePhysics.cxx @@ -42,28 +42,29 @@ APrimePhysics::APrimePhysics(const framework::config::Parameters& params) process_{nullptr} { ap_mass_ = parameters_.getParameter("ap_mass", 0.) * MeV; enable_ = parameters_.getParameter("enable", false); - decay_mode_ = parameters_.getParameter("decay_mode", "no_decay"); - ap_tau_ = parameters_.getParameter("ap_tau", -1.0) * s; } void APrimePhysics::ConstructParticle() { + auto model{ + parameters_.getParameter("model")}; static const std::map - decay_lut = { - {"no_decay", - G4APrime::DecayMode::NoDecay}, + decay_lut = { + {"no_decay", G4APrime::DecayMode::NoDecay}, {"flat_decay", G4APrime::DecayMode::FlatDecay}, {"geant_decay", G4APrime::DecayMode::GeantDecay}}; auto decay_it{ - decay_lut.find(decay_mode_)}; + decay_lut.find(model.getParameter("decay_mode", "no_decay"))}; if (decay_it == decay_lut.end()) { EXCEPTION_RAISE( "BadConf", "Unrecognized decay mode '" + - decay_mode_ + + model.getParameter("decay_mode") + "'," " options are 'no_decay', 'flat_decay', or 'geant_decay'."); } + double ap_tau = model.getParameter("ap_tau", -1.0); + /** * Insert A-prime into the Geant4 particle table. * @@ -71,7 +72,7 @@ void APrimePhysics::ConstructParticle() { * deletes them at the end of the run. We configure the A' to have * the input mass and the PDG ID number of 622. */ - G4APrime::Initialize(ap_mass_, 622, ap_tau_, decay_it->second); + G4APrime::Initialize(ap_mass_, 622, ap_tau, decay_it->second); } void APrimePhysics::ConstructProcess() { From af4eecb4a39436ce7d8ce312d90aca311285009b Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Mon, 12 Aug 2024 15:22:42 -0400 Subject: [PATCH 4/6] Update .gitmodules track the original (unforked) G4DarkBreM repo --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index dd778b955..a3c6d9717 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ url = https://github.com/jothepro/doxygen-awesome-css [submodule "SimCore/G4DarkBreM"] path = SimCore/G4DarkBreM - url = git@github.com:RobMina/G4DarkBreM_visdecay.git + url = https://github.com/LDMX-Software/G4DarkBreM.git [submodule "Tracking/acts"] path = Tracking/acts url = https://github.com/acts-project/acts From 56aeec4e7beb459118c6bdf59767f067fcbf7ed2 Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Fri, 16 Aug 2024 07:35:34 -0400 Subject: [PATCH 5/6] put G4DarkBreM on v2.1.0 --- .gitmodules | 6 +++--- SimCore/G4DarkBreM | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index a3c6d9717..e450d0425 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "docs/doxygen.conf/doxygen-awesome-css"] path = docs/doxygen.conf/doxygen-awesome-css url = https://github.com/jothepro/doxygen-awesome-css -[submodule "SimCore/G4DarkBreM"] - path = SimCore/G4DarkBreM - url = https://github.com/LDMX-Software/G4DarkBreM.git [submodule "Tracking/acts"] path = Tracking/acts url = https://github.com/acts-project/acts @@ -13,3 +10,6 @@ [submodule "Trigger/ruckus"] path = Trigger/ruckus url = https://github.com/slaclab/ruckus +[submodule "SimCore/G4DarkBreM"] + path = SimCore/G4DarkBreM + url = https://github.com/LDMX-Software/G4DarkBreM.git diff --git a/SimCore/G4DarkBreM b/SimCore/G4DarkBreM index 0e2adfd31..dc6f96827 160000 --- a/SimCore/G4DarkBreM +++ b/SimCore/G4DarkBreM @@ -1 +1 @@ -Subproject commit 0e2adfd317348f2abb85bbe6b85a5785a29e0632 +Subproject commit dc6f96827b6c9f3266afef4f967066460dae1205 From b38b58c0b497b947a67d60b57aeef6b5336bc996 Mon Sep 17 00:00:00 2001 From: Rob Mina Date: Fri, 16 Aug 2024 07:38:55 -0400 Subject: [PATCH 6/6] format my C++ edits in Google style --- SimCore/src/SimCore/APrimePhysics.cxx | 33 ++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/SimCore/src/SimCore/APrimePhysics.cxx b/SimCore/src/SimCore/APrimePhysics.cxx index 6e47da522..97310eb88 100644 --- a/SimCore/src/SimCore/APrimePhysics.cxx +++ b/SimCore/src/SimCore/APrimePhysics.cxx @@ -45,22 +45,20 @@ APrimePhysics::APrimePhysics(const framework::config::Parameters& params) } void APrimePhysics::ConstructParticle() { - auto model{ - parameters_.getParameter("model")}; - static const std::map - decay_lut = { - {"no_decay", G4APrime::DecayMode::NoDecay}, - {"flat_decay", G4APrime::DecayMode::FlatDecay}, - {"geant_decay", G4APrime::DecayMode::GeantDecay}}; - auto decay_it{ - decay_lut.find(model.getParameter("decay_mode", "no_decay"))}; + auto model{parameters_.getParameter("model")}; + static const std::map decay_lut = { + {"no_decay", G4APrime::DecayMode::NoDecay}, + {"flat_decay", G4APrime::DecayMode::FlatDecay}, + {"geant_decay", G4APrime::DecayMode::GeantDecay}}; + auto decay_it{decay_lut.find( + model.getParameter("decay_mode", "no_decay"))}; if (decay_it == decay_lut.end()) { - EXCEPTION_RAISE( - "BadConf", - "Unrecognized decay mode '" + - model.getParameter("decay_mode") + - "'," - " options are 'no_decay', 'flat_decay', or 'geant_decay'."); + EXCEPTION_RAISE( + "BadConf", + "Unrecognized decay mode '" + + model.getParameter("decay_mode") + + "'," + " options are 'no_decay', 'flat_decay', or 'geant_decay'."); } double ap_tau = model.getParameter("ap_tau", -1.0); @@ -107,12 +105,11 @@ void APrimePhysics::ConstructProcess() { always DB off electrons here */ , model.getParameter("threshold"), - model.getParameter("epsilon"), - scaling_method_it->second, + model.getParameter("epsilon"), scaling_method_it->second, g4db::G4DarkBreMModel::XsecMethod::Auto, model.getParameter("max_R_for_full", 50.0), model.getParameter("aprime_lhe_id", 622), - true, // always load the library + true, // always load the library model.getParameter("scale_APrime", false), model.getParameter("dist_decay_min", 0.0), model.getParameter("dist_decay_max", 1.0)),