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