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

#include <FPGATrackSimDataFlowTool.h>

Inheritance diagram for FPGATrackSimDataFlowTool:
Collaboration diagram for FPGATrackSimDataFlowTool:

Public Types

template<typename T>
using DataFlowMap_t = std::unordered_map<std::string, T, CxxUtils::TransparentStringHash, std::equal_to<>>

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< FPGATrackSimRoad > &roads_1st, std::vector< FPGATrackSimTrack > const &tracks_1st, const std::vector< 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_view 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 constgetHistDir ()
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
DataFlowMap_t< int > m_dataFlowDataI_min
DataFlowMap_t< int > m_dataFlowDataI_max
DataFlowMap_t< float > m_dataFlowDataF_min
DataFlowMap_t< float > m_dataFlowDataF_max
DataFlowMap_t< TH1I * > m_dataFlowHistsI
DataFlowMap_t< 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 28 of file FPGATrackSimDataFlowTool.h.

Member Typedef Documentation

◆ DataFlowMap_t

template<typename T>
using FPGATrackSimDataFlowTool::DataFlowMap_t = std::unordered_map<std::string, T, CxxUtils::TransparentStringHash, std::equal_to<>>

Definition at line 32 of file FPGATrackSimDataFlowTool.h.

◆ 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 43 of file FPGATrackSimDataFlowTool.cxx.

43 :
44 AthAlgTool(algname, name, ifc)
45{
46}
AthAlgTool()
Default constructor:

◆ ~FPGATrackSimDataFlowTool()

virtual FPGATrackSimDataFlowTool::~FPGATrackSimDataFlowTool ( )
virtualdefault

Member Function Documentation

◆ addDataFlow()

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

Definition at line 358 of file FPGATrackSimDataFlowTool.cxx.

359{
360 if (isInt) {
361 const int value = static_cast<int>(n);
362 updateMin(m_dataFlowDataI_min, key, value);
363 updateMax(m_dataFlowDataI_max, key, value);
364 } else {
365 updateMin(m_dataFlowDataF_min, key, n);
366 updateMax(m_dataFlowDataF_max, key, n);
367 }
368
369 if ((isInt && m_dataFlowHistsI.find(key) == m_dataFlowHistsI.end()) ||
370 (!isInt && m_dataFlowHistsF.find(key) == m_dataFlowHistsF.end())) {
371 const std::string keyStr{key};
372 std::string hname = "h_dataflow_" + keyStr;
373 if (!m_outputtag.value().empty()) {
374 hname += "_";
375 hname += m_outputtag.value();
376 }
377 findAndReplaceAll(hname, "/", "_over_");
378 setHistDir("/DataFlowHist/");
379 TH1* h = nullptr;
380 if (isInt) {
381 h = new TH1I(hname.c_str(), keyStr.c_str(), n + 1, -0.5, n + 0.5);
382 } else {
383 h = new TH1F(hname.c_str(), keyStr.c_str(), (std::round(n) + 1) * 100, -0.5, std::round(n) + 0.5);
384 }
386 clearHistDir();
387 h->Fill(n);
388 if (isInt) {
389 m_dataFlowHistsI.emplace(keyStr, static_cast<TH1I*>(h));
390 } else {
391 m_dataFlowHistsF.emplace(keyStr, static_cast<TH1F*>(h));
392 }
393 } else {
394 if (isInt) {
395 const auto maxIt = m_dataFlowDataI_max.find(key);
396 const auto histIt = m_dataFlowHistsI.find(key);
397 if ((maxIt != m_dataFlowDataI_max.end()) and (histIt != m_dataFlowHistsI.end()))[[likely]]{
398 const int max = maxIt->second;
399 TH1I* h = histIt->second;
400 h->SetBins(max + 1, -0.5, max + 0.5);
401 h->Fill(n);
402 }
403 } else {
404 const auto maxIt = m_dataFlowDataF_max.find(key);
405 const auto histIt = m_dataFlowHistsF.find(key);
406 if ((maxIt != m_dataFlowDataF_max.end()) and (histIt != m_dataFlowHistsF.end()))[[likely]]{
407 const float max = maxIt->second;
408 TH1F* h = histIt->second;
409 h->SetBins((std::round(max) + 1) * 100, -0.5, std::round(max) + 0.5);
410 h->Fill(n);
411 }
412 }
413 }
414
415 return StatusCode::SUCCESS;
416}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define max(a, b)
Definition cfImp.cxx:41
DataFlowMap_t< float > m_dataFlowDataF_min
DataFlowMap_t< float > m_dataFlowDataF_max
DataFlowMap_t< TH1F * > m_dataFlowHistsF
DataFlowMap_t< TH1I * > m_dataFlowHistsI
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
StatusCode regHist(std::string const &dir, TH1 *h)
DataFlowMap_t< int > m_dataFlowDataI_min
DataFlowMap_t< int > m_dataFlowDataI_max
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
#define likely(x)

