ATLAS Offline Software
Loading...
Searching...
No Matches
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
10namespace 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
60 std::make_unique<OverlapDecorationHelper<columnar::ContainerId::particle1>>
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,
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
104 ATH_CHECK( removeOverlap(m_eleEleORT, electrons, electrons) );
105 // Tau-electron OR
107 // Tau-muon OR
109 // Electron-muon OR
110 ATH_CHECK( removeOverlap(m_eleMuORT, electrons, muons) );
111 // Pho-electron OR
112 ATH_CHECK( removeOverlap(m_phoEleORT, photons, electrons) );
113 // Pho-muon OR
114 ATH_CHECK( removeOverlap(m_phoMuORT, photons, muons) );
115 // Electron-jet OR
116 ATH_CHECK( removeOverlap(m_eleJetORT, electrons, jets) );
117 // Muon-jet OR
118 ATH_CHECK( removeOverlap(m_muJetORT, muons, jets) );
119 // Tau-jet OR
121 // Pho-jet OR
122 ATH_CHECK( removeOverlap(m_phoJetORT, jets, photons) );
123 // Electron-fatjet OR
124 ATH_CHECK( removeOverlap(m_eleFatJetORT, fatJets, electrons) );
125 // jet-fatjet OR
126 ATH_CHECK( removeOverlap(m_jetFatJetORT, jets, fatJets) );
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t taus
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< IOverlapTool > m_phoJetORT
Pho-jet overlap handle.
std::unique_ptr< OverlapDecorationHelper< columnar::ContainerId::particle1 > > m_decHelper
Helper used to reset decorations.
std::string m_inputLabel
Input object decoration which specifies which objects to look at.
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.
ToolHandle< IOverlapTool > m_phoEleORT
Pho-ele overlap handle.
ToolHandle< IOverlapTool > m_tauMuORT
Tau-mu overlap handle.
OverlapRemovalTool(const std::string &name)
Create a proper constructor for Athena.
ToolHandle< IOverlapTool > m_tauJetORT
Tau-jet overlap handle.
ToolHandle< IOverlapTool > m_eleMuORT
Ele-mu overlap handle.
ToolHandle< IOverlapTool > m_muJetORT
Mu-jet overlap handle.
bool m_outputPassValue
Toggle the output flag logic.
ToolHandle< IOverlapTool > m_eleEleORT
Ele-ele overlap handle.
bool m_requireExpectedPointers
Require non-null container pointers when expected; i.e., when corresponding overlap tools are configu...
StatusCode removeOverlap(const ToolHandle< IOverlapTool > &tool, const xAOD::IParticleContainer *cont1, const xAOD::IParticleContainer *cont2) const
Use one tool to remove overlaps.
ToolHandle< IOverlapTool > m_eleJetORT
Ele-jet overlap handle.
ToolHandle< IOverlapTool > m_tauEleORT
Tau-ele overlap handle.
std::string m_outputLabel
Output object decoration which specifies overlapping objects.
ToolHandle< IOverlapTool > m_jetFatJetORT
jet-fatjet overlap handle
virtual StatusCode initialize() override
Initialize the tool.
ToolHandle< IOverlapTool > m_phoMuORT
Pho-mu overlap handle.
ToolHandle< IOverlapTool > m_eleFatJetORT
ele-fatjet overlap handle
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.