View Javadoc

1   package org.lcsim.plugin.conditions;
2   
3   import hep.graphics.heprep.HepRep;
4   import hep.graphics.heprep.HepRepFactory;
5   import hep.graphics.heprep.HepRepInstanceTree;
6   import hep.graphics.heprep.HepRepTypeTree;
7   import hep.physics.vec.BasicHep3Vector;
8   import hep.physics.vec.Hep3Vector;
9   import java.util.List;
10  import org.lcsim.geometry.FieldMap;
11  import org.lcsim.util.loop.DummyDetector;
12  
13  /**
14   * A "dummy" detector which is only able to provide HepRep's for WIRED for
15   * when no other geometry is available.
16   * @author tonyj
17   */
18  class HepRepOnlyDetector extends DummyDetector
19  {
20     private HepRep detector;
21     private FieldMap field;
22     /** Creates a new instance of HeprepOnlyDetector */
23     HepRepOnlyDetector(String name, HepRep heprep, double field)
24     {
25        super(name);
26        this.detector = heprep;
27        this.field = new SolenoidalField(field);
28     }
29     
30     public void appendHepRep(HepRepFactory factory, HepRep heprep)
31     {
32        List<HepRepTypeTree> types = detector.getTypeTreeList();
33        for (HepRepTypeTree gTypeTree : types) heprep.addTypeTree(gTypeTree);
34        
35        List<HepRepInstanceTree> instances = detector.getInstanceTreeList();
36        for (HepRepInstanceTree gInstanceTree : instances) heprep.addInstanceTree(gInstanceTree);
37        
38        List<String> layers = detector.getLayerOrder();
39        for (String layer : layers ) heprep.addLayer(layer);
40     }
41     
42     public FieldMap getFieldMap()
43     {
44        return field;
45     }
46     
47     private class SolenoidalField implements FieldMap
48     {
49        private double[] field;
50        SolenoidalField(double zField)
51        {
52           field = new double[]{0,0,zField};
53        }
54        public void getField(double[] position, double[] b)
55        {
56           for (int i=0;i<3;i++) b[i] = field[1];
57        }
58        
59        public double[] getField(double[] position)
60        {
61           return field;
62        }
63        
64        public Hep3Vector getField(Hep3Vector position, BasicHep3Vector field)
65        {
66           if (field == null) field = new BasicHep3Vector();
67           getField(position.v(),field.v());
68           return field;
69        }
70        
71        public Hep3Vector getField(Hep3Vector position)
72        {
73           return getField(position,null);
74        }
75     }
76  }