CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CondFormats/PhysicsToolsObjects/interface/PerformancePayloadFromTable.h

Go to the documentation of this file.
00001 #ifndef PerformancePayloadFromTable_h
00002 #define PerformancePayloadFromTable_h
00003 
00004 #include "CondFormats/PhysicsToolsObjects/interface/PhysicsPerformancePayload.h"
00005 #include "CondFormats/PhysicsToolsObjects/interface/PerformancePayload.h"
00006 
00007 #include <algorithm>
00008 #include <string>
00009 #include <vector>
00010 
00011 #include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h"
00012 
00013 class PerformancePayloadFromTable : public PerformancePayload {
00014 //  class PerformancePayloadFromTable : public PerformancePayload, public PhysicsPerformancePayload {
00015  public:
00016 
00017   static int InvalidPos;
00018 
00019   //PerformancePayloadFromTable(int stride_, std::string columns_,std::vector<float> table) : PerformancePayload(stride_, columns_, table) {}
00020 
00021     PerformancePayloadFromTable(std::vector<PerformanceResult::ResultType> r, std::vector<BinningVariables::BinningVariablesType> b , int stride_,std::vector<float> table) : 
00022       pl(stride_, table),
00023       results_(r), binning_(b) {}
00024 
00025   PerformancePayloadFromTable(){}
00026 virtual ~PerformancePayloadFromTable(){}
00027 
00028   float getResult(PerformanceResult::ResultType,BinningPointByMap) const ; // gets from the full payload
00029 
00030   virtual bool isParametrizedInVariable(const BinningVariables::BinningVariablesType p)  const {
00031     return (minPos(p) != PerformancePayloadFromTable::InvalidPos);
00032   }
00033   
00034   virtual bool isInPayload(PerformanceResult::ResultType,BinningPointByMap) const ;
00035 
00036 const PhysicsPerformancePayload & payLoad() const {return pl;}
00037 
00038  protected:
00039 
00040  virtual std::vector<BinningVariables::BinningVariablesType> myBinning() const {return binning_;}
00041 
00042   virtual int minPos(const BinningVariables::BinningVariablesType b) const {
00043     std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
00044     p = find(binning_.begin(), binning_.end(), b);
00045     if (p == binning_.end()) return PerformancePayloadFromTable::InvalidPos;
00046     return ((p-binning_.begin())*2);
00047   }
00048   virtual int maxPos(const BinningVariables::BinningVariablesType b) const {
00049     std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
00050     p = find(binning_.begin(), binning_.end(), b);
00051     if (p == binning_.end()) return PerformancePayloadFromTable::InvalidPos;
00052     return ((p-binning_.begin())*2+1);
00053 
00054   }    
00055     virtual int resultPos(PerformanceResult::ResultType r ) const {
00056       // result should be: # of binning variables *2 + position of result
00057       std::vector<PerformanceResult::ResultType>::const_iterator p;
00058       p = find (results_.begin(), results_.end(), r);
00059       if ( p == results_.end()) return PerformancePayloadFromTable::InvalidPos;
00060       return (binning_.size()*2+(p-results_.begin()));
00061       
00062   }
00063 
00064   bool matches(BinningPointByMap, PhysicsPerformancePayload::Row &) const;
00065 
00066   PhysicsPerformancePayload pl;
00067 
00068   std::vector<PerformanceResult::ResultType> results_;
00069   std::vector<BinningVariables::BinningVariablesType> binning_;
00070   
00071 };
00072 
00073 #endif
00074