CMS 3D CMS Logo

PerformancePayloadFromBinnedTFormula.cc
Go to the documentation of this file.
2 
5 
7 
8 #include <iostream>
9 using namespace std;
10 
12  for (unsigned int t = 0; t < pls.size(); ++t) {
13  std::vector<std::shared_ptr<TFormula> > temp;
14  for (unsigned int i = 0; i < (pls[t].formulas()).size(); ++i) {
15  const auto formulaUniqueName = edm::createGlobalIdentifier();
17  std::shared_ptr<TFormula> tt(new TFormula(formulaUniqueName.c_str(), tmp.formulas()[i].c_str()));
18  tt->Compile();
19  temp.push_back(tt);
20  }
21  compiledFormulas_.push_back(temp);
22  }
23 }
24 
26  const BinningPointByMap& p) const {
27  //
28  // chooses the correct rectangular region
29  //
30  if (!isInPayload(r, p)) {
31  throw cms::Exception("MalformedPerfPayload") << "Requested performance data not available!";
32  }
33  unsigned int region;
34  bool ok = isOk(p, region);
35  if (ok == false) {
36  throw cms::Exception("MalformedPerfPayload") << "Requested variable does not match internal structure!";
37  }
38 
39  return compiledFormulas_[region][resultPos(r)];
40 }
41 
43  const BinningPointByMap& _p) const {
44  BinningPointByMap p = _p;
45  //
46  // which formula to use?
47  //
48  if (!isInPayload(r, p))
50 
51  // nice, what to do here???
52  // TFormula * formula = compiledFormulas_[resultPos(r)];
53  //
54 
55  const std::shared_ptr<TFormula>& formula = getFormula(r, p);
56 
57  // prepare the vector to pass, order counts!!!
58  //
59  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
60 
61  // sorry, TFormulas just work up to dimension==4
62  Double_t values[4];
63  int i = 0;
64  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it, ++i) {
65  values[i] = p.value(*it);
66  }
67  //
68  // i need a non const version
69  // Note, in current implementation of TFormula EvalPar should be
70  // thread safe as it does nothing more than call a function
71  // through a function pointer which is stateless. In spite of the
72  // fact that it is not const.
73  return formula->EvalPar(values);
74 }
75 
76 bool PerformancePayloadFromBinnedTFormula::isOk(const BinningPointByMap& _p, unsigned int& whichone) const {
77  BinningPointByMap p = _p;
78  //
79  // change: look on whether a single rectangularr region matches
80  //
81  for (unsigned int ti = 0; ti < pls.size(); ++ti) {
82  bool result = true;
83  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
84  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
85  //
86  // now looking into a single payload
87  //
88  if (!p.isKeyAvailable(*it))
89  return false;
90  float v = p.value(*it);
91  int pos = limitPos(*it);
92  std::pair<float, float> limits = (pls[ti].limits())[pos];
93  if (v < limits.first || v > limits.second)
94  result = false;
95  }
96  if (result == true) {
97  whichone = ti;
98  return true;
99  }
100  }
101  whichone = 9999;
102  return false;
103 }
104 
106  const BinningPointByMap& point) const {
107  // first, let's see if it is available at all
109  return false;
110  unsigned int whocares;
111  if (!isOk(point, whocares))
112  return false;
113  return true;
114 }
115 
117  const BinningPointByMap& point) const {
118  //
119  // which formula to use?
120  //
122  cout << "Warning: result not available!" << endl;
123  }
124 
125  // nice, what to do here???
126  const std::shared_ptr<TFormula>& formula = getFormula(res, point);
127  unsigned int whichone;
128  isOk(point, whichone);
129  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
130  // prepare the vector to pass, order counts!!!
131  //
132  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
133 
134  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
135  int pos = limitPos(*it);
136  std::pair<float, float> limits = (pls[whichone].limits())[pos];
137  cout << " Variable: " << *it << " with limits: "
138  << "from: " << limits.first << " to: " << limits.second << endl;
139  }
140 }
141 
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
static const float InvalidResult
Definition: Electron.h:6
Definition: TTTypes.h:54
const std::shared_ptr< TFormula > & getFormula(PerformanceResult::ResultType, const BinningPointByMap &) const
std::string createGlobalIdentifier(bool binary=false)
float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const override
bool isOk(const BinningPointByMap &p, unsigned int &) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
void printFormula(PerformanceResult::ResultType res, const BinningPointByMap &) const
tmp
align.sh
Definition: createJobs.py:716
*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