19{
20 RecEmcFractionMap::const_iterator cit;
24
25
26
28 ISvcLocator* svcLocator = Gaudi::svcLocator();
29 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
30 if(sc!=StatusCode::SUCCESS) {
31
32 }
33
35
37
38
39
40 double e5x5 = -99999;
43 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
44 w=offset+log((cit->second.getEnergy()/etot)*cit->second.getFraction());
49 }
50 }
52 double e3x3=aShower.
e3x3();
54 for(cit=fracMap3x3.begin();cit!=fracMap3x3.end();cit++) {
55 w=offset+log((cit->second.getEnergy()/e3x3)*cit->second.getFraction());
60 }
61 }
62 } else {
65 for(cit=fracMap5x5.begin();cit!=fracMap5x5.end();cit++) {
66 w=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
69
70
73 Rc=iGeoSvc->
GetCCenter(cit->second.getCellId());
74 int NX0=6;
75 pos =
R + (Rc-
R)/(Rc-R).mag()*NX0*1.86;
76
78 }
79 }
80 }
81 if(wsum<=0) {
82
83 }
84 pos=possum/wsum;
85
86
87 int NX0=6;
88 HepPoint3D posFront=pos-pos/pos.mag()*NX0*1.86;
89
90
91
92
93
98
99
101
102 if(module==1) {
103
104
105 double IRShift, parTheta[5],parPhi[5];
106
107
108 for(int i=0;i<5;i++){
109
113
117
118
119 }
120
121
122 HepPoint3D center01, center23, center12,center03;
127
128 double theta01,theta23,dtheta;
129
130 theta01 = (center01).theta();
131 theta23 = (center23).theta();
132
133 dtheta = theta01-theta23;
134 double xIn,xOut,deltaTheta,deltaX;
135 xIn = (((posCorr).theta()-theta23)-dtheta/2)/dtheta;
136
137 deltaX = parTheta[0]*atan(xIn*parTheta[1]-parTheta[4]) + parTheta[2]*xIn + parTheta[3] ;
138 deltaTheta = deltaX*dtheta;
139
140
141
142
143 double phi12=-9999,phi03=-9999,deltaphi=-9999;
144
145 phi03 = center03.phi();
146 phi12 = center12.phi();
147
148
149 double posPhi;
150 posPhi=posCorr.phi();
151
152
153 if( phiModule==0){
154 posPhi = posPhi;
155 phi03 = phi03;
156 phi12 = phi12;
157
158 }else if( phiModule==119){
159 posPhi = posPhi+2*CLHEP::pi;
160 phi03 = phi03+2*CLHEP::pi;
161 phi12 = phi12+2*CLHEP::pi;
162
163 }else {
164 posPhi = posPhi <0 ? posPhi+2*CLHEP::pi : posPhi;
165 phi03 = phi03 <0 ? phi03+2*CLHEP::pi : phi03;
166 phi12 = phi12 <0 ? phi12+2*CLHEP::pi : phi12;
167 }
168
169 deltaphi = phi12 - phi03;
170
171
172 double yIn,deltaY,deltaPhi;
173 yIn = ((posPhi - phi03) - deltaphi*0.5)/deltaphi;
174
175 deltaY = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
176 deltaPhi = deltaY*deltaphi;
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
195
196 rotateVector.rotateZ(center23.phi());
197
198 posCorr.rotate(-deltaTheta,rotateVector);
199 posCorr.rotateZ(-deltaPhi);
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219 } else {
220
221
222 double IRShift=0, parTheta[5],parPhi[5];
223
224 if(module==0){
225
226 IRShift = 10;
227
228 for(int i=0;i<5;i++) {
229
230
234
238 }
239
240 }else if (module==2){
241 IRShift = -10;
242 for(int i=0;i<5;i++){
243
247
251
252 }
253
254 }
255
257
258 double theta12=-9999,theta03=-9999,theta23=-9999,theta14=-9999,
delta=-9999;
259 double phi01=-9999,phi23=-9999,phi12=-9999,phi34=-9999,deltaphi=-9999;
260 double xIn,deltaX,deltaTheta,yIn,deltaY,deltaPhi;
261
262 double posphi=posCorr.phi();
263 if(phiModule==0){
264 posphi = posphi;
265 }else if( ((thetaModule==0||thetaModule==1)&&phiModule==63)
266 ||((thetaModule==2||thetaModule==3)&&phiModule==79)
267 ||((thetaModule==4||thetaModule==5)&&phiModule==95)
268 ){
269 posphi = posphi+2*CLHEP::pi;
270 }else {
271 posphi = posphi < 0 ? posphi+2*CLHEP::pi : posphi;
272 }
273
274 HepPoint3D center,center01, center23, center12,center03,center34,center14;
275
276
277 if( (thetaModule==1&&((phiModule+3)%4 == 0||(phiModule+2)%4 == 0))
278 ||(thetaModule==3&&((phiModule+4)%5 == 0||(phiModule+3)%5 == 0||(phiModule+2)%5 == 0)))
279 {
280
283 center=center23;
284 theta23 = (center23 - IR).theta();
285 theta14 = (center14 - IR).theta();
286 delta = theta14 - theta23;
287 xIn = (((posCorr-IR).theta() - theta23) -
delta*0.5)/
delta;
288
289
292 phi12 = center12.phi();
293 phi34 = center34.phi();
294
295 if(phiModule==0){
296 phi12 = phi12;
297 phi34 = phi34;
298 }else if( ((thetaModule==0||thetaModule==1)&&phiModule==63)
299 ||((thetaModule==2||thetaModule==3)&&phiModule==79)
300 ||((thetaModule==4||thetaModule==5)&&phiModule==95)
301 ){
302 phi12 = phi12+2*CLHEP::pi;
303 phi34 = phi34+2*CLHEP::pi;
304 }else {
305 phi12 = phi12 <0 ? phi12+2*CLHEP::pi : phi12;
306 phi34 = phi34 <0 ? phi34+2*CLHEP::pi : phi34;
307 }
308
309 deltaphi = phi34 - phi12;
310 yIn = ((posphi - phi12) - deltaphi*0.5)/deltaphi;
311
312 } else {
313
316 center=center12;
317
318 theta12 = (center12 - IR).theta();
319 theta03 = (center03 - IR).theta();
320 delta = theta03 - theta12;
321 xIn = (((posCorr-IR).theta() - theta12) -
delta*0.5)/
delta;
322
323
326 phi01 = center01.phi();
327 phi23 = center23.phi();
328
329
330 if(phiModule==0){
331 phi01 = phi01;
332 phi23 = phi23;
333 }else if( ((thetaModule==0||thetaModule==1)&&phiModule==63)
334 ||((thetaModule==2||thetaModule==3)&&phiModule==79)
335 ||((thetaModule==4||thetaModule==5)&&phiModule==95)
336 ){
337 phi01 = phi01+2*CLHEP::pi;
338 phi23 = phi23+2*CLHEP::pi;
339 }else {
340 phi01 = phi01 <0 ? phi01+2*CLHEP::pi : phi01;
341 phi23 = phi23 <0 ? phi23+2*CLHEP::pi : phi23;
342 }
343
344 deltaphi = phi23 - phi01;
345 yIn = ((posphi - phi01) - deltaphi*0.5)/deltaphi;
346
347 }
348
349 deltaX = parTheta[0]*atan(xIn*parTheta[1]-parTheta[4]) + parTheta[2]*xIn + parTheta[3] ;
350 deltaTheta = deltaX*
delta;
351
352 deltaY = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4]) + parPhi[2]*yIn + parPhi[3] ;
353 deltaPhi = deltaY*deltaphi;
354
356 rotateVector.rotateZ(center.phi());
357 posCorr.setZ(posCorr.z()-IRShift);
358 posCorr.rotate(-deltaTheta,rotateVector);
359 posCorr.setZ(posCorr.z()+IRShift);
360 posCorr.rotateZ(-deltaPhi);
361
362
363
364
365
366
367
368
369
370
371
372
373 }
374
375
376
377
379
380
382
383
384 }
385
387
388
389
390
391
392
393
395 }
396
397 if(aShower.
energy()<1e-5)
return;
398
399 double r,theta,phi;
400 double dtheta,dphi,dx,dy,dz;
401
402 r = posCorr.mag();
403 theta = posCorr.theta();
404 phi = posCorr.phi();
405
406
410 }
411 else {
412 dtheta = 0;
413 dphi = 0;
414 }
415
416
419 if(theta>0)
421 else
422 dz = 0;
423
424
427
428
429
430 HepSymMatrix matrix(3);
431 matrix[0][0]=0;
432 matrix[1][1]=dtheta*dtheta;
433 matrix[2][2]=dphi*dphi;
434 matrix[0][1]=0;
435 matrix[0][2]=0;
436 matrix[1][2]=0;
437
438
439 HepMatrix matrix1(3,3),matrix2(3,3);
440 matrix1[0][0]=
sin(theta)*
cos(phi);
441 matrix1[0][1]=r*
cos(theta)*
cos(phi);
442 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
443 matrix1[1][0]=
sin(theta)*
sin(phi);
444 matrix1[1][1]=r*
cos(theta)*
sin(phi);
445 matrix1[1][2]=r*
sin(theta)*
cos(phi);
446 matrix1[2][0]=
cos(theta);
447 matrix1[2][1]=-r*
sin(theta);
448 matrix1[2][2]=0;
449
450
451 for(int i=0;i<3;i++) {
452 for(int j=0;j<3;j++) {
453 matrix2[i][j]=matrix1[j][i];
454 }
455 }
456
457
458 HepMatrix matrix4(3,3);
459 matrix4=matrix1*matrix*matrix2;
460
461
462 HepSymMatrix matrix5(3);
463 for(int i=0;i<3;i++) {
464 for(int j=0;j<=i;j++) {
465 matrix5[i][j]=matrix4[i][j];
466 }
467 }
468
469
471
472 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
473 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
474 if(matrix5[2][2]>0) dz=sqrt(matrix5[2][2]);
475}
double sin(const BesAngle a)
double cos(const BesAngle a)
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
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)