Print

Print


Commit in GeomConverter on MAIN
src/org/lcsim/detector/converter/heprep/DetectorElementToHepRepConverter.java+107-11.7 -> 1.8
src/org/lcsim/detector/solids/Trap.java+283added 1.1
                             /AbstractSolid.java+1-61.3 -> 1.4
test/org/lcsim/detector/solids/TrapTest.java+95added 1.1
                              /TrdTest.java+7-871.3 -> 1.4
+493-94
2 added + 3 modified, total 5 files
JM: First version of G4Trap port.

GeomConverter/src/org/lcsim/detector/converter/heprep
DetectorElementToHepRepConverter.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- DetectorElementToHepRepConverter.java	24 Jul 2007 19:58:18 -0000	1.7
+++ DetectorElementToHepRepConverter.java	7 Aug 2007 22:47:53 -0000	1.8
@@ -4,20 +4,29 @@
 import hep.graphics.heprep.HepRepFactory;
 import hep.graphics.heprep.HepRepInstance;
 import hep.graphics.heprep.HepRepInstanceTree;
+import hep.graphics.heprep.HepRepTreeID;
 import hep.graphics.heprep.HepRepType;
 import hep.graphics.heprep.HepRepTypeTree;
+import hep.graphics.heprep.HepRepWriter;
 import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
 
+import java.awt.Color;
+import java.io.FileOutputStream;
+
+import org.lcsim.detector.DetectorElementStore;
 import org.lcsim.detector.IDetectorElement;
 import org.lcsim.detector.IGeometryInfo;
 import org.lcsim.detector.solids.Box;
 import org.lcsim.detector.solids.ISolid;
+import org.lcsim.detector.solids.Trap;
 import org.lcsim.detector.solids.Trd;
 import org.lcsim.detector.solids.Tube;
 
 public class DetectorElementToHepRepConverter
 {
+	public final static int TRAP_POINT_ORDER[] = {2,3,1,0,6,7,5,4};
+		
     public static void convert(IDetectorElement detelem, HepRepFactory factory, HepRep heprep, boolean recurse)
     {            	
         HepRepInstanceTree instanceTree = heprep.getInstanceTreeTop("Detector","1.0");
@@ -33,7 +42,8 @@
                 Box box = (Box)geo.getLogicalVolume().getSolid();
 
                 HepRepType ec = typeTree.getType("Barrel");
-                HepRepType type = factory.createHepRepType(ec, detelem.getName());		
+                HepRepType type = factory.createHepRepType(ec, detelem.getName());	
+                
                 type.addAttValue("drawAs","Prism");
 
                 HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
@@ -149,6 +159,24 @@
                 }              
             	            	            	
             }
+            else if (solid instanceof Trap)
+            {
+            	Trap trap = (Trap)solid;
+            	
+            	HepRepType ec = typeTree.getType("Barrel");
+                HepRepType type = factory.createHepRepType(ec, detelem.getName());
+                type.addAttValue("drawAs","Prism");
+                
+                HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
+            	
+            	Hep3Vector points[] = trap.getPoints();
+            	            	            	
+            	for (int i=0; i<TRAP_POINT_ORDER.length; i++)
+            	{
+            		Hep3Vector p = points[TRAP_POINT_ORDER[i]];
+            		factory.createHepRepPoint(instance,p.x(),p.y(),p.z());
+            	}
+            }
         }
         if ( detelem.hasChildren() )
         {
@@ -158,4 +186,82 @@
             }
         }
     }
