CMS 3D CMS Logo

PerformancePayloadFromTFormula.cc
Go to the documentation of this file.
3 
5 
6 #include <boost/uuid/uuid.hpp>
7 #include <boost/uuid/uuid_generators.hpp>
8 #include <boost/uuid/uuid_io.hpp>
9 #include <boost/lexical_cast.hpp>
10 
11 #include <iostream>
12 using namespace std;
13 
15  boost::uuids::random_generator gen;
16 
17  for( std::vector<std::string>::const_iterator formula = pl.formulas().begin(); formula != pl.formulas().end(); ++formula ) {
18  boost::uuids::uuid uniqueFormulaId = gen();
19  const auto formulaUniqueName = boost::lexical_cast<std::string>(uniqueFormulaId);
20  //be sure not to add TFormula to ROOT's global list
21  auto temp = std::make_shared<TFormula>(formulaUniqueName.c_str(),formula->c_str(),false);
22  temp->Compile();
23  compiledFormulas_.emplace_back(std::move(temp));
24  }
25 }
26 
27 
29  BinningPointByMap p = _p;
30  //
31  // which formula to use?
32  //
33  if ( ! isInPayload(r,p) ) {
34  edm::LogError("PerformancePayloadFromTFormula") <<"Missing formula in conditions. Maybe code/conditions are inconsistent" << std::endl;
35  assert(false);
36  }
37 
38  const TFormula* formula = compiledFormulas_[resultPos(r)].get();
39  //
40  // prepare the vector to pass, order counts!!!
41  //
42  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
43 
44  // sorry, TFormulas just work up to dimension==4
45  Double_t values[4];
46  int i=0;
47  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it, ++i){
48  values[i] = p.value(*it);
49  }
50  //
51  return formula->EvalPar(values);
52 }
53 
55  BinningPointByMap p = _p;
56  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
57 
58  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
59  if (! p.isKeyAvailable(*it)) return false;
60  float v = p.value(*it);
61  int pos = limitPos(*it);
62  std::pair<float, float> limits = (pl.limits())[pos];
63  if (v<limits.first || v>limits.second) return false;
64  }
65  return true;
66 }
67 
69  // first, let's see if it is available at all
70  if (resultPos(res) == PerformancePayloadFromTFormula::InvalidPos) return false;
71 
72  if ( ! isOk(point)) return false;
73  return true;
74 }
75 
77  //
78  // which formula to use?
79  //
80  if (resultPos(res) == PerformancePayloadFromTFormula::InvalidPos) {
81  cout << "Warning: result not available!" << endl;
82  return;
83  }
84 
85 
86  const TFormula* formula =
87  compiledFormulas_[resultPos(res)].get();
88  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
89  // prepare the vector to pass, order counts!!!
90  //
91  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
92 
93  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
94  int pos = limitPos(*it);
95  std::pair<float, float> limits = (pl.limits())[pos];
96  cout << " Variable: " << *it << " with limits: " << "from: " << limits.first << " to: " << limits.second << endl;
97  }
98 
99 }
100 
float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const override
bool isKeyAvailable(BinningVariables::BinningVariablesType)
Definition: Electron.h:6
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
float value(BinningVariables::BinningVariablesType)
def gen(fragment, howMuch)
Production test section ####.
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
bool isOk(const BinningPointByMap &p) const
void printFormula(PerformanceResult::ResultType res) const
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