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