20 RecEmcFractionMap::const_iterator cit;
28 ISvcLocator* svcLocator = Gaudi::svcLocator();
29 StatusCode sc = svcLocator->service(
"EmcRecGeoSvc", iGeoSvc );
30 if ( sc != StatusCode::SUCCESS )
37 double e5x5 = aShower.
e5x5();
41 for ( cit = aShower.
Begin(); cit != aShower.
End(); cit++ )
42 {
etot += ( cit->second.getEnergy() * cit->second.getFraction() ); }
44 for ( cit = aShower.
Begin(); cit != aShower.
End(); cit++ )
46 w = ( cit->second.getEnergy() * cit->second.getFraction() );
52 if ( wsum <= 0 ) { cout <<
"[[[[[[[[[[[[[[[" << wsum; }
72 unsigned int theModule;
73 if ( thetaModule > 21 )
75 theModule = 43 - thetaModule;
77 posCorr.setZ( -posCorr.z() );
79 else { theModule = thetaModule; }
83 double IRShift, parTheta[5], parPhi[5];
85 if ( theModule == 21 ) { IRShift = 0; }
86 else if ( theModule == 20 ) { IRShift = 2.5; }
87 else { IRShift = 5.; }
92 for (
int i = 0; i < 5; i++ )
94 if ( theModule == 21 )
96 double par[5] = { 1.698, -1.553, 0.9384, 0.1193, -0.01916 };
99 else if ( theModule == 20 )
101 double par[5] = { 1.593, -1.582, 0.8881, 0.3298, -0.08856 };
102 parTheta[i] = par[i];
106 double par[5] = { 1.605, -1.702, 0.8433, 0.3072, -0.1809 };
107 parTheta[i] = par[i];
114 for (
int i = 0; i < 5; i++ )
118 else if ( e5x5 <= 1.0 && e5x5 > 0.5 )
120 else if ( e5x5 <= 0.5 ) parTheta[i] = Para.
BarrLinThetaPara( theModule + 44, i );
123 else if ( e5x5 <= 1.0 && e5x5 > 0.5 ) parPhi[i] = Para.
BarrLinPhiPara( 1, i );
134 double theta01, theta23, length, d;
135 theta01 = ( center01 - IR ).theta();
136 theta23 = ( center23 - IR ).theta();
137 length = ( center01 - IR ).mag();
138 d = length *
tan( theta01 - theta23 );
142 double xIn, xOut, deltaTheta;
143 xIn = length *
tan( theta01 - ( posCorr - IR ).theta() ) - d / 2;
144 xOut = xIn - ( parTheta[0] * atan( xIn * parTheta[1] - parTheta[4] ) + parTheta[2] * xIn +
146 deltaTheta = atan( ( xOut + d / 2 ) / length ) - atan( ( xIn + d / 2 ) / length );
149 double parPhi1[5] = { 0.7185, -2.539, 0.6759, 0.3472, -0.3108 };
150 double parPhi2[5] = { 0.5781, -2.917, 0.5516, -0.5745, 0.3777 };
159 double yIn, yOut, deltaPhi;
162 if ( phiModule == 0 && posCorr.phi() < 0 )
163 { yIn = posCorr.phi() * 180. / CLHEP::pi + 360. - 119 * 3 - 1.843; }
164 else if ( phiModule == 119 && posCorr.phi() > 0 )
165 { yIn = posCorr.phi() * 180. / CLHEP::pi - 1.843; }
169 yIn = posCorr.phi() < 0
170 ? posCorr.phi() * 180. / CLHEP::pi + 360. - phiModule * 3. - 1.843
171 : posCorr.phi() * 180. / CLHEP::pi - phiModule * 3. - 1.843;
174 yOut = parPhi[0] * atan( yIn * parPhi[1] - parPhi[4] ) + parPhi[2] * yIn + parPhi[3];
175 deltaPhi = yOut * CLHEP::pi / 180.;
179 rotateVector.rotateZ( posCorr.phi() );
180 posCorr.setZ( posCorr.z() - IRShift );
181 posCorr.rotate( -deltaTheta, rotateVector );
182 posCorr.setZ( posCorr.z() + IRShift );
183 if ( Para.
MethodMode() == 0 ) { posCorr.rotateZ( -0.002994 ); }
184 else if ( Para.
MethodMode() == 1 ) { posCorr.rotateZ( -deltaPhi ); }
186 if ( thetaModule > 21 ) { posCorr.setZ( -posCorr.z() ); }
198 double theta12 = -9999, theta03 = -9999, theta23 = -9999, theta14 = -9999, delta = -9999;
199 double phi = -9999, phi01 = -9999, phi23 = -9999, phi12 = -9999, phi34 = -9999,
201 double xIn, xOut, deltaTheta, yIn, yOut, deltaPhi;
202 double posphi = posCorr.phi();
204 double parTheta[5], parPhi[5];
206 HepPoint3D point0, point1, point2, point3, point4;
213 HepPoint3D center, center01, center23, center12, center03, center34, center14;
214 center01 = ( point0 + point1 ) / 2;
215 center23 = ( point2 + point3 ) / 2;
216 center12 = ( point1 + point2 ) / 2;
217 center34 = ( point3 + point4 ) / 2;
218 center03 = ( point0 + point3 ) / 2;
219 center14 = ( point1 + point4 ) / 2;
221 phi01 = center01.phi();
222 phi23 = center23.phi();
223 phi12 = center12.phi();
224 phi34 = center34.phi();
226 if ( ( thetaModule == 1 &&
227 ( ( phiModule + 3 ) % 4 == 0 || ( phiModule + 2 ) % 4 == 0 ) ) ||
228 ( thetaModule == 3 && ( ( phiModule + 4 ) % 5 == 0 || ( phiModule + 3 ) % 5 == 0 ||
229 ( phiModule + 2 ) % 5 == 0 ) ) )
241 if ( phiModule == 0 ) { posphi = posphi; }
242 else if ( ( ( thetaModule == 0 || thetaModule == 1 ) && phiModule == 63 ) ||
243 ( ( thetaModule == 2 || thetaModule == 3 ) && phiModule == 79 ) ||
244 ( ( thetaModule == 4 || thetaModule == 5 ) && phiModule == 95 ) )
245 { posphi = posphi + 2 * CLHEP::pi; }
246 else { posphi = posphi < 0 ? posphi + 2 * CLHEP::pi : posphi; }
248 phi01 = phi01 < 0 ? phi01 + 2 * CLHEP::pi : phi01;
249 phi23 = phi23 < 0 ? phi23 + 2 * CLHEP::pi : phi23;
258 for (
int i = 0; i < 5; i++ )
264 else if ( module == 2 )
271 for (
int i = 0; i < 5; i++ )
278 theta12 = ( center12 - IR ).theta();
279 theta03 = ( center03 - IR ).theta();
280 delta = theta03 - theta12;
281 xIn = ( ( ( posCorr - IR ).theta() - theta12 ) - delta * 0.5 ) / delta;
282 xOut = parTheta[0] * atan( xIn * parTheta[1] - parTheta[4] ) + parTheta[2] * xIn +
284 deltaTheta = xOut * delta;
286 deltaphi = fabs( phi23 - phi01 );
287 yIn = ( ( posphi - phi ) - deltaphi * 0.5 ) / deltaphi;
288 yOut = parPhi[0] * atan( yIn * parPhi[1] - parPhi[4] ) + parPhi[2] * yIn + parPhi[3];
289 deltaPhi = yOut * deltaphi;
292 rotateVector.rotateZ( center.phi() );
293 posCorr.setZ( posCorr.z() - IRShift );
294 posCorr.rotate( -deltaTheta, rotateVector );
295 posCorr.setZ( posCorr.z() + IRShift );
296 posCorr.rotateZ( -deltaPhi );
304 if ( aShower.
energy() < 1e-5 )
return;
306 double r, theta, phi;
307 double dtheta, dphi, dx, dy, dz;
310 theta = posCorr.theta();
315 if ( aShower.
energy() > 0 )
330 dz = fabs( iGeoSvc->
GetBarrelR() * dtheta / (
sin( theta ) *
sin( theta ) ) );
339 HepSymMatrix matrix( 3 );
341 matrix[1][1] = dtheta * dtheta;
342 matrix[2][2] = dphi * dphi;
348 HepMatrix matrix1( 3, 3 ), matrix2( 3, 3 );
349 matrix1[0][0] =
sin( theta ) *
cos( phi );
350 matrix1[0][1] = r *
cos( theta ) *
cos( phi );
351 matrix1[0][2] = -r *
sin( theta ) *
sin( phi );
352 matrix1[1][0] =
sin( theta ) *
sin( phi );
353 matrix1[1][1] = r *
cos( theta ) *
sin( phi );
354 matrix1[1][2] = r *
sin( theta ) *
cos( phi );
355 matrix1[2][0] =
cos( theta );
356 matrix1[2][1] = -r *
sin( theta );
360 for (
int i = 0; i < 3; i++ )
362 for (
int j = 0; j < 3; j++ ) { matrix2[i][j] = matrix1[j][i]; }
366 HepMatrix matrix4( 3, 3 );
367 matrix4 = matrix1 * matrix * matrix2;
370 HepSymMatrix matrix5( 3 );
371 for (
int i = 0; i < 3; i++ )
373 for (
int j = 0; j <= i; j++ ) { matrix5[i][j] = matrix4[i][j]; }