CMS 3D CMS Logo

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

PerformancePayloadFromBinnedTFormula Class Reference

#include <PerformancePayloadFromBinnedTFormula.h>

Inheritance diagram for PerformancePayloadFromBinnedTFormula:
PerformancePayload

List of all members.

Public Member Functions

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

Static Public Attributes

static int InvalidPos = -1

Protected Member Functions

void check () const
TFormula * getFormula (PerformanceResult::ResultType, BinningPointByMap) const
bool isOk (BinningPointByMap p, unsigned int &) 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< std::vector
< TFormula * > > 
compiledFormulas_
std::vector
< PhysicsTFormulaPayload
pls
std::vector
< PerformanceResult::ResultType
results_
std::vector
< BinningVariables::BinningVariablesType
variables_

Detailed Description

Definition at line 14 of file PerformancePayloadFromBinnedTFormula.h.


Constructor & Destructor Documentation

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

Definition at line 20 of file PerformancePayloadFromBinnedTFormula.h.

PerformancePayloadFromBinnedTFormula::PerformancePayloadFromBinnedTFormula ( ) [inline]

Definition at line 22 of file PerformancePayloadFromBinnedTFormula.h.

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

Definition at line 23 of file PerformancePayloadFromBinnedTFormula.h.

References compiledFormulas_.

                                                 {
    compiledFormulas_.clear();
  }

Member Function Documentation

void PerformancePayloadFromBinnedTFormula::check ( ) const [protected]

Definition at line 87 of file PerformancePayloadFromBinnedTFormula.cc.

References PhysicsTFormulaPayload::formulas(), i, findQualityFiles::size, lumiQTWidget::t, groupFilesInBlocks::temp, tmp, and groupFilesInBlocks::tt.

                                                       {
  if (pls.size()== compiledFormulas_.size()) return;
  //
  // otherwise, compile!
  //
  compiledFormulas_.clear();
  for (unsigned int t=0; t< pls.size(); ++t){
    std::vector <TFormula *> temp;
    for (unsigned int i=0; i< (pls[t].formulas()).size(); ++i){
      PhysicsTFormulaPayload  tmp = pls[t];
      TFormula* tt = new TFormula("rr",((tmp.formulas())[i]).c_str()); //FIXME: "rr" should be unique!
      tt->Compile();
      temp.push_back(tt);
    }
    compiledFormulas_.push_back(temp);
  }
}
const std::vector<PhysicsTFormulaPayload>& PerformancePayloadFromBinnedTFormula::formulaPayloads ( ) const [inline]
TFormula * PerformancePayloadFromBinnedTFormula::getFormula ( PerformanceResult::ResultType  r,
BinningPointByMap  p 
) const [protected]

Definition at line 9 of file PerformancePayloadFromBinnedTFormula.cc.

References NULL, and convertSQLiteXML::ok.

                                                                                                                     {
  //
  // chooses the correct rectangular region
  //
  if (! isInPayload(r,p)) return NULL;
  unsigned int region;
  bool ok =  isOk(p,region);
  if (ok == false) return NULL;

  return compiledFormulas_[region][resultPos(r)];

}
float PerformancePayloadFromBinnedTFormula::getResult ( PerformanceResult::ResultType  r,
BinningPointByMap  p 
) const [virtual]

Implements PerformancePayload.

Definition at line 22 of file PerformancePayloadFromBinnedTFormula.cc.

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

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

  // nice, what to do here???
  //  TFormula * formula = compiledFormulas_[resultPos(r)];
  //

  TFormula * formula = getFormula(r,p);

  // 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 PerformancePayloadFromBinnedTFormula::isInPayload ( PerformanceResult::ResultType  res,
BinningPointByMap  point 
) const [virtual]

Implements PerformancePayload.

Definition at line 77 of file PerformancePayloadFromBinnedTFormula.cc.

References CastorDataFrameFilter_impl::check(), and InvalidPos.

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

Definition at line 50 of file PerformancePayloadFromBinnedTFormula.cc.

References BinningPointByMap::isKeyAvailable(), pos, query::result, lumiQTWidget::t, v, and BinningPointByMap::value().

                                                                                                {
  
  //
  // change: look on whether a single rectangularr region matches
  //
  for (unsigned int ti=0; ti< pls.size(); ++ti){
    bool result = true;
    std::vector<BinningVariables::BinningVariablesType>  t = myBinning();
    for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
      //
      // now looking into a single payload
      //
      if (!   p.isKeyAvailable(*it)) return false;
      float v = p.value(*it);
      int pos = limitPos(*it);
      std::pair<float, float> limits = (pls[ti].limits())[pos];
      if (v<limits.first || v>limits.second) result= false;
    }
    if (result == true)  {
      whichone = ti;
      return true;
    }
  }
  whichone = 9999;
  return false;
}
virtual bool PerformancePayloadFromBinnedTFormula::isParametrizedInVariable ( const BinningVariables::BinningVariablesType  p) const [inline, virtual]
virtual int PerformancePayloadFromBinnedTFormula::limitPos ( const BinningVariables::BinningVariablesType  b) const [inline, protected, virtual]

Definition at line 44 of file PerformancePayloadFromBinnedTFormula.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 PerformancePayloadFromBinnedTFormula::InvalidPos;
    return ((p-variables_.begin()));
    
  }
virtual std::vector<BinningVariables::BinningVariablesType> PerformancePayloadFromBinnedTFormula::myBinning ( ) const [inline, protected, virtual]

Definition at line 42 of file PerformancePayloadFromBinnedTFormula.h.

References variables_.

{return variables_;}
void PerformancePayloadFromBinnedTFormula::printFormula ( PerformanceResult::ResultType  res,
BinningPointByMap  point 
) const

Definition at line 108 of file PerformancePayloadFromBinnedTFormula.cc.

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

                                                                                                                     {
  check();
  //
  // which formula to use?
  //
  if (resultPos(res) == PerformancePayloadFromBinnedTFormula::InvalidPos)  {
    cout << "Warning: result not available!" << endl;
  }
  
  // nice, what to do here???
  TFormula * formula = getFormula(res, point);
  unsigned int whichone;
  isOk(point,whichone);
  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 = (pls[whichone].limits())[pos];
    cout << "      Variable: " << *it << " with limits: " << "from: " << limits.first  << " to: " << limits.second << endl;
  }

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

Definition at line 52 of file PerformancePayloadFromBinnedTFormula.h.

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

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

Member Data Documentation

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

Definition at line 68 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by formulaPayloads().

Definition at line 72 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by resultPos().

Definition at line 73 of file PerformancePayloadFromBinnedTFormula.h.

Referenced by limitPos(), and myBinning().