CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFEnergyCalibration.cc
Go to the documentation of this file.
3 #include <TMath.h>
4 #include <math.h>
5 #include <vector>
6 #include <TF1.h>
7 #include <map>
8 
9 using namespace std;
10 
12 {
14 }
15 
17 {
18 
19  delete faBarrel;
20  delete fbBarrel;
21  delete fcBarrel;
22  delete faEtaBarrel;
23  delete fbEtaBarrel;
24  delete faEndcap;
25  delete fbEndcap;
26  delete fcEndcap;
27  delete faEtaEndcap;
28  delete fbEtaEndcap;
29 
30 }
31 
32 void
34 
35  // NEW NEW with HCAL pre-calibration
36 
37  threshE = 3.5;
38  threshH = 2.5;
39 
40  // Barrel (fit made with |eta| < 1.2)
41  faBarrel = new TF1("faBarrel","[0]+([1]+[2]/sqrt(x))*exp(-x/[3])-[4]*exp(-x*x/[5])",1.,1000.);
42  fbBarrel = new TF1("fbBarrel","[0]+([1]+[2]/sqrt(x))*exp(-x/[3])-[4]*exp(-x*x/[5])",1.,1000.);
43  fcBarrel = new TF1("fcBarrel","[0]+([1]+[2]/sqrt(x))*exp(-x/[3])-[4]*exp(-x*x/[5])",1.,1000.);
44  faEtaBarrel = new TF1("faEtaBarrel","[0]+[1]*exp(-x/[2])",1.,1000.);
45  fbEtaBarrel = new TF1("fbEtaBarrel","[0]+[1]*exp(-x/[2])+[3]*[3]*exp(-x*x/([4]*[4]))",1.,1000.);
46  faBarrel->SetParameter(0,1.15665);
47  fbBarrel->SetParameter(0,0.994603);
48  fcBarrel->SetParameter(0,0.956544);
49  faEtaBarrel->SetParameter(0,0.014664);
50  fbEtaBarrel->SetParameter(0,0.00975451);
51  faBarrel->SetParameter(1,0.165627);
52  fbBarrel->SetParameter(1,0.13632);
53  fcBarrel->SetParameter(1,0.0857207);
54  faEtaBarrel->SetParameter(1,-0.0426776);
55  fbEtaBarrel->SetParameter(1,0.102247);
56  faBarrel->SetParameter(2,0.827718);
57  fbBarrel->SetParameter(2,-0.758013);
58  fcBarrel->SetParameter(2,-0.44347);
59  faEtaBarrel->SetParameter(2,431.054);
60  fbEtaBarrel->SetParameter(2,436.21);
61  faBarrel->SetParameter(3,231.339);
62  fbBarrel->SetParameter(3,183.627);
63  fcBarrel->SetParameter(3,63.3479);
64  faBarrel->SetParameter(4,2.45332);
65  fbBarrel->SetParameter(4,1);
66  fcBarrel->SetParameter(4,1.24174);
67  faBarrel->SetParameter(5,29.6603);
68  fbBarrel->SetParameter(5,39.6784);
69  fcBarrel->SetParameter(5,12.322);
70 
71  // End-caps (fit made with eta
72  faEndcap = new TF1("faEndcap","[0]+([1]+[2]/sqrt(x))*exp(-x/[3])-[4]*exp(-x*x/[5])",1.,1000.);
73  fbEndcap = new TF1("fbEndcap","[0]+([1]+[2]/sqrt(x))*exp(-x/[3])-[4]*exp(-x*x/[5])",1.,1000.);
74  fcEndcap = new TF1("fcEndcap","[0]+([1]+[2]/sqrt(x))*exp(-x/[3])-[4]*exp(-x*x/[5])",1.,1000.);
75  faEtaEndcap = new TF1("faEtaEndcap","[0]+[1]*exp(-x/[2])",1.,1000.);
76  fbEtaEndcap = new TF1("fbEtaEndcap","[0]+[1]*exp(-x/[2])+[3]*[3]*exp(-x*x/([4]*[4]))",1.,1000.);
77  faEndcap->SetParameter(0,1.1272);
78  fbEndcap->SetParameter(0,0.982824);
79  fcEndcap->SetParameter(0,0.950244);
80  faEtaEndcap->SetParameter(0,-0.000582903);
81  fbEtaEndcap->SetParameter(0,0.0267319);
82  faEndcap->SetParameter(1,0.258536);
83  fbEndcap->SetParameter(1,0.0977533);
84  fcEndcap->SetParameter(1,0.00564779);
85  faEtaEndcap->SetParameter(1,-0.000482148);
86  fbEtaEndcap->SetParameter(1,-0.554552);
87  faEndcap->SetParameter(2,0.808071);
88  fbEndcap->SetParameter(2,0.155416);
89  fcEndcap->SetParameter(2,0.227162);
90  faEtaEndcap->SetParameter(2,209.466);
91  fbEtaEndcap->SetParameter(2,1.71188);
92  faEndcap->SetParameter(3,214.039);
93  fbEndcap->SetParameter(3,240.379);
94  fcEndcap->SetParameter(3,207.786);
95  fbEtaEndcap->SetParameter(3,0.235834);
96  faEndcap->SetParameter(4,2);
97  fbEndcap->SetParameter(4,1.2);
98  fcEndcap->SetParameter(4,1.32824);
99  fbEtaEndcap->SetParameter(4,-135.431);
100  faEndcap->SetParameter(5,47.2602);
101  fbEndcap->SetParameter(5,78.3083);
102  fcEndcap->SetParameter(5,22.1825);
103 
104 }
105 
106 void
107 PFEnergyCalibration::energyEmHad(double t, double& e, double&h, double eta, double phi) const {
108 
109 
110  // Use calorimetric energy as true energy for neutral particles
111  double tt = t;
112  double ee = e;
113  double hh = h;
114  double a = 1.;
115  double b = 1.;
116  double etaCorrE = 1.;
117  double etaCorrH = 1.;
118  t = min(999.9,max(tt,e+h));
119  if ( t < 1. ) return;
120 
121  // Barrel calibration
122  if ( fabs(eta) < 1.48 ) {
123 
124  // The energy correction
125  a = e>0. ? aBarrel(t) : 1.;
126  b = e>0. ? bBarrel(t) : cBarrel(t);
127  double thresh = e > 0. ? threshE : threshH;
128 
129  // Protection against negative calibration - to be tuned
130  if ( a < -0.25 || b < -0.25 ) {
131  a = 1.;
132  b = 1.;
133  thresh = 0.;
134  }
135 
136  // The new estimate of the true energy
137  t = min(999.9,max(tt, thresh+a*e+b*h));
138 
139  // The angular correction for ECAL hadronic deposits
140  etaCorrE = 1. + aEtaBarrel(t) + bEtaBarrel(t)*fabs(eta)*fabs(eta);
141  etaCorrH = 1.;
142  // etaCorr = 1.;
143  t = max(tt, thresh+etaCorrE*a*e+etaCorrH*b*h);
144 
145  if ( e > 0. && thresh > 0. )
146  e = h > 0. ? threshE-threshH + etaCorrE * a * e : threshE + etaCorrE * a * e;
147  if ( h > 0. && thresh > 0. )
148  h = threshH + etaCorrH * b * h;
149 
150  /*
151  if ( e < 0. || h < 0. ) {
152  std::cout << "Warning : Energy correction ! " << std::endl
153  << "eta,tt,e,h,a,b = " << eta << " " << tt << " "
154  << ee << "/" << e << " " << hh << "/" << h << " " << a << " " << b << std::endl;
155  }
156 
157  if ( etaCorrE > 2. || etaCorrE < 0.5 ||
158  etaCorrH > 2. || etaCorrH < 0.5 )
159  std::cout << "Warning : Angular correction ! " << std::endl
160  << "etaCorrE,etaCorrH,eta,t = "
161  << etaCorrE << " " << etaCorrH << " " << eta << " " << t << std::endl;
162  */
163 
164  // Endcap calibration
165  } else {
166 
167  // The energy correction
168  a = e>0. ? aEndcap(t) : 1.;
169  b = e>0. ? bEndcap(t) : cEndcap(t);
170  double thresh = e > 0. ? threshE : threshH;
171 
172  if ( a < -0.25 || b < -0.25 ) {
173  a = 1.;
174  b = 1.;
175  thresh = 0.;
176  }
177 
178  // The new estimate of the true energy
179  t = min(999.9,max(tt, thresh+a*e+b*h));
180 
181  // The angular correction
182  double dEta = fabs ( fabs(eta) - 1.5 );
183  double etaPow = dEta * dEta * dEta * dEta;
184  //etaCorrE = 1. + aEtaEndcap(t) + 0.5*bEtaEndcap(t)*etaPow;
185  etaCorrE = 1. + aEtaEndcap(t) + bEtaEndcap(t)*etaPow;
186  etaCorrH = 1. + aEtaEndcap(t) + bEtaEndcap(t)*etaPow;
187  /*
188  if ( etaCorr > 2. || etaCorr < 0.5 )
189  std::cout << "Warning : Angular correction ! " << std::endl
190  << "etaCorr,eta,t = " << etaCorr << " " << eta << " " << tt
191  << " ee,hh,e,h = " << e << " " << h << " " << a*e << " " << b*h
192  << std::endl;
193  */
194 
195  t = min(999.9,max(tt, thresh + etaCorrE*a*e + etaCorrH*b*h));
196 
197  if ( e > 0. && thresh > 0. )
198  e = h > 0. ? threshE-threshH + etaCorrE * a * e : threshE + etaCorrE * a * e;
199  if ( h > 0. && thresh > 0. )
200  h = threshH + b * etaCorrH * h;
201 
202 
203  }
204 
205  // Protection
206  if ( e < 0. || h < 0. ) {
207  /*
208  std::cout << "Warning : Energy correction ! " << std::endl
209  << "eta,tt,e,h,a,b = " << eta << " " << tt << " "
210  << ee << "/" << e << " " << hh << "/" << h << " " << a << " " << b << std::endl;
211  */
212  // Some protection against crazy calibration
213  if ( e < 0. ) e = ee;
214  if ( h < 0. ) h = hh;
215  }
216 
217  // And that's it !
218 
219 
220 }
221 
222 // The calibration functions
223 double
225 
226  if ( pfCalibrations ) {
227 
231 
232  } else {
233 
234  return faBarrel->Eval(x);
235 
236  }
237 }
238 
239 double
241 
242  if ( pfCalibrations ) {
243 
247 
248  } else {
249 
250  return fbBarrel->Eval(x);
251 
252  }
253 }
254 
255 double
257 
258  if ( pfCalibrations ) {
259 
263 
264  } else {
265 
266  return fcBarrel->Eval(x);
267 
268  }
269 }
270 
271 double
273 
274  if ( pfCalibrations ) {
275 
279 
280  } else {
281 
282  return faEtaBarrel->Eval(x);
283 
284  }
285 }
286 
287 double
289 
290  if ( pfCalibrations ) {
291 
295 
296  } else {
297 
298  return fbEtaBarrel->Eval(x);
299 
300  }
301 }
302 
303 double
305 
306  if ( pfCalibrations ) {
307 
311 
312  } else {
313 
314  return faEndcap->Eval(x);
315 
316  }
317 }
318 
319 double
321 
322  if ( pfCalibrations ) {
323 
327 
328  } else {
329 
330  return fbEndcap->Eval(x);
331 
332  }
333 }
334 
335 double
337 
338  if ( pfCalibrations ) {
339 
343 
344  } else {
345 
346  return fcEndcap->Eval(x);
347 
348  }
349 }
350 
351 double
353 
354  if ( pfCalibrations ) {
355 
359 
360  } else {
361 
362  return faEtaEndcap->Eval(x);
363 
364  }
365 }
366 
367 double
369 
370  if ( pfCalibrations ) {
371 
375 
376  } else {
377 
378  return fbEtaEndcap->Eval(x);
379 
380  }
381 }
382 
383 
384 double
386  std::vector<double> &EclustersPS1,
387  std::vector<double> &EclustersPS2,
388  bool crackCorrection ){
389  double eEcal = clusterEcal.energy();
390  //temporaty ugly fix
391  reco::PFCluster myPFCluster=clusterEcal;
392  myPFCluster.calculatePositionREP();
393  double eta = myPFCluster.positionREP().eta();
394  double phi = myPFCluster.positionREP().phi();
395 
396  double ePS1 = 0;
397  double ePS2 = 0;
398 
399  for(unsigned i=0;i<EclustersPS1.size();i++) ePS1 += EclustersPS1[i];
400  for(unsigned i=0;i<EclustersPS2.size();i++) ePS2 += EclustersPS2[i];
401 
402  double calibrated = Ecorr(eEcal,ePS1,ePS2,eta,phi, crackCorrection);
403  if(eEcal!=0 && calibrated==0) std::cout<<"Eecal = "<<eEcal<<" eta = "<<eta<<" phi = "<<phi<<std::endl;
404  return calibrated;
405 }
406 
408  std::vector<double> &EclustersPS1,
409  std::vector<double> &EclustersPS2,
410  double& ps1,double& ps2,
411  bool crackCorrection){
412  double eEcal = clusterEcal.energy();
413  //temporaty ugly fix
414  reco::PFCluster myPFCluster=clusterEcal;
415  myPFCluster.calculatePositionREP();
416  double eta = myPFCluster.positionREP().eta();
417  double phi = myPFCluster.positionREP().phi();
418 
419  double ePS1 = 0;
420  double ePS2 = 0;
421 
422  for(unsigned i=0;i<EclustersPS1.size();i++) ePS1 += EclustersPS1[i];
423  for(unsigned i=0;i<EclustersPS2.size();i++) ePS2 += EclustersPS2[i];
424 
425  double calibrated = Ecorr(eEcal,ePS1,ePS2,eta,phi,ps1,ps2,crackCorrection);
426  if(eEcal!=0 && calibrated==0) std::cout<<"Eecal = "<<eEcal<<" eta = "<<eta<<" phi = "<<phi<<std::endl;
427  return calibrated;
428 }
429 
430 
431 std::ostream& operator<<(std::ostream& out,
432  const PFEnergyCalibration& calib) {
433 
434  if(!out ) return out;
435 
436  out<<"PFEnergyCalibration -- "<<endl;
437 
438  if ( calib.pfCalibrations ) {
439 
440  std::cout << "Functions taken from the global tags : " << std::endl;
441 
442  static std::map<std::string, PerformanceResult::ResultType> functType;
443 
444  functType["PFfa_BARREL"] = PerformanceResult::PFfa_BARREL;
445  functType["PFfa_ENDCAP"] = PerformanceResult::PFfa_ENDCAP;
446  functType["PFfb_BARREL"] = PerformanceResult::PFfb_BARREL;
447  functType["PFfb_ENDCAP"] = PerformanceResult::PFfb_ENDCAP;
448  functType["PFfc_BARREL"] = PerformanceResult::PFfc_BARREL;
449  functType["PFfc_ENDCAP"] = PerformanceResult::PFfc_ENDCAP;
450  functType["PFfaEta_BARREL"] = PerformanceResult::PFfaEta_BARREL;
451  functType["PFfaEta_ENDCAP"] = PerformanceResult::PFfaEta_ENDCAP;
452  functType["PFfbEta_BARREL"] = PerformanceResult::PFfbEta_BARREL;
453  functType["PFfbEta_ENDCAP"] = PerformanceResult::PFfbEta_ENDCAP;
454 
455  for(std::map<std::string,PerformanceResult::ResultType>::const_iterator
456  func = functType.begin();
457  func != functType.end();
458  ++func) {
459 
460  cout << "Function: " << func->first << endl;
461  PerformanceResult::ResultType fType = func->second;
462  calib.pfCalibrations->printFormula(fType);
463  }
464 
465  } else {
466 
467  std::cout << "Default calibration functions : " << std::endl;
468 
469  calib.faBarrel->Print();
470  calib.fbBarrel->Print();
471  calib.fcBarrel->Print();
472  calib.faEtaBarrel->Print();
473  calib.fbEtaBarrel->Print();
474  calib.faEndcap->Print();
475  calib.fbEndcap->Print();
476  calib.fcEndcap->Print();
477  calib.faEtaEndcap->Print();
478  calib.fbEtaEndcap->Print();
479  }
480 
481  return out;
482 }
483 
484 
485 
486 
499 
500 
501 
507 
508 
509 //useful to compute the signed distance to the closest crack in the barrel
510 double
512  if(TMath::Abs(b)<TMath::Abs(a)) a=b;
513  return a;
514 }
515 
516 
517 //compute the unsigned distance to the closest phi-crack in the barrel
518 double
520 
521  static double pi= M_PI;// 3.14159265358979323846;
522 
523  //Location of the 18 phi-cracks
524  static std::vector<double> cPhi;
525  if(cPhi.size()==0)
526  {
527  cPhi.resize(18,0);
528  cPhi[0]=2.97025;
529  for(unsigned i=1;i<=17;++i) cPhi[i]=cPhi[0]-2*i*pi/18;
530  }
531 
532  //Shift of this location if eta<0
533  static double delta_cPhi=0.00638;
534 
535  double m; //the result
536 
537  //the location is shifted
538  if(eta<0) phi +=delta_cPhi;
539 
540  if (phi>=-pi && phi<=pi){
541 
542  //the problem of the extrema
543  if (phi<cPhi[17] || phi>=cPhi[0]){
544  if (phi<0) phi+= 2*pi;
545  m = minimum(phi -cPhi[0],phi-cPhi[17]-2*pi);
546  }
547 
548  //between these extrema...
549  else{
550  bool OK = false;
551  unsigned i=16;
552  while(!OK){
553  if (phi<cPhi[i]){
554  m=minimum(phi-cPhi[i+1],phi-cPhi[i]);
555  OK=true;
556  }
557  else i-=1;
558  }
559  }
560  }
561  else{
562  m=0.; //if there is a problem, we assum that we are in a crack
563  std::cout<<"Problem in dminphi"<<std::endl;
564  }
565  if(eta<0) m=-m; //because of the disymetry
566  return m;
567 }
568 
569 // corrects the effect of phi-cracks
570 double
572 
573  // we use 3 gaussians to correct the phi-cracks effect
574  static double p1= 5.59379e-01;
575  static double p2= -1.26607e-03;
576  static double p3= 9.61133e-04;
577 
578  static double p4= 1.81691e-01;
579  static double p5= -4.97535e-03;
580  static double p6= 1.31006e-03;
581 
582  static double p7= 1.38498e-01;
583  static double p8= 1.18599e-04;
584  static double p9= 2.01858e-03;
585 
586 
587  double dminphi = dCrackPhi(phi,eta);
588 
589  double result = (1+p1*TMath::Gaus(dminphi,p2,p3)+p4*TMath::Gaus(dminphi,p5,p6)+p7*TMath::Gaus(dminphi,p8,p9));
590 
591  return result;
592 }
593 
594 
595 // corrects the effect of |eta|-cracks
596 double
598 
599  // we use a gaussian with a screwness for each of the 5 |eta|-cracks
600  static std::vector<double> a; //amplitude
601  static std::vector<double> m; //mean
602  static std::vector<double> s; //sigma
603  static std::vector<double> sa; // screwness amplitude
604  static std::vector<double> ss; // screwness sigma
605 
606  if(a.size()==0)
607  {
608  a.push_back(6.13349e-01) ;a.push_back(5.08146e-01) ;a.push_back(4.44480e-01) ;a.push_back(3.3487e-01) ;a.push_back(7.65627e-01) ;
609  m.push_back(-1.79514e-02);m.push_back(4.44747e-01) ;m.push_back(7.92824e-01) ;m.push_back(1.14090e+00) ;m.push_back(1.47464e+00) ;
610  s.push_back(7.92382e-03) ;s.push_back(3.06028e-03) ;s.push_back(3.36139e-03) ;s.push_back(3.94521e-03) ;s.push_back(8.63950e-04) ;
611  sa.push_back(1.27228e+01);sa.push_back(3.81517e-02) ;sa.push_back(1.63507e-01);sa.push_back(-6.56480e-02);sa.push_back(1.87160e-01);
612  ss.push_back(5.48753e-02);ss.push_back(-1.00223e-02);ss.push_back(2.22866e-03);ss.push_back(4.26288e-04) ;ss.push_back(2.67937e-03);
613  }
614  double result = 1;
615 
616  for(unsigned i=0;i<=4;i++) result+=a[i]*TMath::Gaus(eta,m[i],s[i])*(1+sa[i]*TMath::Sign(1.,eta-m[i])*TMath::Exp(-TMath::Abs(eta-m[i])/ss[i]));
617 
618  return result;
619 }
620 
621 
622 //corrects the global behaviour in the barrel
623 double
625 
626  //Energy dependency
627  /*
628  //YM Parameters 52XX:
629  static double p0=1.00000e+00;
630  static double p1=3.27753e+01;
631  static double p2=2.28552e-02;
632  static double p3=3.06139e+00;
633  static double p4=2.25135e-01;
634  static double p5=1.47824e+00;
635  static double p6=1.09e-02;
636  static double p7=4.19343e+01;
637  */
638  static double p0 = 0.9944;
639  static double p1 = 9.827;
640  static double p2 = 1.503;
641  static double p3 = 1.196;
642  static double p4 = 0.3349;
643  static double p5 = 0.89;
644  static double p6 = 0.004361;
645  static double p7 = 51.51;
646  //Eta dependency
647  static double p8=2.705593e-03;
648 
649  double result = (p0+1/(p1+p2*TMath::Power(E,p3))+p4*TMath::Exp(-E/p5)+p6*TMath::Exp(-E*E/(p7*p7)))*(1+p8*eta*eta);
650 
651  return result;
652 }
653 
654 
655 
664 
665 
666 //Alpha, Beta, Gamma give the weight of each sub-detector (PS layer1, PS layer2 and Ecal) in the areas of the endcaps where there is a PS
667 // Etot = Beta*eEcal + Gamma*(ePS1 + Alpha*ePS2)
668 
669 double
671 
672  //Energy dependency
673  static double p0 = 5.97621e-01;
674 
675  //Eta dependency
676  static double p1 =-1.86407e-01;
677  static double p2 = 3.85197e-01;
678 
679  //so that <feta()> = 1
680  static double norm = (p1+p2*(2.6+1.656)/2);
681 
682  double result = p0*(p1+p2*eta)/norm;
683 
684  return result;
685 }
686 
687 double
688 PFEnergyCalibration::Beta(double E, double eta) {
689 
690  //Energy dependency
691  static double p0 = 0.032;
692  static double p1 = 9.70394e-02;
693  static double p2 = 2.23072e+01;
694  static double p3 = 100;
695 
696  //Eta dependency
697  static double p4 = 1.02496e+00 ;
698  static double p5 = -4.40176e-03 ;
699 
700  //so that <feta()> = 1
701  static double norm = (p4+p5*(2.6+1.656)/2);
702 
703  double result = (1.0012+p0*TMath::Exp(-E/p3)+p1*TMath::Exp(-E/p2))*(p4+p5*eta)/norm;
704  return result;
705 }
706 
707 
708 double
709 PFEnergyCalibration::Gamma(double etaEcal) {
710 
711  //Energy dependency
712  static double p0 = 2.49752e-02;
713 
714  //Eta dependency
715  static double p1 = 6.48816e-02;
716  static double p2 = -1.59517e-02;
717 
718  //so that <feta()> = 1
719  static double norm = (p1+p2*(2.6+1.656)/2);
720 
721  double result = p0*(p1+p2*etaEcal)/norm;
722 
723  return result;
724 }
725 
726 
727 
733 
734 
735 // returns the corrected energy in the barrel (0,1.48)
736 // Global Behaviour, phi and eta cracks are taken into account
737 double
738 PFEnergyCalibration::EcorrBarrel(double E, double eta, double phi,
739  bool crackCorrection ){
740 
741  // double result = E*CorrBarrel(E,eta)*CorrEta(eta)*CorrPhi(phi,eta);
742  double correction = crackCorrection ? std::max(CorrEta(eta),CorrPhi(phi,eta)) : 1.;
743  double result = E * CorrBarrel(E,eta) * correction;
744 
745  return result;
746 }
747 
748 
749 // returns the corrected energy in the area between the barrel and the PS (1.48,1.65)
750 double
752 
753  //Energy dependency
754  static double p0 =1;
755  static double p1 =0.18;
756  static double p2 =8.;
757 
758  //Eta dependency
759  static double p3 =0.3;
760  static double p4 =1.11;
761  static double p5 =0.025;
762  static double p6 =1.49;
763  static double p7 =0.6;
764 
765  //so that <feta()> = 1
766  static double norm = 1.21;
767 
768  double result = E*(p0+p1*TMath::Exp(-E/p2))*(p3+p4*TMath::Gaus(eta,p6,p5)+p7*eta)/norm;
769 
770  return result;
771 }
772 
773 
774 // returns the corrected energy in the PS (1.65,2.6)
775 // only when (ePS1>0)||(ePS2>0)
776 double
777 PFEnergyCalibration::EcorrPS(double eEcal,double ePS1,double ePS2,double etaEcal) {
778 
779  // gives the good weights to each subdetector
780  double E = Beta(1.0155*eEcal+0.025*(ePS1+0.5976*ePS2)/9e-5,etaEcal)*eEcal+Gamma(etaEcal)*(ePS1+Alpha(etaEcal)*ePS2)/9e-5 ;
781 
782  //Correction of the residual energy dependency
783  static double p0 = 1.00;
784  static double p1 = 2.18;
785  static double p2 =1.94;
786  static double p3 =4.13;
787  static double p4 =1.127;
788 
789  double result = E*(p0+p1*TMath::Exp(-E/p2)-p3*TMath::Exp(-E/p4));
790 
791  return result;
792 }
793 
794 // returns the corrected energy in the PS (1.65,2.6)
795 // only when (ePS1>0)||(ePS2>0)
796 double
797 PFEnergyCalibration::EcorrPS(double eEcal,double ePS1,double ePS2,double etaEcal,double & outputPS1, double & outputPS2) {
798 
799  // gives the good weights to each subdetector
800  double gammaprime=Gamma(etaEcal)/9e-5;
801  outputPS1=gammaprime*ePS1;
802  outputPS2=gammaprime*Alpha(etaEcal)*ePS2;
803  double E = Beta(1.0155*eEcal+0.025*(ePS1+0.5976*ePS2)/9e-5,etaEcal)*eEcal+outputPS1+outputPS2;
804 
805  //Correction of the residual energy dependency
806  static double p0 = 1.00;
807  static double p1 = 2.18;
808  static double p2 =1.94;
809  static double p3 =4.13;
810  static double p4 =1.127;
811 
812  double corrfac=(p0+p1*TMath::Exp(-E/p2)-p3*TMath::Exp(-E/p4));
813  outputPS1*=corrfac;
814  outputPS2*=corrfac;
815  double result = E*corrfac;
816 
817  return result;
818 }
819 
820 
821 // returns the corrected energy in the PS (1.65,2.6)
822 // only when (ePS1=0)&&(ePS2=0)
823 double
825 
826  //Energy dependency
827  static double p0= 1.02;
828  static double p1= 0.165;
829  static double p2= 6.5 ;
830  static double p3= 2.1 ;
831 
832  //Eta dependency
833  static double p4 = 1.02496e+00 ;
834  static double p5 = -4.40176e-03 ;
835 
836  //so that <feta()> = 1
837  static double norm = (p4+p5*(2.6+1.656)/2);
838 
839  double result = eEcal*(p0+p1*TMath::Exp(-TMath::Abs(eEcal-p3)/p2))*(p4+p5*eta)/norm;
840 
841  return result;
842 }
843 
844 
845 // returns the corrected energy in the area between the end of the PS and the end of the endcap (2.6,2.98)
846 double
848 
849  //Energy dependency
850  static double p0 =1;
851  static double p1 = 0.058;
852  static double p2 =12.5;
853  static double p3 =-1.05444e+00;
854  static double p4 =-5.39557e+00;
855  static double p5 =8.38444e+00;
856  static double p6 = 6.10998e-01 ;
857 
858  //Eta dependency
859  static double p7 =1.06161e+00;
860  static double p8 = 0.41;
861  static double p9 =2.918;
862  static double p10 =0.0181;
863  static double p11= 2.05;
864  static double p12 =2.99;
865  static double p13=0.0287;
866 
867  //so that <feta()> = 1
868  static double norm=1.045;
869 
870  double result = E*(p0+p1*TMath::Exp(-(E-p3)/p2)+1/(p4+p5*TMath::Power(E,p6)))*(p7+p8*TMath::Gaus(eta,p9,p10)+p11*TMath::Gaus(eta,p12,p13))/norm;
871  return result;
872 }
873 
874 
875 
876 
877 // returns the corrected energy everywhere
878 // this work should be improved between 1.479 and 1.52 (junction barrel-endcap)
879 double
880 PFEnergyCalibration::Ecorr(double eEcal,double ePS1,double ePS2,
881  double eta,double phi,
882  bool crackCorrection ) {
883 
884  static double endBarrel=1.48;
885  static double beginingPS=1.65;
886  static double endPS=2.6;
887  static double endEndCap=2.98;
888 
889  double result=0;
890 
891  eta=TMath::Abs(eta);
892 
893  if(eEcal>0){
894  if(eta <= endBarrel) result = EcorrBarrel(eEcal,eta,phi,crackCorrection);
895  else if(eta <= beginingPS) result = EcorrZoneBeforePS(eEcal,eta);
896  else if((eta < endPS) && ePS1==0 && ePS2==0) result = EcorrPS_ePSNil(eEcal,eta);
897  else if(eta < endPS) result = EcorrPS(eEcal,ePS1,ePS2,eta);
898  else if(eta < endEndCap) result = EcorrZoneAfterPS(eEcal,eta);
899  else result =eEcal;
900  }
901  else result = eEcal;// useful if eEcal=0 or eta>2.98
902  //protection
903  if(result<eEcal) result=eEcal;
904  return result;
905 }
906 
907 // returns the corrected energy everywhere
908 // this work should be improved between 1.479 and 1.52 (junction barrel-endcap)
909 double
910 PFEnergyCalibration::Ecorr(double eEcal,double ePS1,double ePS2,double eta,double phi,double& ps1,double&ps2,bool crackCorrection) {
911 
912  static double endBarrel=1.48;
913  static double beginingPS=1.65;
914  static double endPS=2.6;
915  static double endEndCap=2.98;
916 
917  double result=0;
918 
919  eta=TMath::Abs(eta);
920 
921  if(eEcal>0){
922  if(eta <= endBarrel) result = EcorrBarrel(eEcal,eta,phi,crackCorrection);
923  else if(eta <= beginingPS) result = EcorrZoneBeforePS(eEcal,eta);
924  else if((eta < endPS) && ePS1==0 && ePS2==0) result = EcorrPS_ePSNil(eEcal,eta);
925  else if(eta < endPS) result = EcorrPS(eEcal,ePS1,ePS2,eta,ps1,ps2);
926  else if(eta < endEndCap) result = EcorrZoneAfterPS(eEcal,eta);
927  else result =eEcal;
928  }
929  else result = eEcal;// useful if eEcal=0 or eta>2.98
930  // protection
931  if(result<eEcal) result=eEcal;
932  return result;
933 }
float getResult(PerformanceResult::ResultType, BinningPointByMap) const
int i
Definition: DBlmapReader.cc:9
double Beta(double E, double eta)
double EcorrZoneAfterPS(double E, double eta)
double Alpha(double eta)
const PerformancePayloadFromTFormula * pfCalibrations
double bBarrel(double x) const
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
double aEndcap(double x) const
double bEndcap(double x) const
double EcorrBarrel(double E, double eta, double phi, bool crackCorrection=true)
double EcorrZoneBeforePS(double E, double eta)
double EcorrPS_ePSNil(double eEcal, double eta)
double CorrEta(double eta)
#define min(a, b)
Definition: mlp_lapack.h:161
T eta() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
void energyEmHad(double t, double &e, double &h, double eta, double phi) const
double Gamma(double etaEcal)
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
double CorrPhi(double phi, double eta)
double CorrBarrel(double E, double eta)
const T & max(const T &a, const T &b)
void calculatePositionREP()
computes posrep_ once and for all
Definition: PFCluster.h:79
double bEtaEndcap(double x) const
double p4[4]
Definition: TauolaWrapper.h:92
double cEndcap(double x) const
tuple result
Definition: query.py:137
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:76
double p2[4]
Definition: TauolaWrapper.h:90
double dCrackPhi(double phi, double eta)
double energy() const
cluster energy
Definition: PFCluster.h:73
tuple out
Definition: dbtoconf.py:99
#define M_PI
Definition: BFit3D.cc:3
bool insert(BinningVariables::BinningVariablesType, float)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double b
Definition: hdecay.h:120
double EcorrPS(double eEcal, double ePS1, double ePS2, double etaEcal)
double aEtaBarrel(double x) const
double p1[4]
Definition: TauolaWrapper.h:89
double Ecorr(double eEcal, double ePS1, double ePS2, double eta, double phi, bool crackCorrection=true)
double a
Definition: hdecay.h:121
double aEtaEndcap(double x) const
tuple cout
Definition: gather_cfg.py:121
void printFormula(PerformanceResult::ResultType res) const
double bEtaBarrel(double x) const
double pi
Definition: DDAxes.h:10
double minimum(double a, double b)
double aBarrel(double x) const
double cBarrel(double x) const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
double energyEm(const reco::PFCluster &clusterEcal, std::vector< double > &EclustersPS1, std::vector< double > &EclustersPS2, bool crackCorrection=true)
double p3[4]
Definition: TauolaWrapper.h:91
Definition: DDAxes.h:10