18{
19 RecEmcFractionMap::const_iterator cit;
22 double w,wsum;
24
25
27 ISvcLocator* svcLocator = Gaudi::svcLocator();
28 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
29 if(sc!=StatusCode::SUCCESS) {
30
31 }
33
34 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
35 etot+=(cit->second.getEnergy()*cit->second.getFraction());
36
37 }
38 wsum=0;
39 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
40 w=(cit->second.getEnergy()*cit->second.getFraction());
41
42 wsum+=w;
44 possum+=pos*w;
45 }
46
47 if(wsum<=0) {
48 cout<<"[[[[[[[[[[[[[[["<<wsum;
49 }
50
51 pos=possum/wsum;
52
53
54
55
61
62 if(module==1) {
63 unsigned int theModule;
64 if(thetaModule>21) {
65 theModule = 43 - thetaModule;
67 posCorr.setZ(-posCorr.z());
68 } else {
69 theModule = thetaModule;
70 }
71
72
73 double IRShift, parTheta[5];
74 if(theModule==21) {
75 IRShift = 0;
76 double par[5] = { 1.698, -1.553, 0.9384, 0.1193, -0.01916 };
77 for(int i=0;i<5;i++) {
78 parTheta[i] = par[i];
79 }
80 } else if(theModule==20) {
81 IRShift = 2.5;
82 double par[5] = { 1.593, -1.582, 0.8881, 0.3298, -0.08856 };
83 for(int i=0;i<5;i++) {
84 parTheta[i] = par[i];
85 }
86 } else {
87 IRShift = 5.;
88 double par[5] = { 1.605, -1.702, 0.8433, 0.3072, -0.1809 };
89 for(int i=0;i<5;i++) {
90 parTheta[i] = par[i];
91 }
92 }
93
98
99
100 double theta01,theta23,length,d;
101 theta01 = (center01-IR).theta();
102 theta23 = (center23-IR).theta();
103 length = (center01-IR).mag();
104 d = length*
tan(theta01-theta23);
105
106
107
108 double xIn,xOut,deltaTheta;
109 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
110 xOut = xIn-(parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])+parTheta[2]*xIn+parTheta[3]);
111 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
112
113
114 double parPhi1[5] = { 0.7185, -2.539, 0.6759, 0.3472, -0.3108 };
115 double parPhi2[5] = { 0.5781, -2.917, 0.5516, -0.5745, 0.3777 };
116 double parPhi[5];
117 for(int i=0;i<5;i++) {
118 parPhi[i] = (parPhi1[i]+parPhi2[i])/2;
119 }
120
121 double yIn,yOut,deltaPhi;
122 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.1537
123 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.1537;
124 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
125 deltaPhi = yOut*CLHEP::pi/180.;
126
127
129 rotateVector.rotateZ(posCorr.phi());
130 posCorr.setZ(posCorr.z()-IRShift);
131 posCorr.rotate(-deltaTheta,rotateVector);
132 posCorr.setZ(posCorr.z()+IRShift);
133
134 posCorr.rotateZ(-0.002994);
135
136
137 if(thetaModule>21) {
138 posCorr.setZ(-posCorr.z());
139 }
140 }
141
143
144
145 if(aShower.
energy()<1e-5)
return;
146
147 double r,theta,phi;
148 double dtheta,dphi,dx,dy,dz;
149
150 r = posCorr.mag();
151 theta = posCorr.theta();
152 phi = posCorr.phi();
153
154
159 }
160 else {
161 dtheta = 0;
162 dphi = 0;
163 }
164
165
168 if(theta>0)
170 else
171 dz = 0;
172
173
176
177
178
179 HepSymMatrix matrix(3);
180 matrix[0][0]=0;
181 matrix[1][1]=dtheta*dtheta;
182 matrix[2][2]=dphi*dphi;
183 matrix[0][1]=0;
184 matrix[0][2]=0;
185 matrix[1][2]=0;
186
187
188 HepMatrix matrix1(3,3),matrix2(3,3);
189 matrix1[0][0]=
sin(theta)*
cos(phi);
190 matrix1[0][1]=r*
cos(theta)*
cos(phi);
191 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
192 matrix1[1][0]=
sin(theta)*
sin(phi);
193 matrix1[1][1]=r*
cos(theta)*
sin(phi);
194 matrix1[1][2]=r*
sin(theta)*
cos(phi);
195 matrix1[2][0]=
cos(theta);
196 matrix1[2][1]=-r*
sin(theta);
197 matrix1[2][2]=0;
198
199
200 for(int i=0;i<3;i++) {
201 for(int j=0;j<3;j++) {
202 matrix2[i][j]=matrix1[j][i];
203 }
204 }
205
206
207 HepMatrix matrix4(3,3);
208 matrix4=matrix1*matrix*matrix2;
209
210
211 HepSymMatrix matrix5(3);
212 for(int i=0;i<3;i++) {
213 for(int j=0;j<=i;j++) {
214 matrix5[i][j]=matrix4[i][j];
215 }
216 }
217
218
220}
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 SigTheta(int n) 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