Commit in GeomConverter/src/org/lcsim/detector/converter/compact on MAIN
SiTrackerBarrelConverter.java+173-1761.23 -> 1.24
Changes to accommodate modifications to SiSensor and SiSensorElectrode classes

GeomConverter/src/org/lcsim/detector/converter/compact
SiTrackerBarrelConverter.java 1.23 -> 1.24
diff -u -r1.23 -r1.24
--- SiTrackerBarrelConverter.java	25 Sep 2007 23:43:07 -0000	1.23
+++ SiTrackerBarrelConverter.java	14 Oct 2007 06:00:27 -0000	1.24
@@ -46,15 +46,16 @@
 import org.lcsim.geometry.subdetector.SiTrackerBarrel;
 
 public class SiTrackerBarrelConverter
-implements ISubdetectorConverter
+        implements ISubdetectorConverter
 {
     public void convert( Subdetector subdet, Detector detector)
-    {        
-    	subdet.setDetectorElement( new DeSiTrackerBarrel( subdet.getName(), detector.getDetectorElement()));
-    	
+    {
+        subdet.setDetectorElement( new DeSiTrackerBarrel( subdet.getName(), detector.getDetectorElement()));
+        
         Map<String, ILogicalVolume> modules = buildModules(subdet);
         
-        try {
+        try
+        {
             buildLayers(detector, subdet, modules);
         }
         catch ( DataConversionException x )
@@ -94,7 +95,7 @@
     {
         String subdetName = subdetElement.getAttributeValue("name");
         ILogicalVolume moduleLogVol = null;
-
+        
         Element moduleElement=null;
         for (Iterator i = subdetElement.getChildren("module").iterator(); i.hasNext();)
         {
@@ -102,25 +103,25 @@
             if (moduleCheck.getAttributeValue("name").compareTo(module_name) == 0)
             {
                 moduleElement = moduleCheck;
-            }            
+            }
         }
         if ( moduleElement == null )
         {
             throw new RuntimeException("module <" + module_name + " was not found");
         }
         
-        Element moduleEnvelopeElement = moduleElement.getChild("module_envelope");        
-
+        Element moduleEnvelopeElement = moduleElement.getChild("module_envelope");
+        
         // Create the module box.
         double moduleLength = moduleEnvelopeElement.getAttribute("length").getDoubleValue();
         double moduleWidth = moduleEnvelopeElement.getAttribute("width").getDoubleValue();
         double moduleThickness = moduleEnvelopeElement.getAttribute("thickness").getDoubleValue();
-        ISolid moduleBox = 
-            new Box(module_name + "_box", 
-                    moduleWidth/2, 
-                    moduleLength/2, 
-                    moduleThickness/2);
-       
+        ISolid moduleBox =
+                new Box(module_name + "_box",
+                moduleWidth/2,
+                moduleLength/2,
+                moduleThickness/2);
+        
         // Create the module logical volume.
         IMaterial air = MaterialStore.getInstance().get("Air");
         moduleLogVol = new LogicalVolume(module_name, moduleBox, air);
@@ -129,45 +130,45 @@
         for (Iterator j = moduleElement.getChildren("module_component").iterator(); j.hasNext(); ++componentNumber)
         {
             Element componentElement = (Element) j.next();
-
+            
             boolean sensitive = ((componentElement.getAttribute("sensitive") == null) ? false : componentElement.getAttribute("sensitive").getBooleanValue());
-
+            
             String componentName = module_name + "_component" + componentNumber;
             
             // Create the box solid for the module component.
             double componentLength = componentElement.getAttribute("length").getDoubleValue();
             double componentWidth = componentElement.getAttribute("width").getDoubleValue();
             double componentThickness = componentElement.getAttribute("thickness").getDoubleValue();
-            ISolid componentBox = 
-                new Box(componentName,
-                        componentWidth/2,
-                        componentLength/2,
-                        componentThickness/2);
-
-            IMaterial componentMaterial = 
-                MaterialStore.getInstance().get(componentElement.getAttributeValue("material"));            
+            ISolid componentBox =
+                    new Box(componentName,
+                    componentWidth/2,
+                    componentLength/2,
+                    componentThickness/2);
+            
+            IMaterial componentMaterial =
+                    MaterialStore.getInstance().get(componentElement.getAttributeValue("material"));
             
             // Create the volume for the module component.
-            ILogicalVolume componentLogVol = 
-                new LogicalVolume(componentName, componentBox, componentMaterial);
-                                    
-            // Set component position.                 
+            ILogicalVolume componentLogVol =
+                    new LogicalVolume(componentName, componentBox, componentMaterial);
+            
+            // Set component position.
             double px=0, py=0, pz=0;
             
             if (componentElement.getChild("position") != null)
             {
                 Element pos_elem = componentElement.getChild("position");
-
+                
                 if (pos_elem.getAttribute("x") != null)
                 {
                     px = pos_elem.getAttribute("x").getDoubleValue();
                 }
-
+                
                 if (pos_elem.getAttribute("y") != null)
                 {
                     py = pos_elem.getAttribute("y").getDoubleValue();
                 }
-
+                
                 if (pos_elem.getAttribute("z") != null)
                 {
                     pz = pos_elem.getAttribute("z").getDoubleValue();
@@ -175,24 +176,24 @@
             }
             
             ITranslation3D pos = new Translation3D(px,py,pz);
-
+            
             // Set component rotation.
             double rx=0, ry=0, rz=0;
             
             if (componentElement.getChild("rotation") != null)
             {
                 Element rot_elem = componentElement.getChild("rotation");
-
+                
                 if (rot_elem.getAttribute("x") != null)
                 {
                     rot_elem.getAttribute("x").getDoubleValue();
                 }
-
+                
                 if (rot_elem.getAttribute("y") != null)
                 {
                     rot_elem.getAttribute("y").getDoubleValue();
                 }
-
+                
                 if (rot_elem.getAttribute("z") != null)
                 {
                     rot_elem.getAttribute("z").getDoubleValue();
@@ -200,33 +201,34 @@
             }
             
             IRotation3D rot = new RotationPassiveXYZ(rx,ry,rz);
-
+            
             // Make transform
             Transform3D componentTransform = new Transform3D(pos,rot);
             
             PhysicalVolume componentPhysVol =
-                new PhysicalVolume(
+                    new PhysicalVolume(
                     componentTransform,
                     componentName,
                     componentLogVol,
                     moduleLogVol,
                     componentNumber
-                    );            
-           
-            if ( sensitive ) {
+                    );
+            
+            if ( sensitive )
+            {
                 componentPhysVol.setSensitive(true);
             }
             
-            ++componentNumber;            
-        }        
-                
-        return moduleLogVol;        
+            ++componentNumber;
+        }
+        
+        return moduleLogVol;
     }
     
     private void buildLayers(
-            Detector detector, 
-            Subdetector subdet, 
-            Map<String,ILogicalVolume> modules) throws DataConversionException   
+            Detector detector,
+            Subdetector subdet,
+            Map<String,ILogicalVolume> modules) throws DataConversionException
     {
         Element node = subdet.getNode();
         String detector_name = subdet.getName();
@@ -237,28 +239,28 @@
         {
             // Get the next layer element.
             Element layer_element = (Element) i.next();
-
+            
             // Get the reference to the module from the layer.
             String module_name = layer_element.getAttributeValue("module");
-
+            
             // Get the logical volume for the module.
             ILogicalVolume moduleEnvelope = modules.get(module_name);
-
+            
             // Get the barrel_envelope for this layer.
             Element barrel_envelope = layer_element.getChild("barrel_envelope");
-
+            
             // Inner radius of layer.
             double ir = barrel_envelope.getAttribute("inner_r").getDoubleValue();
-
+            
             // Outer radius of layer.
             double or = barrel_envelope.getAttribute("outer_r").getDoubleValue();
-
+            
             // Full length in z of layer.
             double oz = barrel_envelope.getAttribute("z_length").getDoubleValue();
-
+            
             // Name of this layer including layer number.
             String layer_name = detector_name + "_layer" + nlayer;
-
+            
             //System.out.println("layer_name=" + layer_name);
             
             Tube layer_tube = new Tube(
@@ -266,78 +268,78 @@
                     ir,
                     or,
                     oz/2);
-
+            
             // Create the layer envelope volume.
             IMaterial air = MaterialStore.getInstance().get("Air");
-            ILogicalVolume layer_volume = 
-                new LogicalVolume(layer_name, layer_tube, air);
+            ILogicalVolume layer_volume =
+                    new LogicalVolume(layer_name, layer_tube, air);
             
             // Layer PhysicalVolume.
-            IPhysicalVolume layer_envelope_physvol = 
-                new PhysicalVolume(
-                        null,
-                        layer_name,
-                        layer_volume,
-                        detector.getTrackingVolume().getLogicalVolume(),
-                        nlayer); 
+            IPhysicalVolume layer_envelope_physvol =
+                    new PhysicalVolume(
+                    null,
+                    layer_name,
+                    layer_volume,
+                    detector.getTrackingVolume().getLogicalVolume(),
+                    nlayer);
             
             // Layer DE.
             String layerPath = "/tracking_region/" + layer_name;
-            IDetectorElement layerDE = 
-                new SiTrackerBarrelLayer(layer_name, subdet.getDetectorElement(), layerPath, nlayer);            
-
+            IDetectorElement layerDE =
+                    new SiTrackerBarrelLayer(layer_name, subdet.getDetectorElement(), layerPath, nlayer);
+            
             // Get the rphi_layout element.
             Element rphi_layout = layer_element.getChild("rphi_layout");
-
+            
             // Starting phi of first module.
             double phi0 = rphi_layout.getAttribute("phi0").getDoubleValue();
-
+            
             // Number of modules in phi.
             int nphi = rphi_layout.getAttribute("nphi").getIntValue();
             assert (nphi > 0);
-
+            
             // Phi tilt of a module.
             double phi_tilt = rphi_layout.getAttribute("phi_tilt").getDoubleValue();
-
+            
             // Radius of the module center.
             double rc = rphi_layout.getAttribute("rc").getDoubleValue();
-
+            
             // The delta radius of every other module.
             double rphi_dr = 0.0;
             if (rphi_layout.getAttribute("dr") != null)
             {
                 rphi_dr = rphi_layout.getAttribute("dr").getDoubleValue();
             }
-
+            
             // Phi increment for one module.
             double phi_incr = (Math.PI * 2) / nphi;
-
+            
             // Phi of the module center.
             double phic = 0;
             phic += phi0;
-
+            
             // Get the <z_layout> element.
             Element z_layout = layer_element.getChild("z_layout");
-
+            
             // Z position of first module in phi.
             double z0 = z_layout.getAttribute("z0").getDoubleValue();
-
+            
             // Number of modules to place in z.
             double nz = z_layout.getAttribute("nz").getIntValue();
             assert (nz > 0);
-
+            
             // Radial displacement parameter, of every other module.
             double z_dr = z_layout.getAttribute("dr").getDoubleValue();
-
+            
             // Z increment for module placement along Z axis.
             // Adjust for z0 at center of module rather than
             // the end of cylindrical envelope.
             double z_incr = (2.0 * z0) / (nz - 1);
-
+            
             // Starting z for module placement along Z axis.
             double module_z = -z0;
-
-            // DEBUG 
+            
+            // DEBUG
             //System.out.println("layer ir=" + ir);
             //System.out.println("layer or=" + or);
             //System.out.println("layer oz=" + oz);
@@ -349,9 +351,9 @@
             //System.out.println("module nz=" + nz);
             //System.out.println("module dr=" + dr);
             //
-
+            
             //String module_lkp_name = layer.getAttributeValue("module");
-
+            
             int moduleId=0;
             
             // Loop over the number of modules in phi.
@@ -359,24 +361,24 @@
             {
                 // Delta x of module position.
                 double dx = z_dr * cos(phic + phi_tilt);
-
+                
                 // Delta y of module position.
                 double dy = z_dr * sin(phic + phi_tilt);
-
+                
                 // Basic x module position.
                 double x = rc * cos(phic);
-
+                
                 // Basic y module position.
                 double y = rc * sin(phic);
-
+                
                 // Loop over the number of modules in z.
                 for (int zcount = 0; zcount < nz; zcount++)
                 {
                     // Create a unique name for the module in this logical volume, layer, phi, and z.
                     String module_place_name = detector_name + "_layer" + nlayer + "_phi" + phicount + "_z" + zcount;
-
+                    
                     double z = module_z;
-
+                    
                     // DEBUG
                     //System.out.println("module build...");
                     //System.out.println("module nphi=" + ii);
@@ -385,19 +387,19 @@
                     //System.out.println("module y=" + y);
                     //System.out.println("module z=" + z);
                     // DEBUG
-
+                    
                     // Position of module.
                     //Position module_position = new Position(module_place_name + "_position");
-                    ITranslation3D module_position = new Translation3D(x,y,z); 
+                    ITranslation3D module_position = new Translation3D(x,y,z);
                     
                     /*
-                     from the LCDD converter 
+                     from the LCDD converter
                      
                     double rotx = Math.PI / 2;
                     double roty = -((Math.PI / 2) - phic - phi_tilt);
                     double rotz = 0;
-                                        
-                    */
+                     
+                     */
                     
                     // Rotation of module.
                     
@@ -407,67 +409,67 @@
                     double rotx = Math.PI/2;
                     double roty = 0;
                     double rotz = ((Math.PI / 2) - phic - phi_tilt);
-
-
+                    
+                    
                     IRotation3D module_rotation = new RotationPassiveXYZ(rotx,roty,rotz);
-
+                    
                     //System.out.println("module rotx=" + rotx);
                     //System.out.println("module roty=" + roty);
                     //System.out.println("module rotz=" + rotz);
                     
                     Transform3D moduleTransform = new Transform3D(module_position, module_rotation);
-                                       
+                    
                     // Module PhysicalVolume.
                     IPhysicalVolume module_physvol =
-                        new PhysicalVolume(
-                                moduleTransform,
-                                module_place_name,
-                                moduleEnvelope,
-                                layer_volume,
-                                moduleId
-                                );
+                            new PhysicalVolume(
+                            moduleTransform,
+                            module_place_name,
+                            moduleEnvelope,
+                            layer_volume,
+                            moduleId
+                            );
                     
-                    String modulePath = 
-                        "/tracking_region/" + layer_name + "/" + module_place_name;
+                    String modulePath =
+                            "/tracking_region/" + layer_name + "/" + module_place_name;
                     
                     new SiTrackerBarrelModule(
-                            module_place_name, 
-                            layerDE, 
+                            module_place_name,
+                            layerDE,
                             modulePath,
                             moduleId);
                     
                     // Increment the by-layer module number.
                     ++moduleId;
-                                                                                                                        
+                    
                     // Adjust the x and y coordinates of the module.
                     x += dx;
                     y += dy;
-
+                    
                     // Flip sign of x and y adjustments.
                     dx *= -1;
                     dy *= -1;
-
+                    
                     // Add z increment to get next z placement pos.
                     module_z += z_incr;
-
+                    
                     //System.out.println();
                 }
-
+                
                 // Increment the phi placement of module.
                 phic += phi_incr;
-
+                
                 // Increment the center radius according to dr parameter.
                 rc += rphi_dr;
-
+                
                 // Flip sign of dr parameter.
                 rphi_dr *= -1;
-
+                
                 // Reset the Z placement parameter for module.
                 module_z = -z0;
-            }                                   
+            }
         }
     }
-
+    
     public Class getSubdetectorType()
     {
         return SiTrackerBarrel.class;
@@ -480,54 +482,56 @@
         {
             for ( IDetectorElement module : layer.getChildren() )
             {
-                IPhysicalVolumePath modulePath = 
-                    module.getGeometry().getPath();
+                IPhysicalVolumePath modulePath =
+                        module.getGeometry().getPath();
                 
                 IPhysicalVolume modulePhysVol =
-                    modulePath.getLeafVolume();               
+                        modulePath.getLeafVolume();
                 
                 int sensorId=0;
                 for ( IPhysicalVolume pv : modulePhysVol.getLogicalVolume().getDaughters())
                 {
-                	// Create the identifier for this sensor.
+                    // Create the identifier for this sensor.
                     if ( pv.isSensitive() )
-                    {        
-                		IIdentifierDictionary iddict = 
-                			IdentifierDictionaryManager.getInstance().
-                			getIdentifierDictionary( subdet.getReadout().getName() );
-                    	
-                		ExpandedIdentifier expId = new ExpandedIdentifier(iddict.getNumberOfFields());
-                		
-                    	try {                    		                    		                    		
-                    		// Set the System ID.                        
-                    		expId.setValue(iddict.getFieldIndex("system"), subdet.getSystemID());
-
-                    		// Set the barrel-endcap flag.
-                    		expId.setValue(iddict.getFieldIndex("barrel"), 0);
-
-                    		// Set the layer number.
-                    		expId.setValue(iddict.getFieldIndex("layer"), layer.getGeometry().getPath().getLeafVolume().getCopyNumber());
-
-                    		// Set the module id from the DetectorElement.
-                    		expId.setValue(iddict.getFieldIndex("module"),((SiTrackerBarrelModule)module).getModuleId());
-
-                    		// Set the sensor id for double-sided.
-                    		expId.setValue(iddict.getFieldIndex("sensor"),sensorId);
-                    	}
-                    	catch (FieldNotFoundException x)
-                    	{
-                    		throw new RuntimeException(x);
-                    	}
-                                             
-                        // Create the packed id using util method.  
+                    {
+                        IIdentifierDictionary iddict =
+                                IdentifierDictionaryManager.getInstance().
+                                getIdentifierDictionary( subdet.getReadout().getName() );
+                        
+                        ExpandedIdentifier expId = new ExpandedIdentifier(iddict.getNumberOfFields());
+                        
+                        try
+                        {
+                            // Set the System ID.
+                            expId.setValue(iddict.getFieldIndex("system"), subdet.getSystemID());
+                            
+                            // Set the barrel-endcap flag.
+                            expId.setValue(iddict.getFieldIndex("barrel"), 0);
+                            
+                            // Set the layer number.
+                            expId.setValue(iddict.getFieldIndex("layer"), layer.getGeometry().getPath().getLeafVolume().getCopyNumber());
+                            
+                            // Set the module id from the DetectorElement.
+                            expId.setValue(iddict.getFieldIndex("module"),((SiTrackerBarrelModule)module).getModuleId());
+                            
+                            // Set the sensor id for double-sided.
+                            expId.setValue(iddict.getFieldIndex("sensor"),sensorId);
+                        }
+                        catch (FieldNotFoundException x)
+                        {
+                            throw new RuntimeException(x);
+                        }
+                        
+                        // Create the packed id using util method.
                         // No IdentifierHelper is available yet.
                         IIdentifier id = null;
-                        try {
-                        	id = IdentifierUtil.pack( iddict, expId );
+                        try
+                        {
+                            id = IdentifierUtil.pack( iddict, expId );
                         }
                         catch (InvalidIndexException x)
                         {
-                        	throw new RuntimeException(x);
+                            throw new RuntimeException(x);
                         }
                         
                         //System.out.println(pv.getName() + " is sens");
@@ -535,33 +539,26 @@
                         String sensorPath = modulePath.toString() + "/" + pv.getName();
                         //String sensorName = subdet.getName() + "_layer" + layer.getGeometry().getPhysicalVolume().getCopyNumber() + "_module" + moduleId + "_sensor" + sensorId;
                         String sensorName = subdet.getName() + "_layer" + layer.getGeometry().getPhysicalVolume().getCopyNumber() + "_module" + ((SiTrackerBarrelModule)module).getModuleId() + "_sensor" + sensorId;
-                                                                        
-//                        SiSensor sensor = new SiSensor(sensorId, sensorName, module, sensorPath, id);
-//                        sensor.setIdentifier( id );
-//                        sensor.setElectrodes(ChargeCarrier.HOLE,new SiStrips(3679,0.025,1));
-////                        sensor.setElectrodes(ChargeCarrier.ELECTRON,new SiStrips(3679,0.025,1));
-//                        sensor.setElectrodeAngle(ChargeCarrier.HOLE,0.0);
-////                        sensor.setElectrodeAngle(ChargeCarrier.ELECTRON,0.0);
-//                        sensor.setOrientation(Orientation.PSIDE_POSITIVE_Z);
-//                        sensor.initialize();
-
+                        
                         SiSensor sensor = new SiSensor(sensorId,sensorName,module,sensorPath,id);
                         sensor.setIdentifier(id);
-                        SiSensorElectrodes sense_electrodes = new SiStrips(3679,0.025,0);
-                        SiSensorElectrodes readout_electrodes = new SiStrips(1840,0.050,0);
-                        double[][] transfer_efficiencies = { {0.986,0.419} } ;
-//                        double[][] transfer_efficiencies = { {1.0,0.40625} } ;
-//                        double[][] transfer_efficiencies = { {1.0,0.5} } ;
- 
+                        
+                        ITranslation3D electrodes_position = new Translation3D(0.0,0.0,sensor.getThickness()/2);
+                        IRotation3D electrodes_rotation = new RotationPassiveXYZ(0.0,0.0,0.0);
+                        Transform3D electrodes_transform = new Transform3D(electrodes_position, electrodes_rotation);
+                        
+                        SiSensorElectrodes sense_electrodes = new SiStrips(3679,0.025,sensor,electrodes_transform);
+                        SiSensorElectrodes readout_electrodes = new SiStrips(1840,0.050,sensor,electrodes_transform);
+                        double[][] transfer_efficiencies = { {0.986,0.419} };
+                        
                         sensor.setSenseElectrodes(ChargeCarrier.HOLE,sense_electrodes);
                         sensor.setReadoutElectrodes(ChargeCarrier.HOLE,readout_electrodes);
                         sensor.setTransferEfficiencies(ChargeCarrier.HOLE,new BasicMatrix(transfer_efficiencies));
-                        sensor.setElectrodeAngle(ChargeCarrier.HOLE,0.0);
                         sensor.setOrientation(Orientation.PSIDE_POSITIVE_Z);
                         sensor.initialize();
                         
                         // Incremenet sensorID for double-sided.
-                        ++sensorId;                        
+                        ++sensorId;
                     }
                 }
                 
CVSspam 0.2.8