ATLAS Offline Software
TopIsolationCPTools.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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 // Isolation include(s):
20 
21 namespace top {
23  asg::AsgTool(name),
24  m_isolationCalibFile("IsolationSelection/v1/MC15_Z_Jpsi_cutMap.root") {
25  declareProperty("config", m_config);
26 
27  declareProperty("IsolationCorrectionTool", m_isolationCorr);
28  }
29 
31  ATH_MSG_INFO("top::IsolationCPTools initialize...");
32 
33  if (!m_config->makeAllCPTools()) {
34  ATH_MSG_INFO("top::IsolationCPTools: no need to initialise for mini-xAOD");
35  return StatusCode::SUCCESS;
36  }
37 
38  if (!m_config->useElectrons() && !m_config->useMuons()) {
39  ATH_MSG_INFO("top::IsolationCPTools: no need to initialise since neither using electrons nor muons");
40  return StatusCode::SUCCESS;
41  }
42  top::check(setupIsolation(), "Failed to setup Isolation tools");
43  return StatusCode::SUCCESS;
44  }
45 
47  // needed both for electrons and photons to apply the leakage correction,
48  // [http://cern.ch/go/j6Lx]
49  std::string iso_corr_tool_name = "IsolationCorrectionTool";
50  if (asg::ToolStore::contains<CP::IIsolationCorrectionTool>(iso_corr_tool_name)) {
51  m_isolationCorr = asg::ToolStore::get<CP::IIsolationCorrectionTool>(iso_corr_tool_name);
52  } else {
53  CP::IIsolationCorrectionTool* isolationCorr = new CP::IsolationCorrectionTool(iso_corr_tool_name);
54  top::check(asg::setProperty(isolationCorr, "IsMC", m_config->isMC()),
55  "Failed to setProperty IsMC"); // if MC, else false
56  top::check(asg::setProperty(isolationCorr, "AFII_corr", m_config->isAFII()),
57  "Failed to setProperty AFII_corr"); // if AFII, else false
58  if (m_config->useEgammaLeakageCorrection()) {
59  top::check(asg::setProperty(isolationCorr, "Apply_SC_leakcorr", true),
60  "Failed to setProperty Apply_SC_leakcorr"); // super cluster based core correction
61  top::check(asg::setProperty(isolationCorr, "Apply_etaEDParPU_correction", true),
62  "Failed to setProperty Apply_etaEDParPU_correction"); // improved energy density based pileup
63  // correction with eta variations
64  top::check(asg::setProperty(isolationCorr, "Apply_etaEDPar_mc_correction", m_config->isMC()),
65  "Failed to setProperty Apply_etaEDPar_mc_correction"); // pileup dependent correction to MC
66  }
67  top::check(isolationCorr->initialize(), "Failed to initialize");
68 
69  m_isolationCorr = isolationCorr;
70  }
71 
72  top::check(setupPerObjectWPs(m_config->electronIsolationWPs(), "ElectronWP"), "Failed to initialize electron isolation CP tools");
73  top::check(setupPerObjectWPs(m_config->muonIsolationWPs(), "MuonWP"), "Failed to initialize muon isolation CP tools");
74  top::check(setupPerObjectWPs(m_config->photonIsolationWPs(), "PhotonWP"), "Failed to initialize photon isolation CP tools");
75 
76  return StatusCode::SUCCESS;
77  }
78 
79  StatusCode IsolationCPTools::setupPerObjectWPs(const std::vector<std::string>& WPs, const std::string& objectWPtype) {
80  for (const std::string& isoWP : WPs) {
81  std::string tool_name = "IsolationTool_" + objectWPtype + "_" + isoWP;
82  ATH_MSG_INFO("Initializing isolation tool: " << tool_name);
83  if (!asg::ToolStore::contains<CP::IIsolationSelectionTool>(tool_name)) {
85  top::check(asg::setProperty(iso_tool, "CalibFileName", m_isolationCalibFile),
86  "Failed to set CalibFileName for " + tool_name);
87  top::check(asg::setProperty(iso_tool, objectWPtype, isoWP),
88  "Failed to set " + objectWPtype + " for " + tool_name);
89  top::check(iso_tool->initialize(), "Failed to initialize " + tool_name);
90  m_isolationTools.push_back(iso_tool);
91  }
92  }
93  return StatusCode::SUCCESS;
94  }
95 } // namespace top
top::IsolationCPTools::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: TopIsolationCPTools.cxx:30
CP::IIsolationCorrectionTool::initialize
virtual StatusCode initialize()=0
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
top::IsolationCPTools::m_isolationCalibFile
std::string m_isolationCalibFile
Definition: TopIsolationCPTools.h:34
asg
Definition: DataHandleTestTool.h:28
IsolationCorrectionTool.h
IsoCloseByCorrectionTest.IsolationSelectionTool
IsolationSelectionTool
Definition: IsoCloseByCorrectionTest.py:77
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
IsolationSelectionTool.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::IIsolationSelectionTool
Definition: IIsolationSelectionTool.h:37
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
TopIsolationCPTools.h
top::IsolationCPTools::setupPerObjectWPs
StatusCode setupPerObjectWPs(const std::vector< std::string > &WPs, const std::string &objectWPtype)
Setup IsolationSelectonTools for all WPs specified for one object type (electron, muon,...
Definition: TopIsolationCPTools.cxx:79
CP::IIsolationCorrectionTool
Definition: IIsolationCorrectionTool.h:22
top::IsolationCPTools::m_config
std::shared_ptr< top::TopConfig > m_config
Definition: TopIsolationCPTools.h:32
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
top::IsolationCPTools::IsolationCPTools
IsolationCPTools(const std::string &name)
Definition: TopIsolationCPTools.cxx:22
top::IsolationCPTools::setupIsolation
StatusCode setupIsolation()
Definition: TopIsolationCPTools.cxx:46
CP::IsolationCorrectionTool
Definition: IsolationCorrectionTool.h:27
TopConfig.h
IsoCloseByCorrectionTest.iso_tool
iso_tool
Definition: IsoCloseByCorrectionTest.py:70
top::IsolationCPTools::m_isolationCorr
ToolHandle< CP::IIsolationCorrectionTool > m_isolationCorr
Definition: TopIsolationCPTools.h:36
top::IsolationCPTools::m_isolationTools
ToolHandleArray< CP::IIsolationSelectionTool > m_isolationTools
Definition: TopIsolationCPTools.h:37
CheckAppliedSFs.WPs
WPs
Definition: CheckAppliedSFs.py:206