forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from shervin86/smearer76X
Smearer76 x
- Loading branch information
Showing
14 changed files
with
941 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
EgammaAnalysis/ElectronTools/data/74X_16DecRereco_2015_scales.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
absEta_0_1-lowR9 runNumber 254790 256629 1.0028 0.0007 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 254790 256629 0.9987 0.0007 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 256630 257613 0.9993 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 256630 257613 0.9953 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 257614 257818 1.0007 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 257614 257818 0.9966 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 257819 258158 1.0010 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 257819 258158 0.9970 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 258159 258213 1.0006 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 258159 258213 0.9966 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 258214 258443 1.0013 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 258214 258443 0.9972 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 258444 258704 1.0005 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 258444 258704 0.9965 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 258705 258744 1.0011 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 258705 258744 0.9971 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 258745 259625 1.0007 0.0003 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 258745 259625 0.9966 0.0003 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 259626 259810 1.0010 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 259626 259810 0.9970 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 259811 259890 1.0011 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 259811 259890 0.9970 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 259891 260426 1.0003 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 259891 260426 0.9962 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 260427 260535 1.0002 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 260427 260535 0.9962 0.0002 0.0001 0.0002 | ||
absEta_0_1-lowR9 runNumber 260536 260627 1.0013 0.0002 0.0001 0.0002 | ||
absEta_0_1-highR9 runNumber 260536 260627 0.9972 0.0002 0.0001 0.0002 | ||
absEta_1_1.4442-lowR9 runNumber 254790 256629 1.0036 0.0031 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 254790 256629 0.9923 0.0031 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 256630 257613 1.0036 0.0007 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 256630 257613 0.9922 0.0008 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 257614 257818 1.0078 0.0009 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 257614 257818 0.9964 0.0010 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 257819 258158 1.0066 0.0008 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 257819 258158 0.9952 0.0009 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 258159 258213 1.0064 0.0009 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 258159 258213 0.9951 0.0010 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 258214 258443 1.0072 0.0008 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 258214 258443 0.9958 0.0009 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 258444 258704 1.0068 0.0008 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 258444 258704 0.9954 0.0009 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 258705 258744 1.0072 0.0008 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 258705 258744 0.9958 0.0009 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 258745 259625 1.0075 0.0011 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 258745 259625 0.9961 0.0012 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 259626 259810 1.0072 0.0009 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 259626 259810 0.9958 0.0010 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 259811 259890 1.0090 0.0009 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 259811 259890 0.9976 0.0010 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 259891 260426 1.0096 0.0009 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 259891 260426 0.9982 0.0010 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 260427 260535 1.0083 0.0009 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 260427 260535 0.9969 0.0009 0.0004 0.0005 | ||
absEta_1_1.4442-lowR9 runNumber 260536 260627 1.0105 0.0007 0.0001 0.0006 | ||
absEta_1_1.4442-highR9 runNumber 260536 260627 0.9991 0.0008 0.0004 0.0005 | ||
absEta_1.566_2-lowR9 runNumber 254790 256629 1.0138 0.0034 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 254790 256629 1.0055 0.0034 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 256630 257613 1.0177 0.0010 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 256630 257613 1.0094 0.0011 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 257614 257818 1.0101 0.0011 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 257614 257818 1.0018 0.0011 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 257819 258158 1.0102 0.0010 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 257819 258158 1.0019 0.0011 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 258159 258213 1.0087 0.0011 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 258159 258213 1.0004 0.0011 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 258214 258443 1.0078 0.0011 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 258214 258443 0.9995 0.0012 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 258444 258704 1.0080 0.0010 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 258444 258704 0.9998 0.0011 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 258705 258744 1.0080 0.0010 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 258705 258744 0.9998 0.0011 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 258745 259625 1.0096 0.0016 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 258745 259625 1.0013 0.0016 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 259626 259810 1.0092 0.0011 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 259626 259810 1.0009 0.0012 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 259811 259890 1.0061 0.0011 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 259811 259890 0.9978 0.0012 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 259891 260426 1.0062 0.0011 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 259891 260426 0.9980 0.0012 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 260427 260535 1.0061 0.0011 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 260427 260535 0.9978 0.0012 0.0004 0.0009 | ||
absEta_1.566_2-lowR9 runNumber 260536 260627 1.0095 0.0009 0.0002 0.0007 | ||
absEta_1.566_2-highR9 runNumber 260536 260627 1.0012 0.0009 0.0004 0.0009 | ||
absEta_2_2.5-highR9 runNumber 254790 256629 1.0194 0.0033 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 254790 256629 1.0281 0.0033 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 256630 257613 1.0096 0.0009 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 256630 257613 1.0182 0.0009 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 257614 257818 1.0017 0.0010 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 257614 257818 1.0102 0.0010 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 257819 258158 1.0015 0.0009 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 257819 258158 1.0100 0.0009 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 258159 258213 0.9987 0.0010 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 258159 258213 1.0072 0.0010 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 258214 258443 0.9969 0.0010 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 258214 258443 1.0054 0.0010 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 258444 258704 0.9986 0.0009 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 258444 258704 1.0070 0.0010 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 258705 258744 0.9990 0.0010 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 258705 258744 1.0075 0.0010 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 258745 259625 0.9979 0.0014 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 258745 259625 1.0064 0.0015 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 259626 259810 0.9987 0.0010 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 259626 259810 1.0072 0.0010 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 259811 259890 0.9964 0.0010 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 259811 259890 1.0049 0.0011 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 259891 260426 0.9942 0.0011 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 259891 260426 1.0026 0.0011 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 260427 260535 0.9961 0.0010 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 260427 260535 1.0046 0.0011 0.0003 0.0013 | ||
absEta_2_2.5-highR9 runNumber 260536 260627 0.9961 0.0008 0.0002 0.0005 | ||
absEta_2_2.5-lowR9 runNumber 260536 260627 1.0046 0.0009 0.0003 0.0013 |
9 changes: 9 additions & 0 deletions
9
EgammaAnalysis/ElectronTools/data/74X_16DecRereco_2015_smearings.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#category Emean err_Emean rho err_rho phi err_phi | ||
absEta_0_1-highR9 0 0 0.0080 0.0005 M_PI_2 M_PI_2 | ||
absEta_0_1-lowR9 0 0 0.0094 0.0012 M_PI_2 M_PI_2 | ||
absEta_1_1.4442-highR9 0 0 0.0115 0.0021 M_PI_2 M_PI_2 | ||
absEta_1_1.4442-lowR9 0 0 0.0183 0.0005 M_PI_2 M_PI_2 | ||
absEta_1.566_2-highR9 0 0 0.0201 0.0016 M_PI_2 M_PI_2 | ||
absEta_1.566_2-lowR9 0 0 0.0221 0.0006 M_PI_2 M_PI_2 | ||
absEta_2_2.5-highR9 0 0 0.0230 0.0008 M_PI_2 M_PI_2 | ||
absEta_2_2.5-lowR9 0 0 0.0268 0.0010 M_PI_2 M_PI_2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 changes: 204 additions & 0 deletions
204
EgammaAnalysis/ElectronTools/interface/EnergyScaleCorrection_class.hh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
#ifndef EnergyScaleCorrection_class_hh | ||
#define EnergyScaleCorrection_class_hh | ||
/// Read and get energy scale and smearings from .dat files | ||
/**\class EnergyScaleCorrection_class EnergyScaleCorrection_class.cc Calibration/ZFitter/src/EnergyScaleCorrection_class.cc | ||
* \author Shervin Nourbakhsh | ||
* | ||
*/ | ||
|
||
/** Description | ||
This module is taken from the ECALELF package, used to derive the energy scales and smearings. | ||
There are two sub-classes: | ||
- correctionValue_class that defines the corrections | ||
- correctionCategory_class that defines the categories | ||
There is one map that associates the correction to the category (values read from text file) | ||
There is one class that reads the text files with the corrections and returns the scale/smearings given the electron/photon properties | ||
*/ | ||
|
||
#include <TString.h> | ||
#include <iostream> | ||
#include <fstream> | ||
#include <map> | ||
#include <math.h> | ||
#include <TChain.h> | ||
#include <TRandom3.h> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
//============================== First auxiliary class | ||
class correctionValue_class | ||
{ | ||
public: | ||
// values | ||
float scale, scale_err, scale_err_syst; | ||
float constTerm, constTerm_err; | ||
float alpha, alpha_err; | ||
float Emean, Emean_err; | ||
|
||
correctionValue_class(void) | ||
{ | ||
scale = 1; | ||
scale_err = 0; | ||
scale_err_syst=0; | ||
constTerm = 0; | ||
constTerm_err = 0; | ||
alpha = 0; | ||
alpha_err = 0; | ||
Emean = 0; | ||
Emean_err = 0; | ||
}; | ||
|
||
friend std::ostream& operator << (std::ostream& os, const correctionValue_class a) | ||
{ | ||
os << "( " | ||
<< a.scale << " +/- " << a.scale_err << " +/- " << a.scale_err_syst << ")" | ||
<< "\t" | ||
<< a.constTerm << " +/- " << a.constTerm_err | ||
<< "\t" | ||
<< a.alpha << " +/- " << a.alpha_err | ||
<< "\t" | ||
<< a.Emean << " +/- " << a.Emean_err; | ||
return os; | ||
}; | ||
}; | ||
|
||
//============================== Second auxiliary class | ||
class correctionCategory_class | ||
{ | ||
// for class definition and ordering | ||
public: | ||
unsigned int runmin; | ||
unsigned int runmax; | ||
|
||
private: | ||
// definition of the variables used for binning and the min-max ranges | ||
float r9min; ///< min R9 vaule for the bin | ||
float r9max; ///< max R9 value for the bin | ||
float etmin; ///< min Et value for the bin | ||
float etmax; ///< max Et value for the bin | ||
float etamin; ///< min eta value for the bin | ||
float etamax; ///< max eta value for the bin | ||
|
||
|
||
public: | ||
/** there are two constructors: | ||
- the first using the values taken from the e/gamma object | ||
- the second used to define the categories and the correction values | ||
*/ | ||
|
||
/** This constructor uses a string to define the category | ||
The string is used in the .dat file where the corrections are defined | ||
The syntax of the strings follows the definitions in the ECALELF ElectronCategory_class: http://ecalelfs.github.io/ECALELF/d5/d11/classElectronCategory__class.html | ||
*/ | ||
correctionCategory_class(TString category_); ///< constructor with name of the category according to ElectronCategory_class | ||
|
||
/// this constructor is used to assign a category to the electron/photon given values in input | ||
inline correctionCategory_class(const unsigned int runNumber, const float etaEle, const float R9Ele, const float EtEle) | ||
{ | ||
runmin = runNumber; | ||
runmax = runNumber; | ||
etamin = fabs(etaEle); | ||
etamax = fabs(etaEle); | ||
r9min = R9Ele; | ||
r9max = R9Ele; | ||
etmin = EtEle; | ||
etmax = EtEle; | ||
} | ||
|
||
/// for ordering of the categories | ||
bool operator<(const correctionCategory_class& b) const; | ||
|
||
/// for DEBUG | ||
friend std::ostream& operator << (std::ostream& os, const correctionCategory_class a) | ||
{ | ||
os << a.runmin << " " << a.runmax | ||
<< "\t" << a.etamin << " " << a.etamax | ||
<< "\t" << a.r9min << " " << a.r9max | ||
<< "\t" << a.etmin << " " << a.etmax; | ||
return os; | ||
}; | ||
}; | ||
|
||
|
||
//============================== | ||
/// map associating the category and the correction | ||
typedef std::map < correctionCategory_class, correctionValue_class > correction_map_t; | ||
|
||
|
||
|
||
//============================== Main class | ||
class EnergyScaleCorrection_class | ||
{ | ||
|
||
enum fileFormat_t { | ||
UNKNOWN=0, | ||
GLOBE, | ||
ECALELF_TOY, | ||
ECALELF | ||
}; | ||
|
||
public: | ||
bool doScale, doSmearings; | ||
|
||
public: | ||
EnergyScaleCorrection_class(TString correctionFileName, | ||
TString smearingFileName = "", unsigned int genSeed=0); ///< constructor with correction file names | ||
EnergyScaleCorrection_class(){}; ///< dummy constructor needed in ElectronEnergyCalibratorRun2 | ||
~EnergyScaleCorrection_class(void); | ||
|
||
|
||
//------------------------------ scales | ||
float ScaleCorrection(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, | ||
double EtEle ) const; ///< method to get energy scale corrections | ||
|
||
float ScaleCorrectionUncertainty(unsigned int runNumber, bool isEBEle, | ||
double R9Ele, double etaSCEle, double EtEle) const; ///< method to get scale correction uncertainties: it's stat+syst in eta x R9 categories | ||
|
||
private: | ||
correctionValue_class getScaleCorrection(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const; ///< returns the correction value class | ||
float getScaleOffset(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const; // returns the correction value | ||
float getScaleStatUncertainty(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const; // returns the stat uncertainty | ||
float getScaleSystUncertainty(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const; // technical implementation | ||
|
||
|
||
void ReadFromFile(TString filename); ///< category "runNumber" runMin runMax deltaP err_deltaP_per_bin err_deltaP_stat err_deltaP_syst | ||
|
||
// this method adds the correction values read from the txt file to the map | ||
void AddScale(TString category_, int runMin_, int runMax_, double deltaP_, double err_deltaP_, double err_syst_deltaP); | ||
|
||
//============================== smearings | ||
public: | ||
float getSmearingSigma(int runNumber, float energy, bool isEBEle, float R9Ele, float etaSCEle) const; | ||
|
||
|
||
private: | ||
fileFormat_t smearingType_; | ||
|
||
TRandom3 *rgen_; | ||
correction_map_t scales, scales_not_defined; | ||
correction_map_t smearings, smearings_not_defined; | ||
|
||
void AddSmearing(TString category_, int runMin_, int runMax_, //double smearing_, double err_smearing_); | ||
double constTerm, double err_constTerm, double alpha, double err_alpha, double Emean, double err_Emean); | ||
void ReadSmearingFromFile(TString filename); ///< File structure: category constTerm alpha; | ||
public: | ||
inline void SetSmearingType(fileFormat_t value) | ||
{ | ||
if(value >= 0 && value <= 1) { | ||
smearingType_ = value; | ||
} else { | ||
smearingType_ = UNKNOWN; | ||
} | ||
}; | ||
|
||
float getSmearingRho(int runNumber, float energy, bool isEBEle, float R9Ele, float etaSCEle) const; ///< public for sigmaE estimate | ||
|
||
|
||
|
||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.