ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimDataFlowTool Class Reference

#include <FPGATrackSimDataFlowTool.h>

Inheritance diagram for FPGATrackSimDataFlowTool:

Public Member Functions

 FPGATrackSimDataFlowTool (std::string const &, std::string const &, IInterface const *)
virtual ~FPGATrackSimDataFlowTool ()=default
virtual StatusCode initialize () override
StatusCode calculateDataFlow (FPGATrackSimDataFlowInfo *info, FPGATrackSimLogicalEventInputHeader const *header_1st, std::vector< FPGATrackSimCluster > const &clusters_1st, const std::vector< std::shared_ptr< const FPGATrackSimRoad > > &roads_1st, std::vector< FPGATrackSimTrack > const &tracks_1st, const std::vector< std::shared_ptr< const FPGATrackSimRoad > > &roads_2nd, std::vector< FPGATrackSimTrack > const &tracks_2nd)
StatusCode getDataFlowInfo (FPGATrackSimDataFlowInfo const &info)
virtual StatusCode finalize () override
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode makeDataFlowTable ()
StatusCode addDataFlow (float const n, std::string const &key, bool const isInt=true)
StatusCode printDataFlow (std::string const &key, int const div=1)
void addTableBreak (unsigned const n=1)
void findAndReplaceAll (std::string &data, std::string const &toFind, std::string const &replaceStr) const
void setMaxAcceptance (TH1 *h, double const max_frac, double &max_value) const
double roundTo (double const v, int const nSigDigits) const
void setHistDir (std::string const &dir)
std::string const & getHistDir ()
void clearHistDir ()
StatusCode regHist (std::string const &dir, TH1 *h)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< ITHistSvc > m_tHistSvc {this,"THistSvc","THistSvc"}
ServiceHandle< IFPGATrackSimMappingSvcm_FPGATrackSimMapping {this,"FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"}
ServiceHandle< IFPGATrackSimEventSelectionSvcm_evtSel {this,"FPGATrackSimEventSelectionSvc","FPGATrackSimEventSelectionSvc"}
Gaudi::Property< bool > m_runSecondStage {this, "RunSecondStage", false, "flag to enable running the second stage fitting"}
Gaudi::Property< std::string > m_outputtag {this, "outputTag", "", "Extra string to use in output folder names - default none"}
Gaudi::Property< float > m_cut_chi2ndof {this, "Chi2ndofCut", 40., "cut on Chi2 of FPGATrackSimTrack"}
std::string const m_dataFlowTxtName = "./dataflow.txt"
std::string const m_dataFlowTeXName = "./dataflow.tex"
std::ofstream m_dataFlowTxt
std::ofstream m_dataFlowTeX
std::string m_dir
size_t m_nEvents = 0
unsigned m_nLayers_1st = 0U
unsigned const m_nSigDigits = 2
unsigned const m_tableTypeWidth = 32
unsigned const m_tableDataWidth = 9
double const m_max_frac = 0.99
std::unordered_map< std::string, int > m_dataFlowDataI_min
std::unordered_map< std::string, int > m_dataFlowDataI_max
std::unordered_map< std::string, float > m_dataFlowDataF_min
std::unordered_map< std::string, float > m_dataFlowDataF_max
std::unordered_map< std::string, TH1I * > m_dataFlowHistsI
std::unordered_map< std::string, TH1F * > m_dataFlowHistsF
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 26 of file FPGATrackSimDataFlowTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ FPGATrackSimDataFlowTool()

FPGATrackSimDataFlowTool::FPGATrackSimDataFlowTool ( std::string const & algname,
std::string const & name,
IInterface const * ifc )

Definition at line 18 of file FPGATrackSimDataFlowTool.cxx.

18 :
19 AthAlgTool(algname, name, ifc)
20{
21}
AthAlgTool()
Default constructor:

◆ ~FPGATrackSimDataFlowTool()

virtual FPGATrackSimDataFlowTool::~FPGATrackSimDataFlowTool ( )
virtualdefault

Member Function Documentation

◆ addDataFlow()

StatusCode FPGATrackSimDataFlowTool::addDataFlow ( float const n,
std::string const & key,
bool const isInt = true )
private

Definition at line 332 of file FPGATrackSimDataFlowTool.cxx.

