CMS 3D CMS Logo

SteppingAction.h
Go to the documentation of this file.
1 #ifndef SimG4Core_SteppingAction_H
2 #define SimG4Core_SteppingAction_H
3 
7 
8 #include "G4LogicalVolume.hh"
9 #include "G4Region.hh"
10 #include "G4UserSteppingAction.hh"
11 #include "G4VPhysicalVolume.hh"
12 #include "G4VTouchable.hh"
13 #include "G4Track.hh"
14 
15 #include <string>
16 #include <vector>
17 
18 class CMSSteppingVerbose;
19 
20 class SteppingAction : public G4UserSteppingAction {
21 public:
22  explicit SteppingAction(const CMSSteppingVerbose*, const edm::ParameterSet&, bool, bool);
23  ~SteppingAction() override = default;
24 
25  void UserSteppingAction(const G4Step* aStep) final;
26 
28 
29 private:
30  bool initPointer();
31 
32  inline bool isInsideDeadRegion(const G4Region* reg) const;
33  inline bool isOutOfTimeWindow(const G4Region* reg, const double& time) const;
34  inline bool isForZDC(const G4LogicalVolume* lv, int pdg) const;
35 
36  bool isLowEnergy(const G4LogicalVolume*, const G4Track*) const;
37  void PrintKilledTrack(const G4Track*, const TrackStatus&) const;
38 
39  const G4VPhysicalVolume* tracker{nullptr};
40  const G4VPhysicalVolume* calo{nullptr};
42  const G4LogicalVolume* m_CMStoZDC{nullptr};
43  const G4Region* m_ZDCRegion{nullptr};
46  double maxTrackTime;
49 
50  unsigned int numberTimes;
51  unsigned int numberEkins;
52  unsigned int numberPart;
53  unsigned int ndeadRegions;
54  unsigned int nWarnings{0};
56 
57  bool initialized{false};
58  bool killBeamPipe{false};
60  bool hasWatcher;
61  bool dd4hep_;
62 
63  std::vector<double> maxTrackTimes, ekinMins;
64  std::vector<std::string> maxTimeNames, ekinNames, ekinParticles;
65  std::vector<std::string> deadRegionNames;
66  std::vector<const G4Region*> maxTimeRegions;
67  std::vector<const G4Region*> deadRegions;
68  std::vector<G4LogicalVolume*> ekinVolumes;
69  std::vector<int> ekinPDG;
71 };
72 
73 inline bool SteppingAction::isInsideDeadRegion(const G4Region* reg) const {
74  bool res = false;
75  for (auto const& region : deadRegions) {
76  if (reg == region) {
77  res = true;
78  break;
79  }
80  }
81  return res;
82 }
83 
84 inline bool SteppingAction::isOutOfTimeWindow(const G4Region* reg, const double& time) const {
85  double tofM = maxTrackTime;
86  for (unsigned int i = 0; i < numberTimes; ++i) {
87  if (reg == maxTimeRegions[i]) {
88  tofM = maxTrackTimes[i];
89  break;
90  }
91  }
92  return (time > tofM);
93 }
94 
95 inline bool SteppingAction::isForZDC(const G4LogicalVolume* lv, int pdg) const {
96  return (m_CMStoZDCtransport && lv == m_CMStoZDC && (pdg == 22 || pdg == 2112));
97 }
98 
99 #endif
bool m_CMStoZDCtransport
const G4LogicalVolume * m_CMStoZDC
void UserSteppingAction(const G4Step *aStep) final
const G4VPhysicalVolume * tracker
std::vector< int > ekinPDG
std::vector< const G4Region * > deadRegions
double theCriticalDensity
SimActivityRegistry::G4StepSignal m_g4StepSignal
std::string cms2ZDCName_
unsigned int numberPart
bool isOutOfTimeWindow(const G4Region *reg, const double &time) const
const CMSSteppingVerbose * steppingVerbose
unsigned int numberEkins
std::string trackerName_
bool isForZDC(const G4LogicalVolume *lv, int pdg) const
Definition: Electron.h:6
G4int maxNumberOfSteps
void PrintKilledTrack(const G4Track *, const TrackStatus &) const
std::vector< std::string > deadRegionNames
bool isLowEnergy(const G4LogicalVolume *, const G4Track *) const
unsigned int numberTimes
std::vector< double > maxTrackTimes
bool isInsideDeadRegion(const G4Region *reg) const
std::vector< G4LogicalVolume * > ekinVolumes
double theCriticalEnergyForVacuum
const G4Region * m_ZDCRegion
double maxZCentralCMS
std::vector< double > ekinMins
std::vector< std::string > maxTimeNames
std::vector< std::string > ekinNames
double maxTrackTimeForward
SteppingAction(const CMSSteppingVerbose *, const edm::ParameterSet &, bool, bool)
unsigned int ndeadRegions
std::string caloName_
~SteppingAction() override=default
std::vector< std::string > ekinParticles
TrackStatus
Definition: Common.h:9
std::vector< const G4Region * > maxTimeRegions
unsigned int nWarnings