ATLAS Offline Software
AsgElectronSelectorTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Dear emacs, this is -*-c++-*-
6 
7 #ifndef __ASGELECTRONSELECTORTOOL__
8 #define __ASGELECTRONSELECTORTOOL__
9 
10 // This include is needed at the top before any includes regarding Eigen
11 // since it includes Eigen in a specific way which causes compilation errors
12 // if not included before Eigen
14 
15 // Atlas includes
16 #include "AsgTools/AsgTool.h"
18 #include "xAODEgamma/ElectronFwd.h"
19 #include <Eigen/Dense>
20 
21 class EventContext;
22 
24 
26  virtual public IAsgElectronLikelihoodTool
27 {
29 
30 public:
32  AsgElectronSelectorTool( const std::string& myname );
33 
34 
37 public:
39  virtual StatusCode initialize() override;
40 
41  // Main methods for IAsgSelectorTool interface
46  virtual const asg::AcceptInfo& getAcceptInfo() const override;
47 
49  asg::AcceptData accept( const xAOD::IParticle* part ) const override;
50  asg::AcceptData accept( const EventContext& ctx, const xAOD::IParticle* part ) const override;
51 
53  asg::AcceptData accept( const EventContext& ctx, const xAOD::Electron* eg ) const override {
54  return accept (ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object
55  }
56 
58  asg::AcceptData accept( const EventContext& ctx, const xAOD::Egamma* eg ) const override {
59  return accept (ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object
60  }
61 
63  asg::AcceptData accept( const EventContext& ctx, const xAOD::Electron* eg, double mu ) const override;
64 
66  asg::AcceptData accept( const EventContext& ctx, const xAOD::Egamma* eg, double mu ) const override;
67 
68  // Main methods for IAsgCalculatorTool interface
69 public:
71  double calculate( const xAOD::IParticle* part ) const;
72  double calculate( const EventContext &ctx, const xAOD::IParticle* part ) const override;
73 
75  double calculate( const EventContext &ctx, const xAOD::Electron* eg ) const override {
76  return calculate (ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object
77  }
78 
80  double calculate( const EventContext &ctx, const xAOD::Egamma* eg ) const override {
81  return calculate (ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup variable from the xAOD object
82  }
83 
85  double calculate( const EventContext &ctx, const xAOD::Electron* eg, double mu ) const override;
86 
88  double calculateCF( const EventContext &ctx, const xAOD::Electron* eg, double mu) const;
89 
91  double calculate( const EventContext &ctx, const xAOD::Egamma* eg, double mu ) const override;
92 
93 
95  std::vector<float> calculateMultipleOutputs( const EventContext &ctx, const xAOD::Electron *eg, double mu = -99) const override;
96 
97  virtual std::string getOperatingPointName() const override;
98 
99  // Private methods
100 private:
103 
105  bool isForwardElectron( const xAOD::Egamma* eg, const float eta ) const;
106 
108  double transformMLOutput( float score ) const;
109 
111  double combineOutputs(const std::vector<float>& mvaScores, double eta) const;
112  static double combineOutputsCF(const std::vector<float>& mvaScores) ;
113 
115  static unsigned int getDiscEtaBin( double eta ) ;
116 
118  static unsigned int getDiscEtBin( double et ) ;
119 
120  // NOTE that this will only perform the cut interpolation up to ~45 GeV, so
121  // no smoothing is done above this for the high ET MVA binning yet
123  static double interpolateCuts( const std::vector<double>& cuts, double et, double eta ) ;
124 
125 
126 
127  // Private member variables
128 private:
129 
131  std::string m_workingPoint;
132 
134  std::string m_configFile;
135 
137  std::unique_ptr<const ElectronDNNCalculator> m_mvaTool;
138 
140  std::string m_modelFileName;
141 
143  std::string m_quantileFileName;
144 
146  std::vector<std::string> m_variables;
147 
150 
152 
154  bool m_multiClass{};
156  bool m_CFReject{};
158  bool m_newVars{};
160  bool m_cfSignal{};
162  std::vector<double> m_fractions;
163 
165  std::vector<int> m_cutAmbiguity;
167  std::vector<int> m_cutBL;
169  std::vector<int> m_cutPi;
171  std::vector<int> m_cutSCT;
175  std::vector<double> m_cutSelector;
176  std::vector<double> m_cutSelectorCF;
177 
178 
191 
193  std::vector<float> m_defaultVector;
194 
196  static const unsigned int s_fnDiscEtBins = 10;
198  static const unsigned int s_fnDiscEtaBins = 10;
199 
200 
201 }; // End: class definition
202 
203 #endif
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
AsgElectronSelectorTool
Electron selector tool to select signal electrons using the ElectronDNNCalculator retrieve a score ba...
Definition: AsgElectronSelectorTool.h:27
AsgElectronSelectorTool::m_cutPosition_kinematic
int m_cutPosition_kinematic
The position of the kinematic cut bit in the AcceptInfo return object.
Definition: AsgElectronSelectorTool.h:180
AsgElectronSelectorTool::calculateCF
double calculateCF(const EventContext &ctx, const xAOD::Electron *eg, double mu) const
The main result method: the actual CF mva score is calculated here.
Definition: AsgElectronSelectorTool.cxx:543
et
Extra patterns decribing particle interation process.
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
AsgElectronSelectorTool::m_cutPi
std::vector< int > m_cutPi
cut min on pixel hits
Definition: AsgElectronSelectorTool.h:169
AsgElectronSelectorTool::calculate
double calculate(const EventContext &ctx, const xAOD::Electron *eg) const override
The main result method: the actual mva score is calculated here.
Definition: AsgElectronSelectorTool.h:75
AsgElectronSelectorTool::m_configFile
std::string m_configFile
The input config file.
Definition: AsgElectronSelectorTool.h:134
ParticleTest.eg
eg
Definition: ParticleTest.py:29
AsgElectronSelectorTool::m_variables
std::vector< std::string > m_variables
Variables used in the MVA Tool.
Definition: AsgElectronSelectorTool.h:146
AsgElectronSelectorTool::m_mvaTool
std::unique_ptr< const ElectronDNNCalculator > m_mvaTool
Pointer to the class that calculates the MVA score.
Definition: AsgElectronSelectorTool.h:137
AsgElectronSelectorTool::combineOutputsCF
static double combineOutputsCF(const std::vector< float > &mvaScores)
Definition: AsgElectronSelectorTool.cxx:958
ASG_TOOL_CLASS2
#define ASG_TOOL_CLASS2(CLASSNAME, INT1, INT2)
Definition: AsgToolMacros.h:77
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AsgElectronSelectorTool::getOperatingPointName
virtual std::string getOperatingPointName() const override
Get the name of the current operating point.
Definition: AsgElectronSelectorTool.cxx:820
AsgElectronSelectorTool::AsgElectronSelectorTool
AsgElectronSelectorTool(const std::string &myname)
Standard constructor.
Definition: AsgElectronSelectorTool.cxx:38
AsgElectronSelectorTool::accept
asg::AcceptData accept(const EventContext &ctx, const xAOD::Egamma *eg) const override
The main accept method: the actual cuts are applied here.
Definition: AsgElectronSelectorTool.h:58
AsgElectronSelectorTool::getDiscEtBin
static unsigned int getDiscEtBin(double et)
Gets the Descriminant Et bin the et (MeV) [0,s_fnDiscEtBins-1].
Definition: AsgElectronSelectorTool.cxx:979
AsgElectronSelectorTool::m_defaultVector
std::vector< float > m_defaultVector
Default vector to return if calculation fails.
Definition: AsgElectronSelectorTool.h:193
AsgElectronSelectorTool::m_modelFileName
std::string m_modelFileName
The input file name that holds the model.
Definition: AsgElectronSelectorTool.h:140
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
AsgElectronSelectorTool::m_CFReject
bool m_CFReject
Run CF rejection or not.
Definition: AsgElectronSelectorTool.h:156
IAsgSelectionTool
Definition: IAsgSelectionTool.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
AsgElectronSelectorTool::m_cutAmbiguity
std::vector< int > m_cutAmbiguity
do cut on ambiguity bit
Definition: AsgElectronSelectorTool.h:165
AsgElectronSelectorTool::m_cutSelector
std::vector< double > m_cutSelector
cut on mva output
Definition: AsgElectronSelectorTool.h:175
AsgElectronSelectorTool::accept
asg::AcceptData accept(const xAOD::IParticle *part) const override
The main accept method: using the generic interface.
Definition: AsgElectronSelectorTool.cxx:826
AsgElectronSelectorTool::calculate
double calculate(const EventContext &ctx, const xAOD::Egamma *eg) const override
The main result method: the actual mva score is calculated here.
Definition: AsgElectronSelectorTool.h:80
IAsgElectronLikelihoodTool.h
AsgElectronSelectorTool::m_cfSignal
bool m_cfSignal
Use the CF output node in the numerator or the denominator.
Definition: AsgElectronSelectorTool.h:160
AsgElectronSelectorTool::m_multiClass
bool m_multiClass
Multiclass model or not.
Definition: AsgElectronSelectorTool.h:154
asg::AcceptInfo
Definition: AcceptInfo.h:28
AsgElectronSelectorTool::m_cutPosition_NBlayer
int m_cutPosition_NBlayer
The position of the NBlayer cut bit in the AcceptInfo return object.
Definition: AsgElectronSelectorTool.h:186
AsgElectronSelectorTool::accept
asg::AcceptData accept(const EventContext &ctx, const xAOD::Electron *eg) const override
The main accept method: the actual cuts are applied here.
Definition: AsgElectronSelectorTool.h:53
AsgElectronSelectorTool::m_quantileFileName
std::string m_quantileFileName
The input file name that holds the QuantileTransformer.
Definition: AsgElectronSelectorTool.h:143
AsgElectronSelectorTool::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations.
Definition: AsgElectronSelectorTool.cxx:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AsgElectronSelectorTool::getDiscEtaBin
static unsigned int getDiscEtaBin(double eta)
Gets the Discriminant Eta bin [0,s_fnDiscEtaBins-1] given the eta.
Definition: AsgElectronSelectorTool.cxx:968
AsgElectronSelectorTool::calculate
double calculate(const xAOD::IParticle *part) const
The main result method: the actual mva score is calculated here.
Definition: AsgElectronSelectorTool.cxx:845
AsgElectronSelectorTool::calculateMultipleOutputs
std::vector< float > calculateMultipleOutputs(const EventContext &ctx, const xAOD::Electron *eg, double mu=-99) const override
The result method for multiple outputs: can return multiple outputs of the MVA.
Definition: AsgElectronSelectorTool.cxx:561
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
ElectronFwd.h
EventPrimitives.h
AsgElectronSelectorTool::interpolateCuts
static double interpolateCuts(const std::vector< double > &cuts, double et, double eta)
Interpolates cut values along pt.
Definition: AsgElectronSelectorTool.cxx:993
AsgElectronSelectorTool::m_fractions
std::vector< double > m_fractions
Fractions to combine the output nodes of a multiclass model into one discriminant.
Definition: AsgElectronSelectorTool.h:162
AsgElectronSelectorTool::m_skipAmbiguityCut
bool m_skipAmbiguityCut
Definition: AsgElectronSelectorTool.h:151
AsgElectronSelectorTool::m_doSmoothBinInterpolation
bool m_doSmoothBinInterpolation
do smooth interpolation between bins
Definition: AsgElectronSelectorTool.h:173
ElectronDNNCalculator
Used by AsgElectronSelectorTool to calculate the score of a python trained DNN using lwtnn as interfa...
Definition: ElectronDNNCalculator.h:78
xAOD::Electron_v1
Definition: Electron_v1.h:34
AsgElectronSelectorTool::m_cutPosition_NPixel
int m_cutPosition_NPixel
The position of the NPixel cut bit in the AcceptInfo return object.
Definition: AsgElectronSelectorTool.h:184
AsgElectronSelectorTool::m_cutPosition_MVA
int m_cutPosition_MVA
The position of the MVA cut bit in the AcceptInfo return object.
Definition: AsgElectronSelectorTool.h:190
AsgElectronSelectorTool::m_cutPosition_ambiguity
int m_cutPosition_ambiguity
The position of the ambiguity cut bit in the AcceptInfo return object.
Definition: AsgElectronSelectorTool.h:188
IAsgElectronLikelihoodTool
Interface to tool to select electrons.
Definition: IAsgElectronLikelihoodTool.h:27
xAOD::score
@ score
Definition: TrackingPrimitives.h:513
AsgElectronSelectorTool::m_workingPoint
std::string m_workingPoint
Working Point.
Definition: AsgElectronSelectorTool.h:131
AsgElectronSelectorTool::m_newVars
bool m_newVars
New or old set of variables.
Definition: AsgElectronSelectorTool.h:158
AsgElectronSelectorTool::m_cutBL
std::vector< int > m_cutBL
cut min on b-layer hits
Definition: AsgElectronSelectorTool.h:167
AsgElectronSelectorTool::s_fnDiscEtaBins
static const unsigned int s_fnDiscEtaBins
number of discriminants vs |eta|
Definition: AsgElectronSelectorTool.h:198
AsgElectronSelectorTool::isForwardElectron
bool isForwardElectron(const xAOD::Egamma *eg, const float eta) const
check for FwdElectron
Definition: AsgElectronSelectorTool.cxx:892
AsgElectronSelectorTool::transformMLOutput
double transformMLOutput(float score) const
Applies a logit transformation to the score returned by the underlying MVA tool.
Definition: AsgElectronSelectorTool.cxx:916
AsgElectronSelectorTool::m_cutPosition_NSilicon
int m_cutPosition_NSilicon
The position of the NSilicon cut bit in the AcceptInfo return object.
Definition: AsgElectronSelectorTool.h:182
AsgElectronSelectorTool::~AsgElectronSelectorTool
virtual ~AsgElectronSelectorTool()
Standard destructor.
AsgElectronSelectorTool::m_acceptMVA
asg::AcceptInfo m_acceptMVA
Accept info.
Definition: AsgElectronSelectorTool.h:102
AsgElectronSelectorTool::combineOutputs
double combineOutputs(const std::vector< float > &mvaScores, double eta) const
Combines the six output nodes of a multiclass model into one discriminant.
Definition: AsgElectronSelectorTool.cxx:929
AsgElectronSelectorTool::getAcceptInfo
virtual const asg::AcceptInfo & getAcceptInfo() const override
Method to get the plain AcceptInfo.
Definition: AsgElectronSelectorTool.cxx:315
AsgElectronSelectorTool::m_cutSCT
std::vector< int > m_cutSCT
cut min on precision hits
Definition: AsgElectronSelectorTool.h:171
AsgTool.h
asg::AcceptData
Definition: AcceptData.h:30
AsgElectronSelectorTool::m_cutSelectorCF
std::vector< double > m_cutSelectorCF
Definition: AsgElectronSelectorTool.h:176
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
AsgElectronSelectorTool::s_fnDiscEtBins
static const unsigned int s_fnDiscEtBins
number of discrimintants vs Et
Definition: AsgElectronSelectorTool.h:196
AsgElectronSelectorTool::m_skipDeltaPoverP
bool m_skipDeltaPoverP
Flag for skip the use of deltaPoverP in dnn calculation (like at HLT)
Definition: AsgElectronSelectorTool.h:149