333{
334 if (isInt) {
335 if (m_dataFlowDataI_min.find(key) == m_dataFlowDataI_min.end()) {
336 m_dataFlowDataI_min.insert({key, n});
337 }
338 else if (n < m_dataFlowDataI_min.find(key)->second) {
339 m_dataFlowDataI_min.find(key)->second = n;
340 }
341
342 if (m_dataFlowDataI_max.find(key) == m_dataFlowDataI_max.end()) {
343 m_dataFlowDataI_max.insert({key, n});
344 }
345 else if (n > m_dataFlowDataI_max.find(key)->second) {
346 m_dataFlowDataI_max.find(key)->second = n;
347 }
348 }
349 else {
350 if (m_dataFlowDataF_min.find(key) == m_dataFlowDataF_min.end()) {
351 m_dataFlowDataF_min.insert({key, n});
352 }
353 else if (n < m_dataFlowDataF_min.find(key)->second) {
354 m_dataFlowDataF_min.find(key)->second = n;
355 }
356
357 if (m_dataFlowDataF_max.find(key) == m_dataFlowDataF_max.end()) {
358 m_dataFlowDataF_max.insert({key, n});
359 }
360 else if (n > m_dataFlowDataF_max.find(key)->second) {
361 m_dataFlowDataF_max.find(key)->second = n;
362 }
363 }
364
365 if ((isInt && m_dataFlowHistsI.find(key) == m_dataFlowHistsI.end()) ||
366 (!isInt && m_dataFlowHistsF.find(key) == m_dataFlowHistsF.end())) {
367 std::string hname = "h_dataflow_" + key;
368 if (!m_outputtag.value().empty()) hname += ("_" + m_outputtag.value());
369 findAndReplaceAll(hname, "/", "_over_");
370
371 setHistDir("/DataFlowHist/");
372 TH1* h;
373 if (isInt)
374 h = new TH1I(hname.c_str(), key.c_str(), n + 1, -0.5, n + 0.5);
375 else
376 h = new TH1F(hname.c_str(), key.c_str(), (round(n) + 1) * 100, -0.5, round(n) + 0.5);
378 clearHistDir();
379
380 h->Fill(n);
381
382 if (isInt)
383 m_dataFlowHistsI.insert({key, dynamic_cast<TH1I*>(h)});
384 else
385 m_dataFlowHistsF.insert({key, dynamic_cast<TH1F*>(h)});
386 }
387 else {
388 if (m_dataFlowDataI_max.find(key) != m_dataFlowDataI_max.end()) {
389 int max = m_dataFlowDataI_max.find(key)->second;
390 TH1I* h = m_dataFlowHistsI.find(key)->second;
391 h->SetBins(max + 1, -0.5, max + 0.5);
392 h->Fill(n);
393 }
394 else if (m_dataFlowDataF_max.find(key) != m_dataFlowDataF_max.end()) {
395 float max = m_dataFlowDataF_max.find(key)->second;
396 TH1F* h = m_dataFlowHistsF.find(key)->second;
397 h->SetBins((round(max) + 1) * 100, -0.5, round(max) + 0.5);
398 h->Fill(n);
399 }
400 }
401
402 return StatusCode::SUCCESS;
403}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define max(a, b)
Definition cfImp.cxx:41
std::unordered_map< std::string, TH1I * > m_dataFlowHistsI
std::unordered_map< std::string, int > m_dataFlowDataI_min
std::unordered_map< std::string, float > m_dataFlowDataF_max
std::unordered_map< std::string, float > m_dataFlowDataF_min
std::unordered_map< std::string, int > m_dataFlowDataI_max
void setHistDir(std::string const &dir)
Gaudi::Property< std::string > m_outputtag
void findAndReplaceAll(std::string &data, std::string const &toFind, std::string const &replaceStr) const
std::unordered_map< std::string, TH1F * > m_dataFlowHistsF
StatusCode regHist(std::string const &dir, TH1 *h)
float round(const float toRound, const unsigned int decimals)
Definition Mdt.cxx:27
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)

◆ addTableBreak()

void FPGATrackSimDataFlowTool::addTableBreak ( unsigned const n = 1)
private

Definition at line 469 of file FPGATrackSimDataFlowTool.cxx.

470{
471 for (unsigned i = 0; i < n; i++) {
472 m_dataFlowTxt << "--------------" << std::endl;
473 m_dataFlowTeX << "\\hline" << std::endl;
474 }
475}

◆ calculateDataFlow()

StatusCode FPGATrackSimDataFlowTool::calculateDataFlow ( FPGATrackSimDataFlowInfo * info,
FPGATrackSimLogicalEventInputHeader const * header_1st,
std::vector< FPGATrackSimCluster > const & clusters_1st,
const std::vector< std::shared_ptr< const FPGATrackSimRoad > > & roads_1st,
std::vector< FPGATrackSimTrack > const & tracks_1st,
const std::vector< std::shared_ptr< const FPGATrackSimRoad > > & roads_2nd,
std::vector< FPGATrackSimTrack > const & tracks_2nd )

