ATLAS Offline Software
BTaggingSelectionTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CPBTAGGINGSELECTIONTOOL_H
6 #define CPBTAGGINGSELECTIONTOOL_H
7 
10 
11 #include "AsgTools/AsgTool.h"
14 #include "TFile.h"
15 #include "TSpline.h"
16 #include "TVector.h"
17 #include "TMatrixD.h"
18 #include <string>
19 #include <set>
20 #include <vector>
21 #include <map>
22 
24  public virtual IBTaggingSelectionTool,
25  public virtual IAsgSelectionTool {
27 
30 
31  public:
33  BTaggingSelectionTool( const std::string& name );
34  StatusCode initialize() override;
35 
37  virtual asg::AcceptData accept( const xAOD::IParticle* p ) const override;
38  virtual asg::AcceptData accept( const xAOD::Jet& jet ) const override;
39 
41  virtual asg::AcceptData accept(double /* jet pt */, double /* jet eta */, double /* tag_weight */ ) const override;
42  virtual asg::AcceptData accept(double /* jet pt */, double /* jet eta*/ , double /* taggerWeight_b */, double /* taggerWeight_c */) const override;
43  virtual asg::AcceptData accept(double /* jet pt */, double /* jet eta */, double /* dl1pb */, double /* dl1pc */, double /* dl1pu */) const override;
44  virtual asg::AcceptData accept(double /* jet pt */, double /* jet eta */, double /* dl1pb */, double /* dl1pc */, double /* dl1pu */, double /* dl1ptau */) const override;
45 
48  virtual int getQuantile( const xAOD::IParticle* ) const override;
49  virtual int getQuantile( const xAOD::Jet& ) const override;
50  virtual int getQuantile( double /* jet pt */, double /* jet eta */, double /* tag weight */ ) const override;
51  virtual int getQuantile( double /*pT*/, double /*eta*/, double /*tag_weight_b*/, double /*tag_weight_c*/ ) const override;
52 
53  virtual CP::CorrectionCode getCutValue(double /* jet pt */, double & cutval) const override;
54  //1D tagging wrapper
55  virtual CP::CorrectionCode getTaggerWeight( const xAOD::Jet& jet, double & tagweight) const override;
56  virtual CP::CorrectionCode getTaggerWeight( double pb, double pc, double pu, double & tagweight) const override;
57  virtual CP::CorrectionCode getTaggerWeight( double pb, double pc, double pu, double & tagweight, double ptau) const override;
58 
59  //flexibility for Continuous2D
60  virtual CP::CorrectionCode getTaggerWeight( const xAOD::Jet& jet, double & weight ,bool getCTagW) const override;
61  virtual CP::CorrectionCode getTaggerWeight( double /* dl1pb */, double /* dl1pc */ , double /* dl1pu */, double & weight, bool getCTagW , double /* dl1ptau */ = 0.) const override;
62  const asg::AcceptInfo& getAcceptInfo( ) const override {return m_acceptinfo;}
63 private:
65  virtual bool checkRange( double /* jet pt */, double /* jet eta */ , asg::AcceptData& ) const;
66  //fill the spline or vector that store the cut values for a particular working point
67  void InitializeTaggerVariables(std::string taggerName,std::string OP, TSpline3 *spline, TVector *constcut, double &fraction);
68 
69  bool m_initialised = false;
71  bool m_StoreNConstituents = false;
72  bool m_continuous = false; //Continuous1D
73  bool m_continuous2D = false; //Continuous2D
74  bool m_useCTag = false; //use c-tagging or b-tagging in 1D
77 
78  double m_maxEta;
79  double m_minPt;
80  double m_maxRangePt;
81 
82  std::string m_CutFileName;
83  std::string m_taggerName;
84  std::string m_OP;
85  std::string m_jetAuthor;
87  std::string m_wps_raw;
88 
89  TFile *m_inf;
90  std::vector<double> m_continuouscuts;
91 
93  std::string name;
94  double fraction_b;
95  double fraction_c;
96  double fraction_tau;
97  TSpline3* spline;
98  TVector* constcut;
99  TMatrixD* cuts2D; //useful only in Continuous2D
100  std::vector<int> benchmarks; //useful only in Continuous WP. list of bins that are considered as tagged.
101 
102  double get2DCutValue(int row, int column) const{
103  TMatrixD& cuts2D_safe ATLAS_THREAD_SAFE = *(this->cuts2D);
104  double cut = cuts2D_safe(row,column);
105  return cut;
106  }
107 
108  };
109 
111 
114 
115  Tagger SetTaggerEnum(const std::string& taggerName){
116  if(taggerName.find("DL1") != std::string::npos) return Tagger::DL1;
117  else if(taggerName.find("GN1") != std::string::npos) return Tagger::GN1;
118  else if(taggerName.find("GN2") != std::string::npos) return Tagger::GN2;
119  else if(taggerName == "MV2c10") return Tagger::MV2c10;
120  else
121  ATH_MSG_ERROR("Tagger Name NOT supported.");
122  return Tagger::UNKNOWN;
123  };
124  //get from the CDI file the taggers cut object(that holds the definition of cut values)
125  //and flaovur fraction (for DL1 tagger) and store them in the right taggerproperties struct
126  void ExtractTaggerProperties(taggerproperties& tagger, const std::string& taggerName, const std::string& OP);
127 
128  std::vector<std::string> split (const std::string &input, const char &delimiter);
129 
130 };
131 
132 #endif // CPBTAGGINGSELECTIONTOOL_H
BTaggingSelectionTool::m_StoreNConstituents
bool m_StoreNConstituents
Definition: BTaggingSelectionTool.h:71
python.StoreID.UNKNOWN
int UNKNOWN
Definition: StoreID.py:16
query_example.row
row
Definition: query_example.py:24
BTaggingSelectionTool::taggerproperties::fraction_b
double fraction_b
Definition: BTaggingSelectionTool.h:94
BTaggingSelectionTool::m_wps_raw
std::string m_wps_raw
Definition: BTaggingSelectionTool.h:87
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
BTaggingSelectionTool::UNKNOWN
@ UNKNOWN
Definition: BTaggingSelectionTool.h:112
BTaggingSelectionTool::m_continuous
bool m_continuous
Definition: BTaggingSelectionTool.h:72
BTaggingSelectionTool::initialize
StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: BTaggingSelectionTool.cxx:59
BTaggingSelectionTool::m_maxRangePt
double m_maxRangePt
Definition: BTaggingSelectionTool.h:80
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
BTaggingSelectionTool::m_initialised
bool m_initialised
Definition: BTaggingSelectionTool.h:69
keylayer_zslicemap.pb
pb
Definition: keylayer_zslicemap.py:188
BTagging.h
BTaggingSelectionTool::MV2c10
@ MV2c10
Definition: BTaggingSelectionTool.h:112
ASG_TOOL_CLASS2
#define ASG_TOOL_CLASS2(CLASSNAME, INT1, INT2)
Definition: AsgToolMacros.h:77
BTaggingSelectionTool::tagWeight_member_t
double(xAOD::BTagging::* tagWeight_member_t)() const
Definition: BTaggingSelectionTool.h:26
BTaggingSelectionTool::m_continuous2D
bool m_continuous2D
Definition: BTaggingSelectionTool.h:73
BTaggingSelectionTool::InitializeTaggerVariables
void InitializeTaggerVariables(std::string taggerName, std::string OP, TSpline3 *spline, TVector *constcut, double &fraction)
BTaggingSelectionTool::m_continuouscuts
std::vector< double > m_continuouscuts
Definition: BTaggingSelectionTool.h:90
BTaggingSelectionTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *p) const override
Get the decision using a generic IParticle pointer.
Definition: BTaggingSelectionTool.cxx:377
DeMoUpdate.column
dictionary column
Definition: DeMoUpdate.py:1110
BTaggingSelectionTool::m_taggerEnum
Tagger m_taggerEnum
Definition: BTaggingSelectionTool.h:113
BTaggingSelectionTool::m_jetAuthor
std::string m_jetAuthor
Definition: BTaggingSelectionTool.h:85
IAsgSelectionTool
Definition: IAsgSelectionTool.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
IAsgSelectionTool.h
BTaggingSelectionTool::m_ErrorOnTagWeightFailure
bool m_ErrorOnTagWeightFailure
Definition: BTaggingSelectionTool.h:70
BTaggingSelectionTool::m_acceptinfo
asg::AcceptInfo m_acceptinfo
Object used to store the last decision.
Definition: BTaggingSelectionTool.h:76
BTaggingSelectionTool::taggerproperties::benchmarks
std::vector< int > benchmarks
Definition: BTaggingSelectionTool.h:100
BTaggingSelectionTool::m_minPt
double m_minPt
Definition: BTaggingSelectionTool.h:79
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
BTaggingSelectionTool::m_maxEta
double m_maxEta
Definition: BTaggingSelectionTool.h:78
BTaggingSelectionTool::m_useCTag
bool m_useCTag
Definition: BTaggingSelectionTool.h:74
BTaggingSelectionTool::split
std::vector< std::string > split(const std::string &input, const char &delimiter)
Definition: BTaggingSelectionTool.cxx:756
BTaggingSelectionTool::taggerproperties::name
std::string name
Definition: BTaggingSelectionTool.h:93
python.AthDsoLogger.delimiter
delimiter
Definition: AthDsoLogger.py:71
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
BTaggingSelectionTool::getTaggerWeight
virtual CP::CorrectionCode getTaggerWeight(const xAOD::Jet &jet, double &tagweight) const override
Definition: BTaggingSelectionTool.cxx:244
IBTaggingSelectionTool.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
asg::AcceptInfo
Definition: AcceptInfo.h:28
BTaggingSelectionTool
Definition: BTaggingSelectionTool.h:25
IBTaggingSelectionTool
Definition: IBTaggingSelectionTool.h:14
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
BTaggingSelectionTool::m_tagger
taggerproperties m_tagger
Definition: BTaggingSelectionTool.h:110
BTaggingSelectionTool::taggerproperties::get2DCutValue
double get2DCutValue(int row, int column) const
Definition: BTaggingSelectionTool.h:102
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
BTaggingSelectionTool::m_taggerName
std::string m_taggerName
Definition: BTaggingSelectionTool.h:83
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
BTaggingSelectionTool::m_ContinuousBenchmarks
std::string m_ContinuousBenchmarks
Definition: BTaggingSelectionTool.h:86
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
BTaggingSelectionTool::m_CutFileName
std::string m_CutFileName
Definition: BTaggingSelectionTool.h:82
BTaggingSelectionTool::Tagger
Tagger
Definition: BTaggingSelectionTool.h:112
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
BTaggingSelectionTool::GN2
@ GN2
Definition: BTaggingSelectionTool.h:112
BTaggingSelectionTool::taggerproperties::fraction_c
double fraction_c
Definition: BTaggingSelectionTool.h:95
BTaggingSelectionTool::GN1
@ GN1
Definition: BTaggingSelectionTool.h:112
CheckAppliedSFs.pu
pu
Definition: CheckAppliedSFs.py:311
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
BTaggingSelectionTool::SetTaggerEnum
Tagger SetTaggerEnum(const std::string &taggerName)
Definition: BTaggingSelectionTool.h:115
BTaggingSelectionTool::taggerproperties
Definition: BTaggingSelectionTool.h:92
BTaggingSelectionTool::getQuantile
virtual int getQuantile(const xAOD::IParticle *) const override
Decide in which quantile of the tag weight distribution the jet belongs (continuous tagging) The retu...
Definition: BTaggingSelectionTool.cxx:573
BTaggingSelectionTool::taggerproperties::spline
TSpline3 * spline
Definition: BTaggingSelectionTool.h:97
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
BTaggingSelectionTool::BTaggingSelectionTool
BTaggingSelectionTool(const std::string &name)
Create a proper constructor for Athena.
Definition: BTaggingSelectionTool.cxx:42
BTaggingSelectionTool::ExtractTaggerProperties
void ExtractTaggerProperties(taggerproperties &tagger, const std::string &taggerName, const std::string &OP)
Definition: BTaggingSelectionTool.cxx:193
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
BTaggingSelectionTool::taggerproperties::cuts2D
TMatrixD * cuts2D
Definition: BTaggingSelectionTool.h:99
BTaggingSelectionTool::taggerproperties::constcut
TVector * constcut
Definition: BTaggingSelectionTool.h:98
BTaggingSelectionTool::m_inf
TFile * m_inf
Definition: BTaggingSelectionTool.h:89
BTaggingSelectionTool::getAcceptInfo
const asg::AcceptInfo & getAcceptInfo() const override
Declare the interface ID for this pure-virtual interface class to the Athena framework.
Definition: BTaggingSelectionTool.h:62
BTaggingSelectionTool::getCutValue
virtual CP::CorrectionCode getCutValue(double, double &cutval) const override
Definition: BTaggingSelectionTool.cxx:725
AsgTool.h
asg::AcceptData
Definition: AcceptData.h:30
checker_macros.h
Define macros for attributes used to control the static checker.
BTaggingSelectionTool::checkRange
virtual bool checkRange(double, double, asg::AcceptData &) const
Helper function that decides whether a jet belongs to the correct jet selection for b-tagging.
Definition: BTaggingSelectionTool.cxx:707
BTaggingSelectionTool::m_OP
std::string m_OP
Definition: BTaggingSelectionTool.h:84
BTaggingSelectionTool::DL1
@ DL1
Definition: BTaggingSelectionTool.h:112
python.SystemOfUnits.pc
float pc
Definition: SystemOfUnits.py:99
BTaggingSelectionTool::taggerproperties::fraction_tau
double fraction_tau
Definition: BTaggingSelectionTool.h:96