1 package org.lcsim.geometry.field;
2
3 import hep.physics.vec.BasicHep3Vector;
4 import hep.physics.vec.Hep3Vector;
5 import org.jdom.Element;
6 import org.lcsim.geometry.FieldMap;
7 import org.lcsim.geometry.compact.Field;
8
9
10
11
12
13
14
15 abstract class AbstractFieldMap extends Field implements FieldMap
16 {
17 AbstractFieldMap(Element node)
18 {
19 super(node);
20 }
21 abstract void getField(double x, double y, double z, BasicHep3Vector field);
22
23 public Hep3Vector getField(Hep3Vector position, BasicHep3Vector field)
24 {
25 if (field == null) field = new BasicHep3Vector();
26 getField(position.x(),position.y(),position.z(),field);
27 return field;
28 }
29
30 public Hep3Vector getField(Hep3Vector position)
31 {
32 return getField(position,null);
33 }
34
35 public void getField(double[] position, double[] b)
36 {
37 BasicHep3Vector field = new BasicHep3Vector();
38 getField(position[0],position[1],position[2],field);
39 b[0] = field.x();
40 b[1] = field.y();
41 b[2] = field.z();
42 }
43
44 public double[] getField(double[] position)
45 {
46 BasicHep3Vector field = new BasicHep3Vector();
47 getField(position[0],position[1],position[2],field);
48 return field.v();
49 }
50 }