17{
18 RecEmcShowerMap::iterator iShowerMap;
19 for(iShowerMap=aShowerMap.begin();
20 iShowerMap!=aShowerMap.end();
21 iShowerMap++) {
22
23
24 double eShower = iShowerMap->second.e5x5();
25 double matWindow = 0;
26 if(eShower>0) {
27 matWindow = 0.01277+0.004268/sqrt(eShower);
28 }
29
30 double phi = iShowerMap->second.phi();
31 phi = phi < 0 ? phi+CLHEP::twopi : phi;
32
33 int nphi1 = (int)(phi*88./CLHEP::twopi);
34 int nphi2 = (int)(phi*88./CLHEP::twopi+0.5);
35 nphi2 += 88;
36
37
38 int nphi1max=nphi1;
39 double emax=tofHitMap[nphi1].Energy();
40 if(tofHitMap[nphi1-1].Energy() > emax) {
41 emax = tofHitMap[nphi1-1].Energy();
42 nphi1max = nphi1-1;
43 }
44 if(tofHitMap[nphi1+1].Energy() > emax) {
45 emax = tofHitMap[nphi1+1].Energy();
46 nphi1max = nphi1+1;
47 }
48 nphi1 = nphi1max;
49
50 int nphi2max=nphi2;
51 emax=tofHitMap[nphi2].Energy();
52 if(tofHitMap[nphi2-1].Energy() > emax) {
53 emax = tofHitMap[nphi2-1].Energy();
54 nphi2max = nphi2-1;
55 }
56 if(tofHitMap[nphi2+1].Energy() > emax) {
57 emax = tofHitMap[nphi2+1].Energy();
58 nphi2max = nphi2+1;
59 }
60 nphi2 = nphi2max;
61
62 double etof2x1=0;
63 double etof2x3=0;
64 int nphi[6] = { nphi1-1, nphi1, nphi1+1, nphi2-1, nphi2, nphi2+1 };
65
66 for(int i=0;i<6;i++) {
67
68 if(tofHitMap[nphi[i]].Energy()<=0) continue;
69
71
72
73
74
75
76
77
78
79
80 if(fabs(pos.theta()-iShowerMap->second.theta())<3*matWindow) {
81 etof2x3 += tofHitMap[nphi[i]].Energy();
82 if( i==1 || i==4 ) {
83 etof2x1 += tofHitMap[nphi[i]].Energy();
84 }
85 }
86
87 tofHitMap[nphi[i]].Energy(0);
88 }
89
90 double ecorr = iShowerMap->second.e5x5() + etof2x3/GeV;
91
92 iShowerMap->second.ETof2x3(etof2x3/GeV);
93 iShowerMap->second.ETof2x1(etof2x1/GeV);
95 }
96}
RecEmcEnergy ECorrection(const RecEmcEnergy eIn)