◆ addTableBreak()

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

Definition at line 481 of file FPGATrackSimDataFlowTool.cxx.

482{
483 for (unsigned i = 0; i < n; i++) {
484 m_dataFlowTxt << "--------------" << std::endl;
485 m_dataFlowTeX << "\\hline" << std::endl;
486 }
487}

◆ calculateDataFlow()

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

Definition at line 68 of file FPGATrackSimDataFlowTool.cxx.

72{
73 info->nMappedHits_1st_layer.resize(m_nLayers_1st);
74 for (int i=0; i<header_1st->towers().at(0).nHits(); i++) {
75 info->nMappedHits_1st_total++;
76 }
77
78 info->nClusters_1st_layer.resize(m_nLayers_1st);
79 info->nClusters_1st_total = clusters_1st.size();
80
81 info->nRoads_1st_total = roads_1st.size();
82 for (const auto & r : roads_1st) {
83 if (std::popcount(r.getHitLayers()) == static_cast<int>(m_nLayers_1st) - 1)
84 info->nRoads_1st_7hits++;
85 if (std::popcount(r.getHitLayers()) == static_cast<int>(m_nLayers_1st))
86 info->nRoads_1st_8hits++;
87 }
88
89 std::unordered_map<int, size_t> pattID_nTracks_1st;
90 std::unordered_map<int, size_t> pattID_nTracks_1st_passChi2;
91 std::unordered_map<int, size_t> pattID_nTracks_1st_afterOR;
92
93 std::unordered_map<int, size_t> sectID_nTracks_1st;
94 std::unordered_map<int, size_t> sectID_nTracks_1st_passChi2;
95 std::unordered_map<int, size_t> sectID_nTracks_1st_afterOR;
96
97 info->nTracks_1st_total = tracks_1st.size();
98 for (FPGATrackSimTrack const & t : tracks_1st) {
99 if (t.getChi2ndof() <= m_cut_chi2ndof) {
100 info->nTracks_1st_passChi2++;
101 pattID_nTracks_1st_passChi2[t.getPatternID()]++;
102 sectID_nTracks_1st_passChi2[t.getFirstSectorID()]++;
103 }
104 if (t.passedOR() == 1) {
105 info->nTracks_1st_afterOR++;
106 pattID_nTracks_1st_afterOR[t.getPatternID()]++;
107 sectID_nTracks_1st_afterOR[t.getFirstSectorID()]++;
108 }
109 pattID_nTracks_1st[t.getPatternID()]++;
110 sectID_nTracks_1st[t.getFirstSectorID()]++;
111 }
112 for (const auto& [ID, ntrack]: pattID_nTracks_1st) {
113 info->nTracks_1st_per_patt_total.push_back(ntrack);
114 }
115 for (const auto& [ID, ntrack]: pattID_nTracks_1st_passChi2) {
116 info->nTracks_1st_per_patt_passChi2.push_back(ntrack);
117 }
118 for (const auto& [ID, ntrack]: pattID_nTracks_1st_afterOR) {
119 info->nTracks_1st_per_patt_afterOR.push_back(ntrack);
120 }
121
122 info->nConstants_1st_fitter = sectID_nTracks_1st.size();
123 info->nConstants_1st_passChi2 = sectID_nTracks_1st_passChi2.size();
124 info->nConstants_1st_afterOR = sectID_nTracks_1st_afterOR.size();
125
126 if (m_runSecondStage) {
127 info->nRoads_2nd_total = roads_2nd.size();
128
129 std::unordered_map<int, size_t> sectID_nTracks_2nd;
130 std::unordered_map<int, size_t> sectID_nTracks_2nd_passChi2;
131 std::unordered_map<int, size_t> sectID_nTracks_2nd_afterOR;
132
133 info->nTracks_2nd_total = tracks_2nd.size();
134 for (FPGATrackSimTrack const & t : tracks_2nd) {
135 if (t.getChi2ndof() <= m_cut_chi2ndof) {
136 info->nTracks_2nd_passChi2++;
137 sectID_nTracks_2nd_passChi2[t.getSecondSectorID()]++;
138 }
139 if (t.passedOR() == 1) {
140 info->nTracks_2nd_afterOR++;
141 sectID_nTracks_2nd_afterOR[t.getSecondSectorID()]++;
142 }
143 sectID_nTracks_2nd[t.getSecondSectorID()]++;
144 }
145
146 info->nConstants_2nd_fitter = sectID_nTracks_2nd.size();
147 info->nConstants_2nd_passChi2 = sectID_nTracks_2nd_passChi2.size();
148 info->nConstants_2nd_afterOR = sectID_nTracks_2nd_afterOR.size();
149 }
150
151 for (FPGATrackSimTruthTrack const & truth_t : header_1st->optional().getTruthTracks()) {
152 if (m_evtSel->passCuts(truth_t)) info->nTruthTracks++;
153 }
154
155 for (FPGATrackSimOfflineTrack const & offline_t : header_1st->optional().getOfflineTracks()) {
156 if (m_evtSel->passCuts(offline_t)) info->nOfflineTracks++;
157 }
158
159 if (info->nOfflineTracks > 0) {
160 info->nTracks_1st_over_nOfflineTracks = (float)tracks_1st.size() / (float)info->nOfflineTracks;
161 if (m_runSecondStage) info->nTracks_2nd_over_nOfflineTracks = (float)tracks_2nd.size() / (float)info->nOfflineTracks;
162 }
163
165
166 return StatusCode::SUCCESS;
167}
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
mapped_type at(key_type key) const
Look up an element in the map.

