CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 isThisVolume(const G4VTouchable* touch, const G4VPhysicalVolume* pv) const;
47 
48  bool isLowEnergy(const G4LogicalVolume*, const G4Track*) const;
49  void PrintKilledTrack(const G4Track*, const TrackStatus&) const;
50 
52  const G4VPhysicalVolume *tracker, *calo;
56  double maxTrackTime;
59 
60  unsigned int numberTimes;
61  unsigned int numberEkins;
62  unsigned int numberPart;
63  unsigned int ndeadRegions;
64  unsigned int nWarnings;
66 
69  bool hasWatcher;
70 
71  std::vector<double> maxTrackTimes, ekinMins;
72  std::vector<std::string> maxTimeNames, ekinNames, ekinParticles;
73  std::vector<std::string> deadRegionNames;
74  std::vector<const G4Region*> maxTimeRegions;
75  std::vector<const G4Region*> deadRegions;
76  std::vector<G4LogicalVolume*> ekinVolumes;
77  std::vector<int> ekinPDG;
78 };
79 
80 inline bool SteppingAction::isInsideDeadRegion(const G4Region* reg) const {
81  bool res = false;
82  for (auto& region : deadRegions) {
83  if (reg == region) {
84  res = true;
85  break;
86  }
87  }
88  return res;
89 }
90 
91 inline bool SteppingAction::isOutOfTimeWindow(const G4Region* reg, const double& time) const {
92  double tofM = maxTrackTime;
93  for (unsigned int i = 0; i < numberTimes; ++i) {
94  if (reg == maxTimeRegions[i]) {
95  tofM = maxTrackTimes[i];
96  break;
97  }
98  }
99  return (time > tofM);
100 }
101 
102 inline bool SteppingAction::isThisVolume(const G4VTouchable* touch, const G4VPhysicalVolume* pv) const {
103  int level = (touch->GetHistoryDepth()) + 1;
104  return (level >= 3) ? (touch->GetVolume(level - 3) == pv) : false;
105 }
106 
107 #endif
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
const CMSSteppingVerbose * steppingVerbose
unsigned int numberEkins
bool isLowEnergy(const G4LogicalVolume *, const G4Track *) const
TrackStatus
bool isOutOfTimeWindow(const G4Region *reg, const double &time) const
G4int maxNumberOfSteps
std::vector< std::string > deadRegionNames
const G4VPhysicalVolume * calo
unsigned int numberTimes
std::vector< double > maxTrackTimes
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
bool isInsideDeadRegion(const G4Region *reg) const
tuple level
Definition: testEve_cfg.py:47
SteppingAction(EventAction *ea, const edm::ParameterSet &ps, const CMSSteppingVerbose *, bool hasW)
void PrintKilledTrack(const G4Track *, const TrackStatus &) const
unsigned int ndeadRegions
std::vector< std::string > ekinParticles
bool isThisVolume(const G4VTouchable *touch, const G4VPhysicalVolume *pv) const
std::vector< const G4Region * > maxTimeRegions
unsigned int nWarnings