BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecBarrelGeo.cxx
Go to the documentation of this file.
1//
2// EmcRecBarrelGeo
3//
4// Dec 18, 2003, Created by Wang.Zhe
5//
6// unit: mm, radian
7//
8//#include "BesGeoEMC/DB2BesGeoEMC.h"
9#include "EmcRecGeoSvc/EmcRecBarrelGeo.h"
10
12{
13 ParameterInitialize();
14 CalculateStandardCrystal();
15 Transform2Column1();
16 FillCCenterVector();
17}
18
20{
21 fStandard.clear();
22 fCCenter.clear();
23 fCFrontCenter.clear();
24}
25
26void EmcRecBarrelGeo::ParameterInitialize()
27{
28 /*
29 DB2BesGeoEMC obj1;
30 vector<BesGeoEMC> VecA;
31
32 obj1.Get_BesGeoEMC(VecA);
33 fBarrelR=VecA[0].Get_BarrelR();
34 fBarrelOffset1=VecA[0].Get_BarrelOffset1();
35 fBarrelOffset2=VecA[0].Get_BarrelOffset2();
36 fBarrelh1=VecA[0].Get_Barrelh1();
37 fBarrelh2=VecA[0].Get_Barrelh2();
38 fBarrelh3=VecA[0].Get_Barrelh3();
39 fBarrelL=VecA[0].Get_BarrelL();
40 fBarrelL2=VecA[0].Get_BarrelL2();
41 fBarrelNPhiMax=(int)VecA[0].Get_BarrelNPhiMax();
42 fBarrelNThetaMax=(int)VecA[0].Get_BarrelNThetaMax();
43 */
44
45 fBarrelR=942;
46 fBarrelOffset1=25;
47 fBarrelOffset2=50;
48 fBarrelh1=51;
49 fBarrelh2=52;
50 fBarrelh3=52.466;
51 fBarrelL=280;
52 fBarrelL2=240;
53 fBarrelNPhiMax=120;
54 fBarrelNThetaMax=22;
55
56 fBarrelAlpha=twopi/fBarrelNPhiMax;
57
58 fStandard.clear();
59 fCCenter.clear();
60 fCFrontCenter.clear();
61}
62
63void EmcRecBarrelGeo::CalculateStandardCrystal()
64{
65 double R1,R2,a;
66 EmcRecCrystal pre,now;
67 double dx,dy,dz;
68 HepPoint3D t1,t2;
69 double L,h;
70
71 HepPoint3D O1(0,0,0);
72 HepPoint3D O2(0,0,fBarrelOffset1);
73 HepPoint3D O3(0,0,fBarrelOffset2);
74
75 R1=2*fBarrelR*sin(fBarrelAlpha/2)/sin(fBarrelAlpha);
76 R2=2*fBarrelR*sin(fBarrelAlpha/2)*(tan(fBarrelAlpha)+1/tan(fBarrelAlpha));
77 a=2*fBarrelR*sin(fBarrelAlpha/2)/cos(fBarrelAlpha);
78
79 HepPoint3D M4(0,R1,0);
80 HepPoint3D A1(a,R1,0);
81
82// cout<<O1<<", "<<O2<<", "<<O3<<endl;
83// cout<<M4<<", "<<A1<<endl;
84// cout<<R1<<", "<<R2<<endl;
85
86 // No. 1 theta: 21; phi: 30
87 EmcRecCrystal Crystal1;
88
89 Crystal1.Set(0,M4);
90 Crystal1.Set(1,A1);
91 Crystal1.Set(2,A1); Crystal1.SetZ(2,A1.z()+fBarrelh1);
92 Crystal1.Set(3,M4); Crystal1.SetZ(3,M4.z()+fBarrelh1);
93
94 Crystal1.Set(4,M4); Crystal1.SetY(4,M4.y()+fBarrelL);
95 dx=a*(R1+fBarrelL)/R1;
96 Crystal1.Set(5,Crystal1.Get(4)); Crystal1.SetX(5,dx);
97 dz=fBarrelOffset1+(fBarrelh1-fBarrelOffset1)*(R1+fBarrelL)/R1;
98 Crystal1.Set(6,Crystal1.Get(5)); Crystal1.SetZ(6,Crystal1.Get(5).z()+dz);
99 Crystal1.Set(7,Crystal1.Get(4)); Crystal1.SetZ(7,Crystal1.Get(4).z()+dz);
100
101 fStandard.push_back(Crystal1);
102 pre=fStandard[0];
103
104 // No. 2 theta: 20; phi: 30
105 EmcRecCrystal Crystal2;
106 double sin_gamma,cos_gamma,tan_gamma;
107
108 tan_gamma=R1/(fBarrelh1-fBarrelOffset1);
109 sin_gamma=tan_gamma/(sqrt(1+tan_gamma*tan_gamma));
110 cos_gamma=1/(sqrt(1+tan_gamma*tan_gamma));
111
112 double aa,bb,Rp;
113 aa=fBarrelh1/sin_gamma;
114 bb=fBarrelh1/tan_gamma;
115
116 Crystal2.Set(0,pre.Get(3)); Crystal2.SetZ(0,pre.Get(3).z()+bb*cos_gamma);
117 Crystal2.SetY(0,pre.Get(3).y()+bb*sin_gamma);
118 Rp=R1/sin_gamma;
119 dx=a*(Rp+bb)/Rp;
120 Crystal2.Set(1,Crystal2.Get(0)); Crystal2.SetX(1,dx);
121 Crystal2.Set(3,pre.Get(3)); Crystal2.SetZ(3,pre.Get(3).z()+aa);
122 Crystal2.Set(2,Crystal2.Get(3)); Crystal2.SetX(2,a);
123
124 dz=(fBarrelL+bb)*cos_gamma;
125 dy=(fBarrelL+bb)*sin_gamma;
126 Crystal2.Set(4,pre.Get(3)); Crystal2.SetZ(4,pre.Get(3).z()+dz);
127 Crystal2.SetY(4,pre.Get(3).y()+dy);
128 dx=a*(Rp+bb+fBarrelL)/Rp;
129 Crystal2.Set(5,Crystal2.Get(4)); Crystal2.SetX(5,dx);
130 double gam2,gam3,Lp,Rpp;
131 t1=pre.Get(3)-Crystal2.Get(3);
132 t2=O3-Crystal2.Get(3);
133 gam2=acos(t1*t2/(t1.mag()*t2.mag()));
134 gam3=acos(cos_gamma)-gam2;
135 Lp=fBarrelL/cos(gam3);
136 dz=Lp*cos(gam2);
137 dy=Lp*sin(gam2);
138 Crystal2.Set(7,Crystal2.Get(3)); Crystal2.SetZ(7,Crystal2.Get(3).z()+dz);
139 Crystal2.SetY(7,Crystal2.Get(3).y()+dy);
140 Rpp=R1/sin(gam2);
141 dx=a*(Rpp+Lp)/Rpp;
142 Crystal2.Set(6,Crystal2.Get(7)); Crystal2.SetX(6,dx);
143
144 fStandard.push_back(Crystal2);
145
146 // No. 3 -- No. 22 theta: 19-0; phi: 30
147 for(int i=3; i<=fBarrelNThetaMax; i++) {
148 pre=fStandard[i-2];
149
150 if(i<fBarrelNThetaMax) {
151 L=fBarrelL;
152 h=fBarrelh2;
153 }
154 else {
155 L=fBarrelL2;
156 h=fBarrelh3;
157 }
158
159 tan_gamma=R1/(pre.Get(3).z()-fBarrelOffset2);
160 sin_gamma=tan_gamma/(sqrt(1+tan_gamma*tan_gamma));
161 cos_gamma=1/(sqrt(1+tan_gamma*tan_gamma));
162
163 aa=h/sin_gamma;
164 bb=h/tan_gamma;
165
166 now.Set(3,pre.Get(3)); now.SetZ(3,pre.Get(3).z()+aa);
167 now.Set(0,pre.Get(3)); now.SetZ(0,pre.Get(3).z()+bb*cos_gamma);
168 now.SetY(0,pre.Get(3).y()+bb*sin_gamma);
169
170 now.Set(4,pre.Get(3)); now.SetZ(4,pre.Get(3).z()+(L+bb)*cos_gamma);
171 now.SetY(4,pre.Get(3).y()+(L+bb)*sin_gamma);
172
173 gam2=atan(R1/(now.Get(3).z()-fBarrelOffset2));
174 gam3=acos(cos_gamma)-gam2;
175
176 Lp=L/cos(gam3);
177 dz=Lp*cos(gam2);
178 dy=Lp*sin(gam2);
179
180 now.Set(7,now.Get(3)); now.SetZ(7,now.Get(3).z()+dz);
181 now.SetY(7,now.Get(3).y()+dy);
182
183 Rp=R1/sin_gamma;
184 dx=a*(Rp+bb)/Rp;
185 now.Set(1,now.Get(0)); now.SetX(1,dx);
186 dx=a*(Rp+bb+L)/Rp;
187 now.Set(5,now.Get(4)); now.SetX(5,dx);
188
189 now.Set(2,now.Get(3)); now.SetX(2,a);
190
191 Rpp=R1/sin(gam2);
192 dx=a*(Rpp+Lp)/Rpp;
193 now.Set(6,now.Get(7)); now.SetX(6,dx);
194
195 fStandard.push_back(now);
196 }
197
198// for(int i=1; i<=fBarrelNThetaMax; i++) {
199// cout<<endl;
200// cout<<"No. "<<i<<endl;
201// now=fStandard[i-1];
202// now.BarrelCheckout();
203// now.Dump();
204// }
205}
206
207void EmcRecBarrelGeo::Transform2Column1() // to theta: 21-0; phi: 0
208{
209 HepPoint3D O1(fBarrelR*sin(fBarrelAlpha/2),
210 fBarrelR*cos(fBarrelAlpha/2)-2*fBarrelR*sin(fBarrelAlpha/2)/tan(fBarrelAlpha),
211 0);
212
213 HepPoint3D R=fStandard[0].Get(5);
214 double phi=(R.rotateZ(fBarrelAlpha)+O1).phi();
215
216 for(int i=1; i<=fBarrelNThetaMax; i++) {
217 for(int m=0;m<8;m++)
218 {
219 fStandard[i-1].Type(EmcRecCrystal::SixPlane());
220 fStandard[i-1].Set(m,fStandard[i-1].Get(m).rotateZ(fBarrelAlpha));
221 fStandard[i-1].Set(m,fStandard[i-1].Get(m)+O1);
222 fStandard[i-1].Set(m,fStandard[i-1].Get(m).rotateZ(-phi));
223 }
224
225// cout<<endl;
226// cout<<"No. "<<i<<endl;
227// fStandard[i-1].BarrelCheckout();
228// fStandard[i-1].Dump();
229 }
230}
231
232void EmcRecBarrelGeo::FillCCenterVector()
233{
234 int phi,theta;
235 EmcRecCrystal aCry;
236 HepPoint3D aCenter;
237 HepPoint3D aFrontCenter;
238
239 for(theta=0;theta<2*fBarrelNThetaMax;++theta) {
240 for(phi=0;phi<fBarrelNPhiMax;++phi) {
242 aCenter=aCry.Center();
243 aFrontCenter=aCry.FrontCenter();
244 fCCenter.push_back(aCenter);
245 fCFrontCenter.push_back(aFrontCenter);
246// aCry.Dump();
247// cout<<"("<<theta<<","<<phi<<") ";
248// cout<<aCenter<<endl;
249 }
250 }
251}
252
253
254// Access
256{
257 EmcRecCrystal cry;
258 unsigned int theta=EmcID::theta_module(id);
259 unsigned int phi=EmcID::phi_module(id);
260
261 double dphi=phi*fBarrelAlpha;
262
263 if((int)theta>=fBarrelNThetaMax) {
264 cry=fStandard[theta-fBarrelNThetaMax];
265 for(int m=0;m<8;++m)
266 {
267 cry.SetZ(m,-cry.Get(m).z());
268 }
269 }
270 else {
271 cry=fStandard[fBarrelNThetaMax-theta-1];
272 }
273
274 for(int m=0;m<8;++m)
275 {
276 cry.Set(m,cry.Get(m).rotateZ(dphi));
277 }
278
279 return cry;
280}
281
283{
284 unsigned int theta=EmcID::theta_module(id);
285 unsigned int phi=EmcID::phi_module(id);
286
287 return fCCenter[theta*fBarrelNPhiMax+phi];
288}
289
291{
292 unsigned int theta=EmcID::theta_module(id);
293 unsigned int phi=EmcID::phi_module(id);
294
295 return fCFrontCenter[theta*fBarrelNPhiMax+phi];
296}
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
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 getBARREL()
Definition: EmcID.cxx:146
static unsigned int theta_module(const Identifier &id)
Definition: EmcID.cxx:43
static unsigned int phi_module(const Identifier &id)
Definition: EmcID.cxx:48
EmcRecCrystal GetCrystal(const Identifier &id) const
HepPoint3D GetCFrontCenter(const Identifier &id) const
HepPoint3D GetCCenter(const Identifier &id) const
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)
Definition: TUtil.h:27