ATLAS Offline Software
Loading...
Searching...
No Matches
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"
12
13// Local include(s):
16
17// Forward declaration(s):
18class TFile;
19class TH1F;
20class TGraph;
21
22class Interp3D;
23
24namespace CP {
25
29
30 public:
32 IsolationSelectionTool(const std::string& name);
35
37 virtual StatusCode initialize() override;
39
41 virtual asg::AcceptData accept(const xAOD::Photon& x) const override;
42 virtual asg::AcceptData accept(const xAOD::Electron& x) const override;
43 virtual asg::AcceptData accept(const xAOD::Muon& x) const override;
44 virtual asg::AcceptData accept(const strObj& x) const override;
45 virtual asg::AcceptData accept(const xAOD::IParticle& x) const override; // for tracks, and others?
46
47 virtual const asg::AcceptInfo& getPhotonAcceptInfo() const override;
48 virtual const asg::AcceptInfo& getElectronAcceptInfo() const override;
49 virtual const asg::AcceptInfo& getMuonAcceptInfo() const override;
50 virtual const asg::AcceptInfo& getObjAcceptInfo() const override;
51
52 virtual const std::vector<std::unique_ptr<IsolationWP>>& getMuonWPs() const override;
53 virtual const std::vector<std::unique_ptr<IsolationWP>>& getElectronWPs() const override;
54 virtual const std::vector<std::unique_ptr<IsolationWP>>& getPhotonWPs() const override;
55 virtual const std::vector<std::unique_ptr<IsolationWP>>& getObjWPs() const override;
56
57
58 virtual StatusCode setIParticleCutsFrom(xAOD::Type::ObjectType ObjType) override;
59
60 StatusCode addWP(const std::string& WP, xAOD::Type::ObjectType type);
61 StatusCode addWP(std::unique_ptr<IsolationWP> wp, xAOD::Type::ObjectType type);
62 StatusCode addMuonWP(const std::string& wpname);
63 StatusCode addPhotonWP(const std::string& wpname);
64 StatusCode addElectronWP(const std::string& wpname);
65 StatusCode addUserDefinedWP(const std::string& WPname, xAOD::Type::ObjectType ObjType,
66 std::vector<std::pair<xAOD::Iso::IsolationType, std::string>>& cuts, std::string key = "",
68 StatusCode addCutToWP(IsolationWP* wp, const std::string& key_in, const xAOD::Iso::IsolationType t, const std::string& expression,
69 const xAOD::Iso::IsolationType isoCutRemap);
70 StatusCode addCutToWP(IsolationWP* wp, const std::string& key, const xAOD::Iso::IsolationType t, const std::string& expression);
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 Gaudi::Property<std::string> m_filePathName{this, "filePathName", "ElectronIsolationSelection/2022_2025/v1/", " The nominal file path to use"};
98 std::unique_ptr<TFile> m_WPdefinitionFile{nullptr};
99
101 std::vector<std::unique_ptr<IsolationWP>> m_muWPs{};
102 std::vector<std::unique_ptr<IsolationWP>> m_elWPs{};
103 std::vector<std::unique_ptr<IsolationWP>> m_phWPs{};
104 std::vector<std::unique_ptr<IsolationWP>> m_objWPs{};
105
107 asg::AcceptInfo m_photonAccept{"IsolationSelectionToolPhotonAcceptInfo"};
108 asg::AcceptInfo m_electronAccept{"IsolationSelectionToolElectronAcceptInfo"};
109 asg::AcceptInfo m_muonAccept{"IsolationSelectionToolMuonAcceptInfo"};
110 asg::AcceptInfo m_objAccept{"IsolationSelectionToolObjAcceptInfo"};
111
113 std::vector<std::unique_ptr<IsolationWP>>* m_iparWPs{nullptr};
115
116 // for cut interpolation
117 Gaudi::Property<bool> m_doInterpM{this, "doCutInterpolationMuon", false, "flag to perform cut interpolation, muon"};
118 Gaudi::Property<bool> m_doInterpE{this, "doCutInterpolationElec", true, "flag to perform cut interpolation, electron"};
119 std::shared_ptr<Interp3D> m_Interp{nullptr};
120
121 void addDependencies(const std::string& container, const IsolationWP& wp);
122 SG::ReadDecorHandleKeyArray<xAOD::IParticleContainer> m_isoDecors{this, "IsolationDecors", {}, "List of decorations needed by the tool"};
123
125 Gaudi::Property<std::string> m_inMuonContainer{this, "InMuonContainer", "" , "Name of the muon container parsed to the tool."};
126 Gaudi::Property<std::string> m_inElecContainer{this, "InElectronContainer", "" , "Name of the electron container parsed to the tool."};
127 Gaudi::Property<std::string> m_inPhotContainer{this, "InPhotonContainer", "", "Name of the photon container parsed to the tool."};
128
129 // Helper function to create a piece wise polinomial function
130 std::string createPieceWisePolinomialFunction(const std::vector<double>& boundaries, const std::vector<std::vector<double>>& parameters, bool isOpen = false) const;
131 // The function returns a piecewise polinomial function, where each segment is defined by a polynomial of the form:
132 // f(x) = p0 + p1*x + p2*x^2 + ... + pn*x^n
133 // where n is the degree of the polynomial, and p0, p1, p2, ..., pn are the coefficients of the polynomial.
134 // The function is defined on the intervals [x0, x1), [x1, x2), ..., [xn-1, xn).
135 // boundaries: {x0, x1, x2, ...}: are the boundaries of the polinomial functions
136 // parameters: {(p0_0, p1_0, p2_0, ...), (p0_1, p1_1, p2_1, ...), ...}: are the parameters of the polinomial functions
137 // isOpen: if true, first and last segments are open, i.e. intervals are (-inf, x0), [x0, x1), [x1, x2), ..., [xn-1, xn), [xn, +inf)
138 // if isOpen==false, boundaries.size() == parameters.size()+1, else boundaries.size() == parameters.size()-1
139 //
140
141 };
142} // namespace CP
143
144#endif
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
#define x
Gaudi::Property< bool > m_doInterpM
Gaudi::Property< std::string > m_muWPname
Gaudi::Property< std::vector< std::string > > m_muWPvec
Gaudi::Property< std::vector< std::string > > m_phWPvec
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_isoDecors
virtual ~IsolationSelectionTool()
Destructor.
virtual const asg::AcceptInfo & getObjAcceptInfo() const override
void evaluateWP(const T &x, const std::vector< std::unique_ptr< IsolationWP > > &WP, asg::AcceptData &accept) const
Gaudi::Property< std::string > m_inElecContainer
Gaudi::Property< std::string > m_isoDecSuffix
asg::AcceptInfo m_photonAccept
AcceptInfo's.
StatusCode addMuonWP(const std::string &wpname)
virtual const asg::AcceptInfo & getMuonAcceptInfo() const override
std::vector< std::unique_ptr< IsolationWP > > m_muWPs
internal use
Gaudi::Property< bool > m_doInterpE
std::string createPieceWisePolinomialFunction(const std::vector< double > &boundaries, const std::vector< std::vector< double > > &parameters, bool isOpen=false) const
Gaudi::Property< std::string > m_phWPname
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)
virtual StatusCode initialize() override
Function initialising the tool.
IsolationSelectionTool(const std::string &name)
Create a proper constructor for Athena.
std::vector< std::unique_ptr< IsolationWP > > m_objWPs
StatusCode addWP(const std::string &WP, xAOD::Type::ObjectType type)
std::unique_ptr< TFile > m_calibFile
Gaudi::Property< std::string > m_elWPname
void addDependencies(const std::string &container, const IsolationWP &wp)
IsoWPType
Function finalizing the tool.
virtual const std::vector< std::unique_ptr< IsolationWP > > & getElectronWPs() const override
std::shared_ptr< Interp3D > m_Interp
Gaudi::Property< std::string > m_calibFileName
input file
virtual const std::vector< std::unique_ptr< IsolationWP > > & getMuonWPs() const override
virtual asg::AcceptData accept(const xAOD::Photon &x) const override
Declare the interface that the class provides.
std::unique_ptr< TFile > m_WPdefinitionFile
StatusCode addCutToWP(IsolationWP *wp, const std::string &key_in, const xAOD::Iso::IsolationType t, const std::string &expression, const xAOD::Iso::IsolationType isoCutRemap)
std::vector< std::unique_ptr< IsolationWP > > * m_iparWPs
Iparticle interface.
virtual const asg::AcceptInfo & getPhotonAcceptInfo() const override
Gaudi::Property< std::string > m_phWPKey
std::vector< std::unique_ptr< IsolationWP > > m_phWPs
virtual const std::vector< std::unique_ptr< IsolationWP > > & getObjWPs() const override
Gaudi::Property< std::string > m_filePathName
cvfms path for files containing WP definitions (e.g. for TGraphs)
Gaudi::Property< std::vector< std::string > > m_elWPvec
virtual StatusCode setIParticleCutsFrom(xAOD::Type::ObjectType ObjType) override
virtual const std::vector< std::unique_ptr< IsolationWP > > & getPhotonWPs() const override
std::vector< std::unique_ptr< IsolationWP > > m_elWPs
virtual const asg::AcceptInfo & getElectronAcceptInfo() const override
StatusCode addElectronWP(const std::string &wpname)
Gaudi::Property< std::string > m_inPhotContainer
Gaudi::Property< std::string > m_elWPKey
StatusCode addPhotonWP(const std::string &wpname)
Gaudi::Property< std::string > m_inMuonContainer
Properties to declare the data dependencies to the avalanche scheduler.
Gaudi::Property< std::string > m_muWPKey
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
DecorHandleKeyArray< ReadDecorHandle< T, S >, ReadDecorHandleKey< T >, Gaudi::DataHandle::Reader > ReadDecorHandleKeyArray
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
IsolationType
Overall enumeration for isolation types in xAOD files.
Muon_v1 Muon
Reference the current persistent version:
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".
a structure to hold an efficiency together with a variable number of uncertainties