ATLAS Offline Software
OverlapRemovalTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Local includes
8 
9 
10 namespace ORUtils
11 {
12 
13  //---------------------------------------------------------------------------
14  // Standard constructor
15  //---------------------------------------------------------------------------
17  : asg::AsgTool(name),
18  m_eleEleORT("", this),
19  m_eleMuORT("", this), m_eleJetORT("", this), m_muJetORT("", this),
20  m_tauEleORT("", this), m_tauMuORT("", this), m_tauJetORT("", this),
21  m_phoEleORT("", this), m_phoMuORT("", this), m_phoJetORT("", this),
22  m_eleFatJetORT("", this), m_jetFatJetORT("", this)
23  {
24  declareProperty("EleEleORT", m_eleEleORT, "Electron-electron overlap tool");
25  declareProperty("EleMuORT", m_eleMuORT, "Electron-muon overlap tool");
26  declareProperty("EleJetORT", m_eleJetORT, "Electron-jet overlap tool");
27  declareProperty("MuJetORT", m_muJetORT, "Muon-jet overlap tool");
28  declareProperty("TauEleORT", m_tauEleORT, "Tau-electron overlap tool");
29  declareProperty("TauMuORT", m_tauMuORT, "Tau-muon overlap tool");
30  declareProperty("TauJetORT", m_tauJetORT, "Tau-jet overlap tool");
31  declareProperty("PhoEleORT", m_phoEleORT, "Photon-electron overlap tool");
32  declareProperty("PhoMuORT", m_phoMuORT, "Photon-muon overlap tool");
33  declareProperty("PhoJetORT", m_phoJetORT, "Photon-jet overlap tool");
34  declareProperty("EleFatJetORT", m_eleFatJetORT, "electron-fatjet overlap tool");
35  declareProperty("JetFatJetORT", m_jetFatJetORT, "jet-fatjet overlap tool");
36 
37  // Input/output labels for reset functionality.
38  declareProperty("InputLabel", m_inputLabel = "selected",
39  "Decoration which specifies input objects");
40  declareProperty("OutputLabel", m_outputLabel = "overlaps",
41  "Decoration given to objects that fail OR");
42  declareProperty("OutputPassValue", m_outputPassValue = false,
43  "Set the result assigned to objects that pass");
44  declareProperty("RequireExpectedPointers", m_requireExpectedPointers = true,
45  "Require non-null container pointers when expected by config");
46  }
47 
48  //---------------------------------------------------------------------------
49  // Initialize the tool
50  //---------------------------------------------------------------------------
52  {
53  ATH_MSG_DEBUG("Initializing master tool " << name());
54  ATH_MSG_DEBUG("Master tool config: InputLabel " << m_inputLabel <<
55  " OutputLabel " << m_outputLabel <<
56  " OutputPassValue " << m_outputPassValue);
57 
58  // Initialize the decoration helper
59  m_decHelper =
60  std::make_unique<OverlapDecorationHelper>
62 
63  // Retrieve the configured tools
64  if(!m_eleEleORT.empty()) ATH_CHECK( m_eleEleORT.retrieve() );
65  if(!m_eleMuORT.empty()) ATH_CHECK( m_eleMuORT.retrieve() );
66  if(!m_eleJetORT.empty()) ATH_CHECK( m_eleJetORT.retrieve() );
67  if(!m_muJetORT.empty()) ATH_CHECK( m_muJetORT.retrieve() );
68  if(!m_tauEleORT.empty()) ATH_CHECK( m_tauEleORT.retrieve() );
69  if(!m_tauMuORT.empty()) ATH_CHECK( m_tauMuORT.retrieve() );
70  if(!m_tauJetORT.empty()) ATH_CHECK( m_tauJetORT.retrieve() );
71  if(!m_phoEleORT.empty()) ATH_CHECK( m_phoEleORT.retrieve() );
72  if(!m_phoMuORT.empty()) ATH_CHECK( m_phoMuORT.retrieve() );
73  if(!m_phoJetORT.empty()) ATH_CHECK( m_phoJetORT.retrieve() );
74  if(!m_eleFatJetORT.empty()) ATH_CHECK( m_eleFatJetORT.retrieve() );
75  if(!m_jetFatJetORT.empty()) ATH_CHECK( m_jetFatJetORT.retrieve() );
76 
77  return StatusCode::SUCCESS;
78  }
79 
80  //---------------------------------------------------------------------------
81  // Remove all overlapping objects according to the configured tools
82  //---------------------------------------------------------------------------
85  const xAOD::MuonContainer* muons,
86  const xAOD::JetContainer* jets,
87  const xAOD::TauJetContainer* taus,
88  const xAOD::PhotonContainer* photons,
89  const xAOD::JetContainer* fatJets) const
90  {
91  // Reset all decorations to passing
92  if(electrons) m_decHelper->resetDecorations(*electrons);
93  if(muons) m_decHelper->resetDecorations(*muons);
94  if(jets) m_decHelper->resetDecorations(*jets);
95  if(taus) m_decHelper->resetDecorations(*taus);
96  if(photons) m_decHelper->resetDecorations(*photons);
97  if(fatJets) m_decHelper->resetDecorations(*fatJets);
98 
99  // Following recommended removal sequence from harmonization note.
100  // NOTE: some details are still unspecific in the recommendations.
101  // Talk to me if this does not support your needs.
102 
103  // Electron-electron OR
105  // Tau-electron OR
107  // Tau-muon OR
108  ATH_CHECK( removeOverlap(m_tauMuORT, taus, muons) );
109  // Electron-muon OR
111  // Pho-electron OR
113  // Pho-muon OR
114  ATH_CHECK( removeOverlap(m_phoMuORT, photons, muons) );
115  // Electron-jet OR
117  // Muon-jet OR
119  // Tau-jet OR
121  // Pho-jet OR
122  ATH_CHECK( removeOverlap(m_phoJetORT, jets, photons) );
123  // Electron-fatjet OR
125  // jet-fatjet OR
127 
128  return StatusCode::SUCCESS;
129  }
130 
131  //---------------------------------------------------------------------------
132  // Perform overlap removal with one tool
133  //---------------------------------------------------------------------------
135  removeOverlap(const ToolHandle<IOverlapTool>& tool,
136  const xAOD::IParticleContainer* cont1,
137  const xAOD::IParticleContainer* cont2) const
138  {
139  if(!tool.empty()) {
140  if(cont1 && cont2) {
141  ATH_CHECK( tool->findOverlaps(*cont1, *cont2) );
142  }
143  else if(!cont1 && m_requireExpectedPointers) {
144  ATH_MSG_ERROR("First container pointer for " << tool.name() << " is NULL!");
145  return StatusCode::FAILURE;
146  }
147  else if(!cont2 && m_requireExpectedPointers) {
148  ATH_MSG_ERROR("Second container pointer for " << tool.name() << " is NULL!");
149  return StatusCode::FAILURE;
150  }
151  }
152  return StatusCode::SUCCESS;
153  }
154 
155 } // namespace ORUtils
ORUtils::OverlapRemovalTool::m_muJetORT
ToolHandle< IOverlapTool > m_muJetORT
Mu-jet overlap handle.
Definition: OverlapRemovalTool.h:103
ORUtils::OverlapRemovalTool::m_decHelper
std::unique_ptr< OverlapDecorationHelper > m_decHelper
Helper used to reset decorations.
Definition: OverlapRemovalTool.h:87
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ORUtils::OverlapRemovalTool::m_jetFatJetORT
ToolHandle< IOverlapTool > m_jetFatJetORT
jet-fatjet overlap handle
Definition: OverlapRemovalTool.h:127
ORUtils::OverlapRemovalTool::m_outputPassValue
bool m_outputPassValue
Toggle the output flag logic.
Definition: OverlapRemovalTool.h:76
ORUtils::OverlapRemovalTool::OverlapRemovalTool
OverlapRemovalTool(const std::string &name)
Create a proper constructor for Athena.
Definition: OverlapRemovalTool.cxx:16
asg
Definition: DataHandleTestTool.h:28
ORUtils
Definition: AltMuJetOverlapTool.h:20
ORUtils::OverlapRemovalTool::m_tauJetORT
ToolHandle< IOverlapTool > m_tauJetORT
Tau-jet overlap handle.
Definition: OverlapRemovalTool.h:112
ORUtils::OverlapRemovalTool::m_outputLabel
std::string m_outputLabel
Output object decoration which specifies overlapping objects.
Definition: OverlapRemovalTool.h:72
ORUtils::OverlapRemovalTool::m_phoJetORT
ToolHandle< IOverlapTool > m_phoJetORT
Pho-jet overlap handle.
Definition: OverlapRemovalTool.h:121
ORUtils::OverlapRemovalTool::m_tauMuORT
ToolHandle< IOverlapTool > m_tauMuORT
Tau-mu overlap handle.
Definition: OverlapRemovalTool.h:109
ORUtils::OverlapRemovalTool::m_inputLabel
std::string m_inputLabel
Input object decoration which specifies which objects to look at.
Definition: OverlapRemovalTool.h:70
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ORUtils::OverlapRemovalTool::m_phoMuORT
ToolHandle< IOverlapTool > m_phoMuORT
Pho-mu overlap handle.
Definition: OverlapRemovalTool.h:118
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
OverlapRemovalTool.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MacroChecks.h
ORUtils::OverlapRemovalTool::initialize
virtual StatusCode initialize() override
Initialize the tool.
Definition: OverlapRemovalTool.cxx:51
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
ORUtils::OverlapRemovalTool::m_eleEleORT
ToolHandle< IOverlapTool > m_eleEleORT
Ele-ele overlap handle.
Definition: OverlapRemovalTool.h:94
ORUtils::OverlapRemovalTool::m_requireExpectedPointers
bool m_requireExpectedPointers
Require non-null container pointers when expected; i.e., when corresponding overlap tools are configu...
Definition: OverlapRemovalTool.h:80
ORUtils::OverlapRemovalTool::removeOverlap
StatusCode removeOverlap(const ToolHandle< IOverlapTool > &tool, const xAOD::IParticleContainer *cont1, const xAOD::IParticleContainer *cont2) const
Use one tool to remove overlaps.
Definition: OverlapRemovalTool.cxx:135
ORUtils::OverlapRemovalTool::m_eleMuORT
ToolHandle< IOverlapTool > m_eleMuORT
Ele-mu overlap handle.
Definition: OverlapRemovalTool.h:97
ORUtils::OverlapRemovalTool::m_eleFatJetORT
ToolHandle< IOverlapTool > m_eleFatJetORT
ele-fatjet overlap handle
Definition: OverlapRemovalTool.h:124
ORUtils::OverlapRemovalTool::m_eleJetORT
ToolHandle< IOverlapTool > m_eleJetORT
Ele-jet overlap handle.
Definition: OverlapRemovalTool.h:100
ORUtils::OverlapRemovalTool::removeOverlaps
virtual StatusCode removeOverlaps(const xAOD::ElectronContainer *electrons, const xAOD::MuonContainer *muons, const xAOD::JetContainer *jets, const xAOD::TauJetContainer *taus=0, const xAOD::PhotonContainer *photons=0, const xAOD::JetContainer *fatJets=0) const override
Top-level method for performing full overlap-removal.
Definition: OverlapRemovalTool.cxx:84
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
ORUtils::OverlapRemovalTool::m_phoEleORT
ToolHandle< IOverlapTool > m_phoEleORT
Pho-ele overlap handle.
Definition: OverlapRemovalTool.h:115
ORUtils::OverlapRemovalTool::m_tauEleORT
ToolHandle< IOverlapTool > m_tauEleORT
Tau-ele overlap handle.
Definition: OverlapRemovalTool.h:106
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17