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

#include <FPGATrackSimTrackMonitor.h>

Inheritance diagram for FPGATrackSimTrackMonitor:
Collaboration diagram for FPGATrackSimTrackMonitor:

Public Member Functions

 FPGATrackSimTrackMonitor (const std::string &, const std::string &, const IInterface *)
virtual StatusCode initialize () override
void fillRoad (const std::vector< FPGATrackSimRoad > &roads, const std::vector< FPGATrackSimTruthTrack > &truthTracks, size_t nLogicalLayers)
void fillTrack (const std::vector< const FPGATrackSimTrack * > &tracks, const std::vector< FPGATrackSimTruthTrack > &truthTracks, float chi2Cut)
unsigned getNElements () const
unsigned getMaxNElements () const
unsigned getTotNElements () const
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

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< GenericMonitoringToolm_monTool {this,"MonTool", "", "Monitoring tool"}
Gaudi::Property< std::string > m_dir {this, "dir", {"/TRACKMON/"}, "String name of output directory"}
ServiceHandle< ITHistSvc > m_tHistSvc {this, "THistSvc", "THistSvc/THistSvc", "Histogramming service"}
unsigned m_nElements {0}
unsigned m_maxNElements {0}
unsigned m_totNElements {0}
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 37 of file FPGATrackSimTrackMonitor.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

◆ FPGATrackSimTrackMonitor()

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

Definition at line 19 of file FPGATrackSimTrackMonitor.cxx.

19 :
20 AthAlgTool(algname, name, ifc)
21{
23 ATH_MSG_INFO("constructor");
24}
#define ATH_MSG_INFO(x)
AthAlgTool()
Default constructor:

Member Function Documentation

◆ 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

◆ fillRoad()

void FPGATrackSimTrackMonitor::fillRoad ( const std::vector< FPGATrackSimRoad > & roads,
const std::vector< FPGATrackSimTruthTrack > & truthTracks,
size_t nLogicalLayers )

Definition at line 51 of file FPGATrackSimTrackMonitor.cxx.

54{
55 // overall number of roads
56 auto nRoads = Monitored::Scalar<int>("nRoads", roads.size());
57 // push them into the monitoring tool (this->MonTool set in python)
58 Monitored::Group(m_monTool, nRoads);
59
60 // update counter of total roads
61 m_totNElements += roads.size();
62
63 // loop over all roads in the event
64 for (const auto& road : roads) {
65 // layerIDs
66 unsigned bitmask = road.getHitLayers();
67 for (size_t l = 0; l < nLogicalLayers; l++) {
68 if (bitmask & (1 << l)) {
69 auto mon_layerIDs = Monitored::Scalar<unsigned>("layerIDs",l);
70 Monitored::Group(m_monTool, mon_layerIDs);
71 }
72 }
73 // number of layers represented in this road
74 auto mon_nLayers = Monitored::Scalar<int>("nLayers", road.getNLayers());
75 // number of hits
76 auto mon_nHits = Monitored::Scalar<int>("nHits", road.getNHits());
77 // push all of the above scalars into the monitoring tool
78 Monitored::Group(m_monTool, mon_nLayers, mon_nHits);
79 // roads with 4 hits
80 if (road.getNHits() == 4) {
81 // fit chi2 in this road
82 auto mon_fitChi2_4 = Monitored::Scalar<float>("chi2_4", road.getFitChi2());
83 // fit chi2Eta
84 auto mon_fitChi2Eta_4 = Monitored::Scalar<float>("chi2Eta_4", road.getFitChi2Eta());
85 // fit chi2Phi
86 auto mon_fitChi2Phi_4 = Monitored::Scalar<float>("chi2Phi_4", road.getFitChi2Phi());
87 // push all of the above scalars into the monitoring tool
88 Monitored::Group(m_monTool, mon_fitChi2_4, mon_fitChi2Eta_4, mon_fitChi2Phi_4);
89 } else if (road.getNHits() == 5) {
90 auto mon_fitChi2_5 = Monitored::Scalar<float>("chi2_5", road.getFitChi2());
91 auto mon_fitChi2Eta_5 = Monitored::Scalar<float>("chi2Eta_5", road.getFitChi2Eta());
92 auto mon_fitChi2Phi_5 = Monitored::Scalar<float>("chi2Phi_5", road.getFitChi2Phi());
93 Monitored::Group(m_monTool, mon_fitChi2_5, mon_fitChi2Eta_5, mon_fitChi2Phi_5);
94 }
95 }
96
97 // only monitor efficiency for events with truth tracks
98 if (truthTracks.size() > 0) {
99 // update road counter
100 if (roads.size() > 0) ++m_nElements;
101 // update the max number of elements
102 if (roads.size() > m_maxNElements) m_maxNElements=roads.size();
103 // use the first truth track (the primary one)
104 const auto& truthTrack = truthTracks.front();
105 // efficiency monitor
106 auto mon_eff = Monitored::Scalar<bool>("eff_road", (roads.size() > 0));
107 auto mon_truth_pt_zoom = Monitored::Scalar<float>("pT_zoom", truthTrack.getPt()*0.001);
108 auto mon_truth_pt = Monitored::Scalar<float>("pT", truthTrack.getPt()*0.001);
109 auto mon_truth_eta = Monitored::Scalar<float>("eta", truthTrack.getEta());
110 auto mon_truth_phi = Monitored::Scalar<float>("phi", truthTrack.getPhi());
111 auto mon_truth_d0 = Monitored::Scalar<float>("d0", truthTrack.getD0());
112 auto mon_truth_z0 = Monitored::Scalar<float>("z0", truthTrack.getZ0());
113 Monitored::Group( m_monTool, mon_eff, mon_truth_pt_zoom, mon_truth_pt, mon_truth_eta, mon_truth_phi, mon_truth_d0, mon_truth_z0 );
114 }
115}
ToolHandle< GenericMonitoringTool > m_monTool
l
Printing final latex table to .tex output file.

