19 {
20 RecEmcFractionMap::const_iterator cit;
24
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
38
39
40
41 double e5x5 = -99999;
43 {
45 for ( cit = aShower.
Begin(); cit != aShower.
End(); cit++ )
46 {
47 w = offset + log( ( cit->second.getEnergy() /
etot ) * cit->second.getFraction() );
49 {
53 }
54 }
55 }
57 {
58 double e3x3 = aShower.
e3x3();
60 for ( cit = fracMap3x3.begin(); cit != fracMap3x3.end(); cit++ )
61 {
62 w = offset + log( ( cit->second.getEnergy() / e3x3 ) * cit->second.getFraction() );
64 {
68 }
69 }
70 }
71 else
72 {
73 e5x5 = aShower.
e5x5();
75 for ( cit = fracMap5x5.begin(); cit != fracMap5x5.end(); cit++ )
76 {
77 w = offset + log( ( cit->second.getEnergy() / e5x5 ) * cit->second.getFraction() );
79 {
81
82
85 Rc = iGeoSvc->
GetCCenter( cit->second.getCellId() );
86 int NX0 = 6;
87 pos =
R + ( Rc -
R ) / ( Rc - R ).mag() * NX0 * 1.86;
88
90 }
91 }
92 }
93 if ( wsum <= 0 )
94 {
95
96 }
97 pos = possum / wsum;
98
99 int NX0 = 6;
100 HepPoint3D posFront = pos - pos / pos.mag() * NX0 * 1.86;
101
102
103
104
109
110
112
113 if ( module == 1 )
114 {
115
116 double IRShift, parTheta[5], parPhi[5];
117
118 for ( int i = 0; i < 5; i++ )
119 {
120
122 else if ( e5x5 <= 1.0 && e5x5 > 0.5 )
125
127 else if ( e5x5 <= 1.0 && e5x5 > 0.5 )
130 }
131
133 center03;
138
139 double theta01, theta23, dtheta;
140
141 theta01 = ( center01 ).theta();
142 theta23 = ( center23 ).theta();
143
144 dtheta = theta01 - theta23;
145 double xIn, xOut, deltaTheta, deltaX;
146 xIn = ( ( ( posCorr ).theta() - theta23 ) - dtheta / 2 ) / dtheta;
147
148 deltaX = parTheta[0] * atan( xIn * parTheta[1] - parTheta[4] ) + parTheta[2] * xIn +
149 parTheta[3];
150 deltaTheta = deltaX * dtheta;
151
152
153
154
155 double phi12 = -9999, phi03 = -9999, deltaphi = -9999;
156
157 phi03 = center03.phi();
158 phi12 = center12.phi();
159
160 double posPhi;
161 posPhi = posCorr.phi();
162
163 if ( phiModule == 0 )
164 {
165 posPhi = posPhi;
166 phi03 = phi03;
167 phi12 = phi12;
168 }
169 else if ( phiModule == 119 )
170 {
171 posPhi = posPhi + 2 * CLHEP::pi;
172 phi03 = phi03 + 2 * CLHEP::pi;
173 phi12 = phi12 + 2 * CLHEP::pi;
174 }
175 else
176 {
177 posPhi = posPhi < 0 ? posPhi + 2 * CLHEP::pi : posPhi;
178 phi03 = phi03 < 0 ? phi03 + 2 * CLHEP::pi : phi03;
179 phi12 = phi12 < 0 ? phi12 + 2 * CLHEP::pi : phi12;
180 }
181
182 deltaphi = phi12 - phi03;
183
184 double yIn, deltaY, deltaPhi;
185 yIn = ( ( posPhi - phi03 ) - deltaphi * 0.5 ) / deltaphi;
186
187 deltaY = parPhi[0] * atan( yIn * parPhi[1] - parPhi[4] ) + parPhi[2] * yIn + parPhi[3];
188 deltaPhi = deltaY * deltaphi;
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
207
208 rotateVector.rotateZ( center23.phi() );
209
210 posCorr.rotate( -deltaTheta, rotateVector );
211 posCorr.rotateZ( -deltaPhi );
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230 }
231 else
232 {
233
234
235 double IRShift = 0, parTheta[5], parPhi[5];
236
237 if ( module == 0 )
238 {
239
240 IRShift = 10;
241
242 for ( int i = 0; i < 5; i++ )
243 {
244
246 else if ( e5x5 <= 1.0 && e5x5 > 0.5 )
249
253 }
254 }
255 else if ( module == 2 )
256 {
257 IRShift = -10;
258 for ( int i = 0; i < 5; i++ )
259 {
260
262 else if ( e5x5 <= 1.0 && e5x5 > 0.5 )
265
269 }
270 }
271
273
274 double theta12 = -9999, theta03 = -9999, theta23 = -9999, theta14 = -9999, delta = -9999;
275 double phi01 = -9999, phi23 = -9999, phi12 = -9999, phi34 = -9999, deltaphi = -9999;
276 double xIn, deltaX, deltaTheta, yIn, deltaY, deltaPhi;
277
278 double posphi = posCorr.phi();
279 if ( phiModule == 0 ) { posphi = posphi; }
280 else if ( ( ( thetaModule == 0 || thetaModule == 1 ) && phiModule == 63 ) ||
281 ( ( thetaModule == 2 || thetaModule == 3 ) && phiModule == 79 ) ||
282 ( ( thetaModule == 4 || thetaModule == 5 ) && phiModule == 95 ) )
283 { posphi = posphi + 2 * CLHEP::pi; }
284 else { posphi = posphi < 0 ? posphi + 2 * CLHEP::pi : posphi; }
285
286 HepPoint3D center, center01, center23, center12, center03, center34, center14;
287
288 if ( ( thetaModule == 1 &&
289 ( ( phiModule + 3 ) % 4 == 0 || ( phiModule + 2 ) % 4 == 0 ) ) ||
290 ( thetaModule == 3 && ( ( phiModule + 4 ) % 5 == 0 || ( phiModule + 3 ) % 5 == 0 ||
291 ( phiModule + 2 ) % 5 == 0 ) ) )
292 {
293
294 center23 =
296 center14 =
298 center = center23;
299 theta23 = ( center23 - IR ).theta();
300 theta14 = ( center14 - IR ).theta();
301 delta = theta14 - theta23;
302 xIn = ( ( ( posCorr - IR ).theta() - theta23 ) - delta * 0.5 ) / delta;
303
304 center12 =
306 center34 =
308 phi12 = center12.phi();
309 phi34 = center34.phi();
310
311 if ( phiModule == 0 )
312 {
313 phi12 = phi12;
314 phi34 = phi34;
315 }
316 else if ( ( ( thetaModule == 0 || thetaModule == 1 ) && phiModule == 63 ) ||
317 ( ( thetaModule == 2 || thetaModule == 3 ) && phiModule == 79 ) ||
318 ( ( thetaModule == 4 || thetaModule == 5 ) && phiModule == 95 ) )
319 {
320 phi12 = phi12 + 2 * CLHEP::pi;
321 phi34 = phi34 + 2 * CLHEP::pi;
322 }
323 else
324 {
325 phi12 = phi12 < 0 ? phi12 + 2 * CLHEP::pi : phi12;
326 phi34 = phi34 < 0 ? phi34 + 2 * CLHEP::pi : phi34;
327 }
328
329 deltaphi = phi34 - phi12;
330 yIn = ( ( posphi - phi12 ) - deltaphi * 0.5 ) / deltaphi;
331 }
332 else
333 {
334
335 center12 =
337 center03 =
339 center = center12;
340
341 theta12 = ( center12 - IR ).theta();
342 theta03 = ( center03 - IR ).theta();
343 delta = theta03 - theta12;
344 xIn = ( ( ( posCorr - IR ).theta() - theta12 ) - delta * 0.5 ) / delta;
345
346 center01 =
348 center23 =
350 phi01 = center01.phi();
351 phi23 = center23.phi();
352
353 if ( phiModule == 0 )
354 {
355 phi01 = phi01;
356 phi23 = phi23;
357 }
358 else if ( ( ( thetaModule == 0 || thetaModule == 1 ) && phiModule == 63 ) ||
359 ( ( thetaModule == 2 || thetaModule == 3 ) && phiModule == 79 ) ||
360 ( ( thetaModule == 4 || thetaModule == 5 ) && phiModule == 95 ) )
361 {
362 phi01 = phi01 + 2 * CLHEP::pi;
363 phi23 = phi23 + 2 * CLHEP::pi;
364 }
365 else
366 {
367 phi01 = phi01 < 0 ? phi01 + 2 * CLHEP::pi : phi01;
368 phi23 = phi23 < 0 ? phi23 + 2 * CLHEP::pi : phi23;
369 }
370
371 deltaphi = phi23 - phi01;
372 yIn = ( ( posphi - phi01 ) - deltaphi * 0.5 ) / deltaphi;
373 }
374
375 deltaX = parTheta[0] * atan( xIn * parTheta[1] - parTheta[4] ) + parTheta[2] * xIn +
376 parTheta[3];
377 deltaTheta = deltaX * delta;
378
379 deltaY = parPhi[0] * atan( yIn * parPhi[1] - parPhi[4] ) + parPhi[2] * yIn + parPhi[3];
380 deltaPhi = deltaY * deltaphi;
381
383 rotateVector.rotateZ( center.phi() );
384 posCorr.setZ( posCorr.z() - IRShift );
385 posCorr.rotate( -deltaTheta, rotateVector );
386 posCorr.setZ( posCorr.z() + IRShift );
387 posCorr.rotateZ( -deltaPhi );
388
389
390
391
392
393
394
395
396
397
398
399 }
400
401
402
404 {
405
406
408
409 }
410
412 {
413
414
415
416
417
418
419
421 }
422
423 if ( aShower.
energy() < 1e-5 )
return;
424
425 double r, theta, phi;
426 double dtheta, dphi, dx, dy, dz;
427
428 r = posCorr.mag();
429 theta = posCorr.theta();
430 phi = posCorr.phi();
431
432
433 if ( aShower.
energy() > 0 )
434 {
437 }
438 else
439 {
440 dtheta = 0;
441 dphi = 0;
442 }
443
444
447 if ( theta > 0 )
448 dz = fabs( iGeoSvc->
GetBarrelR() * dtheta / (
sin( theta ) *
sin( theta ) ) );
449 else dz = 0;
450
451
454
455
456
457 HepSymMatrix matrix( 3 );
458 matrix[0][0] = 0;
459 matrix[1][1] = dtheta * dtheta;
460 matrix[2][2] = dphi * dphi;
461 matrix[0][1] = 0;
462 matrix[0][2] = 0;
463 matrix[1][2] = 0;
464
465
466 HepMatrix matrix1( 3, 3 ), matrix2( 3, 3 );
467 matrix1[0][0] =
sin( theta ) *
cos( phi );
468 matrix1[0][1] = r *
cos( theta ) *
cos( phi );
469 matrix1[0][2] = -r *
sin( theta ) *
sin( phi );
470 matrix1[1][0] =
sin( theta ) *
sin( phi );
471 matrix1[1][1] = r *
cos( theta ) *
sin( phi );
472 matrix1[1][2] = r *
sin( theta ) *
cos( phi );
473 matrix1[2][0] =
cos( theta );
474 matrix1[2][1] = -r *
sin( theta );
475 matrix1[2][2] = 0;
476
477
478 for ( int i = 0; i < 3; i++ )
479 {
480 for ( int j = 0; j < 3; j++ ) { matrix2[i][j] = matrix1[j][i]; }
481 }
482
483
484 HepMatrix matrix4( 3, 3 );
485 matrix4 = matrix1 * matrix * matrix2;
486
487
488 HepSymMatrix matrix5( 3 );
489 for ( int i = 0; i < 3; i++ )
490 {
491 for ( int j = 0; j <= i; j++ ) { matrix5[i][j] = matrix4[i][j]; }
492 }
493
494
496
497 if ( matrix5[0][0] > 0 ) dx = sqrt( matrix5[0][0] );
498 if ( matrix5[1][1] > 0 ) dy = sqrt( matrix5[1][1] );
499 if ( matrix5[2][2] > 0 ) dz = sqrt( matrix5[2][2] );
500}
HepGeom::Point3D< double > HepPoint3D
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
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 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)
double LogPosOffset() const
double WestLogShMaxPhiPara(int n, int m) const
double BarrLogShMaxPhiPara(int n, int m) const
static EmcRecParameter & GetInstance()
double EastLogShMaxPhiPara(int n, int m) const
double EastLogShMaxThetaPara(int n, int m) const
std::string PositionMode2() const
double SigTheta(int n) const
double WestLogShMaxThetaPara(int n, int m) const
double SigPhi(int n) const
double BarrLogShMaxThetaPara(int n, int m) 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
virtual HepPoint3D GetCCenter(const Identifier &id) const =0
RecEmcFractionMap::const_iterator End() const
RecEmcFractionMap getFractionMap5x5() const
RecEmcID getShowerId() const
RecEmcFractionMap::const_iterator Begin() const
RecEmcEnergy getEAll() const
RecEmcFractionMap getFractionMap3x3() const
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)