Definition at line 43 of file FPGATrackSimDataFlowTool.cxx.

47{
48 info->nMappedHits_1st_layer.resize(m_nLayers_1st);
49 for (int i=0; i<header_1st->towers().at(0).nHits(); i++) {
50 info->nMappedHits_1st_total++;
51 }
52
53 info->nClusters_1st_layer.resize(m_nLayers_1st);
54 info->nClusters_1st_total = clusters_1st.size();
55
56 info->nRoads_1st_total = roads_1st.size();
57 for (const auto & r : roads_1st) {
58 if (std::popcount(r->getHitLayers()) == static_cast<int>(m_nLayers_1st) - 1)
59 info->nRoads_1st_7hits++;
60 if (std::popcount(r->getHitLayers()) == static_cast<int>(m_nLayers_1st))
61 info->nRoads_1st_8hits++;
62 }
63
64 std::unordered_map<int, size_t> pattID_nTracks_1st;
65 std::unordered_map<int, size_t> pattID_nTracks_1st_passChi2;
66 std::unordered_map<int, size_t> pattID_nTracks_1st_afterOR;
67
68 std::unordered_map<int, size_t> sectID_nTracks_1st;
69 std::unordered_map<int, size_t> sectID_nTracks_1st_passChi2;
70 std::unordered_map<int, size_t> sectID_nTracks_1st_afterOR;
71
72 info->nTracks_1st_total = tracks_1st.size();
73 for (FPGATrackSimTrack const & t : tracks_1st) {
74 if (t.getChi2ndof() <= m_cut_chi2ndof) {
75 info->nTracks_1st_passChi2++;
76 pattID_nTracks_1st_passChi2[t.getPatternID()]++;
77 sectID_nTracks_1st_passChi2[t.getFirstSectorID()]++;
78 }
79 if (t.passedOR() == 1) {
80 info->nTracks_1st_afterOR++;
81 pattID_nTracks_1st_afterOR[t.getPatternID()]++;
82 sectID_nTracks_1st_afterOR[t.getFirstSectorID()]++;
83 }
84 pattID_nTracks_1st[t.getPatternID()]++;
85 sectID_nTracks_1st[t.getFirstSectorID()]++;
86 }
87 for (const auto& [ID, ntrack]: pattID_nTracks_1st) {
88 info->nTracks_1st_per_patt_total.push_back(ntrack);
89 }
90 for (const auto& [ID, ntrack]: pattID_nTracks_1st_passChi2) {
91 info->nTracks_1st_per_patt_passChi2.push_back(ntrack);
92 }
93 for (const auto& [ID, ntrack]: pattID_nTracks_1st_afterOR) {
94 info->nTracks_1st_per_patt_afterOR.push_back(ntrack);
95 }
96
97 info->nConstants_1st_fitter = sectID_nTracks_1st.size();
98 info->nConstants_1st_passChi2 = sectID_nTracks_1st_passChi2.size();
99 info->nConstants_1st_afterOR = sectID_nTracks_1st_afterOR.size();
100
101 if (m_runSecondStage) {
102 info->nRoads_2nd_total = roads_2nd.size();
103
104 std::unordered_map<int, size_t> sectID_nTracks_2nd;
105 std::unordered_map<int, size_t> sectID_nTracks_2nd_passChi2;
106 std::unordered_map<int, size_t> sectID_nTracks_2nd_afterOR;
107
108 info->nTracks_2nd_total = tracks_2nd.size();
109 for (FPGATrackSimTrack const & t : tracks_2nd) {
110 if (t.getChi2ndof() <= m_cut_chi2ndof) {
111 info->nTracks_2nd_passChi2++;
112 sectID_nTracks_2nd_passChi2[t.getSecondSectorID()]++;
113 }
114 if (t.passedOR() == 1) {
115 info->nTracks_2nd_afterOR++;
116 sectID_nTracks_2nd_afterOR[t.getSecondSectorID()]++;
117 }
118 sectID_nTracks_2nd[t.getSecondSectorID()]++;
119 }
120
121 info->nConstants_2nd_fitter = sectID_nTracks_2nd.size();
122 info->nConstants_2nd_passChi2 = sectID_nTracks_2nd_passChi2.size();
123 info->nConstants_2nd_afterOR = sectID_nTracks_2nd_afterOR.size();
124 }
125
126 for (FPGATrackSimTruthTrack const & truth_t : header_1st->optional().getTruthTracks()) {
127 if (m_evtSel->passCuts(truth_t)) info->nTruthTracks++;
128 }
129
130 for (FPGATrackSimOfflineTrack const & offline_t : header_1st->optional().getOfflineTracks()) {
131 if (m_evtSel->passCuts(offline_t)) info->nOfflineTracks++;
132 }
133
134 if (info->nOfflineTracks > 0) {
135 info->nTracks_1st_over_nOfflineTracks = (float)tracks_1st.size() / (float)info->nOfflineTracks;
136 if (m_runSecondStage) info->nTracks_2nd_over_nOfflineTracks = (float)tracks_2nd.size() / (float)info->nOfflineTracks;
137 }
138
140
141 return StatusCode::SUCCESS;
142}
std::vector< Identifier > ID
static const uint32_t nHits
Gaudi::Property< bool > m_runSecondStage
StatusCode getDataFlowInfo(FPGATrackSimDataFlowInfo const &info)
ServiceHandle< IFPGATrackSimEventSelectionSvc > m_evtSel
Gaudi::Property< float > m_cut_chi2ndof
int r
Definition globals.cxx:22

