CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
PerformancePayloadFromBinnedTFormula Class Reference

#include <PerformancePayloadFromBinnedTFormula.h>

Inheritance diagram for PerformancePayloadFromBinnedTFormula:
PerformancePayload

Public Member Functions

const std::vector< PhysicsTFormulaPayload > & formulaPayloads () const
 
float getResult (PerformanceResult::ResultType, const BinningPointByMap &) const override
 
void initialize () override
 
bool isInPayload (PerformanceResult::ResultType, const BinningPointByMap &) const override
 
virtual bool isParametrizedInVariable (const BinningVariables::BinningVariablesType p) const
 
 PerformancePayloadFromBinnedTFormula (const std::vector< PerformanceResult::ResultType > &r, const std::vector< BinningVariables::BinningVariablesType > &b, const std::vector< PhysicsTFormulaPayload > &in)
 
 PerformancePayloadFromBinnedTFormula ()
 
void printFormula (PerformanceResult::ResultType res, const BinningPointByMap &) const
 
 ~PerformancePayloadFromBinnedTFormula () override
 
- Public Member Functions inherited from PerformancePayload
 PerformancePayload ()
 
virtual ~PerformancePayload ()
 

Static Public Attributes

static const int InvalidPos = -1
 
- Static Public Attributes inherited from PerformancePayload
static const float InvalidResult = -100.
 

Protected Member Functions

const std::shared_ptr< TFormula > & getFormula (PerformanceResult::ResultType, const BinningPointByMap &) const
 
bool isOk (const BinningPointByMap &p, unsigned int &) const
 
virtual int limitPos (const BinningVariables::BinningVariablesType b) const
 
virtual std::vector< BinningVariables::BinningVariablesTypemyBinning () const
 
virtual int resultPos (PerformanceResult::ResultType r) const
 

Protected Attributes

std::vector< std::vector< std::shared_ptr< TFormula > > > compiledFormulas_
 
std::vector< PhysicsTFormulaPayloadpls
 
std::vector< PerformanceResult::ResultTyperesults_
 
std::vector< BinningVariables::BinningVariablesTypevariables_
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Definition at line 17 of file PerformancePayloadFromBinnedTFormula.h.

Constructor & Destructor Documentation

PerformancePayloadFromBinnedTFormula::PerformancePayloadFromBinnedTFormula ( const std::vector< PerformanceResult::ResultType > &  r,
const std::vector< BinningVariables::BinningVariablesType > &  b,
const std::vector< PhysicsTFormulaPayload > &  in 
)
inline

Definition at line 22 of file PerformancePayloadFromBinnedTFormula.h.

References initialize().

25  : pls(in), results_(r), variables_(b) {
26  initialize();
27  }
std::vector< PerformanceResult::ResultType > results_
std::vector< BinningVariables::BinningVariablesType > variables_
double b
Definition: hdecay.h:118
PerformancePayloadFromBinnedTFormula::PerformancePayloadFromBinnedTFormula ( )
inline

Definition at line 31 of file PerformancePayloadFromBinnedTFormula.h.

31 {}
PerformancePayloadFromBinnedTFormula::~PerformancePayloadFromBinnedTFormula ( )
inlineoverride

Definition at line 32 of file PerformancePayloadFromBinnedTFormula.h.

References compiledFormulas_, and getResult().

32 { compiledFormulas_.clear(); }
std::vector< std::vector< std::shared_ptr< TFormula > > > compiledFormulas_

Member Function Documentation

const std::vector<PhysicsTFormulaPayload>& PerformancePayloadFromBinnedTFormula::formulaPayloads ( ) const
inline
const std::shared_ptr< TFormula > & PerformancePayloadFromBinnedTFormula::getFormula ( PerformanceResult::ResultType  r,
const BinningPointByMap p 
) const
protected

Definition at line 30 of file PerformancePayloadFromBinnedTFormula.cc.

References Exception, convertSQLiteXML::ok, and HLT_2018_cff::region.

Referenced by resultPos().

31  {
32  //
33  // chooses the correct rectangular region
34  //
35  if (!isInPayload(r, p)) {
36  throw cms::Exception("MalformedPerfPayload") << "Requested performance data not available!";
37  }
38  unsigned int region;
39  bool ok = isOk(p, region);
40  if (ok == false) {
41  throw cms::Exception("MalformedPerfPayload") << "Requested variable does not match internal structure!";
42  }
43 
45 }
bool isOk(const BinningPointByMap &p, unsigned int &) const
virtual int resultPos(PerformanceResult::ResultType r) const
std::vector< std::vector< std::shared_ptr< TFormula > > > compiledFormulas_
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
float PerformancePayloadFromBinnedTFormula::getResult ( PerformanceResult::ResultType  r,
const BinningPointByMap _p 
) const
overridevirtual

Implements PerformancePayload.

Definition at line 47 of file PerformancePayloadFromBinnedTFormula.cc.

References pfMETCorrectionType0_cfi::formula, mps_fire::i, PerformancePayload::InvalidResult, AlCaHLTBitMon_ParallelJobs::p, OrderedSet::t, BinningPointByMap::value(), and contentValuesCheck::values.

Referenced by ~PerformancePayloadFromBinnedTFormula().

48  {
49  BinningPointByMap p = _p;
50  //
51  // which formula to use?
52  //
53  if (!isInPayload(r, p))
55 
56  // nice, what to do here???
57  // TFormula * formula = compiledFormulas_[resultPos(r)];
58  //
59 
60  const std::shared_ptr<TFormula>& formula = getFormula(r, p);
61 
62  // prepare the vector to pass, order counts!!!
63  //
64  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
65 
66  // sorry, TFormulas just work up to dimension==4
67  Double_t values[4];
68  int i = 0;
69  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it, ++i) {
70  values[i] = p.value(*it);
71  }
72  //
73  // i need a non const version
74  // Note, in current implementation of TFormula EvalPar should be
75  // thread safe as it does nothing more than call a function
76  // through a function pointer which is stateless. In spite of the
77  // fact that it is not const.
78  return formula->EvalPar(values);
79 }
static const float InvalidResult
float value(BinningVariables::BinningVariablesType)
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
const std::shared_ptr< TFormula > & getFormula(PerformanceResult::ResultType, const BinningPointByMap &) const
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
void PerformancePayloadFromBinnedTFormula::initialize ( )
overridevirtual

Reimplemented from PerformancePayload.

Definition at line 14 of file PerformancePayloadFromBinnedTFormula.cc.

References relval_steps::gen(), mps_fire::i, findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, OrderedSet::t, groupFilesInBlocks::temp, createJobs::tmp, groupFilesInBlocks::tt, and createPayload::uuid.

Referenced by PerformancePayloadFromBinnedTFormula().

14  {
15  boost::uuids::random_generator gen;
16  for (unsigned int t = 0; t < pls.size(); ++t) {
17  std::vector<std::shared_ptr<TFormula> > temp;
18  for (unsigned int i = 0; i < (pls[t].formulas()).size(); ++i) {
19  boost::uuids::uuid uniqueFormulaId = gen();
20  const auto formulaUniqueName = boost::lexical_cast<std::string>(uniqueFormulaId);
22  std::shared_ptr<TFormula> tt(new TFormula(formulaUniqueName.c_str(), tmp.formulas()[i].c_str()));
23  tt->Compile();
24  temp.push_back(tt);
25  }
26  compiledFormulas_.push_back(temp);
27  }
28 }
size
Write out results.
def gen(fragment, howMuch)
Production test section ####.
std::vector< std::vector< std::shared_ptr< TFormula > > > compiledFormulas_
tmp
align.sh
Definition: createJobs.py:716
bool PerformancePayloadFromBinnedTFormula::isInPayload ( PerformanceResult::ResultType  res,
const BinningPointByMap point 
) const
overridevirtual

Implements PerformancePayload.

Definition at line 110 of file PerformancePayloadFromBinnedTFormula.cc.

References InvalidPos.

Referenced by isParametrizedInVariable().

111  {
112  // first, let's see if it is available at all
114  return false;
115  unsigned int whocares;
116  if (!isOk(point, whocares))
117  return false;
118  return true;
119 }
bool isOk(const BinningPointByMap &p, unsigned int &) const
virtual int resultPos(PerformanceResult::ResultType r) const
Definition: Electron.h:6
bool PerformancePayloadFromBinnedTFormula::isOk ( const BinningPointByMap p,
unsigned int &  whichone 
) const
protected

Definition at line 81 of file PerformancePayloadFromBinnedTFormula.cc.

References BinningPointByMap::isKeyAvailable(), TH2PolyOfflineMaps::limits, AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, OrderedSet::t, findQualityFiles::v, and BinningPointByMap::value().

Referenced by resultPos().