◆ clearHistDir()

void FPGATrackSimDataFlowTool::clearHistDir ( )
inlineprivate

Definition at line 62 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 348 of file FPGATrackSimDataFlowTool.cxx.

349{
350 ATH_MSG_INFO("FPGATrackSimDataFlowTool::finalize()");
352 return StatusCode::SUCCESS;
353}
#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 491 of file FPGATrackSimDataFlowTool.cxx.

492{
493 size_t pos = data.find(toFind);
494 while (pos != std::string::npos) {
495 data.replace(pos, toFind.size(), replaceStr);
496 pos = data.find(toFind, pos + replaceStr.size());
497 }
498}

◆ getDataFlowInfo()

StatusCode FPGATrackSimDataFlowTool::getDataFlowInfo ( FPGATrackSimDataFlowInfo const & info)

Definition at line 171 of file FPGATrackSimDataFlowTool.cxx.

172{
173 m_nEvents++;
174
175 for (size_t i = 0; i < m_nLayers_1st; i++) {
176 ATH_CHECK(addDataFlow(info.nMappedHits_1st_layer[i], "nMappedHitsL" + std::to_string(i) + "_1st"));
177 }
178 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.
179
180 for (size_t i = 0; i < m_nLayers_1st; i++) {
181 ATH_CHECK(addDataFlow(info.nClusters_1st_layer[i], "nClustersL" + std::to_string(i) + "_1st"));
182 }
183 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.
184
185 ATH_CHECK(addDataFlow(info.nRoads_1st_total, "nRoads_1st(Total)"));
186 ATH_CHECK(addDataFlow(info.nRoads_1st_7hits, "nRoads_1st(7/8)"));
187 ATH_CHECK(addDataFlow(info.nRoads_1st_8hits, "nRoads_1st(8/8)"));
188
189 ATH_CHECK(addDataFlow(info.nTracks_1st_total, "nTracks_1st(Total)"));
190 ATH_CHECK(addDataFlow(info.nTracks_1st_passChi2, "nTracks_1st(Chi2ndof<40)"));
191 ATH_CHECK(addDataFlow(info.nTracks_1st_afterOR, "nTracks_1st(passing OR)"));
192
193 for (size_t n : info.nTracks_1st_per_patt_total) {
194 ATH_CHECK(addDataFlow(n, "nTracks_1st per patt(Total)"));
195 }
196 for (size_t n : info.nTracks_1st_per_patt_passChi2) {
197 ATH_CHECK(addDataFlow(n, "nTracks_1st per patt(Chi2ndof<40)"));
198 }
199 for (size_t n : info.nTracks_1st_per_patt_afterOR) {
200 ATH_CHECK(addDataFlow(n, "nTracks_1st per patt(passing OR)"));
201 }
202
203 ATH_CHECK(addDataFlow(info.nConstants_1st_fitter, "nConstants_1st(Fitter)"));
204 ATH_CHECK(addDataFlow(info.nConstants_1st_passChi2, "nConstants_1st(Chi2ndof<40)"));
205 ATH_CHECK(addDataFlow(info.nConstants_1st_afterOR, "nConstants_1st(after OR)"));
206
207 if (m_runSecondStage) {
208 ATH_CHECK(addDataFlow(info.nRoads_2nd_total, "nRoads_2nd(Total)"));
209
210 ATH_CHECK(addDataFlow(info.nTracks_2nd_total, "nTracks_2nd(Total)"));
211 ATH_CHECK(addDataFlow(info.nTracks_2nd_passChi2, "nTracks_2nd(Chi2ndof<40)"));
212 ATH_CHECK(addDataFlow(info.nTracks_2nd_afterOR, "nTracks_2nd(passing OR)"));
213
214 ATH_CHECK(addDataFlow(info.nConstants_2nd_extrapolate, "nConstants_2nd(Extrapolate)"));
215 ATH_CHECK(addDataFlow(info.nConstants_2nd_fitter, "nConstants_2nd(Fitter)"));
216 ATH_CHECK(addDataFlow(info.nConstants_2nd_passChi2, "nConstants_2nd(Chi2ndof<40)"));
217 ATH_CHECK(addDataFlow(info.nConstants_2nd_afterOR, "nConstants_2nd(after OR)"));
218 }
219
220 ATH_CHECK(addDataFlow(info.nTruthTracks, "nTruthTracks"));
221 ATH_CHECK(addDataFlow(info.nOfflineTracks, "nOfflineTracks"));
222
223 if (info.nOfflineTracks > 0) {
224 ATH_CHECK(addDataFlow(info.nTracks_1st_over_nOfflineTracks, "nTracks_1st(Total)/nOfflineTracks", false));
225 if (m_runSecondStage) {
226 ATH_CHECK(addDataFlow(info.nTracks_2nd_over_nOfflineTracks, "nTracks_2nd(Total)/nOfflineTracks", false));
227 }
228 }
229
230 return StatusCode::SUCCESS;
231}
StatusCode addDataFlow(float const n, std::string_view key, bool const isInt=true)

