1 added + 1 removed + 6 modified, total 8 files
lcdd/include
diff -N RZBData.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ RZBData.hh 31 Aug 2005 18:30:00 -0000 1.1
@@ -0,0 +1,59 @@
+// $Header: /cvs/lcd/lcdd/include/RZBData.hh,v 1.1 2005/08/31 18:30:00 jeremy Exp $
+#ifndef RZBData_hh
+#define RZBData_hh 1
+
+/**
+ * @class RZBData
+ * @brief Represents a single row of a magnetic field defined by radius, z dimension, radial B-field strength, and z dimension B-field strength.
+ * @note Double values are multiplied by the field unit from the rz_field_map before they are inserted using this class.
+ */
+class RZBData
+{
+public:
+
+ /*
+ * @param r Radius
+ * @param z Z dimension
+ * @param Br Radial field strength
+ * @param Bz Z dimension field strength
+ */
+ RZBData(double r, double z, double Br, double Bz)
+ : _r(r),
+ _z(z),
+ _Br(Br),
+ _Bz(Bz)
+ {}
+
+ virtual ~RZBData()
+ {}
+
+public:
+
+ double r() const
+ {
+ return _r;
+ }
+
+ double z() const
+ {
+ return _z;
+ }
+
+ double Br() const
+ {
+ return _Br;
+ }
+
+ double Bz() const
+ {
+ return _Bz;
+ }
+
+private:
+ double _r;
+ double _z;
+ double _Br;
+ double _Bz;
+};
+
+#endif
lcdd/include
diff -u -r1.3 -r1.4
--- G4RZFieldMap.hh 31 Aug 2005 01:21:25 -0000 1.3
+++ G4RZFieldMap.hh 31 Aug 2005 18:29:59 -0000 1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/G4RZFieldMap.hh,v 1.3 2005/08/31 01:21:25 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/G4RZFieldMap.hh,v 1.4 2005/08/31 18:29:59 jeremy Exp $
#ifndef G4RZFieldMap_hh
#define G4RZFieldMap_hh 1
@@ -6,7 +6,7 @@
#include "G4MagneticField.hh"
// LCDD
-#include "G4RZB.hh"
+#include "RZBData.hh"
#include <iostream>
#include <vector>
@@ -17,24 +17,22 @@
*/
class G4RZFieldMap : public G4MagneticField
{
-public:
- typedef std::vector<G4RZB> RowsType;
public:
- G4RZFieldMap(double spanR, double gridSizeR, double spanZ, double gridSizeZ);
+ G4RZFieldMap(int numBinsR,
+ int numBinsZ,
+ double gridSizeR,
+ double gridSizeZ,
+ std::vector<RZBData> fieldData);
virtual ~G4RZFieldMap();
public:
-
void GetFieldValue( const double Point[3], double *Bfield ) const;
- void addRZB(double r, double z, double Br, double Bz);
- /*
- * Call once all RZB rows are added to make two arrays of [r][z] containg values for Br or Bz.
- * This should be much more performant than the vector of G4RZB objects.
- * @param clearRows Set to true in order to clear the G4RZB object vector. (Default is true.)
- */
- void makeArray(bool clearRows = true);
+private:
+ void initializeArrays();
+ void fillArrays(std::vector<RZBData> fieldData);
+ void deleteArrays();
private:
@@ -42,21 +40,14 @@
private:
- size_t m_numBinsR;
- size_t m_numBinsZ;
+ int m_numBinsR;
+ int m_numBinsZ;
- double m_spanR;
double m_gridSizeR;
-
- double m_spanZ;
- double m_halfSpanZ;
double m_gridSizeZ;
- RowsType m_rows;
-
double** m_BrArray;
double** m_BzArray;
- bool m_madeArray;
};
#endif
lcdd/include
diff -u -r1.2 -r1.3
--- RZFieldMapType.hh 31 Aug 2005 01:21:25 -0000 1.2
+++ RZFieldMapType.hh 31 Aug 2005 18:30:00 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/RZFieldMapType.hh,v 1.2 2005/08/31 01:21:25 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/RZFieldMapType.hh,v 1.3 2005/08/31 18:30:00 jeremy Exp $
#ifndef RZFieldMapType_hh
#define RZFieldMapType_hh 1
@@ -15,14 +15,14 @@
virtual ~RZFieldMapType()
{}
- void set_span_r(const std::string& span_r)
+ void set_num_bins_r(const std::string& num_bins_r)
{
- m_span_r = span_r;
+ m_num_bins_r = num_bins_r;
}
- const std::string& get_span_r() const
+ const std::string& get_num_bins_r() const
{
- return m_span_r;
+ return m_num_bins_r;
}
void set_grid_size_r(const std::string& grid_size_r)
@@ -35,14 +35,14 @@
return m_grid_size_r;
}
- void set_span_z(const std::string& span_z)
+ void set_num_bins_z(const std::string& num_bins_z)
{
- m_span_z = span_z;
+ m_num_bins_z = num_bins_z;
}
- const std::string& get_span_z() const
+ const std::string& get_num_bins_z() const
{
- return m_span_z;
+ return m_num_bins_z;
}
void set_grid_size_z(const std::string& grid_size_z)
@@ -56,9 +56,9 @@
}
private:
- std::string m_span_r;
+ std::string m_num_bins_r;
std::string m_grid_size_r;
- std::string m_span_z;
+ std::string m_num_bins_z;
std::string m_grid_size_z;
};
lcdd/include
diff -N G4RZB.hh
--- G4RZB.hh 30 Aug 2005 21:22:07 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-// $Header: /cvs/lcd/lcdd/include/Attic/G4RZB.hh,v 1.2 2005/08/30 21:22:07 jeremy Exp $
-#ifndef G4RZB_hh
-#define G4RZB_hh 1
-
-/**
- * @class G4RZB
- * @brief Represents a single row of a magnetic field defined by radius, z dimension, radial B-field strength, and z dimension B-field strength.
- * @note Double values are multiplied by the field unit from the rz_field_map before they are inserted using this class.
- */
-class G4RZB
-{
-public:
-
- /*
- * @param r Radius
- * @param z Z dimension
- * @param Br Radial field strength
- * @param Bz Z dimension field strength
- */
- G4RZB(double r, double z, double Br, double Bz)
- : _r(r),
- _z(z),
- _Br(Br),
- _Bz(Bz)
- {}
-
- virtual ~G4RZB()
- {}
-
-public:
-
- double r() const
- {
- return _r;
- }
-
- double z() const
- {
- return _z;
- }
-
- double Br() const
- {
- return _Br;
- }
-
- double Bz() const
- {
- return _Bz;
- }
-
-private:
- double _r;
- double _z;
- double _Br;
- double _Bz;
-};
-
-#endif
lcdd/schemas/lcdd/1.0
diff -u -r1.3 -r1.4
--- lcdd_fields.xsd 31 Aug 2005 01:21:26 -0000 1.3
+++ lcdd_fields.xsd 31 Aug 2005 18:30:00 -0000 1.4
@@ -101,9 +101,9 @@
<xs:sequence>
<xs:element name="rzB" type="RZBType" minOccurs="2" maxOccurs="unbounded" />
</xs:sequence>
- <xs:attribute name="span_r" type="xs:double" />
+ <xs:attribute name="num_bins_r" type="xs:integer" />
<xs:attribute name="grid_size_r" type="xs:double" />
- <xs:attribute name="span_z" type="xs:double" />
+ <xs:attribute name="num_bins_z" type="xs:integer" />
<xs:attribute name="grid_size_z" type="xs:double" />
</xs:extension>
</xs:complexContent>
lcdd/src
diff -u -r1.4 -r1.5
--- G4RZFieldMap.cc 31 Aug 2005 01:31:53 -0000 1.4
+++ G4RZFieldMap.cc 31 Aug 2005 18:30:01 -0000 1.5
@@ -1,64 +1,56 @@
-// $Header: /cvs/lcd/lcdd/src/G4RZFieldMap.cc,v 1.4 2005/08/31 01:31:53 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/G4RZFieldMap.cc,v 1.5 2005/08/31 18:30:01 jeremy Exp $
#include "G4RZFieldMap.hh"
#include "globals.hh"
#include <cmath>
-G4RZFieldMap::G4RZFieldMap(double spanR, double gridSizeR, double spanZ, double gridSizeZ)
- : m_numBinsR(0),
- m_numBinsZ(0),
- m_spanR(spanR),
+G4RZFieldMap::G4RZFieldMap(int numBinsR,
+ int numBinsZ,
+ double gridSizeR,
+ double gridSizeZ,
+ std::vector<RZBData> fieldData)
+ : m_numBinsR(numBinsR),
+ m_numBinsZ(numBinsZ),
m_gridSizeR(gridSizeR),
- m_spanZ(spanZ),
m_gridSizeZ(gridSizeZ),
m_BrArray(0),
- m_BzArray(0),
- m_madeArray(false)
+ m_BzArray(0)
{
- computeNumBins();
+ initializeArrays();
+ fillArrays(fieldData);
}
-G4RZFieldMap::~G4RZFieldMap()
-{
- /* delete the array */
- if ( m_madeArray ) {
- for (size_t i=0; i<m_numBinsR; i++) {
- delete[] m_BrArray[i];
- delete[] m_BzArray[i];
- }
- delete[] m_BrArray;
- delete[] m_BzArray;
- }
-}
-
-void G4RZFieldMap::computeNumBins()
+void G4RZFieldMap::fillArrays(std::vector<RZBData> fieldData)
{
- /* r bins */
- double rem = fmod( (float)m_spanR, (float)m_gridSizeR);
+ for ( std::vector<RZBData>::iterator iter = fieldData.begin();
+ iter != fieldData.end();
+ iter++ ) {
+ RZBData rzb = *iter;
- if ( rem != 0 ) {
- G4Exception("spanR is not evenly divisible by gridSizeR.");
- }
-
- m_numBinsR = (size_t)(m_spanR / m_gridSizeR);
-
- if ( m_numBinsR == 0 ) {
- G4Exception("numBinsR == 0");
- }
-
- /* z bins */
- rem = fmod( (float)m_spanZ, (float)m_gridSizeZ);
+ int iz= (int) ((rzb.z() + 0.0001)/m_gridSizeZ);
+ iz = iz;
+ int ir=(int) ((rzb.r() + 0.0001)/m_gridSizeR);
+ ir = ir;
- if ( rem != 0 ) {
- G4Exception("spanZ is not evenly disible by gridSizeZ.");
+ m_BzArray[iz][ir] = rzb.Br();
+ m_BrArray[iz][ir] = rzb.Bz();
}
+}
- m_numBinsZ = (size_t)(m_spanZ / m_gridSizeZ);
+G4RZFieldMap::~G4RZFieldMap()
+{
+ deleteArrays();
+}
- if ( m_numBinsZ == 0 ) {
- G4Exception("numBinsZ == 0");
+void G4RZFieldMap::deleteArrays()
+{
+ for (int i=0; i<m_numBinsR; i++) {
+ delete[] m_BrArray[i];
+ delete[] m_BzArray[i];
}
+ delete[] m_BrArray;
+ delete[] m_BzArray;
}
/*
@@ -68,175 +60,116 @@
*
* /afs/slac/www/accel/nlc/local/systems/beamdelivery/geant/SDNEW/solenoid.f
*
+ * via RZBFieldProvider.cpp test code provided by Norman.
+ *
*/
void G4RZFieldMap::GetFieldValue( const double Point[3], double *Bfield ) const
{
- std::cout << std::endl << "G4RZFieldMap::GetFieldValue" << std::endl;
- std::cout << "Point = " << Point[0] << ", " << Point[1] << ", " << Point[2] << std::endl;
-
- double rcyl = sqrt( ( Point[0] * Point[0] ) + ( Point[1] * Point[1] ) );
+ double r = sqrt( ( Point[0] * Point[0] ) + ( Point[1] * Point[1] ) );
double z = Point[2];
- size_t binR = (int)floor( rcyl / m_gridSizeR );
- binR += 1;
+ double hz = 0;
+ double hr = 0;
- std::cout << "binR = " << binR << std::endl;
-
- if ( binR >= m_numBinsR ) {
- std::cerr << "OVERFLOW: binR > m_numBinsR - 1 ... RETURNING" << std::endl;
+ /* hard-coded max values??? */
+ if(fabs(z)>630.0 || r>660.0) {
+ hz = 0.0;
+ hr = 0.0;
return;
}
- size_t binZ = (size_t) floor( ( fabs(z) / m_gridSizeZ ) );
- binZ += 1;
-
- std::cout << "binZ = " << binZ << std::endl;
+ int iz = (int) ((fabs(z)+0.001)/m_gridSizeZ);
+ int ir = (int) ((r+0.001)/m_gridSizeR);
- if ( binZ >= m_numBinsZ ) {
- std::cerr << "OVERFLOW: binZ > m_numBinsZ - 1 ... SETTING binZ = m_numBinZ" << std::endl;
- binZ = m_numBinsZ;
+ std::cout << "dz " << m_gridSizeZ << " dr " << m_gridSizeR << std::endl;
+ std::cout << "z " << z << " r " << r << std::endl;
+ std::cout << "iz " << iz << " ir " << ir << std::endl;
+ iz = iz;
+ ir = ir;
+
+ // outside
+ if(iz<0 || ir>m_numBinsR) {
+ hz = 0.0;
+ hr = 0.0;
+ return;
}
- double brmin = m_BrArray[binR][binZ];
- double bzmin = m_BzArray[binR][binZ];
-
- double remR = (double) ( rcyl - ( (binR - 1) * m_gridSizeR ) );
- double brdz = (m_BrArray[binZ+1][binR] - brmin) / m_gridSizeZ;
- double brdr = (m_BrArray[binZ][binR+1] - brmin) / m_gridSizeR;
+ int izfar = 0;
+ if(iz>=m_numBinsZ) {
+ izfar = 1;
+ iz = m_numBinsZ;
+ }
- double remZ = (double) fabs(z) - ( (binZ - 1) * m_gridSizeZ );
- double bzdz = (m_BzArray[binZ+1][binR] - bzmin) / m_gridSizeZ;
- double bzdr = (m_BzArray[binZ][binR+1] - bzmin) / m_gridSizeR;
+ double bz0 = m_BzArray[iz][ir];
+ double br0 = m_BrArray[iz][ir];
- double bz = bzmin + bzdz * remZ + bzdr * remR;
- double br = brmin + brdz * remZ + brdr * remR;
+ //cout << "bz0 " << bz0 << " br0 " << br0 << endl;
- double theta = atan2(Point[1], Point[0]);
- double bx = br * cos(theta);
- double by = br * sin(theta);
+ double delz = 0.;
+ double delr = 0.;
- Bfield[0] = bx;
- Bfield[1] = by;
- Bfield[2] = bz;
+ double brdz = 0.;
+ double brdr = 0.;
- /* flip sign for negative z */
- if ( Point[2] < 0. ) {
- Bfield[2] = -Bfield[2];
+ if(r>0.0) {
+ delr = r - float(ir) * m_gridSizeR;
+ brdz = (m_BrArray[iz+1][ir]-br0)/m_gridSizeZ;
+ brdr = (m_BrArray[iz][ir+1]-br0)/m_gridSizeR;
+ std::cout << "br= " << m_BrArray[iz+1][ir] << " " << m_BrArray[iz][ir+1] << std::endl;
}
- // DEBUG: prints
- std::cout << "brmin = " << brmin << std::endl;
- std::cout << "bzmin = " << bzmin << std::endl;
- std::cout << "remR = " << remR << std::endl;
- std::cout << "brdz = " << brdz << std::endl;
- std::cout << "brdr = " << brdr << std::endl;
- std::cout << "bzdz = " << bzdz << std::endl;
- std::cout << "bzdr = " << bzdr << std::endl;
- std::cout << "bz = " << bz << std::endl;
- std::cout << "br = " << br << std::endl;
- std::cout << "Bfield = " << Bfield[0] << ", " << Bfield[1] << ", " << Bfield[2] << std::endl;
-}
-
-void G4RZFieldMap::addRZB(double r, double z, double Br, double Bz)
-{
- // std::cout << "adding --> r z Br Bz = " << r << " " << z << " " << Br << " " << Bz << std::endl;
- if ( !m_madeArray ) {
- m_rows.push_back(G4RZB(r, z, Br, Bz));
- }
- else {
- std::cerr << "ERROR: Additional m_rows not allowed once G4RZFieldMap::makeArray() has been called." << std::endl;
- }
-}
+ delz = fabs(z) - float(iz) * m_gridSizeZ;
-void G4RZFieldMap::makeArray(bool clearM_Rows)
-{
- if ( !m_madeArray ) {
+ //cout << " z " << z << " abs(z) " << abs(z) << " iz " << iz << endl;
+ //cout << " float(iz-1) " << float(iz-1) << " dz " << dz << endl;
+ //cout << " delz " << delz << endl;
- /* Make two 2D arrays of numBinsR x numBinsZ */
- m_BrArray = new double*[m_numBinsR];
- m_BzArray = new double*[m_numBinsR];
+ double bzdz = (m_BzArray[iz+1][ir]-bz0)/m_gridSizeZ;
+ double bzdr = (m_BzArray[iz][ir+1]-bz0)/m_gridSizeR;
- for (size_t i=0; i<m_numBinsR; i++) {
- m_BrArray[i] = new double[m_numBinsZ];
- m_BzArray[i] = new double[m_numBinsZ];
- }
+ //cout << "bz= " << bz[iz+1][ir] << " " << bz[iz][ir+1] << endl;
- /* Init arrays to all 0's */
- for ( size_t i=0; i<m_numBinsR; i++) {
- for ( size_t j=0; j<m_numBinsZ; j++) {
- m_BrArray[i][j]=0;
- m_BzArray[i][j]=0;
- }
- }
+ if(izfar==1) {
+ hz = bz0+bzdr*delr;
+ hr = br0+brdr*delr;
+ }
+ else {
+ hz = bz0+bzdz*delz+bzdr*delr;
+ hr = br0+brdz*delz+brdr*delr;
+ }
- /* Fill arrays with values from object vector. */
- size_t binR = 0;
- size_t binZ = 0;
- for ( RowsType::const_iterator iter = m_rows.begin();
- iter != m_rows.end();
- iter++ ) {
-
- /* Compute the r bin. */
- binR = (size_t) floor( (*iter).r() / m_gridSizeR );
-
- double r = (*iter).r();
- if ( r == m_spanR ) {
- binR -= 1;
- }
- else if ( r > m_spanR ) {
- G4Exception("r value is > spanR");
- }
-
- std::cout << std::endl;
- std::cout << "r = " << (*iter).r() << std::endl;
- std::cout << "binR = " << binR << std::endl;
-
- /* r overflow? */
- if ( binR > ( m_numBinsR - 1 ) ) {
- G4Exception("OVERFLOW: R bin > numBinsR - 1");
- }
-
- /*
- * Compute z bin, normalized to positive value.
- * Forces z symmetry w.r.t. the +/- z halves.
- */
- double z = fabs((*iter).z());
- binZ = (size_t) floor( z / m_gridSizeZ );
-
- /* If Z value is equal to spanZ, set to last z bin. */
- if (z == m_spanZ) {
- binZ -= 1;
- }
- else if ( z > m_spanZ ) {
- G4Exception("z value is > spanZ");
- }
-
- std::cout << "z = " << z << std::endl;
- std::cout << "binZ = " << binZ << std::endl;
-
- /* z overflow? */
- if ( binZ > ( m_numBinsZ - 1) ) {
- G4Exception("OVERFLOW: Z bin > numBinsZ - 1");
- }
+ if(z<0.0) hr = -hr;
- /* Assign Bz and Br array values. */
- std::cout << "setting r,z bins = " << binR << ", " << binZ << std::endl;
+ double theta = atan2(Point[1], Point[0]);
+ double hx = hr * cos(theta);
+ double hy = hr * sin(theta);
- m_BrArray[binR][binZ] = (*iter).Bz();
- m_BzArray[binR][binZ] = (*iter).Br();
+ Bfield[0] = hx;
+ Bfield[1] = hy;
+ Bfield[2] = hz;
- std::cout << "br[r][z] = " << m_BrArray[binR][binZ] << std::endl;
- std::cout << "br[r][z] = " << m_BzArray[binR][binZ] << std::endl;
- }
+ /* flip sign for negative z */
+ if ( Point[2] < 0. ) {
+ Bfield[2] = -Bfield[2];
+ }
+}
- /* clear object vector m_rows */
- if ( clearM_Rows ) {
- m_rows.clear();
+void G4RZFieldMap::initializeArrays()
+{
+ /* Make two 2D arrays of numBinsR x numBinsZ */
+ m_BrArray = new double*[m_numBinsR];
+ m_BzArray = new double*[m_numBinsR];
+
+ for (int i=0; i<m_numBinsR; i++) {
+ m_BrArray[i] = new double[m_numBinsZ];
+ m_BzArray[i] = new double[m_numBinsZ];
+ }
+
+ /* Init arrays to all 0's */
+ for ( int i=0; i<m_numBinsR; i++) {
+ for ( int j=0; j<m_numBinsZ; j++) {
+ m_BrArray[i][j]=0;
+ m_BzArray[i][j]=0;
}
-
- m_madeArray = true;
- }
- else {
- std::cerr << "WARNING: Ignoring additional call to G4RZFieldMap::makeArray()." << std::endl;
}
}
lcdd/src
diff -u -r1.2 -r1.3
--- rz_field_mapProcess.cc 31 Aug 2005 01:21:26 -0000 1.2
+++ rz_field_mapProcess.cc 31 Aug 2005 18:30:01 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/rz_field_mapProcess.cc,v 1.2 2005/08/31 01:21:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/rz_field_mapProcess.cc,v 1.3 2005/08/31 18:30:01 jeremy Exp $
#include "FieldMapTypeProcess.hh"
#include "rz_field_map.hh"
#include <iostream>
@@ -27,9 +27,9 @@
rz_field_map* rzmap = new rz_field_map;
/* set attributes */
- rzmap->set_span_r(attrs.getValue("span_r"));
+ rzmap->set_num_bins_r(attrs.getValue("num_bins_r"));
rzmap->set_grid_size_r(attrs.getValue("grid_size_r"));
- rzmap->set_span_z(attrs.getValue("span_z"));
+ rzmap->set_num_bins_z(attrs.getValue("num_bins_z"));
rzmap->set_grid_size_z(attrs.getValue("grid_size_z"));
/* Top-level caller needs to setup the SAXObject references. */
lcdd/src
diff -u -r1.3 -r1.4
--- rz_field_mapSubscriber.cc 31 Aug 2005 01:21:26 -0000 1.3
+++ rz_field_mapSubscriber.cc 31 Aug 2005 18:30:01 -0000 1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/rz_field_mapSubscriber.cc,v 1.3 2005/08/31 01:21:26 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/rz_field_mapSubscriber.cc,v 1.4 2005/08/31 18:30:01 jeremy Exp $
#include "Saxana/SAXSubscriber.h"
#include "Saxana/SAXComponentFactory.h"
@@ -48,38 +48,31 @@
std::string funit = obj->get_funit();
std::string name = obj->get_name();
- double spanR, gridSizeR, spanZ, gridSizeZ;
+ int numBinsR, numBinsZ;
+ double gridSizeR, gridSizeZ;
- std::string sval = obj->get_span_r();
- sval += "*" + lunit;
- spanR = calc->Eval(sval);
+ std::string sval = obj->get_num_bins_r();
+ numBinsR = (int)calc->Eval(sval);
+
+ sval = obj->get_num_bins_z();
+ numBinsZ = (int)calc->Eval(sval);
sval = obj->get_grid_size_r();
sval += "*" + lunit;
gridSizeR = calc->Eval(sval);
- sval = obj->get_span_z();
- sval += "*" + lunit;
- spanZ = calc->Eval(sval);
-
sval = obj->get_grid_size_z();
sval += "*" + lunit;
gridSizeZ = calc->Eval(sval);
- G4RZFieldMap* fmap = new G4RZFieldMap(spanR, gridSizeR, spanZ, gridSizeZ);
- LCDDProcessor::instance()->addMagneticField(name, fmap);
-
- /* add RZB rows */
+ /* Make list of RZB rows from content. */
const ContentSequence* seq = obj->get_content();
size_t count = seq->size();
-
- //std::cout << "count: " << count << std::endl;
+ std::vector<RZBData> fieldData;
for ( size_t i=0; i<count; i++ ) {
- //std::cout << "got childtag " << std::endl;
if ( seq->content(i).tag == "rzB" ) {
- //std::cout << "got rzB" << std::endl;
rzb* row = dynamic_cast<rzb*>(seq->content(i).object);
@@ -106,7 +99,7 @@
sval += "*" + funit;
double Bz = calc->Eval(sval);
- fmap->addRZB(r, z, Br, Bz);
+ fieldData.push_back(RZBData(r, z, Br, Bz));
}
else {
G4Exception("Failed cast to rzB.");
@@ -117,8 +110,8 @@
}
}
- /* Make an array for performance purposes, clearing the object vector. */
- fmap->makeArray();
+ G4RZFieldMap* fmap = new G4RZFieldMap(numBinsR, numBinsZ, gridSizeR, gridSizeZ, fieldData);
+ LCDDProcessor::instance()->addMagneticField(name, fmap);
}
else {
G4Exception("Failed cast to rz_field_map.");
CVSspam 0.2.8