CMS 3D CMS Logo

PerformancePayloadFromTFormula.cc
Go to the documentation of this file.
4 
6 
7 #include <iostream>
8 using namespace std;
9 
11  for (std::vector<std::string>::const_iterator formula = pl.formulas().begin(); formula != pl.formulas().end();
12  ++formula) {
13  const auto formulaUniqueName = edm::createGlobalIdentifier();
14  //be sure not to add TFormula to ROOT's global list
15  auto temp = std::make_shared<TFormula>(formulaUniqueName.c_str(), formula->c_str(), false);
16  temp->Compile();
17  compiledFormulas_.emplace_back(std::move(temp));
18  }
19 }
20 
22  BinningPointByMap p = _p;
23  //
24  // which formula to use?
25  //
26  if (!isInPayload(r, p)) {
27  edm::LogError("PerformancePayloadFromTFormula")
28  << "Missing formula in conditions. Maybe code/conditions are inconsistent" << std::endl;
29  assert(false);
30  }
31 
32  const TFormula* formula = compiledFormulas_[resultPos(r)].get();
33  //
34  // prepare the vector to pass, order counts!!!
35  //
36  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
37 
38  // sorry, TFormulas just work up to dimension==4
39  Double_t values[4];
40  int i = 0;
41  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it, ++i) {
42  values[i] = p.value(*it);
43  }
44  //
45  return formula->EvalPar(values);
46 }
47 
49  BinningPointByMap p = _p;
50  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
51 
52  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
53  if (!p.isKeyAvailable(*it))
54  return false;
55  float v = p.value(*it);
56  int pos = limitPos(*it);
57  std::pair<float, float> limits = (pl.limits())[pos];
58  if (v < limits.first || v > limits.second)
59  return false;
60  }
61  return true;
62 }
63 
65  const BinningPointByMap& point) const {
66  // first, let's see if it is available at all
68  return false;
69 
70  if (!isOk(point))
71  return false;
72  return true;
73 }
74 
76  //
77  // which formula to use?
78  //
80  cout << "Warning: result not available!" << endl;
81  return;
82  }
83 
84  const TFormula* formula = compiledFormulas_[resultPos(res)].get();
85  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
86  // prepare the vector to pass, order counts!!!
87  //
88  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
89 
90  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
91  int pos = limitPos(*it);
92  std::pair<float, float> limits = (pl.limits())[pos];
93  cout << " Variable: " << *it << " with limits: "
94  << "from: " << limits.first << " to: " << limits.second << endl;
95  }
96 }
97 
Log< level::Error, false > LogError
assert(be >=bs)
Definition: Electron.h:6
void printFormula(PerformanceResult::ResultType res) const
std::string createGlobalIdentifier(bool binary=false)
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const override
def move(src, dest)
Definition: eostools.py:511
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
bool isOk(const BinningPointByMap &p) const