ATLAS Offline Software
Loading...
Searching...
No Matches
CorrectPFOTool Class Reference

Applies various corrections to PFO. More...

#include <CorrectPFOTool.h>

Inheritance diagram for CorrectPFOTool:
Collaboration diagram for CorrectPFOTool:

Public Member Functions

 CorrectPFOTool (const std::string &name)
StatusCode initialize () override final
 Dummy implementation of the initialisation function.
StatusCode process (xAOD::IParticleContainer *cont) const override final
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

StatusCode setEtaPhi (xAOD::IParticle *obj, float eta, float phi) const
StatusCode setEnergyPt (xAOD::IParticle *obj, float e, float pt, const SG::AuxElement::Accessor< float > *weightAcc=nullptr) const
StatusCode setP4 (xAOD::IParticle *obj, const xAOD::JetFourMom_t &p4, const SG::AuxElement::Accessor< float > *weightAcc=nullptr) const
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

unsigned int m_inputType =xAOD::Type::Other
bool m_applyToChargedPFO =true
bool m_applyToNeutralPFO =true

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode process_impl (xAOD::IParticleContainer *cont) const override final
StatusCode correctPFO (xAOD::PFOContainer &cont) const
StatusCode correctPFO (xAOD::FlowElementContainer &cont) const
StatusCode correctPFOByVertex (xAOD::PFOContainer &cont) const
StatusCode correctPFOByVertex (xAOD::FlowElementContainer &cont) const
const xAOD::VertexgetPrimaryVertex () const
StatusCode applyNeutralCorrection (xAOD::PFO &pfo, const xAOD::Vertex &vtx) const
StatusCode applyNeutralCorrection (xAOD::FlowElement &pfo, const xAOD::Vertex &vtx) const
StatusCode applyChargedCorrection (xAOD::PFO &pfo) const
StatusCode applyChargedCorrection (xAOD::FlowElement &pfo) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

bool m_inputIsEM
bool m_calibrate
 If true EM clusters are used for neutral PFOs.
bool m_correctneutral
 If true, EM PFOs are calibrated to LC.
bool m_correctcharged
bool m_useChargedWeights
bool m_doByVertex
ToolHandle< CP::IWeightPFOToolm_weightPFOTool
SG::ReadHandleKey< xAOD::VertexContainerm_vertexContainer_key
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Applies various corrections to PFO.

Properties: InputIsEM - If true, EM-scale is used for the neutral pflow CalibratePFO - If true the EM-scale pflow is calibrated

Author
Jennifer Roloff, John Stupak, and Steven Schramm - based on PFlowPseudoJetGetter by P-A Delsart, D. Adams

Definition at line 32 of file CorrectPFOTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CorrectPFOTool()

CorrectPFOTool::CorrectPFOTool ( const std::string & name)

Definition at line 13 of file CorrectPFOTool.cxx.

13 :
15 m_weightPFOTool("",this) {
16
17 // Configuration
18 declareProperty("WeightPFOTool", m_weightPFOTool, "Name of tool that extracts the cPFO weights.");
19 declareProperty("InputIsEM", m_inputIsEM = true, "True if neutral PFOs are EM scale clusters.");
20 declareProperty("CalibratePFO", m_calibrate = false, "True if LC calibration should be applied to EM PFOs.");
21 declareProperty("CorrectNeutral", m_correctneutral = true, "True to use the neutral component of PFlow.");
22 declareProperty("CorrectCharged", m_correctcharged = true, "True if use the charged component of PFlow.");
23 declareProperty("UseChargedWeights",m_useChargedWeights = true, "True if we make use of weighting scheme for charged PFO");
24 declareProperty("DoByVertex", m_doByVertex = false, "True to add vertex-by-vertex corrections for neutral PFOs");
25
26 // Input properties
27 declareProperty("VertexContainerKey",
28 m_vertexContainer_key="PrimaryVertices",
29 "Datahandle key for the primary vertex container");
30}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool m_calibrate
If true EM clusters are used for neutral PFOs.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
ToolHandle< CP::IWeightPFOTool > m_weightPFOTool
bool m_correctneutral
If true, EM PFOs are calibrated to LC.
JetConstituentModifierBase(const std::string &name)

Member Function Documentation