+    
+	public final static String HITS_LAYER = "Hits";
+	public final static String PARTICLES_LAYER = "Particles";
+	
+    public static 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);
+
+        HepRepInstanceTree instanceTree = factory.createHepRepInstanceTree("Detector", "1.0", typeTree);
+        root.addInstanceTree(instanceTree);
+
+        String detectorLayer = "Detector";
+        root.addLayer(detectorLayer);
+
+        HepRepType barrel = factory.createHepRepType(typeTree, "Barrel");
+        barrel.addAttValue("layer", detectorLayer);
+        HepRepType endcap = factory.createHepRepType(typeTree, "Endcap");
+        endcap.addAttValue("layer", detectorLayer);
+              
+        for (IDetectorElement de : DetectorElementStore.getInstance())
+        {        	
+        	DetectorElementToHepRepConverter.convert(de, factory, root, false);
+        }
+        // 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                              
+
+        HepRepWriter writer = 
+            HepRepFactory.create().createHepRepWriter(new FileOutputStream(filepath),false,false);
+        writer.write(root,"test");
+        writer.close();
+    }        
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/solids
Trap.java added at 1.1
diff -N Trap.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Trap.java	7 Aug 2007 22:47:54 -0000	1.1
@@ -0,0 +1,283 @@
+package org.lcsim.detector.solids;
+
+import static java.lang.Math.cos;
+import static java.lang.Math.sin;
+import static java.lang.Math.tan;
+import static java.lang.Math.abs;
+import static java.lang.Math.sqrt;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import static hep.physics.vec.VecOp.cross;
+import static hep.physics.vec.VecOp.sub;
+import static hep.physics.vec.VecOp.dot;
+import static org.lcsim.detector.solids.Inside.INSIDE;
+import static org.lcsim.detector.solids.Inside.OUTSIDE;
+import static org.lcsim.detector.solids.Inside.SURFACE;
+import static org.lcsim.detector.solids.Tolerance.TOLERANCE;
+
+/**
+ * Port of Geant4's 
+ * <a href="http://www.lcsim.org/software/geant4/doxygen/html/classG4Trap.html">G4Trap</a>.
+ *
+ * @author Jeremy McCormick
+ * @version $Id: Trap.java,v 1.1 2007/08/07 22:47:54 jeremy Exp $
+ */
+
+public class Trap 
+extends AbstractSolid 
+{
+	double dz;
+	double TthetaCphi;	
+	double TthetaSphi;
+	double dy1;
+	double dx1;
+	double dx2;
+	double Talpha1;
+	double dy2;
+	double dx3;
+	double dx4;
+	double Talpha2;
+	
+	double cubicVolume;
+	
+	TrapSidePlane planes[] = new TrapSidePlane[4];
+	
+	Hep3Vector points[];
+	
+	public static final double COPLANAR_TOLERANCE = 1E-4;
+		
+	public class TrapSidePlane
+	{
+		public double a;
+		public double b;
+		public double c;
+		public double d;
+	}
+		
+	public Trap(
+			String name,
+			double dz,
+			double theta,
+			double phi,
+			double dy1,
+			double dx1,
+			double dx2,
+			double alp1,
+			double dy2,
+			double dx3,
+			double dx4,
+			double alp2)
+	{
+		super(name);
+		
+		if ( dz > 0 && dy1 > 0 && dx1 > 0 && dx2 > 0 && dy2 > 0 && dx3 > 0 && dx4 > 0 )
+		{		
+			this.dz=dz;
+			this.TthetaCphi=tan(theta)*cos(phi);
+			this.TthetaSphi=tan(theta)*sin(phi);
+
+			this.dy1=dy1;
+			this.dx1=dx1;
+			this.dx2=dx2;
+			Talpha1=tan(alp1);
+      
+			this.dy2=dy2;
+			this.dx3=dx3;
+			this.dx4=dx4;
+			Talpha2=tan(alp2);
+			
+			makePlanes();
+		}
+		else 
+		{
+			throw new IllegalArgumentException("bad parameters");
+		} 
+	}
+	
+	private boolean makePlanes()
+	{
+		  boolean good = true;
+
+		  Hep3Vector pt[] = getPoints();
+
+		  // Bottom side with normal approx. -Y
+		  //
+		  planes[0]=makePlane(pt[0],pt[4],pt[5],pt[1]) ;
+		  if (planes[0]==null)
+		  {
+			  throw new RuntimeException();
+		    //G4cerr << "ERROR - G4Trap()::MakePlanes(): " << GetName() << G4endl;
+		    //G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
+		    //            "Face at ~-Y not planar.");
+		  }
+
+		  // Top side with normal approx. +Y
+		  //
+		  planes[1]=makePlane(pt[2],pt[3],pt[7],pt[6]);
+		  if (planes[1]==null)
+		  {
+			  throw new RuntimeException();
+		    //G4cerr << "ERROR - G4Trap()::MakePlanes(): " << GetName() << G4endl;
+		    //G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
+		    //            "Face at ~+Y not planar.");
+		  }
+
+		  // Front side with normal approx. -X
+		  //
+		  planes[2]=makePlane(pt[0],pt[2],pt[6],pt[4]);
+		  if (planes[2]==null)
+		  {
+			  throw new RuntimeException();
+		    //G4cerr << "ERROR - G4Trap()::MakePlanes(): " << GetName() << G4endl;
+		    //G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
+		    //            "Face at ~-X not planar.");
+		  }
+		   
+		  // Back side iwth normal approx. +X
+		  //
+		  planes[3]= makePlane(pt[1],pt[5],pt[7],pt[3]);
+		  if (planes[3]==null)
+		  {
+			  throw new RuntimeException();
+		    //G4cerr << "ERROR - G4Trap()::MakePlanes(): " << GetName() << G4endl;
+		    //G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
+		    //            "Face at ~+X not planar");
+		  }
+
+		  return good;		
+	}
+	
+	private TrapSidePlane makePlane( 
+			Hep3Vector p1,
+			Hep3Vector p2,
+			Hep3Vector p3,
+			Hep3Vector p4)
+	{
+		double a, b, c, s;
+		Hep3Vector v12, v13, v14, Vcross;
+		TrapSidePlane plane = new TrapSidePlane();
+
+		boolean good=false;
+
+		v12    = sub(p2,p1);
+		v13    = sub(p3,p1);
+		v14    = sub(p4,p1);
+		Vcross = cross(v12,v13);
+
+		  if (abs(dot(Vcross,v14)/(Vcross.magnitude()*v14.magnitude())) > COPLANAR_TOLERANCE)
+		  {
+		    good = false;
+		  }
+		  else
+		  {
+		    // a,b,c correspond to the x/y/z components of the
+		    // normal vector to the plane
+		     
+		    //  a  = (p2.y()-p1.y())*(p1.z()+p2.z())+(p3.y()-p2.y())*(p2.z()+p3.z());
+		    //  a += (p4.y()-p3.y())*(p3.z()+p4.z())+(p1.y()-p4.y())*(p4.z()+p1.z()); // ?   
+		    // b  = (p2.z()-p1.z())*(p1.x()+p2.x())+(p3.z()-p2.z())*(p2.x()+p3.x());
+		    // b += (p4.z()-p3.z())*(p3.x()+p4.x())+(p1.z()-p4.z())*(p4.x()+p1.x()); // ?      
+		    // c  = (p2.x()-p1.x())*(p1.y()+p2.y())+(p3.x()-p2.x())*(p2.y()+p3.y());
+		    // c += (p4.x()-p3.x())*(p3.y()+p4.y())+(p1.x()-p4.x())*(p4.y()+p1.y()); // ?
+
+		    // Let create diagonals 4-2 and 3-1 than (4-2)x(3-1) provides
+		    // vector perpendicular to the plane directed to outside !!!
+		    // and a,b,c, = f(1,2,3,4) external relative to trap normal
+
+		    a = +(p4.y() - p2.y())*(p3.z() - p1.z())
+		        - (p3.y() - p1.y())*(p4.z() - p2.z());
+
+		    b = -(p4.x() - p2.x())*(p3.z() - p1.z())
+		        + (p3.x() - p1.x())*(p4.z() - p2.z());
+		 
+		    c = +(p4.x() - p2.x())*(p3.y() - p1.y())
+		        - (p3.x() - p1.x())*(p4.y() - p2.y());
+
+		    s = sqrt( a*a + b*b + c*c ); // so now vector plane.(a,b,c) is unit 
+
+		    if( s > 0 )
+		    {
+		      plane.a = a/s;
+		      plane.b = b/s;
+		      plane.c = c/s;
+		    }
+		    else
+		    {
+		    	throw new RuntimeException();
+		      //G4cerr << "ERROR - G4Trap()::MakePlane(): " << GetName() << G4endl;
+		      //G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
+		      //            "Invalid parameters: norm.mod() <= 0") ;
+		    }
+		    // Calculate D: p1 in in plane so D=-n.p1.Vect()
+		    
+		    plane.d = -( plane.a*p1.x() + plane.b*p1.y() + plane.c*p1.z() );
+
+		    good = true;
+		  }
+		  
+		  if (good == false)
+		  {
+			  plane = null;
+		  }
+		  
+		  return plane;
+	}	
+	
+	public double getCubicVolume()
+	{
+	  if(cubicVolume != 0.) {;}
+	  else  { cubicVolume = dz*( (dx1+dx2+dx3+dx4)*(dy1+dy2)
+	                             + (dx4+dx3-dx2-dx1)*(dy2-dy1)/3 ); }
+	  return cubicVolume;
+	}
+		
+	public Inside inside(Hep3Vector p)
+	{
+		Inside in;
+		double Dist;
+		int i;
+		if ( abs(p.z()) <= dz-TOLERANCE*0.5)
+		{
+			in = INSIDE;
+
+			for ( i = 0;i < 4;i++ )
+			{
+				Dist = planes[i].a*p.x() + planes[i].b*p.y()
+				+planes[i].c*p.z() + planes[i].d;
+
+				if      (Dist >  TOLERANCE*0.5)  return in = OUTSIDE;
+				else if (Dist > -TOLERANCE*0.5)         in = SURFACE;
+
+			}
+		}
+		else if (abs(p.z()) <= dz+TOLERANCE*0.5)
+		{
+			in = SURFACE;
+
+			for ( i = 0; i < 4; i++ )
+			{
+				Dist =  planes[i].a*p.x() + planes[i].b*p.y()
+				+planes[i].c*p.z() + planes[i].d;
+
+				if (Dist > TOLERANCE*0.5)        return in = OUTSIDE;      
+			}
+		}
+		else in = OUTSIDE;
+
+		return in;
+	}	
+			
+	public Hep3Vector[] getPoints()
+	{	
+		Hep3Vector points[] = new Hep3Vector[8];
+		points[0] = new BasicHep3Vector(-dz*TthetaCphi-dy1*Talpha1-dx1,-dz*TthetaSphi-dy1,-dz);
+		points[1] = new BasicHep3Vector(-dz*TthetaCphi-dy1*Talpha1+dx1,-dz*TthetaSphi-dy1,-dz);
+		points[2] = new BasicHep3Vector(-dz*TthetaCphi+dy1*Talpha1-dx2,-dz*TthetaSphi+dy1,-dz);
+		points[3] = new BasicHep3Vector(-dz*TthetaCphi+dy1*Talpha1+dx2,-dz*TthetaSphi+dy1,-dz);
+		points[4] = new BasicHep3Vector(+dz*TthetaCphi-dy2*Talpha2-dx3,+dz*TthetaSphi-dy2,+dz);
+		points[5] = new BasicHep3Vector(+dz*TthetaCphi-dy2*Talpha2+dx3,+dz*TthetaSphi-dy2,+dz);
+		points[6] = new BasicHep3Vector(+dz*TthetaCphi+dy2*Talpha2-dx4,+dz*TthetaSphi+dy2,+dz);
+		points[7] = new BasicHep3Vector(+dz*TthetaCphi+dy2*Talpha2+dx4,+dz*TthetaSphi+dy2,+dz);					
+		return points;
+	}
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/solids
AbstractSolid.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- AbstractSolid.java	6 Mar 2007 20:22:17 -0000	1.3
+++ AbstractSolid.java	7 Aug 2007 22:47:54 -0000	1.4
@@ -12,10 +12,5 @@
 	{
 		super(name);
 		SolidStore.getInstance().add(this);
-	}
-	
-	//protected void finalize()
-	//{
-	//	SolidStore.getInstance().remove(this);
-	//}
+	}	
 }
