File indexing completed on 2024-04-06 12:02:27
0001 #include "CondFormats/PhysicsToolsObjects/interface/PerformancePayloadFromTable.h"
0002
0003 const int PerformancePayloadFromTable::InvalidPos = -1;
0004
0005 #include <iostream>
0006
0007 float PerformancePayloadFromTable::getResult(PerformanceResult::ResultType r, const BinningPointByMap& p) const {
0008 if (!isInPayload(r, p))
0009 return PerformancePayload::InvalidResult;
0010
0011
0012 for (int i = 0; i < pl.nRows(); i++) {
0013 PhysicsPerformancePayload::Row row = pl.getRow(i);
0014
0015 if (matches(p, row)) {
0016 int pos = resultPos(r);
0017 return row[pos];
0018 }
0019 }
0020 return PerformancePayload::InvalidResult;
0021 }
0022
0023 bool PerformancePayloadFromTable::matches(const BinningPointByMap& _p, PhysicsPerformancePayload::Row& row) const {
0024
0025
0026
0027
0028
0029 BinningPointByMap p = _p;
0030 std::vector<BinningVariables::BinningVariablesType> t = myBinning();
0031
0032 for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
0033
0034
0035
0036
0037 float v = p.value(*it);
0038 if (!(v >= row[minPos(*it)] && v < row[maxPos(*it)]))
0039 return false;
0040 }
0041 return true;
0042 }
0043
0044 bool PerformancePayloadFromTable::isInPayload(PerformanceResult::ResultType res,
0045 const BinningPointByMap& _point) const {
0046 BinningPointByMap point = _point;
0047
0048 if (resultPos(res) == PerformancePayloadFromTable::InvalidPos)
0049 return false;
0050
0051 std::vector<BinningVariables::BinningVariablesType> t = myBinning();
0052 for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end(); ++it) {
0053 if (!point.isKeyAvailable(*it))
0054 return false;
0055 }
0056
0057 for (int i = 0; i < pl.nRows(); i++) {
0058 PhysicsPerformancePayload::Row row = pl.getRow(i);
0059 if (matches(point, row)) {
0060 return true;
0061 }
0062 }
0063 return false;
0064 }
0065
0066 #include "FWCore/Utilities/interface/typelookup.h"
0067 TYPELOOKUP_DATA_REG(PerformancePayloadFromTable);