lcdd/src
diff -u -r1.26 -r1.27
--- G4CalorimeterSD.cc 31 Mar 2006 01:09:38 -0000 1.26
+++ G4CalorimeterSD.cc 8 Dec 2006 00:43:49 -0000 1.27
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4CalorimeterSD.cc,v 1.26 2006/03/31 01:09:38 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4CalorimeterSD.cc,v 1.27 2006/12/08 00:43:49 jeremy Exp $
#include "G4CalorimeterSD.hh"
// LCDD
@@ -97,7 +97,7 @@
// DEBUG: Compute step midpoint and compare to the cell pos
#ifdef G4DEBUG
#ifdef G4VERBOSE
- if ( verbose > 1 ) {
+ if ( getVerbose() > 1 ) {
G4ThreeVector globalMidPos = midPosition();
std::cout << "globalMidPos " << globalMidPos << std::endl;
std::cout << "globalCellPos - globalMidPos = " << globalCellPos - globalMidPos << std::endl;
lcdd/src
diff -u -r1.9 -r1.10
--- G4RZFieldMap.cc 21 Apr 2006 23:51:27 -0000 1.9
+++ G4RZFieldMap.cc 8 Dec 2006 00:43:49 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/G4RZFieldMap.cc,v 1.9 2006/04/21 23:51:27 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4RZFieldMap.cc,v 1.10 2006/12/08 00:43:49 jeremy Exp $
#include "G4RZFieldMap.hh"
#include "globals.hh"
@@ -26,6 +26,14 @@
m_BrArray(0),
m_BzArray(0)
{
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "numBinsR=" << numBinsR << endl;
+ cout << "numBinsZ=" << numBinsZ << endl;
+ cout << "gridSizeR=" << gridSizeR << endl;
+ cout << "gridSizeZ=" << gridSizeZ << endl;
+#endif
+
if ( numBinsR < 2 ) {
G4Exception("numBinsR must be >= 2");
}
@@ -51,7 +59,7 @@
void G4RZFieldMap::initializeArrays()
{
- /* Make two 2D arrays of numBinsZ x numBinsR */
+ // Make two 2D arrays of numBinsZ x numBinsR
m_BrArray = new double*[m_numBinsZ];
m_BzArray = new double*[m_numBinsZ];
@@ -60,7 +68,7 @@
m_BzArray[i] = new double[m_numBinsR];
}
- /* Init arrays to all 0's */
+ // Initialize arrays to all 0's.
for ( int i=0; i<m_numBinsZ; i++) {
for ( int j=0; j<m_numBinsR; j++) {
m_BrArray[i][j]=0;
@@ -129,7 +137,8 @@
double hz = 0;
double hr = 0;
- if(fabs(z)>m_maxZ || r>m_maxR) {
+ // Check for z or r out of range.
+ if(fabs(z) >= m_maxZ || r >= m_maxR) {
#ifdef FIELD_MAP_DEBUG
cout << "OUT OF RANGE: z r = " << fabs(z) << " " << r << endl;
cout << "MAX: maxZ maxR " << m_maxZ << " " << m_maxR << endl;
@@ -137,29 +146,54 @@
return;
}
+ // Compute z bin.
int iz = (int) ((fabs(z)+0.001)/m_gridSizeZ);
+
+ // Compute r bin.
int ir = (int) ((r+0.001)/m_gridSizeR);
+ // Adjust for iz out of range.
+// int izfar = 0;
+// if( iz >= m_numBinsZ-1 ) {
+// izfar = 1;
+// iz = m_numBinsZ - 1;
+// }
+
+ // Check for iz < 0.
+ if ( iz < 0 ) {
#ifdef FIELD_MAP_DEBUG
- cout << "dz " << m_gridSizeZ << " dr " << m_gridSizeR << endl;
- cout << "z " << z << " r " << r << endl;
- cout << "iz " << iz << " ir " << ir << endl;
+ cout << "ERROR: iz < 0" << endl;
+ cout << "iz=" << iz << endl;
+ cout << "returning" << endl;
#endif
+ }
- // outside
- if(iz<0 || ir>m_numBinsR) {
+// Check for Z overflow on iz+1.
+ if ( iz+1 >= m_numBinsZ ) {
#ifdef FIELD_MAP_DEBUG
- cout << "BIN OVERFLOW: iz ir = " << iz << " " << ir << endl;
+ cout << "ERROR: iz overflow" << endl;
+ cout << "iz=" << iz << endl;
+ cout << "returning" << endl;
#endif
return;
}
- int izfar = 0;
- if(iz>=m_numBinsZ) {
- izfar = 1;
- iz = m_numBinsZ;
+ // Check for R overflow on ir+1.
+ if ( ir+1 >= m_numBinsR ) {
+#ifdef FIELD_MAP_DEBUG
+ cout << "ERROR: ir overflow" << endl;
+ cout << "ir=" << ir << endl;
+ cout << "returning" << endl;
+#endif
+ return;
}
+#ifdef FIELD_MAP_DEBUG
+ cout << "dz " << m_gridSizeZ << " dr " << m_gridSizeR << endl;
+ cout << "z " << z << " r " << r << endl;
+ cout << "iz " << iz << " ir " << ir << endl;
+#endif
+
double bz0 = m_BzArray[iz][ir];
double br0 = m_BrArray[iz][ir];
@@ -175,6 +209,30 @@
if(r>0.0) {
delr = r - float(ir) * m_gridSizeR;
+
+#ifdef FIELD_MAP_DEBUG
+ if ( iz+1 == m_gridSizeZ-1 ) {
+ cout << "WARNING: iz+1 == gridSizeZ-1" << endl;
+ }
+
+ if ( ir+1 == m_gridSizeR-1 ) {
+ cout << "WARNING: ir+1 == gridSizeR-1" << endl;
+ }
+#endif
+
+#ifdef FIELD_MAP_DEBUG
+ cout << "checking brarray access ..." << endl;
+ cout << "iz+1=" << iz+1 << endl;
+ cout << "ir=" << ir << endl;
+ cout << m_BrArray[iz+1][ir] << endl;
+ cout << "m_BrArray[iz+1][ir] is ok" << endl;
+ cout << "iz=" << iz << endl;
+ cout << "ir+1=" << ir+1 << endl;
+ cout << m_BrArray[iz][ir+1] << endl;
+ cout << "m_BrArray[iz][ir+1] is ok" << endl;
+ cout << "done" << endl;
+#endif
+
brdz = (m_BrArray[iz+1][ir]-br0)/m_gridSizeZ;
brdr = (m_BrArray[iz][ir+1]-br0)/m_gridSizeR;
#ifdef FIELD_MAP_DEBUG
@@ -197,14 +255,14 @@
cout << "bz= " << m_BzArray[iz+1][ir] << " " << m_BzArray[iz][ir+1] << endl;
#endif
- if(izfar==1) {
- hz = bz0+bzdr*delr;
- hr = br0+brdr*delr;
- }
- else {
- hz = bz0+bzdz*delz+bzdr*delr;
- hr = br0+brdz*delz+brdr*delr;
- }
+// if(izfar==1) {
+// hz = bz0+bzdr*delr;
+// hr = br0+brdr*delr;
+// }
+// else {
+ hz = bz0+bzdz*delz+bzdr*delr;
+ hr = br0+brdz*delz+brdr*delr;
+// }
if(z<0.0) hr = -hr;