\ No newline at end of file

GeomConverter/test/org/lcsim/detector/solids
TrapTest.java added at 1.1
diff -N TrapTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrapTest.java	7 Aug 2007 22:47:54 -0000	1.1
@@ -0,0 +1,95 @@
+package org.lcsim.detector.solids;
+
+import static org.lcsim.units.clhep.SystemOfUnits.m;
+import junit.framework.TestCase;
+
+import org.lcsim.detector.DetectorElement;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.IPhysicalVolumeNavigator;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.PhysicalVolumeNavigatorStore;
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.converter.heprep.DetectorElementToHepRepConverter;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialElement;
+
+/**
+ * Test that writes out the HepRep for a {@link org.lcsim.detector.solids.Trap} solid.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: TrapTest.java,v 1.1 2007/08/07 22:47:54 jeremy Exp $
+ */
+
+public class TrapTest 
+extends TestCase
+{	
+	private static IMaterial dummymat = new MaterialElement("dummymat",1,1,1.0);
+	IPhysicalVolumeNavigator nav;
+	IPhysicalVolume world;
+	
+	public void testTrd() throws Exception
+	{
+		createGeometry();
+		DetectorElementToHepRepConverter.writeHepRep("trap.heprep");
+	}
+	
+	public IPhysicalVolume createGeometry()
+	{
+		world = createWorld();
+    	nav = PhysicalVolumeNavigatorStore.getInstance().createDefault(world);
+		createSolids(world);
+		return world;
+	}
+	
+	public final void createSolids(IPhysicalVolume mom)
+	{
+		double dx1 = 30;
+		double dx2 = 40;
+		double dy1 = 40;
+		double dx3 = 10;
+		double dx4 = 14;
+		double dy2 = 16;
+		double dz = 60;
+		double theta = Math.toRadians(20);
+		double phi = Math.toRadians(5);
+		double alph1 = Math.toRadians(10);
+		double alph2 = alph1;
+				
+		Trap trap = new Trap("trap",dz,theta,phi,dy1,dx1,dx2,alph1,dy2,dx3,dx4,alph2);
+		LogicalVolume lvTest = new LogicalVolume("lvtrap",trap,dummymat);
+		new PhysicalVolume(
+				new Transform3D(),
+				"pvtrap",
+				lvTest,
+				mom.getLogicalVolume(),
+				0);			
+		
+		new DetectorElement("detrap",null,"/pvtrap");
+	}
+	
+	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;
+	}   	
+}

