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