CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
20 enum TrackStatus {
21  sAlive = 0,
24  sOutOfTime = 3,
25  sLowEnergy = 4,
27 };
28 
29 class SteppingAction: public G4UserSteppingAction {
30 
31 public:
32  explicit SteppingAction(EventAction * ea, const edm::ParameterSet & ps,
33  const CMSSteppingVerbose*, bool hasW);
34  virtual ~SteppingAction();
35 
36  virtual void UserSteppingAction(const G4Step * aStep) final;
37 
39 
40 private:
41 
42  bool initPointer();
43 
44  bool isInsideDeadRegion(const G4Region* reg) const;
45  bool isOutOfTimeWindow(G4Track* theTrack, const G4Region* reg) const;
46  bool isThisVolume(const G4VTouchable* touch, const G4VPhysicalVolume* pv) const;
47 
48  bool isLowEnergy(const G4Step * aStep) const;
49  void PrintKilledTrack(const G4Track*, const TrackStatus&) const;
50 
52  const G4VPhysicalVolume *tracker, *calo;
56  double maxTrackTime;
57  std::vector<double> maxTrackTimes, ekinMins;
58  std::vector<std::string> maxTimeNames, ekinNames, ekinParticles;
59  std::vector<std::string> deadRegionNames;
60  std::vector<const G4Region*> maxTimeRegions;
61  std::vector<const G4Region*> deadRegions;
62  std::vector<G4LogicalVolume*> ekinVolumes;
63  std::vector<int> ekinPDG;
64  unsigned int numberTimes;
65  unsigned int numberEkins;
66  unsigned int numberPart;
67  unsigned int ndeadRegions;
68 
71  bool hasWatcher;
72 };
73 
74 inline bool SteppingAction::isInsideDeadRegion(const G4Region* reg) const
75 {
76  bool res = false;
77  for(unsigned int i=0; i<ndeadRegions; ++i) {
78  if(reg == deadRegions[i]) {
79  res = true;
80  break;
81  }
82  }
83  return res;
84 }
85 
86 inline bool
87 SteppingAction::isOutOfTimeWindow(G4Track* theTrack, const G4Region* reg) const
88 {
89  double tofM = maxTrackTime;
90  for (unsigned int i=0; i<numberTimes; ++i) {
91  if (reg == maxTimeRegions[i]) {
92  tofM = maxTrackTimes[i];
93  break;
94  }
95  }
96  return (theTrack->GetGlobalTime() > tofM) ? true : false;
97 }
98 
99 inline bool SteppingAction::isThisVolume(const G4VTouchable* touch,
100  const G4VPhysicalVolume* pv) const
101 {
102  int level = (touch->GetHistoryDepth())+1;
103  return (level >= 3) ? (touch->GetVolume(level - 3) == pv) : false;
104 }
105 
106 #endif
virtual ~SteppingAction()
int i
Definition: DBlmapReader.cc:9
virtual void UserSteppingAction(const G4Step *aStep) final
const G4VPhysicalVolume * tracker
std::vector< int > ekinPDG
std::vector< const G4Region * > deadRegions
double theCriticalDensity
SimActivityRegistry::G4StepSignal m_g4StepSignal
unsigned int numberPart
const CMSSteppingVerbose * steppingVerbose
bool isOutOfTimeWindow(G4Track *theTrack, const G4Region *reg) const
unsigned int numberEkins
TrackStatus
std::vector< std::string > deadRegionNames
const G4VPhysicalVolume * calo
unsigned int numberTimes
std::vector< double > maxTrackTimes
std::vector< G4LogicalVolume * > ekinVolumes
double theCriticalEnergyForVacuum
EventAction * eventAction_
std::vector< double > ekinMins
std::vector< std::string > maxTimeNames
std::vector< std::string > ekinNames
bool isLowEnergy(const G4Step *aStep) const
bool isInsideDeadRegion(const G4Region *reg) const
tuple level
Definition: testEve_cfg.py:34
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