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;
20
21class Interp3D;
22
23namespace 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 // Helper function to create a piece wise polinomial function
126 std::string createPieceWisePolinomialFunction(const std::vector<double>& boundaries, const std::vector<std::vector<double>>& parameters, bool isOpen = false) const;
127 // The function returns a piecewise polinomial function, where each segment is defined by a polynomial of the form:
128 // f(x) = p0 + p1*x + p2*x^2 + ... + pn*x^n
129 // where n is the degree of the polynomial, and p0, p1, p2, ..., pn are the coefficients of the polynomial.
130 // The function is defined on the intervals [x0, x1), [x1, x2), ..., [xn-1, xn).
131 // boundaries: {x0, x1, x2, ...}: are the boundaries of the polinomial functions
132 // parameters: {(p0_0, p1_0, p2_0, ...), (p0_1, p1_1, p2_1, ...), ...}: are the parameters of the polinomial functions
133 // isOpen: if true, first and last segments are open, i.e. intervals are (-inf, x0), [x0, x1), [x1, x2), ..., [xn-1, xn), [xn, +inf)
134 // if isOpen==false, boundaries.size() == parameters.size()+1, else boundaries.size() == parameters.size()-1
135 };
136} // namespace CP
137
138#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.
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::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