◆ getHistDir()

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

Definition at line 61 of file FPGATrackSimDataFlowTool.h.

61{ return m_dir; }

◆ initialize()

StatusCode FPGATrackSimDataFlowTool::initialize ( )
overridevirtual

Definition at line 50 of file FPGATrackSimDataFlowTool.cxx.

51{
52 ATH_MSG_INFO("FPGATrackSimDataFlowTool::initialize()");
53
54 ATH_CHECK(m_tHistSvc.retrieve());
56 ATH_CHECK(m_evtSel.retrieve());
57
58 m_nLayers_1st = m_FPGATrackSimMapping->PlaneMap_1st(0)->getNLogiLayers();
59
62
63 return StatusCode::SUCCESS;
64}
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 235 of file FPGATrackSimDataFlowTool.cxx.

236{
237 m_dataFlowTxt << std::left << std::setw(m_tableTypeWidth) << "Type"
238 << std::setw(m_tableDataWidth) << "Stage"
239 << std::setw(m_tableDataWidth) << "Mean"
240 << std::setw(m_tableDataWidth) << "RMS"
241 << std::setw(m_tableDataWidth) << "RMS95"
242 << std::setw(m_tableDataWidth) << "Min"
243 << std::setw(m_tableDataWidth) << "Max" << std::endl;
244
245 m_dataFlowTeX << "\\documentclass[12pt]{article}" << std::endl;
246 m_dataFlowTeX << "\\begin{document}" << std::endl;
247 m_dataFlowTeX << "\\begin{table}" << std::endl;
248 m_dataFlowTeX << "\\makebox[\\linewidth]{" << std::endl;
249 m_dataFlowTeX << "\\begin{tabular}{|c|c|c|c|c|c|c|}" << std::endl;
250 m_dataFlowTeX << "\\hline" << std::endl;
251 m_dataFlowTeX << "Type & Stage & Mean & RMS & RMS95 & Min & Max \\\\" << std::endl;
252
254
255 for (size_t i = 0; i < m_nLayers_1st; i++) {
256 ATH_CHECK(printDataFlow("nMappedHitsL" + std::to_string(i) + "_1st"));
257 }
258 ATH_CHECK(printDataFlow("nMappedHits_1st per layer", m_nLayers_1st));
259
261
262 for (size_t i = 0; i < m_nLayers_1st; i++) {
263 ATH_CHECK(printDataFlow("nClustersL" + std::to_string(i) + "_1st"));
264 }
265 ATH_CHECK(printDataFlow("nClusters_1st per layer", m_nLayers_1st));
266
268
269 ATH_CHECK(printDataFlow("nRoads_1st(Total)"));
270 ATH_CHECK(printDataFlow("nRoads_1st(7/8)"));
271 ATH_CHECK(printDataFlow("nRoads_1st(8/8)"));
272
274
275 ATH_CHECK(printDataFlow("nTracks_1st(Total)"));
276 ATH_CHECK(printDataFlow("nTracks_1st(Chi2ndof<40)"));
277 ATH_CHECK(printDataFlow("nTracks_1st(passing OR)"));
278
280
281 ATH_CHECK(printDataFlow("nTracks_1st per patt(Total)"));
282 ATH_CHECK(printDataFlow("nTracks_1st per patt(Chi2ndof<40)"));
283 ATH_CHECK(printDataFlow("nTracks_1st per patt(passing OR)"));
284
286
287 ATH_CHECK(printDataFlow("nConstants_1st(Fitter)"));
288 ATH_CHECK(printDataFlow("nConstants_1st(Chi2ndof<40)"));
289 ATH_CHECK(printDataFlow("nConstants_1st(after OR)"));
290
292
293 if (m_runSecondStage) {
294 ATH_CHECK(printDataFlow("nRoads_2nd(Total)"));
295
297
298 ATH_CHECK(printDataFlow("nTracks_2nd(Total)"));
299 ATH_CHECK(printDataFlow("nTracks_2nd(Chi2ndof<40)"));
300 ATH_CHECK(printDataFlow("nTracks_2nd(passing OR)"));
301
303
304 ATH_CHECK(printDataFlow("nConstants_2nd(Extrapolate)"));
305 ATH_CHECK(printDataFlow("nConstants_2nd(Fitter)"));
306 ATH_CHECK(printDataFlow("nConstants_2nd(Chi2ndof<40)"));
307 ATH_CHECK(printDataFlow("nConstants_2nd(after OR)"));
308
310 }
311
312 ATH_CHECK(printDataFlow("nTruthTracks"));
313 ATH_CHECK(printDataFlow("nOfflineTracks"));
314 ATH_CHECK(printDataFlow("nTracks_1st(Total)/nOfflineTracks"));
315 if (m_runSecondStage) ATH_CHECK(printDataFlow("nTracks_2nd(Total)/nOfflineTracks"));
316
317 std::string str_sample;
318 std::string str_PU;
319
320 switch (m_evtSel->getSampleType()) {
321 case SampleType::singleElectrons : str_sample = " single electron"; break;
322 case SampleType::singleMuons : str_sample = " single muon"; break;
323 case SampleType::singlePions : str_sample = " single pion"; break;
324 default : str_sample = ""; break;
325 }
326
327 str_PU = m_evtSel->checkPU() ? " with pile-up" : "";
328
329 m_dataFlowTxt << "--------------" << std::endl;
330 m_dataFlowTxt << "Data flow for " << m_nEvents << str_sample << " events" << str_PU << ". "
331 << "(" << roundTo(100. * m_max_frac, m_nSigDigits) << "%" << " acceptance)" << std::endl;
332
333 m_dataFlowTeX << "\\hline" << std::endl;
334 m_dataFlowTeX << "\\end{tabular}}" << std::endl;
335 m_dataFlowTeX << "\\caption{Data flow for " << m_nEvents << str_sample << " events" << str_PU << ". "
336 << "(" << roundTo(100. * m_max_frac, m_nSigDigits) << "\\%" << " acceptance)} " << std::endl;
337 m_dataFlowTeX << "\\end{table}" << std::endl;
338 m_dataFlowTeX << "\\end{document}" << std::endl;
339
340 m_dataFlowTxt.close();
341 m_dataFlowTeX.close();
342
343 return StatusCode::SUCCESS;
344}
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 419 of file FPGATrackSimDataFlowTool.cxx.

