CMS 3D CMS Logo

Phase2SteppingAction.h
Go to the documentation of this file.
1 #ifndef SimG4Core_Phase2SteppingAction_H
2 #define SimG4Core_Phase2SteppingAction_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 Phase2SteppingAction : public G4UserSteppingAction {
21 public:
22  explicit Phase2SteppingAction(const CMSSteppingVerbose*, const edm::ParameterSet&, bool, bool);
23  ~Phase2SteppingAction() 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 
35  bool isLowEnergy(const G4LogicalVolume*, const G4Track*) const;
36  void PrintKilledTrack(const G4Track*, const TrackStatus&) const;
37 
38  const G4VPhysicalVolume* cmse{nullptr};
39  const G4VPhysicalVolume* tracker{nullptr};
40  const G4VPhysicalVolume* calo{nullptr};
41  const G4VPhysicalVolume* btl{nullptr};
45  double maxTrackTime;
48 
49  unsigned int numberTimes;
50  unsigned int numberEkins;
51  unsigned int numberPart;
52  unsigned int ndeadRegions;
53  unsigned int nWarnings{0};
55 
56  bool initialized{false};
57  bool killBeamPipe{false};
58  bool hasWatcher;
59  bool dd4hep_;
60 
61  std::vector<double> maxTrackTimes, ekinMins;
62  std::vector<std::string> maxTimeNames, ekinNames, ekinParticles;
63  std::vector<std::string> deadRegionNames;
64  std::vector<const G4Region*> maxTimeRegions;
65  std::vector<const G4Region*> deadRegions;
66  std::vector<G4LogicalVolume*> ekinVolumes;
67  std::vector<int> ekinPDG;
69 };
70 
71 inline bool Phase2SteppingAction::isInsideDeadRegion(const G4Region* reg) const {
72  bool res = false;
73  for (auto& region : deadRegions) {
74  if (reg == region) {
75  res = true;
76  break;
77  }
78  }
79  return res;
80 }
81 
82 inline bool Phase2SteppingAction::isOutOfTimeWindow(const G4Region* reg, const double& time) const {
83  double tofM = maxTrackTime;
84  for (unsigned int i = 0; i < numberTimes; ++i) {
85  if (reg == maxTimeRegions[i]) {
86  tofM = maxTrackTimes[i];
87  break;
88  }
89  }
90  return (time > tofM);
91 }
92 
93 #endif
const CMSSteppingVerbose * steppingVerbose
std::vector< std::string > maxTimeNames
bool isOutOfTimeWindow(const G4Region *reg, const double &time) const
SimActivityRegistry::G4StepSignal m_g4StepSignal
Definition: Electron.h:6
Phase2SteppingAction(const CMSSteppingVerbose *, const edm::ParameterSet &, bool, bool)
std::vector< std::string > ekinNames
const G4VPhysicalVolume * tracker
std::vector< int > ekinPDG
std::vector< G4LogicalVolume * > ekinVolumes
const G4VPhysicalVolume * btl
std::vector< std::string > ekinParticles
void PrintKilledTrack(const G4Track *, const TrackStatus &) const
~Phase2SteppingAction() override=default
std::vector< double > ekinMins
std::vector< std::string > deadRegionNames
std::vector< const G4Region * > maxTimeRegions
bool isLowEnergy(const G4LogicalVolume *, const G4Track *) const
bool isInsideDeadRegion(const G4Region *reg) const
std::vector< const G4Region * > deadRegions
TrackStatus
Definition: Common.h:9
const G4VPhysicalVolume * cmse
std::vector< double > maxTrackTimes
void UserSteppingAction(const G4Step *aStep) final