test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
void initialize ()
 
virtual bool isInPayload (PerformanceResult::ResultType, const BinningPointByMap &) const
 
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
 
virtual ~PerformancePayloadFromBinnedTFormula ()
 
- 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::BinningVariablesType
myBinning () const
 
virtual int resultPos (PerformanceResult::ResultType r) const
 

Protected Attributes

std::vector< std::vector
< boost::shared_ptr< TFormula > > > 
compiledFormulas_
 
std::vector
< PhysicsTFormulaPayload
pls
 
std::vector
< PerformanceResult::ResultType
results_
 
std::vector
< BinningVariables::BinningVariablesType
variables_
 

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 {}
virtual PerformancePayloadFromBinnedTFormula::~PerformancePayloadFromBinnedTFormula ( )
inlinevirtual

Definition at line 32 of file PerformancePayloadFromBinnedTFormula.h.

References compiledFormulas_.

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

Definition at line 44 of file PerformancePayloadFromBinnedTFormula.h.

References pls.

Referenced by PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::beginJob().

44 {return pls;}
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, convertSQLiteXML::ok, and HLT_25ns10e33_v2_cff::region.

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 
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
virtual bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const
float PerformancePayloadFromBinnedTFormula::getResult ( PerformanceResult::ResultType  r,
const BinningPointByMap _p 
) const
virtual

Implements PerformancePayload.

Definition at line 47 of file PerformancePayloadFromBinnedTFormula.cc.

References EcalElecEmulTccOnlyExample_cfg::formula, i, PerformancePayload::InvalidResult, AlCaHLTBitMon_ParallelJobs::p, lumiQTWidget::t, BinningPointByMap::value(), and makeHLTPrescaleTable::values.

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 }
int i
Definition: DBlmapReader.cc:9
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
virtual bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const
void PerformancePayloadFromBinnedTFormula::initialize ( )
virtual

Reimplemented from PerformancePayload.

Definition at line 16 of file PerformancePayloadFromBinnedTFormula.cc.

References relval_steps::gen(), 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 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::vector< boost::shared_ptr< TFormula > > > compiledFormulas_
def gen
run2 Cosmic #### Run 256259 @ 0T 2015C### Run 272133 @ 3.8T 2016B###
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple size
Write out results.
bool PerformancePayloadFromBinnedTFormula::isInPayload ( PerformanceResult::ResultType  res,
const BinningPointByMap point 
) const
virtual

Implements PerformancePayload.

Definition at line 107 of file PerformancePayloadFromBinnedTFormula.cc.

References InvalidPos.

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
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().

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)
tuple result
Definition: mps_fire.py:84
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:7
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.

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
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
tuple cout
Definition: gather_cfg.py:145
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(), InvalidPos, 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:7
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().