CMS 3D CMS Logo

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

#include <PerformancePayloadFromTFormula.h>

Inheritance diagram for PerformancePayloadFromTFormula:
PerformancePayload

Public Member Functions

const PhysicsTFormulaPayloadformulaPayload () 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
 
 PerformancePayloadFromTFormula (const std::vector< PerformanceResult::ResultType > &r, const std::vector< BinningVariables::BinningVariablesType > &b, PhysicsTFormulaPayload &in)
 
 PerformancePayloadFromTFormula ()
 
 PerformancePayloadFromTFormula (const PerformancePayloadFromTFormula &b)
 
void printFormula (PerformanceResult::ResultType res) const
 
virtual ~PerformancePayloadFromTFormula ()
 
- 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

bool isOk (const BinningPointByMap &p) 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< boost::shared_ptr< TFormula > > compiledFormulas_
 
PhysicsTFormulaPayload pl
 
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 PerformancePayloadFromTFormula.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file PerformancePayloadFromTFormula.h.

References initialize().

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

Definition at line 29 of file PerformancePayloadFromTFormula.h.

References initialize().

29 {}
PerformancePayloadFromTFormula::PerformancePayloadFromTFormula ( const PerformancePayloadFromTFormula b)
inline

Definition at line 33 of file PerformancePayloadFromTFormula.h.

33  :
34  pl(b.pl),
35  results_(b.results_),
std::vector< boost::shared_ptr< TFormula > > compiledFormulas_
std::vector< BinningVariables::BinningVariablesType > variables_
std::vector< PerformanceResult::ResultType > results_
virtual PerformancePayloadFromTFormula::~PerformancePayloadFromTFormula ( )
inlinevirtual

Definition at line 39 of file PerformancePayloadFromTFormula.h.

References compiledFormulas_, and getResult().

39  {
40  compiledFormulas_.clear();
41  }
std::vector< boost::shared_ptr< TFormula > > compiledFormulas_

Member Function Documentation

const PhysicsTFormulaPayload& PerformancePayloadFromTFormula::formulaPayload ( ) const
inline

Definition at line 53 of file PerformancePayloadFromTFormula.h.

References pl, and printFormula().

53 {return pl;}
float PerformancePayloadFromTFormula::getResult ( PerformanceResult::ResultType  r,
const BinningPointByMap _p 
) const
virtual

Implements PerformancePayload.

Definition at line 27 of file PerformancePayloadFromTFormula.cc.

References EcalElecEmulTccOnlyExample_cfg::formula, mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, lumiQTWidget::t, BinningPointByMap::value(), and MuonErrorMatrixValues_cff::values.

Referenced by PFEnergyCalibration::aBarrel(), PFEnergyCalibration::aEndcap(), PFEnergyCalibration::aEtaBarrelEH(), PFEnergyCalibration::aEtaBarrelH(), PFEnergyCalibration::aEtaEndcapEH(), PFEnergyCalibration::aEtaEndcapH(), PFEnergyCalibration::bBarrel(), PFEnergyCalibration::bEndcap(), PFEnergyCalibration::bEtaBarrelEH(), PFEnergyCalibration::bEtaBarrelH(), PFEnergyCalibration::bEtaEndcapEH(), PFEnergyCalibration::bEtaEndcapH(), PFEnergyCalibration::cBarrel(), PFEnergyCalibration::cEndcap(), and ~PerformancePayloadFromTFormula().

27  {
28  BinningPointByMap p = _p;
29  //
30  // which formula to use?
31  //
32  if ( ! isInPayload(r,p) ) {
33  edm::LogError("PerformancePayloadFromTFormula") <<"Missing formula in conditions. Maybe code/conditions are inconsistent" << std::endl;
34  assert(false);
35  }
36  // nice, what to do here???
37  const boost::shared_ptr<TFormula>& formula = compiledFormulas_[resultPos(r)];
38  //
39  // prepare the vector to pass, order counts!!!
40  //
41  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
42 
43  // sorry, TFormulas just work up to dimension==4
44  Double_t values[4];
45  int i=0;
46  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it, ++i){
47  values[i] = p.value(*it);
48  }
49  //
50  // i need a non const version #$%^
51  // Note, in current implementation of TFormula EvalPar should be
52  // thread safe as it does nothing more than call a function
53  // through a function pointer which is stateless. In spite of the
54  // fact that it is not const.
55  return formula->EvalPar(values);
56 }
std::vector< boost::shared_ptr< TFormula > > compiledFormulas_
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
virtual bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const
float value(BinningVariables::BinningVariablesType)
virtual int resultPos(PerformanceResult::ResultType r) const
void PerformancePayloadFromTFormula::initialize ( )
virtual

Reimplemented from PerformancePayload.

Definition at line 14 of file PerformancePayloadFromTFormula.cc.

