ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimLayerStudyTool.h
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#ifndef FPGATrackSimLayerStudyTool_H
4#define FPGATrackSimLayerStudyTool_H
5
22
24#include "GaudiKernel/ServiceHandle.h"
25#include "GaudiKernel/ITHistSvc.h"
27
28#include "TGraph.h"
29class TH1D;
30class TH2D;
31
35
37
38
40 {
41 public:
42
44 // AthAlgTool
45
46 FPGATrackSimLayerStudyTool(const std::string &, const std::string &, const IInterface *);
47
48 virtual StatusCode initialize() override;
49
50 // This is done at the start of execution to create all the graphs
51 // ... also stores some of the configuration parameters for later use
52 StatusCode registerHistograms(const FPGATrackSimBinnedHits* binnedhits, bool skipTruth);
55
56 // Simple accessors for directory
57 const std::string dir() const {return m_dir;}
58
59 // Takes the truthtracks as input and parses it into a useful form for later use
60 // (e.g. stores which bin the true track is in)
61 void parseTruthInfo ATLAS_NOT_THREAD_SAFE(std::vector<FPGATrackSimTruthTrack> const & truthtracks);
62 FPGATrackSimBinUtil::IdxSet& truthBin(unsigned stepnum) { return m_truthbin[stepnum]; }
63 std::vector<FPGATrackSimBinUtil::IdxSet>& truthBin() { return m_truthbin; }
64
65 // Fill methods
66 void fillHitLevelInput(const FPGATrackSimHit* hit);
68 void fillBinningSummary ATLAS_NOT_THREAD_SAFE(const std::vector<std::shared_ptr<const FPGATrackSimHit>> &hits);
69
70 // Error Checks
71 void sliceCheck();
72
73 private:
75 // Handles
76 ServiceHandle<ITHistSvc> m_tHistSvc{this, "THistSvc", "THistSvc"};
77
79 // Properties
80 Gaudi::Property<std::string> m_dir{this, "dir", {"/GENSCAN/"}, "String name of output directory"};
81 Gaudi::Property<double> m_phiScale{this, "phiScale", {}, "Scale for Delta Phi variable"};
82 Gaudi::Property<double> m_etaScale{this, "etaScale", {}, "Scale for Delta Eta variable"};
83 Gaudi::Property<double> m_drScale{this, "drScale", {}, "Scale for radius differences"};
84 Gaudi::Property<bool> m_plotAllBins{this, "plotAllBins", {false}, "Default is to plot only truth bin values, this set to plot all bins"};
85
86 Gaudi::Property<double> m_d0pad{this, "D0Pad", 0.0, "Extra phi padding from d0 resolution"};
87 Gaudi::Property<double> m_phipad{this, "PhiPad", 0.0, "Extra phi padding from phi resolution"};
88 Gaudi::Property<double> m_qptpad{this, "QPtPad", 0.0, "Extra phi padding from q/pT resolution"};
89 Gaudi::Property<double> m_z0pad{this, "Z0Pad", 0.0, "Extra eta padding from z0 resolution"};
90 Gaudi::Property<double> m_etapad{this, "EtaPad", 0.0, "Extra eta padding from eta resolution"};
91 Gaudi::Property<std::string> m_layerStudyTreeName{this, "LayerStudyTreeName", "LayerStudy", "Name of the LayerStudy TTree"};
92 Gaudi::Property<std::string> m_truthTreeName{this,"TruthTreeName","TruthTree","Name of the Truth TTree"};
94 // Pointer to binned hits
96
98 // Parsed truth/info
99 bool m_isSingleParticle = false;
100 bool m_truthIsValid = false;
102 std::vector<FPGATrackSimBinUtil::IdxSet> m_truthbin;
104
105 // plots are only filled for the truth bin if single particle sample
106 // this gives the distributions of the cut variables when they are
107 // reconstructed in the right bin
109
110 // this flag governs if pair filter and pairset filter plots filled
111 bool m_binPlotsActive = false;
112
114 // Data Flow Counters
115
117 // Histograms
118 std::vector<TH2D *> m_rZ_allhits;
119 TH1D *m_truthpars_hists[5] = {0, 0, 0, 0, 0};
120
121 TH1D *m_inputHits = 0;
122
124 TH1D *m_binsFilled = 0;
125
126 // residuals and shifts from truth bin center
127 std::vector<TH1D *> m_phiResidual;
128 std::vector<TH1D *> m_etaResidual;
129 std::vector<TH1D *> m_phiTrueBinShift;
130 std::vector<TH1D *> m_etaTrueBinShift;
131 int m_N_ptplot{5}; // for 2-d plots in pt slices
132 std::vector<TH2D *> m_phiResidual_v_r;
133 std::vector<TH2D *> m_etaResidual_v_r;
134 std::vector<TH2D *> m_phiScale_v_r;
135 std::vector<TH2D *> m_etaScale_v_r;
136
141
142 // step-by-step plot
143 std::vector<TH1D *> m_hitsPerStepBin;
144 TH1D * m_hitsPerLayer = 0;
147
148 // distributions for efficiency monitoring
149 std::vector<std::string> m_distPlotClasses{"truth","ThrshNlayer","ThrshNlayerm1"}; // 0=truth distribution, 1=passes n-1 binning selection
150 std::vector<TH1D *> m_ptDist;
151 std::vector<TH1D *> m_etaDist;
152 std::vector<TH1D *> m_phiDist;
153 std::vector<TH1D *> m_d0Dist;
154 std::vector<TH1D *> m_z0Dist;
155
156
157
158 private:
159
160 // TTree for layer definitions studies
161 StatusCode bookTrees();
162 void ClearTreeVectors();
163
164 TTree *m_bin_tree = nullptr; // output tree
166 std::vector<unsigned> m_bin_tree_bin; // 5 tracks parameter bin
167 std::vector<float> m_bin_tree_r;
168 std::vector<float> m_bin_tree_z;
169 std::vector<int> m_bin_tree_id;
170 std::vector<int> m_bin_tree_hash;
171 std::vector<int> m_bin_tree_layer;
172 std::vector<int> m_bin_tree_side;
173 std::vector<int> m_bin_tree_etamod;
174 std::vector<int> m_bin_tree_phimod;
175 std::vector<int> m_bin_tree_dettype;
176 std::vector<int> m_bin_tree_detzone;
177
178 TTree *m_truth_tree = nullptr; // output tree
179 double m_truth_tree_phi{0.0};
181 double m_truth_tree_d0{0.0};
182 double m_truth_tree_z0{0.0};
183 double m_truth_tree_eta{0.0};
184 std::vector<double> m_truth_tree_parset;
185
187 // make and register histogram or vector of histograms in one line...
188 template <typename HistType, typename... HistDef>
189 StatusCode makeAndRegHist(HistType *&ptr, HistDef... histargs)
190 {
191 ptr = new HistType(histargs...);
192 ATH_CHECK(m_tHistSvc->regHist(m_dir + ptr->GetName(), ptr));
193 return StatusCode::SUCCESS;
194 }
195
196
197 template <typename HistType, typename... HistDef>
198 StatusCode makeAndRegHistVector(std::vector<HistType*>& vec, unsigned len, const std::vector<std::string>* namevec, const char* namebase, HistDef... histargs)
199 {
200 if (vec.size()==0){
201 for (unsigned i = 0; i < len; i++) {
202 HistType *ptr = 0;
203 std::string name = std::string(namebase);
204 if (!namevec) {
205 name += std::to_string(i);
206 } else {
207 if (namevec->size()==len) {
208 name += (*namevec)[i];
209 } else {
210 return StatusCode::FAILURE;
211 }
212 }
213 ATH_CHECK(makeAndRegHist(ptr, name.c_str(), histargs...));
214 vec.push_back(ptr);
215 }
216 }
217 return StatusCode::SUCCESS;
218 }
219
220 // Register a graph
221 StatusCode regGraph(TGraph *g) const { return m_tHistSvc->regGraph(m_dir + g->GetName(), g);}
222
223 };
224
225#endif // FPGATrackSimLayerStudyTool_H
#define ATH_CHECK
Evaluate an expression and check for errors.
std::vector< size_t > vec
Binning Utilities for GenScanTool.
Binning Classes for GenScanTool.
: FPGATrackSim-specific class to represent an hit in the detector.
Structs that store the 5 track parameters.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Property< double > m_z0pad
FPGATrackSimBinUtil::ParSet m_truthparset
StatusCode registerHistograms(const FPGATrackSimBinnedHits *binnedhits, bool skipTruth)
FPGATrackSimLayerStudyTool(const std::string &, const std::string &, const IInterface *)
StatusCode regGraph(TGraph *g) const
void fillBinLevelOutput ATLAS_NOT_THREAD_SAFE(const FPGATrackSimBinUtil::IdxSet &idx, const FPGATrackSimBinnedHits::BinEntry &data)
Gaudi::Property< std::string > m_layerStudyTreeName
Gaudi::Property< std::string > m_truthTreeName
std::vector< FPGATrackSimBinUtil::IdxSet > & truthBin()
std::vector< FPGATrackSimBinUtil::IdxSet > m_truthbin
Gaudi::Property< double > m_etaScale
StatusCode makeAndRegHist(HistType *&ptr, HistDef... histargs)
virtual StatusCode initialize() override
Gaudi::Property< double > m_phiScale
const FPGATrackSimBinnedHits * m_binnedhits
Gaudi::Property< double > m_d0pad
Gaudi::Property< bool > m_plotAllBins
ServiceHandle< ITHistSvc > m_tHistSvc
Gaudi::Property< double > m_qptpad
void parseTruthInfo ATLAS_NOT_THREAD_SAFE(std::vector< FPGATrackSimTruthTrack > const &truthtracks)
void fillBinningSummary ATLAS_NOT_THREAD_SAFE(const std::vector< std::shared_ptr< const FPGATrackSimHit > > &hits)
Gaudi::Property< double > m_phipad
void fillHitLevelInput(const FPGATrackSimHit *hit)
StatusCode makeAndRegHistVector(std::vector< HistType * > &vec, unsigned len, const std::vector< std::string > *namevec, const char *namebase, HistDef... histargs)
Gaudi::Property< double > m_drScale
Gaudi::Property< double > m_etapad
FPGATrackSimBinUtil::IdxSet & truthBin(unsigned stepnum)
Gaudi::Property< std::string > m_dir
std::vector< std::string > m_distPlotClasses
void setBinPlotsActive(const FPGATrackSimBinUtil::IdxSet &idx)