File indexing completed on 2024-04-06 12:01:57
0001 #ifndef CondEx_Efficiency_H
0002 #define CondEx_Efficiency_H
0003
0004
0005
0006
0007
0008
0009 #include "CondFormats/Serialization/interface/Serializable.h"
0010
0011 #include <cmath>
0012 #include <iostream>
0013
0014 namespace condex {
0015
0016
0017
0018
0019 class Efficiency {
0020 public:
0021 Efficiency() {}
0022 virtual ~Efficiency() {}
0023 virtual void initialize() { std::cout << "initializing base class Efficiency" << std::endl; }
0024 float operator()(float pt, float eta) const { return value(pt, eta); }
0025
0026 virtual float value(float pt, float eta) const = 0;
0027
0028 COND_SERIALIZABLE;
0029 };
0030
0031 class ParametricEfficiencyInPt : public Efficiency {
0032 public:
0033 ParametricEfficiencyInPt() : cutLow(0), cutHigh(0), low(0), high(0) {}
0034 ParametricEfficiencyInPt(float cm, float ch, float el, float eh) : cutLow(cm), cutHigh(ch), low(el), high(eh) {}
0035
0036 private:
0037 float value(float pt, float) const override {
0038 if (pt < low)
0039 return cutLow;
0040 if (pt > high)
0041 return cutHigh;
0042 return cutLow + (pt - low) / (high - low) * (cutHigh - cutLow);
0043 }
0044 float cutLow, cutHigh;
0045 float low, high;
0046
0047 COND_SERIALIZABLE;
0048 };
0049
0050 class ParametricEfficiencyInEta : public Efficiency {
0051 public:
0052 ParametricEfficiencyInEta() : cutLow(0), cutHigh(0), low(0), high(0) {}
0053 ParametricEfficiencyInEta(float cmin, float cmax, float el, float eh)
0054 : cutLow(cmin), cutHigh(cmax), low(el), high(eh) {}
0055
0056 private:
0057 float value(float, float eta) const override {
0058 eta = std::abs(eta);
0059 if (eta < low)
0060 return cutLow;
0061 if (eta > high)
0062 return cutHigh;
0063 return cutLow + (eta - low) / (high - low) * (cutHigh - cutLow);
0064 }
0065 float cutLow, cutHigh;
0066 float low, high;
0067
0068 COND_SERIALIZABLE;
0069 };
0070
0071 }
0072
0073 #endif