◆ fillTrack()

void FPGATrackSimTrackMonitor::fillTrack ( const std::vector< const FPGATrackSimTrack * > & tracks,
const std::vector< FPGATrackSimTruthTrack > & truthTracks,
float chi2Cut )

Definition at line 119 of file FPGATrackSimTrackMonitor.cxx.

122{
123 // monitor chi2 for all tracks and find the best
124 float bestChi2 = chi2Cut;
125 float chi2_best = chi2Cut;
126 float chi2Eta_best = chi2Cut;
127 float chi2Phi_best = chi2Cut;
128 float chi2_best_4 = chi2Cut;
129 float chi2Eta_best_4 = chi2Cut;
130 float chi2Phi_best_4 = chi2Cut;
131 float chi2_best_5 = chi2Cut;
132 float chi2Eta_best_5 = chi2Cut;
133 float chi2Phi_best_5 = chi2Cut;
134
135 // lambda function to monitor chi2 (all) and keep track of the best one
136 auto monitorChi2 = [&](const std::string& chi2_name, float chi2_value, float& best_value, const std::string& suffix="") {
137 if (chi2_value < chi2Cut) {
138 // monitor all chi2
139 auto mon = Monitored::Scalar<float>(chi2_name + suffix, chi2_value);
140 Monitored::Group(m_monTool, mon);
141 // update best chi2
142 if (chi2_value < best_value) best_value = chi2_value;
143 }
144 };
145
146
147 // overall number of tracks
148 auto mon_nTracks = Monitored::Scalar<int>("nTracks", tracks.size());
149 // push them into the monitoring tool (this->MonTool set in python)
150 Monitored::Group(m_monTool, mon_nTracks);
151
152 // update counter of total tracks
153 m_totNElements += tracks.size();
154
155 // loop over all tracks in the event
156 for (const auto& track : tracks) {
157 // number of real hits
158 int nValidHits = 0;
159 for (const auto& hit : track->getFPGATrackSimHits()) {
160 if (hit.isReal()) {
161 ++nValidHits;
162 }
163 }
164 auto mon_nHits = Monitored::Scalar<int>("nHits", nValidHits);
165 Monitored::Group(m_monTool, mon_nHits);
166
167 // monitor chi2 for tracks
168 float chi2_all = track->getChi2ndof();
169 if (chi2_all < chi2Cut) {
170 auto mon_chi2_all = Monitored::Scalar<float>("chi2_all", chi2_all);
171 Monitored::Group(m_monTool, mon_chi2_all);
172 // update best chi2
173 if (chi2_all < bestChi2) {
174 bestChi2 = chi2_all;
175 }
176 }
177
178 // monitor base chi2 values
179 monitorChi2("chi2", track->getChi2(), chi2_best);
180 monitorChi2("chi2Eta", track->getChi2Eta(), chi2Eta_best);
181 monitorChi2("chi2Phi", track->getChi2Phi(), chi2Phi_best);
182
183 // monitor nHits-dependent chi2 values
184 if (nValidHits == 4) {
185 monitorChi2("chi2", track->getChi2(), chi2_best_4, "_4");
186 monitorChi2("chi2Eta", track->getChi2Eta(), chi2Eta_best_4, "_4");
187 monitorChi2("chi2Phi", track->getChi2Phi(), chi2Phi_best_4, "_4");
188 } else if (nValidHits == 5) {
189 monitorChi2("chi2", track->getChi2(), chi2_best_5, "_5");
190 monitorChi2("chi2Eta", track->getChi2Eta(), chi2Eta_best_5, "_5");
191 monitorChi2("chi2Phi", track->getChi2Phi(), chi2Phi_best_5, "_5");
192 }
193 }
194 // monitor the best chi2 found
195 if (bestChi2 < chi2Cut) {
196 auto mon_best_chi2 = Monitored::Scalar<float>("best_chi2", bestChi2);
197 Monitored::Group(m_monTool, mon_best_chi2);
198 }
199
200 // lambda function to monitor the best chi2 value
201 auto monitorBestChi2 = [&](const std::string& best_name, float best_value) {
202 if (best_value < chi2Cut) {
203 auto mon_best = Monitored::Scalar<float>(best_name, best_value);
204 Monitored::Group(m_monTool, mon_best);
205 }
206 };
207
208 // best chi2 values
209 monitorBestChi2("chi2_best", chi2_best);
210 monitorBestChi2("chi2Eta_best", chi2Eta_best);
211 monitorBestChi2("chi2Phi_best", chi2Phi_best);
212 monitorBestChi2("chi2_best_4", chi2_best_4);
213 monitorBestChi2("chi2Eta_best_4", chi2Eta_best_4);
214 monitorBestChi2("chi2Phi_best_4", chi2Phi_best_4);
215 monitorBestChi2("chi2_best_5", chi2_best_5);
216 monitorBestChi2("chi2Eta_best_5", chi2Eta_best_5);
217 monitorBestChi2("chi2Phi_best_5", chi2Phi_best_5);
218
219
220 // only monitor efficiency for events with truth tracks
221 if (truthTracks.size() > 0) {
222 // update track counter
223 if (tracks.size() > 0) ++m_nElements;
224 // update the max number of elements
225 if (tracks.size() > m_maxNElements) m_maxNElements=tracks.size();
226 // use the first truth track (the primary one)
227 const auto& truthTrack = truthTracks.front();
228 // efficiency monitor
229 auto mon_eff = Monitored::Scalar<bool>("eff_track", (tracks.size() > 0));
230 auto mon_truth_pt_zoom = Monitored::Scalar<float>("pT_zoom", truthTrack.getPt()*0.001);
231 auto mon_truth_pt = Monitored::Scalar<float>("pT", truthTrack.getPt()*0.001f);
232 auto mon_truth_eta = Monitored::Scalar<float>("eta", truthTrack.getEta());
233 auto mon_truth_phi = Monitored::Scalar<float>("phi", truthTrack.getPhi());
234 auto mon_truth_d0 = Monitored::Scalar<float>("d0", truthTrack.getD0());
235 auto mon_truth_z0 = Monitored::Scalar<float>("z0", truthTrack.getZ0());
236 Monitored::Group( m_monTool, mon_eff, mon_truth_pt_zoom, mon_truth_pt, mon_truth_eta, mon_truth_phi, mon_truth_d0, mon_truth_z0 );
237 }
238}

