ATLAS Offline Software
Loading...
Searching...
No Matches
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
21class TProfile;
22class TProfile2D;
23
24
25namespace 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
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
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
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