CMS 3D CMS Logo

EnergyUncertaintyElectronSpecific.cc
Go to the documentation of this file.
2 #include "TMath.h"
3 
4 #include <iostream>
5 
6 
8 }
9 
11  {}
12 
14  {}
15 
17  {
18  if (c == reco::GsfElectron::GOLDEN) return computeElectronEnergyUncertainty_golden(eta,brem,energy) ;
22  if (c == reco::GsfElectron::GAP) return computeElectronEnergyUncertainty_cracks(eta,brem,energy) ;
23  throw cms::Exception("GsfElectronAlgo|InternalError")<<"unknown classification" ;
24  }
25 
27 
28  double et = energy/cosh(eta);
29 
30  constexpr int nBinsEta=5;
31  constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.4, 0.8, 1.5, 2.0, 2.5};
32 
33  constexpr int nBinsBrem=6;
34  constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.0, 1.1, 1.2, 1.3, 1.5, 8.0};
35 
36  constexpr float par0[nBinsEta][nBinsBrem] = {
37  {0.00567891,
38  0.0065673,
39  0.00574742,
40  0.00542964,
41  0.00523293,
42  0.00547518},
43 
44  {0.00552517,
45  0.00611188,
46  0.0062729,
47  0.00574846,
48  0.00447373,
49  0.00595789},
50 
51  {0.00356679,
52  0.00503827,
53  0.00328016,
54  0.00592303,
55  0.00512479,
56  0.00484166},
57 
58  {0.0109195,
59  0.0102361,
60  0.0101576,
61  0.0120683,
62  0.0155326,
63  0.0225035},
64 
65  {0.0109632,
66  0.0103342,
67  0.0103486,
68  0.00862762,
69  0.0111448,
70  0.0146648}};
71 
72  static_assert(par0[0][0] == 0.00567891f);
73  static_assert(par0[0][1] == 0.0065673f);
74  static_assert(par0[1][3] == 0.00574846f);
75 
76  constexpr float par1[nBinsEta][nBinsBrem] = {
77  {0.238685,
78  0.193642,
79  0.249171,
80  0.259997,
81  0.310505,
82  0.390506},
83 
84  {0.288736,
85  0.312303,
86  0.294717,
87  0.294491,
88  0.379178,
89  0.38164},
90 
91  {0.456456,
92  0.394912,
93  0.541713,
94  0.401744,
95  0.483151,
96  0.657995},
97 
98  {1.13803,
99  1.39866,
100  1.51353,
101  1.48587,
102  1.49732,
103  1.82363},
104 
105  {0.458212,
106  0.628761,
107  0.659144,
108  0.929563,
109  1.06724,
110  1.6427}};
111 
112  constexpr float par2[nBinsEta][nBinsBrem] = {
113  {2.12035,
114  3.41493,
115  1.7401,
116  1.46234,
117  0.233226,
118  -2.78168},
119 
120  {1.30552,
121  0.137905,
122  0.653793,
123  0.790746,
124  -1.42584,
125  -2.34653},
126 
127  {0.610716,
128  0.778879,
129  -1.58577,
130  1.45098,
131  -0.0985911,
132  -3.47167},
133  {
134  -3.48281,
135  -6.4736,
136  -8.03308,
137  -7.55974,
138  -7.98843,
139  -10.1027},
140 
141  {0.995183,
142  -2.42889,
143  -2.14073,
144  -6.27768,
145  -7.68512,
146  -13.3504}};
147 
148  Int_t iEtaSl = -1;
149  for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){
150  if ( EtaBins[iEta] <= fabs(eta) && fabs(eta) <EtaBins[iEta+1] ){
151  iEtaSl = iEta;
152  }
153  }
154 
155  Int_t iBremSl = -1;
156  for (Int_t iBrem = 0; iBrem < nBinsBrem; ++iBrem){
157  if ( BremBins[iBrem] <= brem && brem <BremBins[iBrem+1] ){
158  iBremSl = iBrem;
159  }
160  }
161 
162  if (fabs(eta)>2.5) iEtaSl = nBinsEta-1;
163  if (brem<BremBins[0]) iBremSl = 0;
164  if (brem>BremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1;
165 
166  if(iEtaSl == -1) {
167  edm::LogError("BadRange")<<"Bad eta value: "<<eta<<" in computeElectronEnergyUncertainty_golden";
168  return 0;
169  }
170 
171  if(iBremSl == -1) {
172  edm::LogError("BadRange")<<"Bad brem value: "<<brem<<" in computeElectronEnergyUncertainty_golden";
173  return 0;
174  }
175 
176  float uncertainty = 0;
177  if (et<5) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(5-par2[iEtaSl][iBremSl]);
178  if (et>100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]);
179 
180  if (et>5 && et<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(et-par2[iEtaSl][iBremSl]);
181 
182  return (uncertainty*energy);
183 
184 }
185 
187 
188  const double et = energy/cosh(eta);
189 
190  constexpr int nBinsEta=4;
191  constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.5, 2.0, 2.5};
192 
193  constexpr int nBinsBrem=1;
194  constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 8.0};
195 
196  constexpr float par0[nBinsEta][nBinsBrem] =
197  {{0.00593389}, {0.00266954},
198  {0.00500623}, {0.00841038} };
199 
200  constexpr float par1[nBinsEta][nBinsBrem] =
201  {{0.178275},
202  {0.811415},
203  {2.34018},
204  {1.06851}};
205 
206  constexpr float par2[nBinsEta][nBinsBrem] =
207  {{-7.28273},
208  {-1.66063},
209  {-11.0129},
210  {-4.1259}};
211 
212  constexpr float par3[nBinsEta][nBinsBrem] =
213  {{13.2632},
214  {1.03555},
215  {-0.200323},
216  {-0.0646195}};
217 
218 
219  Int_t iEtaSl = -1;
220  for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){
221  if ( EtaBins[iEta] <= fabs(eta) && fabs(eta) <EtaBins[iEta+1] ){
222  iEtaSl = iEta;
223  }
224  }
225 
226  Int_t iBremSl = -1;
227  for (Int_t iBrem = 0; iBrem < nBinsBrem; ++iBrem){
228  if ( BremBins[iBrem] <= brem && brem <BremBins[iBrem+1] ){
229  iBremSl = iBrem;
230  }
231  }
232 
233  if (fabs(eta)>2.5) iEtaSl = nBinsEta-1;
234  if (brem<BremBins[0]) iBremSl = 0;
235  if (brem>BremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1;
236 
237  if(iEtaSl == -1) {
238  edm::LogError("BadRange")<<"Bad eta value: "<<eta<<" in computeElectronEnergyUncertainty_bigbrem";
239  return 0;
240  }
241 
242  if(iBremSl == -1) {
243  edm::LogError("BadRange")<<"Bad brem value: "<<brem<<" in computeElectronEnergyUncertainty_bigbrem";
244  return 0;
245  }
246 
247  float uncertainty = 0;
248  if (et<5) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(5-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((5-par2[iEtaSl][iBremSl])*(5-par2[iEtaSl][iBremSl]));
249  if (et>100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl]));
250 
251  if (et>5 && et<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(et-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((et-par2[iEtaSl][iBremSl])*(et-par2[iEtaSl][iBremSl]));
252 
253  return (uncertainty*energy);
254 
255 }
257 
258  const double et = energy/cosh(eta);
259 
260  constexpr int nBinsEta=4;
261  constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.7, 1.3, 1.8, 2.5};
262 
263  constexpr int nBinsBrem=1;
264  constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 8.0};
265 
266  constexpr float par0[nBinsEta][nBinsBrem] =
267  {{0.00601311},
268  {0.0059814},
269  {0.00953032},
270  {0.00728618}};
271 
272  constexpr float par1[nBinsEta][nBinsBrem] =
273  {{ 0.390988},
274  {1.02668},
275  {2.27491},
276  {2.08268}};
277 
278  constexpr float par2[nBinsEta][nBinsBrem] =
279  {{-4.11919},
280  {-2.87477},
281  {-7.61675},
282  {-8.66756}};
283 
284  constexpr float par3[nBinsEta][nBinsBrem]=
285  {{4.61671},
286  {0.163447},
287  {-0.335786},
288  {-1.27831}};
289 
290  Int_t iEtaSl = -1;
291  for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){
292  if ( EtaBins[iEta] <= fabs(eta) && fabs(eta) <EtaBins[iEta+1] ){
293  iEtaSl = iEta;
294  }
295  }
296 
297  Int_t iBremSl = -1;
298  for (Int_t iBrem = 0; iBrem < nBinsBrem; ++iBrem){
299  if ( BremBins[iBrem] <= brem && brem <BremBins[iBrem+1] ){
300  iBremSl = iBrem;
301  }
302  }
303 
304  if (fabs(eta)>2.5) iEtaSl = nBinsEta-1;
305  if (brem<BremBins[0]) iBremSl = 0;
306  if (brem>BremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1;
307 
308  if(iEtaSl == -1) {
309  edm::LogError("BadRange")<<"Bad eta value: "<<eta<<" in computeElectronEnergyUncertainty_badtrack";
310  return 0;
311  }
312 
313  if(iBremSl == -1) {
314  edm::LogError("BadRange")<<"Bad brem value: "<<brem<<" in computeElectronEnergyUncertainty_badtrack";
315  return 0;
316  }
317 
318  float uncertainty = 0;
319  if (et<5) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(5-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((5-par2[iEtaSl][iBremSl])*(5-par2[iEtaSl][iBremSl]));
320  if (et>100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl]));
321 
322  if (et>5 && et<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(et-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((et-par2[iEtaSl][iBremSl])*(et-par2[iEtaSl][iBremSl]));
323 
324  return (uncertainty*energy);
325 
326 }
327 
329 
330  const double et = energy/cosh(eta);
331 
332  constexpr int nBinsEta=4;
333  constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.2, 1.7, 2.5};
334 
335  constexpr int nBinsBrem=5;
336  constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.8, 2.2, 3.0, 4.0, 8.0};
337 
338  constexpr float par0[nBinsEta][nBinsBrem]= {
339  {0.0049351,
340  0.00566155,
341  0.0051397,
342  0.00468481,
343  0.00444475},
344 
345  {0.00201762,
346  0.00431475,
347  0.00501004,
348  0.00632666,
349  0.00636704},
350 
351  {-0.00729396,
352  0.00539783,
353  0.00608149,
354  0.00465335,
355  0.00642685},
356 
357  {0.0149449,
358  0.0216691,
359  0.0255957,
360  0.0206101,
361  0.0180508} };
362 
363  constexpr float par1[nBinsEta][nBinsBrem] = {
364  {0.579925,
365  0.496137,
366  0.551947,
367  0.63011,
368  0.684261},
369 
370  {0.914762,
371  0.824483,
372  0.888521,
373  0.960241,
374  1.25728},
375 
376  {3.24295,
377  1.72935,
378  1.80606,
379  2.13562,
380  2.07592},
381 
382  {1.00448,
383  1.18393,
384  0.00775295,
385  2.59246,
386  3.1099}};
387 
388  constexpr float par2[nBinsEta][nBinsBrem] = {
389  {-9.33987,
390  -5.52543,
391  -7.30079,
392  -6.7722,
393  -4.67614},
394 
395  {-4.48042,
396  -5.02885,
397  -4.77311,
398  -3.36742,
399  -5.53561},
400 
401  {-17.1458,
402  -5.92807,
403  -6.67563,
404  -10.1105,
405  -7.50257},
406 
407  {-2.09368,
408  -4.56674,
409  -44.2722,
410  -13.1702,
411  -13.6208}};
412 
413  constexpr float par3[nBinsEta][nBinsBrem] = {
414  {1.62129,
415  1.19101,
416  1.89701,
417  1.81614,
418  1.64415},
419 
420  {-1.50473,
421  -0.153502,
422  -0.355145,
423  -1.16499,
424  -0.864123},
425 
426  {-4.69711,
427  -2.18733,
428  -0.922401,
429  -0.230781,
430  -2.91515},
431 
432  {0.455037,
433  -0.601872,
434  241.516,
435  -2.35024,
436  -2.11069}};
437 
438  Int_t iEtaSl = -1;
439  for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){
440  if ( EtaBins[iEta] <= fabs(eta) && fabs(eta) <EtaBins[iEta+1] ){
441  iEtaSl = iEta;
442  }
443  }
444 
445  Int_t iBremSl = -1;
446  for (Int_t iBrem = 0; iBrem < nBinsBrem; ++iBrem){
447  if ( BremBins[iBrem] <= brem && brem <BremBins[iBrem+1] ){
448  iBremSl = iBrem;
449  }
450  }
451 
452  if (fabs(eta)>2.5) iEtaSl = nBinsEta-1;
453  if (brem<BremBins[0]) iBremSl = 0;
454  if (brem>BremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1;
455 
456  if(iEtaSl == -1) {
457  edm::LogError("BadRange")<<"Bad eta value: "<<eta<<" in computeElectronEnergyUncertainty_showering";
458  return 0;
459  }
460 
461  if(iBremSl == -1) {
462  edm::LogError("BadRange")<<"Bad brem value: "<<brem<<" in computeElectronEnergyUncertainty_showering";
463  return 0;
464  }
465 
466  float uncertainty = 0;
467  if (et<5) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(5-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((5-par2[iEtaSl][iBremSl])*(5-par2[iEtaSl][iBremSl]));
468  if (et>100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl]));
469 
470  if (et>5 && et<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(et-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((et-par2[iEtaSl][iBremSl])*(et-par2[iEtaSl][iBremSl]));
471 
472  return (uncertainty*energy);
473 
474 }
475 
477 
478  const double et = energy/cosh(eta);
479 
480  constexpr int nBinsEta=5;
481  constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.42, 0.78, 1.2, 1.52, 1.65};
482 
483  constexpr int nBinsBrem=6;
484  constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.2, 1.5, 2.1, 3., 4, 8.0};
485 
486  constexpr float par0[nBinsEta][nBinsBrem] = {
487  {0.0139815,
488  0.00550839,
489  0.0108292,
490  0.00596201,
491  -0.00498136,
492  0.000621696},
493 
494  {0.00467498,
495  0.00808463,
496  0.00546665,
497  0.00506318,
498  0.00608425,
499  -4.45641e-06},
500 
501  {0.00971734,
502  0.00063951,
503  -0.0121618,
504  -0.00604365,
505  0.00492161,
506  -0.00143907},
507 
508  {-0.0844907,
509  -0.0592498,
510  -0.0828631,
511  -0.0740798,
512  -0.0698045,
513  -0.0699518},
514 
515  {-0.0999971,
516  -0.0999996,
517  -0.0989356,
518  -0.0999965,
519  -0.0833049,
520  -0.020072}};
521 
522  constexpr float par1[nBinsEta][nBinsBrem] = {
523  {0.569273,
524  0.674654,
525  0.523128,
526  1.02501,
527  1.75645,
528  0.955191},
529 
530  {0.697951,
531  0.580628,
532  0.814515,
533  0.819975,
534  0.829616,
535  1.18952},
536 
537  {3.79446,
538  2.47472,
539  5.12931,
540  3.42497,
541  1.84123,
542  2.3773},
543 
544  {19.9999,
545  10.4079,
546  16.6273,
547  15.9316,
548  15.4883,
549  14.7306},
550 
551  {15.9122,
552  18.5882,
553  19.9996,
554  19.9999,
555  18.2281,
556  8.1587}};
557 
558  constexpr float par2[nBinsEta][nBinsBrem] = {
559  {-4.31243,
560  -3.071,
561  -2.56702,
562  -7.74555,
563  -21.3726,
564  -6.2189},
565 
566  {-6.56009,
567  -3.66067,
568  -7.8275,
569  -6.01641,
570  -7.85456,
571  -8.27071},
572 
573  {-49.9996,
574  -25.0724,
575  -49.985,
576  -28.1932,
577  -10.6485,
578  -15.4014},
579 
580  {-39.9444,
581  -25.1133,
582  -49.9999,
583  -50,
584  -49.9998,
585  -49.9998},
586 
587  {-30.1268,
588  -42.6113,
589  -46.6999,
590  -47.074,
591  -49.9995,
592  -25.2897}};
593 
594 
595  static_assert(par0[0][3]==0.00596201f);
596  static_assert(par1[0][3]==1.02501f);
597  static_assert(par2[0][3]==-7.74555f);
598 
599 
600  static_assert(par0[2][4]==0.00492161f);
601  static_assert(par1[2][4]==1.84123f);
602  static_assert(par2[2][4]==-10.6485f);
603 
604  static_assert(par0[4][3]==-0.0999965f);
605  static_assert(par1[4][3]==19.9999f);
606  static_assert(par2[4][3]==-47.074f);
607 
608  Int_t iEtaSl = -1;
609  for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){
610  if ( EtaBins[iEta] <= fabs(eta) && fabs(eta) <EtaBins[iEta+1] ){
611  iEtaSl = iEta;
612  }
613  }
614 
615  Int_t iBremSl = -1;
616  for (Int_t iBrem = 0; iBrem < nBinsBrem; ++iBrem){
617  if ( BremBins[iBrem] <= brem && brem <BremBins[iBrem+1] ){
618  iBremSl = iBrem;
619  }
620  }
621 
622  if (fabs(eta)>2.5) iEtaSl = nBinsEta-1;
623  if (brem<BremBins[0]) iBremSl = 0;
624  if (brem>BremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1;
625 
626  if(iEtaSl == -1) {
627  edm::LogError("BadRange")<<"Bad eta value: "<<eta<<" in computeElectronEnergyUncertainty_cracks";
628  return 0;
629  }
630 
631  if(iBremSl == -1) {
632  edm::LogError("BadRange")<<"Bad brem value: "<<brem<<" in computeElectronEnergyUncertainty_cracks";
633  return 0;
634  }
635 
636  float uncertainty = 0;
637  if (et<5) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(5-par2[iEtaSl][iBremSl]);
638  if (et>100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]);
639 
640  if (et>5 && et<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(et-par2[iEtaSl][iBremSl]);
641 
642  return (uncertainty*energy);
643 
644 }
void init(const edm::EventSetup &theEventSetup)
double computeElectronEnergyUncertainty_badtrack(double eta, double brem, double energy)
double f[11][100]
double computeElectronEnergyUncertainty_cracks(double eta, double brem, double energy)
double computeElectronEnergyUncertainty_showering(double eta, double brem, double energy)
double computeElectronEnergyUncertainty(reco::GsfElectron::Classification c, double eta, double brem, double energy)
et
define resolution functions of each parameter
double computeElectronEnergyUncertainty_golden(double eta, double brem, double energy)
double computeElectronEnergyUncertainty_bigbrem(double eta, double brem, double energy)
#define constexpr