Go to the documentation of this file.00001 #ifndef PerformancePayloadFromTFormula_h
00002 #define PerformancePayloadFromTFormula_h
00003
00004 #include "CondFormats/PhysicsToolsObjects/interface/PhysicsTFormulaPayload.h"
00005 #include "CondFormats/PhysicsToolsObjects/interface/PerformancePayload.h"
00006
00007 #include <algorithm>
00008 #include <string>
00009 #include <vector>
00010 #include "TFormula.h"
00011
00012 #include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h"
00013
00014 class PerformancePayloadFromTFormula : public PerformancePayload {
00015
00016 public:
00017
00018 static int InvalidPos;
00019
00020 PerformancePayloadFromTFormula(std::vector<PerformanceResult::ResultType> r, std::vector<BinningVariables::BinningVariablesType> b , PhysicsTFormulaPayload& in) : pl(in), results_(r), variables_(b) {}
00021
00022 PerformancePayloadFromTFormula(){}
00023 virtual ~PerformancePayloadFromTFormula(){
00024 for (unsigned int i=0; i< compiledFormulas_.size(); ++i){
00025 delete compiledFormulas_[i];
00026 }
00027 compiledFormulas_.clear();
00028 }
00029
00030 float getResult(PerformanceResult::ResultType,BinningPointByMap) const ;
00031
00032 virtual bool isParametrizedInVariable(const BinningVariables::BinningVariablesType p) const {
00033 return (limitPos(p) != PerformancePayloadFromTFormula::InvalidPos);
00034 }
00035
00036 virtual bool isInPayload(PerformanceResult::ResultType,BinningPointByMap) const ;
00037
00038 const PhysicsTFormulaPayload & formulaPayload() const {return pl;}
00039
00040 void printFormula(PerformanceResult::ResultType res) const;
00041
00042
00043 protected:
00044
00045 virtual std::vector<BinningVariables::BinningVariablesType> myBinning() const {return variables_;}
00046
00047 virtual int limitPos(const BinningVariables::BinningVariablesType b) const {
00048 std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
00049 p = find(variables_.begin(), variables_.end(), b);
00050 if (p == variables_.end()) return PerformancePayloadFromTFormula::InvalidPos;
00051 return ((p-variables_.begin()));
00052
00053 }
00054
00055 virtual int resultPos(PerformanceResult::ResultType r) const {
00056 std::vector<PerformanceResult::ResultType>::const_iterator p;
00057 p = find (results_.begin(), results_.end(), r);
00058 if ( p == results_.end()) return PerformancePayloadFromTFormula::InvalidPos;
00059 return ((p-results_.begin()));
00060 }
00061
00062
00063 bool isOk(BinningPointByMap p) const;
00064
00065 void check() const;
00066
00067 PhysicsTFormulaPayload pl;
00068
00069
00070
00071 std::vector<PerformanceResult::ResultType> results_;
00072 std::vector<BinningVariables::BinningVariablesType> variables_;
00073
00074
00075
00076 mutable std::vector<TFormula *> compiledFormulas_;
00077 };
00078
00079 #endif