CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoEcal/EgammaCoreTools/plugins/EcalClusterEnergyCorrection.cc

Go to the documentation of this file.
00001 #include "RecoEcal/EgammaCoreTools/plugins/EcalClusterEnergyCorrection.h"
00002 
00003 // Shower leakage corrections developed by Jungzhie et al. using TB data
00004 // Developed for EB only!
00005 float EcalClusterEnergyCorrection::fEta(float energy, float eta, int algorithm) const
00006 {
00007 
00008   // this correction is setup only for EB
00009   if ( algorithm != 0 ) return energy;
00010   
00011   float ieta = fabs(eta)*(5/0.087);
00012   float p0 = (params_->params())[0];  // should be 40.2198
00013   float p1 = (params_->params())[1];  // should be -3.03103e-6
00014 
00015   float correctedEnergy = energy;
00016   if ( ieta < p0 ) correctedEnergy = energy;
00017   else             correctedEnergy = energy/(1.0 + p1*(ieta-p0)*(ieta-p0));
00018   //std::cout << "ECEC fEta = " << correctedEnergy << std::endl;
00019   return correctedEnergy;
00020 }
00021 
00022 float EcalClusterEnergyCorrection::fBrem(float e, float brem, int algorithm) const 
00023 {
00024   // brem == phiWidth/etaWidth of the SuperCluster 
00025   // e  == energy of the SuperCluster 
00026   // first parabola (for br > threshold) 
00027   // p0 + p1*x + p2*x^2 
00028   // second parabola (for br <= threshold) 
00029   // ax^2 + bx + c, make y and y' the same in threshold 
00030   // y = p0 + p1*threshold + p2*threshold^2  
00031   // yprime = p1 + 2*p2*threshold 
00032   // a = p3 
00033   // b = yprime - 2*a*threshold 
00034   // c = y - a*threshold^2 - b*threshold 
00035 
00036   int offset;
00037   if ( algorithm == 0 ) offset = 0;
00038   else if ( algorithm == 1 ) offset = 20;
00039   else {
00040     // not supported, produce no correction
00041     return e;
00042   }
00043 
00044   //Make No Corrections if brem is invalid! 
00045   if ( brem == 0 ) return e; 
00046 
00047   float bremLowThr  = (params_->params())[2 + offset];
00048   float bremHighThr = (params_->params())[3 + offset];
00049   if ( brem < bremLowThr  ) brem = bremLowThr;
00050   if ( brem > bremHighThr ) brem = bremHighThr;
00051 
00052   // Parameters provided in cfg file
00053   float p0 = (params_->params())[4 + offset];
00054   float p1 = (params_->params())[5 + offset];
00055   float p2 = (params_->params())[6 + offset];
00056   float p3 = (params_->params())[7 + offset];
00057   float p4 = (params_->params())[8 + offset];
00058   // 
00059   float threshold = p4;  
00060 
00061   float y = p0*threshold*threshold + p1*threshold + p2; 
00062   float yprime = 2*p0*threshold + p1; 
00063   float a = p3; 
00064   float b = yprime - 2*a*threshold; 
00065   float c = y - a*threshold*threshold - b*threshold; 
00066    
00067   float fCorr = 1; 
00068   if ( brem < threshold )  
00069     fCorr = p0*brem*brem + p1*brem + p2; 
00070   else  
00071     fCorr = a*brem*brem + b*brem + c; 
00072  
00073   //std::cout << "ECEC fBrem " << e/fCorr << std::endl;
00074   return e/fCorr; 
00075 }   
00076 
00077 
00078 float EcalClusterEnergyCorrection::fEtEta(float et, float eta, int algorithm) const
00079 { 
00080   // et -- Et of the SuperCluster (with respect to (0,0,0)) 
00081   // eta -- eta of the SuperCluster 
00082 
00083   //std::cout << "fEtEta, mode = " << algorithm << std::endl;
00084   //std::cout << "ECEC: p0    " << (params_->params())[9]  << " " << (params_->params())[10] << " " << (params_->params())[11] << " " << (params_->params())[12] << std::endl;
00085   //std::cout << "ECEC: p1    " << (params_->params())[13] << " " << (params_->params())[14] << " " << (params_->params())[15] << " " << (params_->params())[16] << std::endl;
00086   //std::cout << "ECEC: fcorr " << (params_->params())[17] << " " << (params_->params())[18] << " " << (params_->params())[19] << std::endl;
00087  
00088   float fCorr = 0.; 
00089   int offset;
00090   if ( algorithm == 0 ) offset = 0;
00091   else if ( algorithm == 1 ) offset = 20;
00092   else if ( algorithm == 10 ) offset = 28;
00093   else if ( algorithm == 11 ) offset = 39;
00094   else {
00095     // not supported, produce no correction
00096     return et;
00097   }
00098 
00099   // Barrel 
00100   if ( algorithm == 0 || algorithm == 10 ) { 
00101     float p0 = (params_->params())[ 9 + offset]  + (params_->params())[10 + offset]/ (et + (params_->params())[11 + offset]) + (params_->params())[12 + offset]/(et*et);  
00102     float p1 = (params_->params())[13 + offset]  + (params_->params())[14 + offset]/ (et + (params_->params())[15 + offset]) + (params_->params())[16 + offset]/(et*et);  
00103  
00104     fCorr = p0 +  p1 * atan((params_->params())[17 + offset]*((params_->params())[18 + offset]-fabs(eta))) + (params_->params())[19 + offset] * fabs(eta); 
00105  
00106   } else if ( algorithm == 1 || algorithm == 11 ) { // Endcap 
00107     float p0 = (params_->params())[ 9 + offset] + (params_->params())[10 + offset]/sqrt(et); 
00108     float p1 = (params_->params())[11 + offset] + (params_->params())[12 + offset]/sqrt(et); 
00109     float p2 = (params_->params())[13 + offset] + (params_->params())[14 + offset]/sqrt(et); 
00110     float p3 = (params_->params())[15 + offset] + (params_->params())[16 + offset]/sqrt(et); 
00111   
00112     fCorr = p0 + p1*fabs(eta) + p2*eta*eta + p3/fabs(eta); 
00113   } 
00114  
00115   // cap the correction at 50%
00116   if ( fCorr < 0.5 ) fCorr = 0.5;  
00117   if ( fCorr > 1.5 ) fCorr = 1.5;   
00118  
00119   //std::cout << "ECEC fEtEta " << et/fCorr << std::endl;
00120   return et/fCorr; 
00121 } 
00122 
00123 
00124 float EcalClusterEnergyCorrection::getValue( const reco::SuperCluster & superCluster, const int mode ) const
00125 {
00126   // mode flags:
00127   // hybrid modes: 1 - return f(eta) correction in GeV
00128   //               2 - return f(eta) + f(brem) correction
00129   //               3 - return f(eta) + f(brem) + f(et, eta) correction
00130   // multi5x5:     4 - return f(brem) correction
00131   //               5 - return f(brem) + f(et, eta) correction
00132 
00133   // special cases: mode = 10 -- return f(et, eta) correction with respect to already corrected SC in barrel
00134   //                mode = 11 -- return f(et, eta) correction with respect to already corrected SC in endcap
00135 
00136   checkInit();
00137   
00138   float eta = fabs(superCluster.eta()); 
00139   float brem = superCluster.phiWidth()/superCluster.etaWidth(); 
00140   int algorithm = -1;
00141 
00142   if ( mode <= 3  || mode == 10 ) {
00143     // algorithm: hybrid
00144     algorithm = 0;
00145 
00146     float energy = superCluster.rawEnergy();
00147     if ( mode == 10 ) {
00148       algorithm = 10;
00149       energy = superCluster.energy();
00150     }
00151     float correctedEnergy = fEta(energy, eta, algorithm);
00152 
00153     if ( mode == 1 ) {
00154       return correctedEnergy - energy;
00155 
00156     } else {
00157       // now apply F(brem)
00158       correctedEnergy = fBrem(correctedEnergy, brem, algorithm);
00159       if ( mode == 2 ) {
00160         return correctedEnergy - energy;
00161       }
00162 
00163       float correctedEt = correctedEnergy/cosh(eta);
00164       correctedEt = fEtEta(correctedEt, eta, algorithm);
00165       correctedEnergy = correctedEt*cosh(eta);
00166       return correctedEnergy - energy;
00167     }
00168   } else if ( mode == 4 || mode == 5 || mode == 11 ) {
00169     algorithm = 1;
00170 
00171     float energy = superCluster.rawEnergy() + superCluster.preshowerEnergy(); 
00172     if ( mode == 11 ) {
00173       algorithm = 11;    
00174       energy = superCluster.energy();
00175     }
00176 
00177     float correctedEnergy = fBrem(energy, brem, algorithm);
00178     if ( mode == 4 ) {
00179       return correctedEnergy - energy;
00180     }
00181 
00182     float correctedEt = correctedEnergy/cosh(eta);
00183     correctedEt = fEtEta(correctedEt, eta, algorithm);
00184     correctedEnergy = correctedEt*cosh(eta);
00185     return correctedEnergy - energy;
00186 
00187   } else {
00188     
00189     // perform no correction
00190     return 0;
00191   }
00192   
00193 }
00194 
00195 
00196 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionFactory.h"
00197 DEFINE_EDM_PLUGIN( EcalClusterFunctionFactory, EcalClusterEnergyCorrection, "EcalClusterEnergyCorrection");