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 #include<iostream>
11 
12 namespace condex {
13 
14 
15 
16  /* very simple base class
17  * trivial inheritance, no template tricks
18  */
19  class Efficiency {
20  public:
22  virtual ~Efficiency(){}
23  virtual void initialize(){ std::cout << "initializing base class Efficiency" <<std::endl;}
24  float operator()(float pt, float eta) const {
25  return value(pt,eta);
26  }
27 
28  virtual float value(float pt, float eta) const=0;
29 
30  };
31 
32 
34  public:
36  ParametricEfficiencyInPt(float cm, float ch,
37  float el, float eh) :
38  cutLow(cm), cutHigh(ch),
39  low(el), high(eh){}
40  private:
41  virtual float value(float pt, float) const {
42  if ( pt<low) return cutLow;
43  if ( pt>high) return cutHigh;
44  return cutLow + (pt-low)/(high-low)*(cutHigh-cutLow);
45  }
46  float cutLow, cutHigh;
47  float low, high;
48 
49  };
50 
52  public:
54  ParametricEfficiencyInEta(float cmin, float cmax,
55  float el, float eh) :
56  cutLow(cmin), cutHigh(cmax),
57  low(el), high(eh){}
58  private:
59  virtual float value(float, float eta) const {
60  eta = std::abs(eta);
61  if ( eta<low) return cutLow;
62  if ( eta>high) return cutHigh;
63  return cutLow + (eta-low)/(high-low)*(cutHigh-cutLow);
64  }
65  float cutLow, cutHigh;
66  float low, high;
67 
68  };
69 
70 }
71 
72 
73 
74 
75 #endif
ParametricEfficiencyInEta(float cmin, float cmax, float el, float eh)
Definition: Efficiency.h:54
virtual float value(float, float eta) const
Definition: Efficiency.h:59
T eta() const
virtual ~Efficiency()
Definition: Efficiency.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float operator()(float pt, float eta) const
Definition: Efficiency.h:24
virtual float value(float pt, float eta) const =0
virtual float value(float pt, float) const
Definition: Efficiency.h:41
tuple cout
Definition: gather_cfg.py:121
virtual void initialize()
Definition: Efficiency.h:23
ParametricEfficiencyInPt(float cm, float ch, float el, float eh)
Definition: Efficiency.h:36