ATLAS Offline Software
Loading...
Searching...
No Matches
BaseOverlapTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ASSOCIATIONUTILS_BASEOVERLAPTOOL_H
6#define ASSOCIATIONUTILS_BASEOVERLAPTOOL_H
7
8// System includes
9#include <string>
10#include <memory>
11
12// Framework includes
13#include "AsgTools/AsgTool.h"
14
15// EDM includes
16#include "xAODBase/IParticle.h"
17
18// Columnar includes
22
23// Local includes
27
28namespace ORUtils
29{
30
43 class BaseOverlapTool : public asg::AsgTool, public columnar::ColumnarTool<>, virtual public IOverlapTool
44 {
45
48
49 public:
50
52 BaseOverlapTool(const std::string& name);
53
57 StatusCode initialize() override final;
58
60 virtual void callEvents (columnar::EventContextRange events) const override;
61
62 protected:
63
66 virtual StatusCode initializeDerived()
67 { return StatusCode::SUCCESS; }
68
76 template<columnar::RegularContainerIdConcept CI1,columnar::RegularContainerIdConcept CI2,typename CM>
77 StatusCode handleOverlap(const columnar::ObjectId<CI1,CM>& testParticle,
78 const columnar::ObjectId<CI2,CM>& refParticle) const;
79
80
82 template<typename XAODContainer,columnar::RegularContainerIdConcept CI,typename CM>
83 StatusCode checkForXAODContainer(columnar::ObjectRange<CI,CM> cont, std::string_view message) const
84 {
85 if constexpr (CM::isXAOD) {
86 if(typeid(cont.getXAODObjectNoexcept()) != typeid(XAODContainer) &&
87 typeid(cont.getXAODObjectNoexcept()) != typeid(ConstDataVector<XAODContainer>)) {
88 ATH_MSG_ERROR(message);
89 return StatusCode::FAILURE;
90 }
91 }
92 return StatusCode::SUCCESS;
93 }
94
97
99 std::string m_inputLabel;
101 std::string m_outputLabel;
102
106
109
112
114
115 protected:
118
125 std::unique_ptr<BaseAccessors> m_baseAccessors {std::make_unique<BaseAccessors> (this)};
126
128 std::unique_ptr<OverlapDecorationHelper<columnar::ContainerId::particle1>> m_decHelper1;
129 std::unique_ptr<OverlapDecorationHelper<columnar::ContainerId::particle2>> m_decHelper2;
130
132 std::unique_ptr<OverlapLinkHelper<columnar::ContainerId::particle1>> m_objLinkHelper1;
133 std::unique_ptr<OverlapLinkHelper<columnar::ContainerId::particle2>> m_objLinkHelper2;
134
136
137
138 protected:
141
146 [[nodiscard]] char getObjectPriority(columnar::Particle1Id obj) const {
147 return m_decHelper1->getObjectPriority (obj); }
148 [[nodiscard]] char getObjectPriority(columnar::Particle2Id obj) const {
149 return m_decHelper2->getObjectPriority (obj); }
150 [[nodiscard]] bool isSurvivingObject(columnar::Particle1Id obj) const {
151 return m_decHelper1->isSurvivingObject (obj);}
152 [[nodiscard]] bool isSurvivingObject(columnar::Particle2Id obj) const {
153 return m_decHelper2->isSurvivingObject (obj);}
154 [[nodiscard]] bool isRejectedObject(columnar::Particle1Id obj) const {
155 return m_decHelper1->isRejectedObject (obj); }
156 [[nodiscard]] bool isRejectedObject(columnar::Particle2Id obj) const {
157 return m_decHelper2->isRejectedObject (obj); }
159 m_decHelper1->setObjectFail (obj); }
161 m_decHelper2->setObjectFail (obj); }
162 template<columnar::ContainerIdConcept CI>
164 return m_objLinkHelper1->addObjectLink (p1, p2); }
165 template<columnar::ContainerIdConcept CI>
167 return m_objLinkHelper2->addObjectLink (p1, p2); }
168
170
171 }; // class BaseOverlapTool
172
173 //---------------------------------------------------------------------------
174 // Handle overlap condition
175 //---------------------------------------------------------------------------
176 template<columnar::RegularContainerIdConcept CI1,columnar::RegularContainerIdConcept CI2,typename CM>
177 StatusCode BaseOverlapTool ::
178 handleOverlap(const columnar::ObjectId<CI1,CM>& testParticle,
179 const columnar::ObjectId<CI2,CM>& refParticle) const
180 {
181 // Apply user-priority override
182 if(!m_enableUserPrio ||
183 getObjectPriority(testParticle) <=
184 getObjectPriority(refParticle))
185 {
186 if constexpr (CM::isXAOD)
187 {
189 const float invGeV = 1e-3;
190 ATH_MSG_DEBUG(" Found overlap " << testParticle.getXAODObject().type() <<
191 " pt " << testParticle.getXAODObject().pt()*invGeV);
192 } else
193 {
194 ATH_MSG_DEBUG(" Found overlap " << testParticle);
195 }
196 setObjectFail(testParticle);
198 ATH_CHECK( addObjectLink(testParticle, refParticle) );
199 }
200 }
201 return StatusCode::SUCCESS;
202 }
203
204
205} // namespace ORUtils
206
207#endif
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
constexpr float invGeV
DataVector adapter that acts like it holds const pointers.
std::unique_ptr< OverlapDecorationHelper< columnar::ContainerId::particle1 > > m_decHelper1
Helper for handling input/output decorations.
void initializeDecorations(columnar::Particle2Range container) const
std::string m_inputLabel
Input object decoration which specifies which objects to look at.
StatusCode addObjectLink(columnar::Particle1Id p1, columnar::ObjectId< CI > p2) const
bool isSurvivingObject(columnar::Particle2Id obj) const
char getObjectPriority(columnar::Particle1Id obj) const
void setObjectFail(columnar::Particle2Id obj) const
void initializeDecorations(columnar::Particle1Range container) const
BaseOverlapTool(const std::string &name)
Create proper constructor for Athena.
virtual StatusCode initializeDerived()
Initialization for derived tools.
bool isRejectedObject(columnar::Particle2Id obj) const
StatusCode initialize() override final
Initialize base class functionality.
bool m_outputPassValue
Toggle the output flag logic.
StatusCode handleOverlap(const columnar::ObjectId< CI1, CM > &testParticle, const columnar::ObjectId< CI2, CM > &refParticle) const
Common helper method to handle an overlap result.
bool isRejectedObject(columnar::Particle1Id obj) const
StatusCode addObjectLink(columnar::Particle2Id p1, columnar::ObjectId< CI > p2) const
bool m_enableUserPrio
Enable user-priority scoring.
virtual void callEvents(columnar::EventContextRange events) const override
The callEvents() for columnar tools.
void setObjectFail(columnar::Particle1Id obj) const
bool isSurvivingObject(columnar::Particle1Id obj) const
std::unique_ptr< OverlapDecorationHelper< columnar::ContainerId::particle2 > > m_decHelper2
std::unique_ptr< OverlapLinkHelper< columnar::ContainerId::particle2 > > m_objLinkHelper2
std::string m_outputLabel
Output object decoration which specifies overlapping objects.
char getObjectPriority(columnar::Particle2Id obj) const
std::unique_ptr< OverlapLinkHelper< columnar::ContainerId::particle1 > > m_objLinkHelper1
Helper for linking overlap objects.
bool m_linkOverlapObjects
Flag to toggle overlap object links.
StatusCode checkForXAODContainer(columnar::ObjectRange< CI, CM > cont, std::string_view message) const
check whether the container is of the right type
std::unique_ptr< BaseAccessors > m_baseAccessors
Interface class for overlap removal tools.
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
Base class for the dual-use tool interface classes.
Definition IAsgTool.h:41
the base class for all columnar components
a class representing a single object (electron, muons, etc.)
a class representing a continuous sequence of objects (a.k.a. a container)
ObjectId< ContainerId::particle1 > Particle1Id
Definition ParticleDef.h:48
ObjectId< ContainerId::particle2 > Particle2Id
Definition ParticleDef.h:54
ObjectRange< ContainerId::eventContext > EventContextRange
AccessorTemplate< ContainerId::particle2, CT, ColumnAccessMode::input, CM > Particle2Accessor
Definition ParticleDef.h:56
ObjectRange< ContainerId::particle2 > Particle2Range
Definition ParticleDef.h:53
ObjectRange< ContainerId::particle1 > Particle1Range
Definition ParticleDef.h:47
AccessorTemplate< ContainerId::particle1, CT, ColumnAccessMode::input, CM > Particle1Accessor
Definition ParticleDef.h:50
columnar::Particle2Accessor< columnar::ObjectColumn > m_particles2Acc
columnar::Particle1Accessor< columnar::ObjectColumn > m_particles1Acc