◆ applyChargedCorrection() [1/2]

StatusCode CorrectPFOTool::applyChargedCorrection ( xAOD::FlowElement & pfo) const
private

Definition at line 313 of file CorrectPFOTool.cxx.

313 {
315 float weight = 0.0;
316 ATH_CHECK( m_weightPFOTool->fillWeight( pfo, weight ) );
317 ATH_MSG_VERBOSE("Fill pseudojet for CPFO with weighted pt: " << pfo.pt()*weight);
318 pfo.setP4(pfo.p4()*weight);
319 }//if should use charged PFO weighting scheme
320 return StatusCode::SUCCESS;
321}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
virtual double pt() const override
void setP4(float pt, float eta, float phi, float m)
virtual FourMom_t p4() const override
The full 4-momentum of the particle.

◆ applyChargedCorrection() [2/2]

StatusCode CorrectPFOTool::applyChargedCorrection ( xAOD::PFO & pfo) const
private

Definition at line 303 of file CorrectPFOTool.cxx.

303 {
305 float weight = 0.0;
306 ATH_CHECK( m_weightPFOTool->fillWeight( pfo, weight ) );
307 ATH_MSG_VERBOSE("Fill pseudojet for CPFO with weighted pt: " << pfo.pt()*weight);
308 pfo.setP4(pfo.p4()*weight);
309 }//if should use charged PFO weighting scheme
310 return StatusCode::SUCCESS;
311}
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition PFO_v1.cxx:95
void setP4(const FourMom_t &vec)
set the 4-vec
Definition PFO_v1.cxx:107
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition PFO_v1.cxx:52

◆ applyNeutralCorrection() [1/2]

StatusCode CorrectPFOTool::applyNeutralCorrection ( xAOD::FlowElement & pfo,
const xAOD::Vertex & vtx ) const
private

Definition at line 292 of file CorrectPFOTool.cxx.

292 {
293 if (pfo.e() < FLT_MIN) { //This is necessary to avoid changing sign of pT for pT<0 PFO
294 pfo.setP4(0,0,0,0);
295 }
296 // Only apply origin correction if we really reconstructed a vertex
297 else if(vtx.vertexType() == xAOD::VxType::PriVtx) {
299 }
300 return StatusCode::SUCCESS;
301}
virtual double e() const override
The total energy of the particle.
VxType::VertexType vertexType() const
The type of the vertex.
TLorentzVector getVertexCorrectedFourVec(const xAOD::FlowElement &fe, const xAOD::Vertex &vertexToCorrectTo)
Definition FEHelpers.cxx:13
@ PriVtx
Primary vertex.

◆ applyNeutralCorrection() [2/2]

StatusCode CorrectPFOTool::applyNeutralCorrection ( xAOD::PFO & pfo,
const xAOD::Vertex & vtx ) const
private

Definition at line 273 of file CorrectPFOTool.cxx.

273 {
274 if (pfo.e() < FLT_MIN) { //This is necessary to avoid changing sign of pT for pT<0 PFO
275 pfo.setP4(0,0,0,0);
276 } else {
277 if ( !m_inputIsEM || m_calibrate ) { // Use LC four-vector
278 // Only correct if we really reconstructed a vertex
280 pfo.setP4(pfo.GetVertexCorrectedFourVec(vtx));
281 }
282 } else { // Use EM four-vector
283 // Only apply origin correction if we really reconstructed a vertex
286 } else {pfo.setP4(pfo.p4EM());} // Just set EM 4-vec
287 }
288 }
289 return StatusCode::SUCCESS;
290}
TLorentzVector GetVertexCorrectedFourVec(const xAOD::Vertex &vertexToCorrectTo) const
Correct 4-vector to point at a vertex.
Definition PFO_v1.cxx:722
FourMom_t p4EM() const
get EM scale 4-vector
Definition PFO_v1.cxx:144
TLorentzVector GetVertexCorrectedEMFourVec(const xAOD::Vertex &vertexToCorrectTo) const
Correct EM scale 4-vector to point at a vertex.
Definition PFO_v1.cxx:737
virtual double e() const
The total energy of the particle.
Definition PFO_v1.cxx:81

◆ correctPFO() [1/2]

StatusCode CorrectPFOTool::correctPFO ( xAOD::FlowElementContainer & cont) const
private

