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 316 of file CorrectPFOTool.cxx.

316 {
318 float weight = 0.0;
319 ATH_CHECK( m_weightPFOTool->fillWeight( pfo, weight ) );
320 ATH_MSG_VERBOSE("Fill pseudojet for CPFO with weighted pt: " << pfo.pt()*weight);
321 pfo.setP4(pfo.p4()*weight);
322 }//if should use charged PFO weighting scheme
323 return StatusCode::SUCCESS;
324}
#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 306 of file CorrectPFOTool.cxx.

306 {
308 float weight = 0.0;
309 ATH_CHECK( m_weightPFOTool->fillWeight( pfo, weight ) );
310 ATH_MSG_VERBOSE("Fill pseudojet for CPFO with weighted pt: " << pfo.pt()*weight);
311 pfo.setP4(pfo.p4()*weight);
312 }//if should use charged PFO weighting scheme
313 return StatusCode::SUCCESS;
314}
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 295 of file CorrectPFOTool.cxx.

295 {
296 if (pfo.e() < FLT_MIN) { //This is necessary to avoid changing sign of pT for pT<0 PFO
297 pfo.setP4(0,0,0,0);
298 }
299 // Only apply origin correction if we really reconstructed a vertex
300 else if(vtx.vertexType() == xAOD::VxType::PriVtx) {
302 }
303 return StatusCode::SUCCESS;
304}
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 276 of file CorrectPFOTool.cxx.

276 {
277 if (pfo.e() < FLT_MIN) { //This is necessary to avoid changing sign of pT for pT<0 PFO
278 pfo.setP4(0,0,0,0);
279 } else {
280 if ( !m_inputIsEM || m_calibrate ) { // Use LC four-vector
281 // Only correct if we really reconstructed a vertex
283 pfo.setP4(pfo.GetVertexCorrectedFourVec(vtx));
284 }
285 } else { // Use EM four-vector
286 // Only apply origin correction if we really reconstructed a vertex
289 } else {pfo.setP4(pfo.p4EM());} // Just set EM 4-vec
290 }
291 }
292 return StatusCode::SUCCESS;
293}
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 133 of file CorrectPFOTool.cxx.

133 {
134
135 const xAOD::Vertex* vtx = nullptr;
136 if(m_correctneutral) {
137 vtx = getPrimaryVertex();
138 if(vtx==nullptr) {
139 ATH_MSG_ERROR("Primary vertex container was empty or no valid vertex found!");
140 return StatusCode::FAILURE;
141 } else if (vtx->vertexType()==xAOD::VxType::NoVtx) {
142 ATH_MSG_VERBOSE("No genuine primary vertex found. Will not apply origin correction");
143 }
144 }
145
146 for ( xAOD::FlowElement* ppfo : cont ) {
147
148 if ( !ppfo->isCharged()) { // Neutral PFOs
149 if(m_correctneutral) {
150 ATH_CHECK( applyNeutralCorrection(*ppfo, *vtx) );
151 }
152 } else { // Charged PFOs
153 if(m_correctcharged) {
155 }
156 }
157 } // PFO loop
158
159 return StatusCode::SUCCESS;
160}
#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 104 of file CorrectPFOTool.cxx.

104 {
105
106 const xAOD::Vertex* vtx = nullptr;
107 if(m_correctneutral) {
108 vtx = getPrimaryVertex();
109 if(vtx==nullptr) {
110 ATH_MSG_ERROR("Primary vertex container was empty or no valid vertex found!");
111 return StatusCode::FAILURE;
112 } else if (vtx->vertexType()==xAOD::VxType::NoVtx) {
113 ATH_MSG_VERBOSE("No genuine primary vertex found. Will not apply origin correction");
114 }
115 }
116
117 for ( xAOD::PFO* ppfo : cont ) {
118
119 if ( std::abs(ppfo->charge())<FLT_MIN) { // Neutral PFOs
120 if(m_correctneutral) {
121 ATH_CHECK( applyNeutralCorrection(*ppfo, *vtx) );
122 }
123 } else { // Charged PFOs
124 if(m_correctcharged) {
126 }
127 }
128 } // PFO loop
129
130 return StatusCode::SUCCESS;
131}
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 220 of file CorrectPFOTool.cxx.

220 {
221 static const SG::AuxElement::Accessor<unsigned> copyIndex("ConstituentCopyIndex");
222
223 // Retrieve Primary Vertices
225 if (!handle.isValid()){
226 ATH_MSG_WARNING(" This event has no primary vertex container" );
227 return StatusCode::FAILURE;
228 }
229
230 const xAOD::VertexContainer* pvtxs = handle.cptr();
231 if(pvtxs->empty()){
232 ATH_MSG_WARNING(" Failed to retrieve valid primary vertex container" );
233 return StatusCode::FAILURE;
234 }
235
236 for ( xAOD::FlowElement* ppfo : cont ) {
237
238 if ( !ppfo->isCharged()) { // Neutral PFOs
239 if(m_correctneutral) {
240 // Neutral PFOs - there are copies, one per vertex, already created
241 // We need to now need to correct each copy to point to the corresponding vertex
242 if (!copyIndex.isAvailable(*ppfo))
243 {
244 ATH_MSG_WARNING("Encountered a neutral per-vertex PFO object without the corresponding vertex index attribute");
245 continue;
246 }
247
248 const unsigned iVtx = copyIndex(*ppfo);
249 if (iVtx >= pvtxs->size())
250 {
251 ATH_MSG_WARNING("Encountered a neutral per-vertex PFO object with an index beyond the size of the vertex container");
252 continue;
253 }
254 const xAOD::Vertex* vtx = pvtxs->at(iVtx);
255 // Determine the correct four-vector interpretation for a neutral PFO associated with this vertex
256 // Cannot use applyNeutralCorrection as that only used VxType::PriVtx, but we want to apply to all primary vertices
257 // As such, extract the relevant parts and modify appropriately here
258 // This is necessary to avoid changing sign of pT for pT<0 PFO
259 if (ppfo->e() < FLT_MIN) {
260 ppfo->setP4(0, 0, 0, 0);
261 }
262 ppfo->setP4(FEHelpers::getVertexCorrectedFourVec(*ppfo, *vtx));
263 }
264 } else { // Charged PFOs
265 if(m_correctcharged) {
267 }
268 }
269 } // PFO loop
270
271
272 return StatusCode::SUCCESS;
273}
#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:573
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 162 of file CorrectPFOTool.cxx.

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

◆ 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 69 of file CorrectPFOTool.cxx.

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

54 {
55 // Type-checking happens in the JetConstituentModifierBase class
56 // so it is safe just to static_cast
58 xAOD::FlowElementContainer* feCont = static_cast<xAOD::FlowElementContainer*>(cont);
59 if(!feCont->empty() && !(feCont->front()->signalType() & xAOD::FlowElement::PFlow)){
60 ATH_MSG_ERROR("CorrectPFOTool received FlowElements that aren't PFOs");
61 return StatusCode::FAILURE;
62 }
63 return m_doByVertex ? correctPFOByVertex(*feCont) : correctPFO(*feCont);
64 }
65 xAOD::PFOContainer* pfoCont = static_cast<xAOD::PFOContainer*> (cont);
66 return m_doByVertex ? correctPFOByVertex(*pfoCont) : correctPFO(*pfoCont);
67}
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: