ATLAS Offline Software
TopOverlapRemovalCPTools.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 
7 #include <map>
8 #include <string>
9 
10 // Top includes
12 #include "TopEvent/EventTools.h"
13 
14 // PathResolver include(s):
16 
17 // Overlap removal includes:
20 
21 namespace top {
23  asg::AsgTool(name) {
24  declareProperty("config", m_config);
25  }
26 
28  ATH_MSG_INFO("top::OverlapRemovalCPTools initialize...");
29 
30  if (m_config->isTruthDxAOD()) {
31  ATH_MSG_INFO("top::OverlapRemovalCPTools: no need to initialise anything on truth DxAOD");
32  return StatusCode::SUCCESS;
33  }
34 
35  if (!m_config->makeAllCPTools()) {
36  ATH_MSG_INFO("top::OverlapRemovalCPTools: no need to initialise for mini-xAOD");
37  return StatusCode::SUCCESS;
38  }
39 
40  top::check(setupOverlapRemoval(), "Failed to setup Overlap Removal");
41  return StatusCode::SUCCESS;
42  }
43 
45  // Allowed overlap removal options
46  std::set<std::string> allowed_OR_procedures = {
47  "recommended", "jetmuApplyRelPt", "harmonized",
48  "Boosted", "BoostedSlidingDREl", "BoostedSlidingDRMu", "BoostedSlidingDRElMu", "noTauJetOLR", "noPhotonMuOR", "noPhotonMuOrJetOR"
49  };
50  std::string OR_procedure = m_config->overlapRemovalProcedure();
51 
52  float overlapRemovalSlidingInnerDRel = m_config->overlapRemovalSlidingInnerDRel();
53  float overlapRemovalSlidingInnerDRmu = m_config->overlapRemovalSlidingInnerDRmu();
54 
55  // if this is set, turns OFF ele-jet OR completely (it's taken care of by the electronInJetSubtraction tool)
56  bool applyElectronInJetSubtraction = m_config->applyElectronInJetSubtraction();
57 
58  // If the requested OR procedure is unknown then fail.
59  // This is mostly to avoid me writing 'harmonised' by mistake ;)
60  if (allowed_OR_procedures.find(OR_procedure)
61  == allowed_OR_procedures.end()) {
62  ATH_MSG_ERROR(OR_procedure << " is not a valid option.\n"
63  "Valid options are currently: "
64  "recommended [default], jetmuApplyRelPt, harmonized, "
65  "Boosted, BoostedSlidingDREl, BoostedSlidingDRMu, BoostedSlidingDRElMu, noTauJetOLR");
66  return StatusCode::FAILURE;
67  }
68 
69  ATH_MSG_INFO("Overlap removal procedure = " << OR_procedure);
70 
71  ORUtils::ORFlags OR_flags("OverlapRemovalTool",
72  "ORToolDecoration");
73 
74  OR_flags.doElectrons = m_config->useElectrons();
75  if(m_config->doEleEleOverlapRemoval()) OR_flags.doEleEleOR = true;
76  OR_flags.doMuons = m_config->useMuons();
77  OR_flags.doJets = m_config->useJets();
78  OR_flags.doTaus = m_config->useTaus();
79  OR_flags.doPhotons = m_config->usePhotons();
80  if (OR_procedure == "Boosted" ||
81  OR_procedure == "BoostedSlidingDREl" ||
82  OR_procedure == "BoostedSlidingDRMu" ||
83  OR_procedure == "BoostedSlidingDRElMu") {
84  OR_flags.boostedLeptons = true;
85  }
86  OR_flags.doFatJets = (m_config->useLargeRJets() && m_config->doLargeJetOverlapRemoval());
87 
88  const float floatMax = std::numeric_limits<float>::max();
89 
91  "Failed to setup OR Tool box");
92  for (auto&& tool : m_ORtoolBox.getOverlapTools()) {
93  top::check(tool->setProperty("EnableUserPriority", true),
94  "Failed to set EnableUserPriority");
95  }
96  if (OR_procedure == "harmonized") {
97  if (m_config->useMuons() &&
98  m_config->useElectrons()) top::check(m_ORtoolBox.eleMuORT.setProperty("RemoveCaloMuons", false),
99  "Failed to set RemoveCaloMuons in eleMuORT");
100  if (m_config->useMuons() && m_config->useJets()) {
101  top::check(m_ORtoolBox.muJetORT.setProperty("MuJetPtRatio", floatMax),
102  "Failed to set MuJetPtRatio in muJetORT");
103  top::check(m_ORtoolBox.muJetORT.setProperty("MuJetTrkPtRatio", floatMax),
104  "Failed to set MuJetTrkPtRatio in muJetORT");
105  top::check(m_ORtoolBox.muJetORT.setProperty("UseGhostAssociation", false),
106  "Failed to set UseGhostAssociation in muJetORT");
107  top::check(m_ORtoolBox.muJetORT.setProperty("InnerDR", 0.4),
108  "Failed to set InnerDR in muJetORT");
109  }
110  } else if (OR_procedure == "jetmuApplyRelPt") {
111  top::check(m_ORtoolBox.muJetORT.setProperty("ApplyRelPt", true),
112  "Failed to set ApplyRelPt in muJetORT");
113  } else if (OR_procedure == "BoostedSlidingDREl" ||
114  OR_procedure == "BoostedSlidingDRMu" ||
115  OR_procedure == "BoostedSlidingDRElMu") {
116  if (m_config->useElectrons() && m_config->useJets() &&
117  OR_procedure == "BoostedSlidingDREl") {
118  top::check(m_ORtoolBox.eleJetORT.setProperty("UseSlidingDR", true),
119  "Failed to setSliding DR in ElJetORT");
120  top::check(m_ORtoolBox.eleJetORT.setProperty("InnerDR", overlapRemovalSlidingInnerDRel),
121  "Failed to setting inner radius equal to SlidingInnerDRel in EleJetORT");
122  top::check(m_ORtoolBox.muJetORT.setProperty("UseSlidingDR", false),
123  "Failed to setSliding DR in MuJetORT");
124  }
125  if (m_config->useMuons() && m_config->useJets() &&
126  OR_procedure == "BoostedSlidingDRMu") {
127  top::check(m_ORtoolBox.eleJetORT.setProperty("UseSlidingDR", false),
128  "Failed to setSliding DR in ElJetORT");
129  top::check(m_ORtoolBox.muJetORT.setProperty("UseSlidingDR", true),
130  "Failed to setSliding DR in MuJetORT");
131  top::check(m_ORtoolBox.muJetORT.setProperty("InnerDR", overlapRemovalSlidingInnerDRmu),
132  "Failed to setting inner radius equal to SlidingInnerDRmu in MuJetORT");
133  }
134  if (m_config->useElectrons() && m_config->useMuons() && m_config->useJets() &&
135  OR_procedure == "BoostedSlidingDRElMu") {
136  top::check(m_ORtoolBox.eleJetORT.setProperty("UseSlidingDR", true),
137  "Failed to setSliding DR in ElJetORT");
138  top::check(m_ORtoolBox.eleJetORT.setProperty("InnerDR", overlapRemovalSlidingInnerDRel),
139  "Failed to setting inner radius equal to SlidingInnerDRel in EleJetORT");
140  top::check(m_ORtoolBox.muJetORT.setProperty("UseSlidingDR", true),
141  "Failed to setSliding DR in MuJetORT");
142  top::check(m_ORtoolBox.muJetORT.setProperty("InnerDR", overlapRemovalSlidingInnerDRmu),
143  "Failed to setting inner radius equal to SlidingInnerDRmu in MuJetORT");
144  }
145  } else if (OR_procedure == "noTauJetOLR") {
147  "Failed to set DR in TauJetORT to zero");
148  } else if (OR_procedure == "noPhotonMuOR") {
150  "Failed to set DR in phoMuonORT to zero");
151  } else if (OR_procedure == "noPhotonMuOrJetOR") {
153  "Failed to set DR in phoMuonORT to zero");
155  "Failed to set DR in phoJetORT to zero");
156  }
157 
158  if (applyElectronInJetSubtraction) {
159  top::check(m_ORtoolBox.eleJetORT.setProperty("UseSlidingDR", true),
160  "Failed to setSliding DR in ElJetORT");
162  "Failed to setting inner radius equal to SlidingInnerDRel in EleJetORT");
163  top::check(m_ORtoolBox.eleJetORT.setProperty("SlidingDRC1", 0),
164  "Failed to set SlidingDRC1");
165  top::check(m_ORtoolBox.eleJetORT.setProperty("SlidingDRC2", 0),
166  "Failed to set SlidingDRC2");
167  top::check(m_ORtoolBox.eleJetORT.setProperty("SlidingDRMaxCone", 0),
168  "Failed to set SlidingDRMaxCone");
169  }
170 
172  "Failed to initialize overlap removal tools");
174 
175  OR_flags.masterName = "OverlapRemovalToolLoose";
176  OR_flags.inputLabel = "ORToolDecorationLoose";
177 
179  "Failed to setup OR Tool box");
180  for (auto&& tool : m_ORtoolBox_Loose.getOverlapTools()) {
181  top::check(tool->setProperty("EnableUserPriority", true),
182  "Failed to set EnableUserPriority");
183  }
184  if (OR_procedure == "harmonized") {
185  if (m_config->useMuons() && m_config->useElectrons())
187  false),
188  "Failed to set RemoveCaloMuons in eleMuORT");
189  if (m_config->useMuons() && m_config->useJets()) {
190  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("MuJetPtRatio", floatMax),
191  "Failed to set MuJetPtRatio in muJetORT");
192  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("MuJetTrkPtRatio", floatMax),
193  "Failed to set MuJetTrkPtRatio in muJetORT");
194  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("UseGhostAssociation", false),
195  "Failed to set UseGhostAssociation in muJetORT");
197  "Failed to set InnerDR in muJetORT");
198  }
199  } else if (OR_procedure == "jetmuApplyRelPt") {
200  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("ApplyRelPt", false),
201  "Failed to set ApplyRelPt in muJetORT");
202  } else if (OR_procedure == "BoostedSlidingDREl" ||
203  OR_procedure == "BoostedSlidingDRMu" ||
204  OR_procedure == "BoostedSlidingDRElMu") {
205  if (m_config->useElectrons() && m_config->useJets() &&
206  OR_procedure == "BoostedSlidingDREl") {
207  top::check(m_ORtoolBox_Loose.eleJetORT.setProperty("UseSlidingDR", true),
208  "Failed to setSliding DR in ElJetORT");
209  top::check(m_ORtoolBox_Loose.eleJetORT.setProperty("InnerDR", overlapRemovalSlidingInnerDRel),
210  "Failed to setting inner radius equal to SlidingInnerDRel in EleJetORT");
211  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("UseSlidingDR", false),
212  "Failed to setSliding DR in MuJetORT");
213  }
214  if (m_config->useMuons() && m_config->useJets() &&
215  OR_procedure == "BoostedSlidingDRMu") {
216  top::check(m_ORtoolBox_Loose.eleJetORT.setProperty("UseSlidingDR", false),
217  "Failed to setSliding DR in ElJetORT");
218  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("UseSlidingDR", true),
219  "Failed to setSliding DR in MuJetORT");
220  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("InnerDR", overlapRemovalSlidingInnerDRmu),
221  "Failed to setting inner radius equal to SlidingInnerDRmu in MuJetORT");
222  }
223  if (m_config->useElectrons() && m_config->useMuons() && m_config->useJets() &&
224  OR_procedure == "BoostedSlidingDRElMu") {
225  top::check(m_ORtoolBox_Loose.eleJetORT.setProperty("UseSlidingDR", true),
226  "Failed to setSliding DR in ElJetORT");
227  top::check(m_ORtoolBox_Loose.eleJetORT.setProperty("InnerDR", overlapRemovalSlidingInnerDRel),
228  "Failed to setting inner radius equal to SlidingInnerDRel in EleJetORT");
229  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("UseSlidingDR", true),
230  "Failed to setSliding DR in MuJetORT");
231  top::check(m_ORtoolBox_Loose.muJetORT.setProperty("InnerDR", overlapRemovalSlidingInnerDRmu),
232  "Failed to setting inner radius equal to SlidingInnerDRmu in MuJetORT");
233  }
234  } else if (OR_procedure == "noTauJetOLR") {
236  "Failed to set DR in TauJetORT to zero");
237  } else if (OR_procedure == "noPhotonMuOR") {
239  "Failed to set DR in phoMuonORT to zero");
240  } else if (OR_procedure == "noPhotonMuOrJetOR") {
242  "Failed to set DR in phoMuonORT to zero");
244  "Failed to set DR in phoJetORT to zero");
245  }
246 
247  if (applyElectronInJetSubtraction) {
248  top::check(m_ORtoolBox_Loose.eleJetORT.setProperty("UseSlidingDR", true),
249  "Failed to setSliding DR in ElJetORT");
251  "Failed to setting inner radius equal to SlidingInnerDRel in EleJetORT");
253  "Failed to set SlidingDRC1");
255  "Failed to set SlidingDRC2");
256  top::check(m_ORtoolBox_Loose.eleJetORT.setProperty("SlidingDRMaxCone", 0),
257  "Failed to set SlidingDRMaxCone");
258  }
259 
261  "Failed to initialize loose overlap removal tools");
263 
264  ATH_MSG_INFO("Setting up special OR tools for soft muons");
265  ORUtils::ORFlags OR_flags_sm_Alljets("OverlapRemovalTool_softMuons_Alljets","ORToolDecoration", "AT_fail_softMuons_OR_Alljets");
266  OR_flags_sm_Alljets.doElectrons = false;
267  OR_flags_sm_Alljets.doMuons = true;
268  OR_flags_sm_Alljets.doJets = true;
269  OR_flags_sm_Alljets.doTaus = false;
270  OR_flags_sm_Alljets.doPhotons = false;
271  OR_flags_sm_Alljets.boostedLeptons = false;
272  OR_flags_sm_Alljets.doFatJets = false;
273 
274  top::check(ORUtils::recommendedTools(OR_flags_sm_Alljets, m_ORtoolBox_softMuons_Alljets), "Failed to setup OR Tool box for soft muons-Alljets");
276  top::check(tool->setProperty("EnableUserPriority", true), "Failed to set EnableUserPriority");
277  }
278  top::check(m_ORtoolBox_softMuons_Alljets.initialize(),"Failed to initialize soft muons overlap removal tools");
280 
281  return StatusCode::SUCCESS;
282  }
283 } // namespace top
ORUtils::ORFlags::boostedLeptons
bool boostedLeptons
Activate boosted-lepton recommendations (sliding dR cones)
Definition: OverlapRemovalInit.h:48
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
max
#define max(a, b)
Definition: cfImp.cxx:41
ORUtils::ToolBox::eleMuORT
OverlapHandle_t eleMuORT
Definition: ToolBox.h:70
TopOverlapRemovalCPTools.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
top::OverlapRemovalCPTools::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: TopOverlapRemovalCPTools.cxx:27
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ORUtils::ORFlags::doEleEleOR
bool doEleEleOR
Do electron-electron overlap.
Definition: OverlapRemovalInit.h:55
top::OverlapRemovalCPTools::m_overlapRemovalTool
asg::AnaToolHandle< ORUtils::IOverlapRemovalTool > m_overlapRemovalTool
Definition: TopOverlapRemovalCPTools.h:37
ORUtils::ORFlags::doPhotons
bool doPhotons
Definition: OverlapRemovalInit.h:63
ORUtils::recommendedTools
StatusCode recommendedTools(const ORFlags &flags, ToolBox &toolBox)
Pre-configured standard recommended OR tools.
Definition: OverlapRemovalInit.cxx:50
asg
Definition: DataHandleTestTool.h:28
ORUtils::ORFlags::doElectrons
bool doElectrons
Definition: OverlapRemovalInit.h:59
ORUtils::ORFlags::doFatJets
bool doFatJets
Definition: OverlapRemovalInit.h:64
asg::AnaToolHandle::setProperty
StatusCode setProperty(const std::string &property, const T2 &value)
set the given property of the tool.
top::OverlapRemovalCPTools::setupOverlapRemoval
StatusCode setupOverlapRemoval()
Definition: TopOverlapRemovalCPTools.cxx:44
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
ORUtils::ToolBox::muJetORT
OverlapHandle_t muJetORT
Definition: ToolBox.h:72
ORUtils::ToolBox::eleJetORT
OverlapHandle_t eleJetORT
Definition: ToolBox.h:71
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ORUtils::ToolBox::getOverlapTools
std::vector< OverlapHandle_t * > getOverlapTools()
Get a list of all handles to loop over.
Definition: ToolBox.cxx:71
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
top::OverlapRemovalCPTools::m_overlapRemovalTool_softMuons_Alljets
asg::AnaToolHandle< ORUtils::IOverlapRemovalTool > m_overlapRemovalTool_softMuons_Alljets
Definition: TopOverlapRemovalCPTools.h:39
ORUtils::ToolBox::initialize
StatusCode initialize()
Attach and initialize all tools.
Definition: ToolBox.cxx:35
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
OverlapRemovalTool.h
ORUtils::ToolBox::tauJetORT
OverlapHandle_t tauJetORT
Definition: ToolBox.h:75
top::OverlapRemovalCPTools::m_ORtoolBox_softMuons_Alljets
ORUtils::ToolBox m_ORtoolBox_softMuons_Alljets
Definition: TopOverlapRemovalCPTools.h:36
top::OverlapRemovalCPTools::m_ORtoolBox
ORUtils::ToolBox m_ORtoolBox
Definition: TopOverlapRemovalCPTools.h:34
ORUtils::ORFlags::doTaus
bool doTaus
Definition: OverlapRemovalInit.h:62
top::OverlapRemovalCPTools::m_config
std::shared_ptr< top::TopConfig > m_config
Definition: TopOverlapRemovalCPTools.h:32
top::OverlapRemovalCPTools::m_ORtoolBox_Loose
ORUtils::ToolBox m_ORtoolBox_Loose
Definition: TopOverlapRemovalCPTools.h:35
ORUtils::ToolBox::phoMuORT
OverlapHandle_t phoMuORT
Definition: ToolBox.h:77
PathResolver.h
top::OverlapRemovalCPTools::m_overlapRemovalTool_Loose
asg::AnaToolHandle< ORUtils::IOverlapRemovalTool > m_overlapRemovalTool_Loose
Definition: TopOverlapRemovalCPTools.h:38
OverlapRemovalInit.h
Defines helper functions for initializing the OR tools in C++.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
TopConfig.h
ORUtils::ToolBox::masterTool
MasterHandle_t masterTool
Master overlap removal tool handle.
Definition: ToolBox.h:64
top::OverlapRemovalCPTools::OverlapRemovalCPTools
OverlapRemovalCPTools(const std::string &name)
Definition: TopOverlapRemovalCPTools.cxx:22
ORUtils::ORFlags
A struct of global config options used to simplify the config helper interface.
Definition: OverlapRemovalInit.h:29
ORUtils::ORFlags::masterName
std::string masterName
Master tool name.
Definition: OverlapRemovalInit.h:36
ORUtils::ToolBox::phoJetORT
OverlapHandle_t phoJetORT
Definition: ToolBox.h:78
ORUtils::ORFlags::doMuons
bool doMuons
Definition: OverlapRemovalInit.h:60
ORUtils::ORFlags::doJets
bool doJets
Definition: OverlapRemovalInit.h:61
ORUtils::ORFlags::inputLabel
std::string inputLabel
Input object decoration.
Definition: OverlapRemovalInit.h:38