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 23 of file PerformancePayloadFromBinnedTFormula.cc.

References edm::hlt::Exception, convertSQLiteXML::ok, and HLT_25ns14e33_v3_cff::region.

23  {
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 
33 
34 }
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 36 of file PerformancePayloadFromBinnedTFormula.cc.

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

36  {
37  BinningPointByMap p = _p;
38  //
39  // which formula to use?
40  //
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 }
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 10 of file PerformancePayloadFromBinnedTFormula.cc.

References PhysicsTFormulaPayload::formulas(), i, findQualityFiles::size, edmStreamStallGrapher::t, groupFilesInBlocks::temp, tmp, and groupFilesInBlocks::tt.

Referenced by PerformancePayloadFromBinnedTFormula().

10  {
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 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::vector< boost::shared_ptr< TFormula > > > compiledFormulas_
const std::vector< std::string > & formulas() const
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 96 of file PerformancePayloadFromBinnedTFormula.cc.

References InvalidPos.

96  {
97  // first, let's see if it is available at all
99  unsigned int whocares;
100  if ( ! isOk(point,whocares)) return false;
101  return true;
102 }
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 68 of file PerformancePayloadFromBinnedTFormula.cc.

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

68  {
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 }
bool isKeyAvailable(BinningVariables::BinningVariablesType)
float value(BinningVariables::BinningVariablesType)
tuple result
Definition: query.py:137
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 104 of file PerformancePayloadFromBinnedTFormula.cc.

References gather_cfg::cout, EcalElecEmulExample_cfg::formula, InvalidPos, and edmStreamStallGrapher::t.

104  {
105  //
106  // which formula to use?
107  //
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 }
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:121
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().