Commit in GeomConverter/test/org/lcsim/detector on MAIN
ShapeRotateTest.java+151-531.1 -> 1.2


GeomConverter/test/org/lcsim/detector
ShapeRotateTest.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ShapeRotateTest.java	27 Mar 2007 20:41:27 -0000	1.1
+++ ShapeRotateTest.java	28 Mar 2007 00:52:48 -0000	1.2
@@ -3,7 +3,9 @@
 import static org.lcsim.units.clhep.SystemOfUnits.m;
 import hep.graphics.heprep.HepRep;
 import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepInstance;
 import hep.graphics.heprep.HepRepInstanceTree;
+import hep.graphics.heprep.HepRepPoint;
 import hep.graphics.heprep.HepRepTreeID;
 import hep.graphics.heprep.HepRepType;
 import hep.graphics.heprep.HepRepTypeTree;
@@ -11,7 +13,10 @@
 import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
 
+import java.awt.Color;
 import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -26,7 +31,10 @@
 {
     private static IMaterial dummymat = new MaterialElement("dummymat",1,1,1.0);
     private IPhysicalVolumeNavigator nav;
-    
+
+    List<Hep3Vector> points =
+        new ArrayList<Hep3Vector>();
+
     public ShapeRotateTest(String name)
     {
         super(name);
@@ -36,22 +44,30 @@
     {
         return new TestSuite(ShapeRotateTest.class);
     }
-    
+
     public void testShapeRotate()
     {
         System.out.println("testShapeRotate");
-        
+
         Hep3Vector point = new BasicHep3Vector(0,0,-10);
         IPhysicalVolumePath path = nav.getPath(point);
-        
+
         System.out.println(point + " " + path.toString());
-        
+
         point = new BasicHep3Vector(0,0,10);
         path = nav.getPath(point);
-        
+
         System.out.println(point + " " + path.toString());
+        
+        for (IDetectorElement de : DetectorElementStore.getInstance())
+        {
+            if ( de.hasGeometryInfo() )
+            {
+                System.out.println(de.getName() + " " + de.getGeometry().getPosition());
+            }
+        }
     }
-    
+
     public class TestDE
     extends DetectorElement
     {
@@ -60,36 +76,53 @@
             super(name, parent, path);
         }        
     }
-    
+
     public void setUp()
     {
         IPhysicalVolume world = createWorld();
         nav = new PhysicalVolumeNavigator("default",world);
-        
-        Box box = new Box("testbox",50,50,50);
-        ILogicalVolume lv1 = new LogicalVolume("test",box,dummymat);
-        Rotation3D rot = new Rotation3D();
-        rot.setPassiveXYZ(Math.PI/2, 0, 0);
+
+        // testbox1
+        Box box1 = new Box("testbox1",50,50,50);
+        ILogicalVolume lv1 = new LogicalVolume("testbox1",box1,dummymat);
+        Rotation3D rot1 = new Rotation3D();
+        //rot1.setPassiveXYZ(0, 0, Math.PI/4);
+        Hep3Vector t1 = new BasicHep3Vector(100,0,0);
         new PhysicalVolume(
-                new Transform3D(rot),
+                new Transform3D(t1,rot1),
                 "testbox1",
                 lv1,
                 world.getLogicalVolume(),
-                0);
-        
-        IDetectorElement box1 = new TestDE("testbox1",null,"/testbox1");
-        
-        box = new Box("testbox2",10,10,10);
-        LogicalVolume lv2 = new LogicalVolume("test2",box,dummymat);
+                0);        
+
+        Box box2 = new Box("testbox2",10,10,10);
+        LogicalVolume lv2 = new LogicalVolume("testbox2",box2,dummymat);
+        Rotation3D rot2 = new Rotation3D();        
+        //rot2.setPassiveEuler(Math.PI/4, 0,0);
         new PhysicalVolume(
-                new Transform3D(new BasicHep3Vector(0,0,10)),
+                new Transform3D(new BasicHep3Vector(25,0,0), rot2),
                 "testbox2",
                 lv2,
                 lv1,
                 1);                
         
-        new TestDE("testbox2",box1,"/testbox1/testbox2");
+        Hep3Vector t3 = new BasicHep3Vector(-100,0,0);
+        Rotation3D rot3 = new Rotation3D();
+        rot3.setPassiveXYZ(0,Math.PI,0);
+        new PhysicalVolume(
+                new Transform3D(t3,rot3),
+                "testbox3",
+                lv1,
+                world.getLogicalVolume(),
+                1);             
         
+        IDetectorElement de1 = new TestDE("de1",null,"/testbox1");
+        IDetectorElement de2 = new TestDE("de2",null,"/testbox3");
+        IDetectorElement de3 = new TestDE("de3",de1,"/testbox1/testbox2");
+        IDetectorElement de4 = new TestDE("de4",de2,"/testbox3/testbox2");
+
+        points.add(new BasicHep3Vector(25,0,0));
+
         try {
             writeHepRep("ShapeRotateTest.heprep");
         }
@@ -98,12 +131,42 @@
             throw new RuntimeException(x);
         }
     }
