BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MucGeoGap.cxx
Go to the documentation of this file.
1//$id$
2//
3//$log$
4
5/*
6 * 2003/08/30 Zhengyun You Peking University
7 *
8 * 2004/09/09 Zhengyun You Peking University
9 * transplanted to Gaudi framework
10 */
11
12#include "TGeoBBox.h"
13#include <iostream>
14#include <vector>
15
16#include "Identifier/MucID.h"
17#include "MucGeomSvc/MucConstant.h"
18#include "MucGeomSvc/MucGeoGap.h"
19#include "MucGeomSvc/MucGeoStrip.h"
20#include "MucGeomSvc/MucGeometron.h"
21
22using namespace std;
23
25 : m_Part( -1 )
26 , m_Seg( -1 )
27 , m_Gap( -1 )
28 , m_StripNum( -1 )
29 , m_XSize( -1.0 )
30 , m_YSize( -1.0 )
31 , m_ZSize( -1.0 ) {
32 // Default constructor.
33}
34
36 const int part, const int seg, const int gap, const int orient, const int stripNum,
37 const float xSize, const float ySize, const float zSize, const float xTarget1Global,
38 const float yTarget1Global, const float zTarget1Global, const float xTarget2Global,
39 const float yTarget2Global, const float zTarget2Global, const float xTarget3Global,
40 const float yTarget3Global, const float zTarget3Global, const float dzHighEdge,
41 const float dzFarFrontGas, const float dzNearFrontGas, const float dzNearBackGas,
42 const float dzFarBackGas, const float dxTarget1ToFiducial, const float dyTarget1ToFiducial,
43 const float dxFiducialToCenter, const float dyFiducialToCenter )
44 : m_Part( part )
45 , m_Seg( seg )
46 , m_Gap( gap )
47 , m_StripNum( stripNum )
48 , m_Orient( orient )
49 , m_XSize( xSize )
50 , m_YSize( ySize )
51 , m_ZSize( zSize )
52 , m_dzHighEdge( dzHighEdge )
53 , m_dzFarFrontGas( dzFarFrontGas )
54 , m_dzNearFrontGas( dzNearFrontGas )
55 , m_dzNearBackGas( dzNearBackGas )
56 , m_dzFarBackGas( dzFarBackGas )
57 , m_pMucGeoStrip( MucID::getStripNum( part, seg, gap ) ) {
58 // Real constructor (construct strips externally).
59
60 // v1Global, v2Global, v3Global are position vectors of the three survey targets in the
61 // Bes global coordinate system.
62 // cout << m_dzHighEdge << " " << m_dzFarFrontGas << " " << m_dzNearFrontGas << " " <<
63 // dzNearBackGas << " " << dzFarBackGas << endl;
64 Hep3Vector v1Global( xTarget1Global, yTarget1Global, zTarget1Global );
65 Hep3Vector v2Global( xTarget2Global, yTarget2Global, zTarget2Global );
66 Hep3Vector v3Global( xTarget3Global, yTarget3Global, zTarget3Global );
67
68 Hep3Vector v2To1Global = v1Global - v2Global;
69 Hep3Vector v3To1Global = v1Global - v3Global;
70
71 // v1Gap is the position vector of target1 in the gap coordinate system.
72 Hep3Vector v1Gap( dxTarget1ToFiducial + dxFiducialToCenter,
73 dyTarget1ToFiducial + dyFiducialToCenter, 0.0 );
74
75 // Make rotaiton and translation matrix.
76 Hep3Vector newX( 1, 0, 0 ), newY( 0, 1, 0 ), newZ( 0, 0, 1 );
77 HepRotation rotateGap( newX, newY, newZ );
78
79 if ( part == 1 )
80 {
81 newX = v2To1Global;
82 newX.setMag( 1.0 );
83 newY = v3To1Global;
84 newY.setMag( 1.0 );
85 newZ = newX.cross( newY );
86 }
87 if ( part != 1 )
88 {
89 newY = -1.0 * v2To1Global;
90 newY.setMag( 1.0 );
91 newZ = v3To1Global.cross( newY );
92 newZ.setMag( 1.0 );
93 newX = newY.cross( newZ );
94 }
95
96 HepRotation rotateGlobal( newX, newY, newZ );
97 HepRotation rotateGapToGlobal( rotateGlobal * rotateGap );
98
99 Hep3Vector translateGapToGlobal( v1Global - rotateGapToGlobal * v1Gap );
100
101 m_Rotation = rotateGapToGlobal;
102 m_Translation = translateGapToGlobal;
103 m_Center = m_Translation;
104
105 // cout << " Rotation : " << endl << m_Rotation.xx() << " " << m_Rotation.xy() << " " <<
106 // m_Rotation.xz() << endl << m_Rotation.yx() << " " << m_Rotation.yy() << " " <<
107 // m_Rotation.yz() << endl << m_Rotation.zx() << " " << m_Rotation.zy() << " " <<
108 // m_Rotation.zz() << endl; cout << " Center : " << m_Center << endl;
109
110 HepMatrix rM( 3, 3 ), rMT( 3, 3 );
111 for ( int i = 0; i < 3; i++ )
112 {
113 for ( int j = 0; j < 3; j++ ) { rM[i][j] = m_Rotation( i, j ); }
114 }
115 rMT = rM.T();
116
117 Hep3Vector newXT( rMT( 1, 1 ), rMT( 2, 1 ), rMT( 3, 1 ) );
118 Hep3Vector newYT( rMT( 1, 2 ), rMT( 2, 2 ), rMT( 3, 2 ) );
119 Hep3Vector newZT( rMT( 1, 3 ), rMT( 2, 3 ), rMT( 3, 3 ) );
120 HepRotation rotateGlobalToGap( newXT, newYT, newZT );
121
122 m_RotationT = rotateGlobalToGap;
123}
124
125/// ROOT constructor.
126MucGeoGap::MucGeoGap( const int part, const int seg, const int gap, const int orient,
127 const int stripNum, const TGeoPhysicalNode* gapPhysicalNode,
128 const float ironThickness )
129 : m_Part( part )
130 , m_Seg( seg )
131 , m_Gap( gap )
132 , m_StripNum( stripNum )
133 , m_Orient( orient )
134 , m_pMucGeoStrip( MucID::getStripNum( part, seg, gap ) )
135 , m_IronThickness( ironThickness )
136
137{
138 TGeoBBox* gapBox = (TGeoBBox*)gapPhysicalNode->GetShape();
139
140 m_XSize = gapBox->GetDX() * 2.0;
141 m_YSize = gapBox->GetDY() * 2.0;
142 m_ZSize = gapBox->GetDZ() * 2.0;
143
144 m_dzHighEdge = 20.0;
145 m_dzFarFrontGas = -4.5;
146 m_dzNearFrontGas = -2.5;
147 m_dzNearBackGas = 2.5;
148 m_dzFarBackGas = 4.5;
149
150 double eRot[9], *pRot;
151 pRot = eRot;
152 pRot = gapPhysicalNode->GetMatrix()->GetRotationMatrix();
153
154 // cout << "part " << part << " seg " << seg << " gap " << gap << endl;
155 // cout << pRot[0] << " " << pRot[1] << " " << pRot[2] << endl
156 // << pRot[3] << " " << pRot[4] << " " << pRot[5] << endl
157 // << pRot[6] << " " << pRot[7] << " " << pRot[8] << endl;
158 Hep3Vector rotX( pRot[0], pRot[3], pRot[6] );
159 Hep3Vector rotY( pRot[1], pRot[4], pRot[7] );
160 Hep3Vector rotZ( pRot[2], pRot[5], pRot[8] );
161 HepRotation rotateGapToGlobal( rotX, rotY, rotZ );
162 m_Rotation = rotateGapToGlobal;
163
164 Hep3Vector rotTX( pRot[0], pRot[1], pRot[2] );
165 Hep3Vector rotTY( pRot[3], pRot[4], pRot[5] );
166 Hep3Vector rotTZ( pRot[6], pRot[7], pRot[8] );
167 HepRotation rotateGlobalToGap( rotTX, rotTY, rotTZ );
168 m_RotationT = rotateGlobalToGap;
169
170 double eTrans[3], *pTrans;
171 pTrans = eTrans;
172 pTrans = gapPhysicalNode->GetMatrix()->GetTranslation();
173
174 Hep3Vector translateGapToGlobal( pTrans[0], pTrans[1], pTrans[2] );
175 m_Translation = translateGapToGlobal;
176 m_Center = m_Translation;
177
178 double eTrans_gap[3], *pTrans_gap; // pTran is for box now!!!
179 pTrans_gap = eTrans_gap;
180 pTrans_gap = gapPhysicalNode->GetMatrix( 2 )->GetTranslation();
181 // std::cout <<"gap position: "<<pTrans_gap[0]<< " " << pTrans_gap[1] << " " << pTrans_gap[2]
182 // << std::endl;
183
184 Hep3Vector GapSurface1, GapSurface2;
185 Hep3Vector GapCenter( pTrans_gap[0], pTrans_gap[1], pTrans_gap[2] );
186 GapSurface1 = GapCenter - rotZ * 20; // Gap thickness/2= 20
187 GapSurface2 = GapCenter + rotZ * 20; // Gap thickness/2= 20
188
189 m_SurfaceInner = GapSurface1;
190 m_SurfaceOuter = GapSurface2;
191 if ( GapSurface1.mag() > GapSurface2.mag() ) // keep Inner be the little one
192 {
193 m_SurfaceInner = GapSurface2;
194 m_SurfaceOuter = GapSurface1;
195 }
196
197 // std::cout <<"sur1 position: "<<GapSurface1[0]<<" "<<GapSurface1[1]<<"
198 // "<<GapSurface1[2]<<std::endl;
199 // std::cout <<"sur2 position: "<<GapSurface2[0]<<" "<<GapSurface2[1]<<"
200 // "<<GapSurface2[2]<<std::endl; std::cout <<"box position: "<< pTrans[0] << " " <<
201 // pTrans[1] << " " << pTrans[2] << std::endl;
202}
203
205 // Assignment operator.
206 if ( this != &orig )
207 { // Watch out for self-assignment!
208 m_Part = orig.m_Part;
209 m_Seg = orig.m_Seg;
210 m_Gap = orig.m_Gap;
211 m_StripNum = orig.m_StripNum;
212 m_Orient = orig.m_Orient;
213 m_HitStatus = orig.m_HitStatus;
214
215 m_XSize = orig.m_XSize;
216 m_YSize = orig.m_YSize;
217 m_ZSize = orig.m_ZSize;
218
219 m_dzHighEdge = orig.m_dzHighEdge;
220 m_dzFarFrontGas = orig.m_dzFarFrontGas;
221 m_dzNearFrontGas = orig.m_dzNearFrontGas;
222 m_dzNearBackGas = orig.m_dzNearBackGas;
223 m_dzFarBackGas = orig.m_dzFarBackGas;
224
225 m_Center = orig.m_Center;
226 m_Rotation = orig.m_Rotation;
227 m_RotationT = orig.m_RotationT;
228 m_Translation = orig.m_Translation;
229
230 m_IronThickness = orig.m_IronThickness;
231
232 m_pMucGeoStrip = orig.m_pMucGeoStrip;
233 }
234 return *this;
235}
236
238 : m_Part( orig.m_Part )
239 , m_Seg( orig.m_Seg )
240 , m_Gap( orig.m_Gap )
241 , m_StripNum( orig.m_StripNum )
242 , m_Orient( orig.m_Orient )
243 , m_HitStatus( orig.m_HitStatus )
244 , m_XSize( orig.m_XSize )
245 , m_YSize( orig.m_YSize )
246 , m_ZSize( orig.m_ZSize )
247 , m_dzHighEdge( orig.m_dzHighEdge )
248 , m_dzFarFrontGas( orig.m_dzFarFrontGas )
249 , m_dzNearFrontGas( orig.m_dzNearFrontGas )
250 , m_dzNearBackGas( orig.m_dzNearBackGas )
251 , m_dzFarBackGas( orig.m_dzFarBackGas )
252 , m_Center( orig.m_Center )
253 , m_Rotation( orig.m_Rotation )
254 , m_RotationT( orig.m_RotationT )
255 , m_Translation( orig.m_Translation )
256 , m_IronThickness( orig.m_IronThickness ) {
257 // Copy constructor.
258 m_pMucGeoStrip = orig.m_pMucGeoStrip;
259}
260
262 // Destructor.
263 MucGeoStrip* pStrip = 0;
264 while ( m_pMucGeoStrip.size() > 0 )
265 {
266 pStrip = m_pMucGeoStrip.back();
267 delete pStrip;
268 m_pMucGeoStrip.pop_back();
269 }
270}
271
272MucGeoStrip* MucGeoGap::GetStrip( const int strip ) const {
273 // Point to a strip within this gap.
274 if ( strip < 0 || strip >= int( m_pMucGeoStrip.size() ) )
275 {
276 std::cout << "Error: MucGeoGap::GetStrip() strip " << strip << " exceed strip range"
277 << endl;
278 return 0;
279 }
280 if ( !m_pMucGeoStrip[strip] )
281 {
282 std::cout << "Error: MucGeoGap::GetStrip() strip " << strip << " not found" << endl;
283 return 0;
284 }
285
286 return m_pMucGeoStrip[strip];
287}
288
289void MucGeoGap::GetSize( float& xSize, float& ySize, float& zSize ) const {
290 // Get size of this gap.
291 xSize = m_XSize;
292 ySize = m_YSize;
293 zSize = m_ZSize;
294
295 return;
296}
297
298void MucGeoGap::GetRotationMatrix( float& thetaX, float& phiX, float& thetaY, float& phiY,
299 float& thetaZ, float& phiZ ) const {
300 // Get the rotation angles (in degrees) of the gap in the global coordinate system.
301 Hep3Vector x( m_Rotation.colX() );
302 Hep3Vector y( m_Rotation.colY() );
303 Hep3Vector z( m_Rotation.colZ() );
304
305 thetaX = kRad * x.theta();
306 phiX = kRad * x.phi();
307 thetaY = kRad * y.theta();
308 phiY = kRad * y.phi();
309 thetaZ = kRad * z.theta();
310 phiZ = kRad * z.phi();
311
312 // cout << "Gap rotation matrix : " << endl
313 // << "X: theta = " << thetaX << " phi = " << phiX << endl
314 // << "Y: theta = " << thetaY << " phi = " << phiY << endl
315 // << "Z: theta = " << thetaZ << " phi = " << phiZ << endl;
316
317 return;
318}
319
320int MucGeoGap::GuessStrip( const float x, const float y, const float ) const {
321 // Given a position (gap coordinate), find the approximate strip containing the position, as
322 // there are intervals between the strips.
323 float x0, y0, z0; // XYZ position of the strip NO min.
324 float xn, yn, zn; // XYZ position of the strip NO max.
325 float dx; // Approximate width of a strip and a interval.
326 int n, iGuess;
327
328 n = m_StripNum - 1;
329
330 GetStrip( 0 )->GetCenterPos( x0, y0, z0 );
331 GetStrip( n )->GetCenterPos( xn, yn, zn );
332
333 // cout << n << endl;
334 // cout << "x0 " << x0 << " xn " << xn << " x " << x << endl;
335 // cout << "y0 " << y0 << " yn " << yn << " y " << y << endl;
336 // cout << "orient " << m_Orient << endl;
337
338 if ( m_Orient == 0 )
339 {
340 dx = ( yn - y0 ) / n;
341 iGuess = int( ( y - y0 ) / dx + 0.5 );
342 return iGuess;
343 }
344 else
345 {
346 dx = ( xn - x0 ) / n;
347 iGuess = int( ( x - x0 ) / dx + 0.5 );
348 return iGuess;
349 }
350}
351
353 const Hep3Vector gDirection ) const {
354 // Given a line by basepoint gPoint and direction gDirection,
355 // find the intersection with the gap (in global coordinate).
356 Hep3Vector gapVect = m_Rotation.colZ();
357 HepPoint3D gCross( 0, 0, 0 );
358
359 HepPlane3D plane( gapVect, m_Center );
360 MucGeometron geometron;
361 // bool getPoint =
362 geometron.GetIntersectionLinePlane( gPoint, gDirection, plane, gCross );
363
364 return gCross;
365}
366
368 const HepPoint3D gPoint, const Hep3Vector gDirection, const HepPoint3D gPointSigma,
369 const Hep3Vector gDirectionSigma, HepPoint3D& gCross, HepPoint3D& gCrossSigma ) const {
370 Hep3Vector gapVect = m_Rotation.colZ();
371
372 HepPlane3D plane( gapVect, m_Center );
373 MucGeometron geometron;
374 geometron.GetIntersectionLinePlaneWithSigma( gPoint, gDirection, gPointSigma,
375 gDirectionSigma, plane, gCross, gCrossSigma );
376
377 return gCross;
378}
379
380void MucGeoGap::ProjectToGapSurface( const HepPoint3D gPoint, const Hep3Vector gDirection,
381 HepPoint3D& gCross1, HepPoint3D& gCross2 ) const {
382 // Given a line by basepoint gPoint and direction gDirection,
383 // find the intersection with the gap (in global coordinate).
384 Hep3Vector gapVect = m_Rotation.colZ();
385
386 HepPlane3D planeInner( gapVect, m_SurfaceInner );
387 HepPlane3D planeOuter( gapVect, m_SurfaceOuter );
388 MucGeometron geometron;
389 // bool getPoint =
390
391 geometron.GetIntersectionLinePlane( gPoint, gDirection, planeInner, gCross1 );
392 geometron.GetIntersectionLinePlane( gPoint, gDirection, planeOuter, gCross2 );
393}
394
395HepPoint3D MucGeoGap::ProjectToGapQuadLocal( const int part, // liangyt 2009.3.12
396 const int orient,
397 const float a, // y = ax*x + b*x +c;
398 const float b, const float c, const int whichhalf,
399 HepPoint3D& gCross1, HepPoint3D& gCross2 ) const {
400 Hep3Vector gapVect, center_local;
401 if ( part == 1 && orient == 1 )
402 {
403 gapVect = m_Rotation.colZ();
404 center_local = m_Center;
405 }
406 else if ( part == 1 && orient == 0 )
407 { // in this orientation, the fitting is done in local coordinate.
408 gapVect.setX( 0 );
409 gapVect.setY( 1 );
410 gapVect.setZ( 0 );
411 center_local.setX( 0 );
412 center_local.setY( m_Center.mag() );
413 center_local.setZ( 0 );
414 }
415 else
416 { // in this orientation, the fitting is done in local coordinate.
417 gapVect.setX( 1 );
418 gapVect.setY( 0 );
419 gapVect.setZ( 0 );
420 center_local.setX( m_Center.z() );
421 center_local.setY( 0 );
422 center_local.setZ( 0 );
423 }
424
425 // cout<<"in mucgeogap: part = "<<part<<" o: "<<orient<<" gapvect: "<<gapVect<<" center =
426 // "<<m_Center<<endl; cout<<"in mucgeogap: center local = "<<center_local<<endl;
427
428 HepPlane3D plane( gapVect, center_local );
429
430 MucGeometron geometron;
431 geometron.GetIntersectionQuadPlaneLocal( part, orient, a, b, c, plane, gCross1, gCross2 );
432
433 return HepPoint3D( 0, 0, 0 );
434}
435
436HepPoint3D MucGeoGap::ProjectToGap( const HepPoint3D gPoint, // liangyt 2007.4.9
437 const float vy, const float y0,
438 const float a, // y = ax*x + b*x +c;
439 const float b, const float c, const int whichhalf,
440 HepPoint3D& gCross1, HepPoint3D& gCross2 ) const {
441 // Given a line by basepoint gPoint and direction gDirection,
442 // find the intersection with the gap (in global coordinate).
443 Hep3Vector gapVect = m_Rotation.colZ();
444
445 HepPlane3D plane( gapVect, m_Center );
446 MucGeometron geometron;
447 // bool getPoint =
448 geometron.GetIntersectionQuadPlane( gPoint, vy, y0, a, b, c, plane, gCross1, gCross2 );
449
450 HepPoint3D localCross = TransformToGap( gCross1 );
451
452 bool found = false;
453 bool found1 = false;
454 bool found2 = false;
455 HepPoint3D temp;
456 int good = 0;
457
458 if ( IsInGap( localCross.x(), localCross.y(), localCross.z() ) )
459 {
460 good = 1;
461 found1 = true;
462 }
463
464 localCross = TransformToGap( gCross2 );
465 if ( IsInGap( localCross.x(), localCross.y(), localCross.z() ) )
466 {
467 good = 2;
468 found2 = true;
469 }
470 if ( found1 && found2 )
471 {
472 float center = b / ( -2 * a );
473 if ( whichhalf == 2 )
474 {
475 if ( gCross1.x() > center ) good = 1;
476 if ( gCross2.x() > center ) good = 2;
477 }
478 if ( whichhalf == 1 )
479 {
480 if ( gCross1.x() < center ) good = 1;
481 if ( gCross2.x() < center ) good = 2;
482 }
483 }
484 if ( good == 2 )
485 {
486 temp = gCross1;
487 gCross1 = gCross2;
488 gCross2 = temp;
489 } // keep gCross1 be the good one!
490 // cout<<"detail: "<<whichhalf<<" "<<gCross1<<" & "<<gCross2<<" "<<a<<" "<<b<<" "<<c<<endl;
491
492 return gCross1;
493}
494
495void MucGeoGap::ProjectToGapSurface( const HepPoint3D gPoint, // liangyt 2007.4.9
496 const float vy, const float y0,
497 const float a, // y = ax*x + b*x +c;
498 const float b, const float c, const int whichhalf,
499 HepPoint3D& gCross1, HepPoint3D& gCross2 ) const {
500 // Given a line by basepoint gPoint and direction gDirection,
501 // find the intersection with the gap (in global coordinate).
502
503 HepPoint3D cross1, cross2, cross3, cross4;
504
505 Hep3Vector gapVect = m_Rotation.colZ();
506
507 HepPlane3D planeInner( gapVect, m_SurfaceInner );
508 HepPlane3D planeOuter( gapVect, m_SurfaceOuter );
509
510 MucGeometron geometron;
511 // bool getPoint =
512 geometron.GetIntersectionQuadPlane( gPoint, vy, y0, a, b, c, planeInner, cross1, cross2 );
513 geometron.GetIntersectionQuadPlane( gPoint, vy, y0, a, b, c, planeOuter, cross3, cross4 );
514
515 gCross1 = CompareIntersection( whichhalf, cross1, cross2, a, b, c );
516 gCross2 = CompareIntersection( whichhalf, cross3, cross4, a, b, c );
517}
518
519HepPoint3D MucGeoGap::CompareIntersection( const int whichhalf, const HepPoint3D gCross1,
520 const HepPoint3D gCross2, const float a,
521 const float b, const float c ) const {
522 bool found = false;
523 bool found1 = false;
524 bool found2 = false;
525 int good = 0;
526
527 HepPoint3D localCross = TransformToGap( gCross1 );
528 if ( IsInGap( localCross.x(), localCross.y(), 0.0 ) )
529 {
530 good = 1;
531 found1 = true;
532 }
533
534 localCross = TransformToGap( gCross2 );
535 if ( IsInGap( localCross.x(), localCross.y(), 0.0 ) )
536 {
537 good = 2;
538 found2 = true;
539 }
540 if ( found1 && found2 )
541 {
542 float center = b / ( -2 * a );
543 if ( whichhalf == 2 )
544 {
545 if ( gCross1.x() > center ) good = 1;
546 if ( gCross2.x() > center ) good = 2;
547 }
548 if ( whichhalf == 1 )
549 {
550 if ( gCross1.x() < center ) good = 1;
551 if ( gCross2.x() < center ) good = 2;
552 }
553 }
554
555 if ( good == 1 ) return gCross1;
556 else if ( good == 2 ) return gCross2;
557 else
558 {
559 HepPoint3D Empty( -9999, -9999, -9999 );
560 cout << "in MucGeoGap:: both intersection position are bad!!!" << endl;
561 return Empty;
562 }
563}
564
565Hep3Vector MucGeoGap::RotateToGlobal( const Hep3Vector pVect ) const {
566 // Rotate a vector from gap coordinate to Bes global coordinate.
567 return m_Rotation * pVect;
568}
569
570Hep3Vector MucGeoGap::RotateToGap( const Hep3Vector gVect ) const {
571 // Rotate a vector from Bes global coordinate to gap coordinate.
572 return m_RotationT * gVect;
573}
574
576 // Transform a point from gap coordinate to Bes global coordinate.
577 return m_Rotation * pPoint + m_Translation;
578}
579
581 // Transform a point from Bes global coordinate to gap coordinate.
582 return m_RotationT * ( gPoint - m_Translation );
583}
584
585bool MucGeoGap::IsInGap( const float x, const float y, const float z ) const {
586 // Check if the point (given in gap coordinate) is within the gap boundary.
587 return ( ( x > -0.5 * m_XSize - kGapEdge ) && ( x < 0.5 * m_XSize + kGapEdge ) &&
588 ( y > -0.5 * m_YSize - kGapEdge ) && ( y < 0.5 * m_YSize + kGapEdge ) &&
589 ( z > ( m_dzHighEdge - m_ZSize ) ) && ( z < m_dzHighEdge ) );
590}
591
592MucGeoStrip* MucGeoGap::AddStrip( const int strip ) {
593 // Add a strip to the gap.
594 MucGeoStrip* pStrip;
595 MucGeoStrip* neighbor;
596
597 if ( strip >= int( m_pMucGeoStrip.size() ) )
598 {
599 cout << " MucGeoGap::AddStrip strip number " << strip << " outside of expected range "
600 << m_pMucGeoStrip.size() << endl;
601 return 0;
602 }
603
604 if ( ( strip + 1 ) > m_StripNum ) m_StripNum = strip + 1;
605
606 if ( m_pMucGeoStrip[strip] )
607 {
608 // The strip object has already been created; don't create a new one.
609 return m_pMucGeoStrip[strip];
610 }
611
612 pStrip = new MucGeoStrip( strip, this );
613
614 m_pMucGeoStrip[strip] = pStrip;
615 pStrip->SetLeftNeighbor( 0L );
616 pStrip->SetRightNeighbor( 0L );
617
618 // Make this strip and the previous one neighbors.
619 if ( strip > 0 )
620 {
621 neighbor = m_pMucGeoStrip[strip - 1];
622 if ( neighbor )
623 {
624 neighbor->SetRightNeighbor( pStrip );
625 pStrip->SetLeftNeighbor( neighbor );
626 }
627 }
628
629 return pStrip;
630}
631
632ostream& operator<<( ostream& s, const MucGeoGap& gap ) {
633 // float x0, y0, z0;
634 float dx, dy, dz;
635 HepPoint3D center;
636 center = gap.GetCenter();
637 gap.GetSize( dx, dy, dz );
638
639 s << " Identifier : " << gap.Part() << " " << gap.Seg() << " " << gap.Gap() << endl;
640 s << " Strip number " << gap.GetStripNum() << endl;
641 s << " Center position (" << center.x() << "," << center.y() << "," << center.z() << ")"
642 << endl;
643 s << " Size (" << dx << "," << dy << "," << dz << ")" << endl;
644
645 return s;
646}
const Double_t kRad
Definition BesTView.cxx:34
HepGeom::Point3D< double > HepPoint3D
const Int_t n
Double_t x[10]
XmlRpcServer s
ostream & operator<<(ostream &s, const MucGeoGap &gap)
HepGeom::Point3D< double > HepPoint3D
void GetSize(float &xSize, float &ySize, float &zSize) const
Get size of this gap.
HepPoint3D CompareIntersection(const int whichhalf, const HepPoint3D gCross1, const HepPoint3D gCross2, const float a, const float b, const float c) const
Hep3Vector RotateToGlobal(const Hep3Vector pVect) const
Rotate a vector from gap coordinate to global coordinate.
Hep3Vector RotateToGap(const Hep3Vector gVect) const
Rotate a vector from global coordinate to gap coordinate.
HepPoint3D TransformToGlobal(const HepPoint3D pPoint) const
Transform a point from gap coordinate to global coordinate.
MucGeoGap()
Default constructor.
Definition MucGeoGap.cxx:24
int GuessStrip(const float x, const float y, const float z) const
void ProjectToGapSurface(const HepPoint3D gPoint, const Hep3Vector gVect, HepPoint3D &cross1, HepPoint3D &cross2) const
Given a line, find the intersection with two surface of the gap in the global.
HepPoint3D GetCenter() const
Get gap center position in global coordinate.
HepPoint3D ProjectToGap(const HepPoint3D gPoint, const Hep3Vector gVect) const
Given a line, find the intersection with the gap in the global.
~MucGeoGap()
Desctructor.
MucGeoStrip * AddStrip(const int strip)
Add a strip to the gap.
int Part() const
Get part identifier (0,2 for cap, 1 for barrel).
void GetRotationMatrix(float &thetaX, float &phiX, float &thetaY, float &phiY, float &thetaZ, float &phiZ) const
Get the rotation angles (in degrees) of the gap in global coordinate.
HepPoint3D ProjectToGapWithSigma(const HepPoint3D gPoint, const Hep3Vector gVect, const HepPoint3D gPointSigma, const Hep3Vector gVectSigma, HepPoint3D &gCross, HepPoint3D &gCrossSigma) const
MucGeoGap & operator=(const MucGeoGap &orig)
Assignment constructor.
bool IsInGap(const float x, const float y, const float z) const
Check if the point (given in gap coordinate) is within the gap boundary.
HepPoint3D ProjectToGapQuadLocal(const int part, const int orient, const float a, const float b, const float c, const int whichhalf, HepPoint3D &cross1, HepPoint3D &cross2) const
HepPoint3D TransformToGap(const HepPoint3D gPoint) const
Transform a point from global coordinate to gap coordinate.
MucGeoStrip * GetStrip(const int strip) const
Point to a strip within this gap.
void SetLeftNeighbor(MucGeoStrip *p)
Set pointer to the adjacent strip on the -X or -Y side of this one.
void SetRightNeighbor(MucGeoStrip *p)
Set pointer to the adjacent strip on the +X or +Y side of this one.
void GetCenterPos(float &x, float &y, float &z) const
Get center position of this strip (in the gap coordinate system).
bool GetIntersectionQuadPlane(const HepPoint3D pLine, const float vy, const float y0, const float a, const float b, const float c, const HepPlane3D plane, HepPoint3D &cross1, HepPoint3D &cross2)
bool GetIntersectionLinePlane(const HepPoint3D pLine, const Hep3Vector vectLine, const HepPlane3D plane, HepPoint3D &cross)
Get intersection of a line and a plane.
bool GetIntersectionQuadPlaneLocal(const int part, const int orient, const float a, const float b, const float c, const HepPlane3D plane, HepPoint3D &cross1, HepPoint3D &cross2)
bool GetIntersectionLinePlaneWithSigma(const HepPoint3D pLine, const Hep3Vector vectLine, const HepPoint3D pLineSigma, const Hep3Vector vectLineSigma, const HepPlane3D plane, HepPoint3D &cross, HepPoint3D &crossSigma)