test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PerformancePayloadFromTFormula.cc
Go to the documentation of this file.
2 
4 
5 #include <boost/uuid/uuid.hpp>
6 #include <boost/uuid/uuid_generators.hpp>
7 #include <boost/uuid/uuid_io.hpp>
8 #include <boost/lexical_cast.hpp>
9 
10 #include <iostream>
11 using namespace std;
12 
14  boost::uuids::random_generator gen;
15 
16  for( std::vector<std::string>::const_iterator formula = pl.formulas().begin(); formula != pl.formulas().end(); ++formula ) {
17  boost::uuids::uuid uniqueFormulaId = gen();
18  const auto formulaUniqueName = boost::lexical_cast<std::string>(uniqueFormulaId);
19  boost::shared_ptr<TFormula> temp(new TFormula(formulaUniqueName.c_str(),formula->c_str()));
20  temp->Compile();
21  compiledFormulas_.push_back(temp);
22  }
23 }
24 
25 
27  BinningPointByMap p = _p;
28  //
29  // which formula to use?
30  //
31  if (! isInPayload(r,p)) return PerformancePayload::InvalidResult;
32 
33  // nice, what to do here???
34  const boost::shared_ptr<TFormula>& formula = compiledFormulas_[resultPos(r)];
35  //
36  // prepare the vector to pass, order counts!!!
37  //
38  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
39 
40  // sorry, TFormulas just work up to dimension==4
41  Double_t values[4];
42  int i=0;
43  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it, ++i){
44  values[i] = p.value(*it);
45  }
46  //
47  // i need a non const version #$%^
48  // Note, in current implementation of TFormula EvalPar should be
49  // thread safe as it does nothing more than call a function
50  // through a function pointer which is stateless. In spite of the
51  // fact that it is not const.
52  return formula->EvalPar(values);
53 }
54 
56  BinningPointByMap p = _p;
57  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
58 
59  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
60  if (! p.isKeyAvailable(*it)) return false;
61  float v = p.value(*it);
62  int pos = limitPos(*it);
63  std::pair<float, float> limits = (pl.limits())[pos];
64  if (v<limits.first || v>limits.second) return false;
65  }
66  return true;
67 }
68 
70  // first, let's see if it is available at all
71  if (resultPos(res) == PerformancePayloadFromTFormula::InvalidPos) return false;
72 
73  if ( ! isOk(point)) return false;
74  return true;
75 }
76 
78  //
79  // which formula to use?
80  //
81  if (resultPos(res) == PerformancePayloadFromTFormula::InvalidPos) {
82  cout << "Warning: result not available!" << endl;
83  return;
84  }
85 
86  // nice, what to do here???
87  const boost::shared_ptr<TFormula>& formula =
88  compiledFormulas_[resultPos(res)];
89  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
90  // prepare the vector to pass, order counts!!!
91  //
92  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
93 
94  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
95  int pos = limitPos(*it);
96  std::pair<float, float> limits = (pl.limits())[pos];
97  cout << " Variable: " << *it << " with limits: " << "from: " << limits.first << " to: " << limits.second << endl;
98  }
99 
100 }
101 
int i
Definition: DBlmapReader.cc:9
bool isKeyAvailable(BinningVariables::BinningVariablesType)
static const float InvalidResult
def gen
run2 Cosmic #### Run 256259 @ 0T 2015C### Run 272133 @ 3.8T 2016B###
virtual bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const
float value(BinningVariables::BinningVariablesType)
float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:96
bool isOk(const BinningPointByMap &p) const
tuple cout
Definition: gather_cfg.py:145
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