ATLAS Offline Software
Loading...
Searching...
No Matches
METTauAssociator.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7// METTauAssociator.cxx
8// Implementation file for class METTauAssociator
9//
10// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
11//
12// Author: P Loch, S Resconi, TJ Khoo, AS Mete
14
15// METReconstruction includes
17
18// MET EDM
20
21// Tau EDM
23#include "xAODTau/TauTrack.h"
25
26// Tracking EDM
27#include "xAODTracking/Vertex.h"
28
29// DeltaR calculation
31
35
36
39
40namespace met {
41
42 using namespace xAOD;
43
44 // Constructors
49 {
50 }
51
52 // Athena algtool's Hooks
55 {
57
58 ATH_MSG_VERBOSE ("Initializing " << name() << "...");
59 ATH_CHECK( m_tauContKey.initialize() );
62
63 return StatusCode::SUCCESS;
64 }
65
66 // executeTool
68 StatusCode METTauAssociator::executeTool(xAOD::MissingETContainer* /*metCont*/, xAOD::MissingETAssociationMap* metMap, const EventContext& ctx) const
69 {
70 ATH_MSG_VERBOSE ("In execute: " << name() << "...");
71
73 if (!tauCont.isValid()) {
74 ATH_MSG_WARNING("Unable to retrieve input tau container " << m_tauContKey.key());
75 return StatusCode::FAILURE;
76 }
77
78 ATH_MSG_DEBUG("Successfully retrieved tau collection");
79 if (fillAssocMap(metMap,tauCont.cptr(), ctx).isFailure()) {
80 ATH_MSG_WARNING("Unable to fill map with tau container " << m_tauContKey.key());
81 return StatusCode::FAILURE;
82 }
83 return StatusCode::SUCCESS;
84 }
85
86
87 //*********************************************************************************************************
88 // Get tau constituents
90 std::vector<const xAOD::IParticle*>& tclist,
91 const met::METAssociator::ConstitHolder& /*tcCont*/, const EventContext&) const
92 {
93 const TauJet* tau = static_cast<const TauJet*>(obj);
94 TLorentzVector tauAxis = tauRecTools::getTauAxis(*tau);
95 const xAOD::Vertex* tauVertex = tau->vertex();
96
97 auto clusterList = tau->clusters();
98 for (const xAOD::IParticle* particle : clusterList) {
99 const xAOD::CaloCluster* cluster = static_cast<const xAOD::CaloCluster*>(particle);
100
101 TLorentzVector clusterP4 = cluster->p4();
102
103 // Correct the four momentum to point at the tau vertex
104 if (tauVertex) {
105 xAOD::CaloVertexedTopoCluster vertexedCluster(*cluster, tauVertex->position());
106 clusterP4 = vertexedCluster.p4();
107 }
108
109 if (clusterP4.DeltaR(tauAxis) > 0.2) continue;
110
111 tclist.push_back(particle);
112 }
113
114 return StatusCode::SUCCESS;
115 }
116
117
119 std::vector<const xAOD::IParticle*>& constlist,
120 const met::METAssociator::ConstitHolder& constits) const
121 {
122 const TauJet* tau = static_cast<const TauJet*>(obj);
123 for( const xAOD::TauTrack* tauTrk : tau->tracks(xAOD::TauJetParameters::coreTrack) ){//all tracks dR<0.2 regardless of quality
124 if(tauTrk->trackLinks().empty() || !tauTrk->trackLinks().at(0).isValid()){
125 ATH_MSG_DEBUG("Skipping absent tau track, probably thinned");
126 continue;
127 }
128 const TrackParticle* trk = tauTrk->track();
129 if(acceptTrack(trk,constits.pv) && isGoodEoverP(trk) ){
130 ATH_MSG_VERBOSE("Accept tau track " << trk << " px, py = " << trk->p4().Px() << ", " << trk->p4().Py());
131 constlist.push_back(trk);
132 }
133 }
134
135 return StatusCode::SUCCESS;
136 }
137 //*********************************************************************************************************
138 // Get tau constituents
140 std::vector<const xAOD::IParticle*>& pfolist,
141 const met::METAssociator::ConstitHolder& constits,
142 std::map<const IParticle*,MissingETBase::Types::constvec_t> &/*momenta*/, const EventContext&) const
143 {
144 const TauJet* tau = static_cast<const TauJet*>(obj);
145 const Jet* seedjet = *tau->jetLink();
146 TLorentzVector momentum;
147 for(const auto *const pfo : *constits.pfoCont) {
148 bool match = false;
149 if (!pfo->isCharged()) {
150 if(xAOD::P4Helpers::isInDeltaR(*seedjet,*pfo,0.2,m_useRapidity) && pfo->eEM()>0) {
151 ATH_MSG_VERBOSE("Found nPFO with dR " << seedjet->p4().DeltaR(pfo->p4EM()));
152 match = true;
153 }
154 }
155 else {
156 const TrackParticle* pfotrk = pfo->track(0);
157 for( const xAOD::TauTrack* ttrk : tau->tracks(xAOD::TauJetParameters::coreTrack) ){//all tracks <0.2, no quality
158 if(ttrk->trackLinks().empty() || !ttrk->trackLinks().at(0).isValid()){
159 ATH_MSG_DEBUG("Skipping absent tau track, probably thinned");
160 continue;
161 }
162 const TrackParticle* tautrk = ttrk->track();
163 if(tautrk==pfotrk) {
164 ATH_MSG_VERBOSE("Found cPFO with dR " << seedjet->p4().DeltaR(ttrk->p4()));
165 // We set a small -ve pt for cPFOs that were rejected
166 // by the ChargedHadronSubtractionTool
167 const static SG::ConstAccessor<char> PVMatchedAcc("matchedToPV");
168 if(PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(pfotrk) )) match = true;
169 }
170 }
171 }
172 if(match) {
173 pfolist.push_back(pfo);
174 }
175 }
176 return StatusCode::SUCCESS;
177 }
178
180 std::vector<const xAOD::IParticle*>& felist,
181 const met::METAssociator::ConstitHolder& constits,
182 std::map<const IParticle*,MissingETBase::Types::constvec_t> &/*momenta*/, const EventContext& ctx) const
183 {
184 const TauJet* tau = static_cast<const TauJet*>(obj);
185 if (m_useFELinks)
186 ATH_CHECK( extractFEsFromLinks(tau, felist,constits, ctx) );
187 else
188 ATH_CHECK( extractFEs(tau, felist, constits) );
189
190 return StatusCode::SUCCESS;
191 }
192
193
194 StatusCode METTauAssociator::extractFEsFromLinks(const xAOD::TauJet* tau, //TODO to be tested
195 std::vector<const xAOD::IParticle*>& felist,
196 const met::METAssociator::ConstitHolder& constits, const EventContext& ctx) const
197 {
198
199 ATH_MSG_DEBUG("Extract FEs From Links for " << tau->type() << " with pT " << tau->pt());
200
201 std::vector<FELink_t> nFELinks;
202 std::vector<FELink_t> cFELinks;
203
206 nFELinks=neutralFEReadDecorHandle(*tau);
207 cFELinks=chargedFEReadDecorHandle(*tau);
208
209 // Charged FEs
210 for (const FELink_t& feLink : cFELinks) {
211 if (!feLink.isValid()) continue;
212 const xAOD::FlowElement* fe_init = *feLink;
213 for (const auto *const fe : *constits.feCont){
214 if (fe->index() == fe_init->index() && fe->isCharged()){ //index-based match between JetETmiss and CHSFlowElements collections
215 const static SG::ConstAccessor<char> PVMatchedAcc("matchedToPV");
216 if( fe->isCharged() && PVMatchedAcc(*fe)&& ( !m_cleanChargedPFO || isGoodEoverP(static_cast<const xAOD::TrackParticle*>(fe->chargedObject(0))) ) ) {
217 ATH_MSG_DEBUG("Accept cFE with pt " << fe->pt() << ", e " << fe->e() << ", eta " << fe->eta() << ", phi " << fe->phi() );
218 felist.push_back(fe);
219 }
220 }
221 }
222 } // end cFE loop
223
224 // Neutral FEs
225 for (const FELink_t& feLink : nFELinks) {
226 if (!feLink.isValid()) continue;
227 const xAOD::FlowElement* fe_init = *feLink;
228 for (const auto *const fe : *constits.feCont){
229 if (fe->index() == fe_init->index() && !fe->isCharged()){ //index-based match between JetETmiss and CHSFlowElements collections
230 if( ( !fe->isCharged()&& fe->e() > FLT_MIN ) ){
231 ATH_MSG_DEBUG("Accept nFE with pt " << fe->pt() << ", e " << fe->e() << ", eta " << fe->eta() << ", phi " << fe->phi() << " in sum.");
232 felist.push_back(fe);
233 }
234 }
235 }
236 } // end nFE links loop
237
238
239 return StatusCode::SUCCESS;
240
241 }
242
243
245 std::vector<const xAOD::IParticle*>& felist,
246 const met::METAssociator::ConstitHolder& constits) const
247 {
248 //const TauJet* tau = static_cast<const TauJet*>(obj);
249 if(!tau->jetLink().isValid()){
250 ATH_MSG_ERROR("Tau seed jet link is invalid. Cannot extract FlowElements.");
251 return StatusCode::FAILURE;
252 }
253 const Jet* seedjet = *tau->jetLink();
254 TLorentzVector momentum;
255 for(const xAOD::FlowElement* pfo : *constits.feCont) {
256 bool match = false;
257 if (!pfo->isCharged()) {
258 if(xAOD::P4Helpers::isInDeltaR(*seedjet,*pfo,0.2,m_useRapidity) && pfo->e()>0) {
259 ATH_MSG_VERBOSE("Found nPFO with dR " << seedjet->p4().DeltaR(pfo->p4()));
260 match = true;
261 }
262 }
263 else {
264 const TrackParticle* pfotrk = static_cast<const xAOD::TrackParticle*>(pfo->chargedObject(0));
265 for( const xAOD::TauTrack* ttrk : tau->tracks(xAOD::TauJetParameters::coreTrack) ){//all tracks <0.2, no quality
266 if(ttrk->trackLinks().empty() || !ttrk->trackLinks().at(0).isValid()){
267 ATH_MSG_DEBUG("Skipping absent tau track, probably thinned");
268 continue;
269 }
270 const TrackParticle* tautrk = ttrk->track();
271 if(tautrk==pfotrk) {
272 ATH_MSG_VERBOSE("Found cPFO with dR " << seedjet->p4().DeltaR(ttrk->p4()));
273 // We set a small -ve pt for cPFOs that were rejected
274 // by the ChargedHadronSubtractionTool
275 const static SG::ConstAccessor<char> PVMatchedAcc("matchedToPV");
276 if(PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(pfotrk) )) match = true;
277 }
278 }
279 }
280 if(match) {
281 felist.push_back(pfo);
282 }
283 }
284 return StatusCode::SUCCESS;
285 }
286
287
288}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Evaluate cluster kinematics with a different vertex / signal state.
ElementLink< xAOD::TauJetContainer > TauLink_t
ElementLink< xAOD::FlowElementContainer > FELink_t
Helper class to provide constant type-safe access to aux data.
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Gaudi::Property< bool > m_useFELinks
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< bool > m_useRapidity
Gaudi::Property< bool > m_cleanChargedPFO
virtual StatusCode fillAssocMap(xAOD::MissingETAssociationMap *metMap, const xAOD::IParticleContainer *hardObjs, const EventContext &ctx) const
METAssociator(const std::string &name)
bool isGoodEoverP(const xAOD::TrackParticle *trk) const
bool acceptTrack(const xAOD::TrackParticle *trk, const xAOD::Vertex *pv) const
SG::ReadHandleKey< xAOD::TauJetContainer > m_tauContKey
StatusCode extractFEs(const xAOD::TauJet *tau, std::vector< const xAOD::IParticle * > &felist, const met::METAssociator::ConstitHolder &constits) const
METTauAssociator()
Default constructor:
StatusCode extractTopoClusters(const xAOD::IParticle *obj, std::vector< const xAOD::IParticle * > &tclist, const met::METAssociator::ConstitHolder &constits, const EventContext &ctx) const final
StatusCode extractFEsFromLinks(const xAOD::TauJet *tau, std::vector< const xAOD::IParticle * > &felist, const met::METAssociator::ConstitHolder &constits, const EventContext &ctx) const
StatusCode extractPFO(const xAOD::IParticle *obj, std::vector< const xAOD::IParticle * > &pfolist, const met::METAssociator::ConstitHolder &constits, std::map< const xAOD::IParticle *, MissingETBase::Types::constvec_t > &momenta, const EventContext &ctx) const final
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
StatusCode extractTracks(const xAOD::IParticle *obj, std::vector< const xAOD::IParticle * > &constlist, const met::METAssociator::ConstitHolder &constits) const final
SG::ReadDecorHandleKey< xAOD::TauJetContainer > m_neutralFEReadDecorKey
StatusCode extractFE(const xAOD::IParticle *obj, std::vector< const xAOD::IParticle * > &felist, const met::METAssociator::ConstitHolder &constits, std::map< const xAOD::IParticle *, MissingETBase::Types::constvec_t > &momenta, const EventContext &ctx) const final
StatusCode executeTool(xAOD::MissingETContainer *metCont, xAOD::MissingETAssociationMap *metMap, const EventContext &ctx) const final
SG::ReadDecorHandleKey< xAOD::TauJetContainer > m_chargedFEReadDecorKey
virtual FourMom_t p4() const
The full 4-momentum of the particle.
virtual FourMom_t p4() const final
The full 4-momentum of the particle.
Evaluate cluster kinematics with a different vertex / signal state.
const xAOD::IParticle * chargedObject(std::size_t i) const
virtual double e() const override
The total energy of the particle.
virtual FourMom_t p4() const override
The full 4-momentum of the particle.
Class providing the definition of the 4-vector interface.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
virtual double pt() const
The transverse momentum ( ) of the particle.
const JetLink_t & jetLink() const
const Vertex * vertex() const
std::vector< const IParticle * > clusters() const
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
std::vector< const TauTrack * > tracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
Get the v<const pointer> to a given tauTrack collection associated with this tau.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
const Amg::Vector3D & position() const
Returns the 3-pos.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:359
static const SG::ConstAccessor< char > PVMatchedAcc("matchedToPV")
TLorentzVector getTauAxis(const xAOD::TauJet &tau, bool doVertexCorrection=true)
Return the four momentum of the tau axis The tau axis is widely used to select clusters and cells in ...
bool isInDeltaR(const xAOD::IParticle &p1, const xAOD::IParticle &p2, double dR, bool useRapidity=true)
Check if 2 xAOD::IParticle are in a cone.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Jet_v1 Jet
Definition of the current "jet version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
TauTrack_v1 TauTrack
Definition of the current version.
Definition TauTrack.h:16
TauJet_v3 TauJet
Definition of the current "tau version".
MissingETAssociationMap_v1 MissingETAssociationMap
Version control by type defintion.
const xAOD::FlowElementContainer * feCont
const xAOD::PFOContainer * pfoCont