CMS 3D CMS Logo

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(){}
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(){}
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

Generated on Tue Jun 9 17:26:17 2009 for CMSSW by  doxygen 1.5.4