CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoParticleFlow/PFClusterTools/src/PFSCEnergyCalibration.cc

Go to the documentation of this file.
00001 #include "RecoParticleFlow/PFClusterTools/interface/PFSCEnergyCalibration.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include <vector>
00004 
00005 using namespace std;
00006 
00007 PFSCEnergyCalibration::PFSCEnergyCalibration() {}
00008 
00009 
00010 PFSCEnergyCalibration::PFSCEnergyCalibration(std::vector<double>& barrelFbremCorr,
00011                                              std::vector<double>& endcapFbremCorr,
00012                                              std::vector<double>& barrelCorr,
00013                                              std::vector<double>& endcapCorr):
00014   barrelFbremCorr_(barrelFbremCorr),
00015   endcapFbremCorr_(endcapFbremCorr),
00016   barrelCorr_(barrelCorr),
00017   endcapCorr_(endcapCorr)
00018 {
00019 
00020   // intial parameters
00021 
00022   bool log = false;
00023   
00024   if(barrelFbremCorr_.size() != 13)
00025     edm::LogError("PFSCEnergyCalibration")<<" wrong size input paramter: calibPFSCEle_Fbrem_barrel read = "
00026                                           << barrelCorr_.size() << " expected = 13" << endl;
00027   
00028   
00029   if(endcapFbremCorr_.size() != 13)
00030     edm::LogError("PFSCEnergyCalibration")<<" wrong size input parameter: calibPFSCEle_Fbrem_endcap read = "
00031                                           << endcapCorr_.size() << " expected = 13" << endl;
00032 
00033   
00034   
00035   if(barrelCorr_.size() != 17)
00036     edm::LogError("PFSCEnergyCalibration")<<" wrong size input paramter: calibPFSCEle_barrel read = "
00037                                           << barrelCorr_.size() << " expected = 17" << endl;
00038   
00039   
00040   if(endcapCorr_.size() != 9)
00041     edm::LogError("PFSCEnergyCalibration")<<" wrong size input parameter: calibPFSCEle_endcap read = "
00042                                           << endcapCorr_.size() << " expected = 9" << endl;
00043 
00044   
00045   if(log)
00046     cout << " ****** THE BARREL SC FBREM CORRECTIONS ******* " << barrelFbremCorr_.size()  << endl;
00047   for(unsigned int ip = 0; ip< barrelFbremCorr_.size(); ip++){
00048     pbb[ip] = barrelFbremCorr_[ip];
00049     if(log)
00050       cout << " pbb[" << ip << "] " << " = " << pbb[ip] << endl;
00051   }
00052   
00053   if(log)
00054     cout << " ****** THE ENCCAP SC FBREM CORRECTIONS ******* " << endcapFbremCorr_.size() << endl;
00055   for(unsigned int ip = 0; ip< endcapFbremCorr_.size(); ip++){
00056     pbe[ip] = endcapFbremCorr_[ip];
00057     if(log)
00058       cout << " pbe[" << ip << "] " << " = " << pbe[ip] << endl;
00059   }
00060   
00061   if(log)
00062     cout << " ****** THE BARREL SC CORRECTIONS ******* " << barrelCorr_.size()  << endl;
00063   for(unsigned int ip = 0; ip< barrelCorr_.size(); ip++){
00064     bb[ip] = barrelCorr_[ip];
00065     if(log)
00066       cout << " bb[" << ip << "] " << " = " << bb[ip] << endl;
00067   }
00068   
00069   if(log)
00070     cout << " ****** THE ENCCAP SC CORRECTIONS ******* " << endcapCorr_.size() << endl;
00071   for(unsigned int ip = 0; ip< endcapCorr_.size(); ip++){
00072     cc[ip] = endcapCorr_[ip];
00073     if(log)
00074       cout << " cc[" << ip << "] " << " = " << cc[ip] << endl;
00075   }
00076 }
00077 PFSCEnergyCalibration::~PFSCEnergyCalibration() {}
00078 
00079 
00080 double PFSCEnergyCalibration::SCCorrFBremBarrel(double e, double et, double brLinear) { //MM
00081   double fCorr = 1;
00082 
00083   // make NO correction if brLinear is invalid!
00084   if ( brLinear == 0 ) return e;
00085   //
00086   
00087   if ( brLinear < pbb[0] ) brLinear = pbb[0];
00088   if ( brLinear > pbb[1] ) brLinear = pbb[1];
00089   
00090   
00091   double p0 = pbb[2]; 
00092   double p1 = pbb[3];  
00093   double p2 = pbb[4]; 
00094   double p3 = pbb[5];
00095   double p4 = pbb[6];  
00096   
00097 
00098   //Low pt ( < 25 GeV) dedicated corrections
00099   if( et < pbb[7] ) {
00100     p0 = pbb[8]; 
00101     p1 = pbb[9];  
00102     p2 = pbb[10];  
00103     p3 = pbb[11];
00104     p4 = pbb[12];
00105   }
00106 
00107   double threshold = p4;
00108   
00109   double y = p0*threshold*threshold + p1*threshold + p2;
00110   double yprime = 2*p0*threshold + p1;
00111   double a = p3;
00112   double b = yprime - 2*a*threshold;
00113   double c = y - a*threshold*threshold - b*threshold;
00114   
00115   if ( brLinear < threshold ) 
00116     fCorr = p0*brLinear*brLinear + p1*brLinear + p2;
00117   else 
00118     fCorr = a*brLinear*brLinear + b*brLinear + c;
00119   
00120   return e/fCorr;
00121 
00122 }
00123 
00124 
00125 double PFSCEnergyCalibration::SCCorrFBremEndcap(double e, double eta, double brLinear) {//MM
00126   double fCorr = 1;
00127 
00128   //Energy must contain associated preshower energy
00129 
00130   if ( brLinear == 0 ) return e;
00131   
00132   if ( brLinear < pbe[0] ) brLinear = pbe[0];
00133   if ( brLinear > pbe[1] ) brLinear = pbe[1];
00134   
00135   
00136   double p0 = pbe[2]; 
00137   double p1 = pbe[3];  
00138   double p2 = pbe[4]; 
00139   double p3 = pbe[5];
00140   double p4 = pbe[6];  
00141 
00142   //Change of set of corrections to take
00143   //into account the active preshower region
00144   if(fabs(eta) > pbe[7] ) {
00145     p0 = pbe[8]; 
00146     p1 = pbe[9];  
00147     p2 = pbe[10];  
00148     p3 = pbe[11];
00149     p4 = pbe[12];   
00150   }
00151 
00152   double threshold = p4;
00153     
00154   double y = p0*threshold*threshold + p1*threshold + p2;
00155   double yprime = 2*p0*threshold + p1;
00156   double a = p3;
00157   double b = yprime - 2*a*threshold;
00158   double c = y - a*threshold*threshold - b*threshold;
00159 
00160   if ( brLinear < threshold ) 
00161     fCorr = p0*brLinear*brLinear + p1*brLinear + p2;
00162   else 
00163     fCorr = a*brLinear*brLinear + b*brLinear + c;
00164     
00165   return e/fCorr;
00166 
00167 
00168 }
00169 
00170 
00171 double PFSCEnergyCalibration::SCCorrEtEtaBarrel(double et, double eta) {
00172   double fCorr = 0;
00173   
00174   
00175   // 25 November Morning
00176   
00177 //   //p0  
00178 //   double bb0 = 1.03257;
00179 //   double bb1 = -1.37103e+01;
00180 //   double bb2 = 3.39716e+02;
00181 //   double bb3 = 4.86192e-01;
00182   
00183 //   //p1
00184 //   double bb4 = 1.81653e-03;
00185 //   double bb5 = 3.64445e-01;
00186 //   double bb6 = 1.41132;
00187   
00188   
00189 //   //p2
00190 //   double bb7 = 1.02061;
00191 //   double bb8 = 5.91624e-03;
00192 //   double bb9 = -5.14434e-05;
00193 //   double bb10 = 1.42516e-07; 
00194   
00195   //2010 corrections
00196 //  double temp_et = et;
00197 //   // Avoid energy correction divergency at low Et. 
00198 //   if(temp_et < 2)
00199 //     temp_et = 2;
00200   
00201 //   double d0 = 15.0;     // sharpness of the curve
00202 //   double d1 = -0.00181;
00203 //   double d2 = 1.081;
00204   
00205 //   double p0 = bb[0] + bb[1]/(temp_et + bb[2]) - bb[3]/(temp_et) ;
00206 //   double p1 = bb[4] + bb[5]/(bb[6] + temp_et);
00207 
00208   
00209 
00210 //   // for the momentum the fixed value d2 is prefered to p2
00211 //   double p2 = bb[7] + bb[8]*temp_et + bb[9]*temp_et*temp_et + bb[10]*temp_et*temp_et*temp_et;
00212   
00213 //   if(temp_et > 130) {
00214 //     double y = 130;
00215 //     p2 = bb[7] + bb[8]*y + bb[9]*y*y + bb[10]*y*y*y;
00216 //   }
00217    
00218 //   fCorr = p0 + p1*atan(d0*(d2 - fabs(eta))) + d1*fabs(eta);
00219  
00220 
00221   //February 2011 corrections
00222   double temp_et = et;
00223   // Avoid energy correction divergency at low Et. 
00224   if(temp_et < 3)
00225     temp_et = 3;
00226 
00227   double c0 = bb[0];
00228   double c1 = bb[1];
00229   double c2 = bb[2];
00230   double c3 = bb[3];
00231 
00232   double d0 = bb[4];
00233   double d1 = bb[5];
00234   double d2 = bb[6];
00235   double d3 = bb[7];
00236 
00237   double e0 = 1.081;  // curve point in eta distribution
00238   double e1 = 7.6;     // sharpness of the curve
00239   double e2 = -0.00181;
00240 
00241   //Low pt ( < 25 GeV) dedidacted corrections
00242   if(temp_et < bb[8] ) {
00243 
00244     c0 = bb[9];
00245     c1 = bb[10];
00246     c2 = bb[11];
00247     c3 = bb[12];
00248     
00249     d0 = bb[13];
00250     d1 = bb[14];
00251     d2 = bb[15];
00252     d3 = bb[16];
00253     
00254   }
00255   
00256   double p0 = c0 + c1/(temp_et + c2) + c3/(temp_et*temp_et);
00257   double p1 = d0/(temp_et + d1) + d2/(temp_et*temp_et + d3);
00258 
00259 
00260   fCorr = p0 + p1*atan(e1*(e0 - fabs(eta))) + e2*fabs(eta);
00261   
00262   return et/fCorr;
00263   
00264 }
00265 
00266 double PFSCEnergyCalibration::SCCorrEtEtaEndcap(double et, double eta) {
00267   double fCorr = 0;
00268   
00269 
00270 //   //p0
00271 //   double c0 = 9.99464e-01;
00272 //   double c1 = -1.23130e+01;
00273 //   double c2 = 2.87841;
00274   
00275 //   //p1
00276 //   double c3 = -1.05697e-04;
00277 //   double c4 = 1.02819e+01;
00278 //   double c5 = 3.05904; 
00279   
00280   
00281 //   //p2
00282 //   double c6 = 1.35017e-03;
00283 //   double c7 = -2.21845;
00284 //   double c8 = 3.42062;
00285  
00286   double temp_et = et;
00287   // Avoid energy correction divergency at low Et. 
00288   if(temp_et < 3)
00289     temp_et = 3;
00290 
00291   double p0 = cc[0] + cc[1]/(cc[2] + temp_et);
00292   double p1 = cc[3] + cc[4]/(cc[5] + temp_et);
00293   double p2 = cc[6] + cc[7]/(cc[8] + temp_et);
00294     
00295     
00296     fCorr = p0 + p1*fabs(eta) +  p2*eta*eta;
00297     
00298     return et/fCorr;
00299 }
00300