ATLAS Offline Software
MuonPerformanceAlg.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 MUONPERFORMANCEALG_H
6 #define MUONPERFORMANCEALG_H
7 
8 #include <fstream>
9 #include <string>
10 #include <vector>
11 
13 #include "GaudiKernel/ToolHandle.h"
16 #include "xAODMuon/Muon.h"
17 #include "xAODMuon/MuonContainer.h"
22 
24 public:
25  // Algorithm Constructor
26  MuonPerformanceAlg(const std::string& name, ISvcLocator* pSvcLocator);
27  virtual ~MuonPerformanceAlg() = default;
28  // Gaudi algorithm hooks
29  virtual StatusCode initialize() override;
30  virtual StatusCode execute() override;
31  virtual StatusCode finalize() override;
32 
33  virtual unsigned int cardinality() const override final { return 1;}
34 
35  // statistics to be counted
36  std::vector<std::string> m_muonLocationList;
37 
38 private:
39  bool passID(const xAOD::TrackParticle*, bool debug) const;
40 
43  std::string m_fileName;
44 
46  std::ofstream m_fileOutput;
47 
48  // Containers
49  SG::ReadHandleKey<xAOD::MuonContainer> m_muonsNameKey{this, "MuonContainerName", "Muons", "muon container"};
50  SG::ReadDecorHandleKey<xAOD::MuonContainer> m_muonTruthParticleKey {this,"muonTruthParticleLinkKey", m_muonsNameKey, "truthParticleLink"};
51  unsigned int m_nevents;
52  std::vector<std::string> m_hitCutString;
53  std::vector<int> m_ntruth;
54  std::vector<int> m_ntruth5;
55  std::vector<int> m_ntruth10;
56  std::vector<int> m_nfound;
57  std::vector<int> m_nfound5;
58  std::vector<int> m_nfound10;
59  std::vector<int> m_nfoundr;
60  std::vector<int> m_nfoundr5;
61  std::vector<int> m_nfoundr10;
62  std::vector<int> m_nreco;
63  std::vector<int> m_nreco5;
64  std::vector<int> m_nreco10;
65 
66  SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfo", "EventInfo", "event info"};
67  SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthMuons{this, "TruthMuons", "MuonTruthParticles", "truth muons"};
71 
74 
75  void print(const std::string& txt, const xAOD::TruthParticle* muon);
76  void print(const std::string& txt, const xAOD::Muon* muon);
77 
78  IntegerArrayProperty m_pdgsToBeConsidered;
79  std::set<int> m_selectedPdgs; // set storing particle PDG's considered for matching
80  bool selectPdg(int pdg) const { return m_selectedPdgs.count(pdg); }
81 };
82 
83 #endif // MUONPERFORMANCEALG
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
MuonPerformanceAlg::m_nevents
unsigned int m_nevents
Definition: MuonPerformanceAlg.h:51
MuonPerformanceAlg::print
void print(const std::string &txt, const xAOD::TruthParticle *muon)
Definition: MuonPerformanceAlg.cxx:571
MuonPerformanceAlg::m_fileName
std::string m_fileName
Definition: MuonPerformanceAlg.h:43
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
MuonPerformanceAlg::m_muonsNameKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonsNameKey
Definition: MuonPerformanceAlg.h:49
ReadDecorHandleKey.h
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
MuonPerformanceAlg::selectPdg
bool selectPdg(int pdg) const
Definition: MuonPerformanceAlg.h:80
Muon.h
MuonPerformanceAlg
Definition: MuonPerformanceAlg.h:23
TruthParticleContainer.h
MuonPerformanceAlg::m_nfoundr10
std::vector< int > m_nfoundr10
Definition: MuonPerformanceAlg.h:61
MuonPerformanceAlg::m_nreco
std::vector< int > m_nreco
Definition: MuonPerformanceAlg.h:62
MuonPerformanceAlg::m_writeToFile
bool m_writeToFile
name of external file to write statistics
Definition: MuonPerformanceAlg.h:42
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
MuonPerformanceAlg::m_nfound
std::vector< int > m_nfound
Definition: MuonPerformanceAlg.h:56
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
MuonPerformanceAlg::m_selectedPdgs
std::set< int > m_selectedPdgs
Definition: MuonPerformanceAlg.h:79
MuonPerformanceAlg::m_runNumber
int m_runNumber
Definition: MuonPerformanceAlg.h:72
MuonPerformanceAlg::m_muonTruthParticleKey
SG::ReadDecorHandleKey< xAOD::MuonContainer > m_muonTruthParticleKey
Definition: MuonPerformanceAlg.h:50
AthAlgorithm.h
MuonPerformanceAlg::m_nfoundr5
std::vector< int > m_nfoundr5
Definition: MuonPerformanceAlg.h:60
MuonPerformanceAlg::m_fileOutput
std::ofstream m_fileOutput
output file
Definition: MuonPerformanceAlg.h:46
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
MuonPerformanceAlg::m_eventNumber
int m_eventNumber
Definition: MuonPerformanceAlg.h:73
MuonPerformanceAlg::m_nreco10
std::vector< int > m_nreco10
Definition: MuonPerformanceAlg.h:64
MuonPerformanceAlg::~MuonPerformanceAlg
virtual ~MuonPerformanceAlg()=default
MuonPerformanceAlg::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition: MuonPerformanceAlg.h:66
MuonPerformanceAlg::cardinality
virtual unsigned int cardinality() const override final
Definition: MuonPerformanceAlg.h:33
AthAlgorithm
Definition: AthAlgorithm.h:47
MuonPerformanceAlg::m_truthMuons
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthMuons
Definition: MuonPerformanceAlg.h:67
MuonPerformanceAlg::m_ntruth
std::vector< int > m_ntruth
Definition: MuonPerformanceAlg.h:53
MuonPerformanceAlg::m_nfound10
std::vector< int > m_nfound10
Definition: MuonPerformanceAlg.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
MuonPerformanceAlg::m_truthMuonRecoMuonLinkKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthMuonRecoMuonLinkKey
Definition: MuonPerformanceAlg.h:68
MuonPerformanceAlg::execute
virtual StatusCode execute() override
Definition: MuonPerformanceAlg.cxx:126
MuonPerformanceAlg::m_ntruth5
std::vector< int > m_ntruth5
Definition: MuonPerformanceAlg.h:54
MuonPerformanceAlg::m_ntruth10
std::vector< int > m_ntruth10
Definition: MuonPerformanceAlg.h:55
EventInfo.h
MuonContainer.h
MuonPerformanceAlg::MuonPerformanceAlg
MuonPerformanceAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonPerformanceAlg.cxx:20
TrackParticle.h
MuonPerformanceAlg::m_nfoundr
std::vector< int > m_nfoundr
Definition: MuonPerformanceAlg.h:59
MuonPerformanceAlg::m_truthMuonTruthOrigin
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthMuonTruthOrigin
Definition: MuonPerformanceAlg.h:70
MuonPerformanceAlg::finalize
virtual StatusCode finalize() override
Definition: MuonPerformanceAlg.cxx:596
MuonPerformanceAlg::m_hitCutString
std::vector< std::string > m_hitCutString
Definition: MuonPerformanceAlg.h:52
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
SG::ReadDecorHandleKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Definition: StoreGate/StoreGate/ReadDecorHandleKey.h:85
TruthParticle.h
MuonPerformanceAlg::m_truthMuonTruthType
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthMuonTruthType
Definition: MuonPerformanceAlg.h:69
MuonPerformanceAlg::m_nreco5
std::vector< int > m_nreco5
Definition: MuonPerformanceAlg.h:63
MuonPerformanceAlg::m_pdgsToBeConsidered
IntegerArrayProperty m_pdgsToBeConsidered
Definition: MuonPerformanceAlg.h:78
MuonPerformanceAlg::m_nfound5
std::vector< int > m_nfound5
Definition: MuonPerformanceAlg.h:57
MuonPerformanceAlg::passID
bool passID(const xAOD::TrackParticle *, bool debug) const
Definition: MuonPerformanceAlg.cxx:67
MuonPerformanceAlg::m_muonLocationList
std::vector< std::string > m_muonLocationList
Definition: MuonPerformanceAlg.h:36
MuonPerformanceAlg::initialize
virtual StatusCode initialize() override
Definition: MuonPerformanceAlg.cxx:27