Definition at line 130 of file CorrectPFOTool.cxx.

130 {
131
132 const xAOD::Vertex* vtx = nullptr;
133 if(m_correctneutral) {
134 vtx = getPrimaryVertex();
135 if(vtx==nullptr) {
136 ATH_MSG_ERROR("Primary vertex container was empty or no valid vertex found!");
137 return StatusCode::FAILURE;
138 } else if (vtx->vertexType()==xAOD::VxType::NoVtx) {
139 ATH_MSG_VERBOSE("No genuine primary vertex found. Will not apply origin correction");
140 }
141 }
142
143 for ( xAOD::FlowElement* ppfo : cont ) {
144
145 if ( !ppfo->isCharged()) { // Neutral PFOs
146 if(m_correctneutral) {
147 ATH_CHECK( applyNeutralCorrection(*ppfo, *vtx) );
148 }
149 } else { // Charged PFOs
150 if(m_correctcharged) {
152 }
153 }
154 } // PFO loop
155
156 return StatusCode::SUCCESS;
157}
#define ATH_MSG_ERROR(x)
StatusCode applyChargedCorrection(xAOD::PFO &pfo) const
StatusCode applyNeutralCorrection(xAOD::PFO &pfo, const xAOD::Vertex &vtx) const
const xAOD::Vertex * getPrimaryVertex() const
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ correctPFO() [2/2]

StatusCode CorrectPFOTool::correctPFO ( xAOD::PFOContainer & cont) const
private

Definition at line 101 of file CorrectPFOTool.cxx.

101 {
102
103 const xAOD::Vertex* vtx = nullptr;
104 if(m_correctneutral) {
105 vtx = getPrimaryVertex();
106 if(vtx==nullptr) {
107 ATH_MSG_ERROR("Primary vertex container was empty or no valid vertex found!");
108 return StatusCode::FAILURE;
109 } else if (vtx->vertexType()==xAOD::VxType::NoVtx) {
110 ATH_MSG_VERBOSE("No genuine primary vertex found. Will not apply origin correction");
111 }
112 }
113
114 for ( xAOD::PFO* ppfo : cont ) {
115
116 if ( std::abs(ppfo->charge())<FLT_MIN) { // Neutral PFOs
117 if(m_correctneutral) {
118 ATH_CHECK( applyNeutralCorrection(*ppfo, *vtx) );
119 }
120 } else { // Charged PFOs
121 if(m_correctcharged) {
123 }
124 }
125 } // PFO loop
126
127 return StatusCode::SUCCESS;
128}
PFO_v1 PFO
Definition of the current "pfo version".
Definition PFO.h:17

◆ correctPFOByVertex() [1/2]

StatusCode CorrectPFOTool::correctPFOByVertex ( xAOD::FlowElementContainer & cont) const
private

Definition at line 217 of file CorrectPFOTool.cxx.

217 {
218 static const SG::AuxElement::Accessor<unsigned> copyIndex("ConstituentCopyIndex");
219
220 // Retrieve Primary Vertices
222 if (!handle.isValid()){
223 ATH_MSG_WARNING(" This event has no primary vertex container" );
224 return StatusCode::FAILURE;
225 }
226
227 const xAOD::VertexContainer* pvtxs = handle.cptr();
228 if(pvtxs->empty()){
229 ATH_MSG_WARNING(" Failed to retrieve valid primary vertex container" );
230 return StatusCode::FAILURE;
231 }
232
233 for ( xAOD::FlowElement* ppfo : cont ) {
234
235 if ( !ppfo->isCharged()) { // Neutral PFOs
236 if(m_correctneutral) {
237 // Neutral PFOs - there are copies, one per vertex, already created
238 // We need to now need to correct each copy to point to the corresponding vertex
239 if (!copyIndex.isAvailable(*ppfo))
240 {
241 ATH_MSG_WARNING("Encountered a neutral per-vertex PFO object without the corresponding vertex index attribute");
242 continue;
243 }
244
245 const unsigned iVtx = copyIndex(*ppfo);
246 if (iVtx >= pvtxs->size())
247 {
248 ATH_MSG_WARNING("Encountered a neutral per-vertex PFO object with an index beyond the size of the vertex container");
249 continue;
250 }
251 const xAOD::Vertex* vtx = pvtxs->at(iVtx);
252 // Determine the correct four-vector interpretation for a neutral PFO associated with this vertex
253 // Cannot use applyNeutralCorrection as that only used VxType::PriVtx, but we want to apply to all primary vertices
254 // As such, extract the relevant parts and modify appropriately here
255 // This is necessary to avoid changing sign of pT for pT<0 PFO
256 if (ppfo->e() < FLT_MIN) {
257 ppfo->setP4(0, 0, 0, 0);
258 }
259 ppfo->setP4(FEHelpers::getVertexCorrectedFourVec(*ppfo, *vtx));
260 }
261 } else { // Charged PFOs
262 if(m_correctcharged) {
264 }
265 }
266 } // PFO loop
267
268
269 return StatusCode::SUCCESS;
270}
#define ATH_MSG_WARNING(x)
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".

