ATLAS Offline Software
Loading...
Searching...
No Matches
TrackObjectSelectionTool.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
11#include "GaudiKernel/ISvcLocator.h"
12#include "GaudiKernel/Service.h"
13
19
20
25 const std::string& name ) :
26 asg::AsgTool( name ) { }
27
28
33
35
36 ATH_MSG_DEBUG( "Initializing " << name() << "..." );
37
38 return StatusCode::SUCCESS;
39}
40
41
46 TrackAnalysisCollections& trkAnaColls ) {
47
48 ATH_MSG_DEBUG( "Selecting offline tracks matched to an offline " << m_objectType.value() );
49
50 ISvcLocator* svcLoc = Gaudi::svcLocator();
51 SmartIF<ITrackAnalysisDefinitionSvc> trkAnaDefSvc( svcLoc->service( "TrkAnaDefSvc" + trkAnaColls.anaTag() ) );
52 ATH_CHECK( trkAnaDefSvc.isValid() );
53
54 if( not trkAnaDefSvc->useOffline() ) {
55 ATH_MSG_DEBUG( "Tool not enabled if offline tracks are not used." );
56 return StatusCode::SUCCESS;
57 }
58
60 std::vector< const xAOD::TrackParticle* > newVec;
61 for( const xAOD::TrackParticle* thisTrack :
63 if( accept( *thisTrack,
64 trkAnaColls.truthPartVec( TrackAnalysisCollections::FS ) ) ) newVec.push_back( thisTrack );
65 }
66
68 ATH_CHECK( trkAnaColls.fillOfflTrackVec( newVec,
70
72 if( trkAnaDefSvc->useEFTrigger() and
73 m_objectType.value().find("Truth") != std::string::npos ) {
74
75 ATH_MSG_DEBUG( "Now doing EFTrack-truth selection" );
76
78 newVec.clear();
79 for( const xAOD::TrackParticle* thisTrack :
81 if( accept( *thisTrack,
82 trkAnaColls.truthPartVec( TrackAnalysisCollections::FS ) ) ) newVec.push_back( thisTrack );
83 }
84
86 ATH_CHECK( trkAnaColls.fillTrigTrackVec( newVec,
88 } // end if
89
90 return StatusCode::SUCCESS;
91}
92
93
98 const xAOD::TrackParticle& offTrack,
99 const std::vector< const xAOD::TruthParticle* >& truthVec ) const {
100
102 if( m_objectType.value().find("Electron") != std::string::npos ) {
103
105 offTrack, m_objectQuality.value() );
106
107 if( not ele ) return false;
108
109 ATH_MSG_DEBUG( "Offline Track with pt = " << pT( offTrack ) <<
110 " matches with " << m_objectQuality.value() <<
111 " Electron with transverse energy = " << eT( *ele ) );
112
113 return true;
114 }
115
117 if( m_objectType.value().find("Muon") != std::string::npos ) {
118 const xAOD::Muon* mu = getLinkedMuon(
119 offTrack, m_objectQuality.value() );
120
121 if( not mu ) return false;
122
123 ATH_MSG_DEBUG( "Offline Track with pt = " << pT( offTrack ) <<
124 " matches with " << m_objectQuality.value() <<
125 " Muon with transverse energy = " << eT( *mu ) );
126
127 return true;
128 }
129
131 if( m_objectType.value().find("Tau") != std::string::npos ) {
132
133 const xAOD::TauJet* tau = getLinkedTau(
134 offTrack, m_tauNprongs.value(),
135 m_tauType.value(), m_objectQuality.value() );
136
137 if( not tau ) return false;
138
139 ATH_MSG_DEBUG( "Offline Track with pt = " << pT( offTrack ) <<
140 " matches with " << m_objectQuality.value() <<
141 " hadronic " << m_tauNprongs.value() << "prong " <<
142 m_tauType.value() << " Tau with transverse energy = " <<
143 eT( *tau ) );
144
145 return true;
146 }
147
149 if( m_objectType.value().find("Jet") != std::string::npos ) {
150 const xAOD::Jet* jet = getLinkedJet(
151 offTrack, m_objectQuality.value() );
152
153 if( not jet ) return false;
154
155 ATH_MSG_DEBUG( "Offline Track with pt = " << pT( offTrack ) <<
156 " is linked to a " << m_objectQuality.value() <<
157 " jet with pT = " << jet->pt() );
158
159 return true;
160 }
161
163 if( m_objectType.value().find("Truth") != std::string::npos ) {
164
165 const xAOD::TruthParticle* truth = getLinkedTruth(
166 offTrack, m_truthProbCut.value() );
167
168 if( not truth ) return false;
169
170 if( truthVec.empty() ) {
171 ATH_MSG_DEBUG( "Truth vector is empty" );
172 return false;
173 }
174
175 ATH_MSG_DEBUG( "Offline Track with pt = " << pT( offTrack ) <<
176 " matches with truth particle with pt = " << pT( *truth ) );
177
179 if( std::find( truthVec.begin(), truthVec.end(),
180 truth ) == truthVec.end() ) return false;
181
182 return true;
183 }
184
185 ATH_MSG_WARNING( "Type " << m_objectType.value() <<
186 " is not supported for track-object selection" );
187 return false;
188}
#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.
Tool to select offline ID tracks which asociated with fully-reconstructed object with specific qualit...
Utility methods to access track/truth particles parmeters in a consitent way in this package.
const std::vector< const xAOD::TrackParticle * > & offlTrackVec(Stage stage=FULL)
StatusCode fillTrigTrackVec(const std::vector< const xAOD::TrackParticle * > &vec, Stage stage=FULL)
Trigger tracks.
const std::vector< const xAOD::TrackParticle * > & trigTrackVec(Stage stage=FULL)
const std::string & anaTag()
— Getter methods —
const std::vector< const xAOD::TruthParticle * > & truthPartVec(Stage stage=FULL)
get truth/offline/trigger track vector (TEST or REFERENCE)
StatusCode fillOfflTrackVec(const std::vector< const xAOD::TrackParticle * > &vec, Stage stage=FULL)
Offline tracks.
virtual StatusCode initialize() override
Initialize.
virtual StatusCode selectTracks(TrackAnalysisCollections &trkAnaColls) override
Main Track selection method.
TrackObjectSelectionTool(const std::string &name)
Constructor.
bool accept(const xAOD::TrackParticle &offTrack, const std::vector< const xAOD::TruthParticle * > &truthVec) const
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
float pT(const U &p)
Accessor utility function for getting the value of pT.
const xAOD::Jet * getLinkedJet(const xAOD::TrackParticle &track, const std::string &quality)
getLinkedJet
float eT(const U &p)
Accessor utility function for getting the value of Tranverse energy.
const xAOD::Muon * getLinkedMuon(const xAOD::TrackParticle &track, const std::string &quality)
getLinkedMuon
const xAOD::Electron * getLinkedElectron(const xAOD::TrackParticle &track, const std::string &quality)
getLinkedElectron
const xAOD::TruthParticle * getLinkedTruth(const xAOD::TrackParticle &track, const float truthProbCut)
getLinkedTruth
const xAOD::TauJet * getLinkedTau(const xAOD::TrackParticle &track, const int requiredNtracks, const std::string &type, const std::string &quality)
getLinkedTau
Jet_v1 Jet
Definition of the current "jet version".
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TauJet_v3 TauJet
Definition of the current "tau version".
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".