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

00001 #ifndef MMTOOL_h
00002 #define MMTOOL_h
00003 
00004 #include <iostream>
00005 #include <cstdlib>
00006 #include <cmath>
00007 
00008 //Declaration of the function
00009 float get_MM_weight(bool isLoose, bool isTight, float var, bool ele, bool tagged);
00010 
00011 //Get the weight for the QCD
00012 float get_MM_weight(bool isLoose, bool isTight, float var, bool ele, bool tagged) {
00013         int     Nbins     = 0;
00014         float   wmm       = 0.0;
00015         double  eff_real  = -1;
00016         double  eff_fake  = -1;
00017         float*  eff_real_a = NULL;
00018         float*  eff_fake_a = NULL; 
00019         
00021         float   binning_ele[10] = {0.0, 0.3, 0.6, 0.9, 1.2, 1.37, 1.52, 1.8, 2.1, 2.47};
00022         float   binning_mu[9]   = {0.0, 0.3, 0.6, 0.9, 1.2, 1.5,  1.8,  2.1, 2.5};
00023         
00024         float   eff_fake_ele_tagged[9]   = {0.722, 0.660, 0.696, 0.673, 0.529, 0, 0.424, 0.294, 0.274};
00025         float   eff_fake_ele_untagged[9] = {0.515, 0.501, 0.487, 0.538, 0.517, 0, 0.405, 0.246, 0.222};
00026         float   eff_real_ele[9]          = {0.947, 0.945, 0.946, 0.927, 0.913, 0, 0.868, 0.852, 0.770};
00027         
00028         // Muons updated Dec,9th 2010
00029         float   eff_fake_mu_tagged[8]    = {0.291, 0.286, 0.307, 0.319, 0.350, 0.285, 0.279, 0.248};
00030         float   eff_fake_mu_untagged[8]  = {0.348, 0.348, 0.345, 0.372, 0.398, 0.351, 0.305, 0.285};
00031         float   eff_real_mu[8]           = {0.988, 0.990, 0.989, 0.990, 0.993, 0.991, 0.985, 0.991};
00032 
00033         float* binning = binning_mu;
00034 
00035         // setting electron or muon variables and efficiencies
00036 
00037         if(ele){
00038                 Nbins= 9;
00039                 binning = binning_ele;
00040                 eff_real_a = eff_real_ele;
00041                 if(!tagged){
00042                         eff_fake_a = eff_fake_ele_untagged;
00043                 }else{
00044                         eff_fake_a = eff_fake_ele_tagged;
00045                 }
00046         }else{
00047                 Nbins = 8;
00048                 binning = binning_mu;
00049                 eff_real_a = eff_real_mu;
00050                 if(!tagged){
00051                         eff_fake_a = eff_fake_mu_untagged;
00052                 }else{
00053                         eff_fake_a = eff_fake_mu_tagged;
00054                 }
00055         }
00057         var = fabs(var);
00058 
00060         for(int i=0; i<Nbins; ++i) {
00061                 if( (var >= binning[i]) && (var < binning[i+1]) ) {
00062                         eff_real = eff_real_a[i];
00063                         eff_fake = eff_fake_a[i];
00064                         break;
00065                 }
00066         }
00067 
00068 
00070         if( var > binning[Nbins] ) {
00071                         eff_real = eff_real_a[Nbins-1];
00072                         eff_fake = eff_fake_a[Nbins-1];
00073         }
00074         
00076         if(eff_real>1 || eff_real<0 ) {
00077                 std::cout << "WARNING +++ WARNING +++ WARNING +++ real efficiency not correct: " << eff_real << " | var: " << var << std::endl;
00078                 exit(1);
00079         }
00080         if(eff_fake>1 || eff_fake<0 ) {
00081                 std::cout << "WARNING +++ WARNING +++ WARNING +++ fake efficiency not correct: " << eff_fake << " | var: " << var << std::endl;
00082                 exit(1);
00083         }
00084         
00086         
00087 
00088         if (isLoose) wmm = (eff_fake * eff_real )/(eff_real - eff_fake);
00089         if (isTight) wmm = (eff_fake * (eff_real - 1.))/(eff_real - eff_fake);
00090         return wmm;
00091 }
00092 
00093 #endif

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