17{
18 RecEmcFractionMap::const_iterator cit;
21 double w,wsum=0;
22
23
24
26 ISvcLocator* svcLocator = Gaudi::svcLocator();
27 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
28 if(sc!=StatusCode::SUCCESS) {
29
30 }
31
34
35
36
39 for(cit=aShower.
Begin();cit!=aShower.
End();cit++){
40 w=offset+log((cit->second.getEnergy()/
etot)*cit->second.getFraction());
41 if(w>0){
42 wsum+=w;
44 possum+=pos*w;
45 }
46 }
48 double e3x3=aShower.
e3x3();
50 for(cit=fracMap3x3.begin();
51 cit!=fracMap3x3.end();
52 cit++) {
53 w=offset+log((cit->second.getEnergy()/e3x3)*cit->second.getFraction());
54 if(w>0){
55 wsum+=w;
57 possum+=pos*w;
58 }
59 }
60 } else {
61 double e5x5=aShower.
e5x5();
63 for(cit=fracMap5x5.begin();
64 cit!=fracMap5x5.end();
65 cit++) {
66 w=offset+log((cit->second.getEnergy()/e5x5)*cit->second.getFraction());
67 if(w>0){
68 wsum+=w;
70 possum+=pos*w;
71 }
72 }
73 }
74 if(wsum<=0) {
75
76 }
77 pos=possum/wsum;
78
79
80
81
87
88 if(module==1) {
89 unsigned int theModule;
90 if(thetaModule>21) {
91 theModule = 43 - thetaModule;
93 posCorr.setZ(-posCorr.z());
94 } else {
95 theModule = thetaModule;
96 }
97
98 double IRShift, parTheta[5];
99 if(theModule==21) {
100 IRShift = 0;
101 double par[5] = { 51.97, -0.1209, 6.175, -0.1431, -0.005497 };
102 for(int i=0;i<5;i++) {
103 parTheta[i] = par[i];
104 }
105 } else if(theModule==20) {
106 IRShift = 2.5;
107 double par[5] = { 56.31, -0.1135, 6.312, -1.216, -0.02978 };
108 for(int i=0;i<5;i++) {
109 parTheta[i] = par[i];
110 }
111 } else {
112 IRShift = 5.;
113 double par[5] = { 10.65, -0.2257, 2.216, -0.1562, -0.05552 };
114 for(int i=0;i<5;i++) {
115 parTheta[i] = par[i];
116 }
117 }
118
123
124 double theta01,theta23,length,d;
125 theta01 = (center01-IR).theta();
126 theta23 = (center23-IR).theta();
127 length = (center01-IR).mag();
128 d = length*
tan(theta01-theta23);
129
130 double xIn,xOut,deltaTheta;
131 xIn = length*
tan(theta01-(posCorr-IR).theta())-d/2;
132 xOut = xIn-( parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])
133 + parTheta[2]*xIn + parTheta[3] );
134 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
135
136
137
138
139
140 double parPhi[5] = { 51.1, -0.1499, 7.62, 0.1301, 0.005581 };
141 double yIn,yOut,deltaPhi;
142 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.1537
143 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.1537;
144 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
145 deltaPhi = yOut*CLHEP::pi/180.;
146
147
149 rotateVector.rotateZ(center01.phi());
150 posCorr.setZ(posCorr.z()-IRShift);
151 posCorr.rotate(-deltaTheta,rotateVector);
152 posCorr.setZ(posCorr.z()+IRShift);
153
154 posCorr.rotateZ(-0.002994);
155
156
157 if(thetaModule>21) {
158 posCorr.setZ(-posCorr.z());
159 }
160 }
161
163
164 if(aShower.
energy()<1e-5)
return;
165
166 double r,theta,phi;
167 double dtheta,dphi,dx,dy,dz;
168
169 r = posCorr.mag();
170 theta = posCorr.theta();
171 phi = posCorr.phi();
172
173
177 }
178 else {
179 dtheta = 0;
180 dphi = 0;
181 }
182
183
186 if(theta>0)
188 else
189 dz = 0;
190
191
194
195
196
197 HepSymMatrix matrix(3);
198 matrix[0][0]=0;
199 matrix[1][1]=dtheta*dtheta;
200 matrix[2][2]=dphi*dphi;
201 matrix[0][1]=0;
202 matrix[0][2]=0;
203 matrix[1][2]=0;
204
205
206 HepMatrix matrix1(3,3),matrix2(3,3);
207 matrix1[0][0]=
sin(theta)*
cos(phi);
208 matrix1[0][1]=r*
cos(theta)*
cos(phi);
209 matrix1[0][2]=-r*
sin(theta)*
sin(phi);
210 matrix1[1][0]=
sin(theta)*
sin(phi);
211 matrix1[1][1]=r*
cos(theta)*
sin(phi);
212 matrix1[1][2]=r*
sin(theta)*
cos(phi);
213 matrix1[2][0]=
cos(theta);
214 matrix1[2][1]=-r*
sin(theta);
215 matrix1[2][2]=0;
216
217
218 for(int i=0;i<3;i++) {
219 for(int j=0;j<3;j++) {
220 matrix2[i][j]=matrix1[j][i];
221 }
222 }
223
224
225 HepMatrix matrix4(3,3);
226 matrix4=matrix1*matrix*matrix2;
227
228
229 HepSymMatrix matrix5(3);
230 for(int i=0;i<3;i++) {
231 for(int j=0;j<=i;j++) {
232 matrix5[i][j]=matrix4[i][j];
233 }
234 }
235
236
238
239 if(matrix5[0][0]>0) dx=sqrt(matrix5[0][0]);
240 if(matrix5[1][1]>0) dy=sqrt(matrix5[1][1]);
241 if(matrix5[2][2]>0) dz=sqrt(matrix5[2][2]);
242}
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
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 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