References EcalElecEmulTccOnlyExample_cfg::formula, relval_steps::gen(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and createPayload::uuid.

Referenced by PerformancePayloadFromTFormula().

14  {
15  boost::uuids::random_generator gen;
16 
17  for( std::vector<std::string>::const_iterator formula = pl.formulas().begin(); formula != pl.formulas().end(); ++formula ) {
18  boost::uuids::uuid uniqueFormulaId = gen();
19  const auto formulaUniqueName = boost::lexical_cast<std::string>(uniqueFormulaId);
20  boost::shared_ptr<TFormula> temp(new TFormula(formulaUniqueName.c_str(),formula->c_str()));
21  temp->Compile();
22  compiledFormulas_.push_back(temp);
23  }
24 }
std::vector< boost::shared_ptr< TFormula > > compiledFormulas_
const std::vector< std::string > & formulas() const
def gen(fragment, howMuch)
Production test section ####.
bool PerformancePayloadFromTFormula::isInPayload ( PerformanceResult::ResultType  res,
const BinningPointByMap point 
) const
virtual

Implements PerformancePayload.

Definition at line 72 of file PerformancePayloadFromTFormula.cc.

References InvalidPos.

Referenced by isParametrizedInVariable().

72  {
73  // first, let's see if it is available at all
75 
76  if ( ! isOk(point)) return false;
77  return true;
78 }
Definition: Electron.h:4
bool isOk(const BinningPointByMap &p) const
virtual int resultPos(PerformanceResult::ResultType r) const
bool PerformancePayloadFromTFormula::isOk ( const BinningPointByMap p) const
protected

Definition at line 58 of file PerformancePayloadFromTFormula.cc.

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

Referenced by resultPos().

58  {
59  BinningPointByMap p = _p;
60  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
61 
62  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
63  if (! p.isKeyAvailable(*it)) return false;
64  float v = p.value(*it);
65  int pos = limitPos(*it);
66  std::pair<float, float> limits = (pl.limits())[pos];
67  if (v<limits.first || v>limits.second) return false;
68  }
69  return true;
70 }
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
bool isKeyAvailable(BinningVariables::BinningVariablesType)
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
float value(BinningVariables::BinningVariablesType)
const std::vector< std::pair< float, float > > & limits() const
virtual bool PerformancePayloadFromTFormula::isParametrizedInVariable ( const BinningVariables::BinningVariablesType  p) const
inlinevirtual

Definition at line 47 of file PerformancePayloadFromTFormula.h.

References InvalidPos, isInPayload(), and limitPos().

47  {
49  }
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
virtual int PerformancePayloadFromTFormula::limitPos ( const BinningVariables::BinningVariablesType  b) const
inlineprotectedvirtual

Definition at line 62 of file PerformancePayloadFromTFormula.h.

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

Referenced by isParametrizedInVariable().

62  {
63  std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
64  p = find(variables_.begin(), variables_.end(), b);
66  return ((p-variables_.begin()));
67 
68  }
std::vector< BinningVariables::BinningVariablesType > variables_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
double b
Definition: hdecay.h:120
virtual std::vector<BinningVariables::BinningVariablesType> PerformancePayloadFromTFormula::myBinning ( ) const
inlineprotectedvirtual

Definition at line 60 of file PerformancePayloadFromTFormula.h.

References variables_.

60 {return variables_;}
std::vector< BinningVariables::BinningVariablesType > variables_
void PerformancePayloadFromTFormula::printFormula ( PerformanceResult::ResultType  res) const

Definition at line 80 of file PerformancePayloadFromTFormula.cc.

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

Referenced by formulaPayload(), and operator<<().

80  {
81  //
82  // which formula to use?
83  //
85  cout << "Warning: result not available!" << endl;
86  return;
87  }
88 
89  // nice, what to do here???
90  const boost::shared_ptr<TFormula>& formula =
92  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
93  // prepare the vector to pass, order counts!!!
94  //
95  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
96 
97  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
98  int pos = limitPos(*it);
99  std::pair<float, float> limits = (pl.limits())[pos];
100  cout << " Variable: " << *it << " with limits: " << "from: " << limits.first << " to: " << limits.second << endl;
101  }
102 
103 }
std::vector< boost::shared_ptr< TFormula > > compiledFormulas_
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
Definition: Electron.h:4
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
const std::vector< std::pair< float, float > > & limits() const
virtual int resultPos(PerformanceResult::ResultType r) const
virtual int PerformancePayloadFromTFormula::resultPos ( PerformanceResult::ResultType  r) const
inlineprotectedvirtual

Definition at line 70 of file PerformancePayloadFromTFormula.h.

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

70  {
71  std::vector<PerformanceResult::ResultType>::const_iterator p;
72  p = find (results_.begin(), results_.end(), r);
74  return ((p-results_.begin()));
75  }
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 PerformancePayloadFromTFormula::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 91 of file PerformancePayloadFromTFormula.h.

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

Definition at line 91 of file PerformancePayloadFromTFormula.h.

Member Data Documentation

std::vector< boost::shared_ptr<TFormula> > PerformancePayloadFromTFormula::compiledFormulas_
protected

Definition at line 89 of file PerformancePayloadFromTFormula.h.

Referenced by ~PerformancePayloadFromTFormula().

const int PerformancePayloadFromTFormula::InvalidPos =-1
static
PhysicsTFormulaPayload PerformancePayloadFromTFormula::pl
protected

Definition at line 80 of file PerformancePayloadFromTFormula.h.

Referenced by formulaPayload().

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

Definition at line 84 of file PerformancePayloadFromTFormula.h.

Referenced by resultPos().

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

Definition at line 85 of file PerformancePayloadFromTFormula.h.

Referenced by limitPos(), and myBinning().