◆ correctPFOByVertex() [2/2]

StatusCode CorrectPFOTool::correctPFOByVertex ( xAOD::PFOContainer & cont) const
private

Definition at line 159 of file CorrectPFOTool.cxx.

159 {
160 static const SG::AuxElement::Accessor<unsigned> copyIndex("ConstituentCopyIndex");
161 // Retrieve Primary Vertices
163 if (!handle.isValid()){
164 ATH_MSG_WARNING(" This event has no primary vertex container" );
165 return StatusCode::FAILURE;
166 }
167
168 const xAOD::VertexContainer* pvtxs = handle.cptr();
169 if(pvtxs->empty()){
170 ATH_MSG_WARNING(" Failed to retrieve valid primary vertex container" );
171 return StatusCode::FAILURE;
172 }
173
174 for ( xAOD::PFO* ppfo : cont ) {
175
176 if ( std::abs(ppfo->charge())<FLT_MIN) { // Neutral PFOs
177 if(m_correctneutral) {
178 // Neutral PFOs - there are copies, one per vertex, already created
179 // We need to now need to correct each copy to point to the corresponding vertex
180 if (!copyIndex.isAvailable(*ppfo))
181 {
182 ATH_MSG_WARNING("Encountered a neutral per-vertex PFO object without the corresponding vertex index attribute");
183 continue;
184 }
185
186 const unsigned iVtx = copyIndex(*ppfo);
187 if (iVtx >= pvtxs->size())
188 {
189 ATH_MSG_WARNING("Encountered a neutral per-vertex PFO object with an index beyond the size of the vertex container");
190 continue;
191 }
192 const xAOD::Vertex* vtx = pvtxs->at(iVtx);
193 // Determine the correct four-vector interpretation for a neutral PFO associated with this vertex
194 // Cannot use applyNeutralCorrection as that only used VxType::PriVtx, but we want to apply to all primary vertices
195 // As such, extract the relevant parts and modify appropriately here
196 // This is necessary to avoid changing sign of pT for pT<0 PFO
197 if (ppfo->e() < FLT_MIN) {
198 ppfo->setP4(0, 0, 0, 0);
199 }
200 if (!m_inputIsEM || m_calibrate) { // Use LC four-vector
201 ppfo->setP4(ppfo->GetVertexCorrectedFourVec(*vtx));
202 } else { // Use EM four-vector
203 ppfo->setP4(ppfo->GetVertexCorrectedEMFourVec(*vtx));
204 }
205 }
206 } else { // Charged PFOs
207 if(m_correctcharged) {
209 }
210 }
211 } // PFO loop
212
213
214 return StatusCode::SUCCESS;
215}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::TEvent, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::TEvent, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getPrimaryVertex()

const xAOD::Vertex * CorrectPFOTool::getPrimaryVertex ( ) const
private

Definition at line 66 of file CorrectPFOTool.cxx.

