ATLAS Offline Software
IMuonTrackTruthTool.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 MUON_IMUONTRACKTRUTHTOOL_H
6 #define MUON_IMUONTRACKTRUTHTOOL_H
7 
8 #include <map>
9 #include <set>
10 #include <vector>
11 
12 #include "GaudiKernel/IAlgTool.h"
14 #include "Identifier/Identifier.h"
19 
20 static const InterfaceID IID_IMuonTrackTruthTool("Muon::IMuonTrackTruthTool", 1, 0);
21 
22 class TruthTrajectory;
23 
24 namespace Muon {
25  class MuonSegment;
26 }
27 
28 namespace Muon {
29 
31  public:
32  std::set<Identifier> matchedHits;
33  std::set<Identifier> matchedChambers;
34  std::set<Identifier> missedHits;
35  std::set<Identifier> missedChambers;
36  std::set<Identifier> wrongHits;
37  std::set<Identifier> wrongChambers;
38  };
39 
41  public:
43  std::shared_ptr<const TruthTrajectory> truthTrajectory;
52  unsigned int numberOfMatchedHits() const {
53  return mdts.matchedHits.size() + tgcs.matchedHits.size() + rpcs.matchedHits.size() + cscs.matchedHits.size() +
54  stgcs.matchedHits.size() + mms.matchedHits.size();
55  }
57  };
58 
60  public:
70  };
71 
73  class IMuonTrackTruthTool : virtual public IAlgTool {
74  public:
75  struct TruthTreeEntry {
77  std::shared_ptr<const TruthTrajectory> truthTrajectory;
84  };
85 
86  typedef std::pair<const Trk::Track*, MuonTrackTruth> MatchResult;
87  typedef std::vector<MatchResult> ResultVec;
88 
89  typedef std::pair<const Muon::MuonSegment*, MuonTrackTruth> SegmentMatchResult;
90  typedef std::vector<SegmentMatchResult> SegmentResultVec;
91 
92  // collect track record entries per barcode
93  typedef std::map<int, TruthTreeEntry> TruthTree;
95  typedef TruthTree::const_iterator TruthTreeConstIt;
96 
97  public:
99  static const InterfaceID& interfaceID();
100 
102  virtual ResultVec match(const TruthTree& truth_tree, const TrackCollection& tracks) const = 0;
103 
105  virtual SegmentResultVec match(const TruthTree& truth_tree, const std::vector<const MuonSegment*>& segments) const = 0;
106 
108  virtual const TruthTree createTruthTree(const TrackRecordCollection* truthTrackCol, const McEventCollection* mcEventCollection,
109  const std::vector<const MuonSimDataCollection*>& muonSimData,
110  const CscSimDataCollection* cscSimDataMap) const = 0;
111 
113  virtual MuonTrackTruth getTruth(const TruthTree& truth_tree, const Trk::Track& track, bool restrictedTruth = false) const = 0;
114 
116  virtual MuonTrackTruth getTruth(const TruthTree& truth_tree, const std::vector<const MuonSegment*>& segments,
117  bool restrictedTruth = false) const = 0;
118 
121 
125  virtual MuonTrackTruth getTruth(const TruthTree& truth_tree, const std::vector<const Trk::MeasurementBase*>& measurements,
126  bool restrictedTruth = false) const = 0;
127 
130  virtual HepMC::ConstGenParticlePtr getMother(const TruthTrajectory& traj, const int barcodeIn) const = 0;
131 
134  virtual HepMC::ConstGenParticlePtr getAncestor(const TruthTrajectory& traj, const int barcodeIn) const = 0;
135 
138  virtual HepMC::ConstGenParticlePtr getInitial(const TruthTrajectory& traj, const int barcodeIn) const = 0;
139 
141  virtual unsigned int getNumberOfScatters(const TruthTrajectory& traj, const int barcodeIn) const = 0;
142  };
143 
144  inline const InterfaceID& IMuonTrackTruthTool::interfaceID() { return IID_IMuonTrackTruthTool; }
145 
146 } // namespace Muon
147 
148 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Muon::MuonTechnologyTruth
Definition: IMuonTrackTruthTool.h:30
Muon::MuonSegmentTruth::isHitMatched
bool isHitMatched
Definition: IMuonTrackTruthTool.h:62
Muon::MuonSegmentTruth::rpcs
MuonTechnologyTruth rpcs
Definition: IMuonTrackTruthTool.h:65
Muon::MuonTrackTruth::isHitMatched
bool isHitMatched
Definition: IMuonTrackTruthTool.h:44
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
CscSimDataCollection.h
Muon::MuonTrackTruth::truthTrajectory
std::shared_ptr< const TruthTrajectory > truthTrajectory
Definition: IMuonTrackTruthTool.h:43
Muon::MuonTrackTruth::stgcs
MuonTechnologyTruth stgcs
Definition: IMuonTrackTruthTool.h:50
Muon::MuonTechnologyTruth::matchedHits
std::set< Identifier > matchedHits
Definition: IMuonTrackTruthTool.h:32
AtlasHitsVector
Definition: AtlasHitsVector.h:33
Muon::MuonSegmentTruth::truthTrack
const TrackRecord * truthTrack
Definition: IMuonTrackTruthTool.h:61
Muon::MuonTechnologyTruth::wrongHits
std::set< Identifier > wrongHits
Definition: IMuonTrackTruthTool.h:36
Muon::IMuonTrackTruthTool::TruthTreeIt
TruthTree::iterator TruthTreeIt
Definition: IMuonTrackTruthTool.h:94
Muon::MuonSegmentTruth::cscs
MuonTechnologyTruth cscs
Definition: IMuonTrackTruthTool.h:64
Muon::IMuonTrackTruthTool::createTruthTree
virtual const TruthTree createTruthTree(const TrackRecordCollection *truthTrackCol, const McEventCollection *mcEventCollection, const std::vector< const MuonSimDataCollection * > &muonSimData, const CscSimDataCollection *cscSimDataMap) const =0
create truth tree from sim data
Muon::IMuonTrackTruthTool::interfaceID
static const InterfaceID & interfaceID()
access to tool interface
Definition: IMuonTrackTruthTool.h:144
Muon::IMuonTrackTruthTool::TruthTreeEntry::cscHits
CscSimDataCollection cscHits
Definition: IMuonTrackTruthTool.h:79
Muon::MuonTrackTruth::MuonTrackTruth
MuonTrackTruth()
Definition: IMuonTrackTruthTool.h:56
Muon::IMuonTrackTruthTool::TruthTreeEntry::mmHits
MuonSimDataCollection mmHits
Definition: IMuonTrackTruthTool.h:83
Muon::IMuonTrackTruthTool::getTruth
virtual MuonTrackTruth getTruth(const TruthTree &truth_tree, const Trk::Track &track, bool restrictedTruth=false) const =0
get track truth
Muon::MuonTrackTruth
Definition: IMuonTrackTruthTool.h:40
Muon::MuonTrackTruth::mms
MuonTechnologyTruth mms
Definition: IMuonTrackTruthTool.h:51
Muon::IMuonTrackTruthTool::TruthTreeEntry::stgcHits
MuonSimDataCollection stgcHits
Definition: IMuonTrackTruthTool.h:82
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
Muon::MuonTechnologyTruth::missedHits
std::set< Identifier > missedHits
Definition: IMuonTrackTruthTool.h:34
xAOD::MuonSegment
MuonSegment_v1 MuonSegment
Reference the current persistent version:
Definition: Event/xAOD/xAODMuon/xAODMuon/MuonSegment.h:13
Muon::MuonSegmentTruth::stgcs
MuonTechnologyTruth stgcs
Definition: IMuonTrackTruthTool.h:67
Muon::IMuonTrackTruthTool::getTruth
virtual MuonTrackTruth getTruth(const TruthTree &truth_tree, const Muon::MuonSegment &segment) const =0
get segment truth
Muon::MuonTrackTruth::mdts
MuonTechnologyTruth mdts
Definition: IMuonTrackTruthTool.h:46
Muon::IMuonTrackTruthTool::getMother
virtual HepMC::ConstGenParticlePtr getMother(const TruthTrajectory &traj, const int barcodeIn) const =0
returns the mother particle of the particle with barcodeIn if it is found in the truth trajectory It ...
inspect_truth_file.truth_tree
truth_tree
Definition: inspect_truth_file.py:75
Muon::IMuonTrackTruthTool::getAncestor
virtual HepMC::ConstGenParticlePtr getAncestor(const TruthTrajectory &traj, const int barcodeIn) const =0
Returns the ancestor particle of the particle with barcodeIn if it is found in the truth trajectory.
Muon::IMuonTrackTruthTool::getInitial
virtual HepMC::ConstGenParticlePtr getInitial(const TruthTrajectory &traj, const int barcodeIn) const =0
Returns the initial particle of the particle with barcodeIn if it is found in the truth trajectory.
Muon::IMuonTrackTruthTool::MatchResult
std::pair< const Trk::Track *, MuonTrackTruth > MatchResult
Definition: IMuonTrackTruthTool.h:86
McEventCollection.h
Muon::IMuonTrackTruthTool::TruthTreeEntry::tgcHits
MuonSimDataCollection tgcHits
Definition: IMuonTrackTruthTool.h:81
Muon::MuonSegmentTruth
Definition: IMuonTrackTruthTool.h:59
Muon::IMuonTrackTruthTool::getNumberOfScatters
virtual unsigned int getNumberOfScatters(const TruthTrajectory &traj, const int barcodeIn) const =0
Returns the number of steps a particle took while maintaining its PDG ID.
MuonSimDataCollection
Definition: MuonSimDataCollection.h:21
TrackCollection.h
Muon::MuonTechnologyTruth::matchedChambers
std::set< Identifier > matchedChambers
Definition: IMuonTrackTruthTool.h:33
CscSimDataCollection
Definition: CscSimDataCollection.h:29
Muon::IMuonTrackTruthTool::match
virtual SegmentResultVec match(const TruthTree &truth_tree, const std::vector< const MuonSegment * > &segments) const =0
perform truth matching for a given set of segments
Muon::MuonTrackTruth::isParameterMatched
bool isParameterMatched
Definition: IMuonTrackTruthTool.h:45
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
DataVector< Trk::Track >
Muon::IMuonTrackTruthTool::TruthTreeEntry::truthTrajectory
std::shared_ptr< const TruthTrajectory > truthTrajectory
Definition: IMuonTrackTruthTool.h:77
Muon::IMuonTrackTruthTool::TruthTreeConstIt
TruthTree::const_iterator TruthTreeConstIt
Definition: IMuonTrackTruthTool.h:95
Muon::MuonSegmentTruth::mm
MuonTechnologyTruth mm
Definition: IMuonTrackTruthTool.h:68
Muon::MuonSegmentTruth::tgcs
MuonTechnologyTruth tgcs
Definition: IMuonTrackTruthTool.h:66
Muon::IMuonTrackTruthTool::getTruth
virtual MuonTrackTruth getTruth(const TruthTree &truth_tree, const std::vector< const MuonSegment * > &segments, bool restrictedTruth=false) const =0
get segment truth for a list of segments, the segments will be considered to belong to the same muon
Muon::MuonTechnologyTruth::missedChambers
std::set< Identifier > missedChambers
Definition: IMuonTrackTruthTool.h:35
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
TruthTrajectory
Definition: TruthTrajectory.h:26
Muon::MuonTrackTruth::tgcs
MuonTechnologyTruth tgcs
Definition: IMuonTrackTruthTool.h:49
Muon::IMuonTrackTruthTool::TruthTreeEntry::rpcHits
MuonSimDataCollection rpcHits
Definition: IMuonTrackTruthTool.h:80
TrackRecordCollection.h
Muon::IMuonTrackTruthTool::SegmentResultVec
std::vector< SegmentMatchResult > SegmentResultVec
Definition: IMuonTrackTruthTool.h:90
TrackRecord
Definition: TrackRecord.h:10
Muon::MuonSegmentTruth::MuonSegmentTruth
MuonSegmentTruth()
Definition: IMuonTrackTruthTool.h:69
Muon::IMuonTrackTruthTool::TruthTreeEntry
Definition: IMuonTrackTruthTool.h:75
Muon::IMuonTrackTruthTool::getTruth
virtual MuonTrackTruth getTruth(const TruthTree &truth_tree, const std::vector< const Trk::MeasurementBase * > &measurements, bool restrictedTruth=false) const =0
get truth for a give set of hits.
Muon::IMuonTrackTruthTool::TruthTree
std::map< int, TruthTreeEntry > TruthTree
Definition: IMuonTrackTruthTool.h:93
Muon::MuonTechnologyTruth::wrongChambers
std::set< Identifier > wrongChambers
Definition: IMuonTrackTruthTool.h:37
Muon::IMuonTrackTruthTool::TruthTreeEntry::mdtHits
MuonSimDataCollection mdtHits
Definition: IMuonTrackTruthTool.h:78
Muon::IMuonTrackTruthTool
The IMuonTrackTruthTool is a pure virtual interface for tools that recover hole on a track.
Definition: IMuonTrackTruthTool.h:73
Muon::IMuonTrackTruthTool::SegmentMatchResult
std::pair< const Muon::MuonSegment *, MuonTrackTruth > SegmentMatchResult
Definition: IMuonTrackTruthTool.h:89
Muon::IMuonTrackTruthTool::ResultVec
std::vector< MatchResult > ResultVec
Definition: IMuonTrackTruthTool.h:87
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
Muon::MuonTrackTruth::rpcs
MuonTechnologyTruth rpcs
Definition: IMuonTrackTruthTool.h:48
MuonSimDataCollection.h
Muon::MuonTrackTruth::numberOfMatchedHits
unsigned int numberOfMatchedHits() const
Definition: IMuonTrackTruthTool.h:52
Muon::MuonSegmentTruth::mdts
MuonTechnologyTruth mdts
Definition: IMuonTrackTruthTool.h:63
Muon::MuonTrackTruth::cscs
MuonTechnologyTruth cscs
Definition: IMuonTrackTruthTool.h:47
Muon::IMuonTrackTruthTool::TruthTreeEntry::truthTrack
const TrackRecord * truthTrack
Definition: IMuonTrackTruthTool.h:76
Muon::IMuonTrackTruthTool::match
virtual ResultVec match(const TruthTree &truth_tree, const TrackCollection &tracks) const =0
perform truth matching for a given set of tracks
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
Muon::MuonTrackTruth::truthTrack
const TrackRecord * truthTrack
Definition: IMuonTrackTruthTool.h:42