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 override
 
void initialize () override
 
bool isInPayload (PerformanceResult::ResultType, const BinningPointByMap &) const override
 
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
 
 ~PerformancePayloadFromTFormula () 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

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< std::shared_ptr< const 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< std::shared_ptr< const TFormula > > compiledFormulas_
std::vector< BinningVariables::BinningVariablesType > variables_
std::vector< PerformanceResult::ResultType > results_
PerformancePayloadFromTFormula::~PerformancePayloadFromTFormula ( )
inlineoverride

Definition at line 39 of file PerformancePayloadFromTFormula.h.

References compiledFormulas_, and getResult().

39  {
40  compiledFormulas_.clear();
41  }
std::vector< std::shared_ptr< const 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
overridevirtual

Implements PerformancePayload.

Definition at line 28 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(), PFEnergyCalibration::cEtaBarrelEH(), PFEnergyCalibration::cEtaBarrelH(), PFEnergyCalibration::cEtaEndcapEH(), PFEnergyCalibration::cEtaEndcapH(), PFEnergyCalibration::dEtaEndcapEH(), PFEnergyCalibration::dEtaEndcapH(), and ~PerformancePayloadFromTFormula().

28  {
29  BinningPointByMap p = _p;
30  //
31  // which formula to use?
32  //
33  if ( ! isInPayload(r,p) ) {
34  edm::LogError("PerformancePayloadFromTFormula") <<"Missing formula in conditions. Maybe code/conditions are inconsistent" << std::endl;
35  assert(false);
36  }
37 
38  const TFormula* formula = compiledFormulas_[resultPos(r)].get();
39  //
40  // prepare the vector to pass, order counts!!!
41  //
42  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
43 
44  // sorry, TFormulas just work up to dimension==4
45  Double_t values[4];
46  int i=0;
47  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it, ++i){
48  values[i] = p.value(*it);
49  }
50  //
51  return formula->EvalPar(values);
52 }
std::vector< std::shared_ptr< const TFormula > > compiledFormulas_
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
float value(BinningVariables::BinningVariablesType)
virtual int resultPos(PerformanceResult::ResultType r) const
void PerformancePayloadFromTFormula::initialize ( )
overridevirtual

Reimplemented from PerformancePayload.

Definition at line 14 of file PerformancePayloadFromTFormula.cc.

References EcalElecEmulTccOnlyExample_cfg::formula, relval_steps::gen(), eostools::move(), 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  //be sure not to add TFormula to ROOT's global list
21  auto temp = std::make_shared<TFormula>(formulaUniqueName.c_str(),formula->c_str(),false);
22  temp->Compile();
23  compiledFormulas_.emplace_back(std::move(temp));
24  }
25 }
std::vector< std::shared_ptr< const TFormula > > compiledFormulas_
const std::vector< std::string > & formulas() const
def gen(fragment, howMuch)
Production test section ####.
def move(src, dest)
Definition: eostools.py:511
bool PerformancePayloadFromTFormula::isInPayload ( PerformanceResult::ResultType  res,
const BinningPointByMap point 
) const
overridevirtual

Implements PerformancePayload.

Definition at line 68 of file PerformancePayloadFromTFormula.cc.

References InvalidPos.

Referenced by isParametrizedInVariable().

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

Definition at line 54 of file PerformancePayloadFromTFormula.cc.

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

Referenced by resultPos().

54  {
55  BinningPointByMap p = _p;
56  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
57 
58  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
59  if (! p.isKeyAvailable(*it)) return false;
60  float v = p.value(*it);
61  int pos = limitPos(*it);
62  std::pair<float, float> limits = (pl.limits())[pos];
63  if (v<limits.first || v>limits.second) return false;
64  }
65  return true;
66 }
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 76 of file PerformancePayloadFromTFormula.cc.

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

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

76  {
77  //
78  // which formula to use?
79  //
81  cout << "Warning: result not available!" << endl;
82  return;
83  }
84 
85 
86  const TFormula* formula =
88  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
89  // prepare the vector to pass, order counts!!!
90  //
91  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
92 
93  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
94  int pos = limitPos(*it);
95  std::pair<float, float> limits = (pl.limits())[pos];
96  cout << " Variable: " << *it << " with limits: " << "from: " << limits.first << " to: " << limits.second << endl;
97  }
98 
99 }
std::vector< std::shared_ptr< const TFormula > > compiledFormulas_
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
Definition: Electron.h:6
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< std::shared_ptr<const 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().