CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PerformancePayloadFromBinnedTFormula.cc
Go to the documentation of this file.
2 
4 
5 #include <iostream>
6 using namespace std;
7 
8 
10  //
11  // chooses the correct rectangular region
12  //
13  if (! isInPayload(r,p)) return NULL;
14  unsigned int region;
15  bool ok = isOk(p,region);
16  if (ok == false) return NULL;
17 
18  return compiledFormulas_[region][resultPos(r)];
19 
20 }
21 
23  check();
24  BinningPointByMap p = _p;
25  //
26  // which formula to use?
27  //
28  if (! isInPayload(r,p)) return PerformancePayload::InvalidResult;
29 
30  // nice, what to do here???
31  // TFormula * formula = compiledFormulas_[resultPos(r)];
32  //
33 
34  TFormula * formula = getFormula(r,p);
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  return formula->EvalPar(values);
49 }
50 
51 bool PerformancePayloadFromBinnedTFormula::isOk(const BinningPointByMap& _p,unsigned int& whichone) const {
52 
53  BinningPointByMap p = _p;
54  //
55  // change: look on whether a single rectangularr region matches
56  //
57  for (unsigned int ti=0; ti< pls.size(); ++ti){
58  bool result = true;
59  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
60  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
61  //
62  // now looking into a single payload
63  //
64  if (! p.isKeyAvailable(*it)) return false;
65  float v = p.value(*it);
66  int pos = limitPos(*it);
67  std::pair<float, float> limits = (pls[ti].limits())[pos];
68  if (v<limits.first || v>limits.second) result= false;
69  }
70  if (result == true) {
71  whichone = ti;
72  return true;
73  }
74  }
75  whichone = 9999;
76  return false;
77 }
78 
80  check();
81  // first, let's see if it is available at all
82  if (resultPos(res) == PerformancePayloadFromBinnedTFormula::InvalidPos) return false;
83  unsigned int whocares;
84  if ( ! isOk(point,whocares)) return false;
85  return true;
86 }
87 
88 
90  if (pls.size()== compiledFormulas_.size()) return;
91  //
92  // otherwise, compile!
93  //
94  compiledFormulas_.clear();
95  for (unsigned int t=0; t< pls.size(); ++t){
96  std::vector <TFormula *> temp;
97  for (unsigned int i=0; i< (pls[t].formulas()).size(); ++i){
99  TFormula* tt = new TFormula("rr",((tmp.formulas())[i]).c_str()); //FIXME: "rr" should be unique!
100  tt->Compile();
101  temp.push_back(tt);
102  }
103  compiledFormulas_.push_back(temp);
104  }
105 }
106 
107 
108 
109 
111  check();
112  //
113  // which formula to use?
114  //
115  if (resultPos(res) == PerformancePayloadFromBinnedTFormula::InvalidPos) {
116  cout << "Warning: result not available!" << endl;
117  }
118 
119  // nice, what to do here???
120  TFormula * formula = getFormula(res, point);
121  unsigned int whichone;
122  isOk(point,whichone);
123  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
124  // prepare the vector to pass, order counts!!!
125  //
126  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
127 
128  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
129  int pos = limitPos(*it);
130  std::pair<float, float> limits = (pls[whichone].limits())[pos];
131  cout << " Variable: " << *it << " with limits: " << "from: " << limits.first << " to: " << limits.second << endl;
132  }
133 
134 }
135 
int i
Definition: DBlmapReader.cc:9
bool isOk(const BinningPointByMap &p, unsigned int &) const
#define NULL
Definition: scimark2.h:8
bool isKeyAvailable(BinningVariables::BinningVariablesType)
static const float InvalidResult
const std::vector< std::string > & formulas() const
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
float value(BinningVariables::BinningVariablesType)
tuple result
Definition: query.py:137
void printFormula(PerformanceResult::ResultType res, const BinningPointByMap &) const
TFormula * getFormula(PerformanceResult::ResultType, const BinningPointByMap &) const
float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:96
virtual bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.
*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