12 added files
lcdd/include
diff -N FieldMapType.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FieldMapType.hh 29 Aug 2005 23:23:18 -0000 1.1
@@ -0,0 +1,44 @@
+// $Header: /cvs/lcd/lcdd/include/FieldMapType.hh,v 1.1 2005/08/29 23:23:18 jeremy Exp $
+#ifndef FieldMapType_hh
+#define FieldMapType_hh 1
+
+#include "FieldType.hh"
+
+// GDML
+#include "Schema/ContentGroup.h"
+#include "Schema/ReferenceType.h"
+
+/**
+ * @name FieldMapType
+ * @brief The "abstract" FieldMapType from lcdd_fields.xsd subschema.
+ * @note The only behavior implemented by this class is adding generic content.
+ */
+class FieldMapType : public FieldType
+{
+public:
+ FieldMapType()
+ {}
+
+ virtual ~FieldMapType()
+ {}
+
+public:
+
+ const ContentSequence* get_content() const
+ {
+ return &m_sequence;
+ }
+
+ void add_content(const std::string& tag, SAXObject* so)
+ {
+ ContentGroup::ContentItem ci = {tag, so};
+ m_sequence.add_content(ci);
+ }
+
+public:
+
+ ContentSequence m_sequence;
+
+};
+
+#endif
lcdd/include
diff -N FieldMapTypeProcess.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FieldMapTypeProcess.hh 29 Aug 2005 23:23:18 -0000 1.1
@@ -0,0 +1,62 @@
+// $Header: /cvs/lcd/lcdd/include/FieldMapTypeProcess.hh,v 1.1 2005/08/29 23:23:18 jeremy Exp $
+
+#ifndef FieldMapTypeProcess_hh
+#define FieldMapTypeProcess_hh 1
+
+#include "Saxana/ProcessingConfigurator.h"
+#include "Saxana/ProcessingContext.h"
+#include "Saxana/SAXProcessor.h"
+#include "Saxana/StateStack.h"
+#include "Saxana/SAXProcessingState.h"
+#include "Saxana/SAXStateProcess.h"
+#include "Saxana/SAXComponentFactory.h"
+
+#include "FieldType.hh"
+#include "FieldTypeProcess.hh"
+#include "FieldMapType.hh"
+
+#include <iostream>
+
+/**
+ * @class FieldMapTypeProcess
+ * @brief Generic process for field maps.
+ * @note This class adds generic content using StackPopNotify.
+*/
+class FieldMapTypeProcess : public FieldTypeProcess
+{
+public:
+ FieldMapTypeProcess( const ProcessingContext* context = 0)
+ : FieldTypeProcess(context)
+ {}
+
+ virtual ~FieldMapTypeProcess()
+ {}
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ /* NO-OP. Just call up the inheritance chain to FieldTypeProcess. */
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ // std::cout << "FieldMapTypeProcess::StartElement - " << name << std::endl;
+ FieldTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string&)
+ {}
+
+ virtual void Characters(const std::string&)
+ {}
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ // std::cout << "FieldMapTypeProcess::StackPopNotify" << std::endl;
+ SAXObject** so = Context()->GetTopObject();
+ FieldMapType* fmap = dynamic_cast<FieldMapType*>( m_obj );
+ fmap->add_content( name, *so);
+ }
+};
+
+#endif
lcdd/include
diff -N G4RZB.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4RZB.hh 29 Aug 2005 23:23:18 -0000 1.1
@@ -0,0 +1,59 @@
+// $Header: /cvs/lcd/lcdd/include/G4RZB.hh,v 1.1 2005/08/29 23:23:18 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()
+ {
+ return _r;
+ }
+
+ double z()
+ {
+ return _z;
+ }
+
+ double Br()
+ {
+ return _Br;
+ }
+
+ double Bz()
+ {
+ return _Bz;
+ }
+
+private:
+ double _r;
+ double _z;
+ double _Br;
+ double _Bz;
+};
+
+#endif
lcdd/include
diff -N G4RZFieldMap.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4RZFieldMap.hh 29 Aug 2005 23:23:18 -0000 1.1
@@ -0,0 +1,37 @@
+// $Header: /cvs/lcd/lcdd/include/G4RZFieldMap.hh,v 1.1 2005/08/29 23:23:18 jeremy Exp $
+
+#ifndef G4RZFieldMap_hh
+#define G4RZFieldMap_hh 1
+
+#include "G4MagneticField.hh"
+
+// LCDD
+#include "G4RZB.hh"
+
+#include <iostream>
+#include <vector>
+
+/**
+ * @class G4RZFieldMap
+ * @brief Magnetic field defined by rows of r, z, Br and Bz values.
+ */
+class G4RZFieldMap : public G4MagneticField
+{
+public:
+ typedef std::vector<G4RZB> RowsType;
+
+public:
+ G4RZFieldMap();
+ virtual ~G4RZFieldMap();
+
+public:
+
+ void GetFieldValue( const double Point[3], double *Bfield ) const;
+ void addRZB(double r, double z, double Br, double Bz);
+ const RowsType& getRows() const;
+
+private:
+ RowsType rows;
+};
+
+#endif
lcdd/include
diff -N RZBType.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ RZBType.hh 29 Aug 2005 23:23:18 -0000 1.1
@@ -0,0 +1,68 @@
+// $Header: /cvs/lcd/lcdd/include/RZBType.hh,v 1.1 2005/08/29 23:23:18 jeremy Exp $
+#ifndef RZBType_hh
+#define RZBType_hh 1
+
+#include <string>
+
+/**
+ * @class RZBType
+ * @brief The RZBType from lcdd_fields.xsd subschema.
+ */
+class RZBType
+{
+
+public:
+ RZBType()
+ {}
+
+ virtual ~RZBType()
+ {}
+
+ void set_r(const std::string& r)
+ {
+ m_r = r;
+ }
+
+ void set_z(const std::string& z)
+ {
+ m_z = z;
+ }
+
+ void set_Br(const std::string& Br)
+ {
+ m_Br = Br;
+ }
+
+ void set_Bz(const std::string& Bz)
+ {
+ m_Bz = Bz;
+ }
+
+ const std::string& get_r() const
+ {
+ return m_r;
+ }
+
+ const std::string& get_z() const
+ {
+ return m_z;
+ }
+
+ const std::string& get_Br() const
+ {
+ return m_Br;
+ }
+
+ const std::string& get_Bz() const
+ {
+ return m_Bz;
+ }
+
+public:
+ std::string m_r;
+ std::string m_z;
+ std::string m_Br;
+ std::string m_Bz;
+};
+
+#endif
lcdd/include
diff -N RZFieldMapType.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ RZFieldMapType.hh 29 Aug 2005 23:23:18 -0000 1.1
@@ -0,0 +1,17 @@
+// $Header: /cvs/lcd/lcdd/include/RZFieldMapType.hh,v 1.1 2005/08/29 23:23:18 jeremy Exp $
+#ifndef RZFieldMapType_hh
+#define RZFieldMapType_hh 1
+
+class RZFieldMapType : FieldMapType
+{
+
+public:
+
+ RZFieldMapType()
+ {}
+
+ virtual ~RZFieldMapType()
+ {}
+};
+
+#endif
lcdd/include
diff -N rz_field_map.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rz_field_map.hh 29 Aug 2005 23:23:19 -0000 1.1
@@ -0,0 +1,26 @@
+// $Header: /cvs/lcd/lcdd/include/rz_field_map.hh,v 1.1 2005/08/29 23:23:19 jeremy Exp $
+#ifndef rz_field_map_hh
+#define rz_field_map_hh 1
+
+#include "FieldMapType.hh"
+
+/**
+ * @class rz_field_map
+ * @brief The rz_field_map element from lcdd_fields.xsd subschema.
+ */
+class rz_field_map : public SAXObject, public FieldMapType
+{
+public:
+ rz_field_map()
+ {}
+
+ virtual ~rz_field_map()
+ {}
+
+ virtual SAXObject::Type type()
+ {
+ return SAXObject::element;
+ }
+};
+
+#endif
lcdd/include
diff -N rzb.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rzb.hh 29 Aug 2005 23:23:19 -0000 1.1
@@ -0,0 +1,28 @@
+// $Header: /cvs/lcd/lcdd/include/rzb.hh,v 1.1 2005/08/29 23:23:19 jeremy Exp $
+#ifndef rzb_hh
+#define rzb_hh 1
+
+#include "RZBType.hh"
+
+#include "Saxana/SAXObject.h"
+
+/**
+ * @class rzb
+ * @brief The rzB element from lcdd_fields.xsd subschema.
+ */
+class rzb : public SAXObject, public RZBType
+{
+public:
+ rzb()
+ {}
+
+ virtual ~rzb()
+ {}
+
+ virtual SAXObject::Type type()
+ {
+ return SAXObject::element;
+ }
+};
+
+#endif
lcdd/src
diff -N G4RZFieldMap.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4RZFieldMap.cc 29 Aug 2005 23:23:19 -0000 1.1
@@ -0,0 +1,27 @@
+// $Header: /cvs/lcd/lcdd/src/G4RZFieldMap.cc,v 1.1 2005/08/29 23:23:19 jeremy Exp $
+#include "G4RZFieldMap.hh"
+
+G4RZFieldMap::G4RZFieldMap()
+{}
+
+G4RZFieldMap::~G4RZFieldMap()
+{}
+
+/* FIXME: Needs implementation! (see Takashi's FORTRAN code) */
+void G4RZFieldMap::GetFieldValue( const double Point[3], double *Bfield ) const
+{
+ /* make compiler happy */
+ if ( Point[0] );
+ if ( Bfield );
+}
+
+void G4RZFieldMap::addRZB(double r, double z, double Br, double Bz)
+{
+ // std::cout << "adding --> r z Br Bz = " << r << " " << z << " " << Br << " " << Bz << std::endl;
+ rows.push_back(G4RZB(r, z, Br, Bz));
+}
+
+const G4RZFieldMap::RowsType& G4RZFieldMap::getRows() const
+{
+ return rows;
+}
lcdd/src
diff -N rz_field_mapProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rz_field_mapProcess.cc 29 Aug 2005 23:23:19 -0000 1.1
@@ -0,0 +1,62 @@
+// $Header: /cvs/lcd/lcdd/src/rz_field_mapProcess.cc,v 1.1 2005/08/29 23:23:19 jeremy Exp $
+#include "FieldMapTypeProcess.hh"
+#include "rz_field_map.hh"
+#include <iostream>
+#include "globals.hh"
+
+/**
+ * @class rz_field_map_Process
+ * @brief Processor for rz_field_map elements.
+ */
+class rz_field_mapProcess : public FieldMapTypeProcess
+{
+public:
+ rz_field_mapProcess(const ProcessingContext* context = 0)
+ : FieldMapTypeProcess(context)
+ {}
+
+ virtual ~rz_field_mapProcess()
+ {}
+
+ virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
+ {
+ // std::cout << "rz_field_mapProcess::StartElement - " << name << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ rz_field_map* rzmap = new rz_field_map;
+
+ /* Top-level caller needs to setup the SAXObject references. */
+ m_obj = rzmap;
+ *obj = rzmap;
+
+ /* Call next process UP in inheritance chain, after the SAXObject is set. */
+ FieldMapTypeProcess::StartElement(name, attrs);
+ }
+
+ virtual void EndElement(const std::string&)
+ {}
+
+ virtual void Characters(const std::string&)
+ {}
+
+ virtual void StackPopNotify(const std::string& name)
+ {
+ // std::cout << "rz_field_mapProcess::StackPopNotify" << std::endl;
+
+ if ( name != "rzB" ) {
+ std::cerr << name << " is not a valid child element for rz_field_map." << std::endl;
+ exit(1);
+ }
+
+ FieldMapTypeProcess::StackPopNotify(name);
+ }
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "rz_field_map";
+ return tag;
+ }
+};
+
+DECLARE_PROCESS_FACTORY(rz_field_mapProcess);
lcdd/src
diff -N rz_field_mapSubscriber.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rz_field_mapSubscriber.cc 29 Aug 2005 23:23:20 -0000 1.1
@@ -0,0 +1,112 @@
+// $Header: /cvs/lcd/lcdd/src/rz_field_mapSubscriber.cc,v 1.1 2005/08/29 23:23:20 jeremy Exp $
+
+#include "Saxana/SAXSubscriber.h"
+#include "Saxana/SAXComponentFactory.h"
+
+#include "G4Processor/GDMLProcessor.h"
+#include "G4Processor/GDMLExpressionEvaluator.h"
+
+#include "LCDDProcessor.hh"
+#include "rz_field_map.hh"
+#include "rzb.hh"
+#include "G4RZFieldMap.hh"
+
+/*
+ * @class rz_field_mapSubscriber
+ * @brief Subscriber for rz_field_map elements.
+ */
+class rz_field_mapSubscriber : virtual public SAXSubscriber
+{
+public:
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+public:
+ rz_field_mapSubscriber()
+ {
+ Subscribe("rz_field_map");
+ }
+
+ virtual ~rz_field_mapSubscriber()
+ {}
+
+ /** Instantiates a G4RZFieldMap object into Geant4 runtime. */
+ virtual void Activate(const SAXObject* object)
+ {
+ //std::cout << "rz_field_mapSubscriber" << std::endl;
+
+ if ( object != 0 ) {
+
+ GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+
+ const rz_field_map* obj = dynamic_cast<const rz_field_map*>(object);
+
+ if ( obj ) {
+ std::string lunit = obj->get_lunit();
+ std::string funit = obj->get_funit();
+ std::string name = obj->get_name();
+
+ G4RZFieldMap* fmap = new G4RZFieldMap();
+ LCDDProcessor::instance()->addMagneticField(name, fmap);
+
+ /* add RZB rows */
+ const ContentSequence* seq = obj->get_content();
+ size_t count = seq->size();
+
+ //std::cout << "count: " << count << std::endl;
+
+ 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);
+
+ if ( row != 0 ) {
+
+ std::string sr = row->get_r();
+ std::string sz = row->get_z();
+ std::string sBr = row->get_Br();
+ std::string sBz = row->get_Bz();
+
+ std::string sval = sr;
+ sval += "*" + lunit;
+ double r = calc->Eval(sval);
+
+ sval = sz;
+ sval += "*" + lunit;
+ double z = calc->Eval(sval);
+
+ sval = sBr;
+ sval += "*" + funit;
+ double Br = calc->Eval(sval);
+
+ sval = sBz;
+ sval += "*" + funit;
+ double Bz = calc->Eval(sval);
+
+ fmap->addRZB(r, z, Br, Bz);
+ }
+ else {
+ G4Exception("Failed cast to rzB.");
+ }
+ }
+ else {
+ G4cerr << "WARNING: Ignoring unknown element " << seq->content(i).tag << "." << std::endl;
+ }
+ }
+ }
+ else {
+ G4Exception("Failed cast to rz_field_map.");
+ }
+ }
+ else {
+ G4Exception("SAXObject is null.");
+ }
+ }
+};
+
+DECLARE_SUBSCRIBER_FACTORY(rz_field_mapSubscriber);
lcdd/src
diff -N rzbProcess.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rzbProcess.cc 29 Aug 2005 23:23:20 -0000 1.1
@@ -0,0 +1,74 @@
+// $Header: /cvs/lcd/lcdd/src/rzbProcess.cc,v 1.1 2005/08/29 23:23:20 jeremy Exp $
+#include "Saxana/ProcessingConfigurator.h"
+#include "Saxana/ProcessingContext.h"
+#include "Saxana/SAXProcessor.h"
+#include "Saxana/StateStack.h"
+#include "Saxana/SAXProcessingState.h"
+#include "Saxana/SAXStateProcess.h"
+#include "Saxana/SAXComponentFactory.h"
+
+#include "rzb.hh"
+
+#include <iostream>
+
+/**
+ * @class rzbProcess
+ * @brief Processor for rzB elements.
+ */
+
+class rzbProcess : public SAXStateProcess
+{
+
+public:
+ rzbProcess(const ProcessingContext* context = 0)
+ : SAXStateProcess(context),
+ m_obj(0)
+ {}
+
+ virtual ~rzbProcess()
+ {}
+
+ virtual const SAXComponentObject* Build() const
+ {
+ return this;
+ }
+
+ virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs)
+ {
+ //std::cout << "rzbProcess::StartElement" << std::endl;
+
+ SAXObject** obj = Context()->GetTopObject();
+
+ rzb* row = new rzb;
+
+ row->set_r(attrs.getValue("r"));
+ row->set_z(attrs.getValue("z"));
+ row->set_Br(attrs.getValue("Br"));
+ row->set_Bz(attrs.getValue("Bz"));
+
+ m_obj = row;
+ *obj = row;
+ }
+
+ virtual void EndElement(const std::string&)
+ {}
+
+ virtual void StackPopNotify(const std::string&)
+ {}
+
+ virtual void Characters(const std::string&)
+ {}
+
+ virtual const std::string& State() const
+ {
+ static std::string tag = "rzB";
+ return tag;
+ }
+
+private:
+
+ SAXObject* m_obj;
+
+};
+
+DECLARE_PROCESS_FACTORY(rzbProcess);
CVSspam 0.2.8