00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TGeoBBox.h"
00013
00014 #include "MucGeomSvc/MucGeoStrip.h"
00015 #include "MucGeomSvc/MucGeoGap.h"
00016 #include "MucGeomSvc/MucGeometron.h"
00017
00018 using namespace std;
00019
00020 MucGeoStrip::MucGeoStrip( const int strip, MucGeoGap* const pGap)
00021 : m_Strip(strip),
00022 m_pGap(pGap),
00023 m_pLeftNeighbor(0L),
00024 m_pRightNeighbor(0L),
00025 m_CenterPos(0.0,0.0,0.0),
00026 m_CenterSigma(0.0,0.0,0.0)
00027 {
00028
00029 }
00030
00031 MucGeoStrip::~MucGeoStrip()
00032 {
00033
00034 m_pLeftNeighbor = 0L;
00035 m_pRightNeighbor = 0L;
00036 m_pGap = 0L;
00037 }
00038
00039 void
00040 MucGeoStrip::GetCenterPos(float &x, float &y, float &z) const
00041 {
00042
00043 x = m_CenterPos.x();
00044 y = m_CenterPos.y();
00045 z = m_CenterPos.z();
00046
00047 return;
00048 }
00049
00050 void
00051 MucGeoStrip::GetCenterSigma(float &sx, float &sy, float &sz)
00052 {
00053
00054 sx = m_CenterSigma.x();
00055 sy = m_CenterSigma.y();
00056 sz = m_CenterSigma.z();
00057
00058 return;
00059 }
00060
00061 void
00062 MucGeoStrip::SetStrip(const float x1, const float x2,
00063 const float y1, const float y2,
00064 const float xSize,
00065 const float ySize,
00066 const float zSize)
00067 {
00068
00069 double un = 1.0;
00070
00071 m_Xmin = x1;
00072 m_Xmax = x2;
00073 m_Ymin = y1;
00074 m_Ymax = y2;
00075 m_Zmin = -0.5*zSize;
00076 m_Zmax = 0.5*zSize;
00077
00078 m_dzFarFrontGas = GetGap()->GetdzFarFrontGas();
00079 m_dzNearFrontGas = GetGap()->GetdzNearFrontGas();
00080 m_dzNearBackGas = GetGap()->GetdzNearBackGas();
00081 m_dzFarBackGas = GetGap()->GetdzFarBackGas();
00082
00083 m_CenterPos.setX(0.5*(m_Xmin + m_Xmax));
00084 m_CenterPos.setY(0.5*(m_Ymin + m_Ymax));
00085 m_CenterPos.setZ(0.0);
00086
00087 m_CenterSigma.setX(un*xSize);
00088 m_CenterSigma.setY(un*ySize);
00089 m_CenterSigma.setZ(un*zSize);
00090 }
00091
00092 void
00093 MucGeoStrip::SetStrip(TGeoPhysicalNode *stripPhysicalNode)
00094 {
00095
00096 double un = 1.0;
00097
00098 TGeoBBox *stripBox = (TGeoBBox*)stripPhysicalNode->GetShape();
00099
00100 double xSize = 2.0 * stripBox->GetDX();
00101 double ySize = 2.0 * stripBox->GetDY();
00102 double zSize = 2.0 * stripBox->GetDZ();
00103
00104 m_dzFarFrontGas = GetGap()->GetdzFarFrontGas();
00105 m_dzNearFrontGas = GetGap()->GetdzNearFrontGas();
00106 m_dzNearBackGas = GetGap()->GetdzNearBackGas();
00107 m_dzFarBackGas = GetGap()->GetdzFarBackGas();
00108
00109 double eTrans[3], *pTrans;
00110 pTrans = eTrans;
00111
00112 double eLocal[3], *pLocal;
00113 pLocal = eLocal;
00114 for (int i = 0; i < 3; i++) pLocal[i] = 0.0;
00115 stripPhysicalNode->GetNode()->LocalToMaster(pLocal, pTrans);
00116
00117 m_CenterPos.setX( pTrans[0] );
00118 m_CenterPos.setY( pTrans[1] );
00119 m_CenterPos.setZ( pTrans[2] );
00120
00121 m_Xmin = pTrans[0] - 0.5 * xSize;
00122 m_Xmax = pTrans[0] + 0.5 * xSize;
00123 m_Ymin = pTrans[1] - 0.5 * ySize;
00124 m_Ymax = pTrans[1] + 0.5 * ySize;
00125 m_Zmin = pTrans[2] - 0.5 * zSize;
00126 m_Zmax = pTrans[2] + 0.5 * zSize;
00127
00128 m_CenterSigma.setX(un*xSize);
00129 m_CenterSigma.setY(un*ySize);
00130 m_CenterSigma.setZ(un*zSize);
00131
00132 }
00133
00134 void
00135 MucGeoStrip::SetLeftNeighbor(MucGeoStrip* p)
00136 {
00138
00139 if (p)
00140 m_pLeftNeighbor = p;
00141 }
00142
00143 void
00144 MucGeoStrip::SetRightNeighbor(MucGeoStrip* p)
00145 {
00147
00148 if (p)
00149 m_pRightNeighbor = p;
00150 }
00151
00152 bool
00153 MucGeoStrip::IsInStrip(const float x,
00154 const float y,
00155 const float z) const
00156 {
00157
00158 return ( (x > m_Xmin) && (x < m_Xmax)
00159 && (y > m_Ymin) && (y < m_Ymax)
00160 && (z >= m_dzFarFrontGas)
00161 && (z <= m_dzFarBackGas) );
00162 }
00163
00164
00165 bool
00166 MucGeoStrip::CrossGasChamber(const HepPoint3D linePoint,
00167 const Hep3Vector lineDir) const
00168 {
00169
00170
00171
00172
00173 HepPlane3D stripSide[6];
00174
00175
00176 HepPoint3D p0Xmin(m_Xmin, m_Ymin, m_dzFarFrontGas);
00177 HepPoint3D p1Xmin(m_Xmin, m_Ymax, m_dzFarFrontGas);
00178 HepPoint3D p2Xmin(m_Xmin, m_Ymin, m_dzFarBackGas);
00179 HepPlane3D plane0(p0Xmin, p1Xmin, p2Xmin);
00180 stripSide[0] = plane0;
00181
00182
00183 HepPoint3D p0Xmax(m_Xmax, m_Ymin, m_dzFarFrontGas);
00184 HepPoint3D p1Xmax(m_Xmax, m_Ymax, m_dzFarFrontGas);
00185 HepPoint3D p2Xmax(m_Xmax, m_Ymin, m_dzFarBackGas);
00186 HepPlane3D plane1(p0Xmax, p1Xmax, p2Xmax);
00187 stripSide[1] = plane1;
00188
00189
00190 HepPoint3D p0Ymin(m_Xmin, m_Ymin, m_dzFarFrontGas);
00191 HepPoint3D p1Ymin(m_Xmax, m_Ymin, m_dzFarFrontGas);
00192 HepPoint3D p2Ymin(m_Xmin, m_Ymin, m_dzFarBackGas);
00193 HepPlane3D plane2(p0Ymin, p1Ymin, p2Ymin);
00194 stripSide[2] = plane2;
00195
00196
00197 HepPoint3D p0Ymax(m_Xmin, m_Ymax, m_dzFarFrontGas);
00198 HepPoint3D p1Ymax(m_Xmax, m_Ymax, m_dzFarFrontGas);
00199 HepPoint3D p2Ymax(m_Xmin, m_Ymax, m_dzFarBackGas);
00200 HepPlane3D plane3(p0Ymax, p1Ymax, p2Ymax);
00201 stripSide[3] = plane3;
00202
00203
00204 HepPoint3D p0Zmin(m_Xmin, m_Ymin, m_dzFarFrontGas);
00205 HepPoint3D p1Zmin(m_Xmax, m_Ymin, m_dzFarFrontGas);
00206 HepPoint3D p2Zmin(m_Xmin, m_Ymax, m_dzFarFrontGas);
00207 HepPlane3D plane4(p0Zmin, p1Zmin, p2Zmin);
00208 stripSide[4] = plane4;
00209
00210
00211 HepPoint3D p0Zmax(m_Xmin, m_Ymin, m_dzFarBackGas);
00212 HepPoint3D p1Zmax(m_Xmax, m_Ymin, m_dzFarBackGas);
00213 HepPoint3D p2Zmax(m_Xmin, m_Ymax, m_dzFarBackGas);
00214 HepPlane3D plane5(p0Zmax, p1Zmax, p2Zmax);
00215 stripSide[5] = plane5;
00216
00217
00218
00219
00220
00221
00222 int numIntersections = 0;
00223 MucGeometron geometron;
00224 bool intersectFlag = 0;
00225 HepPoint3D gCross(0,0,0);
00226
00227 for (int sideID = 0; sideID<6; sideID++)
00228 {
00229 intersectFlag = geometron.GetIntersectionLinePlane(linePoint,
00230 lineDir,
00231 stripSide[sideID],
00232 gCross);
00233 if( intersectFlag &&
00234 ( gCross.x() >= m_Xmin - 1) &&
00235 ( gCross.x() <= m_Xmax + 1) &&
00236 ( gCross.y() >= m_Ymin - 1) &&
00237 ( gCross.y() <= m_Ymax + 1) &&
00238 ( ( gCross.z() >= m_dzFarFrontGas && gCross.z() <= m_dzNearFrontGas ) ||
00239 ( gCross.z() >= m_dzNearBackGas && gCross.z() <= m_dzFarBackGas) ) ) {
00240 numIntersections++;
00241
00242 }
00243 }
00244
00245
00246
00247
00248
00249 if( numIntersections > 2 ) {
00250
00251
00252
00253 }
00254
00255 if( numIntersections > 0 ) return true;
00256
00257 return false;
00258 }
00259