◆ clearHistDir()

void FPGATrackSimDataFlowTool::clearHistDir ( )
inlineprivate

Definition at line 58 of file FPGATrackSimDataFlowTool.h.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode FPGATrackSimDataFlowTool::finalize ( )
overridevirtual

Definition at line 323 of file FPGATrackSimDataFlowTool.cxx.

324{
325 ATH_MSG_INFO("FPGATrackSimDataFlowTool::finalize()");
327 return StatusCode::SUCCESS;
328}
#define ATH_MSG_INFO(x)

◆ findAndReplaceAll()

void FPGATrackSimDataFlowTool::findAndReplaceAll ( std::string & data,
std::string const & toFind,
std::string const & replaceStr ) const
private

Definition at line 479 of file FPGATrackSimDataFlowTool.cxx.

480{
481 size_t pos = data.find(toFind);
482 while (pos != std::string::npos) {
483 data.replace(pos, toFind.size(), replaceStr);
484 pos = data.find(toFind, pos + replaceStr.size());
485 }
486}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11

◆ getDataFlowInfo()

StatusCode FPGATrackSimDataFlowTool::getDataFlowInfo ( FPGATrackSimDataFlowInfo const & info)

Definition at line 146 of file FPGATrackSimDataFlowTool.cxx.

147{
148 m_nEvents++;
149
150 for (size_t i = 0; i < m_nLayers_1st; i++) {
151 ATH_CHECK(addDataFlow(info.nMappedHits_1st_layer[i], "nMappedHitsL" + std::to_string(i) + "_1st"));
152 }
153 ATH_CHECK(addDataFlow(info.nMappedHits_1st_total, "nMappedHits_1st per layer")); // We fill the total number here. It will be divided by the number of layers later.
154
155 for (size_t i = 0; i < m_nLayers_1st; i++) {
156 ATH_CHECK(addDataFlow(info.nClusters_1st_layer[i], "nClustersL" + std::to_string(i) + "_1st"));
157 }
158 ATH_CHECK(addDataFlow(info.nClusters_1st_total, "nClusters_1st per layer")); // We fill the total number here. It will be divided by the number of layers later.
159
160 ATH_CHECK(addDataFlow(info.nRoads_1st_total, "nRoads_1st(Total)"));
161 ATH_CHECK(addDataFlow(info.nRoads_1st_7hits, "nRoads_1st(7/8)"));
162 ATH_CHECK(addDataFlow(info.nRoads_1st_8hits, "nRoads_1st(8/8)"));
163
164 ATH_CHECK(addDataFlow(info.nTracks_1st_total, "nTracks_1st(Total)"));
165 ATH_CHECK(addDataFlow(info.nTracks_1st_passChi2, "nTracks_1st(Chi2ndof<40)"));
166 ATH_CHECK(addDataFlow(info.nTracks_1st_afterOR, "nTracks_1st(passing OR)"));
167
168 for (size_t n : info.nTracks_1st_per_patt_total) {
169 ATH_CHECK(addDataFlow(n, "nTracks_1st per patt(Total)"));
170 }
171 for (size_t n : info.nTracks_1st_per_patt_passChi2) {
172 ATH_CHECK(addDataFlow(n, "nTracks_1st per patt(Chi2ndof<40)"));
173 }
174 for (size_t n : info.nTracks_1st_per_patt_afterOR) {
175 ATH_CHECK(addDataFlow(n, "nTracks_1st per patt(passing OR)"));
176 }
177
178 ATH_CHECK(addDataFlow(info.nConstants_1st_fitter, "nConstants_1st(Fitter)"));
179 ATH_CHECK(addDataFlow(info.nConstants_1st_passChi2, "nConstants_1st(Chi2ndof<40)"));
180 ATH_CHECK(addDataFlow(info.nConstants_1st_afterOR, "nConstants_1st(after OR)"));
181
182 if (m_runSecondStage) {
183 ATH_CHECK(addDataFlow(info.nRoads_2nd_total, "nRoads_2nd(Total)"));
184
185 ATH_CHECK(addDataFlow(info.nTracks_2nd_total, "nTracks_2nd(Total)"));
186 ATH_CHECK(addDataFlow(info.nTracks_2nd_passChi2, "nTracks_2nd(Chi2ndof<40)"));
187 ATH_CHECK(addDataFlow(info.nTracks_2nd_afterOR, "nTracks_2nd(passing OR)"));
188
189 ATH_CHECK(addDataFlow(info.nConstants_2nd_extrapolate, "nConstants_2nd(Extrapolate)"));
190 ATH_CHECK(addDataFlow(info.nConstants_2nd_fitter, "nConstants_2nd(Fitter)"));
191 ATH_CHECK(addDataFlow(info.nConstants_2nd_passChi2, "nConstants_2nd(Chi2ndof<40)"));
192 ATH_CHECK(addDataFlow(info.nConstants_2nd_afterOR, "nConstants_2nd(after OR)"));
193 }
194
195 ATH_CHECK(addDataFlow(info.nTruthTracks, "nTruthTracks"));
196 ATH_CHECK(addDataFlow(info.nOfflineTracks, "nOfflineTracks"));
197
198 if (info.nOfflineTracks > 0) {
199 ATH_CHECK(addDataFlow(info.nTracks_1st_over_nOfflineTracks, "nTracks_1st(Total)/nOfflineTracks", false));
200 if (m_runSecondStage) {
201 ATH_CHECK(addDataFlow(info.nTracks_2nd_over_nOfflineTracks, "nTracks_2nd(Total)/nOfflineTracks", false));
202 }
203 }
204
205 return StatusCode::SUCCESS;
206}
StatusCode addDataFlow(float const n, std::string const &key, bool const isInt=true)

