Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd on MAIN
PolyhedraEndcapCalorimeter2.java+47-261.2 -> 1.3
JM: work in progress

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
PolyhedraEndcapCalorimeter2.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- PolyhedraEndcapCalorimeter2.java	6 Feb 2009 18:07:32 -0000	1.2
+++ PolyhedraEndcapCalorimeter2.java	6 Feb 2009 19:10:09 -0000	1.3
@@ -28,8 +28,6 @@
 
     public void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
     {
-    	System.out.println("TEST");
-    	
         Solids solids = lcdd.getSolids();
         Structure structure = lcdd.getStructure();
         Volume motherVolume = lcdd.pickMotherVolume(this);
@@ -53,19 +51,17 @@
         LayerStack layers = Layering.makeLayering(this.node).getLayerStack();
         
         double subdetectorThickness = org.lcsim.geometry.layer.LayerFromCompactCnv.computeDetectorTotalThickness(node);                        
-        //double radialThickness = rmax - rmin;
-        
-        //System.out.println("subdetectorThickness: " + subdetectorThickness);
+
         PolyhedraRegular envelopeSolid = new PolyhedraRegular(subdetectorName + "_envelope", numsides, rmin, rmax, subdetectorThickness);
         solids.addSolid(envelopeSolid);
         Volume envelopeVolume = new Volume(subdetectorName + "_volume", envelopeSolid, air);
         
         int layerNumber = 0;
         int layerType = 0;
-        double layerZ = subdetectorThickness/2;
-        for (Iterator i = node.getChildren("layer").iterator(); i.hasNext();)
+        double layerZ = -subdetectorThickness/2;
+        for (Iterator<Element> i = node.getChildren("layer").iterator(); i.hasNext();)
         {
-            Element layerElement = (Element) i.next();
+            Element layerElement = i.next();
             double layerThickness = layers.getLayer(layerNumber).getThickness();
             String layerTypeName = subdetectorName + "_layer" + layerType;            
             if (layerElement.getAttribute("repeat") == null)
@@ -75,9 +71,9 @@
             PolyhedraRegular layerSolid = new PolyhedraRegular(layerTypeName + "_solid", numsides, rmin, rmax, layerThickness);
             solids.addSolid(layerSolid);
             Volume layerVolume = new Volume(layerTypeName + "_volume", layerSolid, air);
-            
+               
             int sliceNumber = 0;
-            double sliceZ = layerThickness/2;
+            double sliceZ = -layerThickness/2;
             for (Iterator j = layerElement.getChildren("slice").iterator(); j.hasNext();)
             {
                 String sliceName = layerTypeName + "_slice" + sliceNumber;
@@ -92,43 +88,68 @@
                 PolyhedraRegular sliceSolid = new PolyhedraRegular(sliceName + "_solid", numsides, rmin, rmax, sliceThickness);
                 solids.addSolid(sliceSolid);
                 Volume sliceVolume = new Volume(sliceName + "_volume", sliceSolid, sliceMaterial);
+                if (sliceElement.getAttribute("sensitive") != null)
+                {
+                	if (sliceElement.getAttribute("sensitive").getBooleanValue() == true)
+                	{
+                		sliceVolume.setSensitiveDetector(sens);
+                	}
+                }
                 structure.addVolume(sliceVolume);
-                sliceZ -= sliceThickness/2;
+                sliceZ += sliceThickness/2;
                 Position slicePosition = new Position(sliceName + "_position", 0, 0, sliceZ);
                 define.addPosition(slicePosition);
-                sliceZ -= sliceThickness/2;
-                new PhysVol(sliceVolume, layerVolume, slicePosition, identityRotation);
+                sliceZ += sliceThickness/2;
+                PhysVol slicePhysVol = new PhysVol(sliceVolume, layerVolume, slicePosition, identityRotation);
+                slicePhysVol.addPhysVolID("slice", sliceNumber);
                 sliceNumber++;
             }
-
-            structure.addVolume(layerVolume);
-            //sliceNumber = 0;                        
+            sliceNumber = 0;
+            structure.addVolume(layerVolume);        
             int repeat = (int)layerElement.getAttribute("repeat").getDoubleValue();
             if (repeat <= 0)
                 throw new RuntimeException("The repeat value of " + repeat + " is invalid.");          
             for ( int j=0; j<repeat; j++)
             {
                 String physLayerName = subdetectorName + "_layer" + layerNumber;
-                //System.out.println("incr: " + layerThickness/2);
-                layerZ -= layerThickness/2;
-                //System.out.println("layer " + layerNumber + " at " + layerZ);
+                layerZ += layerThickness/2;
                 Position layerPosition = new Position(physLayerName + "_position", 0, 0, layerZ);
                 define.addPosition(layerPosition);
-                new PhysVol(layerVolume, envelopeVolume, layerPosition, identityRotation);
-                layerZ -= layerThickness/2;
-                //System.out.println("new layer Z " + layerZ);
+                PhysVol layerPhysVol = new PhysVol(layerVolume, envelopeVolume, layerPosition, identityRotation);
+                layerPhysVol.addPhysVolID("layer", layerNumber);
+                layerZ += layerThickness/2;
                 ++layerNumber;
             }
             ++layerType;            
         }
         structure.addVolume(envelopeVolume);
-        Position testPosition = new Position(subdetectorName + "_position",0,0,zmin + subdetectorThickness/2);
-        define.addPosition(testPosition);
-        new PhysVol(envelopeVolume, motherVolume, testPosition, identityRotation);
+                
+        PhysVol physvol = new PhysVol(envelopeVolume);
+        physvol.setZ(zmin+subdetectorThickness/2);
+        physvol.addPhysVolID("system",id);
+        physvol.addPhysVolID("barrel",1);
+        motherVolume.addPhysVol(physvol);
+        
+        boolean reflect = true;
+        if (node.getAttribute("reflect") != null )
+        {
+        	reflect = node.getAttribute("reflect").getBooleanValue();
+        }
+        	
+        if (reflect)
+        {
+            PhysVol physvol2 = new PhysVol(envelopeVolume);
+            physvol2.setZ(-zmin-subdetectorThickness/2);
+            Rotation reflection = lcdd.getDefine().getRotation("reflect_rot");
+            physvol2.setRotation(reflection);
+            physvol2.addPhysVolID("system",id);
+            physvol2.addPhysVolID("barrel",2);
+            motherVolume.addPhysVol(physvol2);
+        }
     }
     
     public boolean isCalorimeter()
     {
         return true;
     }    
-}
+}
\ No newline at end of file
CVSspam 0.2.8