ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimTrackMonitor.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
9
11#include "TH1D.h"
12#include "TH2D.h"
13#include "TTree.h"
14#include <bit>
16
17
19FPGATrackSimTrackMonitor::FPGATrackSimTrackMonitor(const std::string& algname, const std::string &name, const IInterface *ifc) :
20 AthAlgTool(algname, name, ifc)
21{
23 ATH_MSG_INFO("constructor");
24}
25
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}
44
45
46
48
49
51void FPGATrackSimTrackMonitor::fillRoad(const std::vector<std::shared_ptr<const FPGATrackSimRoad>>& roads,
52 const std::vector<FPGATrackSimTruthTrack>& truthTracks,
53 size_t nLogicalLayers)
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)
59
60 // return if no roads
61 if ( roads.empty() ) return;
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 nLayers = Monitored::Scalar<int>("nLayers", road->getNLayers());
75 // push all of the above scalars into the monitoring tool
77 }
78
79 // only monitor efficiency for events with truth tracks
80 if (truthTracks.size() > 0) {
81 // use the first truth track (the primary one)
82 const auto& truthTrack = truthTracks.front();
83 // efficiency monitor
84 auto mon_eff = Monitored::Scalar<bool>("eff_road", (roads.size() > 0));
85 auto mon_truth_pt_zoom = Monitored::Scalar<float>("pT_zoom", truthTrack.getPt()*0.001);
86 auto mon_truth_pt = Monitored::Scalar<float>("pT", truthTrack.getPt()*0.001);
87 auto mon_truth_eta = Monitored::Scalar<float>("eta", truthTrack.getEta());
88 auto mon_truth_phi = Monitored::Scalar<float>("phi", truthTrack.getPhi());
89 auto mon_truth_d0 = Monitored::Scalar<float>("d0", truthTrack.getD0());
90 auto mon_truth_z0 = Monitored::Scalar<float>("z0", truthTrack.getZ0());
91 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 );
92 }
93}
94
95
97void FPGATrackSimTrackMonitor::fillTrack(const std::vector<const FPGATrackSimTrack*>& tracks,
98 const std::vector<FPGATrackSimTruthTrack>& truthTracks,
99 float chi2Cut)
100{
101 // overall number of tracks
102 auto nTracks = Monitored::Scalar<int>("nTracks", tracks.size());
103 // push them into the monitoring tool (this->MonTool set in python)
104 Monitored::Group(m_monTool, nTracks);
105
106 // return if no tracks
107 if ( tracks.empty() ) return;
108
109 // monitor chi2 for all tracks and find the best
110 float bestChi2 = chi2Cut;
111 // loop over all tracks in the event
112 for (const auto& track : tracks) {
113 float chi2 = track->getChi2ndof();
114 // only monitor tracks below chi2 cut
115 if (chi2 < chi2Cut) {
116 auto mon_chi2 = Monitored::Scalar<float>("chi2_all", chi2);
117 Monitored::Group(m_monTool, mon_chi2);
118 // update best chi2
119 if (chi2 < bestChi2) {
120 bestChi2 = chi2;
121 }
122 }
123 }
124 // monitor the best chi2 found
125 if (bestChi2 < chi2Cut) {
126 auto mon_best_chi2 = Monitored::Scalar<float>("best_chi2", bestChi2);
127 Monitored::Group(m_monTool, mon_best_chi2);
128 }
129
130 // only monitor efficiency for events with truth tracks
131 if (truthTracks.size() > 0) {
132 // use the first truth track (the primary one)
133 const auto& truthTrack = truthTracks.front();
134 // efficiency monitor
135 auto mon_eff = Monitored::Scalar<bool>("eff_track", (tracks.size() > 0));
136 auto mon_truth_pt_zoom = Monitored::Scalar<float>("pT_zoom", truthTrack.getPt()*0.001);
137 auto mon_truth_pt = Monitored::Scalar<float>("pT", truthTrack.getPt()*0.001f);
138 auto mon_truth_eta = Monitored::Scalar<float>("eta", truthTrack.getEta());
139 auto mon_truth_phi = Monitored::Scalar<float>("phi", truthTrack.getPhi());
140 auto mon_truth_d0 = Monitored::Scalar<float>("d0", truthTrack.getD0());
141 auto mon_truth_z0 = Monitored::Scalar<float>("z0", truthTrack.getZ0());
142 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 );
143 }
144}
145
146
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This is the monitoring for the FPGATrackSimTrackMonitor.
Header file to be included by clients of the Monitored infrastructure.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
FPGATrackSimTrackMonitor(const std::string &, const std::string &, const IInterface *)
void fillTrack(const std::vector< const FPGATrackSimTrack * > &tracks, const std::vector< FPGATrackSimTruthTrack > &truthTracks, float chi2Cut)
virtual StatusCode initialize() override
ToolHandle< GenericMonitoringTool > m_monTool
void fillRoad(const std::vector< std::shared_ptr< const FPGATrackSimRoad > > &roads, const std::vector< FPGATrackSimTruthTrack > &truthTracks, size_t nLogicalLayers)
ServiceHandle< ITHistSvc > m_tHistSvc
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
double chi2(TH1 *h0, TH1 *h1)