81  {
82  BinningPointByMap p = _p;
83  //
84  // change: look on whether a single rectangularr region matches
85  //
86  for (unsigned int ti = 0; ti < pls.size(); ++ti) {
87  bool result = true;
88  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
89  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
90  //
91  // now looking into a single payload
92  //
93  if (!p.isKeyAvailable(*it))
94  return false;
95  float v = p.value(*it);
96  int pos = limitPos(*it);
97  std::pair<float, float> limits = (pls[ti].limits())[pos];
98  if (v < limits.first || v > limits.second)
99  result = false;
100  }
101  if (result == true) {
102  whichone = ti;
103  return true;
104  }
105  }
106  whichone = 9999;
107  return false;
108 }
bool isKeyAvailable(BinningVariables::BinningVariablesType)
float value(BinningVariables::BinningVariablesType)
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
virtual bool PerformancePayloadFromBinnedTFormula::isParametrizedInVariable ( const BinningVariables::BinningVariablesType  p) const
inlinevirtual
virtual int PerformancePayloadFromBinnedTFormula::limitPos ( const BinningVariables::BinningVariablesType  b) const
inlineprotectedvirtual

Definition at line 50 of file PerformancePayloadFromBinnedTFormula.h.

References b, spr::find(), InvalidPos, AlCaHLTBitMon_ParallelJobs::p, and variables_.

Referenced by isParametrizedInVariable().

50  {
51  std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
52  p = find(variables_.begin(), variables_.end(), b);
53  if (p == variables_.end())
55  return ((p - variables_.begin()));
56  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< BinningVariables::BinningVariablesType > variables_
double b
Definition: hdecay.h:118
virtual std::vector<BinningVariables::BinningVariablesType> PerformancePayloadFromBinnedTFormula::myBinning ( ) const
inlineprotectedvirtual

Definition at line 48 of file PerformancePayloadFromBinnedTFormula.h.

References variables_.

48 { return variables_; }
std::vector< BinningVariables::BinningVariablesType > variables_
void PerformancePayloadFromBinnedTFormula::printFormula ( PerformanceResult::ResultType  res,
const BinningPointByMap point 
) const

Definition at line 121 of file PerformancePayloadFromBinnedTFormula.cc.

References gather_cfg::cout, pfMETCorrectionType0_cfi::formula, InvalidPos, TH2PolyOfflineMaps::limits, and OrderedSet::t.

Referenced by formulaPayloads().

122  {
123  //
124  // which formula to use?
125  //
127  cout << "Warning: result not available!" << endl;
128  }
129 
130  // nice, what to do here???
131  const std::shared_ptr<TFormula>& formula = getFormula(res, point);
132  unsigned int whichone;
133  isOk(point, whichone);
134  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
135  // prepare the vector to pass, order counts!!!
136  //
137  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
138 
139  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
140  int pos = limitPos(*it);
141  std::pair<float, float> limits = (pls[whichone].limits())[pos];
142  cout << " Variable: " << *it << " with limits: "
143  << "from: " << limits.first << " to: " << limits.second << endl;
144  }
145 }
bool isOk(const BinningPointByMap &p, unsigned int &) const
virtual int resultPos(PerformanceResult::ResultType r) const
Definition: Electron.h:6
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
const std::shared_ptr< TFormula > & getFormula(PerformanceResult::ResultType, const BinningPointByMap &) const
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
virtual int PerformancePayloadFromBinnedTFormula::resultPos ( PerformanceResult::ResultType  r) const
inlineprotectedvirtual

Definition at line 58 of file PerformancePayloadFromBinnedTFormula.h.

References spr::find(), getFormula(), InvalidPos, isOk(), AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, and results_.

58  {
59  std::vector<PerformanceResult::ResultType>::const_iterator p;
60  p = find(results_.begin(), results_.end(), r);
61  if (p == results_.end())
63  return ((p - results_.begin()));
64  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< PerformanceResult::ResultType > results_
template<class Archive >
void PerformancePayloadFromBinnedTFormula::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 88 of file PerformancePayloadFromBinnedTFormula.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 88 of file PerformancePayloadFromBinnedTFormula.h.

Member Data Documentation

std::vector<std::vector<std::shared_ptr<TFormula> > > PerformancePayloadFromBinnedTFormula::compiledFormulas_
protected
const int PerformancePayloadFromBinnedTFormula::InvalidPos = -1
static
std::vector<PhysicsTFormulaPayload> PerformancePayloadFromBinnedTFormula::pls
protected

Definition at line 73 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by formulaPayloads().

std::vector<PerformanceResult::ResultType> PerformancePayloadFromBinnedTFormula::results_
protected

Definition at line 77 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by resultPos().

std::vector<BinningVariables::BinningVariablesType> PerformancePayloadFromBinnedTFormula::variables_
protected

Definition at line 78 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by limitPos(), and myBinning().