ATLAS Offline Software
Loading...
Searching...
No Matches
METAssocTestAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "METAssocTestAlg.h"
8
9using namespace xAOD;
10
11// allow for differences due to float compression
12static const float f_tolerance = 1;
13
14namespace met {
15
16 METAssocTestAlg::METAssocTestAlg(const std::string& name, ISvcLocator* pSvcLocator) :
17 ::AthAlgorithm( name, pSvcLocator ) {
18 declareProperty( "METMapSuffix", m_mapsuffix="AntiKt4EMTopo" );
19 declareProperty( "JetCollection", m_jetname="" );
20
21 declareProperty( "FailOnInconsistency", m_failOnInconsistency=false );
22 }
23
25 {
26 if(m_mapsuffix.empty()) {
27 ATH_MSG_FATAL( "METMapSuffix (e.g. AntiKt4EMTopo) must be set!" );
28 return StatusCode::FAILURE;
29 }
30 m_mapname = "METAssoc_"+m_mapsuffix;
31 if(m_jetname.empty()) { m_jetname = m_mapsuffix+"Jets"; }
32
33 ATH_MSG_INFO( "Initialising " << name() );
34 ATH_MSG_INFO( "MET map name: " << m_mapname );
35
36 return StatusCode::SUCCESS;
37 }
38
39 StatusCode METAssocTestAlg::finalize() { return StatusCode::SUCCESS; }
40
42 {
43
44
46 if (!map.isValid()) {
47 ATH_MSG_WARNING("Unable to retrieve met association map");
48 return StatusCode::FAILURE;
49 }
50
51 for(const auto *const assoc : *map) {
52 if(assoc->isMisc()) { // misc association gets special treatment
53 ATH_MSG_VERBOSE( " Now on MET misc association" );
54 ATH_CHECK( checkMiscAssoc(*assoc) );
55 } else {
56 ATH_MSG_VERBOSE( " Now on MET association for jet " << assoc->refJet()->index() );
57 // Test jets for consistency with the map
58 ATH_CHECK( checkJet(*assoc) );
59 // Test associated objects for consistency with the map
60 ATH_CHECK( checkObjects(*assoc) );
61 // Test association for self-consistency based on stored keys
62 ATH_CHECK( checkAssoc(*assoc) );
63 }
64 }
65
66 return StatusCode::SUCCESS;
67 }
68
70 {
71 const auto& jet = *assoc.refJet();
72 JetFourMom_t jetconstp4 = jet.jetP4(JetConstitScaleMomentum);
74
76
77 // switch on all overlapping objects
78 for(size_t iobj=0; iobj<assoc.objects().size(); ++iobj) {
79 helper.setObjSelectionFlag(&assoc,iobj,true);
80 }
81 // get cluster/inclusive pflow and track/charged pflow constituent sums
82 MissingETBase::Types::constvec_t overlapcalvec = assoc.overlapCalVec(helper);
83 MissingETBase::Types::constvec_t overlaptrkvec = assoc.overlapTrkVec(helper);
84
85 ATH_MSG_VERBOSE(" Jet constituent-scale pt: " << jetconstp4.pt() << ", E: " << jetconstp4.e() );
86 ATH_MSG_VERBOSE(" Max constituent overlap pt: " << overlapcalvec.cpt() << ", E: " << overlapcalvec.ce() );
87
88 ATH_MSG_VERBOSE(" Jet track pt: " << jettrkvec.cpt() << ", E: " << jettrkvec.ce() );
89 ATH_MSG_VERBOSE(" Max track overlap pt: " << overlaptrkvec.cpt() << ", E: " << overlaptrkvec.ce() );
90
91 // optionally quit and fail if overlap-removal exceeds original jet constituent-scale energy
92 if(overlapcalvec.ce()-jetconstp4.e()>f_tolerance) {
93 ATH_MSG_ERROR("Too-large overlapcalvec!");
94 if(m_failOnInconsistency) return StatusCode::FAILURE;
95 }
96 if(overlaptrkvec.ce()-jettrkvec.ce()>f_tolerance) {
97 ATH_MSG_ERROR("Too-large overlaptrkvec!");
98 if(m_failOnInconsistency) return StatusCode::FAILURE;
99 }
100
101 return StatusCode::SUCCESS;
102 }
103
105 {
106 const auto& jet = *assoc.refJet();
107 JetFourMom_t jetconstp4 = jet.jetP4(JetConstitScaleMomentum);
109
111
112 // loop over individual objects and check that none of them has a larger
113 // associated constituent sum than the jet
114 for(size_t iobj=0; iobj<assoc.objects().size(); ++iobj) {
115 ATH_MSG_VERBOSE(" Now on constituent " << iobj );
116 const IParticle* obj = assoc.objects()[iobj];
117 if(!obj) continue; // invalid ElementLink -- thinned?
118 helper.resetObjSelectionFlags();
119 helper.setObjSelectionFlag(&assoc,iobj,true);
120 MissingETBase::Types::constvec_t overlapcalvec = assoc.overlapCalVec(helper);
121 MissingETBase::Types::constvec_t overlaptrkvec = assoc.overlapTrkVec(helper);
122
123 ATH_MSG_VERBOSE(" Object pt: " << obj->pt() << ", E: " << obj->e() << ", type: " << obj->type());
124 ATH_MSG_VERBOSE(" Constituent pt: " << overlapcalvec.cpt() << ", E: " << overlapcalvec.ce() );
125 ATH_MSG_VERBOSE(" Track pt: " << overlaptrkvec.cpt() << ", E: " << overlaptrkvec.ce() );
126
127 // optionally quit and fail if overlap-removal exceeds original jet constituent-scale energy
128 if(overlapcalvec.ce()-jetconstp4.e()>f_tolerance) {
129 ATH_MSG_ERROR("Too-large overlapcalvec!");
130 ATH_MSG_ERROR(" Object pt: " << obj->pt() << ", E: " << obj->e() << ", type: " << obj->type());
131 if(m_failOnInconsistency) return StatusCode::FAILURE;
132 }
133 if(overlaptrkvec.ce()-jettrkvec.ce()>f_tolerance) {
134 ATH_MSG_ERROR("Too-large overlaptrkvec!");
135 ATH_MSG_ERROR(" Object pt: " << obj->pt() << ", E: " << obj->e() << ", type: " << obj->type());
136 if(m_failOnInconsistency) return StatusCode::FAILURE;
137 }
138 }
139
140 return StatusCode::SUCCESS;
141 }
142
144 {
145 const auto& jet = *assoc.refJet();
146 JetFourMom_t jetconstp4 = jet.jetP4(JetConstitScaleMomentum);
148
149 // loop over the encoded cluster/inclusive pflow constituent sums and check that these are
150 // all smaller than the jet constituent-scale pt
151 for(size_t ikey=0; ikey<assoc.calkey().size(); ++ikey) {
152 ATH_MSG_VERBOSE(" Now on calkey " << ikey << ": " << assoc.calkey()[ikey] );
153 MissingETBase::Types::constvec_t calvec = assoc.calVec(ikey);
154 ATH_MSG_VERBOSE(" Constituent pt: " << calvec.cpt() << ", E: " << calvec.ce() );
155
156 if(calvec.ce()-jetconstp4.e()>f_tolerance) {
157 ATH_MSG_ERROR("Too-large calvec!");
158 for(size_t iobj=0; iobj<assoc.objects().size(); ++iobj) {
159 if( ((1<<iobj)&assoc.calkey()[ikey]) == 0 ) {
160 const IParticle* obj = assoc.objects()[iobj];
161 if(!obj) continue; // invalid ElementLink -- thinned?
162 ATH_MSG_ERROR(" Object pt: " << obj->pt() << ", E: " << obj->e() << ", type: " << obj->type());
163 }
164 }
165 if(m_failOnInconsistency) return StatusCode::FAILURE;
166 }
167 }
168
169 // loop over the encoded track/charged pflow constituent sums and check that these are
170 // all smaller than the jet track sum
171 for(size_t ikey=0; ikey<assoc.trkkey().size(); ++ikey) {
172 ATH_MSG_VERBOSE(" Now on trkkey " << ikey << ": " << assoc.trkkey()[ikey] );
173 MissingETBase::Types::constvec_t trkvec = assoc.trkVec(ikey);
174 ATH_MSG_VERBOSE(" Track pt: " << trkvec.cpt() << ", E: " << trkvec.ce() );
175
176 if(trkvec.ce()-jettrkvec.ce()>f_tolerance) {
177 ATH_MSG_ERROR("Too-large trkvec!");
178 for(size_t iobj=0; iobj<assoc.objects().size(); ++iobj) {
179 if( ((1<<iobj)&assoc.trkkey()[ikey]) == 0 ) {
180 const IParticle* obj = assoc.objects()[iobj];
181 if(!obj) continue; // invalid ElementLink -- thinned?
182 ATH_MSG_ERROR(" Object pt: " << obj->pt() << ", E: " << obj->e() << ", type: " << obj->type());
183 }
184 }
185 if(m_failOnInconsistency) return StatusCode::FAILURE;
186 }
187 }
188
189 return StatusCode::SUCCESS;
190 }
191
193 {
194 // loop over the encoded cluster/inclusive pflow constituent sums
195 for(size_t ikey=0; ikey<assoc.calkey().size(); ++ikey) {
196 ATH_MSG_VERBOSE(" Now on calkey " << ikey << ": " << assoc.calkey()[ikey] );
197 MissingETBase::Types::constvec_t calvec = assoc.calVec(ikey);
198 ATH_MSG_VERBOSE(" Constituent pt: " << calvec.cpt() << ", E: " << calvec.ce() );
199 }
200
201 // loop over the encoded track/charged pflow constituent sums
202 for(size_t ikey=0; ikey<assoc.trkkey().size(); ++ikey) {
203 ATH_MSG_VERBOSE(" Now on trkkey " << ikey << ": " << assoc.trkkey()[ikey] );
204 MissingETBase::Types::constvec_t trkvec = assoc.trkVec(ikey);
205 ATH_MSG_VERBOSE(" Track pt: " << trkvec.cpt() << ", E: " << trkvec.ce() );
206 }
207
208 return StatusCode::SUCCESS;
209 }
210}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static const float f_tolerance
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
STL class.
StatusCode checkMiscAssoc(const xAOD::MissingETAssociation &)
StatusCode checkAssoc(const xAOD::MissingETAssociation &)
METAssocTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode checkObjects(const xAOD::MissingETAssociation &)
StatusCode checkJet(const xAOD::MissingETAssociation &)
Class providing the definition of the 4-vector interface.
const Jet * refJet() const
Access reference jet.
const std::vector< MissingETBase::Types::bitmask_t > & calkey() const
Get the vector of cal keys.
ConstVec trkVec(const IParticle *pPart) const
Get track constituent vector for a given object.
ConstVec overlapTrkVec(const MissingETAssociationHelper &helper) const
Retrieve total track-based vector to be subtracted from the jet.
std::vector< const IParticle * > objects() const
Access contributing objects.
const std::vector< MissingETBase::Types::bitmask_t > & trkkey() const
Get the vector of trk keys.
ConstVec overlapCalVec(const MissingETAssociationHelper &helper) const
Retrieve total cluster-based vector to be subtracted from the jet.
ConstVec jetTrkVec() const
Get track constituent vector for the reference jet.
ConstVec calVec(const IParticle *pPart) const
Get calo constituent vector for a given object.
xAOD::MissingETAssociation_v1::ConstVec constvec_t
Type for constituent vector.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
MissingETAssociation_v1 MissingETAssociation
Version control by type definition.
@ JetConstitScaleMomentum
Definition JetTypes.h:29
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17