19{
20 RecEmcFractionMap::const_iterator cit;
25 double etot;
26
27
28
30 ISvcLocator* svcLocator = Gaudi::svcLocator();
31 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
32 if(sc!=StatusCode::SUCCESS) {
33
34 }
35
37
38 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
39 etot+=(cit->second.getEnergy()*cit->second.getFraction());
40
41 }
42 wsum=0;
43
45 double ltot=(log(etota/0.0145)+0.5)*1.86;
46 double e55=aShower.
e5x5();
47 double len55=(log(etota/0.0145)+0.5)*1.86;
50
51
52 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
53 w=(cit->second.getEnergy()*cit->second.getFraction());
54
56
57
58 double theDistance=0;
59 if(cit->second.getCellId()==seedID) {
60
61 theDistance=(seedPoint.mag()+ltot);
62 } else {
63 theDistance=(seedPoint.mag()+ltot)/
cos(seedPoint.angle(hitPoint));
64
65 }
66
67
70
71 posMax = (theDistance/pos.mag())*pos;
72
74 }
75
76 if(wsum<=0) {
77 cout<<"[[[[[[[[[[[[[[["<<wsum;
78 }
79 pos=possum/wsum;
80
81
83
84
85
91
92 if(module==1) {
93 unsigned int theModule;
94 if(thetaModule>21) {
95 theModule = 43 - thetaModule;
97 posCorr.setZ(-posCorr.z());
98 } else {
99 theModule = thetaModule;
100 }
101
102 double IRShift, parTheta[5],parPhi[5];
103 if(theModule==21) {
104 IRShift = 0;
105 } else if(theModule==20) {
106 IRShift = 2.5;
107 } else {
108 IRShift = 5.;
109 }
110
112
113 for(int i=0;i<5;i++){
114
118
119
123
124 }
125
130
131 double theta01,theta23,length,d;
132 theta01 = (center01-IR).theta();
133 theta23 = (center23-IR).theta();
134 length = (center01-IR).mag();
135 d = length*
tan(theta01-theta23);
136
137 double xIn,xOut,deltaTheta;
138 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
139 xOut = xIn-( parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])
140 + parTheta[2]*xIn + parTheta[3] );
141 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
142
143
144
145
146 double yIn,yOut,deltaPhi;
147
148 if(phiModule==0&&posCorr.phi()<0){
149
150 yIn = posCorr.phi()*180./CLHEP::pi+360.-119*3-1.843;
151
152 }else if (phiModule==119&&posCorr.phi()>0){
153
154 yIn = posCorr.phi()*180./CLHEP::pi-1.843;
155
156 }else {
157
158 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
159 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
160
161 }
162 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
163
164
165
166 deltaPhi = yOut*CLHEP::pi/180.;
167
169 rotateVector.rotateZ(center01.phi());
170 posCorr.setZ(posCorr.z()-IRShift);
171 posCorr.rotate(-deltaTheta,rotateVector);
172 posCorr.setZ(posCorr.z()+IRShift);
173
174
175 posCorr.rotateZ(-deltaPhi);
176
177 if(thetaModule>21) {
178 posCorr.setZ(-posCorr.z());
179 }
180 }
181 posCorr=((posCorr.mag()-len55)/posCorr.mag())*posCorr;
182
184
185
186 if(aShower.
energy()<1e-5)
return;
187
188 double r,theta,phi;
189 double dtheta,dphi,dx,dy,dz;
190
191 r = posCorr.mag();
192 theta = posCorr.theta();
193 phi = posCorr.phi();
194
195
199 }
200 else {
201 dtheta = 0;
202 dphi = 0;
203 }
204
205
208 if(theta>0)
210 else
211 dz = 0;
212
213
216
217
218
219 HepSymMatrix matrix(3);
220 matrix[0][0]=0;
221 matrix[1][1]=dtheta*dtheta;
222 matrix[2][2]=dphi*dphi;
223 matrix[0][1]=0;
224 matrix[0][2]=0;
225 matrix[1][2]=0;
226
227
228 HepMatrix matrix1(3,3),matrix2(3,3);
229 matrix1[0][0]=
sin(theta)*
cos(phi);
230 matrix1[0][1]=r*
cos(theta)*
cos(phi);
231 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
232 matrix1[1][0]=
sin(theta)*
sin(phi);
233 matrix1[1][1]=r*
cos(theta)*
sin(phi);
234 matrix1[1][2]=r*
sin(theta)*
cos(phi);
235 matrix1[2][0]=
cos(theta);
236 matrix1[2][1]=-r*
sin(theta);
237 matrix1[2][2]=0;
238
239
240 for(int i=0;i<3;i++) {
241 for(int j=0;j<3;j++) {
242 matrix2[i][j]=matrix1[j][i];
243 }
244 }
245
246
247 HepMatrix matrix4(3,3);
248 matrix4=matrix1*matrix*matrix2;
249
250
251 HepSymMatrix matrix5(3);
252 for(int i=0;i<3;i++) {
253 for(int j=0;j<=i;j++) {
254 matrix5[i][j]=matrix4[i][j];
255 }
256 }
257
258
260
261 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
262 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
263 if(matrix5[2][2]>0) dz=sqrt(matrix5[2][2]);
264}
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 BarrShLinPhiPara(int n, int m) const
double SigTheta(int n) const
double BarrShLinThetaPara(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
RecEmcEnergy getEAll() const