ATLAS Offline Software
Loading...
Searching...
No Matches
LengthIntegrator.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 "G4UserEventAction.hh"
12#include "G4UserSteppingAction.hh"
13#include <string>
14#include <map>
15
16// Forward declarations
17class TProfile;
18class TProfile2D;
19class TString;
20class G4Pow;
21
22
23namespace G4UA
24{
25
39 class LengthIntegrator final : public G4UserEventAction,
40 public G4UserSteppingAction
41 {
42
43 public:
44
46 LengthIntegrator(const std::string& histSvcName, bool doHistos);
47
50
53 virtual void BeginOfEventAction(const G4Event*) override;
54
56 virtual void EndOfEventAction(const G4Event*) override;
57
59 virtual void UserSteppingAction(const G4Step*) override;
60
61 private:
62
63 // Holder for G4 math tools
64 G4Pow* m_g4pow;
65
66 //Tree for material information
67 TTree* m_tree;
68
69 //Tree Branches
70 int m_genNPart = 0;
71 float m_genEta = 0.0F;
72 float m_genPhi = 0.0F;
73 float m_genZ = 0.0F;
74 float m_genR = 0.0F;
75
76 //X0 Branches
77 float m_total_X0 = 0.0F;
78 float m_total_L0 = 0.0F;
79
80 std::vector<double> m_collected_X0;
81 std::vector<double> m_collected_L0;
82
83 std::vector<float> m_collected_hitr;
84 std::vector<float> m_collected_hitx;
85 std::vector<float> m_collected_hity;
86 std::vector<float> m_collected_hitz;
87
88 std::vector<float> m_collected_outhitr;
89 std::vector<float> m_collected_outhitx;
90 std::vector<float> m_collected_outhity;
91 std::vector<float> m_collected_outhitz;
92
93 std::vector<float> m_collected_density;
94 std::vector<std::string> m_collected_material;
95 std::vector<std::string> m_collected_volume;
96
97 std::vector<std::string> m_collected_groupedmaterial;
98 std::vector<std::string> m_collected_volumetype;
99
102
103 void fillNtuple();
104 std::string getMaterialClassification(const std::string& name);
105 std::string getVolumeType(const std::string& s);
106
107 // Add elements and values into the map
108 void addToDetThickMap(const std::string&, double, double);
109
111 void regAndFillHist(const std::string&, const std::pair<double, double>&);
112
115 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);
116
119
120 //Do we create histograms
122
127
129 std::map<std::string, std::pair<double, double> > m_detThickMap;
130
132 TProfile2D* m_rzProfRL;
134 std::map<std::string, TProfile*> m_etaMapRL;
136 std::map<std::string, TProfile*> m_phiMapRL;
137
138
139
141 TProfile2D* m_rzProfIL;
143 std::map<std::string, TProfile*> m_etaMapIL;
145 std::map<std::string, TProfile*> m_phiMapIL;
146
147 // 2D plots of rad-length and int-length
148 std::map<std::string,TProfile2D*,std::less<std::string> > m_rzMapRL;
149 std::map<std::string,TProfile2D*,std::less<std::string> > m_xyMapRL;
150
151 std::map<std::string,TProfile2D*,std::less<std::string> > m_rzMapIL;
152 std::map<std::string,TProfile2D*,std::less<std::string> > m_xyMapIL;
153
154 }; // class LengthIntegrator
155
156} // namespace G4UA
157
158#endif
std::vector< float > m_collected_outhitz
std::map< std::string, TProfile2D *, std::less< std::string > > m_xyMapRL
std::map< std::string, TProfile2D *, std::less< std::string > > m_rzMapRL
std::string getVolumeType(const std::string &s)
std::vector< double > m_collected_L0
std::vector< double > m_collected_X0
TProfile2D * m_rzProfRL
Rad-length profile hist in R-Z.
std::vector< float > m_collected_outhity
double m_phiPrimary
Cached phi of the current primary.
std::vector< float > m_collected_density
std::map< std::string, TProfile * > m_phiMapIL
Int-length profile hist in phi.
std::vector< float > m_collected_hitr
std::vector< std::string > m_collected_groupedmaterial
std::string getMaterialClassification(const std::string &name)
void regAndFillHist(const std::string &, const std::pair< double, double > &)
Setup one set of measurement hists for a detector name.
LengthIntegrator(const LengthIntegrator &)=delete
std::vector< float > m_collected_outhitr
std::vector< float > m_collected_outhitx
virtual void EndOfEventAction(const G4Event *) override
Called at end of G4 event to finalize measurements and fill hists.
std::map< std::string, TProfile * > m_phiMapRL
Rad-length profile hist in phi.
LengthIntegrator(const std::string &histSvcName, bool doHistos)
Constructor takes the name of the histogram service as argument.
double m_etaPrimary
Cached eta of the current primary.
std::vector< float > m_collected_hitz
LengthIntegrator & operator=(const LengthIntegrator &)=delete
std::map< std::string, TProfile2D *, std::less< std::string > > m_xyMapIL
void addToDetThickMap(const std::string &, double, double)
std::vector< std::string > m_collected_volumetype
TProfile2D * m_rzProfIL
Int-length profile hist in R-Z.
std::map< std::string, TProfile * > m_etaMapRL
Rad-length profile hist in eta.
std::vector< std::string > m_collected_volume
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...
virtual void BeginOfEventAction(const G4Event *) override
Called at beginning of G4 event to cache some details about the current primary vertex and particle.
std::map< std::string, TProfile * > m_etaMapIL
Int-length profile hist in eta.
virtual void UserSteppingAction(const G4Step *) override
Called at every particle step to accumulate thickness.
ServiceHandle< ITHistSvc > m_hSvc
Handle to the histogram service.
std::map< std::string, std::pair< double, double > > m_detThickMap
Map of detector thickness measurements for current event.
std::map< std::string, TProfile2D *, std::less< std::string > > m_rzMapIL
std::vector< float > m_collected_hitx
std::vector< std::string > m_collected_material
std::vector< float > m_collected_hity
double xmax
Definition listroot.cxx:61
double ymin
Definition listroot.cxx:63
double xmin
Definition listroot.cxx:60
double ymax
Definition listroot.cxx:64