18{
19 RecEmcFractionMap::const_iterator cit;
23 double w,wsum=0;
24
25
26
28 ISvcLocator* svcLocator = Gaudi::svcLocator();
29 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
30 if(sc!=StatusCode::SUCCESS) {
31
32 }
33
36 double e55 = aShower.
e5x5();
37 double len55=(log(e55/0.0145)+0.5)*1.86;
38
41 double ltot=(log(
etot/0.0145)+0.5)*1.86;
44
45
46
47 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
48 w=offset+log((cit->second.getEnergy()/
etot)*cit->second.getFraction());
49
51
52
53 double theDistance;
54 if(cit->second.getCellId()==seedID) {
55
56 theDistance=(seedPoint.mag()+ltot);
57
58 } else {
59
60 theDistance=(seedPoint.mag()+ltot)/
cos(seedPoint.angle(hitPoint));
61 }
62 if(w>0){
63 wsum+=w;
65 posMax = (theDistance/pos.mag())*pos;
66 possum+=posMax*w;
67 }
68 }
70 double e3x3=aShower.
e3x3();
71 double l3x3=(log(e3x3/0.0145)+0.5)*1.86;
74
75
76
78 for(cit=fracMap3x3.begin();
79 cit!=fracMap3x3.end();
80 cit++) {
81 w=offset+log((cit->second.getEnergy()/e3x3)*cit->second.getFraction());
83
84
85 double theDistance;
86 if(cit->second.getCellId()==seedID) {
87 theDistance=(seedPoint.mag()+l3x3);
88 } else {
89 theDistance=(seedPoint.mag()+l3x3)/
cos(seedPoint.angle(hitPoint));
90 }
91 if(w>0){
92 wsum+=w;
94 posMax = (theDistance/pos.mag())*pos;
95 possum+=posMax*w;
96 }
97 }
98 } else {
99 double e5x5=aShower.
e5x5();
100 double l5x5=(log(e5x5/0.0145)+0.5)*1.86;
103
104
105
107 for(cit=fracMap5x5.begin();
108 cit!=fracMap5x5.end();
109 cit++) {
110 w=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
111
113
114
115 double theDistance;
116 if(cit->second.getCellId()==seedID) {
117 theDistance=(seedPoint.mag()+l5x5);
118 } else {
119 theDistance=(seedPoint.mag()+l5x5)/
cos(seedPoint.angle(hitPoint));
120 }
121
122 if(w>0){
123 wsum+=w;
125 posMax = (theDistance/pos.mag())*pos;
126 possum+=posMax*w;
127
128 }
129 }
130 }
131
132 if(wsum<=0) {
133 cout<<"[[[[[[[[[[[[[[["<<wsum;
134 }
135 pos=possum/wsum;
136
137
138
139
141
142
143
149
150 if(module==1) {
151 unsigned int theModule;
152 if(thetaModule>21) {
153 theModule = 43 - thetaModule;
155 posCorr.setZ(-posCorr.z());
156 } else {
157 theModule = thetaModule;
158 }
159
160 double IRShift, parTheta[5],parPhi[5];
161 if(theModule==21) {
162 IRShift = 0;
163 } else if(theModule==20) {
164 IRShift = 2.5;
165 } else {
166 IRShift = 5.;
167 }
168
170
171 for(int i=0;i<5;i++){
172
176
180 }
181
186
187 double theta01,theta23,length,d;
188 theta01 = (center01-IR).theta();
189 theta23 = (center23-IR).theta();
190 length = (center01-IR).mag();
191 d = length*
tan(theta01-theta23);
192
193 double xIn,xOut,deltaTheta;
194 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
195 xOut = xIn-( parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])
196 + parTheta[2]*xIn + parTheta[3] );
197 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
198
199
200
201
202 double yIn,yOut,deltaPhi;
203
204 if(phiModule==0&&posCorr.phi()<0){
205
206 yIn = posCorr.phi()*180./CLHEP::pi+360.-119*3-1.843;
207
208 }else if (phiModule==119&&posCorr.phi()>0){
209
210 yIn = posCorr.phi()*180./CLHEP::pi-1.843;
211
212 }else {
213
214 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
215 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
216
217 }
218 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
219
220
221 deltaPhi = yOut*CLHEP::pi/180.;
222
224 rotateVector.rotateZ(center01.phi());
225 posCorr.setZ(posCorr.z()-IRShift);
226 posCorr.rotate(-deltaTheta,rotateVector);
227 posCorr.setZ(posCorr.z()+IRShift);
228
229 posCorr.rotateZ(-deltaPhi);
230
231 if(thetaModule>21) {
232 posCorr.setZ(-posCorr.z());
233 }
234 }
235 posCorr=((posCorr.mag()-len55)/posCorr.mag())*posCorr;
236
238
239
240 if(aShower.
energy()<1e-5)
return;
241
242 double r,theta,phi;
243 double dtheta,dphi,dx,dy,dz;
244
245 r = posCorr.mag();
246 theta = posCorr.theta();
247 phi = posCorr.phi();
248
249
253 }
254 else {
255 dtheta = 0;
256 dphi = 0;
257 }
258
259
262 if(theta>0)
264 else
265 dz = 0;
266
267
270
271
272
273 HepSymMatrix matrix(3);
274 matrix[0][0]=0;
275 matrix[1][1]=dtheta*dtheta;
276 matrix[2][2]=dphi*dphi;
277 matrix[0][1]=0;
278 matrix[0][2]=0;
279 matrix[1][2]=0;
280
281
282 HepMatrix matrix1(3,3),matrix2(3,3);
283 matrix1[0][0]=
sin(theta)*
cos(phi);
284 matrix1[0][1]=r*
cos(theta)*
cos(phi);
285 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
286 matrix1[1][0]=
sin(theta)*
sin(phi);
287 matrix1[1][1]=r*
cos(theta)*
sin(phi);
288 matrix1[1][2]=r*
sin(theta)*
cos(phi);
289 matrix1[2][0]=
cos(theta);
290 matrix1[2][1]=-r*
sin(theta);
291 matrix1[2][2]=0;
292
293
294 for(int i=0;i<3;i++) {
295 for(int j=0;j<3;j++) {
296 matrix2[i][j]=matrix1[j][i];
297 }
298 }
299
300
301 HepMatrix matrix4(3,3);
302 matrix4=matrix1*matrix*matrix2;
303
304
305 HepSymMatrix matrix5(3);
306 for(int i=0;i<3;i++) {
307 for(int j=0;j<=i;j++) {
308 matrix5[i][j]=matrix4[i][j];
309 }
310 }
311
312
314
315 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
316 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
317 if(matrix5[2][2]>0) dz=sqrt(matrix5[2][2]);
318}
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
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)
double LogPosOffset() const
static EmcRecParameter & GetInstance()
std::string PositionMode2() const
double SigTheta(int n) const
double BarrShLogThetaPara(int n, int m) const
double BarrShLogPhiPara(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
RecEmcFractionMap getFractionMap5x5() const
RecEmcID getShowerId() const
RecEmcFractionMap::const_iterator Begin() const
RecEmcEnergy getEAll() const
RecEmcFractionMap getFractionMap3x3() const