CMS 3D CMS Logo

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

const std::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::BinningVariablesTypemyBinning () const
 
virtual int resultPos (PerformanceResult::ResultType r) const
 

Protected Attributes

std::vector< std::vector< std::shared_ptr< TFormula > > > compiledFormulas_
 
std::vector< PhysicsTFormulaPayloadpls
 
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 PerformancePayloadFromBinnedTFormula.h.

Constructor & Destructor Documentation

◆ PerformancePayloadFromBinnedTFormula() [1/2]

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

Definition at line 22 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:118

◆ PerformancePayloadFromBinnedTFormula() [2/2]

PerformancePayloadFromBinnedTFormula::PerformancePayloadFromBinnedTFormula ( )
inline

Definition at line 31 of file PerformancePayloadFromBinnedTFormula.h.

31 {}

◆ ~PerformancePayloadFromBinnedTFormula()

PerformancePayloadFromBinnedTFormula::~PerformancePayloadFromBinnedTFormula ( )
inlineoverride

Definition at line 32 of file PerformancePayloadFromBinnedTFormula.h.

References compiledFormulas_.

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

Member Function Documentation

◆ formulaPayloads()

const std::vector<PhysicsTFormulaPayload>& PerformancePayloadFromBinnedTFormula::formulaPayloads ( ) const
inline

Definition at line 43 of file PerformancePayloadFromBinnedTFormula.h.

References pls.

Referenced by PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::beginJob().

43 { return pls; }

◆ getFormula()

const std::shared_ptr< TFormula > & PerformancePayloadFromBinnedTFormula::getFormula ( PerformanceResult::ResultType  r,
const BinningPointByMap p 
) const
protected

Definition at line 25 of file PerformancePayloadFromBinnedTFormula.cc.

References Exception, convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, and HLT_2022v12_cff::region.

26  {
27  //
28  // chooses the correct rectangular region
29  //
30  if (!isInPayload(r, p)) {
31  throw cms::Exception("MalformedPerfPayload") << "Requested performance data not available!";
32  }
33  unsigned int region;
34  bool ok = isOk(p, region);
35  if (ok == false) {
36  throw cms::Exception("MalformedPerfPayload") << "Requested variable does not match internal structure!";
37  }
38 
40 }
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
virtual int resultPos(PerformanceResult::ResultType r) const
std::vector< std::vector< std::shared_ptr< TFormula > > > compiledFormulas_
bool isOk(const BinningPointByMap &p, unsigned int &) const

◆ getResult()

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

Implements PerformancePayload.

Definition at line 42 of file PerformancePayloadFromBinnedTFormula.cc.

References pfMETCorrectionType0_cfi::formula, mps_fire::i, PerformancePayload::InvalidResult, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, submitPVValidationJobs::t, and contentValuesCheck::values.

43  {
44  BinningPointByMap p = _p;
45  //
46  // which formula to use?
47  //
48  if (!isInPayload(r, p))
50 
51  // nice, what to do here???
52  // TFormula * formula = compiledFormulas_[resultPos(r)];
53  //
54 
55  const std::shared_ptr<TFormula>& formula = getFormula(r, p);
56 
57  // prepare the vector to pass, order counts!!!
58  //
59  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
60 
61  // sorry, TFormulas just work up to dimension==4
62  Double_t values[4];
63  int i = 0;
64  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it, ++i) {
65  values[i] = p.value(*it);
66  }
67  //
68  // i need a non const version
69  // Note, in current implementation of TFormula EvalPar should be
70  // thread safe as it does nothing more than call a function
71  // through a function pointer which is stateless. In spite of the
72  // fact that it is not const.
73  return formula->EvalPar(values);
74 }
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
static const float InvalidResult
const std::shared_ptr< TFormula > & getFormula(PerformanceResult::ResultType, const BinningPointByMap &) const
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const

◆ initialize()

void PerformancePayloadFromBinnedTFormula::initialize ( )
overridevirtual

Reimplemented from PerformancePayload.

Definition at line 11 of file PerformancePayloadFromBinnedTFormula.cc.

References edm::createGlobalIdentifier(), mps_fire::i, findQualityFiles::size, submitPVValidationJobs::t, groupFilesInBlocks::temp, createJobs::tmp, and groupFilesInBlocks::tt.

Referenced by PerformancePayloadFromBinnedTFormula().

11  {
12  for (unsigned int t = 0; t < pls.size(); ++t) {
13  std::vector<std::shared_ptr<TFormula> > temp;
14  for (unsigned int i = 0; i < (pls[t].formulas()).size(); ++i) {
15  const auto formulaUniqueName = edm::createGlobalIdentifier();
17  std::shared_ptr<TFormula> tt(new TFormula(formulaUniqueName.c_str(), tmp.formulas()[i].c_str()));
18  tt->Compile();
19  temp.push_back(tt);
20  }
21  compiledFormulas_.push_back(temp);
22  }
23 }
size
Write out results.
std::string createGlobalIdentifier(bool binary=false)
std::vector< std::vector< std::shared_ptr< TFormula > > > compiledFormulas_
tmp
align.sh
Definition: createJobs.py:716

