ATLAS Offline Software
MuonTrackStatisticsTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUONTRACKSTATISTICSTOOL_MUONTRACKSTATISTICSTOOL_H
6 #define MUONTRACKSTATISTICSTOOL_MUONTRACKSTATISTICSTOOL_H
7 
8 #include <string>
9 
11 #include "GaudiKernel/ServiceHandle.h"
12 #include "GaudiKernel/ToolHandle.h"
17 
18 /* namespace Muon { */
19 /* class IMuonEDMHelperSvc; */
20 /* } */
21 
22 /* namespace Trk { */
23 /* class ITruthToTrack; */
24 /* } */
25 
26 static const InterfaceID IID_MuonTrackStatisticsTool("MuonTrackStatisticsTool", 1, 0);
27 
29 public:
30  // AlgTool Constructor
31  MuonTrackStatisticsTool(const std::string&, const std::string&, const IInterface*);
33 
34  // tool interface
35  static const InterfaceID& interfaceID() { return IID_MuonTrackStatisticsTool; }
36 
37  // Gaudi algorithm hooks
40  // statistics to be counted
41  struct TrackCounters {
42  TrackCounters(const std::string & trkLoc) :
43  trackLocation(trkLoc),
44  nEvents(0),
45  nTracks(0),
46  nHits(0),
47  nEtaHits(0),
48  nEtaTrig(0),
49  nPhiHits(0),
50  nScatter(0),
51  nHoles(0),
52  nPsudo(0),
53  summedchi2(0) {}
54 
55  std::string trackLocation;
56  int nEvents;
57  int nTracks;
58  int nHits;
59  int nEtaHits;
60  int nEtaTrig;
61  int nPhiHits;
62  int nScatter;
63  int nHoles;
64  int nPsudo;
65  double summedchi2;
66  };
67 
69  TruthTrackCounters(const std::string & trkLoc) : trackLocation(trkLoc), nEvents(0), nTracks(0) {
70  for (unsigned int i = 0; i < 3; i++) {
71  nPIXELhits[i] = 0;
72  nSCThits[i] = 0;
73  nTRThits[i] = 0;
74  nMDThits[i] = 0;
75  nRPChits[i] = 0;
76  nTGChits[i] = 0;
77  nCSChits[i] = 0;
78  }
79  };
80 
81  std::string trackLocation;
82  int nEvents;
83  int nTracks;
84  int nPIXELhits[3];
85  int nSCThits[3];
86  int nTRThits[3];
87  int nMDThits[3];
88  int nRPChits[3];
89  int nTGChits[3];
90  int nCSChits[3];
91  };
92 
93  // function to access tracks and update counters
94  // First function is an interface to MuonTrackStatisticsAlg, which passes in the retrieved collection from SG and the name, which it
95  // uses to find the appropriate counter The counter and collection are then passed to the 2nd function, which does the updating
96  StatusCode updateTrackCounters(const std::string& name, const TrackCollection* tracks);
98 
99  StatusCode updateTruthTrackCounters(const std::string& name, const DetailedTrackTruthCollection* truthMap);
101 
102  void addTrackCounters(const std::string& trkLoc);
103  // void addTruthTrackCounters( std::string trkLoc ) const;
104  std::string printTrackCounters() const;
105 
106 private:
107  // access to Id Helpers
108  ServiceHandle<Muon::IMuonEDMHelperSvc> m_edmHelperSvc{this, "edmHelper", "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
109  "Handle to the service providing the IMuonEDMHelperSvc interface"};
110 
111  bool m_doTruth;
112 
113  std::vector<MuonTrackStatisticsTool::TrackCounters*> m_allCounters;
114  std::vector<MuonTrackStatisticsTool::TruthTrackCounters*> m_allTruthCounters;
115 
116  void storeTruthTracks(void);
117 };
118 
119 #endif // MUONTRACKSTATISTICSTOOL_MUONTRACKSTATISTICSTOOL_H
MuonTrackStatisticsTool::TrackCounters::trackLocation
std::string trackLocation
Definition: MuonTrackStatisticsTool.h:55
MuonTrackStatisticsTool::TruthTrackCounters::nRPChits
int nRPChits[3]
Definition: MuonTrackStatisticsTool.h:88
MuonTrackStatisticsTool::m_doTruth
bool m_doTruth
Definition: MuonTrackStatisticsTool.h:111
MuonTrackStatisticsTool::TruthTrackCounters::nEvents
int nEvents
Definition: MuonTrackStatisticsTool.h:82
MuonTrackStatisticsTool::TruthTrackCounters::nCSChits
int nCSChits[3]
Definition: MuonTrackStatisticsTool.h:90
MuonTrackStatisticsTool::TrackCounters::nScatter
int nScatter
Definition: MuonTrackStatisticsTool.h:62
MuonTrackStatisticsTool::~MuonTrackStatisticsTool
~MuonTrackStatisticsTool()
Definition: MuonTrackStatisticsTool.h:32
MuonTrackStatisticsTool::printTrackCounters
std::string printTrackCounters() const
Definition: MuonTrackStatisticsTool.cxx:172
MuonTrackStatisticsTool::finalize
StatusCode finalize()
Definition: MuonTrackStatisticsTool.cxx:43
MuonTrackStatisticsTool::TruthTrackCounters::nTGChits
int nTGChits[3]
Definition: MuonTrackStatisticsTool.h:89
MuonTrackStatisticsTool::TruthTrackCounters::nSCThits
int nSCThits[3]
Definition: MuonTrackStatisticsTool.h:85
MuonTrackStatisticsTool::TruthTrackCounters::nTRThits
int nTRThits[3]
Definition: MuonTrackStatisticsTool.h:86
MuonTrackStatisticsTool::TrackCounters::nTracks
int nTracks
Definition: MuonTrackStatisticsTool.h:57
DetailedTrackTruthCollection.h
MuonTrackStatisticsTool::TruthTrackCounters::nMDThits
int nMDThits[3]
Definition: MuonTrackStatisticsTool.h:87
MuonTrackStatisticsTool::m_allCounters
std::vector< MuonTrackStatisticsTool::TrackCounters * > m_allCounters
Definition: MuonTrackStatisticsTool.h:113
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuonTrackStatisticsTool::TrackCounters
Definition: MuonTrackStatisticsTool.h:41
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonTrackStatisticsTool::storeTruthTracks
void storeTruthTracks(void)
Definition: MuonTrackStatisticsTool.cxx:364
MuonTrackStatisticsTool::TrackCounters::nPhiHits
int nPhiHits
Definition: MuonTrackStatisticsTool.h:61
AthAlgTool.h
TrackCollection.h
MuonTrackStatisticsTool::TruthTrackCounters::TruthTrackCounters
TruthTrackCounters(const std::string &trkLoc)
Definition: MuonTrackStatisticsTool.h:69
MuonTrackStatisticsTool::m_edmHelperSvc
ServiceHandle< Muon::IMuonEDMHelperSvc > m_edmHelperSvc
Definition: MuonTrackStatisticsTool.h:108
MuonTrackStatisticsTool::addTrackCounters
void addTrackCounters(const std::string &trkLoc)
Definition: MuonTrackStatisticsTool.cxx:155
MuonTrackStatisticsTool::TrackCounters::summedchi2
double summedchi2
Definition: MuonTrackStatisticsTool.h:65
DataVector< Trk::Track >
MuonTrackStatisticsTool::TrackCounters::nEtaTrig
int nEtaTrig
Definition: MuonTrackStatisticsTool.h:60
MuonTrackStatisticsTool::TrackCounters::TrackCounters
TrackCounters(const std::string &trkLoc)
Definition: MuonTrackStatisticsTool.h:42
IMuonEDMHelperSvc.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonTrackStatisticsTool::TruthTrackCounters
Definition: MuonTrackStatisticsTool.h:68
MuonTrackStatisticsTool
Definition: MuonTrackStatisticsTool.h:28
MuonTrackStatisticsTool::MuonTrackStatisticsTool
MuonTrackStatisticsTool(const std::string &, const std::string &, const IInterface *)
Definition: MuonTrackStatisticsTool.cxx:24
MuonTrackStatisticsTool::TrackCounters::nPsudo
int nPsudo
Definition: MuonTrackStatisticsTool.h:64
MuonTrackStatisticsTool::TrackCounters::nHoles
int nHoles
Definition: MuonTrackStatisticsTool.h:63
MuonTrackStatisticsTool::updateTruthTrackCounters
StatusCode updateTruthTrackCounters(const std::string &name, const DetailedTrackTruthCollection *truthMap)
Definition: MuonTrackStatisticsTool.cxx:50
MuonTrackStatisticsTool::TruthTrackCounters::nTracks
int nTracks
Definition: MuonTrackStatisticsTool.h:83
MuonTrackStatisticsTool::updateTrackCounters
StatusCode updateTrackCounters(const std::string &name, const TrackCollection *tracks)
Definition: MuonTrackStatisticsTool.cxx:117
ITruthToTrack.h
MuonTrackStatisticsTool::interfaceID
static const InterfaceID & interfaceID()
Definition: MuonTrackStatisticsTool.h:35
MuonTrackStatisticsTool::m_allTruthCounters
std::vector< MuonTrackStatisticsTool::TruthTrackCounters * > m_allTruthCounters
Definition: MuonTrackStatisticsTool.h:114
MuonTrackStatisticsTool::TruthTrackCounters::nPIXELhits
int nPIXELhits[3]
Definition: MuonTrackStatisticsTool.h:84
DetailedTrackTruthCollection
Definition: DetailedTrackTruthCollection.h:20
MuonTrackStatisticsTool::TrackCounters::nHits
int nHits
Definition: MuonTrackStatisticsTool.h:58
AthAlgTool
Definition: AthAlgTool.h:26
MuonTrackStatisticsTool::TruthTrackCounters::trackLocation
std::string trackLocation
Definition: MuonTrackStatisticsTool.h:79
MuonTrackStatisticsTool::TrackCounters::nEtaHits
int nEtaHits
Definition: MuonTrackStatisticsTool.h:59
MuonTrackStatisticsTool::initialize
StatusCode initialize()
Definition: MuonTrackStatisticsTool.cxx:35
MuonTrackStatisticsTool::TrackCounters::nEvents
int nEvents
Definition: MuonTrackStatisticsTool.h:56
ServiceHandle< Muon::IMuonEDMHelperSvc >