ATLAS Offline Software
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 
8 namespace ORUtils
9 {
10 
11  //---------------------------------------------------------------------------
12  // Constructor
13  //---------------------------------------------------------------------------
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  return StatusCode::SUCCESS;
34  }
35 
36  //---------------------------------------------------------------------------
37  // Identify overlaps
38  //---------------------------------------------------------------------------
41  const xAOD::IParticleContainer& cont2) const
42  {
43  ATH_MSG_DEBUG("Removing overlaps");
44 
45  // Initialize output decoration if necessary
46  m_decHelper->initializeDecorations(cont1);
47  m_decHelper->initializeDecorations(cont2);
48 
49  // Reference container is the one given precedence
50  const auto& refCont = m_swapContainerPrecedence? cont1 : cont2;
51  // Test container is the one flagged with overlaps
52  const auto& testCont = m_swapContainerPrecedence? cont2 : cont1;
53 
54  // Loop over surviving input objects
55  for(const auto testPar : testCont){
56  if(m_decHelper->isSurvivingObject(*testPar)){
57  for(const auto refPar : refCont){
58  if(m_decHelper->isSurvivingObject(*refPar)){
59  // Check for duplicates and overlap
60  if(testPar != refPar && m_dRMatcher->objectsMatch(*testPar, *refPar)){
61  ATH_CHECK( handleOverlap(testPar, refPar) );
62  }
63  }
64  }
65  }
66  }
67  return StatusCode::SUCCESS;
68  }
69 
70 } // namespace ORUtils
ORUtils::DeltaROverlapTool::m_useRapidity
bool m_useRapidity
Calculate delta-R using rapidity.
Definition: DeltaROverlapTool.h:55
ORUtils::DeltaROverlapTool::m_dRMatcher
std::unique_ptr< DeltaRMatcher > m_dRMatcher
Delta-R matcher.
Definition: DeltaROverlapTool.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ORUtils
Definition: AltMuJetOverlapTool.h:20
ORUtils::DeltaROverlapTool::findOverlaps
virtual StatusCode findOverlaps(const xAOD::IParticleContainer &cont1, const xAOD::IParticleContainer &cont2) const override
Identify overlaps with simple dR check.
Definition: DeltaROverlapTool.cxx:40
ORUtils::BaseOverlapTool
Common base class tool for overlap tools.
Definition: BaseOverlapTool.h:38
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ORUtils::DeltaROverlapTool::m_swapContainerPrecedence
bool m_swapContainerPrecedence
In default configuration, the first container is the one that gets tested for object rejection.
Definition: DeltaROverlapTool.h:62
ORUtils::BaseOverlapTool::m_decHelper
std::unique_ptr< OverlapDecorationHelper > m_decHelper
Helper for handling input/output decorations.
Definition: BaseOverlapTool.h:95
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DeltaROverlapTool.h
ORUtils::BaseOverlapTool::handleOverlap
virtual StatusCode handleOverlap(const xAOD::IParticle *testParticle, const xAOD::IParticle *refParticle) const
Common helper method to handle an overlap result.
Definition: BaseOverlapTool.cxx:64
ORUtils::DeltaROverlapTool::initializeDerived
virtual StatusCode initializeDerived() override
Initialize the tool.
Definition: DeltaROverlapTool.cxx:27
ORUtils::DeltaROverlapTool::DeltaROverlapTool
DeltaROverlapTool(const std::string &name)
Create proper constructor for Athena.
Definition: DeltaROverlapTool.cxx:14
ORUtils::DeltaROverlapTool::m_dR
float m_dR
Delta-R cone for flagging objects as overlap.
Definition: DeltaROverlapTool.h:53