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