-    
+
+    public final IPhysicalVolume createWorld()
+    {       
+        Box boxWorld = new Box(
+                "world_box",
+                10.0*m,
+                10.0*m,
+                10.0*m);
+
+        LogicalVolume lvWorld = 
+            new LogicalVolume(
+                    "world",
+                    boxWorld,
+                    dummymat);
+
+        IPhysicalVolume pvTop = 
+            new PhysicalVolume(
+                    null,
+                    "world",
+                    lvWorld,
+                    null,
+                    0);
+
+        return pvTop;
+    }      
+
+
+    public final static String HITS_LAYER = "Hits";
+    public final static String PARTICLES_LAYER = "Particles";
+
     private void writeHepRep(String filepath) throws Exception
     {
         HepRepFactory factory = HepRepFactory.create();
         HepRep root = factory.createHepRep();        
-        
+
+        // detector
         HepRepTreeID treeID = factory.createHepRepTreeID("DetectorType", "1.0");
         HepRepTypeTree typeTree = factory.createHepRepTypeTree(treeID);
         root.addTypeTree(typeTree);
@@ -118,43 +181,78 @@
         barrel.addAttValue("layer", detectorLayer);
         HepRepType endcap = factory.createHepRepType(typeTree, "Endcap");
         endcap.addAttValue("layer", detectorLayer);
-                
+
         DetectorElementToHepRepConverter cnv = 
             new DetectorElementToHepRepConverter();
-        
+
         for (IDetectorElement de : DetectorElementStore.getInstance())
         {
             cnv.convert(de, factory, root);
         }
-        
+        // end detector
+
+        root.addLayer(PARTICLES_LAYER);
+        root.addLayer(HITS_LAYER);
+        root.addLayer("axis");
+
+        treeID = factory.createHepRepTreeID("EventType", "1.0");
+        typeTree = factory.createHepRepTypeTree(treeID);
+        root.addTypeTree(typeTree);
+        instanceTree = factory.createHepRepInstanceTree("Event", "1.0", typeTree);
+        root.addInstanceTree(instanceTree);  
+
+        // axis
+        HepRepType axis = factory.createHepRepType(typeTree, "axis");
+        axis.addAttValue("drawAs","Line");
+        axis.addAttValue("layer", "axis");
+
+        HepRepType xaxis = factory.createHepRepType(axis, "xaxis");
+        xaxis.addAttValue("color",Color.RED);
+        xaxis.addAttValue("fill",true);
+        xaxis.addAttValue("fillColor",Color.RED);
+        HepRepInstance x = factory.createHepRepInstance(instanceTree, xaxis);
+        factory.createHepRepPoint(x,0,0,0);
+        factory.createHepRepPoint(x,1000,0,0);
+
+        HepRepType yaxis = factory.createHepRepType(axis, "yaxis");
+        yaxis.addAttValue("color",Color.GREEN);
+        yaxis.addAttValue("fill",true);
+        yaxis.addAttValue("fillColor",Color.GREEN);
+        HepRepInstance y = factory.createHepRepInstance(instanceTree, yaxis);
+        factory.createHepRepPoint(y,0,0,0);
+        factory.createHepRepPoint(y,0,1000,0);
+
+        HepRepType zaxis = factory.createHepRepType(axis, "zaxis");
+        zaxis.addAttValue("color",Color.BLUE);
+        zaxis.addAttValue("fill",true);
+        zaxis.addAttValue("fillColor",Color.BLUE);
+        HepRepInstance z = factory.createHepRepInstance(instanceTree, zaxis);
+        factory.createHepRepPoint(z,0,0,0);
+        factory.createHepRepPoint(z,0,0,1000);
+        // done axis                              
+
+        // points
+        HepRepType typeX = factory.createHepRepType(typeTree, "points");
+        typeX.addAttValue("layer",HITS_LAYER);
+        typeX.addAttValue("drawAs","Point");
+        typeX.addAttValue("color",Color.GREEN);
+        typeX.addAttValue("fill",true);
+        typeX.addAttValue("fillColor",Color.GREEN);
+        typeX.addAttValue("MarkName","Box");
+        typeX.addAttDef("dEdx", "Hit dEdx", "physics", "");
+        typeX.addAttDef("time", "Hit time", "physics", "");
+        typeX.addAttDef("mcEnergy", "MC Particle Energy", "physics", "");
+
+        for (Hep3Vector p : points )
+        {
+            HepRepInstance instanceX = factory.createHepRepInstance(instanceTree, typeX);
+            HepRepPoint pp = factory.createHepRepPoint(instanceX,p.x(),p.y(),p.z());
+        }        
+        // done points
+
         HepRepWriter writer = 
             HepRepFactory.create().createHepRepWriter(new FileOutputStream(filepath),false,false);
         writer.write(root,"test");
         writer.close();
-    }
-    
-    public final IPhysicalVolume createWorld()
-    {       
-        Box boxWorld = new Box(
-                "world_box",
-                10.0*m,
-                10.0*m,
-                10.0*m);
-        
-        LogicalVolume lvWorld = 
-            new LogicalVolume(
-                    "world",
-                    boxWorld,
-                    dummymat);
-        
-        IPhysicalVolume pvTop = 
-            new PhysicalVolume(
-                    null,
-                    "world",
-                    lvWorld,
-                    null,
-                    0);
-        
-        return pvTop;
-    }      
+    }    
 }
\ No newline at end of file
CVSspam 0.2.8