66 {
67 // Retrieve Primary Vertices
69 if (!handle.isValid()){
70 ATH_MSG_WARNING(" This event has no primary vertex container" );
71 return nullptr;
72 }
73
74 const xAOD::VertexContainer* pvtxs = handle.cptr();
75 if(pvtxs->empty()){
76 ATH_MSG_WARNING(" Failed to retrieve valid primary vertex container" );
77 return nullptr;
78 }
79
80 //Usually the 0th vertex is the primary one, but this is not always
81 // the case. So we will choose the first vertex of type PriVtx
82 for (const auto *theVertex : *pvtxs) {
83 if (theVertex->vertexType()==xAOD::VxType::PriVtx) {
84 return theVertex;
85 }//If we have a vertex of type primary vertex
86 }//iterate over the vertices and check their type
87
88 // If we failed to find an appropriate vertex, return the dummy vertex
89 ATH_MSG_DEBUG("Could not find a primary vertex in this event " );
90 for (const auto *theVertex : *pvtxs) {
91 if (theVertex->vertexType()==xAOD::VxType::NoVtx) {
92 return theVertex;
93 }
94 }
95
96 // If there is no primary vertex, then we cannot do PV matching.
97 ATH_MSG_WARNING("Primary vertex container was empty");
98 return nullptr;
99}
#define ATH_MSG_DEBUG(x)

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ initialize()

StatusCode CorrectPFOTool::initialize ( void )
finaloverridevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 32 of file CorrectPFOTool.cxx.

32 {
34 ATH_MSG_ERROR("This tool is configured to do nothing!");
35 return StatusCode::FAILURE;
36 }
38 ATH_MSG_ERROR("CorrectPFOTool requires PFO inputs. It cannot operate on objects of type "
39 << m_inputType);
40 return StatusCode::FAILURE;
41 }
43 ATH_CHECK( m_weightPFOTool.retrieve() );
44 }
45 ATH_CHECK( m_vertexContainer_key.initialize() );
46
47 ATH_MSG_INFO("Running CorrectPFOTool by vertex:" << m_doByVertex);
48 return StatusCode::SUCCESS;
49}
#define ATH_MSG_INFO(x)
@ ParticleFlow
The object is a particle-flow object.
Definition ObjectType.h:41
@ FlowElement
The object is a track-calo-cluster.
Definition ObjectType.h:52

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

◆ process()

StatusCode JetConstituentModifierBase::process ( xAOD::IParticleContainer * cont) const
finaloverridevirtualinherited

Implements IJetConstituentModifier.

Definition at line 23 of file JetConstituentModifierBase.cxx.

24{
25 // Test that we are operating on the type of object that
26 // we will be writing out.
27 // By implication, any supporting containers should not
28 // be the ones passed to this method...
29 if(!cont->empty() && cont->front()->type() != m_inputType) {
30 ATH_MSG_ERROR("Object type mismatch! This tool expects " << m_inputType
31 << ", but received " << cont->front()->type());
32 return StatusCode::FAILURE;
33 }
34
36
37 return StatusCode::SUCCESS;
38}
const T * front() const
Access the first element in the collection as an rvalue.
virtual StatusCode process_impl(xAOD::IParticleContainer *) const

◆ process_impl()

StatusCode CorrectPFOTool::process_impl ( xAOD::IParticleContainer * cont) const
finaloverrideprivatevirtual

Reimplemented from JetConstituentModifierBase.

Definition at line 51 of file CorrectPFOTool.cxx.

51 {
52 // Type-checking happens in the JetConstituentModifierBase class
53 // so it is safe just to static_cast
55 xAOD::FlowElementContainer* feCont = static_cast<xAOD::FlowElementContainer*>(cont);
56 if(!feCont->empty() && !(feCont->front()->signalType() & xAOD::FlowElement::PFlow)){
57 ATH_MSG_ERROR("CorrectPFOTool received FlowElements that aren't PFOs");
58 return StatusCode::FAILURE;
59 }
60 return m_doByVertex ? correctPFOByVertex(*feCont) : correctPFO(*feCont);
61 }
62 xAOD::PFOContainer* pfoCont = static_cast<xAOD::PFOContainer*> (cont);
63 return m_doByVertex ? correctPFOByVertex(*pfoCont) : correctPFO(*pfoCont);
64}
StatusCode correctPFOByVertex(xAOD::PFOContainer &cont) const
StatusCode correctPFO(xAOD::PFOContainer &cont) const
signal_t signalType() const
FlowElementContainer_v1 FlowElementContainer
Definition of the current "pfo container version".
PFOContainer_v1 PFOContainer
Definition of the current "pfo container version".

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setEnergyPt()

