ATLAS Offline Software
Loading...
Searching...
No Matches
MuonTrackTruthTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUON_MUONTRACKTRUTHTOOL_H
6#define MUON_MUONTRACKTRUTHTOOL_H
7
8#include <map>
9#include <set>
10#include <string>
11#include <utility>
12#include <vector>
13
15
16
25
26class TruthTrajectory;
27
28namespace Muon {
29 class MuonSegment;
30}
31
32namespace Trk {
33 class Track;
34 class MeasurementBase;
35} // namespace Trk
36
37namespace Muon {
38
43 class MuonTrackTruthTool : public extends<AthAlgTool, IMuonTrackTruthTool> {
44 public:
46 bool operator()(const MatchResult& r1, const MatchResult& r2) const;
47 bool operator()(const SegmentMatchResult& r1, const SegmentMatchResult& r2) const;
48 bool operator()(const MuonTrackTruth& r1, const MuonTrackTruth& r2) const;
49 };
50
51 public:
53 using base_class::base_class;
56
58 StatusCode initialize();
59
61 ResultVec match(const TruthTree& truth_tree, const TrackCollection& tracks) const;
62
64 SegmentResultVec match(const TruthTree& truth_tree, const std::vector<const MuonSegment*>& segments) const;
65
67 MuonTrackTruth getTruth(const TruthTree& truth_tree, const Trk::Track& track, bool restrictedTruth = false) const;
68
70 MuonTrackTruth getTruth(const TruthTree& truth_tree, const std::vector<const MuonSegment*>& segments,
71 bool restrictedTruth = false) const;
72
74 MuonTrackTruth getTruth(const TruthTree& truth_tree, const Muon::MuonSegment& segment) const;
75
79 MuonTrackTruth getTruth(const TruthTree& truth_tree, const std::vector<const Trk::MeasurementBase*>& measurements,
80 bool restrictedTruth = false) const;
81
83 const TruthTree createTruthTree(const TrackRecordCollection* truthTrackCol, const McEventCollection* mcEventCollection,
84 const std::vector<const MuonSimDataCollection*>& muonSimData,
85 const CscSimDataCollection* cscSimDataMap) const;
86
89 HepMC::ConstGenParticlePtr getMother(const TruthTrajectory& traj, const int barcodeIn) const;
90
93 HepMC::ConstGenParticlePtr getAncestor(const TruthTrajectory& traj, const int barcodeIn) const;
94
98 HepMC::ConstGenParticlePtr getInitial(const TruthTrajectory& traj, const int barcodeIn) const;
99
102 unsigned int getNumberOfScatters(const TruthTrajectory& traj, const int barcodeIn) const;
103
104 private:
105 MuonTrackTruth getTruth(const std::vector<const Trk::MeasurementBase*>& measurements, const TruthTreeEntry& truthEntry,
106 bool restrictedTruth) const;
107
108 void addSimDataToTree(TruthTree& truth_tree, std::map<int, int>& barcode_map, const MuonSimDataCollection* simDataCol) const;
109 void addCscSimDataToTree(TruthTree& truth_tree, std::map<int, int>& barcode_map, const CscSimDataCollection* simDataCol) const;
110
111 void addMdtTruth(MuonTechnologyTruth& trackTruth, const Identifier& id, const Trk::MeasurementBase& meas,
112 const MuonSimDataCollection& simCol) const;
113
114 void addClusterTruth(MuonTechnologyTruth& trackTruth, const Identifier& id, const Trk::MeasurementBase& meas,
115 const MuonSimDataCollection& simCol) const;
116 void addClusterTruth(MuonTechnologyTruth& trackTruth, const Identifier& id, const Trk::MeasurementBase& meas,
117 const CscSimDataCollection& simCol) const;
118
119 void addMissedHits(MuonTechnologyTruth& truth, const std::set<Identifier>& ids, const std::set<Identifier>& chids,
120 const MuonSimDataCollection& simCol, bool restrictedTruth) const;
121
122 void addMissedHits(MuonTechnologyTruth& truth, const std::set<Identifier>& ids, const std::set<Identifier>& chids,
123 const CscSimDataCollection& simCol, bool restrictedTruth) const;
124
125 int manipulateBarCode(int barcode) const;
126
127 bool selectPdg(int pdg) const { return m_selectedPdgs.count(pdg); }
128
132 const std::pair<HepMC::ConstGenParticlePtr, unsigned int> getInitialPair(const TruthTrajectory& traj, const int barcodeIn) const;
133
134 ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
135
136 PublicToolHandle<Muon::MuonEDMPrinterTool> m_printer{this, "Printer", "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"};
137 ToolHandle<Trk::ITruthTrajectoryBuilder> m_truthTrajectoryBuilder{
138 this, "TruthTrajectoryBuilder", "Muon::MuonDecayTruthTrajectoryBuilder/MuonDecayTruthTrajectoryBuilder"};
139
140 Gaudi::Property<bool> m_manipulateBarCode{this, "ManipulateBarCode", false};
141 Gaudi::Property<bool> m_doSummary{this, "DoSummary", false};
142 Gaudi::Property<bool> m_matchAllParticles{this, "MatchAllParticles", true};
143 Gaudi::Property<unsigned int> m_minHits{this, "MinHits", 4};
144 Gaudi::Property<std::vector<int>> m_pdgsToBeConsidered{this, "ConsideredPDGs", {}};
145
146 std::set<int> m_selectedPdgs; // set storing particle PDG's considered for matching
147 };
148
149} // namespace Muon
150
151#endif // MUON_MDTONTRACKTOOL_H
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
AtlasHitsVector< TrackRecord > TrackRecordCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
This is the common class for 3D segments used in the muon spectrometer.
Tool to calculate track truth.
ToolHandle< Trk::ITruthTrajectoryBuilder > m_truthTrajectoryBuilder
MuonTrackTruth getTruth(const TruthTree &truth_tree, const Trk::Track &track, bool restrictedTruth=false) const
get track truth
void addClusterTruth(MuonTechnologyTruth &trackTruth, const Identifier &id, const Trk::MeasurementBase &meas, const MuonSimDataCollection &simCol) const
bool selectPdg(int pdg) const
Gaudi::Property< unsigned int > m_minHits
void addCscSimDataToTree(TruthTree &truth_tree, std::map< int, int > &barcode_map, const CscSimDataCollection *simDataCol) const
~MuonTrackTruthTool()=default
destructor
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< std::vector< int > > m_pdgsToBeConsidered
const TruthTree createTruthTree(const TrackRecordCollection *truthTrackCol, const McEventCollection *mcEventCollection, const std::vector< const MuonSimDataCollection * > &muonSimData, const CscSimDataCollection *cscSimDataMap) const
create truth tree from sim data
void addMissedHits(MuonTechnologyTruth &truth, const std::set< Identifier > &ids, const std::set< Identifier > &chids, const MuonSimDataCollection &simCol, bool restrictedTruth) const
int manipulateBarCode(int barcode) const
ResultVec match(const TruthTree &truth_tree, const TrackCollection &tracks) const
perform truth matching for a given set of tracks
Gaudi::Property< bool > m_manipulateBarCode
HepMC::ConstGenParticlePtr getInitial(const TruthTrajectory &traj, const int barcodeIn) const
Returns the initial particle of the particle with barcodeIn if it is found in the truth trajectory.
unsigned int getNumberOfScatters(const TruthTrajectory &traj, const int barcodeIn) const
Returns the number of steps a particle took while maintaining its PDG ID.
Gaudi::Property< bool > m_matchAllParticles
HepMC::ConstGenParticlePtr getMother(const TruthTrajectory &traj, const int barcodeIn) const
Returns the mother particle of the particle with barcodeIn if it is found in the truth trajectory.
void addMdtTruth(MuonTechnologyTruth &trackTruth, const Identifier &id, const Trk::MeasurementBase &meas, const MuonSimDataCollection &simCol) const
StatusCode initialize()
AlgTool initilize.
Gaudi::Property< bool > m_doSummary
PublicToolHandle< Muon::MuonEDMPrinterTool > m_printer
const std::pair< HepMC::ConstGenParticlePtr, unsigned int > getInitialPair(const TruthTrajectory &traj, const int barcodeIn) const
Returns the initial particle of the particle with barcodeIn if it is found in the truth trajectory.
void addSimDataToTree(TruthTree &truth_tree, std::map< int, int > &barcode_map, const MuonSimDataCollection *simDataCol) const
HepMC::ConstGenParticlePtr getAncestor(const TruthTrajectory &traj, const int barcodeIn) const
Returns the ancestor particle of the particle with barcodeIn if it is found in the truth trajectory.
This class is the pure abstract base class for all fittable tracking measurements.
A TruthTrajectory is a chain of charged MC particles connected through the mother-daughter relationsh...
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Ensure that the ATLAS eigen extensions are properly loaded.
bool operator()(const MatchResult &r1, const MatchResult &r2) const
bool operator()(const SegmentMatchResult &r1, const SegmentMatchResult &r2) const