ATLAS Offline Software
Loading...
Searching...
No Matches
DeltaROverlapTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Primary include
7
8namespace ORUtils
9{
10
11 //---------------------------------------------------------------------------
12 // Constructor
13 //---------------------------------------------------------------------------
14 DeltaROverlapTool::DeltaROverlapTool(const std::string& name)
15 : BaseOverlapTool(name)
16 {
17 declareProperty("DR", m_dR = 0.4, "Maximum dR for overlap match");
18 declareProperty("UseRapidity", m_useRapidity = true,
19 "Calculate delta-R using rapidity");
20 declareProperty("SwapContainerPrecedence", m_swapContainerPrecedence = false,
21 "Use second container for flagging overlaps");
22 }
23
24 //---------------------------------------------------------------------------
25 // Initialize
26 //---------------------------------------------------------------------------
28 {
29 ATH_MSG_DEBUG("Setting up dR matching with cone size " << m_dR);
30
31 // Initialize the dR matcher
32 m_dRMatcher = std::make_unique<DeltaRMatcher>(m_dR, m_useRapidity);
33 if (m_objectType1.value() != 0 && m_objectType2.value() != 0) {
34 ATH_CHECK (m_dRMatcher->setObjectTypes (static_cast<xAODType::ObjectType>(m_objectType1.value()),
35 static_cast<xAODType::ObjectType>(m_objectType2.value())));
37 ATH_MSG_INFO("Object types not set, please set ObjectType1 and ObjectType2 properties");
38 }
39 addSubtool(*m_dRMatcher);
40 return StatusCode::SUCCESS;
41 }
42
43 //---------------------------------------------------------------------------
44 // Identify overlaps
45 //---------------------------------------------------------------------------
46 template<columnar::ContainerIdConcept CI1,columnar::RegularContainerIdConcept CI2,typename CM>
49 {
50 // Loop over surviving input objects
51 for(const auto testPar : testCont){
52 if(isSurvivingObject(testPar)){
53 for(const auto refPar : refCont){
54 if(isSurvivingObject(refPar)){
55 // Check for duplicates and overlap
56 if constexpr (CM::isXAOD) {
57 if(&testPar.getXAODObject() == &refPar.getXAODObject()) continue;
58 }
59 if(m_dRMatcher->objectsMatch(testPar, refPar)){
60 ATH_CHECK( handleOverlap(testPar, refPar) );
61 }
62 }
63 }
64 }
65 }
66 return StatusCode::SUCCESS;
67 }
68
69
73 columnar::EventContextId /*eventContext*/) const
74 {
75 ATH_MSG_DEBUG("Removing overlaps");
76
77 // Initialize output decoration if necessary
80
82 ATH_CHECK ( internalFindOverlaps(cont2, cont1) );
83 else
84 ATH_CHECK ( internalFindOverlaps(cont1, cont2) );
85 return StatusCode::SUCCESS;
86 }
87
88} // namespace ORUtils
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
void initializeDecorations(columnar::Particle1Range container) const
BaseOverlapTool(const std::string &name)
Create proper constructor for Athena.
StatusCode handleOverlap(const columnar::ObjectId< CI1, CM > &testParticle, const columnar::ObjectId< CI2, CM > &refParticle) const
Common helper method to handle an overlap result.
bool isSurvivingObject(columnar::Particle1Id obj) const
virtual StatusCode findOverlaps(columnar::Particle1Range cont1, columnar::Particle2Range cont2, columnar::EventContextId eventContext) const override
Identify overlaps with simple dR check.
bool m_useRapidity
Calculate delta-R using rapidity.
bool m_swapContainerPrecedence
In default configuration, the first container is the one that gets tested for object rejection.
std::unique_ptr< DeltaRMatcher > m_dRMatcher
Delta-R matcher.
virtual StatusCode initializeDerived() override
Initialize the tool.
Gaudi::Property< unsigned > m_objectType2
float m_dR
Delta-R cone for flagging objects as overlap.
StatusCode internalFindOverlaps(columnar::ObjectRange< CI1, CM > testCont, columnar::ObjectRange< CI2, CM > refCont) const
DeltaROverlapTool(const std::string &name)
Create proper constructor for Athena.
Gaudi::Property< unsigned > m_objectType1
a class representing a continuous sequence of objects (a.k.a. a container)
ObjectId< ContainerId::eventContext > EventContextId
ObjectRange< ContainerId::particle2 > Particle2Range
Definition ParticleDef.h:53
ObjectRange< ContainerId::particle1 > Particle1Range
Definition ParticleDef.h:47
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
static constexpr bool isXAOD
Whether this is the xAOD mode.
Definition ColumnarDef.h:20