CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Efficiency.h
Go to the documentation of this file.
1 #ifndef CondEx_Efficiency_H
2 #define CondEx_Efficiency_H
3 /* example of polymorphic condition
4  * LUT, function, mixed....
5  * this is just a prototype: classes do not need to be defined and declared in the same file
6  * at the moment though all derived classes better sit in the same package together with the base one
7  */
8 
9 #include<cmath>
10 
11 namespace condex {
12 
13  /* very simple base class
14  * trivial inheritance, no template tricks
15  */
16  class Efficiency {
17  public:
19  virtual ~Efficiency(){}
20  float operator()(float pt, float eta) const {
21  return value(pt,eta);
22  }
23 
24  virtual float value(float pt, float eta) const=0;
25 
26  };
27 
28 
30  public:
32  ParametricEfficiencyInPt(float cm, float ch,
33  float el, float eh) :
34  cutLow(cm), cutHigh(ch),
35  low(el), high(eh){}
36  private:
37  virtual float value(float pt, float) const {
38  if ( pt<low) return cutLow;
39  if ( pt>high) return cutHigh;
40  return cutLow + (pt-low)/(high-low)*(cutHigh-cutLow);
41  }
42  float cutLow, cutHigh;
43  float low, high;
44 
45  };
46 
48  public:
50  ParametricEfficiencyInEta(float cmin, float cmax,
51  float el, float eh) :
52  cutLow(cmin), cutHigh(cmax),
53  low(el), high(eh){}
54  private:
55  virtual float value(float, float eta) const {
56  eta = std::abs(eta);
57  if ( eta<low) return cutLow;
58  if ( eta>high) return cutHigh;
59  return cutLow + (eta-low)/(high-low)*(cutHigh-cutLow);
60  }
61  float cutLow, cutHigh;
62  float low, high;
63 
64  };
65 
66 }
67 
68 
69 
70 
71 #endif
ParametricEfficiencyInEta(float cmin, float cmax, float el, float eh)
Definition: Efficiency.h:50
#define abs(x)
Definition: mlp_lapack.h:159
virtual float value(float, float eta) const
Definition: Efficiency.h:55
T eta() const
virtual ~Efficiency()
Definition: Efficiency.h:19
float operator()(float pt, float eta) const
Definition: Efficiency.h:20
virtual float value(float pt, float eta) const =0
virtual float value(float pt, float) const
Definition: Efficiency.h:37
ParametricEfficiencyInPt(float cm, float ch, float el, float eh)
Definition: Efficiency.h:32