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 boost::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< boost::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 23 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:120
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  {
33  compiledFormulas_.clear();
34  }
std::vector< std::vector< boost::shared_ptr< TFormula > > > compiledFormulas_

Member Function Documentation

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

Definition at line 34 of file PerformancePayloadFromBinnedTFormula.cc.

References Exception, and convertSQLiteXML::ok.

Referenced by resultPos().

34  {
35  //
36  // chooses the correct rectangular region
37  //
38  if (! isInPayload(r,p)) { throw cms::Exception("MalformedPerfPayload") << "Requested performance data not available!"; }
39  unsigned int region;
40  bool ok = isOk(p,region);
41  if (ok == false) { throw cms::Exception("MalformedPerfPayload") << "Requested variable does not match internal structure!"; }
42 
43  return compiledFormulas_[region][resultPos(r)];
44 
45 }
std::vector< std::vector< boost::shared_ptr< TFormula > > > compiledFormulas_
bool isOk(const BinningPointByMap &p, unsigned int &) const
virtual int resultPos(PerformanceResult::ResultType r) const
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 EcalElecEmulTccOnlyExample_cfg::formula, mps_fire::i, PerformancePayload::InvalidResult, AlCaHLTBitMon_ParallelJobs::p, lumiQTWidget::t, BinningPointByMap::value(), and MuonErrorMatrixValues_cff::values.

Referenced by ~PerformancePayloadFromBinnedTFormula().

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

Reimplemented from PerformancePayload.

Definition at line 16 of file PerformancePayloadFromBinnedTFormula.cc.

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

Referenced by PerformancePayloadFromBinnedTFormula().

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

Implements PerformancePayload.

Definition at line 107 of file PerformancePayloadFromBinnedTFormula.cc.

References InvalidPos.

Referenced by isParametrizedInVariable().

107  {
108  // first, let's see if it is available at all
110  unsigned int whocares;
111  if ( ! isOk(point,whocares)) return false;
112  return true;
113 }
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 79 of file PerformancePayloadFromBinnedTFormula.cc.

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

Referenced by resultPos().

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

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

Referenced by isParametrizedInVariable().

53  {
54  std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
55  p = find(variables_.begin(), variables_.end(), b);
57  return ((p-variables_.begin()));
58 
59  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< BinningVariables::BinningVariablesType > variables_
double b
Definition: hdecay.h:120
virtual std::vector<BinningVariables::BinningVariablesType> PerformancePayloadFromBinnedTFormula::myBinning ( ) const
inlineprotectedvirtual

Definition at line 51 of file PerformancePayloadFromBinnedTFormula.h.

References variables_.

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

Definition at line 115 of file PerformancePayloadFromBinnedTFormula.cc.

References gather_cfg::cout, EcalElecEmulTccOnlyExample_cfg::formula, InvalidPos, and lumiQTWidget::t.

Referenced by formulaPayloads().

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

Definition at line 61 of file PerformancePayloadFromBinnedTFormula.h.

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

61  {
62  std::vector<PerformanceResult::ResultType>::const_iterator p;
63  p = find (results_.begin(), results_.end(), r);
65  return ((p-results_.begin()));
66  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
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 90 of file PerformancePayloadFromBinnedTFormula.h.

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

Definition at line 90 of file PerformancePayloadFromBinnedTFormula.h.

Member Data Documentation

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

Definition at line 76 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by formulaPayloads().

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

Definition at line 80 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by resultPos().

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

Definition at line 81 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by limitPos(), and myBinning().