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 ()
 
 PerformancePayloadFromBinnedTFormula (const std::vector< PerformanceResult::ResultType > &r, const std::vector< BinningVariables::BinningVariablesType > &b, const std::vector< PhysicsTFormulaPayload > &in)
 
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.

25  : pls(in), results_(r), variables_(b) {
26  initialize();
27  }

References initialize().

◆ 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.

32 { compiledFormulas_.clear(); }

References compiledFormulas_.

Member Function Documentation

◆ formulaPayloads()

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

Definition at line 43 of file PerformancePayloadFromBinnedTFormula.h.

43 { return pls; }

References pls.

Referenced by PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::beginJob().

◆ getFormula()

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

Definition at line 25 of file PerformancePayloadFromBinnedTFormula.cc.

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 }

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

◆ getResult()

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

Implements PerformancePayload.

Definition at line 42 of file PerformancePayloadFromBinnedTFormula.cc.

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 }

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

◆ initialize()

void PerformancePayloadFromBinnedTFormula::initialize ( )
overridevirtual

Reimplemented from PerformancePayload.

Definition at line 11 of file PerformancePayloadFromBinnedTFormula.cc.

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 }

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

Referenced by PerformancePayloadFromBinnedTFormula().

◆ isInPayload()

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

Implements PerformancePayload.

Definition at line 105 of file PerformancePayloadFromBinnedTFormula.cc.

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 }

References InvalidPos, and point.

◆ isOk()

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

Definition at line 76 of file PerformancePayloadFromBinnedTFormula.cc.

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 }

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

◆ 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.

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  }

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

Referenced by isParametrizedInVariable().

◆ myBinning()

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

Definition at line 48 of file PerformancePayloadFromBinnedTFormula.h.

48 { return variables_; }

References variables_.

◆ printFormula()

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

Definition at line 116 of file PerformancePayloadFromBinnedTFormula.cc.

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 }

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

◆ resultPos()

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

Definition at line 58 of file PerformancePayloadFromBinnedTFormula.h.

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  }

References spr::find(), InvalidPos, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, and 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().

mps_fire.i
i
Definition: mps_fire.py:355
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
pfMETCorrectionType0_cfi.formula
formula
Definition: pfMETCorrectionType0_cfi.py:46
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
PhysicsTFormulaPayload
Definition: PhysicsTFormulaPayload.h:9
PerformancePayloadFromBinnedTFormula::results_
std::vector< PerformanceResult::ResultType > results_
Definition: PerformancePayloadFromBinnedTFormula.h:77
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
PerformancePayloadFromBinnedTFormula::compiledFormulas_
std::vector< std::vector< std::shared_ptr< TFormula > > > compiledFormulas_
Definition: PerformancePayloadFromBinnedTFormula.h:85
OrderedSet.t
t
Definition: OrderedSet.py:90
b
double b
Definition: hdecay.h:118
PerformancePayloadFromBinnedTFormula::InvalidPos
static const int InvalidPos
Definition: PerformancePayloadFromBinnedTFormula.h:20
PerformancePayloadFromBinnedTFormula::variables_
std::vector< BinningVariables::BinningVariablesType > variables_
Definition: PerformancePayloadFromBinnedTFormula.h:78
recoMuon::in
Definition: RecoMuonEnumerators.h:6
PerformancePayloadFromBinnedTFormula::initialize
void initialize() override
Definition: PerformancePayloadFromBinnedTFormula.cc:11
PerformancePayloadFromBinnedTFormula::limitPos
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
Definition: PerformancePayloadFromBinnedTFormula.h:50
res
Definition: Electron.h:6
PerformancePayloadFromBinnedTFormula::resultPos
virtual int resultPos(PerformanceResult::ResultType r) const
Definition: PerformancePayloadFromBinnedTFormula.h:58
alignCSCRings.r
r
Definition: alignCSCRings.py:93
TH2PolyOfflineMaps.limits
limits
Definition: TH2PolyOfflineMaps.py:45
BinningPointByMap
Definition: BinningPointByMap.h:8
PerformancePayloadFromBinnedTFormula::pls
std::vector< PhysicsTFormulaPayload > pls
Definition: PerformancePayloadFromBinnedTFormula.h:73
PerformancePayloadFromBinnedTFormula::isOk
bool isOk(const BinningPointByMap &p, unsigned int &) const
Definition: PerformancePayloadFromBinnedTFormula.cc:76
Exception
Definition: hltDiff.cc:246
PerformancePayloadFromBinnedTFormula::myBinning
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
Definition: PerformancePayloadFromBinnedTFormula.h:48
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
PerformancePayloadFromBinnedTFormula::getFormula
const std::shared_ptr< TFormula > & getFormula(PerformanceResult::ResultType, const BinningPointByMap &) const
Definition: PerformancePayloadFromBinnedTFormula.cc:25
PerformancePayload::InvalidResult
static const float InvalidResult
Definition: PerformancePayload.h:18
mps_fire.result
result
Definition: mps_fire.py:303
point
*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
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
edm::createGlobalIdentifier
std::string createGlobalIdentifier()
Definition: GlobalIdentifier.cc:5
PerformancePayloadFromBinnedTFormula::isInPayload
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
Definition: PerformancePayloadFromBinnedTFormula.cc:105