CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BTagCalibrationReader.cc
Go to the documentation of this file.
2 
5  std::string measurementType,
6  std::string sysType):
7  params(BTagEntry::Parameters(op, measurementType, sysType)),
8  useAbsEta(true)
9 {
10  setupTmpData(c);
11 }
12 
14  float eta,
15  float pt,
16  float discr) const
17 {
18  bool use_discr = (params.operatingPoint == BTagEntry::OP_RESHAPING);
19  if (useAbsEta[jf] && eta < 0) {
20  eta = -eta;
21  }
22 
23  // search linearly through eta, pt and discr ranges and eval
24  // future: find some clever data structure based on intervals
25  const std::vector<TmpEntry> &entries = tmpData_.at(jf);
26  for (unsigned i=0; i<entries.size(); ++i) {
27  const BTagCalibrationReader::TmpEntry &e = entries.at(i);
28  if (
29  e.etaMin <= eta && eta < e.etaMax // find eta
30  && e.ptMin <= pt && pt < e.ptMax // check pt
31  ){
32  if (use_discr) { // discr. reshaping?
33  if (e.discrMin <= discr && discr < e.discrMax) { // check discr
34  return e.func.Eval(discr);
35  }
36  } else {
37  return e.func.Eval(pt);
38  }
39  }
40  }
41 
42  return 0.; // default value
43 }
44 
46 {
47  useAbsEta = std::vector<bool>(4, true);
48  const std::vector<BTagEntry> &entries = c->getEntries(params);
49  for (unsigned i=0; i<entries.size(); ++i) {
50  const BTagEntry &be = entries[i];
52  te.etaMin = be.params.etaMin;
53  te.etaMax = be.params.etaMax;
54  te.ptMin = be.params.ptMin;
55  te.ptMax = be.params.ptMax;
56  te.discrMin = be.params.discrMin;
57  te.discrMax = be.params.discrMax;
58 
60  te.func = TF1("", be.formula.c_str(),
62  } else {
63  te.func = TF1("", be.formula.c_str(),
64  be.params.ptMin, be.params.ptMax);
65  }
66 
67  tmpData_[be.params.jetFlavor].push_back(te);
68  if (te.etaMin < 0) {
69  useAbsEta[be.params.jetFlavor] = false;
70  }
71  }
72 }
int i
Definition: DBlmapReader.cc:9
JetFlavor jetFlavor
Definition: BTagEntry.h:42
const std::vector< BTagEntry > & getEntries(const BTagEntry::Parameters &par) const
vector< ParameterSet > Parameters
OperatingPoint operatingPoint
Definition: BTagEntry.h:39
std::vector< bool > useAbsEta
std::string formula
Definition: BTagEntry.h:78
OperatingPoint
Definition: BTagEntry.h:27
double eval(BTagEntry::JetFlavor jf, float eta, float pt, float discr=0.) const
Parameters params
Definition: BTagEntry.h:79
std::map< BTagEntry::JetFlavor, std::vector< TmpEntry > > tmpData_
void setupTmpData(const BTagCalibration *c)
tuple discr
Definition: listHistos.py:51
BTagEntry::Parameters params