420{
421 bool isInt = false;
422 if (m_dataFlowHistsI.find(key) != m_dataFlowHistsI.end())
423 isInt = true;
424 else if (m_dataFlowHistsF.find(key) == m_dataFlowHistsF.end())
425 return StatusCode::SUCCESS;
426
427 double min = isInt ? m_dataFlowDataI_min.find(key)->second : m_dataFlowDataF_min.find(key)->second;
428 double max = isInt ? m_dataFlowDataI_max.find(key)->second : m_dataFlowDataF_max.find(key)->second;
429
430 TH1* h;
431 if (isInt)
432 h = m_dataFlowHistsI.find(key)->second;
433 else
434 h = m_dataFlowHistsF.find(key)->second;
435
437
438 std::string str_stage = "", str_key = key;
439 if (key.find("_1st") != std::string::npos) {
440 str_stage = "FIRST";
441 str_key.erase(key.find("_1st"), std::string("_1st").length());
442 }
443 else if (key.find("_2nd") != std::string::npos) {
444 str_stage = "SECOND";
445 str_key.erase(key.find("_2nd"), std::string("_2nd").length());
446 }
447 else {
448 str_stage = "UNKNOWN";
449 }
450
451 double mean = h->GetMean() / div;
452 double rms = h->GetRMS() / div;
453 double rms95_n = rms95(h) / div;
454 min = min / div;
455 max = max / div;
456
457 m_dataFlowTxt << std::left << std::setw(m_tableTypeWidth) << str_key
458 << std::setw(m_tableDataWidth) << str_stage
459 << std::setw(m_tableDataWidth) << roundTo(mean, m_nSigDigits)
460 << std::setw(m_tableDataWidth) << roundTo(rms, m_nSigDigits)
461 << std::setw(m_tableDataWidth) << roundTo(rms95_n, m_nSigDigits)
462 << std::setw(m_tableDataWidth) << roundTo(min, m_nSigDigits)
463 << std::setw(m_tableDataWidth) << roundTo(max, m_nSigDigits) << std::endl;
464
465 // Replace all "<" by "$<$" in the key to make the type text for tex.
466 // If there are other characters in the future, we can make a vector to store all of them.
467 std::string key_tex = std::move(str_key);
468 findAndReplaceAll(key_tex, "<", "$<$");
469
470 m_dataFlowTeX << key_tex << " & " << str_stage << " & " << roundTo(mean, m_nSigDigits)
471 << " & " << roundTo(rms, m_nSigDigits)
472 << " & " << roundTo(rms95(h), m_nSigDigits)
473 << " & " << roundTo(min, m_nSigDigits)
474 << " & " << roundTo(max, m_nSigDigits) << " \\\\" << std::endl;
475
476 return StatusCode::SUCCESS;
477}
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 63 of file FPGATrackSimDataFlowTool.h.

