Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:26

0001 #ifndef PerformancePayloadFromBinnedTFormula_h
0002 #define PerformancePayloadFromBinnedTFormula_h
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include "CondFormats/PhysicsToolsObjects/interface/PhysicsTFormulaPayload.h"
0007 #include "CondFormats/PhysicsToolsObjects/interface/PerformancePayload.h"
0008 
0009 #include <algorithm>
0010 #include <string>
0011 #include <vector>
0012 
0013 #include "TFormula.h"
0014 
0015 #include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h"
0016 
0017 class PerformancePayloadFromBinnedTFormula : public PerformancePayload {
0018   //  class PerformancePayloadFromBinnedTFormula : public PerformancePayload, public PhysicsPerformancePayload {
0019 public:
0020   static const int InvalidPos;
0021 
0022   PerformancePayloadFromBinnedTFormula(const std::vector<PerformanceResult::ResultType>& r,
0023                                        const std::vector<BinningVariables::BinningVariablesType>& b,
0024                                        const std::vector<PhysicsTFormulaPayload>& in)
0025       : pls(in), results_(r), variables_(b) {
0026     initialize();
0027   }
0028 
0029   void initialize() override;
0030 
0031   PerformancePayloadFromBinnedTFormula() {}
0032   ~PerformancePayloadFromBinnedTFormula() override { compiledFormulas_.clear(); }
0033 
0034   float getResult(PerformanceResult::ResultType,
0035                   const BinningPointByMap&) const override;  // gets from the full payload
0036 
0037   virtual bool isParametrizedInVariable(const BinningVariables::BinningVariablesType p) const {
0038     return (limitPos(p) != PerformancePayloadFromBinnedTFormula::InvalidPos);
0039   }
0040 
0041   bool isInPayload(PerformanceResult::ResultType, const BinningPointByMap&) const override;
0042 
0043   const std::vector<PhysicsTFormulaPayload>& formulaPayloads() const { return pls; }
0044 
0045   void printFormula(PerformanceResult::ResultType res, const BinningPointByMap&) const;
0046 
0047 protected:
0048   virtual std::vector<BinningVariables::BinningVariablesType> myBinning() const { return variables_; }
0049 
0050   virtual int limitPos(const BinningVariables::BinningVariablesType b) const {
0051     std::vector<BinningVariables::BinningVariablesType>::const_iterator p;
0052     p = find(variables_.begin(), variables_.end(), b);
0053     if (p == variables_.end())
0054       return PerformancePayloadFromBinnedTFormula::InvalidPos;
0055     return ((p - variables_.begin()));
0056   }
0057 
0058   virtual int resultPos(PerformanceResult::ResultType r) const {
0059     std::vector<PerformanceResult::ResultType>::const_iterator p;
0060     p = find(results_.begin(), results_.end(), r);
0061     if (p == results_.end())
0062       return PerformancePayloadFromBinnedTFormula::InvalidPos;
0063     return ((p - results_.begin()));
0064   }
0065 
0066   bool isOk(const BinningPointByMap& p, unsigned int&) const;
0067 
0068   const std::shared_ptr<TFormula>& getFormula(PerformanceResult::ResultType, const BinningPointByMap&) const;
0069 
0070   //
0071   // now this is a vector, since we can have different rectangular regions in the same object
0072   //
0073   std::vector<PhysicsTFormulaPayload> pls;
0074   //
0075   // the variable mapping
0076   //
0077   std::vector<PerformanceResult::ResultType> results_;
0078   std::vector<BinningVariables::BinningVariablesType> variables_;
0079 
0080   //
0081   // the transient part; now a vector of vector; CHANGE CHECK!!!!!
0082   //
0083 
0084   // the compiled functions
0085   std::vector<std::vector<std::shared_ptr<TFormula> > > compiledFormulas_ COND_TRANSIENT;
0086   ;
0087 
0088   COND_SERIALIZABLE;
0089 };
0090 
0091 #endif