◆ isInPayload()

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

Implements PerformancePayload.

Definition at line 105 of file PerformancePayloadFromBinnedTFormula.cc.

References InvalidPos, and point.

106  {
107  // first, let's see if it is available at all
109  return false;
110  unsigned int whocares;
111  if (!isOk(point, whocares))
112  return false;
113  return true;
114 }
Definition: Electron.h:6
virtual int resultPos(PerformanceResult::ResultType r) const
bool isOk(const BinningPointByMap &p, unsigned int &) const
*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

◆ isOk()

bool PerformancePayloadFromBinnedTFormula::isOk ( const BinningPointByMap p,
unsigned int &  whichone 
) const
protected

Definition at line 76 of file PerformancePayloadFromBinnedTFormula.cc.

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

76  {
77  BinningPointByMap p = _p;
78  //
79  // change: look on whether a single rectangularr region matches
80  //
81  for (unsigned int ti = 0; ti < pls.size(); ++ti) {
82  bool result = true;
83  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
84  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
85  //
86  // now looking into a single payload
87  //
88  if (!p.isKeyAvailable(*it))
89  return false;
90  float v = p.value(*it);
91  int pos = limitPos(*it);
92  std::pair<float, float> limits = (pls[ti].limits())[pos];
93  if (v < limits.first || v > limits.second)
94  result = false;
95  }
96  if (result == true) {
97  whichone = ti;
98  return true;
99  }
100  }
101  whichone = 9999;
102  return false;
103 }
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
virtual int limitPos(const BinningVariables::BinningVariablesType b) const

◆ isParametrizedInVariable()

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

◆ limitPos()

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

Definition at line 50 of file PerformancePayloadFromBinnedTFormula.h.

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

Referenced by isParametrizedInVariable().

50  {
51  std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
52  p = find(variables_.begin(), variables_.end(), b);
53  if (p == variables_.end())
55  return ((p - variables_.begin()));
56  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< BinningVariables::BinningVariablesType > variables_
double b
Definition: hdecay.h:118

◆ myBinning()

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

Definition at line 48 of file PerformancePayloadFromBinnedTFormula.h.

References variables_.

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

◆ printFormula()

void PerformancePayloadFromBinnedTFormula::printFormula ( PerformanceResult::ResultType  res,
const BinningPointByMap point 
) const

Definition at line 116 of file PerformancePayloadFromBinnedTFormula.cc.

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

117  {
118  //
119  // which formula to use?
120  //
122  cout << "Warning: result not available!" << endl;
123  }
124 
125  // nice, what to do here???
126  const std::shared_ptr<TFormula>& formula = getFormula(res, point);
127  unsigned int whichone;
128  isOk(point, whichone);
129  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
130  // prepare the vector to pass, order counts!!!
131  //
132  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
133 
134  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
135  int pos = limitPos(*it);
136  std::pair<float, float> limits = (pls[whichone].limits())[pos];
137  cout << " Variable: " << *it << " with limits: "
138  << "from: " << limits.first << " to: " << limits.second << endl;
139  }
140 }
Definition: Electron.h:6
const std::shared_ptr< TFormula > & getFormula(PerformanceResult::ResultType, const BinningPointByMap &) const
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
virtual int resultPos(PerformanceResult::ResultType r) const
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
bool isOk(const BinningPointByMap &p, unsigned int &) const
*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

◆ resultPos()

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

Definition at line 58 of file PerformancePayloadFromBinnedTFormula.h.

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

58  {
59  std::vector<PerformanceResult::ResultType>::const_iterator p;
60  p = find(results_.begin(), results_.end(), r);
61  if (p == results_.end())
63  return ((p - results_.begin()));
64  }
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 PerformancePayloadFromBinnedTFormula::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 88 of file PerformancePayloadFromBinnedTFormula.h.

◆ cond::serialization::access

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

Definition at line 88 of file PerformancePayloadFromBinnedTFormula.h.

Member Data Documentation

◆ compiledFormulas_

std::vector<std::vector<std::shared_ptr<TFormula> > > PerformancePayloadFromBinnedTFormula::compiledFormulas_
protected

◆ InvalidPos

const int PerformancePayloadFromBinnedTFormula::InvalidPos = -1
static

◆ pls

std::vector<PhysicsTFormulaPayload> PerformancePayloadFromBinnedTFormula::pls
protected

Definition at line 73 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by formulaPayloads().

◆ results_

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

Definition at line 77 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by resultPos().

◆ variables_

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

Definition at line 78 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by limitPos(), and myBinning().