00001
00002
00003
00004
00005
00006 #include "EmcRec/EmcRecTofMatch.h"
00007 #include "EmcRec/EmcRecParameter.h"
00008
00009 EmcRecTofMatch::EmcRecTofMatch()
00010 {}
00011
00012 EmcRecTofMatch::~EmcRecTofMatch()
00013 {}
00014
00015 void EmcRecTofMatch::Match(RecEmcShowerMap& aShowerMap,
00016 RecEmcTofHitMap& tofHitMap)
00017 {
00018 RecEmcShowerMap::iterator iShowerMap;
00019 for(iShowerMap=aShowerMap.begin();
00020 iShowerMap!=aShowerMap.end();
00021 iShowerMap++) {
00022
00023
00024 double eShower = iShowerMap->second.e5x5();
00025 double matWindow = 0;
00026 if(eShower>0) {
00027 matWindow = 0.01277+0.004268/sqrt(eShower);
00028 }
00029
00030 double phi = iShowerMap->second.phi();
00031 phi = phi < 0 ? phi+CLHEP::twopi : phi;
00032
00033 int nphi1 = (int)(phi*88./CLHEP::twopi);
00034 int nphi2 = (int)(phi*88./CLHEP::twopi+0.5);
00035 nphi2 += 88;
00036
00037
00038 int nphi1max=nphi1;
00039 double emax=tofHitMap[nphi1].Energy();
00040 if(tofHitMap[nphi1-1].Energy() > emax) {
00041 emax = tofHitMap[nphi1-1].Energy();
00042 nphi1max = nphi1-1;
00043 }
00044 if(tofHitMap[nphi1+1].Energy() > emax) {
00045 emax = tofHitMap[nphi1+1].Energy();
00046 nphi1max = nphi1+1;
00047 }
00048 nphi1 = nphi1max;
00049
00050 int nphi2max=nphi2;
00051 emax=tofHitMap[nphi2].Energy();
00052 if(tofHitMap[nphi2-1].Energy() > emax) {
00053 emax = tofHitMap[nphi2-1].Energy();
00054 nphi2max = nphi2-1;
00055 }
00056 if(tofHitMap[nphi2+1].Energy() > emax) {
00057 emax = tofHitMap[nphi2+1].Energy();
00058 nphi2max = nphi2+1;
00059 }
00060 nphi2 = nphi2max;
00061
00062 double etof2x1=0;
00063 double etof2x3=0;
00064 int nphi[6] = { nphi1-1, nphi1, nphi1+1, nphi2-1, nphi2, nphi2+1 };
00065
00066 for(int i=0;i<6;i++) {
00067
00068 if(tofHitMap[nphi[i]].Energy()<=0) continue;
00069
00070 HepPoint3D pos=tofHitMap[nphi[i]].Position();
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 if(fabs(pos.theta()-iShowerMap->second.theta())<3*matWindow) {
00081 etof2x3 += tofHitMap[nphi[i]].Energy();
00082 if( i==1 || i==4 ) {
00083 etof2x1 += tofHitMap[nphi[i]].Energy();
00084 }
00085 }
00086
00087 tofHitMap[nphi[i]].Energy(0);
00088 }
00089
00090 double ecorr = iShowerMap->second.e5x5() + etof2x3/GeV;
00091
00092 iShowerMap->second.ETof2x3(etof2x3/GeV);
00093 iShowerMap->second.ETof2x1(etof2x1/GeV);
00094 iShowerMap->second.setEnergy(ECorrection(ecorr));
00095 }
00096 }
00097
00098 RecEmcEnergy EmcRecTofMatch::ECorrection(const RecEmcEnergy eIn)
00099 {
00100 EmcRecParameter& Para=EmcRecParameter::GetInstance();
00101
00102 RecEmcEnergy eOut=0;
00103 double par[4];
00104 for(int i=0;i<4;i++) {
00105 par[i]=Para.ECorr(i);
00106 }
00107
00108 eOut = eIn/(par[0]+par[1]*eIn+par[2]*eIn*eIn+par[3]*eIn*eIn*eIn);
00109 return eOut;
00110 }