18{
19 RecEmcFractionMap::const_iterator cit;
24
25
27 ISvcLocator* svcLocator = Gaudi::svcLocator();
28 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
29 if(sc!=StatusCode::SUCCESS) {
30
31 }
32
34
35 double e5x5 = aShower.
e5x5();
36
38
39 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
40 etot+=(cit->second.getEnergy()*cit->second.getFraction());
41 }
42 wsum=0;
43 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
44 w=(cit->second.getEnergy()*cit->second.getFraction());
48 }
49
50 if(wsum<=0) {
51 cout<<"[[[[[[[[[[[[[[["<<wsum;
52 }
53
54 pos=possum/wsum;
55
56
57
58
60
61
62
63
69
70 if(module==1) {
71 unsigned int theModule;
72 if(thetaModule>21) {
73 theModule = 43 - thetaModule;
75 posCorr.setZ(-posCorr.z());
76 } else {
77 theModule = thetaModule;
78 }
79
80
82 double IRShift, parTheta[5],parPhi[5];
83
84
85 if(theModule==21) {
86 IRShift = 0;
87 } else if(theModule==20) {
88 IRShift = 2.5;
89 } else {
90 IRShift = 5.;
91 }
92
93
95
96
97 for(int i=0;i<5;i++){
98 if(theModule==21) {
99 double par[5] = { 1.698, -1.553, 0.9384, 0.1193, -0.01916 };
100 parTheta[i] = par[i];
101 }else if(theModule==20){
102 double par[5] = { 1.593, -1.582, 0.8881, 0.3298, -0.08856 };
103 parTheta[i] = par[i];
104 }else{
105 double par[5] = { 1.605, -1.702, 0.8433, 0.3072, -0.1809 };
106 parTheta[i] = par[i];
107 }
108 }
109
111
112 for(int i=0;i<5;i++){
113
115 else if(e5x5<=1.0 && e5x5>0.5) parTheta[i] = Para.
BarrLinThetaPara(theModule+22,i);
117
119 else if(e5x5<=1.0 && e5x5>0.5) parPhi[i] = Para.
BarrLinPhiPara(1,i);
121
122 }
123 }
124
125
126
131
132
133 double theta01,theta23,length,d;
134 theta01 = (center01-IR).theta();
135 theta23 = (center23-IR).theta();
136 length = (center01-IR).mag();
137 d = length*
tan(theta01-theta23);
138
139
140
141 double xIn,xOut,deltaTheta;
142 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
143 xOut = xIn-(parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])+parTheta[2]*xIn+parTheta[3]);
144 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
145
146
147 double parPhi1[5] = { 0.7185, -2.539, 0.6759, 0.3472, -0.3108 };
148 double parPhi2[5] = { 0.5781, -2.917, 0.5516, -0.5745, 0.3777 };
149
150
151
152
153
154
155
156 double yIn,yOut,deltaPhi;
157
158
159 if(phiModule==0&&posCorr.phi()<0){
160
161 yIn = posCorr.phi()*180./CLHEP::pi+360.-119*3-1.843;
162
163 }else if (phiModule==119&&posCorr.phi()>0){
164
165 yIn = posCorr.phi()*180./CLHEP::pi-1.843;
166
167 }else {
168
169 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
170 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
171
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);
184 posCorr.rotateZ(-0.002994);
186 posCorr.rotateZ(-deltaPhi);
187 }
188
189 if(thetaModule>21) {
190 posCorr.setZ(-posCorr.z());
191 }
192 } else {
193
195
197
198 double IRShift = 0;
200 double theta12=-9999,theta03=-9999,theta23=-9999,theta14=-9999,delta=-9999;
201 double phi=-9999,phi01=-9999,phi23=-9999,phi12=-9999,phi34=-9999,deltaphi=-9999;
202 double xIn,xOut,deltaTheta,yIn,yOut,deltaPhi;
203 double posphi=posCorr.phi();
204
205 double parTheta[5],parPhi[5];
206
207 HepPoint3D point0 ,point1 ,point2 ,point3 ,point4 ;
213
214 HepPoint3D center,center01, center23, center12,center03,center34,center14;
215 center01 = (point0+point1)/2;
216 center23 = (point2+point3)/2;
217 center12 = (point1+point2)/2;
218 center34 = (point3+point4)/2;
219 center03 = (point0+point3)/2;
220 center14 = (point1+point4)/2;
221
222 phi01 = center01.phi();
223 phi23 = center23.phi();
224 phi12 = center12.phi();
225 phi34 = center34.phi();
226
227
228 if( (thetaModule==1&&((phiModule+3)%4 == 0||(phiModule+2)%4 == 0))
229 ||(thetaModule==3&&((phiModule+4)%5 == 0||(phiModule+3)%5 == 0||(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){
242 posphi = posphi;
243 }else if( ((thetaModule==0||thetaModule==1)&&phiModule==63)
244 ||((thetaModule==2||thetaModule==3)&&phiModule==79)
245 ||((thetaModule==4||thetaModule==5)&&phiModule==95)
246 ){
247
248 posphi = posphi+2*CLHEP::pi;
249
250 }else {
251 posphi = posphi < 0 ? posphi+2*CLHEP::pi : posphi;
252 }
253
254 phi01 = phi01 <0 ? phi01+2*CLHEP::pi : phi01;
255 phi23 = phi23 <0 ? phi23+2*CLHEP::pi : phi23;
256
257 if(module==0){
258
259 IRShift = 10;
260 center = center23;
261 phi = phi23;
262
263 for(int i=0;i<5;i++) {
266 }
267
268 }else if (module==2){
269
270 IRShift = -10;
271 center = center01;
272 phi = phi01;
273
274 for(int i=0;i<5;i++){
277 }
278
279 }
280
281 theta12 = (center12 - IR).theta();
282 theta03 = (center03 - IR).theta();
283 delta = theta03 - theta12;
284 xIn = (((posCorr-IR).theta() - theta12) - delta*0.5)/delta;
285 xOut = parTheta[0]*atan(xIn*parTheta[1]-parTheta[4]) + parTheta[2]*xIn + parTheta[3] ;
286 deltaTheta = xOut*delta;
287
288 deltaphi = fabs(phi23 - phi01);
289 yIn = ((posphi - phi) - deltaphi*0.5)/deltaphi;
290 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4]) + parPhi[2]*yIn + parPhi[3] ;
291 deltaPhi = yOut*deltaphi;
292
294 rotateVector.rotateZ(center.phi());
295 posCorr.setZ(posCorr.z()-IRShift);
296 posCorr.rotate(-deltaTheta,rotateVector);
297 posCorr.setZ(posCorr.z()+IRShift);
298 posCorr.rotateZ(-deltaPhi);
299
300 }
301 }
302
303
305
306
307 if(aShower.
energy()<1e-5)
return;
308
309 double r,theta,phi;
310 double dtheta,dphi,dx,dy,dz;
311
312 r = posCorr.mag();
313 theta = posCorr.theta();
314 phi = posCorr.phi();
315
316
317
321 }
322 else {
323 dtheta = 0;
324 dphi = 0;
325 }
326
327
330 if(theta>0)
332 else
333 dz = 0;
334
335
338
339
340
341 HepSymMatrix matrix(3);
342 matrix[0][0]=0;
343 matrix[1][1]=dtheta*dtheta;
344 matrix[2][2]=dphi*dphi;
345 matrix[0][1]=0;
346 matrix[0][2]=0;
347 matrix[1][2]=0;
348
349
350 HepMatrix matrix1(3,3),matrix2(3,3);
351 matrix1[0][0]=
sin(theta)*
cos(phi);
352 matrix1[0][1]=r*
cos(theta)*
cos(phi);
353 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
354 matrix1[1][0]=
sin(theta)*
sin(phi);
355 matrix1[1][1]=r*
cos(theta)*
sin(phi);
356 matrix1[1][2]=r*
sin(theta)*
cos(phi);
357 matrix1[2][0]=
cos(theta);
358 matrix1[2][1]=-r*
sin(theta);
359 matrix1[2][2]=0;
360
361
362 for(int i=0;i<3;i++) {
363 for(int j=0;j<3;j++) {
364 matrix2[i][j]=matrix1[j][i];
365 }
366 }
367
368
369 HepMatrix matrix4(3,3);
370 matrix4=matrix1*matrix*matrix2;
371
372
373 HepSymMatrix matrix5(3);
374 for(int i=0;i<3;i++) {
375 for(int j=0;j<=i;j++) {
376 matrix5[i][j]=matrix4[i][j];
377 }
378 }
379
380
382}
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