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>
37 m_TrackingVerbosity(0),
38 m_EnableVisualization(false),
39 m_MagneticFieldStepperName(
""),
40 m_MagneticCacheDistance(0.0),
41 m_DeltaChordInMagneticField(0.0)
47 setDescription(
"Extrapolates tracks from CDC to outer detectors using geant4e");
50 addParam(
"MinPt",
m_MinPt,
"[GeV/c] Minimum transverse momentum of a particle that will be extrapolated (default 0.1)",
52 addParam(
"MinKE",
m_MinKE,
"[GeV] Minimum kinetic energy of a particle to continue extrapolation (default 0.002)",
double(0.002));
53 addParam(
"MaxStep",
m_MaxStep,
"[cm] Maximum step size during extrapolation (use 0 for infinity) (default 25)",
double(25.0));
56 "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",
60 "Chooses the magnetic field stepper used by Geant4. possible values are: default, nystrom, expliciteuler, simplerunge",
61 std::string(
"default"));
63 "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 "[mm] The maximum miss-distance between the trajectory curve and its linear cord(s) approximation", 0.25);
67 std::vector<std::string> defaultCommands;
68 addParam(
"UICommands",
m_UICommands,
"A list of Geant4 UI commands that should be applied at the start of the job",
91 std::sprintf(stepSize,
"/geant4e/limits/stepLength %8.2f mm",
m_MaxStep);
92 G4UImanager::GetUIpointer()->ApplyCommand(stepSize);
93 G4UImanager::GetUIpointer()->ApplyCommand(
"/geant4e/limits/magField 0.001");
94 G4UImanager::GetUIpointer()->ApplyCommand(
"/geant4e/limits/energyLoss 0.05");
104 std::vector<Const::ChargedStable> stack;
106 stack.push_back(pdgIter);
108 for (
unsigned int i = 0; i <
m_PDGCodes.size(); ++i) {
109 for (
unsigned int k = 0; k < stack.size(); ++k) {
110 if (abs(
m_PDGCodes[i]) == stack[k].getPDGCode()) {
112 stack.erase(stack.begin() + k);
117 if (
m_Hypotheses.empty()) B2ERROR(
"No valid PDG codes for extrapolation");
120 for (
unsigned int i = 0; i <
m_Hypotheses.size(); ++i) {
121 B2INFO(
"Ext hypothesis for PDG code " <<
m_Hypotheses[i].getPDGCode() <<
" and its antiparticle will be extrapolated");
Provides a type-safe way to pass members of the chargedStableSet set.
static const ParticleSet chargedStableSet
set of charged stable particles
~ExtModule() override
destructor
double m_DeltaChordInMagneticField
User-defined maximum miss-distance between the trajectory curve and its linear chord(s) approximation...
void initialize() override
Initialize for track extrapolation.
void event() override
Performs track extrapolation for all tracks in one event.
int m_TrackingVerbosity
User-defined tracking verbosity: 0=Silent; 1=Min info per step; 2=sec particles; 3=pre/post step info...
void endRun() override
Perform end-of-run actions.
void terminate() override
Terminates the module.
double m_MaxStep
User-define maximum step size in cm (0 for no upper limit)
std::vector< std::string > m_UICommands
User-defined list of Geant4 UI commands that should be applied before the extrapolation starts.
void beginRun() override
Perform beginning-of-run actions.
std::vector< Const::ChargedStable > m_Hypotheses
ChargedStable hypotheses.
double m_MinPt
User-defined minimum transverse momentum in GeV/c for extrapolation to be started.
TrackExtrapolateG4e * m_Extrapolator
Pointer to the TrackExtrapoleG4e singleton.
bool m_EnableVisualization
User-defined Geant4 visualization support: true to enable.
double m_MagneticCacheDistance
User-defined minimal distance for magnetic field lookup. If distance is smaller, return cached value.
std::vector< int > m_PDGCodes
User-selected PDG codes to extrapolate (anti-particles are included implicitly)
double m_MinKE
User-defined minimum kinetic energy in GeV for extrapolation to continue.
std::string m_MagneticFieldStepperName
User-defined magnetic field stepper to use.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
It is the main interface for the user to define the setup and start the propagation.
static ExtManager * GetManager()
Get pointer to the instance of this singleton class (create if needed)
void Initialize(const char[], const std::string &, double, double, bool, int, const std::vector< std::string > &)
Initialize Geant4 and Geant4e.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.