StatusCode JetConstituentModifierBase::setEnergyPt ( xAOD::IParticle * obj,
float e,
float pt,
const SG::AuxElement::Accessor< float > * weightAcc = nullptr ) const
protectedinherited

Definition at line 61 of file JetConstituentModifierBase.cxx.

63{
64 switch(m_inputType) {
66 {
67 xAOD::CaloCluster* clus = static_cast<xAOD::CaloCluster*>(obj);
68 // Clusters get pt via the energy
69 // This currently leaves the mass unaltered.
70 if(weightAcc) (*weightAcc)(*clus) = clus->calE() > 0. ? e / clus->calE() : 0.;
71 clus->setCalE(e);
72 }
73 break;
75 {
76 xAOD::PFO* pfo = static_cast<xAOD::PFO*>(obj);
77 if( (m_applyToChargedPFO && pfo->isCharged()) ||
78 (m_applyToNeutralPFO && !pfo->isCharged()) ) {
79 if(weightAcc) (*weightAcc)(*pfo) = pfo->pt() > 0. ? pt / pfo->pt() : 0.;
80 // KTJ: Temporary fix
81 // Defeats the purpose, but we need to use this to reset the 4-vec cache
82 pfo->setP4(pt, pfo->eta(), pfo->phi());
83 }
84 }
85 break;
87 {
88 xAOD::FlowElement* pfo = static_cast<xAOD::FlowElement*>(obj);
89 if( (m_applyToChargedPFO && pfo->isCharged()) ||
90 (m_applyToNeutralPFO && !pfo->isCharged()) ) {
91 if(weightAcc) (*weightAcc)(*pfo) = pfo->pt() > 0. ? pt / pfo->pt() : 0.;
92 pfo->setP4(pt, pfo->eta(), pfo->phi(), 0.);
93 }
94 }
95 break;
97 {
99 if( tcc->taste() != 0) {
100 if(weightAcc) (*weightAcc)(*tcc) = tcc->pt() > 0. ? pt / tcc->pt() : 0.;
101 tcc->setParameters(pt, tcc->eta(), tcc->phi(), tcc->m(), xAOD::TrackCaloCluster::Taste(tcc->taste()), tcc->trackParticleLink(), tcc->caloClusterLinks());
102 }
103 }
104 break;
105 default:
106 // Should not get here, because type-checking should happen in process()
107 ATH_MSG_ERROR("No specialisation for object type " << m_inputType);
108 return StatusCode::FAILURE;
109 }
110 return StatusCode::SUCCESS;
111}
flt_t calE() const
Geet Energy in signal state CALIBRATED.
bool isCharged() const
is a charged PFO
Definition PFO_v1.cxx:251
virtual int taste() const
The taste of the particle.
Taste
Type of TrackCaloCluster - Charged - Neutral - Combined.
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39
@ TrackCaloCluster
The object is a track-calo-cluster.
Definition ObjectType.h:51
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackCaloCluster_v1 TrackCaloCluster
Reference the current persistent version:

◆ setEtaPhi()

StatusCode JetConstituentModifierBase::setEtaPhi ( xAOD::IParticle * obj,
float eta,
float phi ) const
protectedinherited

Definition at line 41 of file JetConstituentModifierBase.cxx.

42{
43 switch(m_inputType) {
44 // The main (only?) application is origin-correcting LC topoclusters
45 // By convention we leave the raw p4 unmodified
47 {
48 xAOD::CaloCluster* clus = static_cast<xAOD::CaloCluster*>(obj);
49 clus->setCalEta(eta);
50 clus->setCalPhi(phi);
51 }
52 break;
53 default:
54 // Should not get here, because type-checking should happen in process()
55 ATH_MSG_ERROR("No specialisation for object type " << m_inputType);
56 return StatusCode::FAILURE;
57 }
58 return StatusCode::SUCCESS;
59}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
void setCalPhi(flt_t)
Set for signal state CALIBRATED.
void setCalEta(flt_t)
Set for signal state CALIBRATED.

◆ setP4()

StatusCode JetConstituentModifierBase::setP4 ( xAOD::IParticle * obj,
const xAOD::JetFourMom_t & p4,
const SG::AuxElement::Accessor< float > * weightAcc = nullptr ) const
protectedinherited

