ATLAS Offline Software
Loading...
Searching...
No Matches
TruthTrackMatchingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
9
13#include "TrackMatchingLookup.h"
16
21 const std::string& name ) :
22 asg::AsgTool( name ) { }
23
24
29{
31
32 ATH_MSG_DEBUG( "Initializing " << name() << "..." );
33
34 return StatusCode::SUCCESS;
35}
36
37
42 TrackAnalysisCollections& trkAnaColls,
43 const std::string& chainRoIName,
44 const std::string& roiStr ) const
45{
47 bool doMatch = trkAnaColls.updateChainRois( chainRoIName, roiStr );
48
50 if( not doMatch ) {
51 ATH_MSG_WARNING( "Matching for " << chainRoIName <<
52 " was already done. Skipping" );
53 return StatusCode::SUCCESS;
54 }
55
60 trkAnaColls.matches() ) );
61
62 ATH_MSG_DEBUG( trkAnaColls.printMatchInfo() );
63
64 return StatusCode::SUCCESS;
65}
66
67
72 const std::vector< const xAOD::TruthParticle* >& vTest,
73 const std::vector< const xAOD::TrackParticle* >& vRef,
74 ITrackMatchingLookup& matches ) const
75{
76 ATH_MSG_DEBUG( "Doing Truth->Track matching via truthParticleLink" );
77
78 for( const xAOD::TruthParticle* truth_particle : vTest ) {
79
80 const xAOD::TrackParticle* matched_track_particle = nullptr;
81 float prob = -99.;
82
83 for( const xAOD::TrackParticle* track_particle : vRef ) {
84
86 const xAOD::TruthParticle* truth_particle_tmp =
87 getLinkedTruth( *track_particle, m_truthProbCut.value() );
88
92 if( ( not truth_particle_tmp ) or
93 ( truth_particle_tmp != truth_particle ) ) continue;
94
95 float prob_tmp = getTruthMatchProb( *track_particle );
96
98 if( prob_tmp > prob ) {
99 matched_track_particle = track_particle;
100 prob = prob_tmp;
104 }
105
106 } // loop over vRef
107
109 if( not matched_track_particle ) continue;
110
111 ATH_MSG_DEBUG( "Found matched track particle with pT = " <<
112 pT( *matched_track_particle ) <<
113 " and prob = " << prob );
114
116 float dist = 1 - prob;
117
119 ATH_CHECK( matches.update( *truth_particle, *matched_track_particle, dist ) );
120
121 } // loop over vTest
122
123 return StatusCode::SUCCESS;
124}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Utility methods to access offline object decorations.
Class to hold for each event collections needed in the TrkAnalsis.
Look-up table (templated) class to store (internally to IDTPM) all the matches between test and refer...
Utility methods to access track/truth particles parmeters in a consitent way in this package.
Tool to perform matching of truth particles and tracks via their truthParticleLink decorations....
virtual StatusCode update(const xAOD::TrackParticle &t, const xAOD::TrackParticle &r, float dist=0.)=0
update lookup tables with a new entry Track -> Track
const std::vector< const xAOD::TruthParticle * > & testTruthVec(Stage stage=FULL)
get TEST track vectors
std::string printMatchInfo()
print track matching information
bool updateChainRois(const std::string &chainRoi, const std::string &roiStr)
update chainRois map
ITrackMatchingLookup & matches()
get track matching information
const std::vector< const xAOD::TrackParticle * > & refTrackVec(Stage stage=FULL)
TEST = Track.
TruthTrackMatchingTool(const std::string &name)
Constructor.
virtual StatusCode initialize() override
Initialize.
virtual StatusCode match(TrackAnalysisCollections &trkAnaColls, const std::string &chainRoIName, const std::string &roiStr) const override
General matching method, via TrackAnalysisCollections.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition AsgTool.h:133
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357
float pT(const U &p)
Accessor utility function for getting the value of pT.
float getTruthMatchProb(const xAOD::TrackParticle &track)
getTruthMatchProb
const xAOD::TruthParticle * getLinkedTruth(const xAOD::TrackParticle &track, const float truthProbCut)
getLinkedTruth
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.