◆ getMaxNElements()

unsigned FPGATrackSimTrackMonitor::getMaxNElements ( ) const
inline

Definition at line 67 of file FPGATrackSimTrackMonitor.h.

67{return m_maxNElements;}

◆ getNElements()

unsigned FPGATrackSimTrackMonitor::getNElements ( ) const
inline

Definition at line 64 of file FPGATrackSimTrackMonitor.h.

64{return m_nElements;}

◆ getTotNElements()

unsigned FPGATrackSimTrackMonitor::getTotNElements ( ) const
inline

Definition at line 70 of file FPGATrackSimTrackMonitor.h.

70{return m_totNElements;}

◆ initialize()

StatusCode FPGATrackSimTrackMonitor::initialize ( )
overridevirtual

Definition at line 27 of file FPGATrackSimTrackMonitor.cxx.

28{
29 // print all configured properties (debugging)
30 auto props = this->getProperties();
31 for( Gaudi::Details::PropertyBase* prop : props ) {
32 if (prop->ownerTypeName()==this->type()) {
33 ATH_MSG_DEBUG("Property:\t" << prop->name() << "\t : \t" << prop->toString());
34 }
35 }
36 ATH_MSG_INFO("Initialize Track Monitoring");
37
39 ATH_CHECK(m_tHistSvc.retrieve());
40
41 return StatusCode::SUCCESS;
42
43}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
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.

◆ 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.

◆ 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 }

◆ 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_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

Gaudi::Property<std::string> FPGATrackSimTrackMonitor::m_dir {this, "dir", {"/TRACKMON/"}, "String name of output directory"}
private

Definition at line 80 of file FPGATrackSimTrackMonitor.h.

80{this, "dir", {"/TRACKMON/"}, "String name of output directory"};

◆ 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_maxNElements

unsigned FPGATrackSimTrackMonitor::m_maxNElements {0}
private

Definition at line 90 of file FPGATrackSimTrackMonitor.h.

90{0};

◆ m_monTool

ToolHandle<GenericMonitoringTool> FPGATrackSimTrackMonitor::m_monTool {this,"MonTool", "", "Monitoring tool"}
private

Definition at line 77 of file FPGATrackSimTrackMonitor.h.

77{this,"MonTool", "", "Monitoring tool"};

◆ m_nElements

unsigned FPGATrackSimTrackMonitor::m_nElements {0}
private

Definition at line 87 of file FPGATrackSimTrackMonitor.h.

87{0};

◆ m_tHistSvc

ServiceHandle<ITHistSvc> FPGATrackSimTrackMonitor::m_tHistSvc {this, "THistSvc", "THistSvc/THistSvc", "Histogramming service"}
private

Definition at line 84 of file FPGATrackSimTrackMonitor.h.

84{this, "THistSvc", "THistSvc/THistSvc", "Histogramming service"};

◆ m_totNElements

unsigned FPGATrackSimTrackMonitor::m_totNElements {0}
private

Definition at line 93 of file FPGATrackSimTrackMonitor.h.

93{0};

◆ 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: