PerformancePayloadFromTable

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
#ifndef PerformancePayloadFromTable_h
#define PerformancePayloadFromTable_h

#include "CondFormats/Serialization/interface/Serializable.h"

#include "CondFormats/PhysicsToolsObjects/interface/PhysicsPerformancePayload.h"
#include "CondFormats/PhysicsToolsObjects/interface/PerformancePayload.h"

#include <algorithm>
#include <string>
#include <vector>

#include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h"

class PerformancePayloadFromTable : public PerformancePayload {
  //  class PerformancePayloadFromTable : public PerformancePayload, public PhysicsPerformancePayload {
public:
  static const int InvalidPos;

  //PerformancePayloadFromTable(int stride_, std::string columns_,std::vector<float> table) : PerformancePayload(stride_, columns_, table) {}

  PerformancePayloadFromTable(const std::vector<PerformanceResult::ResultType>& r,
                              const std::vector<BinningVariables::BinningVariablesType>& b,
                              int stride_,
                              const std::vector<float>& table)
      : pl(stride_, table), results_(r), binning_(b) {}

  PerformancePayloadFromTable() {}
  ~PerformancePayloadFromTable() override {}

  float getResult(PerformanceResult::ResultType,
                  const BinningPointByMap&) const override;  // gets from the full payload

  virtual bool isParametrizedInVariable(const BinningVariables::BinningVariablesType p) const {
    return (minPos(p) != PerformancePayloadFromTable::InvalidPos);
  }

  bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap&) const override;

  const PhysicsPerformancePayload& payLoad() const { return pl; }

protected:
  virtual std::vector<BinningVariables::BinningVariablesType> myBinning() const { return binning_; }

  virtual int minPos(const BinningVariables::BinningVariablesType b) const {
    std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
    p = find(binning_.begin(), binning_.end(), b);
    if (p == binning_.end())
      return PerformancePayloadFromTable::InvalidPos;
    return ((p - binning_.begin()) * 2);
  }
  virtual int maxPos(const BinningVariables::BinningVariablesType b) const {
    std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
    p = find(binning_.begin(), binning_.end(), b);
    if (p == binning_.end())
      return PerformancePayloadFromTable::InvalidPos;
    return ((p - binning_.begin()) * 2 + 1);
  }
  virtual int resultPos(PerformanceResult::ResultType r) const {
    // result should be: # of binning variables *2 + position of result
    std::vector<PerformanceResult::ResultType>::const_iterator p;
    p = find(results_.begin(), results_.end(), r);
    if (p == results_.end())
      return PerformancePayloadFromTable::InvalidPos;
    return (binning_.size() * 2 + (p - results_.begin()));
  }

  bool matches(const BinningPointByMap&, PhysicsPerformancePayload::Row&) const;

  PhysicsPerformancePayload pl;

  std::vector<PerformanceResult::ResultType> results_;
  std::vector<BinningVariables::BinningVariablesType> binning_;

  COND_SERIALIZABLE;
};

#endif