18 {
19 RecEmcFractionMap::const_iterator cit;
22 double w, w1, w2, wsum = 0;
24
25
26
27 IEmcRecGeoSvc* iGeoSvc;
28 ISvcLocator* svcLocator = Gaudi::svcLocator();
29 StatusCode sc = svcLocator->service( "EmcRecGeoSvc", iGeoSvc );
30 if ( sc != StatusCode::SUCCESS )
31 {
32
33 }
34
36
37
39 double offset = 0.0;
40
41 double e5x5 = -99999;
43 {
45 for ( cit = aShower.
Begin(); cit != aShower.
End(); cit++ )
46 {
47 w = offset + log( ( cit->second.getEnergy() /
etot ) * cit->second.getFraction() );
49 {
53 }
54 }
55 }
57 {
58 double e3x3 = aShower.
e3x3();
60 for ( cit = fracMap3x3.begin(); cit != fracMap3x3.end(); cit++ )
61 {
62 w = offset + log( ( cit->second.getEnergy() / e3x3 ) * cit->second.getFraction() );
64 {
68 }
69 }
70 }
71 else
72 {
73 e5x5 = aShower.
e5x5();
74 offset =
a0 - 1.594 *
exp( -2.543 * e5x5 );
76
77 num0 = 0;
79 for ( cit = fracMap5x5.begin(); cit != fracMap5x5.end(); cit++ )
80 {
81 w1 = offset + log( ( cit->second.getEnergy() / e5x5 ) * cit->second.getFraction() );
82 w2 = ( cit->second.getEnergy() / e5x5 ) * cit->second.getFraction();
83
84 num0++;
85
86 if ( w1 > 0 ) {
num++; }
87 }
88
89
90
91 for ( cit = fracMap5x5.begin(); cit != fracMap5x5.end(); cit++ )
92 {
93 w1 = offset + log( ( cit->second.getEnergy() / e5x5 ) * cit->second.getFraction() );
94 w2 = ( cit->second.getEnergy() / e5x5 ) * cit->second.getFraction();
95
96 num0++;
97
98 if ( w1 > 0 )
99 {
101 {
102
103 wsum += w1;
105 possum += pos * w1;
106 }
107 else
108 {
109
110 wsum += w2;
112 possum += pos * w2;
113 }
114 }
115 }
116 }
117 if ( wsum <= 0 )
118 {
119
120 }
121 pos = possum / wsum;
122
123
124
126
127
128
131 ;
135
136 if ( module == 1 )
137 {
138 unsigned int theModule;
139 if ( thetaModule > 21 )
140 {
141 theModule = 43 - thetaModule;
143 posCorr.setZ( -posCorr.z() );
144 }
145 else { theModule = thetaModule; }
146
147 double IRShift = 0, parTheta[5], parPhi[5];
148 if ( theModule == 21 ) { IRShift = 0; }
149 else if ( theModule == 20 ) { IRShift = 2.5; }
150 else { IRShift = 5.; }
151
153 for ( int i = 0; i < 5; i++ )
154 {
155
157
159
160
161
162
163
164
165
166 }
167
172
173 double theta01, theta23, length, d;
174 theta01 = ( center01 - IR ).theta();
175 theta23 = ( center23 - IR ).theta();
176 length = ( center01 - IR ).mag();
177 d = length *
tan( theta01 - theta23 );
178
179 double xIn, xOut, deltaTheta;
180 xIn = length *
tan( theta01 - ( posCorr - IR ).theta() ) - d / 2;
181 xOut = xIn - ( parTheta[0] * atan( xIn * parTheta[1] - parTheta[4] ) + parTheta[2] * xIn +
182 parTheta[3] );
183 deltaTheta = atan( ( xOut + d / 2 ) / length ) - atan( ( xIn + d / 2 ) / length );
184
185
186
187
188
189
190 double yIn, yOut, deltaPhi;
191
192
193
194
195 yIn = posCorr.phi() < 0 ? posCorr.phi() * 180. / CLHEP::pi + 360. - phiModule * 3. - 1.843
196 : posCorr.phi() * 180. / CLHEP::pi - phiModule * 3. - 1.843;
197
198 if ( phiModule == 0 && posCorr.phi() < 0 )
199 { yIn = posCorr.phi() * 180. / CLHEP::pi + 360. - 119 * 3 - 1.843; }
200 else if ( phiModule == 119 && posCorr.phi() > 0 )
201 { yIn = posCorr.phi() * 180. / CLHEP::pi - 1.843; }
202 else
203 {
204 yIn = posCorr.phi() < 0
205 ? posCorr.phi() * 180. / CLHEP::pi + 360. - phiModule * 3. - 1.843
206 : posCorr.phi() * 180. / CLHEP::pi - phiModule * 3. - 1.843;
207 }
208 yOut = parPhi[0] * atan( yIn * parPhi[1] - parPhi[4] ) + parPhi[2] * yIn + parPhi[3];
209 deltaPhi = yOut * CLHEP::pi / 180.;
210
212 rotateVector.rotateZ( center01.phi() );
213 posCorr.setZ( posCorr.z() - IRShift );
214 posCorr.rotate( -deltaTheta, rotateVector );
215 posCorr.setZ( posCorr.z() + IRShift );
216
217
218 posCorr.rotateZ( -deltaPhi );
219
220 if ( thetaModule > 21 ) { posCorr.setZ( -posCorr.z() ); }
221 }
223
224 if ( aShower.
energy() < 1e-5 )
return;
225
226 double r, theta, phi;
227 double dtheta, dphi, dx, dy, dz;
228
229 r = posCorr.mag();
230 theta = posCorr.theta();
231 phi = posCorr.phi();
232
233
234 if ( aShower.
energy() > 0 )
235 {
238 }
239 else
240 {
241 dtheta = 0;
242 dphi = 0;
243 }
244
245
248 if ( theta > 0 )
249 dz = fabs( iGeoSvc->
GetBarrelR() * dtheta / (
sin( theta ) *
sin( theta ) ) );
250 else dz = 0;
251
252
255
256
257
258 HepSymMatrix matrix( 3 );
259 matrix[0][0] = 0;
260 matrix[1][1] = dtheta * dtheta;
261 matrix[2][2] = dphi * dphi;
262 matrix[0][1] = 0;
263 matrix[0][2] = 0;
264 matrix[1][2] = 0;
265
266
267 HepMatrix matrix1( 3, 3 ), matrix2( 3, 3 );
268 matrix1[0][0] =
sin( theta ) *
cos( phi );
269 matrix1[0][1] = r *
cos( theta ) *
cos( phi );
270 matrix1[0][2] = -r *
sin( theta ) *
sin( phi );
271 matrix1[1][0] =
sin( theta ) *
sin( phi );
272 matrix1[1][1] = r *
cos( theta ) *
sin( phi );
273 matrix1[1][2] = r *
sin( theta ) *
cos( phi );
274 matrix1[2][0] =
cos( theta );
275 matrix1[2][1] = -r *
sin( theta );
276 matrix1[2][2] = 0;
277
278
279 for ( int i = 0; i < 3; i++ )
280 {
281 for ( int j = 0; j < 3; j++ ) { matrix2[i][j] = matrix1[j][i]; }
282 }
283
284
285 HepMatrix matrix4( 3, 3 );
286 matrix4 = matrix1 * matrix * matrix2;
287
288
289 HepSymMatrix matrix5( 3 );
290 for ( int i = 0; i < 3; i++ )
291 {
292 for ( int j = 0; j <= i; j++ ) { matrix5[i][j] = matrix4[i][j]; }
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}
HepGeom::Point3D< double > HepPoint3D
character *LEPTONflag integer iresonances real zeta5 real a0
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