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 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
personalPlayback.level
level
Definition: personalPlayback.py:22
SteppingAction::maxTimeNames
std::vector< std::string > maxTimeNames
Definition: SteppingAction.h:72
SteppingAction::theCriticalDensity
double theCriticalDensity
Definition: SteppingAction.h:55
mps_fire.i
i
Definition: mps_fire.py:428
EventAction
Definition: EventAction.h:23
SteppingAction::tracker
const G4VPhysicalVolume * tracker
Definition: SteppingAction.h:52
SteppingAction::killBeamPipe
bool killBeamPipe
Definition: SteppingAction.h:68
SteppingAction::maxZCentralCMS
double maxZCentralCMS
Definition: SteppingAction.h:58
SteppingAction::numberPart
unsigned int numberPart
Definition: SteppingAction.h:62
sAlive
Definition: SteppingAction.h:21
protons_cff.time
time
Definition: protons_cff.py:35
SteppingAction
Definition: SteppingAction.h:32
SteppingAction::maxTrackTime
double maxTrackTime
Definition: SteppingAction.h:56
SteppingAction::deadRegionNames
std::vector< std::string > deadRegionNames
Definition: SteppingAction.h:73
CMSSteppingVerbose
Definition: CMSSteppingVerbose.h:25
sKilledByProcess
Definition: SteppingAction.h:22
sLowEnergyInVacuum
Definition: SteppingAction.h:26
SteppingAction::initPointer
bool initPointer()
Definition: SteppingAction.cc:217
SimActivityRegistry.h
SteppingAction::ekinParticles
std::vector< std::string > ekinParticles
Definition: SteppingAction.h:72
TrackStatus
TrackStatus
Definition: SteppingAction.h:20
sNumberOfSteps
Definition: SteppingAction.h:29
SteppingAction::maxTimeRegions
std::vector< const G4Region * > maxTimeRegions
Definition: SteppingAction.h:74
SteppingAction::ekinNames
std::vector< std::string > ekinNames
Definition: SteppingAction.h:72
SteppingAction::theCriticalEnergyForVacuum
double theCriticalEnergyForVacuum
Definition: SteppingAction.h:54
sOutOfTime
Definition: SteppingAction.h:24
SteppingAction::initialized
bool initialized
Definition: SteppingAction.h:67
SteppingAction::maxTrackTimeForward
double maxTrackTimeForward
Definition: SteppingAction.h:57
SteppingAction::PrintKilledTrack
void PrintKilledTrack(const G4Track *, const TrackStatus &) const
Definition: SteppingAction.cc:289
sim_act::Signaler< G4Step >
SteppingAction::isInsideDeadRegion
bool isInsideDeadRegion(const G4Region *reg) const
Definition: SteppingAction.h:80
SteppingAction::numberTimes
unsigned int numberTimes
Definition: SteppingAction.h:60
SteppingAction::steppingVerbose
const CMSSteppingVerbose * steppingVerbose
Definition: SteppingAction.h:53
sDeadRegion
Definition: SteppingAction.h:23
SteppingAction::maxTrackTimes
std::vector< double > maxTrackTimes
Definition: SteppingAction.h:71
edm::ParameterSet
Definition: ParameterSet.h:47
SteppingAction::ndeadRegions
unsigned int ndeadRegions
Definition: SteppingAction.h:63
SteppingAction::calo
const G4VPhysicalVolume * calo
Definition: SteppingAction.h:52
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
SteppingAction::UserSteppingAction
void UserSteppingAction(const G4Step *aStep) final
Definition: SteppingAction.cc:91
SteppingAction::ekinMins
std::vector< double > ekinMins
Definition: SteppingAction.h:71
SteppingAction::~SteppingAction
~SteppingAction() override
Definition: SteppingAction.cc:89
SteppingAction::hasWatcher
bool hasWatcher
Definition: SteppingAction.h:69
res
Definition: Electron.h:6
SteppingAction::isThisVolume
bool isThisVolume(const G4VTouchable *touch, const G4VPhysicalVolume *pv) const
Definition: SteppingAction.h:102
sEnergyDepNaN
Definition: SteppingAction.h:27
SteppingAction::ekinVolumes
std::vector< G4LogicalVolume * > ekinVolumes
Definition: SteppingAction.h:76
SteppingAction::m_g4StepSignal
SimActivityRegistry::G4StepSignal m_g4StepSignal
Definition: SteppingAction.h:39
SteppingAction::isOutOfTimeWindow
bool isOutOfTimeWindow(const G4Region *reg, const double &time) const
Definition: SteppingAction.h:91
SteppingAction::eventAction_
EventAction * eventAction_
Definition: SteppingAction.h:51
SteppingAction::isLowEnergy
bool isLowEnergy(const G4LogicalVolume *, const G4Track *) const
Definition: SteppingAction.cc:200
sLowEnergy
Definition: SteppingAction.h:25
SteppingAction::ekinPDG
std::vector< int > ekinPDG
Definition: SteppingAction.h:77
SteppingAction::SteppingAction
SteppingAction(EventAction *ea, const edm::ParameterSet &ps, const CMSSteppingVerbose *, bool hasW)
Definition: SteppingAction.cc:18
ParameterSet.h
SteppingAction::deadRegions
std::vector< const G4Region * > deadRegions
Definition: SteppingAction.h:75
sVeryForward
Definition: SteppingAction.h:28
SteppingAction::numberEkins
unsigned int numberEkins
Definition: SteppingAction.h:61
SteppingAction::nWarnings
unsigned int nWarnings
Definition: SteppingAction.h:64
SteppingAction::maxNumberOfSteps
G4int maxNumberOfSteps
Definition: SteppingAction.h:65