Definition at line 113 of file JetConstituentModifierBase.cxx.

114 {
115 switch(m_inputType) {
117 {
118 xAOD::CaloCluster* clus = static_cast<xAOD::CaloCluster*>(obj);
119 // This currently leaves the mass unaltered
120 if(weightAcc) (*weightAcc)(*clus) = clus->calE() > 0. ? p4.e() / clus->calE() : 0.;
121 clus->setCalE(p4.e());
122 clus->setCalEta(p4.eta());
123 clus->setCalPhi(p4.phi());
124 }
125 break;
127 {
128 xAOD::PFO* pfo = static_cast<xAOD::PFO*>(obj);
129 // The PFO setter defaults to m=0
130 if( (m_applyToChargedPFO && pfo->isCharged()) ||
131 (m_applyToNeutralPFO && !pfo->isCharged()) ) {
132 if(weightAcc) (*weightAcc)(*pfo) = pfo->pt() > 0. ? p4.pt() / pfo->pt() : 0.;
133 pfo->setP4(p4.pt(),p4.eta(),p4.phi(),p4.mass());
134 }
135 }
136 break;
138 {
139 xAOD::FlowElement* pfo = static_cast<xAOD::FlowElement*>(obj);
140 if( (m_applyToChargedPFO && pfo->isCharged()) ||
141 (m_applyToNeutralPFO && !pfo->isCharged()) ) {
142 if(weightAcc) (*weightAcc)(*pfo) = pfo->pt() > 0. ? p4.pt() / pfo->pt() : 0.;
143 pfo->setP4(p4.pt(),p4.eta(),p4.phi(),p4.mass());
144 }
145 }
146 break;
148 {
150 if( tcc->taste() != 0) {
151 if(weightAcc) (*weightAcc)(*tcc) = tcc->pt() > 0. ? p4.pt() / tcc->pt() : 0.;
152 tcc->setParameters(p4.pt(), p4.eta(), p4.phi(), p4.mass(), xAOD::TrackCaloCluster::Taste(tcc->taste()), tcc->trackParticleLink(), tcc->caloClusterLinks());
153 }
154 break;
155 }
156
157 default:
158 // Should not get here, because type-checking should happen in process()
159 ATH_MSG_ERROR("No specialisation for object type " << m_inputType);
160 return StatusCode::FAILURE;
161 }
162 return StatusCode::SUCCESS;
163}

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_applyToChargedPFO

bool JetConstituentModifierBase::m_applyToChargedPFO =true
protectedinherited

Definition at line 62 of file JetConstituentModifierBase.h.

◆ m_applyToNeutralPFO

bool JetConstituentModifierBase::m_applyToNeutralPFO =true
protectedinherited

Definition at line 63 of file JetConstituentModifierBase.h.

◆ m_calibrate

bool CorrectPFOTool::m_calibrate
private

If true EM clusters are used for neutral PFOs.

Definition at line 59 of file CorrectPFOTool.h.

◆ m_correctcharged

bool CorrectPFOTool::m_correctcharged
private

Definition at line 61 of file CorrectPFOTool.h.

◆ m_correctneutral

bool CorrectPFOTool::m_correctneutral
private

If true, EM PFOs are calibrated to LC.

Definition at line 60 of file CorrectPFOTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doByVertex

bool CorrectPFOTool::m_doByVertex
private

Definition at line 63 of file CorrectPFOTool.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_inputIsEM

bool CorrectPFOTool::m_inputIsEM
private

Definition at line 58 of file CorrectPFOTool.h.

◆ m_inputType

unsigned int JetConstituentModifierBase::m_inputType =xAOD::Type::Other
protectedinherited

Definition at line 60 of file JetConstituentModifierBase.h.

◆ m_useChargedWeights

bool CorrectPFOTool::m_useChargedWeights
private

Definition at line 62 of file CorrectPFOTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vertexContainer_key

SG::ReadHandleKey<xAOD::VertexContainer> CorrectPFOTool::m_vertexContainer_key
private

Definition at line 66 of file CorrectPFOTool.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_weightPFOTool

ToolHandle<CP::IWeightPFOTool> CorrectPFOTool::m_weightPFOTool
private

Definition at line 64 of file CorrectPFOTool.h.


The documentation for this class was generated from the following files: