Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:24

0001 #ifndef PerformancePayloadFromTable_h
0002 #define PerformancePayloadFromTable_h
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include "CondFormats/PhysicsToolsObjects/interface/PhysicsPerformancePayload.h"
0007 #include "CondFormats/PhysicsToolsObjects/interface/PerformancePayload.h"
0008 
0009 #include <algorithm>
0010 #include <string>
0011 #include <vector>
0012 
0013 #include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h"
0014 
0015 class PerformancePayloadFromTable : public PerformancePayload {
0016   //  class PerformancePayloadFromTable : public PerformancePayload, public PhysicsPerformancePayload {
0017 public:
0018   static const int InvalidPos;
0019 
0020   //PerformancePayloadFromTable(int stride_, std::string columns_,std::vector<float> table) : PerformancePayload(stride_, columns_, table) {}
0021 
0022   PerformancePayloadFromTable(const std::vector<PerformanceResult::ResultType>& r,
0023                               const std::vector<BinningVariables::BinningVariablesType>& b,
0024                               int stride_,
0025                               const std::vector<float>& table)
0026       : pl(stride_, table), results_(r), binning_(b) {}
0027 
0028   PerformancePayloadFromTable() {}
0029   ~PerformancePayloadFromTable() override {}
0030 
0031   float getResult(PerformanceResult::ResultType,
0032                   const BinningPointByMap&) const override;  // gets from the full payload
0033 
0034   virtual bool isParametrizedInVariable(const BinningVariables::BinningVariablesType p) const {
0035     return (minPos(p) != PerformancePayloadFromTable::InvalidPos);
0036   }
0037 
0038   bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap&) const override;
0039 
0040   const PhysicsPerformancePayload& payLoad() const { return pl; }
0041 
0042 protected:
0043   virtual std::vector<BinningVariables::BinningVariablesType> myBinning() const { return binning_; }
0044 
0045   virtual int minPos(const BinningVariables::BinningVariablesType b) const {
0046     std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
0047     p = find(binning_.begin(), binning_.end(), b);
0048     if (p == binning_.end())
0049       return PerformancePayloadFromTable::InvalidPos;
0050     return ((p - binning_.begin()) * 2);
0051   }
0052   virtual int maxPos(const BinningVariables::BinningVariablesType b) const {
0053     std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
0054     p = find(binning_.begin(), binning_.end(), b);
0055     if (p == binning_.end())
0056       return PerformancePayloadFromTable::InvalidPos;
0057     return ((p - binning_.begin()) * 2 + 1);
0058   }
0059   virtual int resultPos(PerformanceResult::ResultType r) const {
0060     // result should be: # of binning variables *2 + position of result
0061     std::vector<PerformanceResult::ResultType>::const_iterator p;
0062     p = find(results_.begin(), results_.end(), r);
0063     if (p == results_.end())
0064       return PerformancePayloadFromTable::InvalidPos;
0065     return (binning_.size() * 2 + (p - results_.begin()));
0066   }
0067 
0068   bool matches(const BinningPointByMap&, PhysicsPerformancePayload::Row&) const;
0069 
0070   PhysicsPerformancePayload pl;
0071 
0072   std::vector<PerformanceResult::ResultType> results_;
0073   std::vector<BinningVariables::BinningVariablesType> binning_;
0074 
0075   COND_SERIALIZABLE;
0076 };
0077 
0078 #endif