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 hasW);
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 
60  std::vector<double> maxTrackTimes, ekinMins;
61  std::vector<std::string> maxTimeNames, ekinNames, ekinParticles;
62  std::vector<std::string> deadRegionNames;
63  std::vector<const G4Region*> maxTimeRegions;
64  std::vector<const G4Region*> deadRegions;
65  std::vector<G4LogicalVolume*> ekinVolumes;
66  std::vector<int> ekinPDG;
67 };
68 
69 inline bool Phase2SteppingAction::isInsideDeadRegion(const G4Region* reg) const {
70  bool res = false;
71  for (auto& region : deadRegions) {
72  if (reg == region) {
73  res = true;
74  break;
75  }
76  }
77  return res;
78 }
79 
80 inline bool Phase2SteppingAction::isOutOfTimeWindow(const G4Region* reg, const double& time) const {
81  double tofM = maxTrackTime;
82  for (unsigned int i = 0; i < numberTimes; ++i) {
83  if (reg == maxTimeRegions[i]) {
84  tofM = maxTrackTimes[i];
85  break;
86  }
87  }
88  return (time > tofM);
89 }
90 
91 #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 hasW)
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