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() [1/3]

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

Definition at line 22 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:118
std::vector< PerformanceResult::ResultType > results_

◆ PerformancePayloadFromTFormula() [2/3]

PerformancePayloadFromTFormula::PerformancePayloadFromTFormula ( )
inline

Definition at line 29 of file PerformancePayloadFromTFormula.h.

29 {}

◆ PerformancePayloadFromTFormula() [3/3]

PerformancePayloadFromTFormula::PerformancePayloadFromTFormula ( const PerformancePayloadFromTFormula b)
inline

Definition at line 33 of file PerformancePayloadFromTFormula.h.

34  : pl(b.pl), results_(b.results_), variables_(b.variables_), compiledFormulas_(b.compiledFormulas_) {}
std::vector< BinningVariables::BinningVariablesType > variables_
std::vector< std::shared_ptr< const TFormula > > compiledFormulas_
double b
Definition: hdecay.h:118
std::vector< PerformanceResult::ResultType > results_

◆ ~PerformancePayloadFromTFormula()

PerformancePayloadFromTFormula::~PerformancePayloadFromTFormula ( )
inlineoverride

Definition at line 36 of file PerformancePayloadFromTFormula.h.

References compiledFormulas_.

36 { compiledFormulas_.clear(); }
std::vector< std::shared_ptr< const TFormula > > compiledFormulas_

Member Function Documentation

◆ formulaPayload()

const PhysicsTFormulaPayload& PerformancePayloadFromTFormula::formulaPayload ( ) const
inline

Definition at line 47 of file PerformancePayloadFromTFormula.h.

References pl.

47 { return pl; }

◆ getResult()

float PerformancePayloadFromTFormula::getResult ( PerformanceResult::ResultType  r,
const BinningPointByMap _p 
) const
overridevirtual

Implements PerformancePayload.

Definition at line 21 of file PerformancePayloadFromTFormula.cc.

References cms::cuda::assert(), pfMETCorrectionType0_cfi::formula, mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, submitPVValidationJobs::t, and contentValuesCheck::values.

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

◆ initialize()

void PerformancePayloadFromTFormula::initialize ( )
overridevirtual

Reimplemented from PerformancePayload.

Definition at line 10 of file PerformancePayloadFromTFormula.cc.

References edm::createGlobalIdentifier(), pfMETCorrectionType0_cfi::formula, eostools::move(), and groupFilesInBlocks::temp.

Referenced by PerformancePayloadFromTFormula().

10  {
11  for (std::vector<std::string>::const_iterator formula = pl.formulas().begin(); formula != pl.formulas().end();
12  ++formula) {
13  const auto formulaUniqueName = edm::createGlobalIdentifier();
14  //be sure not to add TFormula to ROOT's global list
15  auto temp = std::make_shared<TFormula>(formulaUniqueName.c_str(), formula->c_str(), false);
16  temp->Compile();
17  compiledFormulas_.emplace_back(std::move(temp));
18  }
19 }
const std::vector< std::string > & formulas() const
std::vector< std::shared_ptr< const TFormula > > compiledFormulas_
std::string createGlobalIdentifier(bool binary=false)
def move(src, dest)
Definition: eostools.py:511

◆ isInPayload()

bool PerformancePayloadFromTFormula::isInPayload ( PerformanceResult::ResultType  res,
const BinningPointByMap point 
) const
overridevirtual

Implements PerformancePayload.

Definition at line 64 of file PerformancePayloadFromTFormula.cc.

References InvalidPos, and point.

65  {
66  // first, let's see if it is available at all
68  return false;
69 
70  if (!isOk(point))
71  return false;
72  return true;
73 }
virtual int resultPos(PerformanceResult::ResultType r) const
Definition: Electron.h:6
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
bool isOk(const BinningPointByMap &p) const

◆ isOk()

bool PerformancePayloadFromTFormula::isOk ( const BinningPointByMap p) const
protected

Definition at line 48 of file PerformancePayloadFromTFormula.cc.

References TH2PolyOfflineMaps::limits, AlCaHLTBitMon_ParallelJobs::p, submitPVValidationJobs::t, and findQualityFiles::v.

48  {
49  BinningPointByMap p = _p;
50  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
51 
52  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
53  if (!p.isKeyAvailable(*it))
54  return false;
55  float v = p.value(*it);
56  int pos = limitPos(*it);
57  std::pair<float, float> limits = (pl.limits())[pos];
58  if (v < limits.first || v > limits.second)
59  return false;
60  }
61  return true;
62 }
const std::vector< std::pair< float, float > > & limits() const
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const

◆ isParametrizedInVariable()

virtual bool PerformancePayloadFromTFormula::isParametrizedInVariable ( const BinningVariables::BinningVariablesType  p) const
inlinevirtual

Definition at line 41 of file PerformancePayloadFromTFormula.h.

References InvalidPos, limitPos(), and AlCaHLTBitMon_ParallelJobs::p.

41  {
43  }
virtual int limitPos(const BinningVariables::BinningVariablesType b) const

◆ limitPos()

virtual int PerformancePayloadFromTFormula::limitPos ( const BinningVariables::BinningVariablesType  b) const
inlineprotectedvirtual

Definition at line 54 of file PerformancePayloadFromTFormula.h.

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

Referenced by isParametrizedInVariable().

54  {
55  std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
56  p = find(variables_.begin(), variables_.end(), b);
57  if (p == variables_.end())
59  return ((p - variables_.begin()));
60  }
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:19
double b
Definition: hdecay.h:118

◆ myBinning()

virtual std::vector<BinningVariables::BinningVariablesType> PerformancePayloadFromTFormula::myBinning ( ) const
inlineprotectedvirtual

Definition at line 52 of file PerformancePayloadFromTFormula.h.

References variables_.

52 { return variables_; }
std::vector< BinningVariables::BinningVariablesType > variables_

◆ printFormula()

void PerformancePayloadFromTFormula::printFormula ( PerformanceResult::ResultType  res) const

Definition at line 75 of file PerformancePayloadFromTFormula.cc.

References gather_cfg::cout, pfMETCorrectionType0_cfi::formula, InvalidPos, TH2PolyOfflineMaps::limits, and submitPVValidationJobs::t.

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

◆ resultPos()

virtual int PerformancePayloadFromTFormula::resultPos ( PerformanceResult::ResultType  r) const
inlineprotectedvirtual

Definition at line 62 of file PerformancePayloadFromTFormula.h.

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

62  {
63  std::vector<PerformanceResult::ResultType>::const_iterator p;
64  p = find(results_.begin(), results_.end(), r);
65  if (p == results_.end())
67  return ((p - results_.begin()));
68  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< PerformanceResult::ResultType > results_

◆ serialize()

template<class Archive >
void PerformancePayloadFromTFormula::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 83 of file PerformancePayloadFromTFormula.h.

◆ cond::serialization::access

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

Definition at line 83 of file PerformancePayloadFromTFormula.h.

Member Data Documentation

◆ compiledFormulas_

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

Definition at line 81 of file PerformancePayloadFromTFormula.h.

Referenced by ~PerformancePayloadFromTFormula().

◆ InvalidPos

const int PerformancePayloadFromTFormula::InvalidPos = -1
static

◆ pl

PhysicsTFormulaPayload PerformancePayloadFromTFormula::pl
protected

Definition at line 72 of file PerformancePayloadFromTFormula.h.

Referenced by formulaPayload().

◆ results_

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

Definition at line 76 of file PerformancePayloadFromTFormula.h.

Referenced by resultPos().

◆ variables_

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

Definition at line 77 of file PerformancePayloadFromTFormula.h.

Referenced by limitPos(), and myBinning().