ATLAS Offline Software
InDetSecVtxTruthMatchTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef InDetSecVtxTruthMatchTool_h
6 #define InDetSecVtxTruthMatchTool_h
7 
8 // Framework include(s):
9 #include "AsgTools/AsgTool.h"
11 
12 // EDM include(s):
19 
20 
21 // standard includes
22 #include<vector>
23 #include <bitset>
24 
26 
27  //Namespace for useful analysis things on the truth matching decorations applied to the VertexContainer
28 
29  //How the matching info is stored; link to the truth vertex, a float with its contribution to the relative track weight, and a float with its contribution to the track sumpt2 of the truth vertex
30  typedef std::tuple<ElementLink<xAOD::TruthVertexContainer>, float, float> VertexTruthMatchInfo;
31 
32  //type codes for vertex matching on all vertices
34  Matched=0, // > threshold (default 50%) from one truth interaction
35  Merged, // not matched
36  Split, // highest weight truth interaction contributes to >1 vtx (vtx with highest fraction of sumpT2 remains matched/merged)
37  Fake, // highest contribution is fake (if pile-up MC info not present those tracks end up as "fakes")
38  Other
39  };
40 
41  //type codes for optional SM origin matching
42  //used to determine the content of "other" type vertices above for in-depth studies
43  //should only be used where extended truth info is available -- e.g when LLP1 has been run with saveFullTruth=True
44  //NOTE: types are NOT exclusive -- vertex can be both from B and D decay, signal and hadronic interation, etc
46  // Must match InDet::TrkOrigin::OriginType values!
62  Signal
63 };
64 
65  //type codes for truth vertices
66  //NOTE: types are subsets of subsequent types
68  Reconstructable=0, // fiducial cuts, >= 2 charged daughters
69  Accepted, // >= 2 reco tracks
70  Seeded, // tracks pass cuts
71  Reconstructed, // matched to reco vtx
72  ReconstructedSplit // matched to multiple vtx
73  };
74 
75  inline bool isMatched(int matchInfo) {
76  if (matchInfo & (0x1 << Matched)) return true;
77  return false;
78  }
79  inline bool isMerged(int matchInfo) {
80  if (matchInfo & (0x1 << Merged)) return true;
81  return false;
82  }
83  inline bool isSplit(int matchInfo) {
84  if (matchInfo & (0x1 << Split)) return true;
85  return false;
86  }
87  inline bool isFake(int matchInfo) {
88  if (matchInfo & (0x1 << Fake)) return true;
89  return false;
90  }
91  inline bool isOther(int matchInfo) {
92  if (matchInfo & (0x1 << Other)) return true;
93  return false;
94  }
95 
96  inline bool isReconstructable(int matchInfo) {
97  if (matchInfo & (0x1 << Reconstructable)) return true;
98  return false;
99  }
100  inline bool isAccepted(int matchInfo) {
101  if (matchInfo & (0x1 << Accepted)) return true;
102  return false;
103  }
104  inline bool isSeeded(int matchInfo) {
105  if (matchInfo & (0x1 << Seeded)) return true;
106  return false;
107  }
108  inline bool isReconstructed(int matchInfo) {
109  if (matchInfo & (0x1 << Reconstructed)) return true;
110  return false;
111  }
112  inline bool isReconstructedSplit(int matchInfo) {
113  if (matchInfo & (0x1 << ReconstructedSplit)) return true;
114  return false;
115  }
116 
117  inline bool isOriginType(int matchInfo, VertexMatchOriginType type) {
118  if (type < 0 || type > Signal) { // Signal is the last valid value
119  return false;
120  }
121  return matchInfo & (0x1 << type);
122  }
123 }
124 
130  public asg::AsgTool {
131 
133 
134  public:
135 
136  InDetSecVtxTruthMatchTool( const std::string & name );
137 
138  virtual StatusCode initialize() override final;
139 
140  // take collection of vertices, match them, and decorate with matching info
141  virtual StatusCode matchVertices( std::vector<const xAOD::Vertex*> recoVerticesToMatch, std::vector<const xAOD::TruthVertex*> truthVerticesToMatch, const xAOD::TrackParticleContainer* trackParticles ) override;
142 
143  private:
144 
145  Gaudi::Property<float> m_trkMatchProb{this, "trackMatchProb", 0.5, "Required MC match probability to consider track a good match" };
146  Gaudi::Property<float> m_vxMatchWeight{this, "vertexMatchWeight", 0.5, "Relative weight threshold to consider vertex matched"};
147  Gaudi::Property<float> m_trkPtCut{this, "trackPtCut", 1000., "pt cut to apply on tracks"};
148  Gaudi::Property<std::string> m_selectedTrackFlag{this, "selectedTrackFlag", "is_selected", "Aux decoration on tracks for seeding efficiencies"};
149  Gaudi::Property<bool> m_doMuSA{this, "doMuSA", false, "Combination flag for special MuSA logic" };
150  Gaudi::Property<bool> m_doSMOrigin{this, "doSMOrigin", false, "Enable decoration of SM origin types"};
151 
152  ToolHandle<InDet::IInDetTrackTruthOriginTool> m_trackTruthOriginTool{this, "TrackTruthOriginTool", "InDet::InDetTrackTruthOriginTool/TrackTruthOriginTool"};
153 
154  //private methods to check if particles are good to use
155  //returns barcode of LLP production truth vertex
156  int checkProduction( const xAOD::TruthParticle& truthPart, std::vector<const xAOD::TruthVertex*> truthVerticesToMatch ) const;
157  void countReconstructibleDescendentParticles(const xAOD::TruthVertex& signalTruthVertex,
158  std::vector<const xAOD::TruthParticle*>& set, int counter) const;
159  std::vector<int> checkParticle( const xAOD::TruthParticle& part, const xAOD::TrackParticleContainer* tkCont ) const;
160  bool isFrom(const xAOD::TruthParticle& truth, int flav) const;
161  int checkSMProduction( const xAOD::TruthParticle& truthPart) const;
162 };
163 
164 #endif
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:215
InDetSecVtxTruthMatchUtils::VertexMatchType
VertexMatchType
Definition: InDetSecVtxTruthMatchTool.h:33
InDetSecVtxTruthMatchTool::m_selectedTrackFlag
Gaudi::Property< std::string > m_selectedTrackFlag
Definition: InDetSecVtxTruthMatchTool.h:148
InDetSecVtxTruthMatchUtils::Pileup
@ Pileup
Definition: InDetSecVtxTruthMatchTool.h:48
InDetSecVtxTruthMatchUtils::ReconstructedSplit
@ ReconstructedSplit
Definition: InDetSecVtxTruthMatchTool.h:72
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
PropertyWrapper.h
InDetSecVtxTruthMatchUtils::OtherSecondary
@ OtherSecondary
Definition: InDetSecVtxTruthMatchTool.h:57
VertexContainerFwd.h
InDetSecVtxTruthMatchTool::m_doSMOrigin
Gaudi::Property< bool > m_doSMOrigin
Definition: InDetSecVtxTruthMatchTool.h:150
TruthParticleFwd.h
InDetSecVtxTruthMatchUtils::HadronicInteraction
@ HadronicInteraction
Definition: InDetSecVtxTruthMatchTool.h:56
InDetSecVtxTruthMatchUtils::isFake
bool isFake(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:87
InDetSecVtxTruthMatchTool::initialize
virtual StatusCode initialize() override final
Dummy implementation of the initialisation function.
Definition: InDetSecVtxTruthMatchTool.cxx:16
InDetSecVtxTruthMatchUtils::isReconstructable
bool isReconstructable(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:96
TruthVertexContainer.h
InDetSecVtxTruthMatchUtils::Signal
@ Signal
Definition: InDetSecVtxTruthMatchTool.h:62
TruthVertexFwd.h
IInDetSecVtxTruthMatchTool
Class for vertex truth matching.
Definition: IInDetSecVtxTruthMatchTool.h:22
InDetSecVtxTruthMatchTool::countReconstructibleDescendentParticles
void countReconstructibleDescendentParticles(const xAOD::TruthVertex &signalTruthVertex, std::vector< const xAOD::TruthParticle * > &set, int counter) const
Definition: InDetSecVtxTruthMatchTool.cxx:554
InDetSecVtxTruthMatchUtils::isMerged
bool isMerged(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:79
IInDetSecVtxTruthMatchTool.h
InDetSecVtxTruthMatchUtils::isMatched
bool isMatched(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:75
InDetSecVtxTruthMatchUtils::isSplit
bool isSplit(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:83
InDetSecVtxTruthMatchUtils::Fake
@ Fake
Definition: InDetSecVtxTruthMatchTool.h:37
InDetSecVtxTruthMatchTool::checkProduction
int checkProduction(const xAOD::TruthParticle &truthPart, std::vector< const xAOD::TruthVertex * > truthVerticesToMatch) const
Definition: InDetSecVtxTruthMatchTool.cxx:488
InDetSecVtxTruthMatchUtils::Split
@ Split
Definition: InDetSecVtxTruthMatchTool.h:36
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
InDetSecVtxTruthMatchTool::m_doMuSA
Gaudi::Property< bool > m_doMuSA
Definition: InDetSecVtxTruthMatchTool.h:149
InDetSecVtxTruthMatchTool::matchVertices
virtual StatusCode matchVertices(std::vector< const xAOD::Vertex * > recoVerticesToMatch, std::vector< const xAOD::TruthVertex * > truthVerticesToMatch, const xAOD::TrackParticleContainer *trackParticles) override
Definition: InDetSecVtxTruthMatchTool.cxx:41
InDetSecVtxTruthMatchUtils::Other
@ Other
Definition: InDetSecVtxTruthMatchTool.h:38
InDetSecVtxTruthMatchUtils::isOther
bool isOther(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:91
InDetSecVtxTruthMatchUtils::isReconstructed
bool isReconstructed(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:108
InDetSecVtxTruthMatchTool::m_vxMatchWeight
Gaudi::Property< float > m_vxMatchWeight
Definition: InDetSecVtxTruthMatchTool.h:146
InDetSecVtxTruthMatchUtils::BHadronDecay
@ BHadronDecay
Definition: InDetSecVtxTruthMatchTool.h:58
InDetSecVtxTruthMatchUtils::isAccepted
bool isAccepted(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:100
InDetSecVtxTruthMatchUtils::VertexMatchOriginType
VertexMatchOriginType
Definition: InDetSecVtxTruthMatchTool.h:45
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDetSecVtxTruthMatchUtils::Fragmentation
@ Fragmentation
Definition: InDetSecVtxTruthMatchTool.h:60
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
InDetSecVtxTruthMatchTool
Class for vertex truth matching.
Definition: InDetSecVtxTruthMatchTool.h:130
InDetSecVtxTruthMatchUtils::Reconstructable
@ Reconstructable
Definition: InDetSecVtxTruthMatchTool.h:68
InDetSecVtxTruthMatchTool::m_trkMatchProb
Gaudi::Property< float > m_trkMatchProb
Definition: InDetSecVtxTruthMatchTool.h:145
InDetSecVtxTruthMatchUtils::LambdaDecay
@ LambdaDecay
Definition: InDetSecVtxTruthMatchTool.h:51
InDetSecVtxTruthMatchTool::m_trackTruthOriginTool
ToolHandle< InDet::IInDetTrackTruthOriginTool > m_trackTruthOriginTool
Definition: InDetSecVtxTruthMatchTool.h:152
InDetSecVtxTruthMatchUtils::StrangeMesonDecay
@ StrangeMesonDecay
Definition: InDetSecVtxTruthMatchTool.h:50
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
InDetSecVtxTruthMatchUtils::OtherDecay
@ OtherDecay
Definition: InDetSecVtxTruthMatchTool.h:55
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
InDetSecVtxTruthMatchUtils::isOriginType
bool isOriginType(int matchInfo, VertexMatchOriginType type)
Definition: InDetSecVtxTruthMatchTool.h:117
InDetSecVtxTruthMatchUtils::KshortDecay
@ KshortDecay
Definition: InDetSecVtxTruthMatchTool.h:49
InDetSecVtxTruthMatchUtils::isReconstructedSplit
bool isReconstructedSplit(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:112
InDetSecVtxTruthMatchUtils::Reconstructed
@ Reconstructed
Definition: InDetSecVtxTruthMatchTool.h:71
InDetSecVtxTruthMatchUtils::Seeded
@ Seeded
Definition: InDetSecVtxTruthMatchTool.h:70
InDetSecVtxTruthMatchUtils::OtherOrigin
@ OtherOrigin
Definition: InDetSecVtxTruthMatchTool.h:61
InDetSecVtxTruthMatchUtils::GammaConversion
@ GammaConversion
Definition: InDetSecVtxTruthMatchTool.h:54
InDetSecVtxTruthMatchUtils::Merged
@ Merged
Definition: InDetSecVtxTruthMatchTool.h:35
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
InDetSecVtxTruthMatchUtils::VertexTruthMatchInfo
std::tuple< ElementLink< xAOD::TruthVertexContainer >, float, float > VertexTruthMatchInfo
Definition: InDetSecVtxTruthMatchTool.h:30
InDetSecVtxTruthMatchUtils::Matched
@ Matched
Definition: InDetSecVtxTruthMatchTool.h:34
InDetSecVtxTruthMatchTool::checkParticle
std::vector< int > checkParticle(const xAOD::TruthParticle &part, const xAOD::TrackParticleContainer *tkCont) const
Definition: InDetSecVtxTruthMatchTool.cxx:406
InDetSecVtxTruthMatchTool::InDetSecVtxTruthMatchTool
InDetSecVtxTruthMatchTool(const std::string &name)
Definition: InDetSecVtxTruthMatchTool.cxx:14
InDetSecVtxTruthMatchTool::isFrom
bool isFrom(const xAOD::TruthParticle &truth, int flav) const
Definition: InDetSecVtxTruthMatchTool.cxx:608
InDetSecVtxTruthMatchUtils::TruthVertexMatchType
TruthVertexMatchType
Definition: InDetSecVtxTruthMatchTool.h:67
InDetSecVtxTruthMatchUtils::StrangeBaryonDecay
@ StrangeBaryonDecay
Definition: InDetSecVtxTruthMatchTool.h:52
InDetSecVtxTruthMatchUtils::TauDecay
@ TauDecay
Definition: InDetSecVtxTruthMatchTool.h:53
IInDetTrackTruthOriginTool.h
InDetSecVtxTruthMatchUtils::FakeOrigin
@ FakeOrigin
Definition: InDetSecVtxTruthMatchTool.h:47
AsgTool.h
InDetSecVtxTruthMatchUtils::isSeeded
bool isSeeded(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:104
test_pyathena.counter
counter
Definition: test_pyathena.py:15
InDetSecVtxTruthMatchUtils::Accepted
@ Accepted
Definition: InDetSecVtxTruthMatchTool.h:69
InDetSecVtxTruthMatchTool::checkSMProduction
int checkSMProduction(const xAOD::TruthParticle &truthPart) const
Definition: InDetSecVtxTruthMatchTool.cxx:545
InDetSecVtxTruthMatchUtils
Definition: InDetSecVtxTruthMatchTool.h:25
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65
InDetSecVtxTruthMatchTool::m_trkPtCut
Gaudi::Property< float > m_trkPtCut
Definition: InDetSecVtxTruthMatchTool.h:147
InDetSecVtxTruthMatchUtils::DHadronDecay
@ DHadronDecay
Definition: InDetSecVtxTruthMatchTool.h:59