CMS 3D CMS Logo

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  /* 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 { return value(pt, eta); }
25 
26  virtual float value(float pt, float eta) const = 0;
27 
29  };
30 
32  public:
34  ParametricEfficiencyInPt(float cm, float ch, float el, float eh) : cutLow(cm), cutHigh(ch), low(el), high(eh) {}
35 
36  private:
37  float value(float pt, float) const override {
38  if (pt < low)
39  return cutLow;
40  if (pt > high)
41  return cutHigh;
42  return cutLow + (pt - low) / (high - low) * (cutHigh - cutLow);
43  }
44  float cutLow, cutHigh;
45  float low, high;
46 
48  };
49 
51  public:
53  ParametricEfficiencyInEta(float cmin, float cmax, float el, float eh)
54  : cutLow(cmin), cutHigh(cmax), low(el), high(eh) {}
55 
56  private:
57  float value(float, float eta) const override {
58  eta = std::abs(eta);
59  if (eta < low)
60  return cutLow;
61  if (eta > high)
62  return cutHigh;
63  return cutLow + (eta - low) / (high - low) * (cutHigh - cutLow);
64  }
65  float cutLow, cutHigh;
66  float low, high;
67 
69  };
70 
71 } // namespace condex
72 
73 #endif
float value(float pt, float) const override
Definition: Efficiency.h:37
ParametricEfficiencyInEta(float cmin, float cmax, float el, float eh)
Definition: Efficiency.h:53
float operator()(float pt, float eta) const
Definition: Efficiency.h:24
virtual ~Efficiency()
Definition: Efficiency.h:22
Definition: Conf.h:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual float value(float pt, float eta) const =0
#define COND_SERIALIZABLE
Definition: Serializable.h:39
float value(float, float eta) const override
Definition: Efficiency.h:57
virtual void initialize()
Definition: Efficiency.h:23
ParametricEfficiencyInPt(float cm, float ch, float el, float eh)
Definition: Efficiency.h:34