◆ getHistDir()

std::string const & FPGATrackSimDataFlowTool::getHistDir ( )
inlineprivate

Definition at line 57 of file FPGATrackSimDataFlowTool.h.

57{ return m_dir; }

◆ initialize()

StatusCode FPGATrackSimDataFlowTool::initialize ( )
overridevirtual

Definition at line 25 of file FPGATrackSimDataFlowTool.cxx.

26{
27 ATH_MSG_INFO("FPGATrackSimDataFlowTool::initialize()");
28
29 ATH_CHECK(m_tHistSvc.retrieve());
31 ATH_CHECK(m_evtSel.retrieve());
32
33 m_nLayers_1st = m_FPGATrackSimMapping->PlaneMap_1st(0)->getNLogiLayers();
34
37
38 return StatusCode::SUCCESS;
39}
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
ServiceHandle< ITHistSvc > m_tHistSvc

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ makeDataFlowTable()

StatusCode FPGATrackSimDataFlowTool::makeDataFlowTable ( )
private

Definition at line 210 of file FPGATrackSimDataFlowTool.cxx.

211{
212 m_dataFlowTxt << std::left << std::setw(m_tableTypeWidth) << "Type"
213 << std::setw(m_tableDataWidth) << "Stage"
214 << std::setw(m_tableDataWidth) << "Mean"
215 << std::setw(m_tableDataWidth) << "RMS"
216 << std::setw(m_tableDataWidth) << "RMS95"
217 << std::setw(m_tableDataWidth) << "Min"
218 << std::setw(m_tableDataWidth) << "Max" << std::endl;
219
220 m_dataFlowTeX << "\\documentclass[12pt]{article}" << std::endl;
221 m_dataFlowTeX << "\\begin{document}" << std::endl;
222 m_dataFlowTeX << "\\begin{table}" << std::endl;
223 m_dataFlowTeX << "\\makebox[\\linewidth]{" << std::endl;
224 m_dataFlowTeX << "\\begin{tabular}{|c|c|c|c|c|c|c|}" << std::endl;
225 m_dataFlowTeX << "\\hline" << std::endl;
226 m_dataFlowTeX << "Type & Stage & Mean & RMS & RMS95 & Min & Max \\\\" << std::endl;
227
229
230 for (size_t i = 0; i < m_nLayers_1st; i++) {
231 ATH_CHECK(printDataFlow("nMappedHitsL" + std::to_string(i) + "_1st"));
232 }
233 ATH_CHECK(printDataFlow("nMappedHits_1st per layer", m_nLayers_1st));
234
236
237 for (size_t i = 0; i < m_nLayers_1st; i++) {
238 ATH_CHECK(printDataFlow("nClustersL" + std::to_string(i) + "_1st"));
239 }
240 ATH_CHECK(printDataFlow("nClusters_1st per layer", m_nLayers_1st));
241
243
244 ATH_CHECK(printDataFlow("nRoads_1st(Total)"));
245 ATH_CHECK(printDataFlow("nRoads_1st(7/8)"));
246 ATH_CHECK(printDataFlow("nRoads_1st(8/8)"));
247
249
250 ATH_CHECK(printDataFlow("nTracks_1st(Total)"));
251 ATH_CHECK(printDataFlow("nTracks_1st(Chi2ndof<40)"));
252 ATH_CHECK(printDataFlow("nTracks_1st(passing OR)"));
253
255
256 ATH_CHECK(printDataFlow("nTracks_1st per patt(Total)"));
257 ATH_CHECK(printDataFlow("nTracks_1st per patt(Chi2ndof<40)"));
258 ATH_CHECK(printDataFlow("nTracks_1st per patt(passing OR)"));
259
261
262 ATH_CHECK(printDataFlow("nConstants_1st(Fitter)"));
263 ATH_CHECK(printDataFlow("nConstants_1st(Chi2ndof<40)"));
264 ATH_CHECK(printDataFlow("nConstants_1st(after OR)"));
265
267
268 if (m_runSecondStage) {
269 ATH_CHECK(printDataFlow("nRoads_2nd(Total)"));
270
272
273 ATH_CHECK(printDataFlow("nTracks_2nd(Total)"));
274 ATH_CHECK(printDataFlow("nTracks_2nd(Chi2ndof<40)"));
275 ATH_CHECK(printDataFlow("nTracks_2nd(passing OR)"));
276
278
279 ATH_CHECK(printDataFlow("nConstants_2nd(Extrapolate)"));
280 ATH_CHECK(printDataFlow("nConstants_2nd(Fitter)"));
281 ATH_CHECK(printDataFlow("nConstants_2nd(Chi2ndof<40)"));
282 ATH_CHECK(printDataFlow("nConstants_2nd(after OR)"));
283
285 }
286
287 ATH_CHECK(printDataFlow("nTruthTracks"));
288 ATH_CHECK(printDataFlow("nOfflineTracks"));
289 ATH_CHECK(printDataFlow("nTracks_1st(Total)/nOfflineTracks"));
290 if (m_runSecondStage) ATH_CHECK(printDataFlow("nTracks_2nd(Total)/nOfflineTracks"));
291
292 std::string str_sample;
293 std::string str_PU;
294
295 switch (m_evtSel->getSampleType()) {
296 case SampleType::singleElectrons : str_sample = " single electron"; break;
297 case SampleType::singleMuons : str_sample = " single muon"; break;
298 case SampleType::singlePions : str_sample = " single pion"; break;
299 default : str_sample = ""; break;
300 }
301
302 str_PU = m_evtSel->checkPU() ? " with pile-up" : "";
303
304 m_dataFlowTxt << "--------------" << std::endl;
305 m_dataFlowTxt << "Data flow for " << m_nEvents << str_sample << " events" << str_PU << ". "
306 << "(" << roundTo(100. * m_max_frac, m_nSigDigits) << "%" << " acceptance)" << std::endl;
307
308 m_dataFlowTeX << "\\hline" << std::endl;
309 m_dataFlowTeX << "\\end{tabular}}" << std::endl;
310 m_dataFlowTeX << "\\caption{Data flow for " << m_nEvents << str_sample << " events" << str_PU << ". "
311 << "(" << roundTo(100. * m_max_frac, m_nSigDigits) << "\\%" << " acceptance)} " << std::endl;
312 m_dataFlowTeX << "\\end{table}" << std::endl;
313 m_dataFlowTeX << "\\end{document}" << std::endl;
314
315 m_dataFlowTxt.close();
316 m_dataFlowTeX.close();
317
318 return StatusCode::SUCCESS;
319}
StatusCode printDataFlow(std::string const &key, int const div=1)
double roundTo(double const v, int const nSigDigits) const
void addTableBreak(unsigned const n=1)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ printDataFlow()

