File indexing completed on 2024-09-07 04:36:05
0001 #ifndef EgammaAnalysis_ElectronTools_EnergyScaleCorrection_class_h
0002 #define EgammaAnalysis_ElectronTools_EnergyScaleCorrection_class_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <TString.h>
0021 #include <iostream>
0022 #include <fstream>
0023 #include <map>
0024 #include <cmath>
0025 #include <TChain.h>
0026 #include <TRandom3.h>
0027 #include <string>
0028
0029
0030 class correctionValue_class {
0031 public:
0032
0033 float scale, scale_err, scale_err_syst;
0034 float rho, rho_err;
0035 float phi, phi_err;
0036 float Emean, Emean_err;
0037
0038 correctionValue_class(void) {
0039 scale = 1;
0040 scale_err = 0;
0041 scale_err_syst = 0;
0042 rho = 0;
0043 rho_err = 0;
0044 phi = 0;
0045 phi_err = 0;
0046 Emean = 0;
0047 Emean_err = 0;
0048 };
0049
0050 friend std::ostream& operator<<(std::ostream& os, const correctionValue_class a) {
0051 os << "( " << a.scale << " +/- " << a.scale_err << " +/- " << a.scale_err_syst << ")"
0052 << "\t" << a.rho << " +/- " << a.rho_err << "\t" << a.phi << " +/- " << a.phi_err << "\t" << a.Emean << " +/- "
0053 << a.Emean_err;
0054 return os;
0055 };
0056 };
0057
0058
0059 class correctionCategory_class {
0060
0061 public:
0062 unsigned int runmin;
0063 unsigned int runmax;
0064
0065 private:
0066
0067 float r9min;
0068 float r9max;
0069 float etmin;
0070 float etmax;
0071 float etamin;
0072 float etamax;
0073
0074 public:
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 correctionCategory_class(
0085 TString category_);
0086
0087
0088 inline correctionCategory_class(const unsigned int runNumber,
0089 const float etaEle,
0090 const float R9Ele,
0091 const float EtEle) {
0092 runmin = runNumber;
0093 runmax = runNumber;
0094 etamin = fabs(etaEle);
0095 etamax = fabs(etaEle);
0096 r9min = R9Ele;
0097 r9max = R9Ele;
0098 etmin = EtEle;
0099 etmax = EtEle;
0100 }
0101
0102
0103 bool operator<(const correctionCategory_class& b) const;
0104
0105
0106 friend std::ostream& operator<<(std::ostream& os, const correctionCategory_class a) {
0107 os << a.runmin << " " << a.runmax << "\t" << a.etamin << " " << a.etamax << "\t" << a.r9min << " " << a.r9max
0108 << "\t" << a.etmin << " " << a.etmax;
0109 return os;
0110 };
0111 };
0112
0113
0114
0115 typedef std::map<correctionCategory_class, correctionValue_class> correction_map_t;
0116
0117
0118 class EnergyScaleCorrection_class {
0119 public:
0120 enum fileFormat_t { UNKNOWN = 0, GLOBE, ECALELF_TOY, ECALELF };
0121
0122 enum paramSmear_t { kNone = 0, kRho, kPhi, kNParamSmear };
0123
0124 bool doScale, doSmearings;
0125
0126 public:
0127 EnergyScaleCorrection_class(std::string correctionFileName, unsigned int genSeed = 0);
0128 EnergyScaleCorrection_class() {}
0129 ~EnergyScaleCorrection_class(void);
0130
0131
0132 float ScaleCorrection(unsigned int runNumber,
0133 bool isEBEle,
0134 double R9Ele,
0135 double etaSCEle,
0136 double EtEle) const;
0137
0138 float ScaleCorrectionUncertainty(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle)
0139 const;
0140
0141 private:
0142 correctionValue_class getScaleCorrection(unsigned int runNumber,
0143 bool isEBEle,
0144 double R9Ele,
0145 double etaSCEle,
0146 double EtEle) const;
0147 float getScaleOffset(unsigned int runNumber,
0148 bool isEBEle,
0149 double R9Ele,
0150 double etaSCEle,
0151 double EtEle) const;
0152 float getScaleStatUncertainty(unsigned int runNumber,
0153 bool isEBEle,
0154 double R9Ele,
0155 double etaSCEle,
0156 double EtEle) const;
0157 float getScaleSystUncertainty(unsigned int runNumber,
0158 bool isEBEle,
0159 double R9Ele,
0160 double etaSCEle,
0161 double EtEle) const;
0162
0163 void ReadFromFile(
0164 TString
0165 filename);
0166
0167
0168 void AddScale(TString category_, int runMin_, int runMax_, double deltaP_, double err_deltaP_, double err_syst_deltaP);
0169
0170
0171 public:
0172 float getSmearingSigma(
0173 int runNumber, bool isEBEle, float R9Ele, float etaSCEle, float EtEle, paramSmear_t par, float nSigma = 0.) const;
0174 float getSmearingSigma(
0175 int runNumber, bool isEBEle, float R9Ele, float etaSCEle, float EtEle, float nSigma_rho, float nSigma_phi) const;
0176
0177 private:
0178 fileFormat_t smearingType_;
0179
0180 correction_map_t scales, scales_not_defined;
0181 correction_map_t smearings, smearings_not_defined;
0182
0183 void AddSmearing(TString category_,
0184 int runMin_,
0185 int runMax_,
0186 double rho,
0187 double err_rho,
0188 double phi,
0189 double err_phi,
0190 double Emean,
0191 double err_Emean);
0192 void ReadSmearingFromFile(TString filename);
0193 public:
0194 inline void SetSmearingType(fileFormat_t value) {
0195 if (value <= 1) {
0196 smearingType_ = value;
0197 } else {
0198 smearingType_ = UNKNOWN;
0199 }
0200 };
0201
0202 float getSmearingRho(
0203 int runNumber, bool isEBEle, float R9Ele, float etaSCEle, float EtEle) const;
0204 };
0205
0206 #endif