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

00001 #ifndef muon_Staco_SF_EPS_h
00002 #define muon_Staco_SF_EPS_h
00003 
00004 #include <iostream>
00005 #include <stdio.h>
00006 #include <math.h>
00007 
00008 
00009 double mu_staco_trigger_SF(double eta, double phi, double pt);
00010 double mu_barrel_SF(double eta, double phi);
00011 double mu_endcap_SF(double pt);
00012 double check_Phi_range(double phi);
00013 
00014 double mu_staco_trigger_SF(double eta, double phi, double pt){
00015 
00016   const double eta_EC = 1.05;
00017   double mu_SF = 0.;
00018   if(fabs(eta) < eta_EC ) mu_SF = mu_barrel_SF(eta,phi);
00019   else mu_SF = mu_endcap_SF(pt);
00020   
00021   return mu_SF;
00022 }
00023 
00024 
00025 // For trigger scale factors
00026 double mu_endcap_SF(double pt){
00027   double mu_pt=pt;
00028   int mu_pt_index=-1;
00029   const double ptbins[8] = {15.,18.,20.,30.,40.,50.,70.,100.};   // lower edges of pT bins
00030   const double pt_SFarray[8] = {1.0058817,1.0276103,1.0207309,1.0291394,1.0371242,1.0411885,1.0198005,1.0501196};
00031   
00032   for (int i=7; i>=0; i--){    // find phi index
00033     if ( mu_pt > ptbins[i] ) {
00034       mu_pt_index = i;
00035       break;
00036     }
00037   }
00038   
00039   if(fabs(pt_SFarray[mu_pt_index]) >2.) std::cout << "EC ,pt= " << mu_pt << " sf = " << pt_SFarray[mu_pt_index] << std::endl;
00040   return  pt_SFarray[mu_pt_index];
00041   
00042 }
00043 // For trigger scale factors
00044 double mu_barrel_SF(double eta, double phi){
00045   
00046   double mu_eta=eta;
00047   double mu_phi=check_Phi_range(phi);
00048   if(mu_phi != phi ) std::cout << "Original Phi is " << phi << " changed to " << mu_phi << std::endl;  
00049 
00050   int etaI=-1, phiI=-1;  
00051 
00052   const double etabins[6] = {-1.05,-0.908,-0.476,0.,0.476,0.908}; // lower edges of eta bins
00053   const double phibins[8] = {-2.945,-2.160,-1.374,-0.589,0.196,0.982,1.767,2.553};// lower edges of phi bins
00054   const double trig_SFmatrix[6][8] = {{1.1502,1.0660,1.4482,1.2095,1.2142,1.2623,1.2654,1.2445},  // rows are eta, columns are phi
00055                                       {1.0048,1.0102,1.1890,1.0415,1.0575,1.0710,1.0401,1.0279},
00056                                       {0.9173,1.0329,1.0243,1.0411,1.0814,1.0160,1.0291,0.9801},
00057                                       {0.9886,1.1381,1.0670,1.0174,1.0696,0.9710,1.0045,0.9845},
00058                                       {0.9829,0.9998,0.9519,0.9569,0.9735,1.0454,1.0030,0.9903},
00059                                       {0.9944,0.6583,1.0112,0.7800,0.8263,1.0898,1.0356,0.8622}};
00060   
00061   for (int i=7; i>=0; i--){    // find phi index
00062     if ( mu_phi > phibins[i] ) {
00063       phiI = i;
00064       break;
00065     }
00066   }
00067   for (int i=5; i>=0; i--){    // find eta index
00068     if ( mu_eta > etabins[i] ) {
00069       etaI = i;
00070       break;
00071     }
00072   }
00073   if(phiI==-1){
00074     phiI=0;
00075     std::cout << "PHI= " << mu_phi << " eta= " << mu_eta << std::endl;
00076   }
00077   
00078 
00079   for(int i=0; i<6 ; ++i){
00080     for(int j=0; j<8 ; ++j){
00081       //      std::cout << "trig_SFmatrix[" << i << "][" << j  << "] =" << trig_SFmatrix[i][j] << std::endl;
00082     }
00083   }
00084 
00085 
00086 
00087   if(fabs(trig_SFmatrix[etaI][phiI])>2.)std::cout << "Barrel, phiI=" << phiI << " etatI= " << etaI << "  ,eta= " << mu_eta << " phi= " << mu_phi << "  sf = " << trig_SFmatrix[etaI][phiI] << std::endl;
00088   
00089   return trig_SFmatrix[etaI][phiI]; 
00090 }
00091 
00092 
00093 
00094 // Helper function to deal with possible phi ambiguity
00095 double check_Phi_range(double phi)
00096 {
00097 
00098   double newphi = phi;
00099   const double pi = acos(-1.);
00100   
00101   if (newphi > pi) {
00102     printf("<muon_SF>: WARNING: Muon phi %4.2f > pi! Using (phi-2*pi) \n", phi);
00103     newphi -= 2*pi;
00104         }
00105   if (newphi < -pi) {
00106     printf("<muon_SF>: WARNING: Muon phi %4.2f < -pi! Using (phi+2*pi) \n", phi);
00107     newphi += 2*pi;
00108   }
00109   
00110   return newphi;
00111 }
00112 
00113 
00114 #endif

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