StatusCode FPGATrackSimDataFlowTool::printDataFlow ( std::string const & key,
int const div = 1 )
private

Definition at line 407 of file FPGATrackSimDataFlowTool.cxx.

408{
409 bool isInt = false;
410 if (m_dataFlowHistsI.find(key) != m_dataFlowHistsI.end())
411 isInt = true;
412 else if (m_dataFlowHistsF.find(key) == m_dataFlowHistsF.end())
413 return StatusCode::SUCCESS;
414
415 double min = isInt ? m_dataFlowDataI_min.find(key)->second : m_dataFlowDataF_min.find(key)->second;
416 double max = isInt ? m_dataFlowDataI_max.find(key)->second : m_dataFlowDataF_max.find(key)->second;
417
418 TH1* h;
419 if (isInt)
420 h = m_dataFlowHistsI.find(key)->second;
421 else
422 h = m_dataFlowHistsF.find(key)->second;
423
425
426 std::string str_stage = "", str_key = key;
427 if (key.find("_1st") != std::string::npos) {
428 str_stage = "FIRST";
429 str_key.erase(key.find("_1st"), std::string("_1st").length());
430 }
431 else if (key.find("_2nd") != std::string::npos) {
432 str_stage = "SECOND";
433 str_key.erase(key.find("_2nd"), std::string("_2nd").length());
434 }
435 else {
436 str_stage = "UNKNOWN";
437 }
438
439 double mean = h->GetMean() / div;
440 double rms = h->GetRMS() / div;
441 double rms95_n = rms95(h) / div;
442 min = min / div;
443 max = max / div;
444
445 m_dataFlowTxt << std::left << std::setw(m_tableTypeWidth) << str_key
446 << std::setw(m_tableDataWidth) << str_stage
447 << std::setw(m_tableDataWidth) << roundTo(mean, m_nSigDigits)
448 << std::setw(m_tableDataWidth) << roundTo(rms, m_nSigDigits)
449 << std::setw(m_tableDataWidth) << roundTo(rms95_n, m_nSigDigits)
450 << std::setw(m_tableDataWidth) << roundTo(min, m_nSigDigits)
451 << std::setw(m_tableDataWidth) << roundTo(max, m_nSigDigits) << std::endl;
452
453 // Replace all "<" by "$<$" in the key to make the type text for tex.
454 // If there are other characters in the future, we can make a vector to store all of them.
455 std::string key_tex = std::move(str_key);
456 findAndReplaceAll(key_tex, "<", "$<$");
457
458 m_dataFlowTeX << key_tex << " & " << str_stage << " & " << roundTo(mean, m_nSigDigits)
459 << " & " << roundTo(rms, m_nSigDigits)
460 << " & " << roundTo(rms95(h), m_nSigDigits)
461 << " & " << roundTo(min, m_nSigDigits)
462 << " & " << roundTo(max, m_nSigDigits) << " \\\\" << std::endl;
463
464 return StatusCode::SUCCESS;
465}
double rms95(TH1 const *h)
This function is used to calculate RMS95 value for 1D histograms.
#define min(a, b)
Definition cfImp.cxx:40
void setMaxAcceptance(TH1 *h, double const max_frac, double &max_value) const
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")

