1 added + 8 modified, total 9 files
GeomConverter/src/org/lcsim/geometry
diff -u -r1.3 -r1.4
--- FieldMap.java 5 May 2006 23:43:09 -0000 1.3
+++ FieldMap.java 9 Apr 2007 05:04:28 -0000 1.4
@@ -1,14 +1,40 @@
package org.lcsim.geometry;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
/**
- *
+ * A field map, allows getting the field at a given point
* @author tonyj
*/
public interface FieldMap
{
- // Get the field magnitude and direction at a particular point.
- public void getField(double[] position, double[] b);
-
- // @deprecated @use getField(double[], double[])
- public double[] getField(double[] position);
+ /** Get the field magnitude and direction at a particular point.
+ * @param position The position at which the field is requested
+ * @param b The field (the object is passed by reference and updated)
+ */
+ public void getField(double[] position, double[] b);
+
+ /**
+ * Get the field magnitude and direction at a particular point. This method
+ * requires allocation of a new object on each call, and should therefore not
+ * be used if it we be called many times.
+ * @param position The position at which the field is requested
+ * @returns The field.
+ * @deprecated @use getField(double[], double[])
+ */
+ public double[] getField(double[] position);
+
+ /**
+ * Get the field magnitude and direction at a particular point.
+ * @param position The position at which the field is requested.
+ * @param field The field. If not <code>null</code> this is passed by reference and updated
+ * @returns The field. This will be the same object passed as field, unless field was <code>null</code>
+ */
+ public Hep3Vector getField(Hep3Vector position, BasicHep3Vector field);
+ /**
+ * Get the field magnitude and direction at a particular point.
+ * Equivalent to <code>getField(position,null)</code>.
+ */
+ public Hep3Vector getField(Hep3Vector position);
}
GeomConverter/src/org/lcsim/geometry
diff -u -r1.32 -r1.33
--- Detector.java 17 Mar 2007 00:10:41 -0000 1.32
+++ Detector.java 9 Apr 2007 05:04:28 -0000 1.33
@@ -21,9 +21,9 @@
extends org.lcsim.geometry.compact.Detector
implements HepRepProvider, IDetectorElement
{
- private FieldOverlay fieldOverlay = new FieldOverlay();
+ private FieldOverlay fieldOverlay = new FieldOverlay();
- Detector(Element node)
+ protected Detector(Element node)
{
super(node);
}
GeomConverter/sandbox/tknelson_snapshot
diff -u -r1.1 -r1.2
--- SiTrackerBarrel.java 27 Feb 2007 19:59:19 -0000 1.1
+++ SiTrackerBarrel.java 9 Apr 2007 05:04:29 -0000 1.2
@@ -314,7 +314,7 @@
layerStack.addLayer(l);
}
- System.out.println(layerStack.toString());
+ //System.out.println(layerStack.toString());
setLayering(new Layering(layerStack));
}
GeomConverter/src/org/lcsim/geometry/field
diff -u -r1.5 -r1.6
--- Solenoid.java 5 May 2006 23:43:11 -0000 1.5
+++ Solenoid.java 9 Apr 2007 05:04:29 -0000 1.6
@@ -1,5 +1,7 @@
package org.lcsim.geometry.field;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.lcsim.geometry.FieldMap;
@@ -66,4 +68,16 @@
{
return outerRadius2;
}
+
+ public Hep3Vector getField(Hep3Vector position, BasicHep3Vector field)
+ {
+ if (field == null) field = new BasicHep3Vector();
+ getField(position.v(),field.v());
+ return field;
+ }
+
+ public Hep3Vector getField(Hep3Vector position)
+ {
+ return getField(position,null);
+ }
}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/field
diff -u -r1.4 -r1.5
--- RZFieldMap.java 5 May 2006 23:43:11 -0000 1.4
+++ RZFieldMap.java 9 Apr 2007 05:04:29 -0000 1.5
@@ -6,6 +6,8 @@
*/
package org.lcsim.geometry.field;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -29,19 +31,19 @@
public class RZFieldMap extends Field
implements FieldMap
{
- int numBinsR;
- int numBinsZ;
+ private int numBinsR;
+ private int numBinsZ;
- double gridSizeR;
- double gridSizeZ;
+ private double gridSizeR;
+ private double gridSizeZ;
- double maxZ;
- double maxR;
+ private double maxZ;
+ private double maxR;
- String location;
+ private String location;
- double[][] BrArray;
- double[][] BzArray;
+ private double[][] BrArray;
+ private double[][] BzArray;
public RZFieldMap(Element node) throws JDOMException
{
@@ -215,6 +217,18 @@
return b;
}
+ public Hep3Vector getField(Hep3Vector position, BasicHep3Vector field)
+ {
+ if (field == null) field = new BasicHep3Vector();
+ getField(position.v(),field.v());
+ return field;
+ }
+
+ public Hep3Vector getField(Hep3Vector position)
+ {
+ return getField(position,null);
+ }
+
public final int getNumBinsR()
{
return numBinsR;
GeomConverter/src/org/lcsim/geometry/field
diff -u -r1.1 -r1.2
--- Dipole.java 5 May 2006 23:43:11 -0000 1.1
+++ Dipole.java 9 Apr 2007 05:04:29 -0000 1.2
@@ -1,5 +1,7 @@
package org.lcsim.geometry.field;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
import static java.lang.Math.pow;
import static java.lang.Math.sqrt;
@@ -10,56 +12,68 @@
public class Dipole extends Field implements FieldMap
{
- double[] coeffs;
- double zmin;
- double zmax;
- double rmax;
-
- public Dipole(Element node) throws JDOMException
- {
- super(node);
-
- zmin = node.getAttribute("zmin").getDoubleValue();
- zmax = node.getAttribute("zmax").getDoubleValue();
- rmax = node.getAttribute("rmax").getDoubleValue();
-
- int ncoeff = node.getChildren("dipoleCoeff").size();
- coeffs = new double[ncoeff];
-
- int i = 0;
- for (Object o : node.getChildren("dipoleCoeff"))
- {
- Element e = (Element) o;
- double coeff = e.getAttribute("value").getDoubleValue();
- coeffs[i] = coeff;
- ++i;
- }
- }
-
- public void getField(double[] position, double[] b)
- {
- double bx = 0;
- double z = position[2];
- double r = sqrt(position[0] * position[0] + position[1] * position[1]);
-
- // Check if z coordinate is within dipole z bounds.
- if (z > zmin && z < zmax && r < rmax)
- {
- // Apply all coefficients to this z coordinate.
- for (int i = 0; i < coeffs.length; ++i)
- {
- bx += coeffs[i] * pow(z, i);
- }
-
- // Apply Bx to input array.
- b[0] += bx;
- }
- }
-
- public double[] getField(double[] p)
- {
- double[] b = new double[3];
- getField(p, b);
- return b;
- }
+ private double[] coeffs;
+ private double zmin;
+ private double zmax;
+ private double rmax;
+
+ public Dipole(Element node) throws JDOMException
+ {
+ super(node);
+
+ zmin = node.getAttribute("zmin").getDoubleValue();
+ zmax = node.getAttribute("zmax").getDoubleValue();
+ rmax = node.getAttribute("rmax").getDoubleValue();
+
+ int ncoeff = node.getChildren("dipoleCoeff").size();
+ coeffs = new double[ncoeff];
+
+ int i = 0;
+ for (Object o : node.getChildren("dipoleCoeff"))
+ {
+ Element e = (Element) o;
+ double coeff = e.getAttribute("value").getDoubleValue();
+ coeffs[i] = coeff;
+ ++i;
+ }
+ }
+
+ public void getField(double[] position, double[] b)
+ {
+ double bx = 0;
+ double z = position[2];
+ double r = sqrt(position[0] * position[0] + position[1] * position[1]);
+
+ // Check if z coordinate is within dipole z bounds.
+ if (z > zmin && z < zmax && r < rmax)
+ {
+ // Apply all coefficients to this z coordinate.
+ for (int i = 0; i < coeffs.length; ++i)
+ {
+ bx += coeffs[i] * pow(z, i);
+ }
+
+ // Apply Bx to input array.
+ b[0] += bx;
+ }
+ }
+
+ public double[] getField(double[] p)
+ {
+ double[] b = new double[3];
+ getField(p, b);
+ return b;
+ }
+
+ public Hep3Vector getField(Hep3Vector position, BasicHep3Vector field)
+ {
+ if (field == null) field = new BasicHep3Vector();
+ getField(position.v(),field.v());
+ return field;
+ }
+
+ public Hep3Vector getField(Hep3Vector position)
+ {
+ return getField(position,null);
+ }
}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/field
diff -u -r1.2 -r1.3
--- FieldOverlay.java 16 May 2006 21:28:18 -0000 1.2
+++ FieldOverlay.java 9 Apr 2007 05:04:29 -0000 1.3
@@ -1,5 +1,7 @@
package org.lcsim.geometry.field;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
import java.util.ArrayList;
import java.util.List;
@@ -9,44 +11,58 @@
* FieldOverlay is a FieldMap that itself
* contains a list of references to other FieldMaps.
* This setup supports the overlay of multiple
- * magnetic fields, such as the detector solenoid
- * and the DiD.
- *
+ * magnetic fields, such as the detector solenoid
+ * and the DiD.
+ *
* @see org.lcsim.geometry.Detector
- *
+ *
* @author Jeremy McCormick
*/
public class FieldOverlay implements FieldMap
{
- List<FieldMap> fields =
- new ArrayList<FieldMap>();
-
- public FieldOverlay()
- {}
-
- public void addField(FieldMap field)
- {
- fields.add(field);
- }
-
- /**
- * @param pos An array of size 3 containing the position.
- * @param b An array of size 3 that is updated by this method to
- * contain the Bfield components (bx,by,bz) of the overlay at pos.
- */
- public void getField(double[] pos, double[] b)
- {
- b[0] = b[1] = b[2] = 0.;
- for (FieldMap field : fields)
- {
- field.getField(pos, b);
- }
- }
-
- public double[] getField(double[] pos)
- {
- double[] b = new double[3];
- getField(pos, b);
- return b;
- }
+ private List<FieldMap> fields = new ArrayList<FieldMap>();
+
+ public FieldOverlay()
+ {}
+
+ public void addField(FieldMap field)
+ {
+ fields.add(field);
+ }
+
+ /**
+ * @param pos An array of size 3 containing the position.
+ * @param b An array of size 3 that is updated by this method to
+ * contain the Bfield components (bx,by,bz) of the overlay at pos.
+ */
+ public void getField(double[] pos, double[] b)
+ {
+ b[0] = b[1] = b[2] = 0.;
+ double[] temp = new double[3];
+ for (FieldMap field : fields)
+ {
+ field.getField(pos, temp);
+ for (int i=0; i<3; i++) b[i] += temp[i];
+ }
+ }
+
+ public double[] getField(double[] pos)
+ {
+ double[] b = new double[3];
+ getField(pos, b);
+ return b;
+ }
+
+ public Hep3Vector getField(Hep3Vector position, BasicHep3Vector field)
+ {
+ if (field == null) field = new BasicHep3Vector();
+ getField(position.v(),field.v());
+ return field;
+ }
+
+ public Hep3Vector getField(Hep3Vector position)
+ {
+ return getField(position,null);
+ }
+
}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/compact
diff -u -r1.20 -r1.21
--- Detector.java 24 Mar 2007 01:02:50 -0000 1.20
+++ Detector.java 9 Apr 2007 05:04:29 -0000 1.21
@@ -6,8 +6,6 @@
import org.jdom.Element;
import org.lcsim.detector.DetectorElement;
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.ILogicalVolume;
import org.lcsim.detector.IPhysicalVolume;
import org.lcsim.detector.IPhysicalVolumeNavigator;
import org.lcsim.detector.PhysicalVolumeNavigator;
@@ -42,8 +40,7 @@
*/
protected Detector(Element element)
{
- super(element.getChild("info").getAttributeValue("name"));
-
+ super(element == null ? "ImNotReallyADetectorElement" : element.getChild("info").getAttributeValue("name"));
materialMgr = XMLMaterialManager.create(XMLMaterialManager.materials() );
}
GeomConverter
diff -N .cvsignore
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .cvsignore 9 Apr 2007 05:04:29 -0000 1.1
@@ -0,0 +1,5 @@
+target
+*.lcdd
+*.heprep
+elements.xml
+build.properties
CVSspam 0.2.8