CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/RecoHI/HiEgammaAlgos/src/HICaloUtil.cc

Go to the documentation of this file.
00001 #include "RecoHI/HiEgammaAlgos/interface/HICaloUtil.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00004 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00007 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00008 #include "DataFormats/Candidate/interface/Candidate.h"
00009 
00010 using namespace edm;
00011 using namespace reco;
00012 
00013 #define PI 3.141592653589793238462643383279502884197169399375105820974945
00014 
00015 
00016 const double HICaloUtil::kEEtaBarrelEndcap = 1.479;
00017 const double HICaloUtil::kER_ECAL          = 136.5;
00018 const double HICaloUtil::kEZ_Endcap        = 328.0;
00019 const double HICaloUtil::kERBARM           = 1.357;
00020 const double HICaloUtil::kEZENDM           = 3.186;
00021 
00022 
00023 //________________________________________________________________________
00024 double HICaloUtil::EcalEta(const Candidate &p)
00025 {  
00026    // Calculate the eta of the particle wrt the center of the detector.
00027 
00028    double rhovert = sqrt(p.vertex().X()*p.vertex().X()+p.vertex().Y()*p.vertex().Y());
00029    double zvert   = p.vertex().Z();
00030    return EcalEta(p.eta(), zvert, rhovert);
00031 }
00032 
00033 
00034 //________________________________________________________________________
00035 double HICaloUtil::EcalEta(double EtaParticle, double Zvertex, double plane_Radius)
00036 {  
00037    // Calculate the eta of the particle wrt center of detector.
00038 
00039    if(EtaParticle != 0.) {
00040       double Theta = 0.0  ;
00041       double ZEcal = (kER_ECAL-plane_Radius)*sinh(EtaParticle)+Zvertex;
00042  
00043       if(ZEcal != 0.0) Theta = atan(kER_ECAL/ZEcal);
00044       if(Theta<0.0) Theta = Theta+PI ;
00045       
00046       double ETA = - log(tan(0.5*Theta));
00047  
00048       if( fabs(ETA) > kEEtaBarrelEndcap )
00049       {
00050          double Zend = kEZ_Endcap ;
00051          if(EtaParticle<0.0 )  Zend = -Zend ;
00052          double Zlen = Zend - Zvertex ;
00053          double RR = Zlen/sinh(EtaParticle);
00054          Theta = atan((RR+plane_Radius)/Zend);
00055          if(Theta<0.0) Theta = Theta+PI ;
00056          ETA = - log(tan(0.5*Theta));
00057       }
00058                  
00059       return ETA;
00060    } 
00061 
00062    return EtaParticle;
00063 }
00064 
00065 
00066 //________________________________________________________________________
00067 double HICaloUtil::EcalPhi(const Candidate &p)
00068 {  
00069    // Calculate the phi of the particle transported to the Ecal.
00070 
00071    int charge     = p.charge();
00072    double phi     = p.phi();
00073    double rhovert =  sqrt(p.vertex().X()*p.vertex().X()+p.vertex().Y()*p.vertex().Y());
00074    if(charge) phi   = EcalPhi(p.pt(), p.eta(), phi, charge, rhovert);
00075    return phi;
00076 }
00077 
00078 
00079 //________________________________________________________________________
00080 double HICaloUtil::EcalPhi(double PtParticle, double EtaParticle, 
00081                               double PhiParticle, int ChargeParticle, double Rstart)
00082 {
00083    // Calculate the phi of the particle transported to the Ecal.
00084 
00085    double Rbend = kERBARM-(Rstart/100.); //assumed rstart in cm
00086    double Bend  = 0.3 * 4. * Rbend/ 2.0 ;
00087  
00088    //PHI correction
00089    double PHI = 0.0 ;
00090    if( fabs(EtaParticle) <=  kEEtaBarrelEndcap) {
00091       if (fabs(Bend/PtParticle)<=1.) {
00092          PHI = PhiParticle - asin(Bend/PtParticle)*ChargeParticle;
00093          if(PHI >  PI) {PHI = PHI - 2*PI;}
00094          if(PHI < -PI) {PHI = PHI + 2*PI;}
00095          return PHI;
00096       } 
00097    } else {
00098       double Rhit = 0.0 ;
00099       Rhit = kEZENDM / sinh(fabs(EtaParticle));
00100       if (fabs(((Rhit-(Rstart/100.))/Rbend)*Bend/PtParticle)<=1.) {
00101          PHI = PhiParticle - asin(((Rhit-(Rstart/100.))/Rbend)*Bend/PtParticle)*ChargeParticle;
00102          if(PHI >  PI) {PHI = PHI - 2*PI;}
00103          if(PHI < -PI) {PHI = PHI + 2*PI;}
00104          return PHI;
00105       } else {
00106          return PhiParticle;
00107       }
00108    }
00109 
00110    return PhiParticle;
00111 }