ATLAS Offline Software
Loading...
Searching...
No Matches
TElectronLikelihoodTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
5// Dear emacs, this is -*-c++-*-
6
19#ifndef TELECTRONLIKELIHOODTOOL_H
20#define TELECTRONLIKELIHOODTOOL_H
21
22// Include the return objects and the base class
24#include "AsgTools/IAsgTool.h"
25#include "PATCore/AcceptData.h"
26#include "PATCore/AcceptInfo.h"
27//
28#include "SafeTH1.h"
29#include <string> // for string
30#include <vector> // for vector
31class TFile;
32
33namespace {
34constexpr unsigned int IP_BINS = 1;
35}
36namespace LikeEnum {
37
39{
40 double likelihood;
41 double eta;
42 double eT;
46 uint8_t ambiguityBit;
47 double d0;
48 double deltaEta;
50 double wstot;
51 double EoverP;
52 double ip;
53};
54
56{
57 double eta;
58 double eT;
59 double f3;
60 double rHad;
61 double rHad1;
62 double Reta;
63 double w2;
64 double f1;
65 double eratio;
66 double deltaEta;
67 double d0;
68 double d0sigma;
69 double rphi;
72 double TRT_PID;
73 double ip;
74};
75}
76
77namespace Root {
79{
80
81public:
83 TElectronLikelihoodTool(const char* name = "TElectronLikelihoodTool");
84
85 // Main methods
86public:
88 StatusCode initialize();
89
91 const asg::AcceptInfo& getAcceptInfo() const { return m_acceptInfo; }
92
95 asg::AcceptData accept(double likelihood,
96 double eta,
97 double eT,
98 int nSiHitsPlusDeadSensors,
99 int nPixHitsPlusDeadSensors,
100 bool passBLayerRequirement,
101 uint8_t ambiguityBit,
102 double d0,
103 double deltaEta,
104 double deltaphires,
105 double wstot,
106 double EoverP,
107 double ip) const;
110
111 double calculate(LikeEnum::LHCalcVars_t& vars_struct) const;
112 double calculate(double eta,
113 double eT,
114 double f3,
115 double rHad,
116 double rHad1,
117 double Reta,
118 double w2,
119 double f1,
120 double eratio,
121 double deltaEta,
122 double d0,
123 double d0sigma,
124 double rphi,
125 double deltaPoverP,
126 double deltaphires,
127 double TRT_PID,
128 double ip) const;
129
131 inline void setPDFFileName(const std::string& val) { m_pdfFileName = val; }
132
134 inline void setVariableNames(const std::string& val)
135 {
136 m_variableNames = val;
138 }
139
141 int loadVarHistograms(const std::string& vstr,
142 TFile* pdfFile,
143 unsigned int varIndex);
144
146 inline void setBinning(const std::string& val) { m_ipBinning = val; }
147
148 unsigned int getBitmask(void) const { return m_variableBitMask; }
149 inline void setBitmask(unsigned int val) { m_variableBitMask = val; };
150
151 // Private methods
152private:
153 // For every input "varVector", make sure elements of vector are
154 // in the same order as prescribed in fVariables
155
156 double evaluateLikelihood(const std::vector<double>& varVector,
157 double et,
158 double eta,
159 double ip = 0) const;
160
161 double evaluateLikelihood(const std::vector<float>& varVector,
162 double et,
163 double eta,
164 double ip = 0) const;
165
166 unsigned int getLikelihoodBitmask(const std::string& vars) const;
167
168 double InterpolateCuts(const std::vector<double>& cuts,
169 const std::vector<double>& cuts_4gev,
170 double et,
171 double eta) const;
172 double InterpolatePdfs(unsigned int s_or_b,
173 unsigned int ipbin,
174 double et,
175 double eta,
176 int bin,
177 unsigned int var) const;
178
179public:
181 std::vector<int> m_cutBL;
183 std::vector<int> m_cutPi;
185 std::vector<int> m_cutSi;
187 std::vector<double> m_cutA0;
189 std::vector<double> m_cutDeltaEta;
190 // /** @brief do cut on delta phi bit*/
191 std::vector<double> m_cutDeltaPhiRes;
193 std::vector<int> m_cutAmbiguity;
204 // /** @brief do cut on wstot above HighETBinThreshold bit*/
205 std::vector<double> m_cutWstotAtHighET;
206 // /** @brief do cut on EoverP above HighETBinThreshold bit*/
207 std::vector<double> m_cutEoverPAtHighET;
213 std::vector<double> m_cutLikelihood;
217 std::vector<double> m_cutLikelihood4GeV;
230 std::vector<double> m_discLooseForPileupTransform;
248 std::string m_variableNames;
250 std::string m_pdfFileName;
251
252 // Private methods
253private:
256 double TransformLikelihoodOutput(double ps,
257 double pb,
258 double ip,
259 double et,
260 double eta) const;
261
263 static unsigned int getLikelihoodEtaBin(double eta) ;
264
266 static unsigned int getLikelihoodEtHistBin(double eT) ;
267
269 unsigned int getLikelihoodEtDiscBin(double eT, const bool isLHbinning) const;
270
271 // Private member variables
272private:
274 std::string m_name;
275
278
281 unsigned int m_variableBitMask;
282
284 std::string m_ipBinning;
285
288
291
294
297
300
303
306
309
312
316
320
321 static constexpr double s_fIpBounds[IP_BINS + 1] = { 0., 500. };
322
323 // number of hists stored for original LH, including 4GeV bin (for backwards
324 // compatibility)
325 static constexpr unsigned int s_fnEtBinsHist = 7;
326 // number of discs stored for original LH, excluding 4GeV bin (for
327 // backwards compatibility)
328 static constexpr unsigned int s_fnDiscEtBins = 9;
329 // number of discs stored for original LH plus one for
330 // HighETBinThreshold (useOneExtraHighETLHBin), excluding 4GeV bin
331 static constexpr unsigned int s_fnDiscEtBinsOneExtra = 10;
332 static constexpr unsigned int s_fnEtaBins = 10;
333 static constexpr unsigned int s_fnVariables = 13;
334 // 5D array of unique_ptr to SafeTH1 // [sig(0)/bkg(1)][ip][et][eta][variable]
335 std::unique_ptr<EGSelectors::SafeTH1> m_fPDFbins[2][IP_BINS][s_fnEtBinsHist][s_fnEtaBins][s_fnVariables];
336 static const std::string s_fVariables[s_fnVariables];
337
338 static unsigned int getIpBin(double ip) ;
339 static std::string getBinName(int etbin,
340 int etabin,
341 int ipbin,
342 const std::string& iptype) ;
343};
344
345} // End: namespace Root
346
347#endif
Scalar eta() const
pseudorapidity method
int m_cutPosition_NPixel
The position of the NPixel cut bit in the AcceptInfo return object.
int m_cutPositionTrackMatchEta
The position of the deltaeta cut bit in the AcceptInfo return object.
std::vector< double > m_discHardCutForPileupTransform
reference disc for very hard cut; used by pileup transform
std::unique_ptr< EGSelectors::SafeTH1 > m_fPDFbins[2][IP_BINS][s_fnEtBinsHist][s_fnEtaBins][s_fnVariables]
static constexpr unsigned int s_fnEtBinsHist
std::vector< double > m_discHardCutQuadForPileupTransform
reference quadratic apr on disc for very hard cut; used by centrality transform
static constexpr unsigned int s_fnDiscEtBinsOneExtra
static constexpr unsigned int s_fnDiscEtBins
static const std::string s_fVariables[s_fnVariables]
std::vector< double > m_discLooseForPileupTransform4GeV
reference disc for a pileup independent loose menu; used by pileup transform - 4-7 GeV
std::vector< double > m_discHardCutSlopeForPileupTransform
reference slope on disc for very hard cut; used by pileup transform
static unsigned int getIpBin(double ip)
std::vector< int > m_cutSi
cut min on precision hits
bool m_useOneExtraHighETLHBin
use one extra bin for high ET LH
double evaluateLikelihood(const std::vector< double > &varVector, double et, double eta, double ip=0) const
double m_highETBinThreshold
ET threshold for using high ET cuts and bin.
double InterpolateCuts(const std::vector< double > &cuts, const std::vector< double > &cuts_4gev, double et, double eta) const
std::vector< int > m_cutBL
cut min on b-layer hits
static constexpr double s_fIpBounds[IP_BINS+1]
asg::AcceptInfo m_acceptInfo
Accept info.
std::vector< int > m_cutAmbiguity
do cut on ambiguity bit
std::vector< int > m_cutPi
cut min on pixel hits
std::vector< double > m_discHardCutQuadForPileupTransform4GeV
reference quadratic par on disc for very hard cut; used by centrality transform - 4-7 GeV
int m_cutPosition_ambiguity
The position of the ambiguity cut bit in the AcceptInfo return object.
int m_cutPositionTrackA0
The position of the d0 cut bit in the AcceptInfo return object.
void setBinning(const std::string &val)
Define the binning.
std::vector< double > m_cutLikelihoodPileupCorrection4GeV
pileup correction factor for cut on likelihood output, 4 GeV bin
std::vector< double > m_discLooseForPileupTransform
reference disc for a pileup independent loose menu; used by pileup transform
std::vector< double > m_cutA0
cut max on track d0 bit
std::vector< double > m_discHardCutForPileupTransform4GeV
reference disc for very hard cut; used by pileup transform - 4-7 GeV
asg::AcceptData accept() const
Return dummy accept with only info.
double calculate(LikeEnum::LHCalcVars_t &vars_struct) const
int m_cutPosition_NBlayer
The position of the NBlayer cut bit in the AcceptInfo return object.
std::vector< double > m_cutEoverPAtHighET
do cut on EoverP above HighETBinThreshold bit
std::string m_variableNames
variables to use in the LH
static unsigned int getLikelihoodEtHistBin(double eT)
Coarse Et binning. Used for the likelihood pdfs.
bool m_doRemoveTRTPIDAtHighEt
do remove TRTPID variable from likelihood at high Et (>80 GeV)
std::vector< double > m_cutLikelihood4GeV
cut on likelihood output, 4 GeV bin
int m_cutPosition_kinematic
The position of the kinematic cut bit in the AcceptInfo return object.
std::vector< double > m_cutWstotAtHighET
do cut on wstot above HighETBinThreshold bit
std::string m_pdfFileName
Name of the pdf file.
int loadVarHistograms(const std::string &vstr, TFile *pdfFile, unsigned int varIndex)
Load the variable histograms from the pdf file.
static constexpr unsigned int s_fnVariables
static unsigned int getLikelihoodEtaBin(double eta)
Eta binning for pdfs and discriminant cuts.
double m_discMaxForPileupTransform
max discriminant for which pileup transform is to be used
int m_cutPosition_LH
The position of the likelihood cut bit in the AcceptInfo return object.
StatusCode initialize()
Initialize this class.
int m_cutPositionWstotAtHighET
The position of the high ET wstot cut bit in the AcceptInfo return object.
std::vector< double > m_cutDeltaPhiRes
do cut on delta phi bit
bool m_doRemoveF3AtHighEt
do remove f3 variable from likelihood at high Et (>80 GeV)
int m_cutPositionEoverPAtHighET
The position of the high ET EoverP cut bit in the AcceptInfo return object.
unsigned int m_variableBitMask
The bitmask corresponding to the variables in the likelihood.
bool m_doCentralityTransform
do centrality-dependent transform on discriminant value
std::vector< double > m_discHardCutSlopeForPileupTransform4GeV
reference slope on disc for very hard cut; used by pileup transform
std::vector< double > m_cutLikelihoodPileupCorrection
pileup correction factor for cut on likelihood output
double m_pileupMaxForPileupTransform
max nvtx or mu to be used in pileup transform
const asg::AcceptInfo & getAcceptInfo() const
accesss to the accept info object
int m_cutPosition_NSilicon
The position of the NSilicon cut bit in the AcceptInfo return object.
double InterpolatePdfs(unsigned int s_or_b, unsigned int ipbin, double et, double eta, int bin, unsigned int var) const
static std::string getBinName(int etbin, int etabin, int ipbin, const std::string &iptype)
TElectronLikelihoodTool(const char *name="TElectronLikelihoodTool")
Standard constructor.
unsigned int getLikelihoodBitmask(const std::string &vars) const
double TransformLikelihoodOutput(double ps, double pb, double ip, double et, double eta) const
Apply a transform to zoom into the LH output peaks.
void setPDFFileName(const std::string &val)
Add an input file that holds the PDFs.
std::vector< double > m_cutLikelihood
cut on likelihood output
unsigned int getLikelihoodEtDiscBin(double eT, const bool isLHbinning) const
Fine Et binning. Used for the likelihood discriminant cuts.
static constexpr unsigned int s_fnEtaBins
int m_cutPositionTrackMatchPhiRes
The position of the deltaphi cut bit in the AcceptInfo return object.
bool m_doPileupTransform
do pileup-dependent transform on discriminant value
bool m_doSmoothBinInterpolation
do smooth interpolation between bins
std::vector< double > m_cutDeltaEta
do cut on delta eta bit
void setVariableNames(const std::string &val)
Define the variable names.
Class mimicking the AthMessaging class from the offline software.
Extra patterns decribing particle interation process.