00001
00009
00010 #include "DataFormats/Math/interface/LorentzVector.h"
00011 #include "DataFormats/Math/interface/deltaR.h"
00012 #include "DataFormats/Math/interface/deltaPhi.h"
00013 #include "CLHEP/Vector/LorentzVector.h"
00014 #include <iostream>
00015 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00016 #include "HFRecoEcalCandidateAlgo.h"
00017 #include "HFEGammaSLCorrector.h"
00018
00019 using namespace std;
00020 using namespace reco;
00021
00022 HFRecoEcalCandidateAlgo::HFRecoEcalCandidateAlgo(bool correct,double e9e25Cut,double intercept2DCut,double intercept2DSlope,
00023 const std::vector<double>& e1e9Cut,
00024 const std::vector<double>& eCOREe9Cut,
00025 const std::vector<double>& eSeLCut,
00026 const reco::HFValueStruct hfvv
00027 ) :
00028
00029 m_correct(correct),
00030 m_e9e25Cut(e9e25Cut),
00031 m_intercept2DCut(intercept2DCut),
00032 m_intercept2DSlope(intercept2DSlope),
00033 m_e1e9Cuthi(e1e9Cut[1]),
00034 m_eCOREe9Cuthi(eCOREe9Cut[1]),
00035 m_eSeLCuthi(eSeLCut[1]),
00036 m_e1e9Cutlo(e1e9Cut[0]),
00037 m_eCOREe9Cutlo(eCOREe9Cut[0]),
00038 m_eSeLCutlo(eSeLCut[0]),
00039 m_era(4),
00040 m_hfvv(hfvv)
00041 {
00042
00043 }
00044
00045 RecoEcalCandidate HFRecoEcalCandidateAlgo::correctEPosition(const SuperCluster& original , const HFEMClusterShape& shape,int nvtx) {
00046 double corEta=original.eta();
00047
00048 double logel=log(shape.eLong3x3()/100.0);
00049 double lowC= 0.00911;
00050 double hiC = 0.0193;
00051 double logSlope = 0.0146;
00052 double logIntercept=-0.00988;
00053 double sgn=(original.eta()>0)?(1.0):(-1.0);
00054 if(logel<=1.25)corEta+=(lowC)*sgn;
00055 else if((logel>1.25)&&(logel<=2))corEta+=(logIntercept+logSlope*logel)*sgn;
00056 else if(logel>2)corEta+=hiC*sgn;
00057
00058 double p0= 0.0125;
00059 double p1=-0.0475;
00060 double p2= 0.0732;
00061 double p3=-0.0506;
00062 double de= sgn*(p0+(p1*(shape.CellEta()))+(p2*(shape.CellEta()*shape.CellEta()))+(p3*(shape.CellEta()*shape.CellEta()*shape.CellEta())));
00063 corEta+=de;
00064
00065 double corPhi=original.phi();
00066
00067 p0= 0.0115;
00068 p1=-0.0394;
00069 p2= 0.0486;
00070 p3=-0.0335;
00071 double dp =p0+(p1*(shape.CellPhi()))+(p2*(shape.CellPhi()*shape.CellPhi()))+(p3*(shape.CellPhi()*shape.CellPhi()*shape.CellPhi()));
00072 corPhi+=dp;
00073
00074
00075 double corEnergy= original.energy();
00076
00077
00078 double energyCorrect=0.7397;
00079 corEnergy= corEnergy/energyCorrect;
00080
00081
00082 int ieta=0;
00083 double etabounds[30]={2.846,2.957,3.132,3.307,3.482,3.657,3.833,4.006,4.184,4.357,4.532,4.709,4.882,5.184};
00084 for (int kk=0;kk<12;kk++){
00085 if((fabs(corEta) < etabounds[kk+1])&&(fabs(corEta) > etabounds[kk])){
00086 ieta = (corEta > 0)?(kk+29):(-kk-29);
00087 }
00088 }
00089 corEnergy=(m_hfvv.PUSlope(ieta)*1.0*(nvtx-1)+m_hfvv.PUIntercept(ieta)*1.0)*corEnergy*1.0*m_hfvv.EnCor(ieta);
00090
00091 double corPx=corEnergy*cos(corPhi)/cosh(corEta);
00092 double corPy=corEnergy*sin(corPhi)/cosh(corEta);
00093 double corPz=corEnergy*tanh(corEta);
00094
00095
00096 RecoEcalCandidate corCand(0,
00097 math::XYZTLorentzVector(corPx,corPy,corPz,corEnergy),
00098 math::XYZPoint(0,0,0));
00099
00100 return corCand;
00101 }
00102
00103 void HFRecoEcalCandidateAlgo::produce(const edm::Handle<SuperClusterCollection>& SuperClusters,
00104 const HFEMClusterShapeAssociationCollection& AssocShapes,
00105 RecoEcalCandidateCollection& RecoECand,
00106 int nvtx) {
00107
00108
00109
00110
00111 for (unsigned int i=0; i < SuperClusters->size(); ++i) {
00112 const SuperCluster& supClus=(*SuperClusters)[i];
00113 reco::SuperClusterRef theClusRef=edm::Ref<SuperClusterCollection>(SuperClusters,i);
00114 const HFEMClusterShapeRef clusShapeRef=AssocShapes.find(theClusRef)->val;
00115 const HFEMClusterShape& clusShape=*clusShapeRef;
00116
00117
00118 double px=supClus.energy()*cos(supClus.phi())/cosh(supClus.eta());
00119 double py=supClus.energy()*sin(supClus.phi())/cosh(supClus.eta());
00120 double pz=supClus.energy()*tanh(supClus.eta());
00121 RecoEcalCandidate theCand(0,
00122 math::XYZTLorentzVector(px,py,pz,supClus.energy()),
00123 math::XYZPoint(0,0,0));
00124
00125
00126 if (m_correct)
00127 theCand=correctEPosition(supClus,clusShape,nvtx);
00128
00129 double e9e25=clusShape.eLong3x3()/clusShape.eLong5x5();
00130 double e1e9=clusShape.eLong1x1()/clusShape.eLong3x3();
00131 double eSeL=hf_egamma::eSeLCorrected(clusShape.eShort3x3(),clusShape.eLong3x3(),4);
00132 double var2d=(clusShape.eCOREe9()-(eSeL*m_intercept2DSlope));
00133
00134 bool isAcceptable=true;
00135 isAcceptable=isAcceptable && (e9e25> m_e9e25Cut);
00136 isAcceptable=isAcceptable && (var2d > m_intercept2DCut);
00137 isAcceptable=isAcceptable && ((e1e9< m_e1e9Cuthi)&&(e1e9> m_e1e9Cutlo));
00138 isAcceptable=isAcceptable && ((clusShape.eCOREe9()< m_eCOREe9Cuthi)&&(clusShape.eCOREe9()> m_eCOREe9Cutlo));
00139 isAcceptable=isAcceptable && ((clusShape.eSeL()<m_eSeLCuthi)&&(clusShape.eSeL()> m_eSeLCutlo));
00140
00141
00142 if(isAcceptable){
00143
00144 theCand.setSuperCluster(theClusRef);
00145 RecoECand.push_back(theCand);
00146 }
00147 }
00148 }
00149