CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondFormats/Calibration/interface/Efficiency.h

Go to the documentation of this file.
00001 #ifndef CondEx_Efficiency_H
00002 #define CondEx_Efficiency_H
00003 /*  example of polymorphic condition
00004  *  LUT, function, mixed....
00005  * this is just a prototype: classes do not need to be defined and declared in the same file
00006  * at the moment though all derived classes better sit in the same package together with the base one
00007  */
00008 
00009 #include<cmath>
00010 
00011 namespace condex {
00012 
00013   /* very simple base class
00014    * trivial inheritance, no template tricks 
00015    */
00016   class Efficiency {
00017   public:
00018     Efficiency(){}
00019     virtual ~Efficiency(){}
00020     float operator()(float pt, float eta) const {
00021       return value(pt,eta);
00022     }
00023 
00024     virtual float value(float pt, float eta) const=0;
00025 
00026   };
00027 
00028 
00029   class ParametricEfficiencyInPt : public Efficiency {
00030   public:
00031     ParametricEfficiencyInPt() : cutLow(0), cutHigh(0), low(0), high(0){}
00032     ParametricEfficiencyInPt(float cm, float ch,
00033                             float el, float eh) :
00034       cutLow(cm), cutHigh(ch),
00035       low(el), high(eh){}
00036   private:
00037     virtual float value(float pt, float) const {
00038       if ( pt<low) return cutLow;
00039       if ( pt>high) return cutHigh;
00040       return cutLow + (pt-low)/(high-low)*(cutHigh-cutLow);
00041     }
00042     float cutLow, cutHigh;
00043     float low, high;
00044 
00045   };  
00046 
00047 class ParametricEfficiencyInEta : public Efficiency {
00048   public:
00049   ParametricEfficiencyInEta() : cutLow(0), cutHigh(0), low(0), high(0) {}
00050     ParametricEfficiencyInEta(float cmin, float cmax,
00051                             float el, float eh) :
00052       cutLow(cmin), cutHigh(cmax),
00053       low(el), high(eh){}
00054   private:
00055     virtual float value(float, float eta) const {
00056       eta = std::abs(eta);
00057       if ( eta<low) return cutLow;
00058       if ( eta>high) return cutHigh;
00059       return cutLow + (eta-low)/(high-low)*(cutHigh-cutLow);
00060     }
00061     float cutLow, cutHigh;
00062     float low, high;
00063 
00064   };
00065 
00066 }
00067 
00068 
00069 
00070 
00071 #endif