ATLAS Offline Software
Loading...
Searching...
No Matches
METTauAssociator.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2023 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());
60
61 if (m_useFELinks) {
66 }
67
68 return StatusCode::SUCCESS;
69 }
70
71 // executeTool
74 {
75 ATH_MSG_VERBOSE ("In execute: " << name() << "...");
76
78 if (!tauCont.isValid()) {
79 ATH_MSG_WARNING("Unable to retrieve input tau container " << m_tauContKey.key());
80 return StatusCode::FAILURE;
81 }
82
83 ATH_MSG_DEBUG("Successfully retrieved tau collection");
84 if (fillAssocMap(metMap,tauCont.cptr()).isFailure()) {
85 ATH_MSG_WARNING("Unable to fill map with tau container " << m_tauContKey.key());
86 return StatusCode::FAILURE;
87 }
88 return StatusCode::SUCCESS;
89 }
90
91
92 //*********************************************************************************************************
93 // Get tau constituents
95 std::vector<const xAOD::IParticle*>& tclist,
96 const met::METAssociator::ConstitHolder& /*tcCont*/) const
97 {
98 const TauJet* tau = static_cast<const TauJet*>(obj);
99 TLorentzVector tauAxis = tauRecTools::getTauAxis(*tau);
100 const xAOD::Vertex* tauVertex = tau->vertex();
101
102 auto clusterList = tau->clusters();
103 for (const xAOD::IParticle* particle : clusterList) {
104 const xAOD::CaloCluster* cluster = static_cast<const xAOD::CaloCluster*>(particle);
105
106 TLorentzVector clusterP4 = cluster->p4();
107
108 // Correct the four momentum to point at the tau vertex
109 if (tauVertex) {
110 xAOD::CaloVertexedTopoCluster vertexedCluster(*cluster, tauVertex->position());
111 clusterP4 = vertexedCluster.p4();
112 }
113
114 if (clusterP4.DeltaR(tauAxis) > 0.2) continue;
115
116 tclist.push_back(particle);
117 }
118
119 return StatusCode::SUCCESS;
120 }
121
122
124 std::vector<const xAOD::IParticle*>& constlist,
125 const met::METAssociator::ConstitHolder& constits) const
126 {
127 const TauJet* tau = static_cast<const TauJet*>(obj);
128 for( const xAOD::TauTrack* tauTrk : tau->tracks(xAOD::TauJetParameters::coreTrack) ){//all tracks dR<0.2 regardless of quality
129 if(tauTrk->trackLinks().empty() || !tauTrk->trackLinks().at(0).isValid()){
130 ATH_MSG_DEBUG("Skipping absent tau track, probably thinned");
131 continue;
132 }
133 const TrackParticle* trk = tauTrk->track();
134 if(acceptTrack(trk,constits.pv) && isGoodEoverP(trk) ){
135 ATH_MSG_VERBOSE("Accept tau track " << trk << " px, py = " << trk->p4().Px() << ", " << trk->p4().Py());
136 constlist.push_back(trk);
137 }
138 }
139
140 return StatusCode::SUCCESS;
141 }
142 //*********************************************************************************************************
143 // Get tau constituents
145 std::vector<const xAOD::IParticle*>& pfolist,
146 const met::METAssociator::ConstitHolder& constits,
147 std::map<const IParticle*,MissingETBase::Types::constvec_t> &/*momenta*/) const
148 {
149 const TauJet* tau = static_cast<const TauJet*>(obj);
150 const Jet* seedjet = *tau->jetLink();
151 TLorentzVector momentum;
152 for(const auto *const pfo : *constits.pfoCont) {
153 bool match = false;
154 if (!pfo->isCharged()) {
155 if(xAOD::P4Helpers::isInDeltaR(*seedjet,*pfo,0.2,m_useRapidity) && pfo->eEM()>0) {
156 ATH_MSG_VERBOSE("Found nPFO with dR " << seedjet->p4().DeltaR(pfo->p4EM()));
157 match = true;
158 }
159 }
160 else {
161 const TrackParticle* pfotrk = pfo->track(0);
162 for( const xAOD::TauTrack* ttrk : tau->tracks(xAOD::TauJetParameters::coreTrack) ){//all tracks <0.2, no quality
163 if(ttrk->trackLinks().empty() || !ttrk->trackLinks().at(0).isValid()){
164 ATH_MSG_DEBUG("Skipping absent tau track, probably thinned");
165 continue;
166 }
167 const TrackParticle* tautrk = ttrk->track();
168 if(tautrk==pfotrk) {
169 ATH_MSG_VERBOSE("Found cPFO with dR " << seedjet->p4().DeltaR(ttrk->p4()));
170 // We set a small -ve pt for cPFOs that were rejected
171 // by the ChargedHadronSubtractionTool
172 const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV");
173 if(PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(pfotrk) )) match = true;
174 }
175 }
176 }
177 if(match) {
178 pfolist.push_back(pfo);
179 }
180 }
181 return StatusCode::SUCCESS;
182 }
183
185 std::vector<const xAOD::IParticle*>& felist,
186 const met::METAssociator::ConstitHolder& constits,
187 std::map<const IParticle*,MissingETBase::Types::constvec_t> &/*momenta*/) const
188 {
189 const TauJet* tau = static_cast<const TauJet*>(obj);
190 if (m_useFELinks)
191 ATH_CHECK( extractFEsFromLinks(tau, felist,constits) );
192 else
193 ATH_CHECK( extractFEs(tau, felist, constits) );
194
195 return StatusCode::SUCCESS;
196 }
197
198
199 StatusCode METTauAssociator::extractFEsFromLinks(const xAOD::TauJet* tau, //TODO to be tested
200 std::vector<const xAOD::IParticle*>& felist,
201 const met::METAssociator::ConstitHolder& constits) const
202 {
203
204 ATH_MSG_DEBUG("Extract FEs From Links for " << tau->type() << " with pT " << tau->pt());
205
206 std::vector<FELink_t> nFELinks;
207 std::vector<FELink_t> cFELinks;
208
211 nFELinks=neutralFEReadDecorHandle(*tau);
212 cFELinks=chargedFEReadDecorHandle(*tau);
213
214 // Charged FEs
215 for (const FELink_t& feLink : cFELinks) {
216 if (!feLink.isValid()) continue;
217 const xAOD::FlowElement* fe_init = *feLink;
218 for (const auto *const fe : *constits.feCont){
219 if (fe->index() == fe_init->index() && fe->isCharged()){ //index-based match between JetETmiss and CHSFlowElements collections
220 const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV");
221 if( fe->isCharged() && PVMatchedAcc(*fe)&& ( !m_cleanChargedPFO || isGoodEoverP(static_cast<const xAOD::TrackParticle*>(fe->chargedObject(0))) ) ) {
222 ATH_MSG_DEBUG("Accept cFE with pt " << fe->pt() << ", e " << fe->e() << ", eta " << fe->eta() << ", phi " << fe->phi() );
223 felist.push_back(fe);
224 }
225 }
226 }
227 } // end cFE loop
228
229 // Neutral FEs
230 for (const FELink_t& feLink : nFELinks) {
231 if (!feLink.isValid()) continue;
232 const xAOD::FlowElement* fe_init = *feLink;
233 for (const auto *const fe : *constits.feCont){
234 if (fe->index() == fe_init->index() && !fe->isCharged()){ //index-based match between JetETmiss and CHSFlowElements collections
235 if( ( !fe->isCharged()&& fe->e() > FLT_MIN ) ){
236 ATH_MSG_DEBUG("Accept nFE with pt " << fe->pt() << ", e " << fe->e() << ", eta " << fe->eta() << ", phi " << fe->phi() << " in sum.");
237 felist.push_back(fe);
238 }
239 }
240 }
241 } // end nFE links loop
242
243
244 return StatusCode::SUCCESS;
245
246 }
247
248
250 std::vector<const xAOD::IParticle*>& felist,
251 const met::METAssociator::ConstitHolder& constits) const
252 {
253 //const TauJet* tau = static_cast<const TauJet*>(obj);
254 if(!tau->jetLink().isValid()){
255 ATH_MSG_ERROR("Tau seed jet link is invalid. Cannot extract FlowElements.");
256 return StatusCode::FAILURE;
257 }
258 const Jet* seedjet = *tau->jetLink();
259 TLorentzVector momentum;
260 for(const xAOD::FlowElement* pfo : *constits.feCont) {
261 bool match = false;
262 if (!pfo->isCharged()) {
263 if(xAOD::P4Helpers::isInDeltaR(*seedjet,*pfo,0.2,m_useRapidity) && pfo->e()>0) {
264 ATH_MSG_VERBOSE("Found nPFO with dR " << seedjet->p4().DeltaR(pfo->p4()));
265 match = true;
266 }
267 }
268 else {
269 const TrackParticle* pfotrk = static_cast<const xAOD::TrackParticle*>(pfo->chargedObject(0));
270 for( const xAOD::TauTrack* ttrk : tau->tracks(xAOD::TauJetParameters::coreTrack) ){//all tracks <0.2, no quality
271 if(ttrk->trackLinks().empty() || !ttrk->trackLinks().at(0).isValid()){
272 ATH_MSG_DEBUG("Skipping absent tau track, probably thinned");
273 continue;
274 }
275 const TrackParticle* tautrk = ttrk->track();
276 if(tautrk==pfotrk) {
277 ATH_MSG_VERBOSE("Found cPFO with dR " << seedjet->p4().DeltaR(ttrk->p4()));
278 // We set a small -ve pt for cPFOs that were rejected
279 // by the ChargedHadronSubtractionTool
280 const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV");
281 if(PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(pfotrk) )) match = true;
282 }
283 }
284 }
285 if(match) {
286 felist.push_back(pfo);
287 }
288 }
289 return StatusCode::SUCCESS;
290 }
291
292
293}
#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
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
size_t index() const
Return the index of this element within its container.
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
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
virtual StatusCode fillAssocMap(xAOD::MissingETAssociationMap *metMap, const xAOD::IParticleContainer *hardObjs) const
std::string m_chargedFELinksKey
METAssociator(const std::string &name)
bool isGoodEoverP(const xAOD::TrackParticle *trk) const
std::string m_neutralFELinksKey
bool acceptTrack(const xAOD::TrackParticle *trk, const xAOD::Vertex *pv) const
StatusCode executeTool(xAOD::MissingETContainer *metCont, xAOD::MissingETAssociationMap *metMap) const final
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 final
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 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
StatusCode extractFEsFromLinks(const xAOD::TauJet *tau, std::vector< const xAOD::IParticle * > &felist, const met::METAssociator::ConstitHolder &constits) const
SG::ReadDecorHandleKey< xAOD::TauJetContainer > m_neutralFEReadDecorKey
SG::ReadDecorHandleKey< xAOD::TauJetContainer > m_chargedFEReadDecorKey
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 final
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:357
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