CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoEcal/EgammaCoreTools/src/Mustache.cc

Go to the documentation of this file.
00001 #include "RecoEcal/EgammaCoreTools/interface/Mustache.h"
00002 #include "TMath.h"
00003 using namespace std;
00004 using namespace reco;
00005 
00006 void Mustache::MustacheID(const reco::SuperCluster& sc, int & nclusters, float & EoutsideMustache)
00007 {
00008   CaloClusterPtrVector clusters;
00009 
00010   for(CaloCluster_iterator iter = sc.clustersBegin(); iter != sc.clustersEnd(); ++iter){
00011     clusters.push_back(*iter);
00012   }
00013 
00014   MustacheID(clusters, nclusters, EoutsideMustache);
00015 }
00016 
00017 void Mustache::MustacheID(CaloClusterPtrVector& clusters, int & nclusters, float & EoutsideMustache) {
00018   std::vector<const CaloCluster*> myClusters;
00019   unsigned myNclusters(clusters.size());
00020   for(unsigned icluster=0;icluster<myNclusters;++icluster) {
00021     myClusters.push_back(&(*clusters[icluster]));
00022   }
00023   MustacheID(myClusters,nclusters,EoutsideMustache);
00024 }
00025 
00026 void Mustache::MustacheID(std::vector<const CaloCluster*>clusters, int & nclusters, float & EoutsideMustache)
00027 {
00028 
00029   nclusters = 0;
00030   EoutsideMustache = 0;
00031   
00032   unsigned int ncl = clusters.size();
00033   if(!ncl) return;
00034 
00035   //loop over all clusters to find the one with highest energy
00036   float emax = 0;
00037   int imax = -1;
00038   for(unsigned int i=0; i<ncl; ++i){
00039     float e = (*clusters[i]).energy();
00040     if(e > emax){
00041       emax = e;
00042       imax = i;
00043     }
00044   }
00045 
00046   if(imax<0) return;
00047   float eta0 = (*clusters[imax]).eta();
00048   float phi0 = (*clusters[imax]).phi();
00049   
00050   //==== Parameters for Mustache ID  =====================
00051   float p00 = -0.107537;
00052   float p01 = 0.590969;
00053   float p02 = -0.076494;
00054   float p10 = -0.0268843;
00055   float p11 = 0.147742;
00056   float p12 = -0.0191235;
00057   
00058   float w00 = -0.00571429;
00059   float w01 = -0.002;
00060   float w10 = 0.0135714;
00061   float w11 = 0.001;
00062 
00063   float deta, dphi;
00064   float upper_cut, lower_cut;
00065   float b_upper, b_lower;
00066   float a_upper, a_lower;
00067   float curv_low, curv_up;
00068   float midpoint;
00069 
00070   for(unsigned int k=0; k<ncl; k++){
00071     deta = 0.0; 
00072     dphi = 0.0; 
00073     upper_cut = 0.0;
00074     lower_cut = 0.0;
00075     b_upper = 0.0;
00076     b_lower = 0.0;
00077     a_upper = 0.0;
00078     a_lower = 0.0;
00079     curv_low = 0.0;
00080     curv_up = 0.0;
00081     midpoint = 0.0;  
00082 
00083     deta = sin(phi0)*((*clusters[k]).eta()-eta0);       
00084     dphi = (*clusters[k]).phi()-phi0;
00085     //if(dphi> 3.1415927) dphi -= 6.2832;
00086     if(dphi> TMath::Pi()) dphi -= 2* TMath::Pi();
00087     if(dphi<-1* TMath::Pi()) dphi +=2* TMath::Pi();
00088     
00089     //2 parabolas (upper and lower) 
00090     //of the form: y = a*x*x + b      
00091     
00092     //b comes from a fit to the width
00093     //and has a slight dependence on Et on the upper edge
00094     b_lower = w00*sin(eta0)*eta0 + w01 / sqrt(log10((*clusters[k]).energy())+1.1);
00095     b_upper = w10*sin(eta0)*eta0 + w11 / sqrt(log10((*clusters[k]).energy())+1.1);
00096     
00097     //here make an adjustment to the width for the offset from 0.
00098     midpoint = b_upper - (b_upper-b_lower)/2.;
00099     b_lower = b_lower - midpoint;
00100     b_upper = b_upper - midpoint;
00101     
00102     //the curvature comes from a parabolic 
00103     //fit for many slices in eta given a 
00104     //slice -0.1 < log10(Et) < 0.1
00105     curv_up = p00*pow(eta0*sin(eta0),2)+p01*eta0*sin(eta0)+p02;
00106     curv_low = p10*pow(eta0*sin(eta0),2)+p11*eta0*sin(eta0)+p12;
00107     
00108     //solving for the curviness given the width of this particular point
00109     a_lower = (1/(4*curv_low))-fabs(b_lower);
00110     a_upper = (1/(4*curv_up))-fabs(b_upper);
00111     
00112     upper_cut =(1./(4.*a_upper))*pow(dphi,2)+b_upper;
00113     lower_cut =(1./(4.*a_lower))*pow(dphi,2)+b_lower;
00114     
00115   
00116     if (!(deta < upper_cut && deta > lower_cut)){
00117       nclusters++;
00118       EoutsideMustache += (*clusters[k]).energy();
00119     }
00120     
00121   }
00122 }