CMS 3D CMS Logo

Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes

PerformancePayloadFromTFormula Class Reference

#include <PerformancePayloadFromTFormula.h>

Inheritance diagram for PerformancePayloadFromTFormula:
PerformancePayload

List of all members.

Public Member Functions

const PhysicsTFormulaPayloadformulaPayload () const
float getResult (PerformanceResult::ResultType, BinningPointByMap) const
virtual bool isInPayload (PerformanceResult::ResultType, BinningPointByMap) const
virtual bool isParametrizedInVariable (const BinningVariables::BinningVariablesType p) const
 PerformancePayloadFromTFormula (std::vector< PerformanceResult::ResultType > r, std::vector< BinningVariables::BinningVariablesType > b, PhysicsTFormulaPayload &in)
 PerformancePayloadFromTFormula ()
void printFormula (PerformanceResult::ResultType res) const
virtual ~PerformancePayloadFromTFormula ()

Static Public Attributes

static int InvalidPos = -1

Protected Member Functions

void check () const
bool isOk (BinningPointByMap p) const
virtual int limitPos (const BinningVariables::BinningVariablesType b) const
virtual std::vector
< BinningVariables::BinningVariablesType
myBinning () const
virtual int resultPos (PerformanceResult::ResultType r) const

Protected Attributes

std::vector< TFormula * > compiledFormulas_
PhysicsTFormulaPayload pl
std::vector
< PerformanceResult::ResultType
results_
std::vector
< BinningVariables::BinningVariablesType
variables_

Detailed Description

Definition at line 14 of file PerformancePayloadFromTFormula.h.


Constructor & Destructor Documentation

PerformancePayloadFromTFormula::PerformancePayloadFromTFormula ( std::vector< PerformanceResult::ResultType r,
std::vector< BinningVariables::BinningVariablesType b,
PhysicsTFormulaPayload in 
) [inline]

Definition at line 20 of file PerformancePayloadFromTFormula.h.

: pl(in), results_(r), variables_(b) {}
PerformancePayloadFromTFormula::PerformancePayloadFromTFormula ( ) [inline]

Definition at line 22 of file PerformancePayloadFromTFormula.h.

{}
virtual PerformancePayloadFromTFormula::~PerformancePayloadFromTFormula ( ) [inline, virtual]

Definition at line 23 of file PerformancePayloadFromTFormula.h.

References compiledFormulas_, and i.

                                           {
    for (unsigned int i=0; i< compiledFormulas_.size(); ++i){
      delete compiledFormulas_[i];
    }
    compiledFormulas_.clear();
  }

Member Function Documentation

void PerformancePayloadFromTFormula::check ( ) const [protected]

Definition at line 57 of file PerformancePayloadFromTFormula.cc.

References i, and matplotRender::t.

                                                 {
  if (pl.formulas().size() == compiledFormulas_.size()) return;
  //
  // otherwise, compile!
  //
  for (unsigned int i=0; i< pl.formulas().size(); ++i){
    TFormula* t = new TFormula("rr",(pl.formulas()[i]).c_str()); //FIXME: "rr" should be unique!
    t->Compile();
    compiledFormulas_.push_back(t);
  }
}
const PhysicsTFormulaPayload& PerformancePayloadFromTFormula::formulaPayload ( ) const [inline]

Definition at line 38 of file PerformancePayloadFromTFormula.h.

References pl.

{return pl;}
float PerformancePayloadFromTFormula::getResult ( PerformanceResult::ResultType  r,
BinningPointByMap  p 
) const [virtual]

Implements PerformancePayload.

Definition at line 8 of file PerformancePayloadFromTFormula.cc.

References CastorDataFrameFilter_impl::check(), EcalElecEmulExample_cfg::formula, i, PerformancePayload::InvalidResult, matplotRender::t, BinningPointByMap::value(), and makeHLTPrescaleTable::values.

Referenced by PFEnergyCalibration::aBarrel(), PFEnergyCalibration::aEndcap(), PFEnergyCalibration::aEtaBarrel(), PFEnergyCalibration::aEtaEndcap(), PFEnergyCalibration::bBarrel(), PFEnergyCalibration::bEndcap(), PFEnergyCalibration::bEtaBarrel(), PFEnergyCalibration::bEtaEndcap(), PFEnergyCalibration::cBarrel(), and PFEnergyCalibration::cEndcap().

                                                                                                        {
  check();
  //
  // which formula to use?
  //
  if (! isInPayload(r,p)) return PerformancePayload::InvalidResult;

  // nice, what to do here???
  TFormula * formula = compiledFormulas_[resultPos(r)];
  //
  // prepare the vector to pass, order counts!!!
  //
  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
  
  // sorry, TFormulas just work up to dimension==4
  Double_t values[4];
  int i=0;
  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it, ++i){
    values[i] = p.value(*it);    
  }
  //
  // i need a non const version #$%^
  return formula->EvalPar(values);
}
bool PerformancePayloadFromTFormula::isInPayload ( PerformanceResult::ResultType  res,
BinningPointByMap  point 
) const [virtual]

Implements PerformancePayload.

Definition at line 47 of file PerformancePayloadFromTFormula.cc.

References CastorDataFrameFilter_impl::check(), and InvalidPos.

                                                                                                              {
  check();
  // first, let's see if it is available at all
  if (resultPos(res) == PerformancePayloadFromTFormula::InvalidPos) return false;
  
  if ( ! isOk(point)) return false;
  return true;
}
bool PerformancePayloadFromTFormula::isOk ( BinningPointByMap  p) const [protected]

Definition at line 33 of file PerformancePayloadFromTFormula.cc.

References BinningPointByMap::isKeyAvailable(), pos, matplotRender::t, v, and BinningPointByMap::value().

                                                                   {
  
  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
  
  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
    if (!   p.isKeyAvailable(*it)) return false;
    float v = p.value(*it);
    int pos = limitPos(*it);
    std::pair<float, float> limits = (pl.limits())[pos];
    if (v<limits.first || v>limits.second) return false;
  }
  return true;
}
virtual bool PerformancePayloadFromTFormula::isParametrizedInVariable ( const BinningVariables::BinningVariablesType  p) const [inline, virtual]

Definition at line 32 of file PerformancePayloadFromTFormula.h.

References InvalidPos, and limitPos().

virtual int PerformancePayloadFromTFormula::limitPos ( const BinningVariables::BinningVariablesType  b) const [inline, protected, virtual]

Definition at line 47 of file PerformancePayloadFromTFormula.h.

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

Referenced by isParametrizedInVariable().

                                                                           {
    std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
    p = find(variables_.begin(), variables_.end(), b);
    if (p == variables_.end()) return PerformancePayloadFromTFormula::InvalidPos;
    return ((p-variables_.begin()));
    
  }
virtual std::vector<BinningVariables::BinningVariablesType> PerformancePayloadFromTFormula::myBinning ( ) const [inline, protected, virtual]

Definition at line 45 of file PerformancePayloadFromTFormula.h.

References variables_.

{return variables_;}
void PerformancePayloadFromTFormula::printFormula ( PerformanceResult::ResultType  res) const

Definition at line 69 of file PerformancePayloadFromTFormula.cc.

References CastorDataFrameFilter_impl::check(), gather_cfg::cout, EcalElecEmulExample_cfg::formula, InvalidPos, pos, and matplotRender::t.

Referenced by operator<<().

                                                                                       {
  check();
  //
  // which formula to use?
  //
  if (resultPos(res) == PerformancePayloadFromTFormula::InvalidPos)  {
    cout << "Warning: result not available!" << endl;
  }
  
  // nice, what to do here???
  TFormula * formula = compiledFormulas_[resultPos(res)];
  cout << "-- Formula: " << formula->GetExpFormula("p") << endl;
  // prepare the vector to pass, order counts!!!
  //
  std::vector<BinningVariables::BinningVariablesType> t = myBinning();
  
  for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
    int pos = limitPos(*it);
    std::pair<float, float> limits = (pl.limits())[pos];
    cout << "      Variable: " << *it << " with limits: " << "from: " << limits.first  << " to: " << limits.second << endl;
  }

}
virtual int PerformancePayloadFromTFormula::resultPos ( PerformanceResult::ResultType  r) const [inline, protected, virtual]

Definition at line 55 of file PerformancePayloadFromTFormula.h.

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

                                                             {
    std::vector<PerformanceResult::ResultType>::const_iterator p;
    p = find (results_.begin(), results_.end(), r);
    if ( p == results_.end()) return PerformancePayloadFromTFormula::InvalidPos;
      return ((p-results_.begin()));
  }

Member Data Documentation

std::vector<TFormula *> PerformancePayloadFromTFormula::compiledFormulas_ [mutable, protected]

Definition at line 76 of file PerformancePayloadFromTFormula.h.

Referenced by ~PerformancePayloadFromTFormula().

Definition at line 67 of file PerformancePayloadFromTFormula.h.

Referenced by formulaPayload().

Definition at line 71 of file PerformancePayloadFromTFormula.h.

Referenced by resultPos().

Definition at line 72 of file PerformancePayloadFromTFormula.h.

Referenced by limitPos(), and myBinning().