10 #include <tracking/modules/ext/ExtModule.h>
13 #include <tracking/trackExtrapolateG4e/TrackExtrapolateG4e.h>
16 #include <framework/logging/Logger.h>
17 #include <simulation/kernel/ExtManager.h>
20 #include <CLHEP/Units/SystemOfUnits.h>
23 #include <G4UImanager.hh>
38 m_TrackingVerbosity(0),
39 m_EnableVisualization(false),
40 m_MagneticFieldStepperName(""),
41 m_MagneticCacheDistance(0.0),
42 m_DeltaChordInMagneticField(0.0)
44 m_Extrapolator = TrackExtrapolateG4e::getInstance();
48 setDescription(
"Extrapolates tracks from CDC to outer detectors using geant4e");
49 setPropertyFlags(c_ParallelProcessingCertified);
50 addParam(
"pdgCodes", m_PDGCodes,
"Positive-charge PDG codes for extrapolation hypotheses", m_PDGCodes);
51 addParam(
"MinPt", m_MinPt,
"[GeV/c] Minimum transverse momentum of a particle that will be extrapolated (default 0.1)",
53 addParam(
"MinKE", m_MinKE,
"[GeV] Minimum kinetic energy of a particle to continue extrapolation (default 0.002)",
double(0.002));
54 addParam(
"MaxStep", m_MaxStep,
"[cm] Maximum step size during extrapolation (use 0 for infinity) (default 25)",
double(25.0));
56 addParam(
"TrackingVerbosity", m_TrackingVerbosity,
57 "Tracking verbosity: 0=Silent; 1=Min info per step; 2=sec particles; 3=pre/post step info; 4=like 3 but more info; 5=proposed step length info",
59 addParam(
"EnableVisualization", m_EnableVisualization,
"If set to True the Geant4 visualization support is enabled",
false);
60 addParam(
"magneticFieldStepper", m_MagneticFieldStepperName,
61 "Chooses the magnetic field stepper used by Geant4. possible values are: default, nystrom, expliciteuler, simplerunge",
63 addParam(
"magneticCacheDistance", m_MagneticCacheDistance,
64 "Minimum distance for BField lookup in cm. If the next requested point is closer than this distance than return the last BField value. 0 means no caching",
66 addParam(
"deltaChordInMagneticField", m_DeltaChordInMagneticField,
67 "[mm] The maximum miss-distance between the trajectory curve and its linear cord(s) approximation", 0.25);
68 vector<string> defaultCommands;
69 addParam(
"UICommands", m_UICommands,
"A list of Geant4 UI commands that should be applied at the start of the job",
73 ExtModule::~ExtModule()
77 void ExtModule::initialize()
83 extMgr->
Initialize(
"Ext", m_MagneticFieldStepperName, m_MagneticCacheDistance, m_DeltaChordInMagneticField,
84 m_EnableVisualization, m_TrackingVerbosity, m_UICommands);
90 m_MaxStep = ((m_MaxStep == 0.0) ? 10.0 : std::min(10.0, m_MaxStep)) * CLHEP::cm;
92 std::sprintf(stepSize,
"/geant4e/limits/stepLength %8.2f mm", m_MaxStep);
93 G4UImanager::GetUIpointer()->ApplyCommand(stepSize);
94 G4UImanager::GetUIpointer()->ApplyCommand(
"/geant4e/limits/magField 0.001");
95 G4UImanager::GetUIpointer()->ApplyCommand(
"/geant4e/limits/energyLoss 0.05");
100 if (m_PDGCodes.empty()) {
102 m_Hypotheses.push_back(pdgIter);
105 std::vector<Const::ChargedStable> stack;
107 stack.push_back(pdgIter);
109 for (
unsigned int i = 0; i < m_PDGCodes.size(); ++i) {
110 for (
unsigned int k = 0; k < stack.size(); ++k) {
111 if (abs(m_PDGCodes[i]) == stack[k].getPDGCode()) {
112 m_Hypotheses.push_back(stack[k]);
113 stack.erase(stack.begin() + k);
118 if (m_Hypotheses.empty()) B2ERROR(
"No valid PDG codes for extrapolation");
121 for (
unsigned int i = 0; i < m_Hypotheses.size(); ++i) {
122 B2INFO(
"Ext hypothesis for PDG code " << m_Hypotheses[i].getPDGCode() <<
" and its antiparticle will be extrapolated");
127 m_Extrapolator->initialize(m_MinPt, m_MinKE, m_Hypotheses);
130 void ExtModule::beginRun()
132 m_Extrapolator->beginRun(
false);
135 void ExtModule::event()
137 m_Extrapolator->event(
false);
140 void ExtModule::endRun()
142 m_Extrapolator->endRun(
false);
145 void ExtModule::terminate()
147 m_Extrapolator->terminate(
false);
Provides a type-safe way to pass members of the chargedStableSet set.
The geant4e-based track extrapolation module.
It is the main interface for the user to define the setup and start the propagation.
void Initialize(const char[], const std::string &, double, double, bool, int, const std::vector< std::string > &)
Initialize Geant4 and Geant4e.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.