20{
21 RecEmcFractionMap::const_iterator cit;
24 double w,w1,w2,wsum=0;
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
39
40 double a0=4;
41 double offset;
42
43 double e5x5 = -99999;
46 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
47 w=offset+log((cit->second.getEnergy()/
etot)*cit->second.getFraction());
48 if(w>0){
49 wsum+=w;
51 possum+=pos*w;
52 }
53 }
55 double e3x3=aShower.
e3x3();
57 for(cit=fracMap3x3.begin();cit!=fracMap3x3.end();cit++) {
58 w=offset+log((cit->second.getEnergy()/e3x3)*cit->second.getFraction());
59 if(w>0){
60 wsum+=w;
62 possum+=pos*w;
63 }
64 }
65 } else {
67 offset=a0-1.594*
exp(-2.543*e5x5);
69
70 num0=0;
72 for(cit=fracMap5x5.begin();cit!=fracMap5x5.end();cit++) {
73 w1=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
74 w2=(cit->second.getEnergy()/e5x5)*cit->second.getFraction();
75
76 num0++;
77
78 if(w1>0){
80 }
81
82 }
83
84
85
86 for(cit=fracMap5x5.begin();cit!=fracMap5x5.end();cit++) {
87 w1=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
88 w2=(cit->second.getEnergy()/e5x5)*cit->second.getFraction();
89
90 num0++;
91
92 if(w1>0){
94
95 wsum+=w1;
97 possum+=pos*w1;
98 } else{
99
100 wsum+=w2;
102 possum+=pos*w2;
103 }
104 }
105 }
106
107
108 }
109 if(wsum<=0) {
110
111 }
112 pos=possum/wsum;
113
114
115
117
119 }
120
121
122
128
129 if(module==1) {
130 unsigned int theModule;
131 if(thetaModule>21) {
132 theModule = 43 - thetaModule;
134 posCorr.setZ(-posCorr.z());
135 } else {
136 theModule = thetaModule;
137 }
138
139 double IRShift=0, parTheta[5],parPhi[5];
140 if(theModule==21) {
141 IRShift = 0;
142 } else if(theModule==20) {
143 IRShift = 2.5;
144 } else {
145 IRShift = 5.;
146 }
147
148
150 for(int i=0;i<5;i++){
151
153
155
156
157
158
159
160
161
162
163
164 }
165
170
171 double theta01,theta23,length,d;
172 theta01 = (center01-IR).theta();
173 theta23 = (center23-IR).theta();
174 length = (center01-IR).mag();
175 d = length*
tan(theta01-theta23);
176
177 double xIn,xOut,deltaTheta;
178 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
179 xOut = xIn-( parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])+ parTheta[2]*xIn + parTheta[3] );
180 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
181
182
183
184
185
186
187 double yIn,yOut,deltaPhi;
188
189
190
191
192 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
193 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
194
195 if(phiModule==0&&posCorr.phi()<0){
196 yIn = posCorr.phi()*180./CLHEP::pi+360.-119*3-1.843;
197 }else if (phiModule==119&&posCorr.phi()>0){
198 yIn = posCorr.phi()*180./CLHEP::pi-1.843;
199 }else {
200 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
201 }
202 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
203 deltaPhi = yOut*CLHEP::pi/180.;
204
206 rotateVector.rotateZ(center01.phi());
207 posCorr.setZ(posCorr.z()-IRShift);
208 posCorr.rotate(-deltaTheta,rotateVector);
209 posCorr.setZ(posCorr.z()+IRShift);
210
211
212 posCorr.rotateZ(-deltaPhi);
213
214 if(thetaModule>21) {
215 posCorr.setZ(-posCorr.z());
216 }
217 }
219
221 }
222
223 if(aShower.
energy()<1e-5)
return;
224
225 double r,theta,phi;
226 double dtheta,dphi,dx,dy,dz;
227
228 r = posCorr.mag();
229 theta = posCorr.theta();
230 phi = posCorr.phi();
231
232
236 }
237 else {
238 dtheta = 0;
239 dphi = 0;
240 }
241
242
245 if(theta>0)
247 else
248 dz = 0;
249
250
253
254
255
256 HepSymMatrix matrix(3);
257 matrix[0][0]=0;
258 matrix[1][1]=dtheta*dtheta;
259 matrix[2][2]=dphi*dphi;
260 matrix[0][1]=0;
261 matrix[0][2]=0;
262 matrix[1][2]=0;
263
264
265 HepMatrix matrix1(3,3),matrix2(3,3);
266 matrix1[0][0]=
sin(theta)*
cos(phi);
267 matrix1[0][1]=r*
cos(theta)*
cos(phi);
268 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
269 matrix1[1][0]=
sin(theta)*
sin(phi);
270 matrix1[1][1]=r*
cos(theta)*
sin(phi);
271 matrix1[1][2]=r*
sin(theta)*
cos(phi);
272 matrix1[2][0]=
cos(theta);
273 matrix1[2][1]=-r*
sin(theta);
274 matrix1[2][2]=0;
275
276
277 for(int i=0;i<3;i++) {
278 for(int j=0;j<3;j++) {
279 matrix2[i][j]=matrix1[j][i];
280 }
281 }
282
283
284 HepMatrix matrix4(3,3);
285 matrix4=matrix1*matrix*matrix2;
286
287
288 HepSymMatrix matrix5(3);
289 for(int i=0;i<3;i++) {
290 for(int j=0;j<=i;j++) {
291 matrix5[i][j]=matrix4[i][j];
292 }
293 }
294
295
297
298 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
299 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
300 if(matrix5[2][2]>0) dz=sqrt(matrix5[2][2]);
301}
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
EvtComplex exp(const EvtComplex &c)
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()
std::string PositionMode2() const
double SigTheta(int n) const
double BarrLoglinThetaPara(int n, int m) const
double BarrLoglinPhiPara(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