Go Back to: C++ Manual General Site
LDMX.SimCore package¶
Submodules¶
LDMX.SimCore.bias_operators module¶
Biasing operator templates for use throughout ldmx-sw
Mainly focused on reducing the number of places that certain parameter and class names are hardcoded into the python configuration.
- class LDMX.SimCore.bias_operators.DarkBrem(vol, bias_all, factor)¶
Bases:
XsecBiasingOperatorBias dark brem process
- Parameters:
vol (str) – name of volume to bias within
bial_all (bool) – Should we bias all electrons or just the primary?
factor (float) – biasing factor to mutliply by
- ecal()¶
Bias dark brem inside of the ecal by the input factor
- target()¶
Bias dark brem inside of the target by the input factor
- class LDMX.SimCore.bias_operators.ElectroNuclear(vol, factor, thresh=0.0)¶
Bases:
XsecBiasingOperatorBias electro nuclear process
- Parameters:
vol (str) – name of volume to bias within
factor (float) – biasing factor to mutliply by
threshold (float, optional) – minimum kinetic energy [MeV] to bias tracks
- class LDMX.SimCore.bias_operators.GammaToMuPair(vol, factor, thresh=0.0)¶
Bases:
XsecBiasingOperatorBias gamma -> mu+ mu- process
- Parameters:
vol (str) – name of volume to bias within
factor (float) – biasing factor to multiply by
threshold (float, optional) – minimum kinetic energy [MeV] to bias tracks
- class LDMX.SimCore.bias_operators.K0LongInelastic(vol, factor, thresh=0.0)¶
Bases:
XsecBiasingOperatorBias K0 Long inelastic collisions
- Parameters
- volstr
name of volume to bias within
- factorfloat
biasing factor to multiply by
- thresholdfloat, optional
minimum kinetic energy [MeV] to bias tracks
- class LDMX.SimCore.bias_operators.NeutronInelastic(vol, factor, thresh=0.0)¶
Bases:
XsecBiasingOperatorBias neutron inelastic collisions
- Parameters:
vol (str) – name of volume to bias within
factor (float) – biasing factor to multiply by
threshold (float, optional) – minimum kinetic energy [MeV] to bias tracks
- class LDMX.SimCore.bias_operators.PhotoNuclear(vol, factor, thresh=0.0, down_bias_conv=True, only_children_of_primary=False)¶
Bases:
XsecBiasingOperatorBias photo nuclear process
- Parameters:
vol (str) – name of volume to bias within
factor (float) – biasing factor to mutliply by
threshold (float, optional) – minimum kinetic energy [MeV] to bias tracks
down_bias_conv (bool, optional) – Should we down bias the gamma conversion process?
only_children_of_primary (bool, optional) – Should we only bias photons that are children of the primary particle?
- class LDMX.SimCore.bias_operators.XsecBiasingOperator(instance_name, class_name, module_name='SimCore_BiasOperators')¶
Bases:
objectObject that stores parameters for a XsecBiasingOperator
- Parameters:
instance_name (str) – Unique name for this particular instance of a XsecBiasingOperator
class_name (str) – Name of C++ class that this XsecBiasingOperator should be
module_name (str, optional) – Name of module that the class was compiled into
LDMX.SimCore.dark_brem module¶
Configuration module for dark brem simulation
- class LDMX.SimCore.dark_brem.DarkBrem¶
Bases:
objectStorage for parameters of dark brem process
- ap_mass¶
Mass of A’ in MeV
- Type:
float
- enable¶
Should we use the custom Geant4 dark brem process? (Default: No)
- Type:
bool
- only_one_per_event¶
Should we deactivate the process after one dark brem or allow for more than one? (Default: No)
- Type:
bool
- cache_xsec¶
Should we cache the xsec’s computed from the model? (Default: yes)
- Type:
bool
- model¶
The model that should be use for dark bremming
- Type:
- activate(ap_mass, model=None)¶
Activate the dark brem process with the input A’ mass [MeV] and dark brem model
If no dark brem model is given, we do not activate the process and only define the A’ mass. This allows for some backwards compatibility by allowing users to use the LHEPrimaryGenerator with A’ particles.
- class LDMX.SimCore.dark_brem.DarkBremModel(name)¶
Bases:
objectStorage for parameters of a dark brem model
All other models should inherit from this class in order to keep the correct internal parameters.
- Parameters:
name (str) – Name of this dark brem model
- class LDMX.SimCore.dark_brem.G4DarkBreMModel(library_path)¶
Bases:
DarkBremModelConfiguration for the event library dark brem model
This model uses G4DarkBreM’s library model. The library can be a directory of LHE files, gzip-compressed LHE files, a CSV processed by G4DarkBreM, or a gzip-compressed CSV processed by G4DarkBreM.
- Parameters:
library_path (str) – Path to library holding the dark brem kinematics
- method¶
Interpretation method for LHE files
- Type:
str
- threshold¶
Minimum energy [GeV] that electron should have for dark brem to have nonzero xsec
- Type:
float
- epsilon¶
Epsilon for dark brem xsec calculation
- Type:
float
- LDMX.SimCore.dark_brem.VertexLibraryModel¶
alias of
G4DarkBreMModel
LDMX.SimCore.generators module¶
Primary Generator templates for use throughout ldmx-sw
Mainly focused on reducing the number of places that certain parameter and class names are hardcoded into the python configuration.
- class LDMX.SimCore.generators.completeReSim(name, file_path)¶
Bases:
PrimaryGeneratorNew complete re-simprimary generator
- Parameters:
name (str) – name of new primary generator
file_path (str) – path to ROOT file containing the SimParticles to re-simulate
- collection_name¶
Name of SimParticles collection to re-sim
- Type:
str
- pass_name¶
Pass name of SimParticles to re-sim
- Type:
str
- class LDMX.SimCore.generators.ecalSP(name, filePath)¶
Bases:
PrimaryGeneratorNew ecal scoring planes primary generator
Sets the collection name, pass name, and time cutoff to reasonable defaults.
- Parameters:
name (str) – name of new primary generator
filePath (str) – path to ROOT file containing the EcalScoringPlanes to re-simulate
- collection_name¶
Name of EcalScoringPlaneHits collection to re-sim
- Type:
str, optional
- pass_name¶
Pass name of EcalScoringPlaneHits to re-sim
- Type:
str, optional
- time_cutoff¶
Maximum time of scoring plane hit to still re-sim [ns]
- Type:
float, optional
- class LDMX.SimCore.generators.genie(name, energy=8.0, targets=[], target_thickness=0.3504, abundances=[], time=0.0, position=[0.0, 0.0, 0.0], beam_size=[0.0, 0.0], direction=[0.0, 0.0, 1.0], tune='default', spline_file='', message_threshold_file='/usr/local/GENIE/Generator/config/Messenger.xml')¶
Bases:
PrimaryGeneratorSimple GENIE generator
- Parameters:
name (str) – name of new primary generator
- energy¶
Energy of particle to shoot [GeV]
- Type:
float
- targets¶
List of target nuclei PDG codes
- Type:
list of int
- abundances¶
List of abundances for target nuclei
- Type:
list of float
- time¶
Time to shoot from [ns]
- Type:
double
- position¶
Position of interaction from [mm]
- Type:
list of double
- direction¶
Unit vector direction of incoming electron
- Type:
list of double
- tune¶
Name of GENIE tune to use
- Type:
str
- target_thickness¶
Thickness of target [mm] to use for generation
- Type:
double
- beam_size¶
uniform beam size width to use
- Type:
list of double
Examples
- myGenie = genie( name=’myGenie’,
energy = 4.0, targets = [ 1000220480 ], abundances = [ 1.0 ], time = 0.0, position = [0.,0.,0.], direction = [0.,0.,1.], tune=’G18_02a_00_000’)
- class LDMX.SimCore.generators.gps(name, initCommands)¶
Bases:
PrimaryGeneratorNew general particle source
The input initialization commands are run in the order that they are listed.
- Parameters:
name (str) – name of new primary generator
initCommands (list of strings) – List of Geant4 commands to initialize this GeneralParticleSource
- Returns:
configured to be a GeneralParticleSource with the passed initialization commands
- Return type:
Examples
- myGPS = gps( ‘myGPS’ , [
“/gps/particle e-“, “/gps/pos/type Plane”, “/gps/pos/shape Square”, “/gps/pos/centre 0 0 0 mm”, “/gps/pos/halfx 40 mm”, “/gps/pos/halfy 80 mm”, “/gps/ang/type cos”, “/gps/ene/type Lin”, “/gps/ene/min 3 GeV”, “/gps/ene/max 4 GeV”, “/gps/ene/gradient 1”, “/gps/ene/intercept 1” ] )
- class LDMX.SimCore.generators.gun(name)¶
Bases:
PrimaryGeneratorNew basic particle gun primary generator
- Parameters:
name (str) – name of new primary generator
- time¶
Time to shoot from [ns]
- Type:
float, optional
- verbosity¶
Verbosity flag for this generator
- Type:
int, optional
- particle¶
Geant4 particle name to shoot
- Type:
str
- energy¶
Energy of particle to shoot [GeV]
- Type:
float
- position¶
Position to shoot from [mm]
- Type:
list of float
- direction¶
Unit vector direction to shoot from
- Type:
list of float
- vertex¶
Vertex position to shoot from [mm]. Defaults to [0.0, 0.0, 0.0]
- Type:
list of float, optional
Examples
myGun = gun( ‘myGun’ ) myGun.particle = ‘e-’ myGun.energy = 4.0 myGun.direction = [ 0., 0., 1. ] myGun.position = [ 0., 0., 0. ]
- class LDMX.SimCore.generators.lhe(name, filePath)¶
Bases:
PrimaryGeneratorNew LHE file primary generator
- Parameters:
name (str) – name of new primary generator
filePath (str) – path to LHE file containing the primary vertices
vertex (list of float, optional) – Vertex position to shoot from [mm]. Defaults to [0.0, 0.0, 0.0]
- class LDMX.SimCore.generators.multi(name)¶
Bases:
PrimaryGeneratorNew multi particle gun primary generator
- Parameters:
name (str) – name of new primary generator
- enablePoisson¶
Poisson-distribute number of particles?
- Type:
bool, optional
- vertex¶
Position to shoot particle(s) from [mm]
- Type:
list of float
- momentum¶
3-momentum to give particle(s) in [MeV]
- Type:
list of float
- nParticles¶
Number of particles to shoot (or average of Poisson distribution)
- Type:
int, optional
- pdgID¶
PDG ID of particle(s) to shoot
- Type:
int
- LDMX.SimCore.generators.single_1pt2gev_e_upstream_tagger()¶
Configure a particle gun to fire a 8 GeV electron upstream of the tagger tracker.
The position and direction are set such that the electron will be bent by the field and arrive at the target at [0, 0, 0] if it isn’t smeared and doesn’t interact with any material. In reality, it will be smeared and it will interact with some material but we can dream.
- Returns:
Instance of a particle gun configured to fire a single 8 GeV electron
upstream of the entire detector apparatus.
- LDMX.SimCore.generators.single_4gev_e_upstream_tagger()¶
Configure a particle gun to fire a 4 GeV electron upstream of the tagger tracker.
The position and direction are set such that the electron will be bent by the field and arrive at the target at [0, 0, 0] if it isn’t smeared and doesn’t interact with any material. In reality, it will be smeared and it will interact with some material but we can dream.
- Returns:
Instance of a particle gun configured to fire a single 4 Gev electron
upstream of the entire detector apparatus.
- LDMX.SimCore.generators.single_4gev_e_upstream_target()¶
Configure a particle gun to fire a 4 GeV electron upstream of the tagger tracker.
The position and direction are set such that the electron will be bent by the field and arrive at the target at approximately [0, 0, 0] (assuming it’s not smeared).
- Returns:
Instance of a particle gun configured to fire a single 4 Gev electron
directly upstream of the target.
- LDMX.SimCore.generators.single_8gev_e_upstream_tagger()¶
Configure a particle gun to fire a 8 GeV electron upstream of the tagger tracker.
The position and direction are set such that the electron will be bent by the field and arrive at the target at [0, 0, 0] if it isn’t smeared and doesn’t interact with any material. In reality, it will be smeared and it will interact with some material but we can dream.
- Returns:
Instance of a particle gun configured to fire a single 8 GeV electron
upstream of the entire detector apparatus.
- LDMX.SimCore.generators.single_backwards_positron(energy: float)¶
A particle gun configured to shoot positrons backwards (i.e. upstream) from the target at the input energy.
This generator is helpful for studying where electron guns of different energies should be started from if they should end up at the center of the target.
- Parameters:
energy (float) – energy in GeV of the positron
- Returns:
configured particle gun to shoot positrons backwards at the input energy
- Return type:
- LDMX.SimCore.generators.single_e_beam_pipe(ene=8.0)¶
Configure a particle gun to fire an electron of settable energy upstream of the tagger tracker.
The starting position here is well upstream of the analyzing magnet the position/angle of the gun is such that 8 gev electrons arrive at the target z=0 at xy=(0,0). This generator is used to study off-energy beam electrons.
Note that if an energy != 8gev, the trajectory will be different. And many electrons with energies sufficiently lower than 8GeV will just curve into the side of the magnet and not reach the target.
- Returns:
Instance of a particle gun configured to fire a single 8 GeV electron
upstream of the entire detector apparatus.
LDMX.SimCore.genie_reweight module¶
LDMX.SimCore.kaon_physics module¶
- class LDMX.SimCore.kaon_physics.KaonPhysics¶
Bases:
objectParameters that determine the physics of kaons in the simulation
- Parameters:
kplus_branching_ratios (list[float])
kminus_branching_ratios (list[float])
k0l_branching_ratios (list[float])
k0s_branching_ratios (list[float]) –
List of the desired branching ratios for kaons. The entries correspond go the following processes
For charged kaons - 0: K -> mu + v - 1: K -> pi + pi0 - 2: K -> 3 pi - 3: K -> pi + 2 pi0 - 4: K -> pi0 + e + v - 5: K -> pi0 + mu + v
For Klong - 0: K -> 3 pi0 - 1: K -> pi0 + pi+ + pi- - 2: K -> pi- + e+ + v - 3: K -> pi+ + e- + v - 4: K -> pi- + mu+ + v - 5: K -> pi+ + mu- + v
For Kshort: - 0: K -> pi+ + pi- - 1: K -> 2 pi0
See the sources for Geant4’s definitions and branching ratios (G4KaonMinus.cc, G4KaonPlus.cc, KaonZeroLong.cc, KaonZeroShort.cc). The default branching ratios correspond to the Geant4 defaults.
kplus_lifetime_factor (float)
kminus_lifetime_factor (float)
k0l_lifetime_factor (float)
k0s_lifetime_factor (float) – Multiplicative factor to scale the lifetime of kaons by. Default is to scale by 1 (no scaling)
verbosity (int) – If > 0: Dump details about the decay after the update If > 1: Also dump details about the decay before the update to show the difference
- upKaons()¶
Returns a configuration of the kaon physics corresponding to the changes that were made in https://github.com/ldmx-software/geant4/tree/LDMX.upKaons_mod
Reduces the charged kaon lifetimes by a factor 1/50 and forces decays to be into one of the leptonic decay modes.
See https://github.com/LDMX-Software/geant4/commit/25228b8b1fbad913b4933b7c0d3951ebe36d404c
LDMX.SimCore.photonuclear_models module¶
Configuration classes for default photonuclear models
- class LDMX.SimCore.photonuclear_models.BertiniAtLeastNProductsModel(name)¶
Bases:
PhotoNuclearModelA photonuclear model producing only topologies with no particles above a certain threshold.
Uses the default Bertini model from Geant4.
- kaon(hard_particle_threshold=200.0)¶
- class LDMX.SimCore.photonuclear_models.BertiniExactlyNProductsModel(name)¶
Bases:
PhotoNuclearModelA photonuclear model producing only topologies with a define number of particles above a certain threshold.
Uses the default Bertini model from Geant4.
- kaon(hard_particle_threshold=200.0)¶
- neutron(hard_particle_threshold=200.0)¶
- class LDMX.SimCore.photonuclear_models.BertiniModel¶
Bases:
PhotoNuclearModelThe default model for photonuclear interactions.
Keeps the default Bertini model from Geant4.
- class LDMX.SimCore.photonuclear_models.BertiniNothingHardModel¶
Bases:
PhotoNuclearModelA photonuclear model producing only topologies with no particles above a certain threshold.
Uses the default Bertini model from Geant4.
- class LDMX.SimCore.photonuclear_models.BertiniSingleNeutronModel¶
Bases:
PhotoNuclearModelA photonuclear model producing only topologies where only one neutron has kinetic energy above a particular threshold.
Uses the default Bertini model from Geant4.
- class LDMX.SimCore.photonuclear_models.NoPhotoNuclearModel¶
Bases:
PhotoNuclearModelA PhotoNuclear model that disables the photonuclear process entirely.
Make sure that no biasing operators for photonuclear reactions are enabled when using this model.
LDMX.SimCore.sensitive_detectors module¶
Configuration classes for sensitive detectors
- class LDMX.SimCore.sensitive_detectors.EcalSD¶
Bases:
SensitiveDetectorSD for the ECal
The two configurable parameters are inherited from a legacy method of merging simulated hit contribs. We have plans to update this hit merging in the future.
- Parameters:
enableHitContribs (bool, optional) – Should the simulation save contributions to Ecal sim hits?
compressHitContribs (bool, optional) – Should the simulation compress contributions to Ecal sim hits by PDG ID?
- class LDMX.SimCore.sensitive_detectors.HcalSD(gdml_identifiers=['scintYVolume', 'scintXVolume', 'scintX_0Volume', 'scintX_1Volume', 'scintX_2Volume', 'scintX_3Volume', 'scintY_0Volume', 'scintY_1Volume', 'scintY_2Volume', 'scintY_3Volume', 'scintZXVolume', 'scintZYVolume', 'ScintBox', 'scint_box'])¶
Bases:
SensitiveDetectorSD for the HCal
Separate from the other calorimeters since it includes a Birks law estimate.
- Parameters:
gdml_identifiers (list[str]) –
A list of strings used to determine which volumes in the Hcal are considered sensitive. Any volume name containing at least one of these identifiers will have a sensitive detector attached.
The current defaults match the mainline LDMX Hcal and prototype Hcal (scint_box) scintillator geometries.
- class LDMX.SimCore.sensitive_detectors.ScoringPlaneSD(subsystem)¶
Bases:
SensitiveDetectorScoring plane SD
Simply collecting tracker-hit equivalent for scoring planes that enclose different subsystems
- Parameters:
subsystem (str) – Name of subsystem to store scoring plane hits for Names must match what is in gdml for sp_<subsystem>
- ecal()¶
- hcal()¶
- magnet()¶
- target()¶
- tracker()¶
- trigscint()¶
- class LDMX.SimCore.sensitive_detectors.TrackerSD(subsystem, subdet_id)¶
Bases:
SensitiveDetectorSD for the recoil and tagging trackers
- Parameters:
subsystem (str) – Recoil or Tagger
subdet_id (int) – ID number for the subsystem
- recoil()¶
- tagger()¶
- class LDMX.SimCore.sensitive_detectors.TrigScintSD(module, name, vol)¶
Bases:
SensitiveDetectorTrigger Scintillaotr Sensitive Detector
used for both the trigger pad modules as well as collecting hits within the target itself
- Parameters:
module (int) – ID number for the module we are collecting hits from
name (str) – Short name to be used in building collection name
vol (str) – Name of logical volume(s) that this SD should be attached to DEPENDS ON GDML
use_birks_law (bool, optional) – Should the simulation use Birks law to estimate energy deposition? Defaults to False.
birks_const_one (float, optional) – First Birks constant, defaults to 1.29e-2
birks_const_two (float, optional) – Second Birks constant, defaults to 9.59e-6
- down()¶
- pad1()¶
- pad2()¶
- pad3()¶
- tag()¶
- target()¶
Target sensitive detector
- testbeam()¶
- up()¶
LDMX.SimCore.simcfg module¶
Internal configuration module for simulation objects
The simulation requires a lot more detailed configuration than the other processors, so we have two extra objects that require their own python classes.
- class LDMX.SimCore.simcfg.PhotoNuclearModel(instance_name, class_name, module_name)¶
Bases:
objectConfiguration for a photonuclear model that we want to load
- Parameters:
instance_name (str) – Unique name for this particular instance of a PhotoNuclear Model
class_name (str) – Name of C++ class that this PhotoNuclear model should be
module_name (str) – Name of C++ library that this PhotoNuclear model is compiled into
- class LDMX.SimCore.simcfg.PrimaryGenerator(instance_name, class_name, module_name='SimCore_Generators')¶
Bases:
objectObject that stores parameters for a PrimaryGenerator
- Parameters:
instance_name (str) – Unique name for this particular instance of a PrimaryGenerator
class_name (str) – Name of C++ class that this PrimaryGenerator should be
module_name (str, optional) – Name of C++ library that this primary generator is compiled into
- class LDMX.SimCore.simcfg.SensitiveDetector(instance_name, class_name, module_name)¶
Bases:
objectConfiguration for a sensitive detector we want to load
- Parameters:
instance_name (str) – Unique name for this particular instance of a PrimaryGenerator
class_name (str) – Name of C++ class that this PrimaryGenerator should be
module_name (str) – Name of C++ library that this primary generator is compiled into
- class LDMX.SimCore.simcfg.UserAction(instance_name, class_name)¶
Bases:
objectObject that stores parameters for a UserAction
- Parameters:
instance_name (str) – Unique name for this particular instance of a UserAction
class_name (str) – Name of C++ class that this UserAction should be
LDMX.SimCore.simulator module¶
Package to help configure the simulation
Defines a derived class from ldmxcfg.Producer with several helpful member functions.
- class LDMX.SimCore.simulator.simulator(instance_name)¶
Bases:
ProducerA instance of the simulation configuration
This class is derived from ldmxcfg.Producer and is mainly focused on providing helper functions that can be used instead of accessing the parameters member directly.
The parameters that are lists (‘preInitCommands’, ‘postInitCommands’, ‘actions’, and ‘generators’) are initialized as empty lists so that we can append to them later.
The ECal hit conbtibutions are enabled and compressed by default.
- Parameters:
instance_name (str) – Name of this instance of the Simulator
- generators¶
Generators to use to make primaries
- Type:
list of PrimaryGenerator
- detector¶
Full path to detector description gdml (suggested to use setDetector)
- Type:
str
- validate_detector¶
Should we have Geant4 validate that the gdml is correctly formatted?
- Type:
bool, optional
- sensitive_detectors¶
List of sensitive detectors to load
- Type:
list[SensitiveDetector]
- description¶
Describe this run in a human-readable way
- Type:
str
- scoringPlanes¶
Full path to the scoring planes gdml (suggested to use setDetector)
- Type:
str, optional
- beamSpotSmear¶
2 (x,y) or 3 (x,y,z) widths to smear ALL primary vertices by [mm]
- Type:
list of float, optional
- time_shift_primaries¶
Should we shift the times of primaries so that z=0mm corresponds to t=0ns?
- Type:
bool
- preInitCommands¶
Geant4 commands to run before the run is initialized
- Type:
list of str, optional
- postInitCommands¶
Geant4 commands to run after run is initialized (but before run starts)
- Type:
list of str, optional
- actions¶
Special User-defined actions to take during the simulation
- Type:
list of UserAction, optional
- biasing_operators¶
Operators for biasing specific particles to undergo specific processes
- Type:
list of XsecBiasingOperators, optional
- logging_prefix¶
Prefix to prepend any Geant4 logging files
- Type:
str, optional
- rootPrimaryGenUseSeed¶
Use the seed stored in the EventHeader for random generation
- Type:
bool, optional
- verbosity¶
Verbosity level to print
- Type:
int, optional
- resimulate(which_events=None, which_runs=None)¶
Create a resimulator based on the simulator configuration.
This is intended to ensure that a resimulator has the same configuration as the simulation that was used to generate the input file. If you require any changes to the simulation configuration, such as loading a modified geometry, you can make those changes after creating the resiulator.
- Parameters:
which_events (list of event numbers, optional) –
Which events from the input files to resimulate. If None, resimulate all events.
Events that are not present in any of the input files will be ignored.
For multiple input files, if an event number is present within more than one input file all versions will be resimulated unless the which_runs parameters is used to distinguish them.
which_runs (list of run numbers, optional) –
Which runs from the input files to resimulate, ignored if no events are listed. Runs not present in the input files will be ignored.
If not provided, all runs will be resimulated (i.e. the run number check is ignored). If only one value is provided, all events requested are also required to have that value for their run number to be resimulated. If more than one value is provided, it must be the same length as the number of events requested so that the event/run number pair can be required.
- setDetector(det_name, include_scoring_planes=False)¶
Set the detector description with the option to include the scoring planes
- Parameters:
det_name (str) – name of a detector in the Detectors module
include_scoring_planes (bool) – True if you want to import and use scoring planes
See also