20 {
21 RecEmcFractionMap::const_iterator cit;
27
28
29
30 IEmcRecGeoSvc* iGeoSvc;
31 ISvcLocator* svcLocator = Gaudi::svcLocator();
32 StatusCode sc = svcLocator->service( "EmcRecGeoSvc", iGeoSvc );
33 if ( sc != StatusCode::SUCCESS )
34 {
35
36 }
37
39
40 for ( cit = aShower.
Begin(); cit != aShower.
End(); cit++ )
41 {
42 etot += ( cit->second.getEnergy() * cit->second.getFraction() );
43
44 }
45 wsum = 0;
46
47 double etota = aShower.
getEAll();
48 double ltot = ( log( etota / 0.0145 ) + 0.5 ) * 1.86;
49 double e55 = aShower.
e5x5();
50 double len55 = ( log( etota / 0.0145 ) + 0.5 ) * 1.86;
53
54
55 for ( cit = aShower.
Begin(); cit != aShower.
End(); cit++ )
56 {
57 w = ( cit->second.getEnergy() * cit->second.getFraction() );
58
60
61
62 double theDistance = 0;
63 if ( cit->second.getCellId() == seedID )
64 {
65
66 theDistance = ( seedPoint.mag() + ltot );
67 }
68 else
69 {
70 theDistance = ( seedPoint.mag() + ltot ) /
cos( seedPoint.angle( hitPoint ) );
71
72 }
73
74
77
78 posMax = ( theDistance / pos.mag() ) * pos;
79
81 }
82
83 if ( wsum <= 0 ) { cout << "[[[[[[[[[[[[[[[" << wsum; }
84 pos = possum / wsum;
85
86
88
89
90
93 ;
97
98 if ( module == 1 )
99 {
100 unsigned int theModule;
101 if ( thetaModule > 21 )
102 {
103 theModule = 43 - thetaModule;
105 posCorr.setZ( -posCorr.z() );
106 }
107 else { theModule = thetaModule; }
108
109 double IRShift, parTheta[5], parPhi[5];
110 if ( theModule == 21 ) { IRShift = 0; }
111 else if ( theModule == 20 ) { IRShift = 2.5; }
112 else { IRShift = 5.; }
113
115
116 for ( int i = 0; i < 5; i++ )
117 {
118
120 else if ( e55 <= 1.0 && e55 > 0.5 )
123
125 else if ( e55 <= 1.0 && e55 > 0.5 ) parPhi[i] = Para.
BarrShLinPhiPara( 1, i );
127 }
128
133
134 double theta01, theta23, length, d;
135 theta01 = ( center01 - IR ).theta();
136 theta23 = ( center23 - IR ).theta();
137 length = ( center01 - IR ).mag();
138 d = length *
tan( theta01 - theta23 );
139
140 double xIn, xOut, deltaTheta;
141 xIn = length *
tan( theta01 - ( posCorr - IR ).theta() ) - d / 2;
142 xOut = xIn - ( parTheta[0] * atan( xIn * parTheta[1] - parTheta[4] ) + parTheta[2] * xIn +
143 parTheta[3] );
144 deltaTheta = atan( ( xOut + d / 2 ) / length ) - atan( ( xIn + d / 2 ) / length );
145
146
147
148
149 double yIn, yOut, deltaPhi;
150
151 if ( phiModule == 0 && posCorr.phi() < 0 )
152 { yIn = posCorr.phi() * 180. / CLHEP::pi + 360. - 119 * 3 - 1.843; }
153 else if ( phiModule == 119 && posCorr.phi() > 0 )
154 { yIn = posCorr.phi() * 180. / CLHEP::pi - 1.843; }
155 else
156 {
157
158 yIn = posCorr.phi() < 0
159 ? posCorr.phi() * 180. / CLHEP::pi + 360. - phiModule * 3. - 1.843
160 : posCorr.phi() * 180. / CLHEP::pi - phiModule * 3. - 1.843;
161 }
162 yOut = parPhi[0] * atan( yIn * parPhi[1] - parPhi[4] ) + parPhi[2] * yIn + parPhi[3];
163
164
165
166
167 deltaPhi = yOut * CLHEP::pi / 180.;
168
170 rotateVector.rotateZ( center01.phi() );
171 posCorr.setZ( posCorr.z() - IRShift );
172 posCorr.rotate( -deltaTheta, rotateVector );
173 posCorr.setZ( posCorr.z() + IRShift );
174
175
176 posCorr.rotateZ( -deltaPhi );
177
178 if ( thetaModule > 21 ) { posCorr.setZ( -posCorr.z() ); }
179 }
180 posCorr = ( ( posCorr.mag() - len55 ) / posCorr.mag() ) * posCorr;
181
183
184
185 if ( aShower.
energy() < 1e-5 )
return;
186
187 double r, theta, phi;
188 double dtheta, dphi, dx, dy, dz;
189
190 r = posCorr.mag();
191 theta = posCorr.theta();
192 phi = posCorr.phi();
193
194
195 if ( aShower.
energy() > 0 )
196 {
199 }
200 else
201 {
202 dtheta = 0;
203 dphi = 0;
204 }
205
206
209 if ( theta > 0 )
210 dz = fabs( iGeoSvc->
GetBarrelR() * dtheta / (
sin( theta ) *
sin( theta ) ) );
211 else 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 {
242 for ( int j = 0; j < 3; j++ ) { matrix2[i][j] = matrix1[j][i]; }
243 }
244
245
246 HepMatrix matrix4( 3, 3 );
247 matrix4 = matrix1 * matrix * matrix2;
248
249
250 HepSymMatrix matrix5( 3 );
251 for ( int i = 0; i < 3; i++ )
252 {
253 for ( int j = 0; j <= i; j++ ) { matrix5[i][j] = matrix4[i][j]; }
254 }
255
256
258
259 if ( matrix5[0][0] > 0 ) dx = sqrt( matrix5[0][0] );
260 if ( matrix5[1][1] > 0 ) dy = sqrt( matrix5[1][1] );
261 if ( matrix5[2][2] > 0 ) dz = sqrt( matrix5[2][2] );
262}
HepGeom::Point3D< double > HepPoint3D
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