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  boost::shared_ptr<TFormula> temp(new TFormula(formulaUniqueName.c_str(),formula->c_str()));
21  temp->Compile();
22  compiledFormulas_.push_back(temp);
23  }
24 }
25 
26 
28  BinningPointByMap p = _p;
29  //
30  // which formula to use?
31  //
32  if ( ! isInPayload(r,p) ) {
33  edm::LogError("PerformancePayloadFromTFormula") <<"Missing formula in conditions. Maybe code/conditions are inconsistent" << std::endl;
34  assert(false);
35  }
36  // nice, what to do here???
37  const boost::shared_ptr<TFormula>& formula = compiledFormulas_[resultPos(r)];
38  //
39  // prepare the vector to pass, order counts!!!
40  //
41  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
42 
43  // sorry, TFormulas just work up to dimension==4
44  Double_t values[4];
45  int i=0;
46  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it, ++i){
47  values[i] = p.value(*it);
48  }
49  //
50  // i need a non const version #$%^
51  // Note, in current implementation of TFormula EvalPar should be
52  // thread safe as it does nothing more than call a function
53  // through a function pointer which is stateless. In spite of the
54  // fact that it is not const.
55  return formula->EvalPar(values);
56 }
57 
59  BinningPointByMap p = _p;
60  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
61 
62  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
63  if (! p.isKeyAvailable(*it)) return false;
64  float v = p.value(*it);
65  int pos = limitPos(*it);
66  std::pair<float, float> limits = (pl.limits())[pos];
67  if (v<limits.first || v>limits.second) return false;
68  }
69  return true;
70 }
71 
73  // first, let's see if it is available at all
74  if (resultPos(res) == PerformancePayloadFromTFormula::InvalidPos) return false;
75 
76  if ( ! isOk(point)) return false;
77  return true;
78 }
79 
81  //
82  // which formula to use?
83  //
84  if (resultPos(res) == PerformancePayloadFromTFormula::InvalidPos) {
85  cout << "Warning: result not available!" << endl;
86  return;
87  }
88 
89  // nice, what to do here???
90  const boost::shared_ptr<TFormula>& formula =
91  compiledFormulas_[resultPos(res)];
92  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
93  // prepare the vector to pass, order counts!!!
94  //
95  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
96 
97  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
98  int pos = limitPos(*it);
99  std::pair<float, float> limits = (pl.limits())[pos];
100  cout << " Variable: " << *it << " with limits: " << "from: " << limits.first << " to: " << limits.second << endl;
101  }
102 
103 }
104 
bool isKeyAvailable(BinningVariables::BinningVariablesType)
Definition: Electron.h:4
virtual bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const
float value(BinningVariables::BinningVariablesType)
def gen(fragment, howMuch)
Production test section ####.
float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:96
bool isOk(const BinningPointByMap &p) const
void printFormula(PerformanceResult::ResultType res) const
*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