00001 #ifndef BTagEntry_H
00002 #define BTagEntry_H
00003
00018 #include <string>
00019 #include <TF1.h>
00020 #include <TH1.h>
00021
00022
00023 class BTagEntry
00024 {
00025 public:
00026 enum OperatingPoint {
00027 OP_LOOSE=0,
00028 OP_MEDIUM=1,
00029 OP_TIGHT=2,
00030 OP_RESHAPING=3,
00031 };
00032 enum JetFlavor {
00033 FLAV_B=0,
00034 FLAV_C=1,
00035 FLAV_UDSG=2,
00036 };
00037 struct Parameters {
00038 OperatingPoint operatingPoint;
00039 std::string measurementType;
00040 std::string sysType;
00041 JetFlavor jetFlavor;
00042 float etaMin;
00043 float etaMax;
00044 float ptMin;
00045 float ptMax;
00046 float discrMin;
00047 float discrMax;
00048
00049
00050 Parameters(
00051 OperatingPoint op=OP_TIGHT,
00052 std::string measurement_type="comb",
00053 std::string sys_type="central",
00054 JetFlavor jf=FLAV_B,
00055 float eta_min=-99999.,
00056 float eta_max=99999.,
00057 float pt_min=0.,
00058 float pt_max=99999.,
00059 float discr_min=0.,
00060 float discr_max=99999.
00061 );
00062
00063 };
00064
00065 BTagEntry() {}
00066 BTagEntry(const std::string &csvLine);
00067 BTagEntry(const std::string &func, Parameters p);
00068 BTagEntry(const TF1* func, Parameters p);
00069 BTagEntry(const TH1* histo, Parameters p);
00070 ~BTagEntry() {}
00071 static std::string makeCSVHeader();
00072 std::string makeCSVLine() const;
00073 static std::string trimStr(std::string str);
00074
00075
00076 std::string formula;
00077 Parameters params;
00078
00079 };
00080
00081 #endif // BTagEntry_H
00082
00083
00084 #ifndef BTagCalibration_H
00085 #define BTagCalibration_H
00086
00101 #include <map>
00102 #include <vector>
00103 #include <string>
00104 #include <istream>
00105 #include <ostream>
00106
00107
00108 class BTagCalibration
00109 {
00110 public:
00111 BTagCalibration() {}
00112 BTagCalibration(const std::string &tagger);
00113 BTagCalibration(const std::string &tagger, const std::string &filename);
00114 ~BTagCalibration() {}
00115
00116 std::string tagger() const {return tagger_;}
00117
00118 void addEntry(const BTagEntry &entry);
00119 const std::vector<BTagEntry>& getEntries(const BTagEntry::Parameters &par) const;
00120
00121 void readCSV(std::istream &s);
00122 void readCSV(const std::string &s);
00123 void makeCSV(std::ostream &s) const;
00124 std::string makeCSV() const;
00125
00126 protected:
00127 static std::string token(const BTagEntry::Parameters &par);
00128
00129 std::string tagger_;
00130 std::map<std::string, std::vector<BTagEntry> > data_;
00131
00132 };
00133
00134 #endif // BTagCalibration_H
00135
00136
00137 #ifndef BTagCalibrationReader_H
00138 #define BTagCalibrationReader_H
00139
00148 #include <memory>
00149 #include <string>
00150
00151
00152
00153 class BTagCalibrationReader
00154 {
00155 public:
00156 class BTagCalibrationReaderImpl;
00157
00158 BTagCalibrationReader() {}
00159 BTagCalibrationReader(BTagEntry::OperatingPoint op,
00160 const std::string & sysType="central",
00161 const std::vector<std::string> & otherSysTypes={});
00162
00163 void load(const BTagCalibration & c,
00164 BTagEntry::JetFlavor jf,
00165 const std::string & measurementType="comb");
00166
00167 double eval(BTagEntry::JetFlavor jf,
00168 float eta,
00169 float pt,
00170 float discr=0.) const;
00171
00172 double eval_auto_bounds(const std::string & sys,
00173 BTagEntry::JetFlavor jf,
00174 float eta,
00175 float pt,
00176 float discr=0.) const;
00177
00178 std::pair<float, float> min_max_pt(BTagEntry::JetFlavor jf,
00179 float eta,
00180 float discr=0.) const;
00181 protected:
00182 std::shared_ptr<BTagCalibrationReaderImpl> pimpl;
00183 };
00184
00185
00186 #endif // BTagCalibrationReader_H
00187
00188