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

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

References initialize().

◆ 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_) {}

◆ ~PerformancePayloadFromTFormula()

PerformancePayloadFromTFormula::~PerformancePayloadFromTFormula ( )
inlineoverride

Definition at line 36 of file PerformancePayloadFromTFormula.h.

36 { compiledFormulas_.clear(); }

References compiledFormulas_.

Member Function Documentation

◆ formulaPayload()

const PhysicsTFormulaPayload& PerformancePayloadFromTFormula::formulaPayload ( ) const
inline

Definition at line 47 of file PerformancePayloadFromTFormula.h.

47 { return pl; }

References pl.

◆ getResult()

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

Implements PerformancePayload.

Definition at line 21 of file PerformancePayloadFromTFormula.cc.

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 }

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

◆ initialize()

void PerformancePayloadFromTFormula::initialize ( )
overridevirtual

Reimplemented from PerformancePayload.

Definition at line 10 of file PerformancePayloadFromTFormula.cc.

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 }

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

Referenced by PerformancePayloadFromTFormula().

◆ isInPayload()

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

Implements PerformancePayload.

Definition at line 64 of file PerformancePayloadFromTFormula.cc.

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 }

References InvalidPos, and point.

◆ isOk()

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

Definition at line 48 of file PerformancePayloadFromTFormula.cc.

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 }

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

◆ isParametrizedInVariable()

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

◆ limitPos()

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

Definition at line 54 of file PerformancePayloadFromTFormula.h.

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  }

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

Referenced by isParametrizedInVariable().

◆ myBinning()

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

Definition at line 52 of file PerformancePayloadFromTFormula.h.

52 { return variables_; }

References variables_.

◆ printFormula()

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

Definition at line 75 of file PerformancePayloadFromTFormula.cc.

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 }

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

◆ resultPos()

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

Definition at line 62 of file PerformancePayloadFromTFormula.h.

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  }

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

mps_fire.i
i
Definition: mps_fire.py:355
PerformancePayloadFromTFormula::resultPos
virtual int resultPos(PerformanceResult::ResultType r) const
Definition: PerformancePayloadFromTFormula.h:62
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
PerformancePayloadFromTFormula::initialize
void initialize() override
Definition: PerformancePayloadFromTFormula.cc:10
cms::cuda::assert
assert(be >=bs)
findQualityFiles.v
v
Definition: findQualityFiles.py:179
PhysicsTFormulaPayload::limits
const std::vector< std::pair< float, float > > & limits() const
Definition: PhysicsTFormulaPayload.h:14
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
PerformancePayloadFromTFormula::isInPayload
bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap &) const override
Definition: PerformancePayloadFromTFormula.cc:64
OrderedSet.t
t
Definition: OrderedSet.py:90
b
double b
Definition: hdecay.h:118
edm::LogError
Definition: MessageLogger.h:183
recoMuon::in
Definition: RecoMuonEnumerators.h:6
PerformancePayloadFromTFormula::compiledFormulas_
std::vector< std::shared_ptr< const TFormula > > compiledFormulas_
Definition: PerformancePayloadFromTFormula.h:81
res
Definition: Electron.h:6
alignCSCRings.r
r
Definition: alignCSCRings.py:93
TH2PolyOfflineMaps.limits
limits
Definition: TH2PolyOfflineMaps.py:45
BinningPointByMap
Definition: BinningPointByMap.h:8
PerformancePayloadFromTFormula::myBinning
virtual std::vector< BinningVariables::BinningVariablesType > myBinning() const
Definition: PerformancePayloadFromTFormula.h:52
eostools.move
def move(src, dest)
Definition: eostools.py:511
PerformancePayloadFromTFormula::results_
std::vector< PerformanceResult::ResultType > results_
Definition: PerformancePayloadFromTFormula.h:76
PerformancePayloadFromTFormula::limitPos
virtual int limitPos(const BinningVariables::BinningVariablesType b) const
Definition: PerformancePayloadFromTFormula.h:54
PerformancePayloadFromTFormula::isOk
bool isOk(const BinningPointByMap &p) const
Definition: PerformancePayloadFromTFormula.cc:48
PerformancePayloadFromTFormula::variables_
std::vector< BinningVariables::BinningVariablesType > variables_
Definition: PerformancePayloadFromTFormula.h:77
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
PerformancePayloadFromTFormula::pl
PhysicsTFormulaPayload pl
Definition: PerformancePayloadFromTFormula.h:72
PhysicsTFormulaPayload::formulas
const std::vector< std::string > & formulas() const
Definition: PhysicsTFormulaPayload.h:15
PerformancePayloadFromTFormula::InvalidPos
static const int InvalidPos
Definition: PerformancePayloadFromTFormula.h:20
edm::createGlobalIdentifier
std::string createGlobalIdentifier()
Definition: GlobalIdentifier.cc:5