63{ 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 517 of file FPGATrackSimDataFlowTool.cxx.

518{
519 int sigDigit = v != 0 ? trunc(log10(fabs(v))) : 0;
520 if (nSigDigits >= 1) {
521 double factor = pow(10., nSigDigits - sigDigit - 1);
522 return round(v * factor) / factor;
523 }
524
525 return v;
526}
float round(const float toRound, const unsigned int decimals)
Definition Mdt.cxx:27
constexpr int pow(int x)
Definition conifer.h:27

◆ setHistDir()

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

Definition at line 60 of file FPGATrackSimDataFlowTool.h.

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

◆ setMaxAcceptance()

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

Definition at line 502 of file FPGATrackSimDataFlowTool.cxx.

503{
504 double total = h->Integral();
505 for (int i = 1; i <= h->GetNbinsX(); i++) {
506 double partial = h->Integral(1, i);
507 if (partial / total > max_frac) {
508 max_value = h->GetBinCenter(i);
509 h->GetXaxis()->SetRange(1, i);
510 break;
511 }
512 }
513}

◆ 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 >, and AthCheckedComponent<::AthAlgTool >.

◆ 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 72 of file FPGATrackSimDataFlowTool.h.

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

◆ m_dataFlowDataF_max

DataFlowMap_t<float> FPGATrackSimDataFlowTool::m_dataFlowDataF_max
private

Definition at line 95 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowDataF_min

DataFlowMap_t<float> FPGATrackSimDataFlowTool::m_dataFlowDataF_min
private

Definition at line 94 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowDataI_max

DataFlowMap_t<int> FPGATrackSimDataFlowTool::m_dataFlowDataI_max
private

Definition at line 93 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowDataI_min

DataFlowMap_t<int> FPGATrackSimDataFlowTool::m_dataFlowDataI_min
private

Definition at line 92 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowHistsF

DataFlowMap_t<TH1F*> FPGATrackSimDataFlowTool::m_dataFlowHistsF
private

Definition at line 98 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowHistsI

DataFlowMap_t<TH1I*> FPGATrackSimDataFlowTool::m_dataFlowHistsI
private

Definition at line 97 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowTeX

std::ofstream FPGATrackSimDataFlowTool::m_dataFlowTeX
private

Definition at line 78 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowTeXName

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

Definition at line 76 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowTxt

std::ofstream FPGATrackSimDataFlowTool::m_dataFlowTxt
private

Definition at line 77 of file FPGATrackSimDataFlowTool.h.

◆ m_dataFlowTxtName

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

Definition at line 75 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 81 of file FPGATrackSimDataFlowTool.h.

◆ m_evtSel

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

Definition at line 67 of file FPGATrackSimDataFlowTool.h.

67{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 66 of file FPGATrackSimDataFlowTool.h.

66{this,"FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"};

◆ m_max_frac

double const FPGATrackSimDataFlowTool::m_max_frac = 0.99
private

Definition at line 90 of file FPGATrackSimDataFlowTool.h.

◆ m_nEvents

size_t FPGATrackSimDataFlowTool::m_nEvents = 0
private

Definition at line 83 of file FPGATrackSimDataFlowTool.h.

◆ m_nLayers_1st

unsigned FPGATrackSimDataFlowTool::m_nLayers_1st = 0U
private

Definition at line 84 of file FPGATrackSimDataFlowTool.h.

◆ m_nSigDigits

unsigned const FPGATrackSimDataFlowTool::m_nSigDigits = 2
private

Definition at line 87 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 71 of file FPGATrackSimDataFlowTool.h.

71{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 70 of file FPGATrackSimDataFlowTool.h.

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

◆ m_tableDataWidth

unsigned const FPGATrackSimDataFlowTool::m_tableDataWidth = 9
private

Definition at line 89 of file FPGATrackSimDataFlowTool.h.

◆ m_tableTypeWidth

unsigned const FPGATrackSimDataFlowTool::m_tableTypeWidth = 32
private

Definition at line 88 of file FPGATrackSimDataFlowTool.h.

◆ m_tHistSvc

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

Definition at line 65 of file FPGATrackSimDataFlowTool.h.

65{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: