/afs/hep.man.ac.uk/u/markowen/ATLAS/SFrameProof/2011EPS/topUtils/src/electron_SF_EPS.h

00001 // copied from PhysicsAnalysis/TopPhys/TopPhysUtils/TopElectronSFUtils/trunk/electron_SF_EPS.h on 21 June 2011 at 3pm UK time
00002 #ifndef electron_SF_EPS_h
00003 #define electron_SF_EPS_h
00004 
00005 /****************************************************************************
00006  * electron_SF_EPS.h                                                        *
00007  *                                                                          *
00008  * Simple functions which return data/MC scale factors                      *
00009  * given a electron's eta                                                                                                       *
00010  * Also functions for corresponding uncertainties.                          *
00011  *                                                                          *
00012  * double ele_ID_SF(double et, double ET)                                   *
00013  * double ele_ID_SF_err(double eta, double ET)                                  *
00014  * double ele_reco_SF();                                                    *
00015  * double ele_reco_SF_err();                                                    *
00016  * double ele_recoID_SF(double eta, double ET);                             *
00017  * double ele_recoID_SF_err(double eta, double ET);                             *
00018  * double ele_trigger_SF();                                                 *
00019  * double ele_trigger_SF_err();                                                 *
00020  *                                                                          *
00021  * History                                                                  *
00022  *         26 Jan 2011 -- created by S. Caughron                            *   
00023  *         05 May 2011 -- updated for pLHC                                  *   
00024  *         14 May 2011 -- more pLHC updates                                 *   
00025  *         20 Jun 2011 -- updated for EPS                                   *   
00026  ***************************************************************************/
00027 
00028 #include <iostream>
00029 
00030 // forward declaration of functions
00031 double ele_ID_SF(double eta, double ET);
00032 double ele_ID_SF_err(double eta, double ET);
00033 double ele_reco_SF(double eta);
00034 double ele_reco_SF_err(double eta);
00035 double ele_recoID_SF(double eta, double ET);
00036 double ele_recoID_SF_err(double eta, double ET);
00037 double ele_trigger_SF(double eta);
00038 double ele_trigger_SF_err(double eta);
00039 
00040 
00041 // For ID+iso scale factors
00042 double ele_ID_SF(double eta, double ET)
00043 {
00044 
00045     double ele_eta = eta;
00046     double ele_ET = ET;
00047     int etaI=-1; int ET_I=-1;   
00048 
00049     const double etabins[18] = {-2.47,-2.37,-2.01,-1.81,-1.37,
00050                                                             -1.15,-0.8,-0.6,-0.1,0,0.1,0.6,0.8,1.15,
00051                                                             1.52,1.81,2.01,2.37};
00052     const double ETbins[5] = {25.,30.,35.,40.,45.}; // lower edges of eta bins
00053 
00054         const double SFmatrix[5][18] = {{0.972, 0.964, 1.007, 1.016, 1.071, 1.007, 0.967, 0.957, 0.979, 
00055                                                                         0.963, 0.953, 0.975, 0.999, 1.057, 1.024, 1.007, 0.957, 0.993},
00056                                                                         {1.003, 0.996, 1.040, 1.049, 1.106, 1.039, 0.998, 0.988, 1.010, 
00057                                                                         0.994, 0.984, 1.006, 1.031, 1.091, 1.057, 1.039, 0.988, 1.025},
00058                                                                         {1.013, 1.005, 1.050, 1.059, 1.117, 1.050, 1.008, 0.998, 1.020,
00059                                                                         1.004, 0.993, 1.016, 1.041, 1.102, 1.068, 1.050, 0.997, 1.035},
00060                                                                         {1.012, 1.005, 1.049, 1.059, 1.116, 1.049, 1.007, 0.997, 1.019,
00061                                                                         1.003, 0.993, 1.015, 1.041, 1.101, 1.067, 1.049, 0.997, 1.034},
00062                                                                         {1.015, 1.008, 1.053, 1.062, 1.120, 1.052, 1.010, 1.000, 1.023,
00063                                                                         1.006, 0.996, 1.019, 1.044, 1.105, 1.070, 1.052, 1.000, 1.037}};
00064                                                                    
00065         const double etamax = 2.47;
00066         const double etacrack[2] = {1.37,1.52};
00067 
00068     if ( fabs(ele_eta) > etamax || (fabs(ele_eta) > etacrack[0] && fabs(ele_eta) < etacrack[1]) )  // check forward, crack regions
00069 
00070         return 1.0;       
00071 
00072     else {           
00073         
00074         for (int i=17; i>=0; i--){    // find eta index
00075             if ( ele_eta > etabins[i] ) {
00076                 etaI = i;
00077                 break;
00078             }
00079         }
00080         for (int i=4; i>=0; i--){    // find eta index
00081             if ( ele_ET > ETbins[i] ) {
00082                 ET_I = i;
00083                 break;
00084             }
00085         }
00086 
00087         return SFmatrix[ET_I][etaI];
00088 
00089     } //else
00090 
00091     return 0;
00092 }
00093 
00094 // For ID+iso scale factor uncertainties (symmetric)
00095 double ele_ID_SF_err(double eta, double ET)
00096 {
00097 
00098     double ele_eta = eta;
00099     double ele_ET = ET;
00100     int etaI=-1; int ET_I=-1;   
00101 
00102     const double etabins[18] = {-2.47,-2.37,-2.01,-1.81,-1.37,
00103                                                             -1.15,-0.8,-0.6,-0.1,0,0.1,0.6,0.8,1.15,
00104                                                             1.52,1.81,2.01,2.37};
00105     const double ETbins[5] = {25.,30.,35.,40.,45.}; // lower edges of eta bins
00106 
00107         const double errmatrix[5][18] = {{0.038, 0.029, 0.037, 0.027, 0.029, 0.027, 0.027, 0.026, 0.030,
00108                                                                          0.027, 0.026, 0.027, 0.027, 0.033, 0.028, 0.035, 0.028, 0.033},
00109                                                                          {0.037, 0.028, 0.036, 0.026, 0.028, 0.026, 0.025, 0.025, 0.028,
00110                                                                          0.026, 0.025, 0.026, 0.026, 0.032, 0.026, 0.034, 0.026, 0.032},
00111                                                                          {0.035, 0.025, 0.034, 0.023, 0.026, 0.023, 0.023, 0.022, 0.026,
00112                                                                          0.023, 0.022, 0.023, 0.023, 0.029, 0.023, 0.031, 0.024, 0.030},
00113                                                                          {0.035, 0.025, 0.034, 0.023, 0.026, 0.023, 0.023, 0.022, 0.026,
00114                                                                          0.023, 0.022, 0.023, 0.023, 0.029, 0.023, 0.032, 0.024, 0.030},
00115                                                                          {0.037, 0.027, 0.036, 0.025, 0.028, 0.025, 0.025, 0.024, 0.028,
00116                                                                          0.025, 0.024, 0.025, 0.025, 0.031, 0.025, 0.033, 0.025, 0.031}};
00117 
00118 
00119         const double etamax = 2.47;
00120         const double etacrack[2] = {1.37,1.52};
00121 
00122     if ( fabs(ele_eta) > etamax || (fabs(ele_eta) > etacrack[0] && fabs(ele_eta) < etacrack[1]) )  // check forward, crack regions
00123 
00124         return 1.0;       
00125 
00126     else {           
00127         
00128         for (int i=17; i>=0; i--){    // find eta index
00129             if ( ele_eta > etabins[i] ) {
00130                 etaI = i;
00131                 break;
00132             }
00133         }
00134         for (int i=4; i>=0; i--){    // find ET index
00135             if ( ele_ET > ETbins[i] ) {
00136                 ET_I = i;
00137                 break;
00138             }
00139         }
00140                 
00141         return errmatrix[ET_I][etaI];
00142 
00143     } //else
00144 
00145     return 0;
00146 }
00147 
00148 double ele_reco_SF(double eta)
00149 {
00150 
00151     double ele_eta = eta;
00152     int etaI=-1; 
00153 
00154     const double etabins[3] = {0, 0.8, 2.37};
00155 
00156         const double SFmatrix[3] = {0.9984, 1.0091, 0.9759};
00157                                                                    
00158         const double etamax = 2.47;
00159         const double etacrack[2] = {1.37,1.52};
00160 
00161     if ( fabs(ele_eta) > etamax || (fabs(ele_eta) > etacrack[0] && fabs(ele_eta) < etacrack[1]) )  // check forward, crack regions
00162 
00163         return 1.0;       
00164 
00165     else {           
00166         
00167         for (int i=2; i>=0; i--){    // find eta index
00168             if ( fabs(ele_eta) > etabins[i] ) {
00169                 etaI = i;
00170                 break;
00171             }
00172         }
00173 
00174         return SFmatrix[etaI];
00175 
00176     } //else
00177 
00178     return 0;
00179 
00180 }
00181 
00182 // For reco SF uncertainties (symmetric)
00183 double ele_reco_SF_err(double eta)
00184 {
00185 
00186     double ele_eta = eta;
00187     int etaI=-1; 
00188 
00189     const double etabins[3] = {0, 0.8, 2.37};
00190 
00191         const double errmatrix[3] = {0.0066, 0.0070, 0.0184};
00192                                                                    
00193         const double etamax = 2.47;
00194         const double etacrack[2] = {1.37,1.52};
00195 
00196     if ( fabs(ele_eta) > etamax || (fabs(ele_eta) > etacrack[0] && fabs(ele_eta) < etacrack[1]) )  // check forward, crack regions
00197 
00198         return 1.0;       
00199 
00200     else {           
00201         
00202         for (int i=2; i>=0; i--){    // find eta index
00203             if ( fabs(ele_eta) > etabins[i] ) {
00204                 etaI = i;
00205                 break;
00206             }
00207         }
00208 
00209         return errmatrix[etaI];
00210 
00211     } //else
00212 
00213     return 0;
00214 
00215 }
00216 
00217 //returns cumulative reco+ID SF
00218 double ele_recoID_SF(double eta, double ET)
00219 {
00220 
00221         double ele_eta = eta;
00222         double ele_ET = ET;
00223         double total_SF = ele_ID_SF(ele_eta, ele_ET) * ele_reco_SF(ele_eta);
00224 
00225         return total_SF;
00226 
00227 }
00228 
00229 //returns cumulative reco+ID SF uncertainty
00230 double ele_recoID_SF_err(double eta, double ET)
00231 {
00232 
00233         double ele_eta = eta;
00234         double ele_ET = ET;
00235         double ID_err = ele_ID_SF_err(ele_eta, ele_ET) / ele_ID_SF(ele_eta, ele_ET);  //need relative errors
00236         double reco_err = ele_reco_SF_err(ele_eta) / ele_reco_SF(ele_eta);
00237 
00238         double tot_rel_err = sqrt( pow(ID_err,2) + pow(reco_err,2) );
00239         double tot_abs_err = tot_rel_err * ele_recoID_SF(ele_eta, ele_ET);
00240 
00241         return tot_abs_err;
00242 
00243 }
00244 
00245 // For trigger SFs
00246 double ele_trigger_SF(double eta)
00247 {
00248 
00249     double ele_eta = eta;
00250     int etaI=-1;
00251 
00252     const double etabins[18] = {-2.47,-2.37,-2.01,-1.81,-1.37,
00253                                                             -1.15,-0.8,-0.6,-0.1,0,0.1,0.6,0.8,1.15,
00254                                                             1.52,1.81,2.01,2.37};
00255 
00256         const double SFmatrix[18] = {0.9655, 0.9739, 0.9842, 0.9867, 0.9970, 0.9896,
00257                                                                  0.9847, 0.9930, 0.9912, 0.9928, 0.9923, 0.9971,
00258                                                                  0.9915, 0.9957, 0.9982, 0.9782, 0.9786, 0.9790};
00259                                                                    
00260         const double etamax = 2.47;
00261         const double etacrack[2] = {1.37,1.52};
00262 
00263     if ( fabs(ele_eta) > etamax || (fabs(ele_eta) > etacrack[0] && fabs(ele_eta) < etacrack[1]) )  // check forward, crack regions
00264 
00265         return 1.0;       
00266 
00267     else {           
00268         
00269         for (int i=17; i>=0; i--){    // find eta index
00270             if ( ele_eta > etabins[i] ) {
00271                 etaI = i;
00272                 break;
00273             }
00274         }
00275 
00276         return SFmatrix[etaI];
00277 
00278     } //else
00279 
00280     return 0;
00281 
00282 }
00283 
00284 // For trigger SF uncertainties (symmetric)
00285 double ele_trigger_SF_err(double eta)
00286 {
00287 
00288     double ele_eta = eta;
00289     int etaI=-1;
00290 
00291     const double etabins[18] = {-2.47,-2.37,-2.01,-1.81,-1.37,
00292                                                             -1.15,-0.8,-0.6,-0.1,0,0.1,0.6,0.8,1.15,
00293                                                             1.52,1.81,2.01,2.37};
00294 
00295         const double errmatrix[18] = {0.0065, 0.0059, 0.0043, 0.0043, 0.0058, 0.0046,
00296                                                                  0.0052, 0.0040, 0.0042, 0.0041, 0.0040, 0.0041,
00297                                                                  0.0046, 0.0041, 0.0043, 0.0067, 0.0043, 0.0098};
00298                                                                    
00299         const double etamax = 2.47;
00300         const double etacrack[2] = {1.37,1.52};
00301 
00302     if ( fabs(ele_eta) > etamax || (fabs(ele_eta) > etacrack[0] && fabs(ele_eta) < etacrack[1]) )  // check forward, crack regions
00303 
00304         return 1.0;       
00305 
00306     else {           
00307         
00308         for (int i=17; i>=0; i--){    // find eta index
00309             if ( ele_eta > etabins[i] ) {
00310                 etaI = i;
00311                 break;
00312             }
00313         }
00314 
00315         return errmatrix[etaI];
00316 
00317     } //else
00318 
00319     return 0;
00320 
00321 }
00322 
00323 #endif

Generated on Thu Jun 30 11:40:04 2011 for manTreeSFrame by  doxygen 1.4.7