10#include <tracking/modules/muid/MuidModule.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>
39 m_MaxDistSqInVariances(0.0),
40 m_MaxKLMTrackClusterDistance(0.0),
41 m_MaxECLTrackClusterDistance(0.0),
42 m_TrackingVerbosity(0),
43 m_EnableVisualization(false),
44 m_MagneticFieldStepperName(
""),
45 m_MagneticCacheDistance(0.0),
46 m_DeltaChordInMagneticField(0.0)
52 setDescription(
"Identifies muons by extrapolating tracks from CDC to KLM using geant4e");
55 addParam(
"MeanDt",
m_MeanDt,
"[ns] Mean hit-trigger time for coincident hits (default 0)",
double(0.0));
59 addParam(
"MaxDt",
m_MaxDt,
"[ns] Coincidence window half-width for in-time KLM hits.",
double(10000.0));
60 addParam(
"MinPt",
m_MinPt,
"[GeV/c] Minimum transverse momentum of a particle that will be extrapolated (default 0.1)",
62 addParam(
"MinKE",
m_MinKE,
"[GeV] Minimum kinetic energy of a particle to continue extrapolation (default 0.002)",
double(0.002));
63 addParam(
"MaxStep",
m_MaxStep,
"[cm] Maximum step size during extrapolation (use 0 for infinity; default 25)",
double(25.0));
66 "[cm] Maximum distance of closest approach of track to KLM cluster for match (default 150)",
double(150.0));
68 "[cm] Maximum distance of closest approach of track to ECL cluster for match (default 100)",
double(100.0));
71 "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.",
75 "Chooses the magnetic field stepper used by Geant4. possible values are: default, nystrom, expliciteuler, simplerunge",
76 std::string(
"default"));
78 "Minimum distance for BField lookup in cm. If the next requested point is closer than this distance than return the flast BField value. 0 means no caching",
81 "[mm] The maximum miss-distance between the trajectory curve and its linear cord(s) approximation", 0.25);
83 "Parameter to add the found hits also to the reco tracks or not. Is turned off by default. "
84 "Make sure to refit the track afterwards.",
86 std::vector<std::string> defaultCommands;
87 addParam(
"UICommands",
m_UICommands,
"A list of Geant4 UI commands that should be applied at the start of the job.",
110 std::sprintf(stepSize,
"/geant4e/limits/stepLength %8.2f mm",
m_MaxStep);
111 G4UImanager::GetUIpointer()->ApplyCommand(stepSize);
112 G4UImanager::GetUIpointer()->ApplyCommand(
"/geant4e/limits/magField 0.001");
113 G4UImanager::GetUIpointer()->ApplyCommand(
"/geant4e/limits/energyLoss 0.05");
119 std::vector<Const::ChargedStable> stack;
121 stack.push_back(pdgIter);
123 for (
unsigned int i = 0; i <
m_PDGCodes.size(); ++i) {
124 for (
unsigned int k = 0; k < stack.size(); ++k) {
125 if (abs(
m_PDGCodes[i]) == stack[k].getPDGCode()) {
127 stack.erase(stack.begin() + k);
132 if (
m_Hypotheses.empty()) B2ERROR(
"No valid PDG codes for extrapolation");
135 for (
unsigned int i = 0; i <
m_Hypotheses.size(); ++i) {
136 B2INFO(
"Muid 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 ChargedStable muon
muon particle
static const ParticleSet chargedStableSet
set of charged stable particles
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...
double m_MaxKLMTrackClusterDistance
user-defined maximum distance in cm between KLMCluster and associated track
double m_DeltaChordInMagneticField
maximum miss-distance between the trajectory curve and its linear chord(s) approximation
double m_MaxDt
Coincidence window half-width for in-time KLM hits (ns)
void initialize() override
Initialize for muon identification.
void event() override
Performs muon identification for all tracks in one event.
int m_TrackingVerbosity
Tracking verbosity: 0=Silent; 1=Min info per step; 2=sec particles; 3=pre/post step info; 4=like 3 bu...
void endRun() override
Perform end-of-run actions.
void terminate() override
Terminates the module.
double m_MaxStep
Maximum step size in cm (0 for no upper limit)
std::vector< std::string > m_UICommands
A list of Geant4 UI commands that should be applied before the extrapolation starts.
double m_MaxECLTrackClusterDistance
user-defined maximum distance in cm between ECLCluster and associated track
void beginRun() override
Perform beginning-of-run actions.
std::vector< Const::ChargedStable > m_Hypotheses
ChargedStable hypotheses.
double m_MinPt
Minimum transverse momentum in GeV/c for extrapolation to be started.
bool m_addHitsToRecoTrack
Parameter to add the found hits also to the reco tracks or not. Is turned off by default.
TrackExtrapolateG4e * m_Extrapolator
Pointer to the TrackExtrapoleG4e singleton.
bool m_EnableVisualization
If set to true the Geant4 visualization support is enabled.
double m_MagneticCacheDistance
minimal distance for magnetic field lookup. If distance is smaller, return cached value
double m_MeanDt
Mean hit - trigger time (ns)
std::vector< int > m_PDGCodes
PDG code for the particle-ID hypotheses.
double m_MinKE
Minimum kinetic energy in GeV for extrapolation to continue.
std::string m_MagneticFieldStepperName
magnetic field stepper to use
double m_MaxDistSqInVariances
user-defined maximum squared-distance (in number of variances) for matching hit to extrapolation
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.