◆ regHist()

StatusCode FPGATrackSimDataFlowTool::regHist ( std::string const & dir,
TH1 * h )
inlineprivate

Definition at line 59 of file FPGATrackSimDataFlowTool.h.

59{ return m_tHistSvc->regHist (dir + h->GetName(), h); }

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ roundTo()

double FPGATrackSimDataFlowTool::roundTo ( double const v,
int const nSigDigits ) const
private

Definition at line 505 of file FPGATrackSimDataFlowTool.cxx.

506{
507 int sigDigit = v != 0 ? trunc(log10(fabs(v))) : 0;
508 if (nSigDigits >= 1) {
509 double factor = pow(10., nSigDigits - sigDigit - 1);
510 return round(v * factor) / factor;
511 }
512
513 return v;
514}
constexpr int pow(int base, int exp) noexcept

◆ setHistDir()

void FPGATrackSimDataFlowTool::setHistDir ( std::string const & dir)
inlineprivate

Definition at line 56 of file FPGATrackSimDataFlowTool.h.

56{ m_dir = "/MONITOROUT" + dir; }

◆ setMaxAcceptance()

void FPGATrackSimDataFlowTool::setMaxAcceptance ( TH1 * h,
double const max_frac,
double & max_value ) const
private

Definition at line 490 of file FPGATrackSimDataFlowTool.cxx.

491{
492 double total = h->Integral();
493 for (int i = 1; i <= h->GetNbinsX(); i++) {
494 double partial = h->Integral(1, i);
495 if (partial / total > max_frac) {
496 max_value = h->GetBinCenter(i);
497 h->GetXaxis()->SetRange(1, i);
498 break;
499 }
500 }
501}

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_cut_chi2ndof

Gaudi::Property<float> FPGATrackSimDataFlowTool::m_cut_chi2ndof {this, "Chi2ndofCut", 40., "cut on Chi2 of FPGATrackSimTrack"}
private

Definition at line 68 of file FPGATrackSimDataFlowTool.h.

