Commit in lcdd/src on MAIN
G4GridXYZSegmentation.cc+110-1091.4 -> 1.5
fix global/local bug in GridXYZ segmentation; indentation; remove some unused debugging code

lcdd/src
G4GridXYZSegmentation.cc 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- G4GridXYZSegmentation.cc	1 Apr 2008 19:52:47 -0000	1.4
+++ G4GridXYZSegmentation.cc	9 Sep 2009 00:35:04 -0000	1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4GridXYZSegmentation.cc,v 1.4 2008/04/01 19:52:47 wenzel Exp $
+// $Header: /cvs/lcd/lcdd/src/G4GridXYZSegmentation.cc,v 1.5 2009/09/09 00:35:04 jeremy Exp $
 #include "G4GridXYZSegmentation.hh"
 
 #include "ReadoutUtil.hh"
@@ -6,14 +6,14 @@
 #include "G4NavigationHistory.hh"
 
 G4GridXYZSegmentation::G4GridXYZSegmentation(double gridSizeX,
-					     double gridSizeY,
-					     double gridSizeZ )
-  : G4Segmentation(G4Segmentation::eNonprojective),
-    m_gridSizeX(gridSizeX),
-    m_gridSizeY(gridSizeY),
-    m_gridSizeZ(gridSizeZ)
+                                             double gridSizeY,
+                                             double gridSizeZ )
+    : G4Segmentation(G4Segmentation::eNonprojective),
+      m_gridSizeX(gridSizeX),
+      m_gridSizeY(gridSizeY),
+      m_gridSizeZ(gridSizeZ)
 {
-  setBinNames();
+    setBinNames();
 }
 
 G4GridXYZSegmentation::~G4GridXYZSegmentation()
@@ -21,154 +21,155 @@
 
 G4ThreeVector G4GridXYZSegmentation::getLocalHitPos(const G4ThreeVector& localStepPos)
 {
-  //G4cout << "G4GridXYZSegmentation::getHitPos(..)" << G4endl;
+    G4ThreeVector localHitPos;
 
-  G4ThreeVector localHitPos;
+    if (m_gridSizeX > 0) {    
+        localHitPos.setX( computeDimX( computeBinX( localStepPos ) ) );
+    }
 
-  if (m_gridSizeX > 0) {    
-    localHitPos.setX( computeDimX( computeBinX( localStepPos ) ) );
-  }
+    if (m_gridSizeY > 0) {
+        localHitPos.setY( computeDimY( computeBinY( localStepPos ) ) );
+    }
 
-  if (m_gridSizeY > 0) {
-    localHitPos.setY( computeDimY( computeBinY( localStepPos ) ) );
-  }
+    if (m_gridSizeZ > 0) {
+        localHitPos.setZ( computeDimZ( computeBinZ( localStepPos ) ) );
+    }
 
-  if (m_gridSizeZ > 0) {
-    localHitPos.setZ( computeDimZ( computeBinZ( localStepPos ) ) );
-  }
-
-  return localHitPos;
+    return localHitPos;
 }
 
 G4ThreeVector G4GridXYZSegmentation::getGlobalHitPos(const G4Step* aStep)
 {  
-  //G4cout << "G4GridXYZSegmentation::getGlobalHitPos()" << G4endl;
-
-  // compute midpoint
-  G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos( aStep );
+    // compute midpoint
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos( aStep );
 
-  // figure local step pos using touchable and global midpoint
-  G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal( aStep, globalStepPos );
+    // figure local step pos using touchable and global midpoint
+    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal( aStep, globalStepPos );
 
-  // local cell pos
-  G4ThreeVector localCellPos = this->getLocalHitPos( localStepPos );
+    // local cell pos
+    G4ThreeVector localCellPos = this->getLocalHitPos( localStepPos );
    
-  // global cell pos
-  G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal( aStep, localCellPos );
+    // global cell pos
+    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal( aStep, localCellPos );
 
-  return globalCellPos;
+    return globalCellPos;
 }
+
 G4ThreeVector G4GridXYZSegmentation::getGlobalHitPos(const G4StepPoint* aPreStepPoint)
 {  
-  G4ThreeVector globalStepPos =  aPreStepPoint->GetPosition();
-  // figure local step pos using touchable and global midpoint
-  G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint,globalStepPos);
+    G4ThreeVector globalStepPos =  aPreStepPoint->GetPosition();
+    // figure local step pos using touchable and global midpoint
+    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal(aPreStepPoint,globalStepPos);
 
-  // local cell pos
-  G4ThreeVector localCellPos = this->getLocalHitPos( localStepPos );
+    // local cell pos
+    G4ThreeVector localCellPos = this->getLocalHitPos( localStepPos );
    
-  // global cell pos
-  G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal( aPreStepPoint, localCellPos );
+    // global cell pos
+    G4ThreeVector globalCellPos = ReadoutUtil::transformLocalToGlobal( aPreStepPoint, localCellPos );
 
