ATLAS Offline Software
FPGATrackSimTrackMonitor.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
11 #include "TH1D.h"
12 #include "TH2D.h"
13 #include "TTree.h"
14 #include <bit>
16 
17 
19 FPGATrackSimTrackMonitor::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 
51 void 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)
58  Monitored::Group(m_monTool, nRoads);
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
76  Monitored::Group(m_monTool, nLayers);
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 
97 void 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 
FPGATrackSimTrackMonitor::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
Definition: FPGATrackSimTrackMonitor.h:76
getMenu.algname
algname
Definition: getMenu.py:54
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthMsgStreamMacros.h
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:157
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:525
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
FPGATrackSimTrackMonitor::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: FPGATrackSimTrackMonitor.h:69
FPGATrackSimTrackMonitor.h
This is the monitoring for the FPGATrackSimTrackMonitor.
FPGATrackSimTrackMonitor::fillTrack
void fillTrack(const std::vector< const FPGATrackSimTrack * > &tracks, const std::vector< FPGATrackSimTruthTrack > &truthTracks, float chi2Cut)
Definition: FPGATrackSimTrackMonitor.cxx:97
FPGATrackSimTrackMonitor::fillRoad
void fillRoad(const std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads, const std::vector< FPGATrackSimTruthTrack > &truthTracks, size_t nLogicalLayers)
Definition: FPGATrackSimTrackMonitor.cxx:51
FPGATrackSimTrackMonitor::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimTrackMonitor.cxx:27
FPGATrackSimTrackMonitor::FPGATrackSimTrackMonitor
FPGATrackSimTrackMonitor(const std::string &, const std::string &, const IInterface *)
Definition: FPGATrackSimTrackMonitor.cxx:19
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
AthAlgTool
Definition: AthAlgTool.h:26