68{this, "Chi2ndofCut", 40., "cut on Chi2 of FPGATrackSimTrack"};

◆ m_dataFlowDataF_max

std::unordered_map<std::string, float> FPGATrackSimDataFlowTool::m_dataFlowDataF_max
private

Definition at line 91 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowDataF_min

std::unordered_map<std::string, float> FPGATrackSimDataFlowTool::m_dataFlowDataF_min
private

Definition at line 90 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowDataI_max

std::unordered_map<std::string, int> FPGATrackSimDataFlowTool::m_dataFlowDataI_max
private

Definition at line 89 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowDataI_min

std::unordered_map<std::string, int> FPGATrackSimDataFlowTool::m_dataFlowDataI_min
private

Definition at line 88 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowHistsF

std::unordered_map<std::string, TH1F*> FPGATrackSimDataFlowTool::m_dataFlowHistsF
private

Definition at line 94 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowHistsI

std::unordered_map<std::string, TH1I*> FPGATrackSimDataFlowTool::m_dataFlowHistsI
private

Definition at line 93 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowTeX

std::ofstream FPGATrackSimDataFlowTool::m_dataFlowTeX
private

Definition at line 74 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowTeXName

std::string const FPGATrackSimDataFlowTool::m_dataFlowTeXName = "./dataflow.tex"
private

Definition at line 72 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowTxt

std::ofstream FPGATrackSimDataFlowTool::m_dataFlowTxt
private

Definition at line 73 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowTxtName

std::string const FPGATrackSimDataFlowTool::m_dataFlowTxtName = "./dataflow.txt"
private

Definition at line 71 of file FPGATrackSimDataFlowTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_dir

std::string FPGATrackSimDataFlowTool::m_dir
private

Definition at line 77 of file FPGATrackSimDataFlowTool.h.

◆ m_evtSel

ServiceHandle<IFPGATrackSimEventSelectionSvc> FPGATrackSimDataFlowTool::m_evtSel {this,"FPGATrackSimEventSelectionSvc","FPGATrackSimEventSelectionSvc"}
private

Definition at line 63 of file FPGATrackSimDataFlowTool.h.

63{this,"FPGATrackSimEventSelectionSvc","FPGATrackSimEventSelectionSvc"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_FPGATrackSimMapping

ServiceHandle<IFPGATrackSimMappingSvc> FPGATrackSimDataFlowTool::m_FPGATrackSimMapping {this,"FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"}
private

Definition at line 62 of file FPGATrackSimDataFlowTool.h.

62{this,"FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"};

◆ m_max_frac

double const FPGATrackSimDataFlowTool::m_max_frac = 0.99
private

Definition at line 86 of file FPGATrackSimDataFlowTool.h.

◆ m_nEvents

size_t FPGATrackSimDataFlowTool::m_nEvents = 0
private

Definition at line 79 of file FPGATrackSimDataFlowTool.h.

◆ m_nLayers_1st

unsigned FPGATrackSimDataFlowTool::m_nLayers_1st = 0U
private

Definition at line 80 of file FPGATrackSimDataFlowTool.h.

◆ m_nSigDigits

unsigned const FPGATrackSimDataFlowTool::m_nSigDigits = 2
private

Definition at line 83 of file FPGATrackSimDataFlowTool.h.

◆ m_outputtag

Gaudi::Property<std::string> FPGATrackSimDataFlowTool::m_outputtag {this, "outputTag", "", "Extra string to use in output folder names - default none"}
private

Definition at line 67 of file FPGATrackSimDataFlowTool.h.

67{this, "outputTag", "", "Extra string to use in output folder names - default none"};

◆ m_runSecondStage

Gaudi::Property<bool> FPGATrackSimDataFlowTool::m_runSecondStage {this, "RunSecondStage", false, "flag to enable running the second stage fitting"}
private

Definition at line 66 of file FPGATrackSimDataFlowTool.h.

66{this, "RunSecondStage", false, "flag to enable running the second stage fitting"};

◆ m_tableDataWidth

unsigned const FPGATrackSimDataFlowTool::m_tableDataWidth = 9
private

Definition at line 85 of file FPGATrackSimDataFlowTool.h.

◆ m_tableTypeWidth

unsigned const FPGATrackSimDataFlowTool::m_tableTypeWidth = 32
private

Definition at line 84 of file FPGATrackSimDataFlowTool.h.

◆ m_tHistSvc

ServiceHandle<ITHistSvc> FPGATrackSimDataFlowTool::m_tHistSvc {this,"THistSvc","THistSvc"}
private

Definition at line 61 of file FPGATrackSimDataFlowTool.h.

61{this,"THistSvc","THistSvc"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: