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

Removes charged PFO not associated to the PV. More...

#include <ChargedHadronSubtractionTool.h>

Inheritance diagram for ChargedHadronSubtractionTool:
Collaboration diagram for ChargedHadronSubtractionTool:

Public Member Functions

 ChargedHadronSubtractionTool (const std::string &name)
StatusCode initialize ()
 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
template<class T, class U>
StatusCode matchToPrimaryVertex (T &) const
template<class T, class U>
StatusCode matchByPrimaryVertex (T &) const
const xAOD::VertexgetPrimaryVertex () const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static double calcAbsZ0SinTheta (const xAOD::TrackParticle &trk, const xAOD::Vertex &vtx)

Private Attributes

Gaudi::Property< bool > m_useTrackToVertexTool = {this, "UseTrackToVertexTool", false, "True if we will use the track to vertex tool"}
Gaudi::Property< bool > m_ignoreVertex = {this, "IgnoreVertex", false, "Dummy option for cosmics - accept everything"}
Gaudi::Property< float > m_z0sinThetaCutValue = {this, "Z0sinThetaCutValue", 2.0, "True if we will use the track to vertex tool"}
Gaudi::Property< bool > m_byVertex = {this, "DoByVertex", false, "True if we should match to each primary vertex, not just PV0"}
SG::ReadHandleKey< xAOD::VertexContainerm_vertexContainer_key = {this, "VertexContainerKey", "PrimaryVertices", "key for the primary vertex container"}
SG::ReadHandleKey< jet::TrackVertexAssociationm_trkVtxAssoc_key = {this, "TrackVertexAssociation", "JetTrackVtxAssoc", "key for the TrackVertexAssociation object"}
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

Removes charged PFO not associated to the PV.

Author
John Stupak, Jennifer Roloff, and Steven Schramm

Definition at line 30 of file ChargedHadronSubtractionTool.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

◆ ChargedHadronSubtractionTool()

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

Definition at line 9 of file ChargedHadronSubtractionTool.cxx.

10{
11}
JetConstituentModifierBase(const std::string &name)

Member Function Documentation

◆ calcAbsZ0SinTheta()

double ChargedHadronSubtractionTool::calcAbsZ0SinTheta ( const xAOD::TrackParticle & trk,
const xAOD::Vertex & vtx )
staticprivate

Definition at line 95 of file ChargedHadronSubtractionTool.cxx.

96{
97 // vtz.z() provides z of that vertex w.r.t the center of the beamspot (z = 0).
98 // Thus we correct the track z0 to be w.r.t z = 0
99 const float z0 = trk.z0() + trk.vz() - vtx.z();
100 const float theta = trk.theta();
101 return std::abs(z0 * std::sin(theta));
102}
Scalar theta() const
theta method
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
float vz() const
The z origin for the parameters.
float z() const
Returns the z position.

◆ 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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ 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 * ChargedHadronSubtractionTool::getPrimaryVertex ( ) const
private

Definition at line 53 of file ChargedHadronSubtractionTool.cxx.

54{
55 // Retrieve Primary Vertices
57 if (!handle.isValid())
58 {
59 ATH_MSG_WARNING(" This event has no primary vertex container");
60 return nullptr;
61 }
62
63 const xAOD::VertexContainer *pvtxs = handle.cptr();
64 if (pvtxs->empty())
65 {
66 ATH_MSG_WARNING(" Failed to retrieve valid primary vertex container");
67 return nullptr;
68 }
69
70 // Usually the 0th vertex is the primary one, but this is not always
71 // the case. So we will choose the first vertex of type PriVtx
72 for (const auto *theVertex : *pvtxs)
73 {
74 if (theVertex->vertexType() == xAOD::VxType::PriVtx)
75 {
76 return theVertex;
77 } // If we have a vertex of type primary vertex
78 } // iterate over the vertices and check their type
79
80 // If we failed to find an appropriate vertex, return the dummy vertex
81 ATH_MSG_DEBUG("Could not find a primary vertex in this event");
82 for (const auto *theVertex : *pvtxs)
83 {
84 if (theVertex->vertexType() == xAOD::VxType::NoVtx)
85 {
86 return theVertex;
87 }
88 }
89
90 // If there is no primary vertex, then we cannot do PV matching.
91 ATH_MSG_WARNING("Primary vertex container is empty");
92 return nullptr;
93}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
bool empty() const noexcept
Returns true if the collection is empty.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ PriVtx
Primary vertex.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".

◆ getProperty()

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

Get one of the tool's properties.

◆ initialize()

StatusCode ChargedHadronSubtractionTool::initialize ( void )
virtual

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 13 of file ChargedHadronSubtractionTool.cxx.

14{
16 {
17 ATH_MSG_ERROR("ChargedHadronSubtractionTool requires PFO inputs. It cannot operate on objects of type "
18 << m_inputType);
19 return StatusCode::FAILURE;
20 }
21 ATH_MSG_INFO("Running ChargedHadronSubtractionTool by-vertex: " << m_byVertex.value());
22 ATH_MSG_INFO("Running ChargedHadronSubtractionTool using TTVA: " << m_useTrackToVertexTool.value());
23
26
27 return StatusCode::SUCCESS;
28}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
SG::ReadHandleKey< jet::TrackVertexAssociation > m_trkVtxAssoc_key
Gaudi::Property< bool > m_useTrackToVertexTool
@ 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.

◆ matchByPrimaryVertex()

template<class T, class U>
StatusCode ChargedHadronSubtractionTool::matchByPrimaryVertex ( T & cont) const
private

Definition at line 184 of file ChargedHadronSubtractionTool.h.

185{
186 const static SG::AuxElement::Accessor<std::vector<unsigned>> matchingPVs("MatchingPVs");
187 const static SG::AuxElement::Accessor<std::vector<unsigned>> matchingPUSBs("MatchingPUsidebands");
188
189 // Retrieve Primary Vertices
191 if (!handle.isValid())
192 {
193 ATH_MSG_WARNING(" This event has no primary vertex container");
194 return StatusCode::FAILURE;
195 }
196
197 const xAOD::VertexContainer *pvtxs = handle.cptr();
198 if (pvtxs->empty())
199 {
200 ATH_MSG_WARNING(" Failed to retrieve valid primary vertex container");
201 return StatusCode::FAILURE;
202 }
203
204 // Use only one of TVA or PV
205 const jet::TrackVertexAssociation *trkVtxAssoc = nullptr;
207 {
208 auto handle = SG::makeHandle(m_trkVtxAssoc_key);
209 if (!handle.isValid())
210 {
211 ATH_MSG_ERROR("Can't retrieve TrackVertexAssociation : " << m_trkVtxAssoc_key.key());
212 return StatusCode::FAILURE;
213 }
214 trkVtxAssoc = handle.cptr();
215 }
216
217 for (U *ppfo : cont)
218 {
219 // Ignore neutral PFOs
220 if constexpr (std::is_same_v<U, xAOD::PFO>) {
221 if (std::abs(ppfo->charge()) < FLT_MIN)
222 continue;
223 } else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
224 if (!ppfo->isCharged())
225 continue;
226 }
227
228 // Get the track for this charged PFO
229 const xAOD::TrackParticle* ptrk = nullptr;
230
231 // Use different methods to get TrackParticle based on U
232 if constexpr (std::is_same_v<U, xAOD::PFO>) {
233 ptrk = ppfo->track(0);
234 } else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
235 ptrk = dynamic_cast<const xAOD::TrackParticle*>(ppfo->chargedObject(0));
236 }
237 if (ptrk == nullptr)
238 {
239 ATH_MSG_WARNING("Charged PFO with index " << ppfo->index() << " has no ID track!");
240 continue;
241 }
242
243 std::vector<unsigned> matchingVertexList;
244 std::vector<unsigned> matchingPUSBList;
245
246 if (trkVtxAssoc)
247 {
248 // Use TrackVertexAssociation
249 const xAOD::Vertex *thisTracksVertex = trkVtxAssoc->associatedVertex(ptrk);
250 if (thisTracksVertex == nullptr)
251 {
252 ATH_MSG_DEBUG("No vertex associated to track " << ptrk->index() << "! So it cannot be associated to the primary vertex");
253 }
254 else
255 {
256 matchingVertexList.push_back(thisTracksVertex->index());
257 for (const xAOD::Vertex *vtx : *pvtxs){
258 if (vtx != nullptr && vtx->vertexType() != xAOD::VxType::NoVtx)
259 {
260 float z0 = ptrk->z0() + ptrk->vz() - vtx->z();
261 float theta = ptrk->theta();
262
263 if (std::abs(z0 * sin(theta)) < 2.0 * m_z0sinThetaCutValue && std::abs(z0 * sin(theta)) >= m_z0sinThetaCutValue)
264 matchingPUSBList.push_back(vtx->index());
265 }
266 }
267 }
268 }
269 else{
270 // Use z0sinThetaCutValue
271 // Loop over the primary vertices to determine which ones potentially match
272 for (const xAOD::Vertex *vtx : *pvtxs)
273 {
274 bool matchedToVertex = false;
275 bool matchedToPileupSideband = false;
276
277 if (vtx == nullptr)
278 {
279 ATH_MSG_WARNING("Encountered a nullptr vertex when trying to match charged PFOs to vertices");
280 continue;
281 }
282 else if (vtx->vertexType() == xAOD::VxType::NoVtx)
283 { // No reconstructed vertices
284 matchedToVertex = true; // simply match all cPFOs in this case
285 }
286 else
287 { // Had a good reconstructed vertex
288 const double absZ0sinTheta = calcAbsZ0SinTheta(*ptrk, *vtx);
289 matchedToVertex = (absZ0sinTheta < m_z0sinThetaCutValue);
290 if (absZ0sinTheta < 2.0 * m_z0sinThetaCutValue && absZ0sinTheta >= m_z0sinThetaCutValue)
291 matchedToPileupSideband = true;
292 }
293
294 if (matchedToVertex)
295 matchingVertexList.push_back(vtx->index());
296 if (matchedToPileupSideband)
297 matchingPUSBList.push_back(vtx->index());
298 }
299 }
300
301 matchingPVs(*ppfo) = matchingVertexList;
302 matchingPUSBs(*ppfo) = matchingPUSBList;
303 }
304
305 return StatusCode::SUCCESS;
306}
static double calcAbsZ0SinTheta(const xAOD::TrackParticle &trk, const xAOD::Vertex &vtx)
Gaudi::Property< float > m_z0sinThetaCutValue
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
size_t index() const
Return the index of this element within its container.
const xAOD::Vertex * associatedVertex(const xAOD::TrackParticle *trk) const
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ matchToPrimaryVertex()

template<class T, class U>
StatusCode ChargedHadronSubtractionTool::matchToPrimaryVertex ( T & cont) const
private

Definition at line 65 of file ChargedHadronSubtractionTool.h.

66{
67 const static SG::AuxElement::Accessor<char> PVMatchedAcc("matchedToPV");
68 const static SG::AuxElement::Accessor<char> PUsidebandMatchedAcc("matchedToPUsideband");
69
70 // Use only one of TVA or PV
71 const jet::TrackVertexAssociation *trkVtxAssoc = nullptr;
72 const xAOD::Vertex *vtx = nullptr;
73 if (!m_ignoreVertex)
74 {
75 // In cosmics, there's no PV container so we need to avoid attempting
76 // to retrieve anything related to it
78 {
79 auto handle = SG::makeHandle(m_trkVtxAssoc_key);
80 if (!handle.isValid())
81 {
82 ATH_MSG_ERROR("Can't retrieve TrackVertexAssociation : " << m_trkVtxAssoc_key.key());
83 return StatusCode::FAILURE;
84 }
85 trkVtxAssoc = handle.cptr();
86 }
87 else
88 {
89 vtx = getPrimaryVertex();
90 if (vtx == nullptr)
91 {
92 ATH_MSG_ERROR("Primary vertex container was empty or no valid vertex found!");
93 return StatusCode::FAILURE;
94 }
95 else if (vtx->vertexType() == xAOD::VxType::NoVtx)
96 {
97 ATH_MSG_VERBOSE("No genuine primary vertex found. Will consider all PFOs matched.");
98 }
99 }
100 }
101
102 for (U *ppfo : cont)
103 {
104 // Ignore neutral PFOs
105 if constexpr (std::is_same_v<U, xAOD::PFO>) {
106 if (std::abs(ppfo->charge()) < FLT_MIN)
107 continue;
108 } else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
109 if (!ppfo->isCharged())
110 continue;
111 }
112
113 bool matchedToPrimaryVertex = false;
114 bool matchedToPileupSideband = false;
115 if (m_ignoreVertex)
116 {
117 // If we don't use vertex information, don't bother computing the decision
118 // Just pass every cPFO -- there shouldn't be many in cosmics!
119 matchedToPrimaryVertex = true;
120 }
121 else
122 {
123 const xAOD::TrackParticle* ptrk = nullptr;
124
125 // Use different methods to get TrackParticle based on U
126 if constexpr (std::is_same_v<U, xAOD::PFO>) {
127 ptrk = ppfo->track(0);
128 } else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
129 ptrk = dynamic_cast<const xAOD::TrackParticle*>(ppfo->chargedObject(0));
130 }
131 if (ptrk == nullptr)
132 {
133 ATH_MSG_WARNING("Charged PFO with index " << ppfo->index() << " has no ID track!");
134 continue;
135 }
136 if (trkVtxAssoc)
137 { // Use TrackVertexAssociation
138 const xAOD::Vertex *thisTracksVertex = trkVtxAssoc->associatedVertex(ptrk);
139 if (thisTracksVertex == nullptr)
140 {
141 ATH_MSG_DEBUG("No vertex associated to track " << ptrk->index() << "! So it cannot be associated to the primary vertex");
142 matchedToPrimaryVertex = false;
143 }
144 else
145 {
146 matchedToPrimaryVertex = (xAOD::VxType::PriVtx == thisTracksVertex->vertexType());
147
148 // r21 PU sideband definition (see below)
149 // needed for comparisons with new r22 definition (neutral only)
150 vtx = getPrimaryVertex();
151 if (vtx != nullptr && vtx->vertexType() != xAOD::VxType::NoVtx)
152 {
153 const double absZ0sinTheta = calcAbsZ0SinTheta(*ptrk, *vtx);
154 if (absZ0sinTheta < 2.0 * m_z0sinThetaCutValue && absZ0sinTheta >= m_z0sinThetaCutValue)
155 matchedToPileupSideband = true;
156 }
157 }
158 }
159 else
160 { // Use Primary Vertex
161 if (vtx->vertexType() == xAOD::VxType::NoVtx)
162 { // No reconstructed vertices
163 matchedToPrimaryVertex = true; // simply match all cPFOs in this case
164 }
165 else
166 { // Had a good reconstructed vertex.
167 // vtz.z() provides z of that vertex w.r.t the center of the beamspot (z = 0).
168 // Thus we correct the track z0 to be w.r.t z = 0
169 float z0 = ptrk->z0() + ptrk->vz() - vtx->z();
170 float theta = ptrk->theta();
171 matchedToPrimaryVertex = (std::abs(z0 * sin(theta)) < m_z0sinThetaCutValue);
172 if (std::abs(z0 * sin(theta)) < 2.0 * m_z0sinThetaCutValue && std::abs(z0 * sin(theta)) >= m_z0sinThetaCutValue)
173 matchedToPileupSideband = true;
174 }
175 } // TVA vs PV decision
176 }
177 PVMatchedAcc(*ppfo) = matchedToPrimaryVertex;
178 PUsidebandMatchedAcc(*ppfo) = matchedToPileupSideband;
179 }
180
181 return StatusCode::SUCCESS;
182}
#define ATH_MSG_VERBOSE(x)
const xAOD::Vertex * getPrimaryVertex() const
VxType::VertexType vertexType() const
The type of the vertex.

◆ 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 ChargedHadronSubtractionTool::process_impl ( xAOD::IParticleContainer * cont) const
privatevirtual

Reimplemented from JetConstituentModifierBase.

Definition at line 30 of file ChargedHadronSubtractionTool.cxx.

31{
32
33 // Type-checking happens in the JetConstituentModifierBase class
34 // so it is safe just to static_cast
36 {
37 xAOD::FlowElementContainer *feCont = static_cast<xAOD::FlowElementContainer *>(cont);
38
39 // Check that these FlowElements are actually PFOs; nothing else is supported
40 if (!feCont->empty() && !(feCont->front()->signalType() & xAOD::FlowElement::PFlow))
41 {
42 ATH_MSG_ERROR("This tool correctly recieved a FlowElement, but it wasn't a PFO!"
43 << " Signal type was " << feCont->front()->signalType());
44 return StatusCode::FAILURE;
45 }
46
48 }
49 xAOD::PFOContainer *pfoCont = static_cast<xAOD::PFOContainer *>(cont);
51}
signal_t signalType() const
FlowElementContainer_v1 FlowElementContainer
Definition of the current "pfo container version".
PFO_v1 PFO
Definition of the current "pfo version".
Definition PFO.h:17
PFOContainer_v1 PFOContainer
Definition of the current "pfo container version".
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16

◆ 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_byVertex

Gaudi::Property<bool> ChargedHadronSubtractionTool::m_byVertex = {this, "DoByVertex", false, "True if we should match to each primary vertex, not just PV0"}
private

Definition at line 53 of file ChargedHadronSubtractionTool.h.

53{this, "DoByVertex", false, "True if we should match to each primary vertex, not just PV0"};

◆ 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_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_ignoreVertex

Gaudi::Property<bool> ChargedHadronSubtractionTool::m_ignoreVertex = {this, "IgnoreVertex", false, "Dummy option for cosmics - accept everything"}
private

Definition at line 51 of file ChargedHadronSubtractionTool.h.

51{this, "IgnoreVertex", false, "Dummy option for cosmics - accept everything"};

◆ m_inputType

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

Definition at line 60 of file JetConstituentModifierBase.h.

◆ m_trkVtxAssoc_key

SG::ReadHandleKey<jet::TrackVertexAssociation> ChargedHadronSubtractionTool::m_trkVtxAssoc_key = {this, "TrackVertexAssociation", "JetTrackVtxAssoc", "key for the TrackVertexAssociation object"}
private

Definition at line 58 of file ChargedHadronSubtractionTool.h.

58{this, "TrackVertexAssociation", "JetTrackVtxAssoc", "key for the TrackVertexAssociation object"};

◆ m_useTrackToVertexTool

Gaudi::Property<bool> ChargedHadronSubtractionTool::m_useTrackToVertexTool = {this, "UseTrackToVertexTool", false, "True if we will use the track to vertex tool"}
private

Definition at line 50 of file ChargedHadronSubtractionTool.h.

50{this, "UseTrackToVertexTool", false, "True if we will use the track to vertex tool"};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vertexContainer_key

SG::ReadHandleKey<xAOD::VertexContainer> ChargedHadronSubtractionTool::m_vertexContainer_key = {this, "VertexContainerKey", "PrimaryVertices", "key for the primary vertex container"}
private

Definition at line 57 of file ChargedHadronSubtractionTool.h.

57{this, "VertexContainerKey", "PrimaryVertices", "key for the primary vertex container"};

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_z0sinThetaCutValue

Gaudi::Property<float> ChargedHadronSubtractionTool::m_z0sinThetaCutValue = {this, "Z0sinThetaCutValue", 2.0, "True if we will use the track to vertex tool"}
private

Definition at line 52 of file ChargedHadronSubtractionTool.h.

52{this, "Z0sinThetaCutValue", 2.0, "True if we will use the track to vertex tool"};

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