CMS 3D CMS Logo

PerformancePayloadFromBinnedTFormula.cc
Go to the documentation of this file.
2 
5 
7 
8 #include <iostream>
9 using namespace std;
10 
12  for (unsigned int t = 0; t < pls.size(); ++t) {
13  std::vector<std::shared_ptr<TFormula> > temp;
14  for (unsigned int i = 0; i < (pls[t].formulas()).size(); ++i) {
15  const auto formulaUniqueName = edm::createGlobalIdentifier();
17  std::shared_ptr<TFormula> tt(new TFormula(formulaUniqueName.c_str(), tmp.formulas()[i].c_str()));
18  tt->Compile();
19  temp.push_back(tt);
20  }
21  compiledFormulas_.push_back(temp);
22  }
23 }
24 
26  const BinningPointByMap& p) const {
27  //
28  // chooses the correct rectangular region
29  //
30  if (!isInPayload(r, p)) {
31  throw cms::Exception("MalformedPerfPayload") << "Requested performance data not available!";
32  }
33  unsigned int region;
34  bool ok = isOk(p, region);
35  if (ok == false) {
36  throw cms::Exception("MalformedPerfPayload") << "Requested variable does not match internal structure!";
37  }
38 
39  return compiledFormulas_[region][resultPos(r)];
40 }
41 
43  const BinningPointByMap& _p) const {
44  BinningPointByMap p = _p;
45  //
46  // which formula to use?
47  //
48  if (!isInPayload(r, p))
50 
51  // nice, what to do here???
52  // TFormula * formula = compiledFormulas_[resultPos(r)];
53  //
54 
55  const std::shared_ptr<TFormula>& formula = getFormula(r, p);
56 
57  // prepare the vector to pass, order counts!!!
58  //
59  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
60 
61  // sorry, TFormulas just work up to dimension==4
62  Double_t values[4];
63  int i = 0;
64  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it, ++i) {
65  values[i] = p.value(*it);
66  }
67  //
68  // i need a non const version
69  // Note, in current implementation of TFormula EvalPar should be
70  // thread safe as it does nothing more than call a function
71  // through a function pointer which is stateless. In spite of the
72  // fact that it is not const.
73  return formula->EvalPar(values);
74 }
75 
76 bool PerformancePayloadFromBinnedTFormula::isOk(const BinningPointByMap& _p, unsigned int& whichone) const {
77  BinningPointByMap p = _p;
78  //
79  // change: look on whether a single rectangularr region matches
80  //
81  for (unsigned int ti = 0; ti < pls.size(); ++ti) {
82  bool result = true;
83  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
84  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
85  //
86  // now looking into a single payload
87  //
88  if (!p.isKeyAvailable(*it))
89  return false;
90  float v = p.value(*it);
91  int pos = limitPos(*it);
92  std::pair<float, float> limits = (pls[ti].limits())[pos];
93  if (v < limits.first || v > limits.second)
94  result = false;
95  }
96  if (result == true) {
97  whichone = ti;
98  return true;
99  }
100  }
101  whichone = 9999;
102  return false;
103 }
104 
106  const BinningPointByMap& point) const {
107  // first, let's see if it is available at all
109  return false;
110  unsigned int whocares;
111  if (!isOk(point, whocares))
112  return false;
113  return true;
114 }
115 
117  const BinningPointByMap& point) const {
118  //
119  // which formula to use?
120  //
122  cout << "Warning: result not available!" << endl;
123  }
124 
125  // nice, what to do here???
126  const std::shared_ptr<TFormula>& formula = getFormula(res, point);
127  unsigned int whichone;
128  isOk(point, whichone);
129  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
130  // prepare the vector to pass, order counts!!!
131  //
132  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
133 
134  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
135  int pos = limitPos(*it);
136  std::pair<float, float> limits = (pls[whichone].limits())[pos];
137  cout << " Variable: " << *it << " with limits: "
138  << "from: " << limits.first << " to: " << limits.second << endl;
139  }
140 }
141 
mps_fire.i
i
Definition: mps_fire.py:428
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
pfMETCorrectionType0_cfi.formula
formula
Definition: pfMETCorrectionType0_cfi.py:46
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
typelookup.h
PhysicsTFormulaPayload
Definition: PhysicsTFormulaPayload.h:9
findQualityFiles.v
v
Definition: findQualityFiles.py:179
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
PerformanceResult::ResultType
ResultType
Definition: PerformanceResult.h:8
PerformancePayloadFromBinnedTFormula::InvalidPos
static const int InvalidPos
Definition: PerformancePayloadFromBinnedTFormula.h:20
PerformancePayloadFromBinnedTFormula::printFormula
void printFormula(PerformanceResult::ResultType res, const BinningPointByMap &) const
Definition: PerformancePayloadFromBinnedTFormula.cc:116
GlobalIdentifier.h
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:84949
edm::createGlobalIdentifier
std::string createGlobalIdentifier(bool binary=false)
Definition: GlobalIdentifier.cc:5
PerformancePayloadFromBinnedTFormula::initialize
void initialize() override
Definition: PerformancePayloadFromBinnedTFormula.cc:11
res
Definition: Electron.h:6
TYPELOOKUP_DATA_REG
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
PerformancePayloadFromBinnedTFormula
Definition: PerformancePayloadFromBinnedTFormula.h:17
alignCSCRings.r
r
Definition: alignCSCRings.py:93
TH2PolyOfflineMaps.limits
limits
Definition: TH2PolyOfflineMaps.py:45
BinningPointByMap
Definition: BinningPointByMap.h:8
std
Definition: JetResolutionObject.h:76
PerformancePayloadFromBinnedTFormula::isOk
bool isOk(const BinningPointByMap &p, unsigned int &) const
Definition: PerformancePayloadFromBinnedTFormula.cc:76
Exception
Definition: hltDiff.cc:246
PerformancePayloadFromBinnedTFormula::getFormula
const std::shared_ptr< TFormula > & getFormula(PerformanceResult::ResultType, const BinningPointByMap &) const
Definition: PerformancePayloadFromBinnedTFormula.cc:25
PerformancePayload::InvalidResult
static const float InvalidResult
Definition: PerformancePayload.h:18
PerformancePayloadFromBinnedTFormula::getResult
float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const override
Definition: PerformancePayloadFromBinnedTFormula.cc:42
Exception.h
mps_fire.result
result
Definition: mps_fire.py:311
point
*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
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
PerformancePayloadFromBinnedTFormula.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
PerformancePayloadFromBinnedTFormula::isInPayload
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
Definition: PerformancePayloadFromBinnedTFormula.cc:105