GeomConverter/test/org/lcsim/detector/solids
TrdTest.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- TrdTest.java	7 Aug 2007 18:11:39 -0000	1.3
+++ TrdTest.java	7 Aug 2007 22:47:54 -0000	1.4
@@ -9,8 +9,6 @@
 import hep.graphics.heprep.HepRepType;
 import hep.graphics.heprep.HepRepTypeTree;
 import hep.graphics.heprep.HepRepWriter;
-import hep.physics.vec.BasicHep3Vector;
-import hep.physics.vec.Hep3Vector;
 
 import java.awt.Color;
 import java.io.FileOutputStream;
@@ -22,15 +20,15 @@
 import org.lcsim.detector.IDetectorElement;
 import org.lcsim.detector.IPhysicalVolume;
 import org.lcsim.detector.IPhysicalVolumeNavigator;
+import org.lcsim.detector.IRotation3D;
+import org.lcsim.detector.ITransform3D;
+import org.lcsim.detector.ITranslation3D;
 import org.lcsim.detector.LogicalVolume;
 import org.lcsim.detector.PhysicalVolume;
 import org.lcsim.detector.PhysicalVolumeNavigatorStore;
-import org.lcsim.detector.IRotation3D;
 import org.lcsim.detector.RotationPassiveXYZ;
