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
condex::Efficiency
Definition: Efficiency.h:19
condex::ParametricEfficiencyInEta::ParametricEfficiencyInEta
ParametricEfficiencyInEta(float cmin, float cmax, float el, float eh)
Definition: Efficiency.h:53
condex::ParametricEfficiencyInPt::low
float low
Definition: Efficiency.h:45
condex::ParametricEfficiencyInPt::cutHigh
float cutHigh
Definition: Efficiency.h:44
condex::Efficiency::~Efficiency
virtual ~Efficiency()
Definition: Efficiency.h:22
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
gather_cfg.cout
cout
Definition: gather_cfg.py:144
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
condex::ParametricEfficiencyInEta::ParametricEfficiencyInEta
ParametricEfficiencyInEta()
Definition: Efficiency.h:52
condex::ParametricEfficiencyInPt::high
float high
Definition: Efficiency.h:45
condex::Efficiency::initialize
virtual void initialize()
Definition: Efficiency.h:23
condex::ParametricEfficiencyInPt::cutLow
float cutLow
Definition: Efficiency.h:44
condex::ParametricEfficiencyInEta::low
float low
Definition: Efficiency.h:66
condex::Efficiency::operator()
float operator()(float pt, float eta) const
Definition: Efficiency.h:24
PVValHelper::eta
Definition: PVValidationHelpers.h:70
condex::ParametricEfficiencyInEta::value
float value(float, float eta) const override
Definition: Efficiency.h:57
condex::ParametricEfficiencyInEta::cutHigh
float cutHigh
Definition: Efficiency.h:65
condex::ParametricEfficiencyInEta::high
float high
Definition: Efficiency.h:66
condex
Definition: Conf.h:12
condex::ParametricEfficiencyInPt::ParametricEfficiencyInPt
ParametricEfficiencyInPt()
Definition: Efficiency.h:33
condex::ParametricEfficiencyInEta
Definition: Efficiency.h:50
Serializable.h
condex::ParametricEfficiencyInPt
Definition: Efficiency.h:31
condex::ParametricEfficiencyInEta::cutLow
float cutLow
Definition: Efficiency.h:65
condex::ParametricEfficiencyInPt::value
float value(float pt, float) const override
Definition: Efficiency.h:37
condex::ParametricEfficiencyInPt::ParametricEfficiencyInPt
ParametricEfficiencyInPt(float cm, float ch, float el, float eh)
Definition: Efficiency.h:34
condex::Efficiency::Efficiency
Efficiency()
Definition: Efficiency.h:21
condex::Efficiency::value
virtual float value(float pt, float eta) const =0
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22