-  return globalCellPos;
+    return globalCellPos;
 }
 
 void G4GridXYZSegmentation::setBins(const G4Step* aStep)
 {
-  G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos( aStep );
+    // Compute the midpoint of the step.
+    G4ThreeVector globalStepPos = ReadoutUtil::computeMidPos( aStep );
+
+    // Transform from global coordinate system to local coordinate system of volume pointed to by this step.
+    G4ThreeVector localStepPos = ReadoutUtil::transformGlobalToLocal( aStep, globalStepPos );
   
-  int binX = computeBinX( globalStepPos );
-  int binY = computeBinY( globalStepPos );
-  int binZ = computeBinZ( globalStepPos );
-
-  int idx=0;
-
-  //  if ( m_gridSizeX > 0 ) {
-  setBin( idx, binX );
-  ++idx;
-  //  }
-
-  //  if ( m_gridSizeY > 0 ) {
-  setBin( idx, binY );
-  ++idx;
-  //  }
-
-  //  if ( m_gridSizeZ > 0 ) {
-  setBin( idx, binZ );
-  ++idx;
-  //  }  
+    // Compute the bin values.
+    int binX = computeBinX( localStepPos );
+    int binY = computeBinY( localStepPos );
+    int binZ = computeBinZ( localStepPos );
+
+    // Set the bins.
+    int idx=0;
+
+    setBin( idx, binX );
+    ++idx;
+
+    setBin( idx, binY );
+    ++idx;
+
+    setBin( idx, binZ );
+    ++idx;
 }
+
+/*
 void G4GridXYZSegmentation::G4GridXYZSegmentation::setBins(const G4StepPoint* aPreStepPointconst)
 {
-  G4ThreeVector globalStepPos = aPreStepPointconst->GetPosition();
-  int binX = computeBinX( globalStepPos );
-  int binY = computeBinY( globalStepPos );
-  int binZ = computeBinZ( globalStepPos );
-
-  int idx=0;
-
-  //  if ( m_gridSizeX > 0 ) {
-  setBin( idx, binX );
-  ++idx;
-  //  }
-
-  //  if ( m_gridSizeY > 0 ) {
-  setBin( idx, binY );
-  ++idx;
-  //  }
-
-  //  if ( m_gridSizeZ > 0 ) {
-  setBin( idx, binZ );
-  ++idx;
-  //  }  
+    G4ThreeVector globalStepPos = aPreStepPointconst->GetPosition();
+    int binX = computeBinX( globalStepPos );
+    int binY = computeBinY( globalStepPos );
+    int binZ = computeBinZ( globalStepPos );
+
+    int idx=0;
+
+    //  if ( m_gridSizeX > 0 ) {
+    setBin( idx, binX );
+    ++idx;
+    //  }
+
+    //  if ( m_gridSizeY > 0 ) {
+    setBin( idx, binY );
+    ++idx;
+    //  }
+
+    //  if ( m_gridSizeZ > 0 ) {
+    setBin( idx, binZ );
+    ++idx;
+    //  }  
 }
+*/
+
 int G4GridXYZSegmentation::computeBinX(const G4ThreeVector& localStepPos)
 {
-  int ret;
-  if ( m_gridSizeX != 0 ) {
-    ret = G4Segmentation::computeBin(localStepPos.x(), m_gridSizeX);
-  }
-  else {
-    ret = 0;
-  }
-  return ret;
+    int ret;
+    if ( m_gridSizeX != 0 ) {
+        ret = G4Segmentation::computeBin(localStepPos.x(), m_gridSizeX);
+    }
+    else {
+        ret = 0;
+    }
+    return ret;
 }
 
 int G4GridXYZSegmentation::computeBinY(const G4ThreeVector& localStepPos)
 {
-  int ret;
-  if ( m_gridSizeY != 0 ) {
-    ret = G4Segmentation::computeBin(localStepPos.y(), m_gridSizeY);
-  }
-  else {
-    ret = 0;
-  }
-  return ret;
+    int ret;
+    if ( m_gridSizeY != 0 ) {
+        ret = G4Segmentation::computeBin(localStepPos.y(), m_gridSizeY);
+    }
+    else {
+        ret = 0;
+    }
+    return ret;
 }
 
 int G4GridXYZSegmentation::computeBinZ(const G4ThreeVector& localStepPos)
 {
-  int ret;
-  if ( m_gridSizeZ != 0 ) {
-    ret = G4Segmentation::computeBin(localStepPos.z(), m_gridSizeZ);
-  }
-  else {
-    ret = 0;
-  }
-  return ret;
+    int ret;
+    if ( m_gridSizeZ != 0 ) {
+        ret = G4Segmentation::computeBin(localStepPos.z(), m_gridSizeZ);
+    }
+    else {
+        ret = 0;
+    }
+    return ret;
 }
 
 double G4GridXYZSegmentation::computeDimX(int bin)
 {
-  return G4Segmentation::computeDim(bin, m_gridSizeX);
+    return G4Segmentation::computeDim(bin, m_gridSizeX);
 }
 
 double G4GridXYZSegmentation::computeDimY(int bin)
 {
-  return G4Segmentation::computeDim(bin, m_gridSizeY);
+    return G4Segmentation::computeDim(bin, m_gridSizeY);
 }
 
 double G4GridXYZSegmentation::computeDimZ(int bin)
 {
-  return G4Segmentation::computeDim(bin, m_gridSizeZ);
+    return G4Segmentation::computeDim(bin, m_gridSizeZ);
 }   
CVSspam 0.2.8