CMS 3D CMS Logo

SteppingAction.h
Go to the documentation of this file.
1 #ifndef SimG4Core_SteppingAction_H
2 #define SimG4Core_SteppingAction_H
3 
6 
7 #include "G4LogicalVolume.hh"
8 #include "G4Region.hh"
9 #include "G4UserSteppingAction.hh"
10 #include "G4VPhysicalVolume.hh"
11 #include "G4VTouchable.hh"
12 #include "G4Track.hh"
13 
14 #include <string>
15 #include <vector>
16 
17 class EventAction;
18 class CMSSteppingVerbose;
19 
21  sAlive = 0,
30 };
31 
32 class SteppingAction : public G4UserSteppingAction {
33 public:
34  explicit SteppingAction(EventAction* ea, const edm::ParameterSet& ps, const CMSSteppingVerbose*, bool hasW);
35  ~SteppingAction() override;
36 
37  void UserSteppingAction(const G4Step* aStep) final;
38 
40 
41 private:
42  bool initPointer();
43 
44  inline bool isInsideDeadRegion(const G4Region* reg) const;
45  inline bool isOutOfTimeWindow(const G4Region* reg, const double& time) const;
46  inline bool isForZDC(const G4LogicalVolume* lv, int pdg) const;
47 
48  bool isLowEnergy(const G4LogicalVolume*, const G4Track*) const;
49  void PrintKilledTrack(const G4Track*, const TrackStatus&) const;
50 
52  const G4VPhysicalVolume *tracker, *calo;
54  const G4LogicalVolume* m_CMStoZDC{nullptr};
57  double maxTrackTime;
60 
61  unsigned int numberTimes;
62  unsigned int numberEkins;
63  unsigned int numberPart;
64  unsigned int ndeadRegions;
65  unsigned int nWarnings;
67 
71  bool hasWatcher;
72 
73  std::vector<double> maxTrackTimes, ekinMins;
74  std::vector<std::string> maxTimeNames, ekinNames, ekinParticles;
75  std::vector<std::string> deadRegionNames;
76  std::vector<const G4Region*> maxTimeRegions;
77  std::vector<const G4Region*> deadRegions;
78  std::vector<G4LogicalVolume*> ekinVolumes;
79  std::vector<int> ekinPDG;
80 };
81 
82 inline bool SteppingAction::isInsideDeadRegion(const G4Region* reg) const {
83  bool res = false;
84  for (auto& region : deadRegions) {
85  if (reg == region) {
86  res = true;
87  break;
88  }
89  }
90  return res;
91 }
92 
93 inline bool SteppingAction::isOutOfTimeWindow(const G4Region* reg, const double& time) const {
94  double tofM = maxTrackTime;
95  for (unsigned int i = 0; i < numberTimes; ++i) {
96  if (reg == maxTimeRegions[i]) {
97  tofM = maxTrackTimes[i];
98  break;
99  }
100  }
101  return (time > tofM);
102 }
103 
104 inline bool SteppingAction::isForZDC(const G4LogicalVolume* lv, int pdg) const {
105  return (m_CMStoZDCtransport && lv == m_CMStoZDC && (pdg == 22 || pdg == 2112));
106 }
107 
108 #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
~SteppingAction() override
unsigned int numberPart
bool isOutOfTimeWindow(const G4Region *reg, const double &time) const
const CMSSteppingVerbose * steppingVerbose
unsigned int numberEkins
bool isForZDC(const G4LogicalVolume *lv, int pdg) const
Definition: Electron.h:6
TrackStatus
G4int maxNumberOfSteps
void PrintKilledTrack(const G4Track *, const TrackStatus &) const
std::vector< std::string > deadRegionNames
const G4VPhysicalVolume * calo
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
EventAction * eventAction_
double maxZCentralCMS
std::vector< double > ekinMins
std::vector< std::string > maxTimeNames
std::vector< std::string > ekinNames
double maxTrackTimeForward
SteppingAction(EventAction *ea, const edm::ParameterSet &ps, const CMSSteppingVerbose *, bool hasW)
unsigned int ndeadRegions
std::vector< std::string > ekinParticles
std::vector< const G4Region * > maxTimeRegions
unsigned int nWarnings