BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecShowerPosLin Class Reference

#include <EmcRecShowerPosLin.h>

+ Inheritance diagram for EmcRecShowerPosLin:

Public Member Functions

 EmcRecShowerPosLin ()
 
virtual ~EmcRecShowerPosLin ()
 
virtual void Position (RecEmcShower &aShower)
 
- Public Member Functions inherited from EmcRecShowerPosAbs
 EmcRecShowerPosAbs ()
 
virtual ~EmcRecShowerPosAbs ()
 
virtual void Position (RecEmcShower &aShower)=0
 

Detailed Description

Definition at line 15 of file EmcRecShowerPosLin.h.

Constructor & Destructor Documentation

◆ EmcRecShowerPosLin()

EmcRecShowerPosLin::EmcRecShowerPosLin ( )
inline

Definition at line 18 of file EmcRecShowerPosLin.h.

18{}

◆ ~EmcRecShowerPosLin()

virtual EmcRecShowerPosLin::~EmcRecShowerPosLin ( )
inlinevirtual

Definition at line 19 of file EmcRecShowerPosLin.h.

19{}

Member Function Documentation

◆ Position()

void EmcRecShowerPosLin::Position ( RecEmcShower aShower)
virtual

Implements EmcRecShowerPosAbs.

Definition at line 17 of file EmcRecShowerPosLin.cxx.

