TIMBER  beta
Tree Interface for Making Binned Events with RDataFrame
BTagCalibrationStandalone.h
1 #ifndef BTagEntry_H
2 #define BTagEntry_H
3 
18 #include <string>
19 #include <TF1.h>
20 #include <TH1.h>
21 
22 
23 class BTagEntry
24 {
25 public:
26  enum OperatingPoint {
27  OP_LOOSE=0,
28  OP_MEDIUM=1,
29  OP_TIGHT=2,
30  OP_RESHAPING=3,
31  };
32  enum JetFlavor {
33  FLAV_B=0,
34  FLAV_C=1,
35  FLAV_UDSG=2,
36  };
37  struct Parameters {
38  OperatingPoint operatingPoint;
39  std::string measurementType;
40  std::string sysType;
41  JetFlavor jetFlavor;
42  float etaMin;
43  float etaMax;
44  float ptMin;
45  float ptMax;
46  float discrMin;
47  float discrMax;
48 
49  // default constructor
50  Parameters(
51  OperatingPoint op=OP_TIGHT,
52  std::string measurement_type="comb",
53  std::string sys_type="central",
54  JetFlavor jf=FLAV_B,
55  float eta_min=-99999.,
56  float eta_max=99999.,
57  float pt_min=0.,
58  float pt_max=99999.,
59  float discr_min=0.,
60  float discr_max=99999.
61  );
62 
63  };
64 
65  BTagEntry() {}
66  BTagEntry(const std::string &csvLine);
67  BTagEntry(const std::string &func, Parameters p);
68  BTagEntry(const TF1* func, Parameters p);
69  BTagEntry(const TH1* histo, Parameters p);
70  ~BTagEntry() {}
71  static std::string makeCSVHeader();
72  std::string makeCSVLine() const;
73  static std::string trimStr(std::string str);
74 
75  // public, no getters needed
76  std::string formula;
77  Parameters params;
78 
79 };
80 
81 #endif // BTagEntry_H
82 
83 
84 #ifndef BTagCalibration_H
85 #define BTagCalibration_H
86 
101 #include <map>
102 #include <vector>
103 #include <string>
104 #include <istream>
105 #include <ostream>
106 
107 
109 {
110 public:
111  BTagCalibration() {}
112  BTagCalibration(const std::string &tagger);
113  BTagCalibration(const std::string &tagger, const std::string &filename);
114  ~BTagCalibration() {}
115 
116  std::string tagger() const {return tagger_;}
117 
118  void addEntry(const BTagEntry &entry);
119  const std::vector<BTagEntry>& getEntries(const BTagEntry::Parameters &par) const;
120 
121  void readCSV(std::istream &s);
122  void readCSV(const std::string &s);
123  void makeCSV(std::ostream &s) const;
124  std::string makeCSV() const;
125 
126 protected:
127  static std::string token(const BTagEntry::Parameters &par);
128 
129  std::string tagger_;
130  std::map<std::string, std::vector<BTagEntry> > data_;
131 
132 };
133 
134 #endif // BTagCalibration_H
135 
136 
137 #ifndef BTagCalibrationReader_H
138 #define BTagCalibrationReader_H
139 
148 #include <memory>
149 #include <string>
150 
151 
152 
154 {
155 public:
157 
159  BTagCalibrationReader(BTagEntry::OperatingPoint op,
160  const std::string & sysType="central",
161  const std::vector<std::string> & otherSysTypes={});
162 
163  void load(const BTagCalibration & c,
164  BTagEntry::JetFlavor jf,
165  const std::string & measurementType="comb");
166 
167  double eval(BTagEntry::JetFlavor jf,
168  float eta,
169  float pt,
170  float discr=0.) const;
171 
172  double eval_auto_bounds(const std::string & sys,
173  BTagEntry::JetFlavor jf,
174  float eta,
175  float pt,
176  float discr=0.) const;
177 
178  std::pair<float, float> min_max_pt(BTagEntry::JetFlavor jf,
179  float eta,
180  float discr=0.) const;
181 protected:
182  std::shared_ptr<BTagCalibrationReaderImpl> pimpl;
183 };
184 
185 
186 #endif // BTagCalibrationReader_H
187 
188 
Definition: BTagCalibrationStandalone.h:153
Definition: BTagCalibrationStandalone.cpp:369
Definition: BTagCalibrationStandalone.h:108
Definition: BTagCalibrationStandalone.h:23
Definition: BTagCalibrationStandalone.h:37