CMS 3D CMS Logo

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