18{
19 RecEmcFractionMap::const_iterator cit;
20 HepPoint3D pos(0,0,0);
21 HepPoint3D possum(0,0,0);
22 double w,wsum;
23 double etot;
24 //cout<<"EmcRecShowerPosLin::Position Begin"<<endl;
25
26 IEmcRecGeoSvc* iGeoSvc;
27 ISvcLocator* svcLocator = Gaudi::svcLocator();
28 StatusCode sc = svcLocator->service("EmcRecGeoSvc",iGeoSvc);
29 if(sc!=StatusCode::SUCCESS) {
30// cout<<"Error: Can't get EmcRecGeoSvc"<<endl;
31 }
32
34
35 double e5x5 = aShower.e5x5();
36
37 etot=0;
38
39 for(cit=aShower.Begin();cit!=aShower.End();cit++){
40 etot+=(cit->second.getEnergy()*cit->second.getFraction());
41 }
42 wsum=0;
43 for(cit=aShower.Begin();cit!=aShower.End();cit++){
44 w=(cit->second.getEnergy()*cit->second.getFraction());
45 wsum+=w;
46 pos=iGeoSvc->GetCFrontCenter(cit->second.getCellId());
47 possum+=pos*w;
48 }
49
50 if(wsum<=0) {
51 cout<<"[[[[[[[[[[[[[[["<<wsum;
52 }
53
54 pos=possum/wsum;
55// aShower.setPosition(pos);
56
57 //PosCorr=0 without position correction
58 //PosCorr=1 with position correction
59 if(Para.PosCorr()==0){ aShower.setPosition(pos);}
60
61
62 //----------------------------------------------------------------------
63 //position correction
64 RecEmcID id = aShower.getShowerId();
65 const unsigned int module = EmcID::barrel_ec(id);;
66 const unsigned int thetaModule = EmcID::theta_module(id);
67 const unsigned int phiModule = EmcID::phi_module(id);
68 HepPoint3D posCorr(pos);
69
70 if(module==1) { //barrel
71 unsigned int theModule;
72 if(thetaModule>21) {
73 theModule = 43 - thetaModule;
74 id = EmcID::crystal_id(module,theModule,phiModule);
75 posCorr.setZ(-posCorr.z());
76 } else {
77 theModule = thetaModule;
78 }
79 //cout<<"EmcID: "<<id<<" theta: "<<theModule<<endl;
80
82 double IRShift, parTheta[5],parPhi[5];
83
84
85 if(theModule==21) {
86 IRShift = 0;
87 } else if(theModule==20) {
88 IRShift = 2.5;
89 } else {
90 IRShift = 5.;
91 }
92
93
94 if(Para.MethodMode()==0){
95
96
97 for(int i=0;i<5;i++){
98 if(theModule==21) {
99 double par[5] = { 1.698, -1.553, 0.9384, 0.1193, -0.01916 };
100 parTheta[i] = par[i];
101 }else if(theModule==20){
102 double par[5] = { 1.593, -1.582, 0.8881, 0.3298, -0.08856 };
103 parTheta[i] = par[i];
104 }else{
105 double par[5] = { 1.605, -1.702, 0.8433, 0.3072, -0.1809 };
106 parTheta[i] = par[i];
107 }
108 }
109
110 } else if(Para.MethodMode()==1){
111
112 for(int i=0;i<5;i++){
113
114 if(e5x5>1.0) parTheta[i] = Para.BarrLinThetaPara(theModule,i);
115 else if(e5x5<=1.0 && e5x5>0.5) parTheta[i] = Para.BarrLinThetaPara(theModule+22,i);
116 else if(e5x5<=0.5) parTheta[i] = Para.BarrLinThetaPara(theModule+44,i);
117
118 if(e5x5>1.0) parPhi[i] = Para.BarrLinPhiPara(0,i);
119 else if(e5x5<=1.0 && e5x5>0.5) parPhi[i] = Para.BarrLinPhiPara(1,i);
120 else if(e5x5<=0.5) parPhi[i] = Para.BarrLinPhiPara(2,i);
121
122 }
123 }
124
125
126
127 HepPoint3D IR(0,0,IRShift);
128 HepPoint3D center01, center23; //center of point0,1 and point2,3 in crystal
129 center01 = (iGeoSvc->GetCrystalPoint(id,0)+iGeoSvc->GetCrystalPoint(id,1))/2;
130 center23 = (iGeoSvc->GetCrystalPoint(id,2)+iGeoSvc->GetCrystalPoint(id,3))/2;
131 //cout<<"before correction: "<<(posCorr-IR).theta()<<"\t"<<posCorr.phi()<<endl;
132
133 double theta01,theta23,length,d;
134 theta01 = (center01-IR).theta();
135 theta23 = (center23-IR).theta();
136 length = (center01-IR).mag();
137 d = length*tan(theta01-theta23); //length in x direction
138 //cout<<"theta01: "<<theta01<<"\t"<<" theta23: "<<theta23<<"\t"
139 //<<" length: "<<length<<" d: "<<d<<endl;
140
141 double xIn,xOut,deltaTheta;
142 xIn = length*tan(theta01-(posCorr-IR).theta())-d/2;
143 xOut = xIn-(parTheta[0]*atan(xIn*parTheta[1]-parTheta[4])+parTheta[2]*xIn+parTheta[3]);
144 deltaTheta = atan((xOut+d/2)/length)-atan((xIn+d/2)/length);
145 //cout<<"xIn: "<<xIn<<" xOut: "<<xOut<<" deltaTheta: "<<deltaTheta<<endl;
146
147 double parPhi1[5] = { 0.7185, -2.539, 0.6759, 0.3472, -0.3108 }; //e-
148 double parPhi2[5] = { 0.5781, -2.917, 0.5516, -0.5745, 0.3777 }; //e+
149
150// double parPhi[5];// = { 0.7723, -3.1, 0.6992, -0.1441, -0.01012 }; //by photon, not used
151
152// for(int i=0;i<5;i++) {
153// parPhi[i] = (parPhi1[i]+parPhi2[i])/2; //average of e- and e+
154// }
155
156 double yIn,yOut,deltaPhi;
157// yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.1537
158// : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.1537;
159 if(phiModule==0&&posCorr.phi()<0){
160
161 yIn = posCorr.phi()*180./CLHEP::pi+360.-119*3-1.843;
162
163 }else if (phiModule==119&&posCorr.phi()>0){
164
165 yIn = posCorr.phi()*180./CLHEP::pi-1.843;
166
167 }else {
168
169 yIn = posCorr.phi() < 0 ? posCorr.phi()*180./CLHEP::pi+360.-phiModule*3.-1.843
170 : posCorr.phi()*180./CLHEP::pi-phiModule*3.-1.843;
171
172 }
173
174 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4])+parPhi[2]*yIn+parPhi[3];
175 deltaPhi = yOut*CLHEP::pi/180.;
176 //cout<<"yIn="<<yIn<<"\tyOut="<<yOut<<"\tdeltaPhi="<<deltaPhi<<endl;
177
178 HepPoint3D rotateVector(0,1,0); //y axis
179 rotateVector.rotateZ(posCorr.phi());
180 posCorr.setZ(posCorr.z()-IRShift);
181 posCorr.rotate(-deltaTheta,rotateVector);
182 posCorr.setZ(posCorr.z()+IRShift);
183 if(Para.MethodMode()==0){
184 posCorr.rotateZ(-0.002994);
185 }else if(Para.MethodMode()==1){
186 posCorr.rotateZ(-deltaPhi);
187 }
188
189 if(thetaModule>21) {
190 posCorr.setZ(-posCorr.z());
191 }
192 } else { //endcap
193
195
196 if(Para.MethodMode()==1){
197
198 double IRShift = 0;
199 HepPoint3D IR(0,0,IRShift);
200 double theta12=-9999,theta03=-9999,theta23=-9999,theta14=-9999,delta=-9999;
201 double phi=-9999,phi01=-9999,phi23=-9999,phi12=-9999,phi34=-9999,deltaphi=-9999;
202 double xIn,xOut,deltaTheta,yIn,yOut,deltaPhi;
203 double posphi=posCorr.phi();
204
205 double parTheta[5],parPhi[5];
206
207 HepPoint3D point0 ,point1 ,point2 ,point3 ,point4 ;
208 point0 = iGeoSvc->GetCrystalPoint(id,0);
209 point1 = iGeoSvc->GetCrystalPoint(id,1);
210 point2 = iGeoSvc->GetCrystalPoint(id,2);
211 point3 = iGeoSvc->GetCrystalPoint(id,3);
212 point4 = iGeoSvc->GetCrystalPoint(id,4);
213
214 HepPoint3D center,center01, center23, center12,center03,center34,center14;
215 center01 = (point0+point1)/2;
216 center23 = (point2+point3)/2;
217 center12 = (point1+point2)/2;
218 center34 = (point3+point4)/2;
219 center03 = (point0+point3)/2;
220 center14 = (point1+point4)/2;
221
222 phi01 = center01.phi();
223 phi23 = center23.phi();
224 phi12 = center12.phi();
225 phi34 = center34.phi();
226
227
228 if( (thetaModule==1&&((phiModule+3)%4 == 0||(phiModule+2)%4 == 0))
229 ||(thetaModule==3&&((phiModule+4)%5 == 0||(phiModule+3)%5 == 0||(phiModule+2)%5 == 0)))
230 {
231 center12 = center23;
232 center03 = center14;
233
234 center01 = center12;
235 center23 = center34;
236
237 phi01 = phi12;
238 phi23 = phi34;
239 }
240
241 if(phiModule==0){
242 posphi = posphi;
243 }else if( ((thetaModule==0||thetaModule==1)&&phiModule==63)
244 ||((thetaModule==2||thetaModule==3)&&phiModule==79)
245 ||((thetaModule==4||thetaModule==5)&&phiModule==95)
246 ){
247
248 posphi = posphi+2*CLHEP::pi;
249
250 }else {
251 posphi = posphi < 0 ? posphi+2*CLHEP::pi : posphi;
252 }
253
254 phi01 = phi01 <0 ? phi01+2*CLHEP::pi : phi01;
255 phi23 = phi23 <0 ? phi23+2*CLHEP::pi : phi23;
256
257 if(module==0){ //east endcap
258
259 IRShift = 10;
260 center = center23;
261 phi = phi23;
262
263 for(int i=0;i<5;i++) {
264 parTheta[i] = Para.EastLinThetaPara(thetaModule,i);
265 parPhi[i] = Para.EastLinPhiPara(0,i);
266 }
267
268 }else if (module==2){ //west endcap
269
270 IRShift = -10;
271 center = center01;
272 phi = phi01;
273
274 for(int i=0;i<5;i++){
275 parTheta[i] = Para.WestLinThetaPara(thetaModule,i);
276 parPhi[i] = Para.WestLinPhiPara(0,i);
277 }
278
279 }
280
281 theta12 = (center12 - IR).theta();
282 theta03 = (center03 - IR).theta();
283 delta = theta03 - theta12;
284 xIn = (((posCorr-IR).theta() - theta12) - delta*0.5)/delta;
285 xOut = parTheta[0]*atan(xIn*parTheta[1]-parTheta[4]) + parTheta[2]*xIn + parTheta[3] ;
286 deltaTheta = xOut*delta;
287
288 deltaphi = fabs(phi23 - phi01);
289 yIn = ((posphi - phi) - deltaphi*0.5)/deltaphi;
290 yOut = parPhi[0]*atan(yIn*parPhi[1]-parPhi[4]) + parPhi[2]*yIn + parPhi[3] ;
291 deltaPhi = yOut*deltaphi;
292
293 HepPoint3D rotateVector(0,1,0); //y axis
294 rotateVector.rotateZ(center.phi());
295 posCorr.setZ(posCorr.z()-IRShift);
296 posCorr.rotate(-deltaTheta,rotateVector);
297 posCorr.setZ(posCorr.z()+IRShift);
298 posCorr.rotateZ(-deltaPhi);
299
300 }
301 }
302
303 // aShower.setPosition(posCorr);
304 if(Para.PosCorr()==1){ aShower.setPosition(posCorr);}
305
306 //----------------------------------------------------------------------
307 if(aShower.energy()<1e-5) return;
308
309 double r,theta,phi;
310 double dtheta,dphi,dx,dy,dz;
311
312 r = posCorr.mag();
313 theta = posCorr.theta();
314 phi = posCorr.phi();
315 //cout<<"theta: "<<theta<<" phi: "<<phi<<endl;
316
317// EmcRecParameter& Para=EmcRecParameter::GetInstance();
318 if(aShower.energy()>0) {
319 dtheta = Para.SigTheta(0)/sqrt(aShower.energy())+Para.SigTheta(1);
320 dphi = Para.SigPhi(0)/sqrt(aShower.energy())+Para.SigPhi(1);
321 }
322 else {
323 dtheta = 0;
324 dphi = 0;
325 }
326 //cout<<"dtheta: "<<dtheta<<" dphi: "<<dphi<<endl;
327
328 dx = fabs(iGeoSvc->GetBarrelR()*sin(phi)*dphi);
329 dy = fabs(iGeoSvc->GetBarrelR()*cos(phi)*dphi);
330 if(theta>0)
331 dz = fabs(iGeoSvc->GetBarrelR()*dtheta/(sin(theta)*sin(theta)));
332 else
333 dz = 0;
334 //cout<<" dx: "<<dx<<" dy: "<<dy<<" dz: "<<dz<<endl;
335
336 aShower.setDtheta(dtheta);
337 aShower.setDphi(dphi);
338
339 //----------------------------------------------------------------------
340 // Error matrix
341 HepSymMatrix matrix(3); //error matrix of r, theta, phi
342 matrix[0][0]=0;
343 matrix[1][1]=dtheta*dtheta;
344 matrix[2][2]=dphi*dphi;
345 matrix[0][1]=0;
346 matrix[0][2]=0;
347 matrix[1][2]=0;
348 //cout<<"matrix: \n"<<matrix;
349
350 HepMatrix matrix1(3,3),matrix2(3,3);
351 matrix1[0][0]=sin(theta)*cos(phi);
352 matrix1[0][1]=r*cos(theta)*cos(phi);
353 matrix1[0][2]=-r*sin(theta)*sin(phi);
354 matrix1[1][0]=sin(theta)*sin(phi);
355 matrix1[1][1]=r*cos(theta)*sin(phi);
356 matrix1[1][2]=r*sin(theta)*cos(phi);
357 matrix1[2][0]=cos(theta);
358 matrix1[2][1]=-r*sin(theta);
359 matrix1[2][2]=0;
360 //cout<<"matrix1: \n"<<matrix1;
361
362 for(int i=0;i<3;i++) {
363 for(int j=0;j<3;j++) {
364 matrix2[i][j]=matrix1[j][i];
365 }
366 }
367 //cout<<"matrix2: \n"<<matrix2;
368
369 HepMatrix matrix4(3,3);
370 matrix4=matrix1*matrix*matrix2;
371 //cout<<"matrix4: \n"<<matrix4;
372
373 HepSymMatrix matrix5(3); //error matrix of x, y, z
374 for(int i=0;i<3;i++) {
375 for(int j=0;j<=i;j++) {
376 matrix5[i][j]=matrix4[i][j];
377 }
378 }
379 //cout<<"matrix5: \n"<<matrix5;
380
381 aShower.setErrorMatrix(matrix5);
382}
double tan(const BesAngle a)
Definition: BesAngle.h:216
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
const double delta
Double_t etot
double w
void setDphi(double dpi)
Definition: DstEmcShower.h:66
void setDtheta(double dt)
Definition: DstEmcShower.h:65
double e5x5() const
Definition: DstEmcShower.h:49
void setPosition(const HepPoint3D &pos)
Definition: DstEmcShower.h:62
double energy() const
Definition: DstEmcShower.h:45
void setErrorMatrix(const HepSymMatrix &error)
Definition: DstEmcShower.h:75
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
Definition: EmcID.cxx:71
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition: EmcID.cxx:38
static unsigned int theta_module(const Identifier &id)
Definition: EmcID.cxx:43
static unsigned int phi_module(const Identifier &id)
Definition: EmcID.cxx:48
static EmcRecParameter & GetInstance()
double EastLinThetaPara(int n, int m) const
double EastLinPhiPara(int n, int m) const
double PosCorr() const
double MethodMode() const
double SigTheta(int n) const
double WestLinThetaPara(int n, int m) const
double BarrLinPhiPara(int n, int m) const
double BarrLinThetaPara(int n, int m) const
double WestLinPhiPara(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
Definition: RecEmcShower.h:55
RecEmcFractionMap::const_iterator Begin() const

The documentation for this class was generated from the following files: