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* tracker{nullptr};
39  const G4VPhysicalVolume* calo{nullptr};
40  const G4VPhysicalVolume* btl{nullptr};
44  double maxTrackTime;
47 
48  unsigned int numberTimes;
49  unsigned int numberEkins;
50  unsigned int numberPart;
51  unsigned int ndeadRegions;
52  unsigned int nWarnings{0};
54 
55  bool initialized{false};
56  bool killBeamPipe{false};
57  bool hasWatcher;
58 
59  std::vector<double> maxTrackTimes, ekinMins;
60  std::vector<std::string> maxTimeNames, ekinNames, ekinParticles;
61  std::vector<std::string> deadRegionNames;
62  std::vector<const G4Region*> maxTimeRegions;
63  std::vector<const G4Region*> deadRegions;
64  std::vector<G4LogicalVolume*> ekinVolumes;
65  std::vector<int> ekinPDG;
66 };
67 
68 inline bool Phase2SteppingAction::isInsideDeadRegion(const G4Region* reg) const {
69  bool res = false;
70  for (auto& region : deadRegions) {
71  if (reg == region) {
72  res = true;
73  break;
74  }
75  }
76  return res;
77 }
78 
79 inline bool Phase2SteppingAction::isOutOfTimeWindow(const G4Region* reg, const double& time) const {
80  double tofM = maxTrackTime;
81  for (unsigned int i = 0; i < numberTimes; ++i) {
82  if (reg == maxTimeRegions[i]) {
83  tofM = maxTrackTimes[i];
84  break;
85  }
86  }
87  return (time > tofM);
88 }
89 
90 #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
std::vector< double > maxTrackTimes
void UserSteppingAction(const G4Step *aStep) final