CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CondFormats/PhysicsToolsObjects/interface/PerformancePayloadFromBinnedTFormula.h

Go to the documentation of this file.
00001 #ifndef PerformancePayloadFromBinnedTFormula_h
00002 #define PerformancePayloadFromBinnedTFormula_h
00003 
00004 #include "CondFormats/PhysicsToolsObjects/interface/PhysicsTFormulaPayload.h"
00005 #include "CondFormats/PhysicsToolsObjects/interface/PerformancePayload.h"
00006 
00007 #include <algorithm>
00008 #include <string>
00009 #include <vector>
00010 #include "TFormula.h"
00011 
00012 #include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h"
00013 
00014 class PerformancePayloadFromBinnedTFormula : public PerformancePayload {
00015 //  class PerformancePayloadFromBinnedTFormula : public PerformancePayload, public PhysicsPerformancePayload {
00016  public:
00017 
00018   static int InvalidPos;
00019 
00020   PerformancePayloadFromBinnedTFormula(std::vector<PerformanceResult::ResultType> r, std::vector<BinningVariables::BinningVariablesType> b  ,  std::vector<PhysicsTFormulaPayload> in) : pls(in), results_(r), variables_(b) {}
00021 
00022   PerformancePayloadFromBinnedTFormula(){}
00023   virtual ~PerformancePayloadFromBinnedTFormula(){
00024     compiledFormulas_.clear();
00025   }
00026 
00027   float getResult(PerformanceResult::ResultType,BinningPointByMap) const ; // gets from the full payload
00028   
00029   virtual bool isParametrizedInVariable(const BinningVariables::BinningVariablesType p)  const {
00030     return (limitPos(p) != PerformancePayloadFromBinnedTFormula::InvalidPos);
00031   }
00032   
00033   virtual bool isInPayload(PerformanceResult::ResultType,BinningPointByMap) const ;
00034   
00035   const std::vector<PhysicsTFormulaPayload> & formulaPayloads() const {return pls;}
00036   
00037   void printFormula(PerformanceResult::ResultType res, BinningPointByMap) const;
00038   
00039 
00040  protected:
00041   
00042   virtual std::vector<BinningVariables::BinningVariablesType> myBinning() const {return variables_;}
00043 
00044   virtual int limitPos(const BinningVariables::BinningVariablesType b) const {
00045     std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
00046     p = find(variables_.begin(), variables_.end(), b);
00047     if (p == variables_.end()) return PerformancePayloadFromBinnedTFormula::InvalidPos;
00048     return ((p-variables_.begin()));
00049     
00050   }
00051 
00052   virtual int resultPos(PerformanceResult::ResultType r) const {
00053     std::vector<PerformanceResult::ResultType>::const_iterator p;
00054     p = find (results_.begin(), results_.end(), r);
00055     if ( p == results_.end()) return PerformancePayloadFromBinnedTFormula::InvalidPos;
00056       return ((p-results_.begin()));
00057   }
00058 
00059 
00060   bool isOk(BinningPointByMap p, unsigned int & ) const; 
00061 
00062   TFormula * getFormula(PerformanceResult::ResultType,BinningPointByMap) const;
00063 
00064   void check() const;
00065   //
00066   // now this is a vector, since we can have different rectangular regions in the same object
00067   //
00068   std::vector<PhysicsTFormulaPayload> pls;
00069   //
00070   // the variable mapping
00071   //
00072   std::vector<PerformanceResult::ResultType> results_;
00073   std::vector<BinningVariables::BinningVariablesType> variables_;
00074   
00075   //
00076   // the transient part; now a vector of vector; CHANGE CHECK!!!!!
00077   //
00078   mutable   std::vector<std::vector<TFormula *> > compiledFormulas_;
00079 };
00080 
00081 #endif
00082