BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MucGeoStrip.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
14#include "MucGeomSvc/MucGeoGap.h"
15#include "MucGeomSvc/MucGeoStrip.h"
16#include "MucGeomSvc/MucGeometron.h"
17
18using namespace std;
19
20MucGeoStrip::MucGeoStrip( const int strip, MucGeoGap* const pGap )
21 : m_Strip( strip )
22 , m_pGap( pGap )
23 , m_pLeftNeighbor( 0L )
24 , m_pRightNeighbor( 0L )
25 , m_CenterPos( 0.0, 0.0, 0.0 )
26 , m_CenterSigma( 0.0, 0.0, 0.0 ) {
27 // Constructor (dummy strip position and sizes).
28}
29
31 // Destructor.
32 m_pLeftNeighbor = 0L;
33 m_pRightNeighbor = 0L;
34 m_pGap = 0L;
35}
36
37void MucGeoStrip::GetCenterPos( float& x, float& y, float& z ) const {
38 // Get center position of this strip (in the gap coordinate system).
39 x = m_CenterPos.x();
40 y = m_CenterPos.y();
41 z = m_CenterPos.z();
42
43 return;
44}
45
46void MucGeoStrip::GetCenterSigma( float& sx, float& sy, float& sz ) {
47 // Get uncertainty in the position of this strip (in the gap coordinate system).
48 sx = m_CenterSigma.x();
49 sy = m_CenterSigma.y();
50 sz = m_CenterSigma.z();
51
52 return;
53}
54
55void MucGeoStrip::SetStrip( const float x1, const float x2, const float y1, const float y2,
56 const float xSize, const float ySize, const float zSize ) {
57 // Set the edge, center and sigma of the strip (in the gap coordinate system).
58 double un = 1.0; // Uncertainty.
59
60 m_Xmin = x1;
61 m_Xmax = x2;
62 m_Ymin = y1;
63 m_Ymax = y2;
64 m_Zmin = -0.5 * zSize;
65 m_Zmax = 0.5 * zSize;
66
67 m_dzFarFrontGas = GetGap()->GetdzFarFrontGas();
68 m_dzNearFrontGas = GetGap()->GetdzNearFrontGas();
69 m_dzNearBackGas = GetGap()->GetdzNearBackGas();
70 m_dzFarBackGas = GetGap()->GetdzFarBackGas();
71
72 m_CenterPos.setX( 0.5 * ( m_Xmin + m_Xmax ) );
73 m_CenterPos.setY( 0.5 * ( m_Ymin + m_Ymax ) );
74 m_CenterPos.setZ( 0.0 );
75
76 m_CenterSigma.setX( un * xSize );
77 m_CenterSigma.setY( un * ySize );
78 m_CenterSigma.setZ( un * zSize );
79}
80
81void MucGeoStrip::SetStrip( TGeoPhysicalNode* stripPhysicalNode ) {
82 // Set the edge, center and sigma of the strip (in the gap coordinate system).
83 double un = 1.0; // Uncertainty.
84
85 TGeoBBox* stripBox = (TGeoBBox*)stripPhysicalNode->GetShape();
86
87 double xSize = 2.0 * stripBox->GetDX();
88 double ySize = 2.0 * stripBox->GetDY();
89 double zSize = 2.0 * stripBox->GetDZ();
90
91 m_dzFarFrontGas = GetGap()->GetdzFarFrontGas();
92 m_dzNearFrontGas = GetGap()->GetdzNearFrontGas();
93 m_dzNearBackGas = GetGap()->GetdzNearBackGas();
94 m_dzFarBackGas = GetGap()->GetdzFarBackGas();
95
96 double eTrans[3], *pTrans;
97 pTrans = eTrans;
98 // int level = stripPhysicalNode->GetLevel();
99 double eLocal[3], *pLocal;
100 pLocal = eLocal;
101 for ( int i = 0; i < 3; i++ ) pLocal[i] = 0.0;
102 stripPhysicalNode->GetNode()->LocalToMaster( pLocal, pTrans );
103
104 m_CenterPos.setX( pTrans[0] );
105 m_CenterPos.setY( pTrans[1] );
106 m_CenterPos.setZ( pTrans[2] );
107
108 m_Xmin = pTrans[0] - 0.5 * xSize;
109 m_Xmax = pTrans[0] + 0.5 * xSize;
110 m_Ymin = pTrans[1] - 0.5 * ySize;
111 m_Ymax = pTrans[1] + 0.5 * ySize;
112 m_Zmin = pTrans[2] - 0.5 * zSize;
113 m_Zmax = pTrans[2] + 0.5 * zSize;
114
115 m_CenterSigma.setX( un * xSize );
116 m_CenterSigma.setY( un * ySize );
117 m_CenterSigma.setZ( un * zSize );
118 // cout << m_CenterPos << endl;
119}
120
122 /// Set pointer to the adjacent strip on the -X or -Y side of this one.
123 // (0 if no neighbor in this gap).
124 if ( p ) m_pLeftNeighbor = p;
125}
126
128 /// Set pointer to the adjacent strip on the +X or +Y side of this one.
129 // (0 if no neighbor in this gap).
130 if ( p ) m_pRightNeighbor = p;
131}
132
133bool MucGeoStrip::IsInStrip( const float x, const float y, const float z ) const {
134 // Is the point within the boundaries of this strip?
135 return ( ( x > m_Xmin ) && ( x < m_Xmax ) && ( y > m_Ymin ) && ( y < m_Ymax ) &&
136 ( z >= m_dzFarFrontGas ) && ( z <= m_dzFarBackGas ) );
137}
138
140 const Hep3Vector lineDir ) const {
141 // Does the line cross this strip?
142
143 // We need to define the 6 planes then loop over to check for intersection.
144 // All are defined in the gap coordinate.
145 HepPlane3D stripSide[6];
146
147 // Xmin.
148 HepPoint3D p0Xmin( m_Xmin, m_Ymin, m_dzFarFrontGas );
149 HepPoint3D p1Xmin( m_Xmin, m_Ymax, m_dzFarFrontGas );
150 HepPoint3D p2Xmin( m_Xmin, m_Ymin, m_dzFarBackGas );
151 HepPlane3D plane0( p0Xmin, p1Xmin, p2Xmin );
152 stripSide[0] = plane0;
153
154 // Xmax.
155 HepPoint3D p0Xmax( m_Xmax, m_Ymin, m_dzFarFrontGas );
156 HepPoint3D p1Xmax( m_Xmax, m_Ymax, m_dzFarFrontGas );
157 HepPoint3D p2Xmax( m_Xmax, m_Ymin, m_dzFarBackGas );
158 HepPlane3D plane1( p0Xmax, p1Xmax, p2Xmax );
159 stripSide[1] = plane1;
160
161 // Ymin.
162 HepPoint3D p0Ymin( m_Xmin, m_Ymin, m_dzFarFrontGas );
163 HepPoint3D p1Ymin( m_Xmax, m_Ymin, m_dzFarFrontGas );
164 HepPoint3D p2Ymin( m_Xmin, m_Ymin, m_dzFarBackGas );
165 HepPlane3D plane2( p0Ymin, p1Ymin, p2Ymin );
166 stripSide[2] = plane2;
167
168 // Ymax.
169 HepPoint3D p0Ymax( m_Xmin, m_Ymax, m_dzFarFrontGas );
170 HepPoint3D p1Ymax( m_Xmax, m_Ymax, m_dzFarFrontGas );
171 HepPoint3D p2Ymax( m_Xmin, m_Ymax, m_dzFarBackGas );
172 HepPlane3D plane3( p0Ymax, p1Ymax, p2Ymax );
173 stripSide[3] = plane3;
174
175 // Zmin.
176 HepPoint3D p0Zmin( m_Xmin, m_Ymin, m_dzFarFrontGas );
177 HepPoint3D p1Zmin( m_Xmax, m_Ymin, m_dzFarFrontGas );
178 HepPoint3D p2Zmin( m_Xmin, m_Ymax, m_dzFarFrontGas );
179 HepPlane3D plane4( p0Zmin, p1Zmin, p2Zmin );
180 stripSide[4] = plane4;
181
182 // Zmax.
183 HepPoint3D p0Zmax( m_Xmin, m_Ymin, m_dzFarBackGas );
184 HepPoint3D p1Zmax( m_Xmax, m_Ymin, m_dzFarBackGas );
185 HepPoint3D p2Zmax( m_Xmin, m_Ymax, m_dzFarBackGas );
186 HepPlane3D plane5( p0Zmax, p1Zmax, p2Zmax );
187 stripSide[5] = plane5;
188
189 // cout << m_Xmin << " " << m_Xmax << endl
190 // << m_Ymin << " " << m_Ymax << endl
191 // << m_dzFarFrontGas << " " << m_dzFarBackGas << endl;
192
193 // If particle intersects this strip there should only be two crossings.
194 int numIntersections = 0;
195 MucGeometron geometron;
196 bool intersectFlag = 0;
197 HepPoint3D gCross( 0, 0, 0 );
198
199 for ( int sideID = 0; sideID < 6; sideID++ )
200 {
201 intersectFlag =
202 geometron.GetIntersectionLinePlane( linePoint, lineDir, stripSide[sideID], gCross );
203 if ( intersectFlag &&
204 ( gCross.x() >= m_Xmin - 1 ) && // expend strip size, to avoid gap between two strip
205 ( gCross.x() <= m_Xmax + 1 ) && ( gCross.y() >= m_Ymin - 1 ) &&
206 ( gCross.y() <= m_Ymax + 1 ) &&
207 ( ( gCross.z() >= m_dzFarFrontGas && gCross.z() <= m_dzNearFrontGas ) ||
208 ( gCross.z() >= m_dzNearBackGas && gCross.z() <= m_dzFarBackGas ) ) )
209 {
210 numIntersections++;
211 // cout << m_StripID.GetStrip() << gCross << endl;
212 }
213 }
214
215 // if( numIntersections == 1 ) {
216 // cout<<"MucGeoStrip::IntersectStrip(): Warning only one intersection. Should be two!" <<
217 // endl;
218 // }
219
220 if ( numIntersections > 2 )
221 {
222 // cout<<"MucGeoStrip::CrossGasChamber(): Warning too many intersections "
223 // << numIntersections
224 // << endl;
225 }
226
227 if ( numIntersections > 0 ) return true;
228
229 return false;
230}
HepGeom::Point3D< double > HepPoint3D
float GetdzNearFrontGas() const
Get m_dzNearFrontGas;.
void SetLeftNeighbor(MucGeoStrip *p)
Set pointer to the adjacent strip on the -X or -Y side of this one.
MucGeoStrip(const int strip, MucGeoGap *const pGap)
Default constructor.
bool CrossGasChamber(const HepPoint3D linePoint, const Hep3Vector lineDir) const
Does the line cross this strip?
void SetRightNeighbor(MucGeoStrip *p)
Set pointer to the adjacent strip on the +X or +Y side of this one.
MucGeoGap * GetGap() const
Get the pointer to the gap that contains the strip.
void GetCenterPos(float &x, float &y, float &z) const
Get center position of this strip (in the gap coordinate system).
void GetCenterSigma(float &sx, float &sy, float &sz)
Get uncertainty in the position of this strip (in the gap coordinate system).
~MucGeoStrip()
Desctructor.
bool IsInStrip(const float x, const float y, const float z) const
Is the point within the boundaries of this strip?
void SetStrip(const float x1, const float x2, const float y1, const float y2, const float xSize, const float ySize, const float zSize)
Set the edge, center and sigma of the strip (in the gap coordinate system).
bool GetIntersectionLinePlane(const HepPoint3D pLine, const Hep3Vector vectLine, const HepPlane3D plane, HepPoint3D &cross)
Get intersection of a line and a plane.