3 #include <RooDataSet.h> 21 smearingType_(ECALELF)
24 if(!correctionFileName.empty()) {
28 std::cerr <<
"[ERROR] scale correction map empty" << std::endl;
33 if(!correctionFileName.empty()) {
37 std::cerr <<
"[ERROR] smearing correction map empty" << std::endl;
53 double R9Ele,
double etaSCEle,
double EtEle)
const 64 double R9Ele,
double etaSCEle,
double EtEle)
const 69 return sqrt(statUncert * statUncert + systUncert * systUncert);
74 double R9Ele,
double etaSCEle,
double EtEle)
const 80 double R9Ele,
double etaSCEle,
double EtEle)
const 90 correction_map_t::const_iterator corr_itr =
scales.find(category);
92 if(corr_itr ==
scales.end()) {
101 std::cout <<
"[ERROR] Scale category not found: " << std::endl;
103 std::cout <<
"Returning uncorrected value." << std::endl;
111 std::cout <<
"[DEBUG] Checking scale correction for category: " << category << std::endl;
112 std::cout <<
"[DEBUG] Correction is: " << corr_itr->second
114 <<
" given for category " << corr_itr->first << std::endl;;
116 return corr_itr->second;
123 correction_map_t::const_iterator corr_itr =
scales.find(category);
125 if(corr_itr ==
scales.end()) {
134 std::cout <<
"[ERROR] Scale offset category not found: " << std::endl;
136 std::cout <<
"Returning uncorrected value." << std::endl;
143 std::cout <<
"[DEBUG] Checking scale offset correction for category: " << category << std::endl;
144 std::cout <<
"[DEBUG] Correction is: " << corr_itr->second
146 <<
" given for category " << corr_itr->first << std::endl;;
149 return corr_itr->second.scale;
160 #ifdef PEDANTIC_OUTPUT 161 std::cout <<
"[STATUS] Reading energy scale correction values from file: " << filename << std::endl;
163 std::cout <<
"[STATUS] Reading energy scale correction values from file: " << filename << std::endl;
169 std::cerr <<
"[ERROR] file " << filename <<
" not readable" << std::endl;
176 double deltaP, err_deltaP, err_deltaP_stat, err_deltaP_syst;
179 for(f_in >> category; f_in.good(); f_in >>
category) {
182 >> deltaP >> err_deltaP >> err_deltaP_stat >> err_deltaP_syst;
184 AddScale(category, runMin, runMax, deltaP, err_deltaP_stat, err_deltaP_syst);
201 if(
scales.count(cat) != 0) {
202 std::cerr <<
"[ERROR] Category already defined!" << std::endl;
203 std::cerr <<
" Adding category: " << cat << std::endl;
209 corr.
scale = deltaP_;
214 #ifdef PEDANTIC_OUTPUT 215 std::cout <<
"[INFO:scale correction] " << cat << corr << std::endl;
222 double rho,
double err_rho,
double phi,
double err_phi,
223 double Emean,
double err_Emean)
227 cat.
runmin = (runMin_ < 0) ? 0 : runMin_;
231 std::cerr <<
"[ERROR] Smearing category already defined!" << std::endl;
232 std::cerr <<
" Adding category: " << cat << std::endl;
246 #ifdef PEDANTIC_OUTPUT 248 std::cout <<
"[INFO:smearings] " << cat << corr << std::endl;
274 #ifdef PEDANTIC_OUTPUT 275 std::cout <<
"[STATUS] Reading smearing values from file: " << filename << std::endl;
280 std::cerr <<
"[ERROR] file " << filename <<
" not readable" << std::endl;
284 int runMin = 0, runMax = 900000;
288 double rho,
phi, Emean, err_rho, err_phi, err_Emean;
293 while(f_in.peek() != EOF && f_in.good()) {
294 if(f_in.peek() == 10) {
299 if(f_in.peek() == 35) {
300 f_in.ignore(1000, 10);
305 std::cerr <<
"[ERROR] Not implemented" << std::endl;
309 f_in >> category >> unused >> etaMin >> etaMax >> r9Min >> r9Max >> runMin >> runMax >>
310 Emean >> err_Emean >>
311 rho >> err_rho >> phi >> err_phi;
313 AddSmearing(category, runMin, runMax, rho, err_rho, phi, err_phi, Emean, err_Emean);
317 Emean >> err_Emean >>
318 rho >> err_rho >> phi_string >> err_phi_string;
322 <<
"\tEmean=" << Emean <<
"\t" 323 << rho <<
"\t" << err_rho <<
"\tphi_string=" 324 << phi_string <<
"#\terr_phi_string=" << err_phi_string << std::endl;
327 if(phi_string==
"M_PI_2") phi=
M_PI_2;
328 else phi = std::stod(phi_string);
330 if(err_phi_string==
"M_PI_2") err_phi=
M_PI_2;
331 else err_phi = std::stod(err_phi_string);
334 AddSmearing(category, runMin, runMax, rho, err_rho, phi, err_phi, Emean, err_Emean);
337 f_in >> category >> rho >>
phi;
338 err_rho = err_phi = Emean = err_Emean = 0;
339 AddSmearing(category, runMin, runMax, rho, err_rho, phi, err_phi, Emean, err_Emean);
342 std::cout << category <<
"\t" << etaMin <<
"\t" << etaMax <<
"\t" << r9Min <<
"\t" << r9Max <<
"\t" << runMin <<
"\t" << runMax <<
"\tEmean=" << Emean <<
"\t" << rho <<
"\t" << phi << std::endl;
357 if (par ==
kRho)
return getSmearingSigma(runNumber, isEBEle, R9Ele, etaSCEle, EtEle, nSigma, 0.);
358 if (par ==
kPhi)
return getSmearingSigma(runNumber, isEBEle, R9Ele, etaSCEle, EtEle, 0., nSigma);
359 return getSmearingSigma(runNumber, isEBEle, R9Ele, etaSCEle, EtEle, 0., 0.);
366 correction_map_t::const_iterator corr_itr =
smearings.find(category);
374 std::cerr <<
"[WARNING] Smearing category not found: " << std::endl;
380 std::cout <<
"[DEBUG] Checking smearing correction for category: " << category << std::endl;
381 std::cout <<
"[DEBUG] Correction is: " << corr_itr->second
383 <<
" given for category " << corr_itr->first;
386 double rho = corr_itr->second.rho + corr_itr->second.rho_err * nSigma_rho;
387 double phi = corr_itr->second.phi + corr_itr->second.phi_err * nSigma_phi;
389 double constTerm = rho *
sin(phi);
390 double alpha = rho * corr_itr->second.Emean *
cos( phi);
392 return sqrt(constTerm * constTerm + alpha * alpha / EtEle);
400 correction_map_t::const_iterator corr_itr =
smearings.find(category);
409 return corr_itr->second.rho;
418 if(etamax > b.
etamax && etamin > b.
etamin)
return false;
420 if(r9min < b.
r9min && r9max < b.
r9max)
return true;
421 if(r9max > b.
r9max && r9min > b.
r9min)
return false;
423 if(etmin < b.
etmin && etmax < b.
etmax)
return true;
424 if(etmax > b.
etmax && etmin > b.
etmin)
return false;
433 std::cout <<
"[DEBUG] correctionClass defined for category: " <<
category << std::endl;
448 if(
category.find(
"absEta_0_1") != std::string::npos) {
451 }
else if(
category.find(
"absEta_1_1.4442") != std::string::npos) {
455 else if(
category.find(
"absEta_1.566_2") != std::string::npos) {
459 else if(
category.find(
"absEta_2_2.5") != std::string::npos) {
463 if(p1 != std::string::npos) {
466 etamin = TString(
category.substr(p1 + 1, p2 - p1 - 1)).Atof();
469 etamax = TString(
category.substr(p1 + 1, p2 - p1 - 1)).Atof();
473 if(
category.find(
"EBlowEta") != std::string::npos) {
477 if(
category.find(
"EBhighEta") != std::string::npos) {
481 if(
category.find(
"EElowEta") != std::string::npos) {
485 if(
category.find(
"EEhighEta") != std::string::npos) {
495 if(p1 != std::string::npos) {
498 etmin = TString(
category.substr(p1 + 1, p2 - p1 - 1)).Atof();
501 etmax = TString(
category.substr(p1 + 1, p2 - p1 - 1)).Atof();
505 if(
category.find(
"gold") != std::string::npos ||
506 category.find(
"Gold") != std::string::npos ||
507 category.find(
"highR9") != std::string::npos) {
510 }
else if(
category.find(
"bad") != std::string::npos ||
511 category.find(
"Bad") != std::string::npos ||
512 category.find(
"lowR9") != std::string::npos
float etmin
min Et value for the bin
float getSmearingSigma(int runNumber, bool isEBEle, float R9Ele, float etaSCEle, float EtEle, paramSmear_t par, float nSigma=0.) const
float r9max
max R9 value for the bin
void AddScale(TString category_, int runMin_, int runMax_, double deltaP_, double err_deltaP_, double err_syst_deltaP)
float getScaleSystUncertainty(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const
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 ...
Sin< T >::type sin(const T &t)
void ReadFromFile(TString filename)
category "runNumber" runMin runMax deltaP err_deltaP_per_bin err_deltaP_stat err_deltaP_syst ...
float ScaleCorrection(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const
method to get energy scale corrections
correctionValue_class getScaleCorrection(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const
returns the correction value class
correctionCategory_class(TString category_)
constructor with name of the category according to ElectronCategory_class
float etmax
max Et value for the bin
bool operator<(const correctionCategory_class &b) const
for ordering of the categories
void AddSmearing(TString category_, int runMin_, int runMax_, double rho, double err_rho, double phi, double err_phi, double Emean, double err_Emean)
EnergyScaleCorrection_class()
~EnergyScaleCorrection_class(void)
dummy constructor needed in ElectronEnergyCalibratorRun2
Cos< T >::type cos(const T &t)
float getScaleOffset(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const
float getSmearingRho(int runNumber, bool isEBEle, float R9Ele, float etaSCEle, float EtEle) const
public for sigmaE estimate
correction_map_t smearings_not_defined
float etamin
min eta value for the bin
correction_map_t smearings
float r9min
min R9 vaule for the bin
float getScaleStatUncertainty(unsigned int runNumber, bool isEBEle, double R9Ele, double etaSCEle, double EtEle) const
void ReadSmearingFromFile(TString filename)
File structure: category constTerm alpha;.
float etamax
max eta value for the bin
fileFormat_t smearingType_