Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update G4DarkBreM with configurable A' scaling and decay #1386

Merged
merged 7 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
25 changes: 22 additions & 3 deletions Biasing/python/eat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -177,14 +180,24 @@ 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.
generator : simcfg.PrimaryGenerator
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
------
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
30 changes: 27 additions & 3 deletions SimCore/src/SimCore/APrimePhysics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,32 @@ APrimePhysics::APrimePhysics(const framework::config::Parameters& params)
}

void APrimePhysics::ConstructParticle() {
auto model{parameters_.getParameter<framework::config::Parameters>("model")};
static const std::map<std::string, G4APrime::DecayMode> 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<std::string>("decay_mode", "no_decay"))};
if (decay_it == decay_lut.end()) {
EXCEPTION_RAISE(
"BadConf",
"Unrecognized decay mode '" +
model.getParameter<std::string>("decay_mode") +
"',"
" options are 'no_decay', 'flat_decay', or 'geant_decay'.");
}

double ap_tau = model.getParameter<double>("ap_tau", -1.0);

/**
* 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() {
Expand Down Expand Up @@ -88,7 +105,14 @@ void APrimePhysics::ConstructProcess() {
always DB off electrons here */
,
model.getParameter<double>("threshold"),
model.getParameter<double>("epsilon"), scaling_method_it->second),
model.getParameter<double>("epsilon"), scaling_method_it->second,
g4db::G4DarkBreMModel::XsecMethod::Auto,
model.getParameter<double>("max_R_for_full", 50.0),
model.getParameter<int>("aprime_lhe_id", 622),
true, // always load the library
model.getParameter<bool>("scale_APrime", false),
model.getParameter<double>("dist_decay_min", 0.0),
model.getParameter<double>("dist_decay_max", 1.0)),
parameters_.getParameter<bool>("only_one_per_event"),
1., /* global bias - should use bias operator instead */
parameters_.getParameter<bool>("cache_xsec"));
Expand Down
Loading