ATLAS Offline Software
IsolationSelectionTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3  */
4 #ifndef ISOLATIONSELECTION_ISOLATIONSELECTIONTOOL_H
5 #define ISOLATIONSELECTION_ISOLATIONSELECTIONTOOL_H
6 
7 // Framework include(s):
8 #include "AsgTools/AsgTool.h"
9 #include "AsgTools/ToolHandle.h"
12 
13 // Local include(s):
16 
17 // Forward declaration(s):
18 class TFile;
19 class TH1F;
20 
21 class Interp3D;
22 
23 namespace CP {
24 
28 
29  public:
31  IsolationSelectionTool(const std::string& name);
34 
36  virtual StatusCode initialize() override;
38 
40  virtual asg::AcceptData accept(const xAOD::Photon& x) const override;
41  virtual asg::AcceptData accept(const xAOD::Electron& x) const override;
42  virtual asg::AcceptData accept(const xAOD::Muon& x) const override;
43  virtual asg::AcceptData accept(const strObj& x) const override;
44  virtual asg::AcceptData accept(const xAOD::IParticle& x) const override; // for tracks, and others?
45 
46  virtual const asg::AcceptInfo& getPhotonAcceptInfo() const override;
47  virtual const asg::AcceptInfo& getElectronAcceptInfo() const override;
48  virtual const asg::AcceptInfo& getMuonAcceptInfo() const override;
49  virtual const asg::AcceptInfo& getObjAcceptInfo() const override;
50 
51  virtual const std::vector<std::unique_ptr<IsolationWP>>& getMuonWPs() const override;
52  virtual const std::vector<std::unique_ptr<IsolationWP>>& getElectronWPs() const override;
53  virtual const std::vector<std::unique_ptr<IsolationWP>>& getPhotonWPs() const override;
54  virtual const std::vector<std::unique_ptr<IsolationWP>>& getObjWPs() const override;
55 
56 
57  virtual StatusCode setIParticleCutsFrom(xAOD::Type::ObjectType ObjType) override;
58 
59  StatusCode addWP(const std::string& WP, xAOD::Type::ObjectType type);
60  StatusCode addWP(std::unique_ptr<IsolationWP> wp, xAOD::Type::ObjectType type);
61  StatusCode addMuonWP(const std::string& wpname);
62  StatusCode addPhotonWP(const std::string& wpname);
63  StatusCode addElectronWP(const std::string& wpname);
64  StatusCode addUserDefinedWP(const std::string& WPname, xAOD::Type::ObjectType ObjType,
65  std::vector<std::pair<xAOD::Iso::IsolationType, std::string>>& cuts, std::string key = "",
67  StatusCode addCutToWP(IsolationWP* wp, const std::string& key_in, const xAOD::Iso::IsolationType t, const std::string& expression,
68  const xAOD::Iso::IsolationType isoCutRemap);
69  StatusCode addCutToWP(IsolationWP* wp, const std::string& key, const xAOD::Iso::IsolationType t, const std::string& expression);
70 
71 
72  private:
73  // same interface for xAOD::IParticle and StrObj -> use template
74  template <typename T> void evaluateWP(const T& x, const std::vector<std::unique_ptr<IsolationWP>>& WP, asg::AcceptData& accept) const;
75 
76  Gaudi::Property<std::string> m_muWPname{this, "MuonWP", "Undefined", "Working point for muon"};
77  Gaudi::Property<std::string> m_elWPname{this, "ElectronWP", "Undefined", "Working point for electron"};
78  Gaudi::Property<std::string> m_phWPname{this, "PhotonWP", "Undefined", "Working point for photon"};
79  Gaudi::Property<std::vector<std::string>> m_muWPvec{this, "MuonWPVec", {}, "Vector of working points for muon"};
80  Gaudi::Property<std::vector<std::string>> m_elWPvec{this, "ElectronWPVec", {}, "Vector of working points for electron"};
81  Gaudi::Property<std::vector<std::string>> m_phWPvec{this, "PhotonWPVec", {}, "Vector of working points for photon"};
82 
83  Gaudi::Property<std::string> m_muWPKey{this, "MuonKey", "/Muons/DFCommonGoodMuon/mu_cutValues_", "path of the cut map for muon"};
84  Gaudi::Property<std::string> m_elWPKey{this, "ElectronKey", "/ElectronPhoton/LHTight/el_cutValues_",
85  "path of the cut map for electron"};
86  Gaudi::Property<std::string> m_phWPKey{this, "PhotonKey", "/ElectronPhoton/LHTight/el_cutValues_",
87  "path of the cut map for photon"};
88  Gaudi::Property<std::string> m_isoDecSuffix{
89  this, "IsoDecSuffix", "", "Suffix added to output isolation variables to allow to NOT overwrite existing values"};
90 
91 
93  Gaudi::Property<std::string> m_calibFileName{this, "CalibFileName", "", " The config to use"};
94  std::unique_ptr<TFile> m_calibFile{nullptr};
95 
97  std::vector<std::unique_ptr<IsolationWP>> m_muWPs{};
98  std::vector<std::unique_ptr<IsolationWP>> m_elWPs{};
99  std::vector<std::unique_ptr<IsolationWP>> m_phWPs{};
100  std::vector<std::unique_ptr<IsolationWP>> m_objWPs{};
101 
103  asg::AcceptInfo m_photonAccept{"IsolationSelectionToolPhotonAcceptInfo"};
104  asg::AcceptInfo m_electronAccept{"IsolationSelectionToolElectronAcceptInfo"};
105  asg::AcceptInfo m_muonAccept{"IsolationSelectionToolMuonAcceptInfo"};
106  asg::AcceptInfo m_objAccept{"IsolationSelectionToolObjAcceptInfo"};
107 
109  std::vector<std::unique_ptr<IsolationWP>>* m_iparWPs{nullptr};
111 
112  // for cut interpolation
113  Gaudi::Property<bool> m_doInterpM{this, "doCutInterpolationMuon", false, "flag to perform cut interpolation, muon"};
114  Gaudi::Property<bool> m_doInterpE{this, "doCutInterpolationElec", true, "flag to perform cut interpolation, electron"};
115  std::shared_ptr<Interp3D> m_Interp{nullptr};
116 
117  void addDependencies(const std::string& container, const IsolationWP& wp);
118  SG::ReadDecorHandleKeyArray<xAOD::IParticleContainer> m_isoDecors{this, "IsolationDecors", {}, "List of decorations needed by the tool"};
119 
121  Gaudi::Property<std::string> m_inMuonContainer{this, "InMuonContainer", "" , "Name of the muon container parsed to the tool."};
122  Gaudi::Property<std::string> m_inElecContainer{this, "InElectronContainer", "" , "Name of the electron container parsed to the tool."};
123  Gaudi::Property<std::string> m_inPhotContainer{this, "InPhotonContainer", "", "Name of the photon container parsed to the tool."};
124  };
125 } // namespace CP
126 
127 #endif
CP::IsolationSelectionTool::m_elWPKey
Gaudi::Property< std::string > m_elWPKey
Definition: IsolationSelectionTool.h:84
CP::IsolationSelectionTool::m_isoDecors
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_isoDecors
Definition: IsolationSelectionTool.h:118
CP::IsolationSelectionTool::m_photonAccept
asg::AcceptInfo m_photonAccept
AcceptInfo's.
Definition: IsolationSelectionTool.h:103
CP::IsolationSelectionTool::getMuonAcceptInfo
virtual const asg::AcceptInfo & getMuonAcceptInfo() const override
Definition: IsolationSelectionTool.cxx:468
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
PropertyWrapper.h
CP::IsolationSelectionTool::getMuonWPs
virtual const std::vector< std::unique_ptr< IsolationWP > > & getMuonWPs() const override
Definition: IsolationSelectionTool.cxx:21
Interp3D
Definition: Interp3D.h:13
CP::IsolationSelectionTool::addWP
StatusCode addWP(const std::string &WP, xAOD::Type::ObjectType type)
Definition: IsolationSelectionTool.cxx:362
ObjectType
ObjectType
Definition: BaseObject.h:11
CP::IsolationSelectionTool::evaluateWP
void evaluateWP(const T &x, const std::vector< std::unique_ptr< IsolationWP >> &WP, asg::AcceptData &accept) const
Definition: IsolationSelectionTool.cxx:395
IsoCloseByCorrectionTest.WP
WP
Definition: IsoCloseByCorrectionTest.py:56
CP::IsolationSelectionTool::getObjWPs
virtual const std::vector< std::unique_ptr< IsolationWP > > & getObjWPs() const override
Definition: IsolationSelectionTool.cxx:24
CP::IsolationSelectionTool::m_electronAccept
asg::AcceptInfo m_electronAccept
Definition: IsolationSelectionTool.h:104
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
CP::IsolationSelectionTool::addCutToWP
StatusCode addCutToWP(IsolationWP *wp, const std::string &key_in, const xAOD::Iso::IsolationType t, const std::string &expression, const xAOD::Iso::IsolationType isoCutRemap)
Definition: IsolationSelectionTool.cxx:111
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
x
#define x
CP::IsolationSelectionTool::m_inMuonContainer
Gaudi::Property< std::string > m_inMuonContainer
Properties to declare the data dependencies to the avalanche scheduler.
Definition: IsolationSelectionTool.h:121
CP::IsolationSelectionTool::m_objWPs
std::vector< std::unique_ptr< IsolationWP > > m_objWPs
Definition: IsolationSelectionTool.h:100
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
Cut
Definition: SUSYToolsAlg.cxx:62
CP::strObj
Definition: IsolationCondition.h:23
ReadDecorHandleKeyArray.h
CP::IsolationSelectionTool::m_inElecContainer
Gaudi::Property< std::string > m_inElecContainer
Definition: IsolationSelectionTool.h:122
CP::IsolationSelectionTool::IsolationSelectionTool
IsolationSelectionTool(const std::string &name)
Create a proper constructor for Athena.
Definition: IsolationSelectionTool.cxx:20
CP::IsolationSelectionTool::m_elWPname
Gaudi::Property< std::string > m_elWPname
Definition: IsolationSelectionTool.h:77
CP::IsolationSelectionTool::Efficiency
@ Efficiency
Definition: IsolationSelectionTool.h:39
HION12.expression
string expression
Definition: HION12.py:56
CP::IsolationSelectionTool::m_calibFileName
Gaudi::Property< std::string > m_calibFileName
input file
Definition: IsolationSelectionTool.h:93
asg::AcceptInfo
Definition: AcceptInfo.h:28
CP::IsolationSelectionTool::m_elWPvec
Gaudi::Property< std::vector< std::string > > m_elWPvec
Definition: IsolationSelectionTool.h:80
CP::IsolationSelectionTool::m_phWPs
std::vector< std::unique_ptr< IsolationWP > > m_phWPs
Definition: IsolationSelectionTool.h:99
CP::IsolationSelectionTool::getElectronAcceptInfo
virtual const asg::AcceptInfo & getElectronAcceptInfo() const override
Definition: IsolationSelectionTool.cxx:466
CP::IsolationSelectionTool::addMuonWP
StatusCode addMuonWP(const std::string &wpname)
Definition: IsolationSelectionTool.cxx:143
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::Iso::IsolationType
IsolationType
Overall enumeration for isolation types in xAOD files.
Definition: IsolationType.h:26
CP::IsolationSelectionTool::m_isoDecSuffix
Gaudi::Property< std::string > m_isoDecSuffix
Definition: IsolationSelectionTool.h:88
CP::IsolationSelectionTool::m_muWPs
std::vector< std::unique_ptr< IsolationWP > > m_muWPs
internal use
Definition: IsolationSelectionTool.h:97
CP::IIsolationSelectionTool
Definition: IIsolationSelectionTool.h:37
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
CP::IsolationSelectionTool::m_inPhotContainer
Gaudi::Property< std::string > m_inPhotContainer
Definition: IsolationSelectionTool.h:123
CP::IsolationSelectionTool::accept
virtual asg::AcceptData accept(const xAOD::Photon &x) const override
Declare the interface that the class provides.
Definition: IsolationSelectionTool.cxx:401
CP::IsolationSelectionTool::IsoWPType
IsoWPType
Function finalizing the tool.
Definition: IsolationSelectionTool.h:39
CP::IsolationSelectionTool::addPhotonWP
StatusCode addPhotonWP(const std::string &wpname)
Definition: IsolationSelectionTool.cxx:220
CP::IsolationWP
Definition: IsolationWP.h:16
PlotSFuncertainty.wp
wp
Definition: PlotSFuncertainty.py:112
CP::IsolationSelectionTool::m_objAccept
asg::AcceptInfo m_objAccept
Definition: IsolationSelectionTool.h:106
CP::IsolationSelectionTool::~IsolationSelectionTool
virtual ~IsolationSelectionTool()
Destructor.
CP::IsolationSelectionTool::m_phWPKey
Gaudi::Property< std::string > m_phWPKey
Definition: IsolationSelectionTool.h:86
CP::IsolationSelectionTool::m_phWPname
Gaudi::Property< std::string > m_phWPname
Definition: IsolationSelectionTool.h:78
CP::IsolationSelectionTool::m_muWPname
Gaudi::Property< std::string > m_muWPname
Definition: IsolationSelectionTool.h:76
CP::IsolationSelectionTool::getPhotonAcceptInfo
virtual const asg::AcceptInfo & getPhotonAcceptInfo() const override
Definition: IsolationSelectionTool.cxx:464
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
IIsolationSelectionTool.h
CP::IsolationSelectionTool::m_doInterpM
Gaudi::Property< bool > m_doInterpM
Definition: IsolationSelectionTool.h:113
CP::IsolationSelectionTool::setIParticleCutsFrom
virtual StatusCode setIParticleCutsFrom(xAOD::Type::ObjectType ObjType) override
Definition: IsolationSelectionTool.cxx:94
xAOD::Electron_v1
Definition: Electron_v1.h:34
CP::IsolationSelectionTool::m_calibFile
std::unique_ptr< TFile > m_calibFile
Definition: IsolationSelectionTool.h:94
CP::IsolationSelectionTool::m_muWPKey
Gaudi::Property< std::string > m_muWPKey
Definition: IsolationSelectionTool.h:83
CP::IsolationSelectionTool::addElectronWP
StatusCode addElectronWP(const std::string &wpname)
Definition: IsolationSelectionTool.cxx:253
CP::IsolationSelectionTool::m_muonAccept
asg::AcceptInfo m_muonAccept
Definition: IsolationSelectionTool.h:105
TH1F
Definition: rootspy.cxx:320
xAOD::Photon_v1
Definition: Photon_v1.h:37
CP::IsolationSelectionTool::getPhotonWPs
virtual const std::vector< std::unique_ptr< IsolationWP > > & getPhotonWPs() const override
Definition: IsolationSelectionTool.cxx:23
CP::IsolationSelectionTool
Definition: IsolationSelectionTool.h:25
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
IsolationWP.h
CP::IsolationSelectionTool::initialize
virtual StatusCode initialize() override
Function initialising the tool.
Definition: IsolationSelectionTool.cxx:27
CP::IsolationSelectionTool::m_Interp
std::shared_ptr< Interp3D > m_Interp
Definition: IsolationSelectionTool.h:115
CP::IsolationSelectionTool::m_iparWPs
std::vector< std::unique_ptr< IsolationWP > > * m_iparWPs
Iparticle interface.
Definition: IsolationSelectionTool.h:109
CP::IsolationSelectionTool::addUserDefinedWP
StatusCode addUserDefinedWP(const std::string &WPname, xAOD::Type::ObjectType ObjType, std::vector< std::pair< xAOD::Iso::IsolationType, std::string >> &cuts, std::string key="", IsoWPType type=Efficiency)
Definition: IsolationSelectionTool.cxx:322
CP::IsolationSelectionTool::m_phWPvec
Gaudi::Property< std::vector< std::string > > m_phWPvec
Definition: IsolationSelectionTool.h:81
CP::IsolationSelectionTool::addDependencies
void addDependencies(const std::string &container, const IsolationWP &wp)
Definition: IsolationSelectionTool.cxx:85
CP::IsolationSelectionTool::m_doInterpE
Gaudi::Property< bool > m_doInterpE
Definition: IsolationSelectionTool.h:114
CP::IsolationSelectionTool::getObjAcceptInfo
virtual const asg::AcceptInfo & getObjAcceptInfo() const override
Definition: IsolationSelectionTool.cxx:469
ToolHandle.h
AsgTool.h
asg::AcceptData
Definition: AcceptData.h:30
CP::IsolationSelectionTool::m_muWPvec
Gaudi::Property< std::vector< std::string > > m_muWPvec
Definition: IsolationSelectionTool.h:79
CP::IsolationSelectionTool::m_elWPs
std::vector< std::unique_ptr< IsolationWP > > m_elWPs
Definition: IsolationSelectionTool.h:98
CP::IsolationSelectionTool::m_iparAcceptInfo
asg::AcceptInfo * m_iparAcceptInfo
Definition: IsolationSelectionTool.h:110
CP::IsolationSelectionTool::getElectronWPs
virtual const std::vector< std::unique_ptr< IsolationWP > > & getElectronWPs() const override
Definition: IsolationSelectionTool.cxx:22
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37