File indexing completed on 2024-04-06 12:02:43
0001 #ifndef BTagEntry_H
0002 #define BTagEntry_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <string>
0019 #include <TF1.h>
0020 #include <TH1.h>
0021
0022
0023 class BTagEntry
0024 {
0025 public:
0026 enum OperatingPoint {
0027 OP_LOOSE=0,
0028 OP_MEDIUM=1,
0029 OP_TIGHT=2,
0030 OP_RESHAPING=3,
0031 };
0032 enum JetFlavor {
0033 FLAV_B=0,
0034 FLAV_C=1,
0035 FLAV_UDSG=2,
0036 };
0037 struct Parameters {
0038 OperatingPoint operatingPoint;
0039 std::string measurementType;
0040 std::string sysType;
0041 JetFlavor jetFlavor;
0042 float etaMin;
0043 float etaMax;
0044 float ptMin;
0045 float ptMax;
0046 float discrMin;
0047 float discrMax;
0048
0049
0050 Parameters(
0051 OperatingPoint op=OP_TIGHT,
0052 std::string measurement_type="comb",
0053 std::string sys_type="central",
0054 JetFlavor jf=FLAV_B,
0055 float eta_min=-99999.,
0056 float eta_max=99999.,
0057 float pt_min=0.,
0058 float pt_max=99999.,
0059 float discr_min=0.,
0060 float discr_max=99999.
0061 );
0062
0063 };
0064
0065 BTagEntry() {}
0066 BTagEntry(const std::string &csvLine);
0067 BTagEntry(const std::string &func, Parameters p);
0068 BTagEntry(const TF1* func, Parameters p);
0069 BTagEntry(const TH1* histo, Parameters p);
0070 ~BTagEntry() {}
0071 static std::string makeCSVHeader();
0072 std::string makeCSVLine() const;
0073 static std::string trimStr(std::string str);
0074
0075
0076 std::string formula;
0077 Parameters params;
0078
0079 };
0080
0081 #endif
0082
0083
0084 #ifndef BTagCalibration_H
0085 #define BTagCalibration_H
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 #include <map>
0102 #include <vector>
0103 #include <string>
0104 #include <istream>
0105 #include <ostream>
0106
0107
0108 class BTagCalibration
0109 {
0110 public:
0111 BTagCalibration() {}
0112 BTagCalibration(const std::string &tagger);
0113 BTagCalibration(const std::string &tagger, const std::string &filename);
0114 ~BTagCalibration() {}
0115
0116 std::string tagger() const {return tagger_;}
0117
0118 void addEntry(const BTagEntry &entry);
0119 const std::vector<BTagEntry>& getEntries(const BTagEntry::Parameters &par) const;
0120
0121 void readCSV(std::istream &s);
0122 void readCSV(const std::string &s);
0123 void makeCSV(std::ostream &s) const;
0124 std::string makeCSV() const;
0125
0126 protected:
0127 static std::string token(const BTagEntry::Parameters &par);
0128
0129 std::string tagger_;
0130 std::map<std::string, std::vector<BTagEntry> > data_;
0131
0132 };
0133
0134 #endif
0135
0136
0137 #ifndef BTagCalibrationReader_H
0138 #define BTagCalibrationReader_H
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 #include <memory>
0149 #include <string>
0150
0151
0152
0153 class BTagCalibrationReader
0154 {
0155 public:
0156 class BTagCalibrationReaderImpl;
0157
0158 BTagCalibrationReader() {}
0159 BTagCalibrationReader(BTagEntry::OperatingPoint op,
0160 const std::string & sysType="central",
0161 const std::vector<std::string> & otherSysTypes={});
0162
0163 void load(const BTagCalibration & c,
0164 BTagEntry::JetFlavor jf,
0165 const std::string & measurementType="comb");
0166
0167 double eval(BTagEntry::JetFlavor jf,
0168 float eta,
0169 float pt,
0170 float discr=0.) const;
0171
0172 double eval_auto_bounds(const std::string & sys,
0173 BTagEntry::JetFlavor jf,
0174 float eta,
0175 float pt,
0176 float discr=0.) const;
0177
0178 std::pair<float, float> min_max_pt(BTagEntry::JetFlavor jf,
0179 float eta,
0180 float discr=0.) const;
0181 protected:
0182 std::shared_ptr<BTagCalibrationReaderImpl> pimpl;
0183 };
0184
0185
0186 #endif
0187
0188