19 {
20 RecEmcFractionMap::const_iterator cit;
25
26
27 IEmcRecGeoSvc* iGeoSvc;
28 ISvcLocator* svcLocator = Gaudi::svcLocator();
29 StatusCode sc = svcLocator->service( "EmcRecGeoSvc", iGeoSvc );
30 if ( sc != StatusCode::SUCCESS )
31 {
32
33 }
34
36
37 double e5x5 = aShower.
e5x5();
38
40
41 for ( cit = aShower.
Begin(); cit != aShower.
End(); cit++ )
42 {
etot += ( cit->second.getEnergy() * cit->second.getFraction() ); }
43 wsum = 0;
44 for ( cit = aShower.
Begin(); cit != aShower.
End(); cit++ )
45 {
46 w = ( cit->second.getEnergy() * cit->second.getFraction() );
50 }
51
52 if ( wsum <= 0 ) { cout << "[[[[[[[[[[[[[[[" << wsum; }
53
54 pos = possum / wsum;
55
56
57
58
60
61
62
65 ;
69
70 if ( module == 1 )
71 {
72 unsigned int theModule;
73 if ( thetaModule > 21 )
74 {
75 theModule = 43 - thetaModule;
77 posCorr.setZ( -posCorr.z() );
78 }
79 else { theModule = thetaModule; }
80
81
83 double IRShift, parTheta[5], parPhi[5];
84
85 if ( theModule == 21 ) { IRShift = 0; }
86 else if ( theModule == 20 ) { IRShift = 2.5; }
87 else { IRShift = 5.; }
88
90 {
91
92 for ( int i = 0; i < 5; i++ )
93 {
94 if ( theModule == 21 )
95 {
96 double par[5] = { 1.698, -1.553, 0.9384, 0.1193, -0.01916 };
97 parTheta[i] = par[i];
98 }
99 else if ( theModule == 20 )
100 {
101 double par[5] = { 1.593, -1.582, 0.8881, 0.3298, -0.08856 };
102 parTheta[i] = par[i];
103 }
104 else
105 {
106 double par[5] = { 1.605, -1.702, 0.8433, 0.3072, -0.1809 };
107 parTheta[i] = par[i];
108 }
109 }
110 }
112 {
113
114 for ( int i = 0; i < 5; i++ )
115 {
116
118 else if ( e5x5 <= 1.0 && e5x5 > 0.5 )
120 else if ( e5x5 <= 0.5 ) parTheta[i] = Para.
BarrLinThetaPara( theModule + 44, i );
121
123 else if ( e5x5 <= 1.0 && e5x5 > 0.5 ) parPhi[i] = Para.
BarrLinPhiPara( 1, i );
125 }
126 }
127
132
133
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 );
139
140
141
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 +
145 parTheta[3] );
146 deltaTheta = atan( ( xOut + d / 2 ) / length ) - atan( ( xIn + d / 2 ) / length );
147
148
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 };
151
152
153
154
155
156
157
158
159 double yIn, yOut, deltaPhi;
160
161
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; }
166 else
167 {
168
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;
172 }
173
174 yOut = parPhi[0] * atan( yIn * parPhi[1] - parPhi[4] ) + parPhi[2] * yIn + parPhi[3];
175 deltaPhi = yOut * CLHEP::pi / 180.;
176
177
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 ); }
185
186 if ( thetaModule > 21 ) { posCorr.setZ( -posCorr.z() ); }
187 }
188 else
189 {
190
192
194 {
195
196 double IRShift = 0;
198 double theta12 = -9999, theta03 = -9999, theta23 = -9999, theta14 = -9999, delta = -9999;
199 double phi = -9999, phi01 = -9999, phi23 = -9999, phi12 = -9999, phi34 = -9999,
200 deltaphi = -9999;
201 double xIn, xOut, deltaTheta, yIn, yOut, deltaPhi;
202 double posphi = posCorr.phi();
203
204 double parTheta[5], parPhi[5];
205
206 HepPoint3D point0, point1, point2, point3, point4;
212
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;
220
221 phi01 = center01.phi();
222 phi23 = center23.phi();
223 phi12 = center12.phi();
224 phi34 = center34.phi();
225
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 ) ) )
230 {
231 center12 = center23;
232 center03 = center14;
233
234 center01 = center12;
235 center23 = center34;
236
237 phi01 = phi12;
238 phi23 = phi34;
239 }
240
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; }
247
248 phi01 = phi01 < 0 ? phi01 + 2 * CLHEP::pi : phi01;
249 phi23 = phi23 < 0 ? phi23 + 2 * CLHEP::pi : phi23;
250
251 if ( module == 0 )
252 {
253
254 IRShift = 10;
255 center = center23;
256 phi = phi23;
257
258 for ( int i = 0; i < 5; i++ )
259 {
262 }
263 }
264 else if ( module == 2 )
265 {
266
267 IRShift = -10;
268 center = center01;
269 phi = phi01;
270
271 for ( int i = 0; i < 5; i++ )
272 {
275 }
276 }
277
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 +
283 parTheta[3];
284 deltaTheta = xOut * delta;
285
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;
290
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 );
297 }
298 }
299
300
302
303
304 if ( aShower.
energy() < 1e-5 )
return;
305
306 double r, theta, phi;
307 double dtheta, dphi, dx, dy, dz;
308
309 r = posCorr.mag();
310 theta = posCorr.theta();
311 phi = posCorr.phi();
312
313
314
315 if ( aShower.
energy() > 0 )
316 {
319 }
320 else
321 {
322 dtheta = 0;
323 dphi = 0;
324 }
325
326
329 if ( theta > 0 )
330 dz = fabs( iGeoSvc->
GetBarrelR() * dtheta / (
sin( theta ) *
sin( theta ) ) );
331 else dz = 0;
332
333
336
337
338
339 HepSymMatrix matrix( 3 );
340 matrix[0][0] = 0;
341 matrix[1][1] = dtheta * dtheta;
342 matrix[2][2] = dphi * dphi;
343 matrix[0][1] = 0;
344 matrix[0][2] = 0;
345 matrix[1][2] = 0;
346
347
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 );
357 matrix1[2][2] = 0;
358
359
360 for ( int i = 0; i < 3; i++ )
361 {
362 for ( int j = 0; j < 3; j++ ) { matrix2[i][j] = matrix1[j][i]; }
363 }
364
365
366 HepMatrix matrix4( 3, 3 );
367 matrix4 = matrix1 * matrix * matrix2;
368
369
370 HepSymMatrix matrix5( 3 );
371 for ( int i = 0; i < 3; i++ )
372 {
373 for ( int j = 0; j <= i; j++ ) { matrix5[i][j] = matrix4[i][j]; }
374 }
375
376
378}
HepGeom::Point3D< double > HepPoint3D
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
void setDtheta(double dt)
void setPosition(const HepPoint3D &pos)
void setErrorMatrix(const HepSymMatrix &error)
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
static unsigned int theta_module(const Identifier &id)
static unsigned int phi_module(const Identifier &id)
static EmcRecParameter & GetInstance()
double EastLinThetaPara(int n, int m) const
double EastLinPhiPara(int n, int m) const
double MethodMode() const
double SigTheta(int n) const
double WestLinThetaPara(int n, int m) const
double BarrLinPhiPara(int n, int m) const
double BarrLinThetaPara(int n, int m) const
double WestLinPhiPara(int n, int m) const
double SigPhi(int n) const
virtual double GetBarrelR() const =0
virtual HepPoint3D GetCFrontCenter(const Identifier &id) const =0
virtual HepPoint3D GetCrystalPoint(const Identifier &id, const int i) const =0
RecEmcFractionMap::const_iterator End() const
RecEmcID getShowerId() const
RecEmcFractionMap::const_iterator Begin() const