ATLAS Offline Software
LengthIntegrator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef G4UserActions_LengthIntegrator_H
6 #define G4UserActions_LengthIntegrator_H
7 
8 #include "GaudiKernel/ITHistSvc.h"
9 #include "GaudiKernel/ServiceHandle.h"
10 
11 #include "G4Pow.hh"
12 #include "TString.h"
13 
14 #include "G4UserEventAction.hh"
15 #include "G4UserSteppingAction.hh"
16 //#include "AthenaBaseComps/AthMessaging.h"
17 #include <string>
18 #include <map>
19 
20 // Forward declarations
21 class TProfile;
22 class TProfile2D;
23 
24 
25 namespace G4UA
26 {
27 
41  class LengthIntegrator final : public G4UserEventAction,
42  public G4UserSteppingAction
43  {
44 
45  public:
46 
48  LengthIntegrator(const std::string& histSvcName, bool doHistos);
49 
52 
55  virtual void BeginOfEventAction(const G4Event*) override;
56 
58  virtual void EndOfEventAction(const G4Event*) override;
59 
61  virtual void UserSteppingAction(const G4Step*) override;
62 
63  private:
64 
65  // Holder for G4 math tools
66  G4Pow* m_g4pow;
67 
68  //Tree for material information
69  TTree* m_tree;
70 
71  //Tree Branches
72  int m_genNPart = 0;
73  float m_genEta = 0.0F;
74  float m_genPhi = 0.0F;
75  float m_genZ = 0.0F;
76  float m_genR = 0.0F;
77 
78  //X0 Branches
79  float m_total_X0 = 0.0F;
80  float m_total_L0 = 0.0F;
81 
82  std::vector<double> m_collected_X0;
83  std::vector<double> m_collected_L0;
84 
85  std::vector<float> m_collected_hitr;
86  std::vector<float> m_collected_hitx;
87  std::vector<float> m_collected_hity;
88  std::vector<float> m_collected_hitz;
89 
90  std::vector<float> m_collected_outhitr;
91  std::vector<float> m_collected_outhitx;
92  std::vector<float> m_collected_outhity;
93  std::vector<float> m_collected_outhitz;
94 
95  std::vector<float> m_collected_density;
96  std::vector<std::string> m_collected_material;
97  std::vector<std::string> m_collected_volume;
98 
99  std::vector<std::string> m_collected_groupedmaterial;
100  std::vector<std::string> m_collected_volumetype;
101 
103  bool m_splitPP1;
104 
105  void fillNtuple();
106  std::string getMaterialClassification(const std::string& name);
107  std::string getVolumeType(const std::string& s);
108 
109  // Add elements and values into the map
110  void addToDetThickMap(const std::string&, double, double);
111 
113  void regAndFillHist(const std::string&, const std::pair<double, double>&);
114 
117  TProfile2D* getOrCreateProfile(const std::string& regName, const TString& histoname, const TString& xtitle, int nbinsx, float xmin, float xmax,const TString& ytitle, int nbinsy,float ymin, float ymax,const TString& ztitle);
118 
121 
122  //Do we create histograms
124 
126  double m_etaPrimary;
128  double m_phiPrimary;
129 
131  std::map<std::string, std::pair<double, double> > m_detThickMap;
132 
134  TProfile2D* m_rzProfRL;
136  std::map<std::string, TProfile*> m_etaMapRL;
138  std::map<std::string, TProfile*> m_phiMapRL;
139 
140 
141 
143  TProfile2D* m_rzProfIL;
145  std::map<std::string, TProfile*> m_etaMapIL;
147  std::map<std::string, TProfile*> m_phiMapIL;
148 
149  // 2D plots of rad-length and int-length
150  std::map<std::string,TProfile2D*,std::less<std::string> > m_rzMapRL;
151  std::map<std::string,TProfile2D*,std::less<std::string> > m_xyMapRL;
152 
153  std::map<std::string,TProfile2D*,std::less<std::string> > m_rzMapIL;
154  std::map<std::string,TProfile2D*,std::less<std::string> > m_xyMapIL;
155 
156  }; // class LengthIntegrator
157 
158 } // namespace G4UA
159 
160 #endif
G4UA::LengthIntegrator::m_etaMapIL
std::map< std::string, TProfile * > m_etaMapIL
Int-length profile hist in eta.
Definition: LengthIntegrator.h:145
G4UA::LengthIntegrator::m_splitPP1
bool m_splitPP1
Definition: LengthIntegrator.h:103
ymin
double ymin
Definition: listroot.cxx:63
G4UA::LengthIntegrator::m_collected_density
std::vector< float > m_collected_density
Definition: LengthIntegrator.h:95
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
G4UA::LengthIntegrator::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override
Called at beginning of G4 event to cache some details about the current primary vertex and particle.
Definition: LengthIntegrator.cxx:173
G4UA::LengthIntegrator::m_collected_X0
std::vector< double > m_collected_X0
Definition: LengthIntegrator.h:82
G4UA::LengthIntegrator::m_rzMapIL
std::map< std::string, TProfile2D *, std::less< std::string > > m_rzMapIL
Definition: LengthIntegrator.h:153
G4UA
for nSW
Definition: CalibrationDefaultProcessing.h:19
G4UA::LengthIntegrator::m_detThickMap
std::map< std::string, std::pair< double, double > > m_detThickMap
Map of detector thickness measurements for current event.
Definition: LengthIntegrator.h:131
G4UA::LengthIntegrator::m_phiMapIL
std::map< std::string, TProfile * > m_phiMapIL
Int-length profile hist in phi.
Definition: LengthIntegrator.h:147
G4UA::LengthIntegrator::m_rzMapRL
std::map< std::string, TProfile2D *, std::less< std::string > > m_rzMapRL
Definition: LengthIntegrator.h:150
G4UA::LengthIntegrator::m_genNPart
int m_genNPart
Definition: LengthIntegrator.h:72
G4UA::LengthIntegrator::getOrCreateProfile
TProfile2D * getOrCreateProfile(const std::string &regName, const TString &histoname, const TString &xtitle, int nbinsx, float xmin, float xmax, const TString &ytitle, int nbinsy, float ymin, float ymax, const TString &ztitle)
this method checks if a histo is on THsvc already and caches a local pointer to it if the histo is no...
Definition: LengthIntegrator.cxx:489
G4UA::LengthIntegrator::m_collected_volumetype
std::vector< std::string > m_collected_volumetype
Definition: LengthIntegrator.h:100
G4UA::LengthIntegrator::m_genZ
float m_genZ
Definition: LengthIntegrator.h:75
G4UA::LengthIntegrator::addToDetThickMap
void addToDetThickMap(const std::string &, double, double)
Definition: LengthIntegrator.cxx:516
G4UA::LengthIntegrator::m_etaPrimary
double m_etaPrimary
Cached eta of the current primary.
Definition: LengthIntegrator.h:126
G4UA::LengthIntegrator::m_etaMapRL
std::map< std::string, TProfile * > m_etaMapRL
Rad-length profile hist in eta.
Definition: LengthIntegrator.h:136
G4UA::LengthIntegrator::m_genEta
float m_genEta
Definition: LengthIntegrator.h:73
G4UA::LengthIntegrator::m_collected_hitx
std::vector< float > m_collected_hitx
Definition: LengthIntegrator.h:86
G4UA::LengthIntegrator::regAndFillHist
void regAndFillHist(const std::string &, const std::pair< double, double > &)
Setup one set of measurement hists for a detector name.
Definition: LengthIntegrator.cxx:530
G4UA::LengthIntegrator
A user action used to evaluate thickness of all detectors traversed by outgoing particles.
Definition: LengthIntegrator.h:43
G4UA::LengthIntegrator::m_rzProfIL
TProfile2D * m_rzProfIL
Int-length profile hist in R-Z.
Definition: LengthIntegrator.h:143
G4UA::LengthIntegrator::m_genR
float m_genR
Definition: LengthIntegrator.h:76
G4UA::LengthIntegrator::m_hSvc
ServiceHandle< ITHistSvc > m_hSvc
Handle to the histogram service.
Definition: LengthIntegrator.h:120
G4UA::LengthIntegrator::getVolumeType
std::string getVolumeType(const std::string &s)
Definition: LengthIntegrator.cxx:373
xmin
double xmin
Definition: listroot.cxx:60
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
G4UA::LengthIntegrator::m_total_X0
float m_total_X0
Definition: LengthIntegrator.h:79
G4UA::LengthIntegrator::m_xyMapRL
std::map< std::string, TProfile2D *, std::less< std::string > > m_xyMapRL
Definition: LengthIntegrator.h:151
G4UA::LengthIntegrator::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Called at every particle step to accumulate thickness.
Definition: LengthIntegrator.cxx:423
G4UA::LengthIntegrator::m_rzProfRL
TProfile2D * m_rzProfRL
Rad-length profile hist in R-Z.
Definition: LengthIntegrator.h:134
G4UA::LengthIntegrator::m_collected_hity
std::vector< float > m_collected_hity
Definition: LengthIntegrator.h:87
G4UA::LengthIntegrator::m_collected_hitz
std::vector< float > m_collected_hitz
Definition: LengthIntegrator.h:88
G4UA::LengthIntegrator::m_splitModerator
bool m_splitModerator
Definition: LengthIntegrator.h:102
G4UA::LengthIntegrator::m_collected_outhitr
std::vector< float > m_collected_outhitr
Definition: LengthIntegrator.h:90
G4UA::LengthIntegrator::m_collected_outhitz
std::vector< float > m_collected_outhitz
Definition: LengthIntegrator.h:93
G4UA::LengthIntegrator::m_g4pow
G4Pow * m_g4pow
Definition: LengthIntegrator.h:66
G4UA::LengthIntegrator::m_collected_outhitx
std::vector< float > m_collected_outhitx
Definition: LengthIntegrator.h:91
PixelAthHitMonAlgCfg.histoname
string histoname
Definition: PixelAthHitMonAlgCfg.py:139
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
G4UA::LengthIntegrator::m_phiMapRL
std::map< std::string, TProfile * > m_phiMapRL
Rad-length profile hist in phi.
Definition: LengthIntegrator.h:138
G4UA::LengthIntegrator::m_collected_L0
std::vector< double > m_collected_L0
Definition: LengthIntegrator.h:83
G4UA::LengthIntegrator::m_doHistos
bool m_doHistos
Definition: LengthIntegrator.h:123
G4UA::LengthIntegrator::m_collected_outhity
std::vector< float > m_collected_outhity
Definition: LengthIntegrator.h:92
G4UA::LengthIntegrator::m_xyMapIL
std::map< std::string, TProfile2D *, std::less< std::string > > m_xyMapIL
Definition: LengthIntegrator.h:154
G4UA::LengthIntegrator::fillNtuple
void fillNtuple()
Definition: LengthIntegrator.cxx:391
G4UA::LengthIntegrator::m_total_L0
float m_total_L0
Definition: LengthIntegrator.h:80
G4UA::LengthIntegrator::m_tree
TTree * m_tree
Definition: LengthIntegrator.h:69
G4UA::LengthIntegrator::m_collected_material
std::vector< std::string > m_collected_material
Definition: LengthIntegrator.h:96
G4UA::LengthIntegrator::LengthIntegrator
LengthIntegrator(const std::string &histSvcName, bool doHistos)
Constructor takes the name of the histogram service as argument.
Definition: LengthIntegrator.cxx:100
G4UA::LengthIntegrator::m_collected_groupedmaterial
std::vector< std::string > m_collected_groupedmaterial
Definition: LengthIntegrator.h:99
plotting.yearwise_efficiency.xtitle
string xtitle
Definition: yearwise_efficiency.py:32
G4UA::LengthIntegrator::m_collected_volume
std::vector< std::string > m_collected_volume
Definition: LengthIntegrator.h:97
xmax
double xmax
Definition: listroot.cxx:61
G4UA::LengthIntegrator::LengthIntegrator
LengthIntegrator(const LengthIntegrator &)=delete
G4UA::LengthIntegrator::getMaterialClassification
std::string getMaterialClassification(const std::string &name)
Definition: LengthIntegrator.cxx:229
G4UA::LengthIntegrator::operator=
LengthIntegrator & operator=(const LengthIntegrator &)=delete
G4UA::LengthIntegrator::m_phiPrimary
double m_phiPrimary
Cached phi of the current primary.
Definition: LengthIntegrator.h:128
G4UA::LengthIntegrator::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Called at end of G4 event to finalize measurements and fill hists.
Definition: LengthIntegrator.cxx:197
ymax
double ymax
Definition: listroot.cxx:64
G4UA::LengthIntegrator::m_collected_hitr
std::vector< float > m_collected_hitr
Definition: LengthIntegrator.h:85
ServiceHandle< ITHistSvc >
G4UA::LengthIntegrator::m_genPhi
float m_genPhi
Definition: LengthIntegrator.h:74