/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Muc/MucGeomSvc/MucGeomSvc-00-02-25/src/MucGeoStrip.cxx

Go to the documentation of this file.
00001 //$id$
00002 //
00003 //$log$
00004 
00005 /*
00006  *    2003/08/30   Zhengyun You     Peking University
00007  * 
00008  *    2004/09/09   Zhengyun You     Peking University
00009  *                 transplanted to Gaudi framework
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   // Constructor (dummy strip position and sizes).
00029 }
00030 
00031 MucGeoStrip::~MucGeoStrip()
00032 {
00033   // Destructor.
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   // Get center position of this strip (in the gap coordinate system).
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   // Get uncertainty in the position of this strip (in the gap coordinate system).
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   // Set the edge, center and sigma of the strip (in the gap coordinate system).
00069   double un = 1.0;  // Uncertainty.
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   // Set the edge, center and sigma of the strip (in the gap coordinate system).
00096   double un = 1.0;  // Uncertainty.
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   //int level = stripPhysicalNode->GetLevel();
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   //cout << m_CenterPos << endl;
00132 }
00133 
00134 void 
00135 MucGeoStrip::SetLeftNeighbor(MucGeoStrip* p)
00136 {
00138   // (0 if no neighbor in this gap).
00139   if (p)
00140     m_pLeftNeighbor = p;
00141 }
00142 
00143 void 
00144 MucGeoStrip::SetRightNeighbor(MucGeoStrip* p)
00145 {
00147   // (0 if no neighbor in this gap).
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   // Is the point within the boundaries of this strip?
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   // Does the line cross this strip?
00170 
00171   // We need to define the 6 planes then loop over to check for intersection.
00172   // All are defined in the gap coordinate.
00173   HepPlane3D stripSide[6];
00174 
00175   // Xmin.
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   // Xmax.
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   // Ymin.
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   // Ymax.
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   // Zmin.
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   // Zmax.
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   //cout << m_Xmin << "  " << m_Xmax << endl
00218   //   << m_Ymin << "  " << m_Ymax << endl
00219   //   << m_dzFarFrontGas << "  " << m_dzFarBackGas << endl;
00220     
00221   //If particle intersects this strip there should only be two crossings.
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) &&  // expend strip size, to avoid gap between two strip
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       //cout << m_StripID.GetStrip() << gCross << endl;
00242     }
00243   }
00244 
00245   //if( numIntersections == 1 ) {
00246   //  cout<<"MucGeoStrip::IntersectStrip(): Warning only one intersection.  Should be two!" << endl;
00247   //}
00248   
00249   if( numIntersections > 2 ) {
00250 //    cout<<"MucGeoStrip::CrossGasChamber(): Warning too many intersections " 
00251 //      << numIntersections 
00252 //      << endl;
00253   }
00254 
00255   if( numIntersections > 0 ) return true;
00256   
00257   return false;
00258 }
00259 

Generated on Tue Nov 29 23:12:57 2016 for BOSS_7.0.2 by  doxygen 1.4.7