-import org.lcsim.detector.ITranslation3D;
-import org.lcsim.detector.Translation3D;
-import org.lcsim.detector.ITransform3D;
 import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.Translation3D;
 import org.lcsim.detector.converter.heprep.DetectorElementToHepRepConverter;
 import org.lcsim.detector.material.IMaterial;
 import org.lcsim.detector.material.MaterialElement;
@@ -39,7 +37,7 @@
  * Test that writes out the HepRep for a {@link org.lcsim.detector.solids.Trd}.
  *
  * @author Jeremy McCormick
- * @version $Id: TrdTest.java,v 1.3 2007/08/07 18:11:39 tknelson Exp $
+ * @version $Id: TrdTest.java,v 1.4 2007/08/07 22:47:54 jeremy Exp $
  */
 
 public class TrdTest 
@@ -52,7 +50,7 @@
 	public void testTrd() throws Exception
 	{
 		createGeometry();
-		writeHepRep("trd.heprep");
+		DetectorElementToHepRepConverter.writeHepRep("trd.heprep");
 	}
 	
 	public IPhysicalVolume createGeometry()
@@ -130,83 +128,5 @@
 					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);
-
-        HepRepInstanceTree instanceTree = factory.createHepRepInstanceTree("Detector", "1.0", typeTree);
-        root.addInstanceTree(instanceTree);
-
-        String detectorLayer = "Detector";
-        root.addLayer(detectorLayer);
-
-        HepRepType barrel = factory.createHepRepType(typeTree, "Barrel");
-        barrel.addAttValue("layer", detectorLayer);
-        HepRepType endcap = factory.createHepRepType(typeTree, "Endcap");
-        endcap.addAttValue("layer", detectorLayer);
-              
-        for (IDetectorElement de : DetectorElementStore.getInstance())
-        {        	
-        	DetectorElementToHepRepConverter.convert(de, factory, root, false);
-        }
-        // 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                              
-
-        HepRepWriter writer = 
-            HepRepFactory.create().createHepRepWriter(new FileOutputStream(filepath),false,false);
-        writer.write(root,"test");
-        writer.close();
-    }    
+	}   	
 }
CVSspam 0.2.8