CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CondFormats/PhysicsToolsObjects/src/PerformancePayloadFromTable.cc

Go to the documentation of this file.
00001 #include "CondFormats/PhysicsToolsObjects/interface/PerformancePayloadFromTable.h"
00002 
00003 int PerformancePayloadFromTable::InvalidPos=-1;
00004 
00005 #include <iostream>
00006 
00007 
00008 float PerformancePayloadFromTable::getResult(PerformanceResult::ResultType r ,BinningPointByMap p) const {
00009 
00010   if (! isInPayload(r,p)) return  PerformancePayload::InvalidResult;
00011 
00012   // loop on the table rows and search for a match
00013   for (int i=0; i< pl.nRows(); i++){
00014     PhysicsPerformancePayload::Row  row = pl.getRow(i);
00015 
00016     if (matches(p,row)){
00017       int pos = resultPos(r);
00018       return row[pos];
00019     }
00020   }
00021   return PerformancePayload::InvalidResult;
00022 }
00023 
00024 bool PerformancePayloadFromTable::matches(BinningPointByMap p, PhysicsPerformancePayload::Row & row) const {
00025   //
00026   // this is the smart function which does not take into account the fields not present 
00027   //
00028 
00029   // I can do it via a loop!
00030   
00031     std::vector<BinningVariables::BinningVariablesType> t = myBinning();
00032 
00033 
00034     for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
00035       //
00036       // first the binning point map must contain ALL the quantities here
00037       //
00038       //    if (! p.isKeyAvailable(*it) ) return false;
00039       float v = p.value(*it);
00040       if (!(v >= row[minPos(*it)] && v  < row[maxPos(*it)])) return false;
00041   }
00042   return true;
00043 }
00044 
00045 bool PerformancePayloadFromTable::isInPayload(PerformanceResult::ResultType res,BinningPointByMap point) const {
00046   // first, let's see if it is available at all
00047   if (resultPos(res) == PerformancePayloadFromTable::InvalidPos) return false;
00048   // now look whther the binning point contains all the info
00049   std::vector<BinningVariables::BinningVariablesType> t = myBinning();
00050   for (std::vector<BinningVariables::BinningVariablesType>::const_iterator it = t.begin(); it != t.end();++it){
00051     if (! point.isKeyAvailable(*it) ) return false;
00052   }
00053   // then, look if there is a matching row
00054   for (int i=0; i< pl.nRows(); i++){
00055     PhysicsPerformancePayload::Row  row = pl.getRow(i);
00056     if (matches(point,row)){
00057       return true;
00058     }
00059   }
00060   return false;
00061 }
00062 
00063 #include "FWCore/Utilities/interface/typelookup.h"
00064 TYPELOOKUP_DATA_REG(PerformancePayloadFromTable);