Print

Print


Commit in lcdd on MAIN
include/lcdd/schema/FieldMap3DType.hh+34-21.4 -> 1.5
schemas/lcdd/1.0/lcdd_fields.xsd+31.13 -> 1.14
src/lcdd/processes/field_map_3dProcess.cc+7-31.3 -> 1.4
src/lcdd/subscribers/field_map_3dSubscriber.cc+20-41.3 -> 1.4
+64-9
4 modified files
add support for 3D field coordinate origin offset

lcdd/include/lcdd/schema
FieldMap3DType.hh 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- FieldMap3DType.hh	10 Jul 2013 18:06:18 -0000	1.4
+++ FieldMap3DType.hh	4 Sep 2013 00:38:03 -0000	1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/schema/FieldMap3DType.hh,v 1.4 2013/07/10 18:06:18 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/schema/FieldMap3DType.hh,v 1.5 2013/09/04 00:38:03 jeremy Exp $
 #ifndef LCDD_SCHEMA_FIELDMAP3DTYPE_HH
 #define LCDD_SCHEMA_FIELDMAP3DTYPE_HH 1
 
@@ -34,10 +34,42 @@
         return _filename;
     }
 
+    void set_xoffset(const std::string& xoffset)
+    {
+        _xoffset = xoffset;
+    }
+
+    void set_yoffset(const std::string& yoffset)
+    {
+        _xoffset = yoffset;
+    }
+
+    void set_zoffset(const std::string& zoffset)
+    {
+        _xoffset = zoffset;
+    }
+
+    const std::string& get_xoffset() const
+    {
+        return _xoffset;
+    }
+
+    const std::string& get_yoffset() const
+    {
+        return _yoffset;
+    }
+
+    const std::string& get_zoffset() const
+    {
+        return _zoffset;
+    }
+
+
+
 private:
 
     std::string _filename;
-
+    std::string _xoffset, _yoffset, _zoffset;
 };
 
 #endif

lcdd/schemas/lcdd/1.0
lcdd_fields.xsd 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- lcdd_fields.xsd	3 Oct 2012 17:38:54 -0000	1.13
+++ lcdd_fields.xsd	4 Sep 2013 00:38:03 -0000	1.14
@@ -214,6 +214,9 @@
         <xs:complexContent>
             <xs:extension base="FieldType">
                 <xs:attribute name="filename" type="xs:string" />
+                <xs:attribute name="xoffset" type="xs:double" use="optional" default="0.0" />
+                <xs:attribute name="yoffset" type="xs:double" use="optional" default="0.0" />
+                <xs:attribute name="zoffset" type="xs:double" use="optional" default="0.0" />
             </xs:extension>
         </xs:complexContent>
     </xs:complexType>

lcdd/src/lcdd/processes
field_map_3dProcess.cc 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- field_map_3dProcess.cc	3 Jul 2013 23:33:51 -0000	1.3
+++ field_map_3dProcess.cc	4 Sep 2013 00:38:03 -0000	1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/processes/field_map_3dProcess.cc,v 1.3 2013/07/03 23:33:51 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/processes/field_map_3dProcess.cc,v 1.4 2013/09/04 00:38:03 jeremy Exp $
 
 // LCDD
 #include "lcdd/processes/FieldMapTypeProcess.hh"
@@ -29,14 +29,18 @@
 
     virtual void StartElement(const std::string& name, const ASCIIAttributeList& attrs)
     {
-
         SAXObject** obj = Context()->GetTopObject();
 
+        // Create schema object.
         field_map_3d* fmap = new field_map_3d;
 
+        // Set input values from XML.
         fmap->set_filename(attrs.getValue("filename"));
+        fmap->set_xoffset(attrs.getValue("xoffset"));
+        fmap->set_yoffset(attrs.getValue("yoffset"));
+        fmap->set_zoffset(attrs.getValue("zoffset"));
 
-        // Top-level caller needs to setup the SAXObject references.
+        // This is the top-level caller, so it needs to setup the SAXObject references.
         _obj = fmap;
         *obj = fmap;
 

lcdd/src/lcdd/subscribers
field_map_3dSubscriber.cc 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- field_map_3dSubscriber.cc	10 Jul 2013 18:06:20 -0000	1.3
+++ field_map_3dSubscriber.cc	4 Sep 2013 00:38:03 -0000	1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/field_map_3dSubscriber.cc,v 1.3 2013/07/10 18:06:20 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/subscribers/field_map_3dSubscriber.cc,v 1.4 2013/09/04 00:38:03 jeremy Exp $
 
 // lcdd
 #include "lcdd/core/LCDDProcessor.hh"
@@ -13,6 +13,9 @@
 // Geant4
 #include "G4Processor/GDMLProcessor.h"
 
+// STL
+#include <iostream>
+
 /**
  * @brief Creates FieldMap3D objects from field_map_3d elements.
  */
@@ -50,14 +53,27 @@
 
                 if (obj) {
 
-                    //GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
+                    GDMLExpressionEvaluator* calc = GDMLProcessor::GetInstance()->GetEvaluator();
                     //std::string lunit = obj->get_lunit();
                     //std::string funit = obj->get_funit();
 
                     std::string name = obj->get_name();
-                    std::string field_name = obj->get_filename();
+                    std::string fileName = obj->get_filename();
+
+                    // Check if file exists before creating field map.
+                    std::ifstream ifile(fileName.c_str());
+                    if (!ifile) {
+                        std::cerr << "field map file does not exist at location: " << fileName << std::endl;
+                        G4Exception("", "", FatalException, "Field map file does not exist.");
+                    }
+
+                    // Calculate offsets.
+                    // TODO: Multiply by units.
+                    double xoffset = calc->Eval(obj->get_xoffset());
+                    double yoffset = calc->Eval(obj->get_yoffset());
+                    double zoffset = calc->Eval(obj->get_zoffset());
 
-                    Cartesian3DMagneticFieldMap* fmap = new Cartesian3DMagneticFieldMap(field_name.c_str(), 0, 0, 0);
+                    Cartesian3DMagneticFieldMap* fmap = new Cartesian3DMagneticFieldMap(fileName.c_str(), xoffset, yoffset, zoffset);
                     LCDDProcessor::instance()->addMagneticField(name, fmap);
                 }
             }
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1