1 added + 9 modified, total 10 files
GeomConverter/src/org/lcsim/detector/converter/compact
diff -N AbstractSubdetectorConverter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AbstractSubdetectorConverter.java 6 Dec 2007 01:26:33 -0000 1.1
@@ -0,0 +1,214 @@
+package org.lcsim.detector.converter.compact;
+
+import org.lcsim.detector.DetectorIdentifierHelper;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.DetectorIdentifierHelper.SystemMap;
+import org.lcsim.detector.identifier.ExpandedIdentifier;
+import org.lcsim.detector.identifier.IExpandedIdentifier;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierDictionary;
+import org.lcsim.detector.identifier.IIdentifierField;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.IdentifierDictionary;
+import org.lcsim.detector.identifier.IdentifierDictionaryManager;
+import org.lcsim.detector.identifier.IdentifierField;
+import org.lcsim.detector.identifier.IdentifierHelper;
+import org.lcsim.detector.identifier.IIdentifierDictionary.DuplicateFieldException;
+import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
+import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
+import org.lcsim.geometry.Readout;
+import org.lcsim.geometry.compact.Detector;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.util.IDDescriptor;
+
+/**
+ * An abstract implementation of {@link ISubdetectorConverter} that provides
+ * some utilities and default method implementations for Subdetector conversion.
+ *
+ * @author Jeremy McCormick
+ * @version $Id: AbstractSubdetectorConverter.java,v 1.1 2007/12/06 01:26:33 jeremy Exp $
+ */
+
+public abstract class AbstractSubdetectorConverter implements ISubdetectorConverter
+{
+ public void makeIdentifierContext(Subdetector subdet)
+ {
+ // Default is a no-op.
+ }
+
+ public IDetectorElement makeSubdetectorDetectorElement(Detector detector, Subdetector subdetector)
+ {
+ // Default is a no-op.
+ return null;
+ }
+
+ /**
+ * Sub-classes must implement this.
+ */
+ public abstract void convert(Subdetector subdet, Detector detector);
+
+ /**
+ * Sub-classes must implement this.
+ */
+ public abstract Class getSubdetectorType();
+
+ /**
+ * Creates a concrete {@link org.lcsim.detector.identifier.IIdentifierHelper} for this Subdetector.
+ * Concrete converter types should override this if they want to use a different type of helper.
+ * @return An IIdentifierHelper for this Subdetector.
+ */
+ public IIdentifierHelper makeIdentifierHelper(Subdetector subdetector, SystemMap systemMap)
+ {
+ // Do not create helper if there is no Readout.
+ if (subdetector.getReadout() == null)
+ return null;
+
+ // Make the IdentifierDictionary.
+ IIdentifierDictionary iddict = makeIdentifierDictionary(subdetector);
+
+ IIdentifierHelper helper = null;
+
+ try {
+ if (iddict.hasField("system") && iddict.hasField("barrel"))
+ {
+ // If description has the "standard" compact fields for
+ // system and barrel, then make a concrete type with
+ // some added utility.
+ helper = new DetectorIdentifierHelper(iddict, systemMap);
+ }
+ else
+ {
+ // Make a generic IdentifierHelper if standard fields are not present.
+ helper = new IdentifierHelper(iddict);
+ }
+ }
+ catch (FieldNotFoundException x)
+ {
+ throw new RuntimeException(x);
+ }
+ catch (InvalidIndexException x)
+ {
+ throw new RuntimeException(x);
+ }
+
+ return helper;
+ }
+
+ /**
+ * Utility method for creating an {@link org.lcsim.detector.identifier.IIdentifierDictionary}
+ * for a {@link org.lcsim.geometry.Subdetector} by using its {@link org.lcsim.geometry.IDDecoder}.
+ *
+ * @param subdet The Subdetector.
+ * @return A IdentifierDictionary.
+ */
+ static IIdentifierDictionary makeIdentifierDictionary(Subdetector subdet)
+ {
+ Readout ro = subdet.getReadout();
+ IIdentifierDictionary iddict = null;
+ if ( ro != null )
+ {
+ iddict = new IdentifierDictionary(ro.getName());
+ IdentifierDictionaryManager.getInstance().addIdentifierDictionary(iddict);
+
+ IDDescriptor desc = ro.getIDDescriptor();
+ for ( int i=0; i<desc.fieldCount(); i++ )
+ {
+ int nbits = Math.abs(desc.fieldLength(i));
+ int start = desc.fieldStart(i);
+ boolean signed = desc.isSigned(i);
+ String name = desc.fieldName(i);
+
+ IIdentifierField field = new IdentifierField(name,nbits,start,signed,i);
+ try {
+ iddict.addField(field);
+ }
+ catch (DuplicateFieldException x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
+ }
+ return iddict;
+ }
+
+ public void makeIdentifiers(Subdetector subdet)
+ {
+ if (subdet.getDetectorElement() == null)
+ return;
+
+ if (subdet.getDetectorElement().getIdentifierHelper() == null)
+ return;
+
+ IIdentifierHelper idhelper = subdet.getDetectorElement().getIdentifierHelper();
+
+ IIdentifierDictionary iddict = idhelper.getIdentifierDictionary();
+
+ int sys = subdet.getSystemID();
+ int sysIndex, barrelIndex;
+
+ try {
+ sysIndex = iddict.getFieldIndex("system");
+ barrelIndex = iddict.getFieldIndex("barrel");
+ }
+ catch (Exception x)
+ {
+ // Missing some required fields. Just ignore.
+ return;
+ }
+
+ IExpandedIdentifier expid = new ExpandedIdentifier(idhelper.getIdentifierDictionary().getNumberOfFields());
+
+ expid.setValue(sysIndex, sys);
+
+ // Barrel.
+ if (subdet.isBarrel())
+ {
+ expid.setValue(barrelIndex, 0);
+ try {
+ IIdentifier barrelId = idhelper.pack(expid);
+ subdet.getDetectorElement().setIdentifier(barrelId);
+ }
+ catch (InvalidIndexException x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
+ // Deal with endcaps.
+ else
+ {
+ try {
+ // Id for the endcap container DetectorElement.
+ IIdentifier endcapId = idhelper.pack(expid);
+ subdet.getDetectorElement().setIdentifier(endcapId);
+ }
+ catch (InvalidIndexException x)
+ {
+ throw new RuntimeException(x);
+ }
+
+ // Ids for the positive and negative endcaps.
+ for (IDetectorElement endcap : subdet.getDetectorElement().getChildren())
+ {
+ // Positive endcap.
+ if (endcap.getName().contains("positive"))
+ {
+ expid.setValue(barrelIndex, 1);
+ }
+ // Negative endcap.
+ else if (endcap.getName().contains("negative"))
+ {
+ expid.setValue(barrelIndex, 2);
+ }
+
+ try {
+ IIdentifier endcapSubId = idhelper.pack(expid);
+ endcap.setIdentifier(endcapSubId);
+ }
+ catch (InvalidIndexException x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.8 -r1.9
--- CylindricalBarrelCalorimeterConverter.java 9 May 2007 00:59:58 -0000 1.8
+++ CylindricalBarrelCalorimeterConverter.java 6 Dec 2007 01:26:33 -0000 1.9
@@ -9,18 +9,27 @@
import org.lcsim.detector.LogicalVolume;
import org.lcsim.detector.PhysicalVolume;
import org.lcsim.detector.PhysicalVolumeNavigatorStore;
+import org.lcsim.detector.identifier.IIdentifierDictionary;
+import org.lcsim.detector.identifier.IdentifierContext;
import org.lcsim.detector.material.IMaterial;
import org.lcsim.detector.material.MaterialStore;
import org.lcsim.detector.solids.Tube;
+import org.lcsim.geometry.IDDecoder;
import org.lcsim.geometry.compact.Detector;
import org.lcsim.geometry.compact.Subdetector;
import org.lcsim.geometry.layer.Layer;
import org.lcsim.geometry.layer.LayerSlice;
import org.lcsim.geometry.layer.Layering;
+import org.lcsim.geometry.segmentation.GridXYZ;
+import org.lcsim.geometry.segmentation.NonprojectiveCylinder;
+import org.lcsim.geometry.segmentation.ProjectiveCylinder;
+import org.lcsim.geometry.segmentation.ProjectiveZPlane;
+import org.lcsim.geometry.segmentation.SegmentationBase;
import org.lcsim.geometry.subdetector.CylindricalBarrelCalorimeter;
-public class CylindricalBarrelCalorimeterConverter
-implements ISubdetectorConverter
+public class CylindricalBarrelCalorimeterConverter
+extends AbstractSubdetectorConverter
+implements ISubdetectorConverter
{
public void convert(
Subdetector subdet,
@@ -157,7 +166,7 @@
// Path to the PhysicalVolume of this sensor.
String sensorPath = "/" + cal.getName() + "/" + layerName + "/" + sliceName;
- new CylindricalBarrelCalorimeterSensorLayer(
+ new DetectorElement(
cal.getName() + "_sensor" + sensorNumber,
cal.getDetectorElement(),
sensorPath);
@@ -170,19 +179,53 @@
}
}
}
+
+ public void makeIdentifierContext(Subdetector subdet)
+ {
+ /*
+ IIdentifierDictionary iddict = subdet.getDetectorElement().getIdentifierHelper().getIdentifierDictionary();
+
+ int systemIndex = iddict.getFieldIndex("system");
+ int barrelIndex = iddict.getFieldIndex("barrel");
+ int layerIndex = iddict.getFieldIndex("layer");
+
+ IdentifierContext systemContext = new IdentifierContext(new int[] {systemIndex});
+ IdentifierContext subdetContext = new IdentifierContext(new int[] {systemIndex,barrelIndex});
+ IdentifierContext layerContext = new IdentifierContext(new int[] {systemIndex,barrelIndex,layerIndex});
+
+ iddict.addIdentifierContext("system", systemContext);
+ iddict.addIdentifierContext("subdetector", subdetContext);
+ iddict.addIdentifierContext("layer", layerContext);
+
+ IDDecoder decoder = subdet.getIDDecoder();
+ if ( decoder instanceof SegmentationBase)
+ {
+ if (decoder instanceof NonprojectiveCylinder)
+ {
+ int phiIndex = iddict.getFieldIndex("phi");
+ int zIndex = iddict.getFieldIndex("z");
+ IdentifierContext cellContext =
+ new IdentifierContext(new int[] {systemIndex,barrelIndex,layerIndex,phiIndex,zIndex});
+ iddict.addIdentifierContext("cell", cellContext);
+ }
+ else if (decoder instanceof ProjectiveCylinder)
+ {
+ // TODO
+ }
+ else if (decoder instanceof GridXYZ)
+ {
+ // TODO
+ }
+ else if (decoder instanceof ProjectiveZPlane)
+ {
+ // TODO
+ }
+ }
+ */
+ }
public Class getSubdetectorType()
{
return CylindricalBarrelCalorimeter.class;
- }
-
- class CylindricalBarrelCalorimeterSensorLayer
- extends DetectorElement
- {
- CylindricalBarrelCalorimeterSensorLayer
- (String name, IDetectorElement parent, String path)
- {
- super(name,parent,path);
- }
- }
+ }
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.10 -r1.11
--- CylindricalEndcapCalorimeterConverter.java 11 Sep 2007 22:50:38 -0000 1.10
+++ CylindricalEndcapCalorimeterConverter.java 6 Dec 2007 01:26:33 -0000 1.11
@@ -4,12 +4,12 @@
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.ILogicalVolume;
import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.IRotation3D;
import org.lcsim.detector.LogicalVolume;
import org.lcsim.detector.PhysicalVolume;
-import org.lcsim.detector.IRotation3D;
import org.lcsim.detector.RotationPassiveEuler;
-import org.lcsim.detector.Translation3D;
import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.Translation3D;
import org.lcsim.detector.material.IMaterial;
import org.lcsim.detector.material.MaterialStore;
import org.lcsim.detector.solids.Tube;
@@ -21,6 +21,7 @@
import org.lcsim.geometry.subdetector.CylindricalEndcapCalorimeter;
public class CylindricalEndcapCalorimeterConverter
+extends AbstractSubdetectorConverter
implements ISubdetectorConverter
{
public void convert( Subdetector subdet, Detector detector)
@@ -50,7 +51,7 @@
// DE for positive endcap.
DetectorElement endcap =
- new CylindricalEndcapCalorimeterDE(cal.getName() + "_positive", subdet.getDetectorElement());
+ new DetectorElement(cal.getName() + "_positive", subdet.getDetectorElement());
endcap.setSupport(cal.getName() + "_positive");
// DE for negative endcap.
@@ -72,7 +73,7 @@
);
reflectedEndcap =
- new CylindricalEndcapCalorimeterDE(cal.getName() + "_negative", subdet.getDetectorElement());
+ new DetectorElement(cal.getName() + "_negative", subdet.getDetectorElement());
reflectedEndcap.setSupport(cal.getName() + "_negative");
}
@@ -102,7 +103,7 @@
{
// Create the DE for an endcap sensor.
String pathName = "/" + cal.getName() + "_positive" + "/" + layerName + "/" + sliceName;
- new CylindricalEndcapCalorimeterSensorLayer(
+ new DetectorElement(
cal.getName() + "_positive_layer" + layerNumber,
endcap,
pathName);
@@ -111,7 +112,7 @@
if ( reflectedEndcap != null )
{
pathName = "/" + cal.getName() + "_negative" + "/" + layerName + "/" + sliceName;
- new CylindricalEndcapCalorimeterSensorLayer(
+ new DetectorElement(
cal.getName() + "_negative_layer" + layerNumber,
reflectedEndcap,
pathName);
@@ -224,25 +225,5 @@
public Class getSubdetectorType()
{
return CylindricalEndcapCalorimeter.class;
- }
-
- class CylindricalEndcapCalorimeterSensorLayer
- extends DetectorElement
- {
- CylindricalEndcapCalorimeterSensorLayer
- (String name, IDetectorElement parent, String path)
- {
- super(name,parent,path);
- }
- }
-
- class CylindricalEndcapCalorimeterDE
- extends DetectorElement
- {
- CylindricalEndcapCalorimeterDE
- (String name, IDetectorElement parent)
- {
- super(name,parent);
- }
- }
+ }
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.32 -r1.33
--- DetectorConverter.java 13 Nov 2007 23:42:35 -0000 1.32
+++ DetectorConverter.java 6 Dec 2007 01:26:33 -0000 1.33
@@ -8,7 +8,6 @@
import org.jdom.Element;
import org.jdom.JDOMException;
import org.lcsim.detector.DetectorElement;
-import org.lcsim.detector.DetectorIdentifierHelper;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.ILogicalVolume;
import org.lcsim.detector.IPhysicalVolume;
@@ -20,38 +19,31 @@
import org.lcsim.detector.converter.lcdd.MaterialElementConverter;
import org.lcsim.detector.converter.lcdd.MaterialMixtureConverter;
import org.lcsim.detector.converter.lcdd.MaterialsConverter;
-import org.lcsim.detector.identifier.ExpandedIdentifier;
-import org.lcsim.detector.identifier.IExpandedIdentifier;
-import org.lcsim.detector.identifier.IIdentifier;
-import org.lcsim.detector.identifier.IIdentifierDictionary;
-import org.lcsim.detector.identifier.IIdentifierField;
import org.lcsim.detector.identifier.IIdentifierHelper;
-import org.lcsim.detector.identifier.IdentifierDictionary;
-import org.lcsim.detector.identifier.IdentifierDictionaryManager;
-import org.lcsim.detector.identifier.IdentifierField;
-import org.lcsim.detector.identifier.IdentifierHelper;
-import org.lcsim.detector.identifier.IIdentifierDictionary.DuplicateFieldException;
-import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
import org.lcsim.detector.material.IMaterial;
import org.lcsim.detector.material.MaterialStore;
import org.lcsim.detector.solids.Box;
import org.lcsim.detector.solids.Tube;
-import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper;
import org.lcsim.geometry.Detector;
-import org.lcsim.geometry.Readout;
import org.lcsim.geometry.compact.Constant;
import org.lcsim.geometry.compact.Subdetector;
import org.lcsim.geometry.subdetector.PolyconeSupport;
-import org.lcsim.geometry.subdetector.SiTrackerBarrel;
-import org.lcsim.geometry.subdetector.SiTrackerEndcap;
-import org.lcsim.geometry.util.IDDescriptor;
public class DetectorConverter implements IDetectorConverter
{
+ // Map of class to converter.
Map<Class,ISubdetectorConverter> subdetectorConverters =
new HashMap<Class,ISubdetectorConverter>();
+ // The parameters converter.
+ ParametersConverter paramCnv = new ParametersConverter();
+
+ // Materials converters.
+ MaterialsConverter materialCnv = new MaterialsConverter();
+ MaterialElementConverter elemCnv = new MaterialElementConverter();
+ MaterialMixtureConverter matCnv = new MaterialMixtureConverter();
+
+ // The SystemMap for setting up the IdentifierHelpers.
SystemMap sysMap;
public IPhysicalVolume convert(Detector detector, Document doc) throws JDOMException, IOException
@@ -60,15 +52,15 @@
convertMaterials("/org/lcsim/material/elements.xml");
convertMaterials("/org/lcsim/material/materials.xml");
convertMaterials(doc);
-
+
// Construct the world volume.
IPhysicalVolume pvWorld = buildWorldVolume(detector);
- // Create the default navigator.
+ // Make the default navigator.
PhysicalVolumeNavigatorStore.getInstance().reset();
PhysicalVolumeNavigatorStore.getInstance().createDefault(pvWorld);
- // Set the Detector's associated DetectorElement.
+ // Set the Detector's DetectorElement.
IDetectorElement deDet = new DeDetector(detector);
detector.setDetectorElement(deDet);
@@ -78,6 +70,9 @@
// Set the world volume.
detector.setWorldVolume(pvWorld);
+ // Make the SystemMap.
+ sysMap = makeSystemMap(detector);
+
// Convert Subdetectors including creation of IdentifierHelpers.
convertSubdetectors(detector);
@@ -118,19 +113,15 @@
return convert( detector, CompactDocumentBuilder.build(resource) );
}
-
private void convertMaterials(Document doc) throws JDOMException
{
- ( new MaterialsConverter() ).convert( doc );
+ materialCnv.convert( doc );
}
private void convertMaterials(String resource) throws JDOMException, IOException
{
Document doc = CompactDocumentBuilder.build(resource);
- MaterialElementConverter elemCnv = new MaterialElementConverter();
- MaterialMixtureConverter matCnv = new MaterialMixtureConverter();
-
for ( Object obj : doc.getRootElement().getChildren())
{
Element e = (Element)obj;
@@ -147,26 +138,20 @@
private void convertSubdetectors(Detector detector)
{
- // Make a system map of subdetector types to system id.
- sysMap = makeSystemMap(detector);
-
- // Create a new parameters converter.
- ParametersConverter paramCnv = new ParametersConverter();
-
- // Loop over all Subdetectors in the Detector.
+ // Process all Subdetectors in the Detector.
for ( Subdetector subdet : detector.getSubdetectors().values())
{
- // Lookup a registered converter for this Subdetector class.
+ System.out.println("cnv " + subdet.getName());
+
+ // Find a converter for this type.
ISubdetectorConverter cnv = getSubdetectorConverter(subdet.getClass());
- // Convert to detailed description if a suitable converter exists.
if ( cnv != null )
{
- // Build the IdentifierDictionary for this Subdetector.
- // Subdetector converters may need this to be done first.
- IIdentifierDictionary iddict = createIdentifierDictionary(subdet);
-
- // Convert parameters.
+ // Make the IdentifierHelper for this Subdetector.
+ IIdentifierHelper helper = cnv.makeIdentifierHelper(subdet, sysMap);
+
+ // Convert the parameters.
try {
paramCnv.convert(subdet.getNode());
}
@@ -175,174 +160,33 @@
throw new RuntimeException(x);
}
- // Convert from a compact type to the generic detector description
- // using a registered converter.
+ // Build the Subdetector's geometry and associated DetectorElement(s).
cnv.convert(subdet, detector);
- // If this subdetector was converted, it should have a DetectorElement.
- if ( subdet.getDetectorElement() != null )
- {
- // Setup the Subdetector Parameters.
- ((DetectorElement)subdet.getDetectorElement()).setParameters(ParametersStore.getInstance().get(subdet.getName()));
+ // Get the top level Subdetector node back.
+ DetectorElement subdetDE = (DetectorElement)subdet.getDetectorElement();
- // Check that a dictionary was created.
- if (iddict != null)
- {
- try {
- // Create a DetectorIdHelper for this subdetector.
- if (iddict.hasField("system") && iddict.hasField("barrel"))
- {
- IIdentifierHelper helper = null;
-
- if (subdet instanceof SiTrackerBarrel || subdet instanceof SiTrackerEndcap)
- {
- // Create a IdentifierHelper specific to SiTracker.
- helper = new SiTrackerIdentifierHelper( iddict, sysMap );
- }
- else
- {
- // Use the standard subdetector IdentifierHelper.
- helper = new DetectorIdentifierHelper( iddict, sysMap );
-
- }
-
- // Set the IdentifierHelper on the subdetector's DetectorElement.
- ((DetectorElement)subdet.getDetectorElement()).setIdentifierHelper(helper);
- }
- else
- {
- // Dict is missing fields, so it is probably a foreign file. Use the basic IdentifierHelper.
- ((DetectorElement)subdet.getDetectorElement()).setIdentifierHelper( new IdentifierHelper( iddict ) );
- }
- }
- catch (FieldNotFoundException x)
- {
- throw new RuntimeException(x);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
-
- // Setup identifiers for the Subdetector and its top-level sub-components.
- try {
- if (iddict.hasField("system") && iddict.hasField("barrel"))
- {
- makeIdentifiers(subdet);
- }
- }
- catch (Exception x)
- {
- throw new RuntimeException(x);
- }
- }
+ // Check if a DetectorElement was created. Some compact "detector" objects
+ // are not really detectors but dead material so this check is necessary
+ // to avoid errors.
+ if ( subdetDE != null)
+ {
+ // Make the Parameters from the compact detector element
+ // and assign to the Subdetector's DetectorElement.
+ subdetDE.setParameters(ParametersStore.getInstance().get(subdet.getName()));
+
+ // Make the Subdetector IdentifierHelper from the IDDecoder
+ // and assign to the Subdetector's DetectorElement.
+ if (helper != null)
+ subdetDE.setIdentifierHelper(helper);
+
+ // Make the identifiers for this Subdetector.
+ cnv.makeIdentifiers(subdet);
}
}
}
}
- private static void makeIdentifiers(Subdetector subdet) throws Exception
- {
- IIdentifierHelper idhelper = subdet.getDetectorElement().getIdentifierHelper();
- IIdentifierDictionary iddict = idhelper.getIdentifierDictionary();
-
- int sys = subdet.getSystemID();
- int sysIndex = iddict.getFieldIndex("system");
- int barrelIndex = iddict.getFieldIndex("barrel");
-
- IExpandedIdentifier expid = new ExpandedIdentifier(idhelper.getIdentifierDictionary().getNumberOfFields());
-
- expid.setValue(sysIndex, sys);
-
- // Barrel.
- if (subdet.isBarrel())
- {
- expid.setValue(barrelIndex, 0);
- try {
- IIdentifier barrelId = idhelper.pack(expid);
- subdet.getDetectorElement().setIdentifier(barrelId);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
- }
- // Deal with endcaps.
- else
- {
- try {
- // Id for the endcap container DetectorElement.
- IIdentifier endcapId = idhelper.pack(expid);
- subdet.getDetectorElement().setIdentifier(endcapId);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
-
- // Ids for the positive and negative endcaps.
- for (IDetectorElement endcap : subdet.getDetectorElement().getChildren())
- {
- // Positive endcap.
- if (endcap.getName().contains("positive"))
- {
- expid.setValue(barrelIndex, 1);
- }
- // Negative endcap.
- else if (endcap.getName().contains("negative"))
- {
- expid.setValue(barrelIndex, 2);
- }
-
- try {
- IIdentifier endcapSubId = idhelper.pack(expid);
- endcap.setIdentifier(endcapSubId);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
- }
- }
- }
-
- /**
- * Creates an {@link IIdentifierDictionary} from an existing
- * {@link org.lcsim.geometry.compact.Subdetector}'s
- * {@link org.lcsim.geometry.IDDecoder}.
- *
- * @param subdet The compact Subdetector.
- */
- protected static IIdentifierDictionary createIdentifierDictionary(Subdetector subdet)
- {
- Readout ro = subdet.getReadout();
- IIdentifierDictionary iddict = null;
- if ( ro != null )
- {
- iddict = new IdentifierDictionary(ro.getName());
- IdentifierDictionaryManager.getInstance().addIdentifierDictionary( iddict );
-
- IDDescriptor desc = ro.getIDDescriptor();
- for ( int i=0; i<desc.fieldCount(); i++ )
- {
- int nbits = Math.abs(desc.fieldLength(i));
- int start = desc.fieldStart(i);
- boolean signed = desc.isSigned(i);
- String name = desc.fieldName(i);
-
- IIdentifierField field = new IdentifierField(name,nbits,start,signed,i);
- try {
- iddict.addField(field);
- }
- catch (DuplicateFieldException x)
- {
- throw new RuntimeException(x);
- }
- }
- }
- return iddict;
- }
-
private void buildTrackingVolume(ILogicalVolume world, Detector detector)
{
Map<String,Constant> constants = detector.getConstants();
@@ -485,5 +329,5 @@
}
return m;
- }
+ }
}
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.16 -r1.17
--- DiskTrackerConverter.java 28 Nov 2007 19:15:08 -0000 1.16
+++ DiskTrackerConverter.java 6 Dec 2007 01:26:33 -0000 1.17
@@ -35,6 +35,7 @@
*
*/
public class DiskTrackerConverter
+extends AbstractSubdetectorConverter
implements ISubdetectorConverter
{
public void convert( Subdetector subdet, Detector detector)
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.4 -r1.5
--- ISubdetectorConverter.java 8 May 2007 00:53:30 -0000 1.4
+++ ISubdetectorConverter.java 6 Dec 2007 01:26:33 -0000 1.5
@@ -1,10 +1,61 @@
package org.lcsim.detector.converter.compact;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.DetectorIdentifierHelper.SystemMap;
+import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.geometry.compact.Detector;
import org.lcsim.geometry.compact.Subdetector;
+/**
+ * Converts a {@link org.lcsim.geometry.Subdetector} into the detailed geometry description
+ * defined by the {@link org.lcsim.detector} package.
+ */
public interface ISubdetectorConverter
{
+ /**
+ * This is the primary conversion method for building the detailed geometry
+ * and the hierarchy of DetectorElement nodes.
+ * @param subdet
+ * @param detector
+ */
public void convert(Subdetector subdet, Detector detector);
- public Class getSubdetectorType();
-}
+
+ /**
+ * Get the type of Subdetector handled by this converter.
+ * @return The type of Subdetector handled by this converter.
+ */
+ public Class getSubdetectorType();
+
+ /**
+ * Create the top-level {@link org.lcsim.detector.IDetectorElement} for this Subdetector.
+ * This node will be assigned the {@link org.lcsim.detector.identifier.IIdentifierHelper}
+ * created by {@link #makeIdentifierHelper(Subdetector, SystemMap)}.
+ * @param detector
+ * @param subdetector
+ * @return
+ */
+ public IDetectorElement makeSubdetectorDetectorElement(Detector detector, Subdetector subdetector);
+
+ /**
+ * This method is called after {@link #convert(Subdetector, Detector)} to define the appropriate
+ * IdentifierContext objects in the IdentifierDictionary.
+ * @param subdet The Subdetector.
+ */
+ public void makeIdentifierContext(Subdetector subdet);
+
+ /**
+ * Create the appropriate type of
+ * {@link org.lcsim.detector.identifier.IIdentifierHelper}
+ * for this subdetector type.
+ *
+ * @param subdetector
+ * @param systemMap
+ * @return
+ */
+ public IIdentifierHelper makeIdentifierHelper(Subdetector subdetector, SystemMap systemMap);
+
+ /**
+ * Creates the hierarchy of Identifiers in this Subdetector.
+ */
+ public void makeIdentifiers(Subdetector subdetector);
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.12 -r1.13
--- MultiLayerTrackerConverter.java 28 Nov 2007 19:15:08 -0000 1.12
+++ MultiLayerTrackerConverter.java 6 Dec 2007 01:26:33 -0000 1.13
@@ -28,7 +28,9 @@
*
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class MultiLayerTrackerConverter implements ISubdetectorConverter
+public class MultiLayerTrackerConverter
+extends AbstractSubdetectorConverter
+implements ISubdetectorConverter
{
public void convert( Subdetector subdet, Detector detector)
{
@@ -130,7 +132,7 @@
throw new RuntimeException(x);
}
- MultiLayerTrackerSensorLayer layerDetectorElement = new MultiLayerTrackerSensorLayer(name + "_layer" + layerNumber, tracker.getDetectorElement(), path, id);
+ new DetectorElement(name + "_layer" + layerNumber, tracker.getDetectorElement(), path, id);
++layerNumber;
}
@@ -143,7 +145,7 @@
static ExpandedIdentifier makeExpandedIdentifier(IDDecoder decoder, int systemNumber, int layer)
{
ExpandedIdentifier id = new ExpandedIdentifier();
- int extras=0;
+ //int extras=0;
for (int i=0; i<decoder.getFieldCount(); i++)
{
String fieldName = decoder.getFieldName(i);
@@ -167,8 +169,9 @@
return id;
}
- public void makeIdentifierContext(Subdetector subdet) throws Exception
+ public void makeIdentifierContext(Subdetector subdet)
{
+ /*
IIdentifierDictionary iddict = subdet.getDetectorElement().getIdentifierHelper().getIdentifierDictionary();
int systemIndex = iddict.getFieldIndex("system");
@@ -182,6 +185,7 @@
iddict.addIdentifierContext("system", systemContext);
iddict.addIdentifierContext("subdetector", subdetContext);
iddict.addIdentifierContext("layer", layerContext);
+ */
}
public Class getSubdetectorType()
@@ -189,6 +193,7 @@
return MultiLayerTracker.class;
}
+ /*
public class MultiLayerTrackerSensorLayer
extends DetectorElement
{
@@ -197,5 +202,5 @@
super(name,parent,path,id);
}
}
-
+ */
}
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.1 -r1.2
--- PolyconeSupportConverter.java 11 Sep 2007 20:18:33 -0000 1.1
+++ PolyconeSupportConverter.java 6 Dec 2007 01:26:33 -0000 1.2
@@ -10,6 +10,8 @@
import org.lcsim.detector.ILogicalVolume;
import org.lcsim.detector.IPhysicalVolume;
import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.DetectorIdentifierHelper.SystemMap;
+import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.detector.material.IMaterial;
import org.lcsim.detector.material.MaterialStore;
import org.lcsim.detector.solids.Polycone;
@@ -23,14 +25,22 @@
* to the {@link org.lcsim.detector} detailed detector representation.
*
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: PolyconeSupportConverter.java,v 1.1 2007/09/11 20:18:33 jeremy Exp $
+ * @version $Id: PolyconeSupportConverter.java,v 1.2 2007/12/06 01:26:33 jeremy Exp $
*/
public class PolyconeSupportConverter
+extends AbstractSubdetectorConverter
implements ISubdetectorConverter
{
+ /**
+ * This type is only used for dead material and has no IdentifierHelper.
+ */
+ public IIdentifierHelper makeIdentifierHelper(Subdetector subdetector, SystemMap systemMap)
+ {
+ return null;
+ }
- public void convert(Subdetector subdet, Detector detector)
+ public void convert(Subdetector subdet, Detector detector)
{
List<ZPlane> zplanes = new ArrayList<ZPlane>();
Element node = subdet.getNode();
@@ -73,5 +83,5 @@
public Class getSubdetectorType()
{
return PolyconeSupport.class;
- }
+ }
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.26 -r1.27
--- SiTrackerBarrelConverter.java 5 Dec 2007 01:36:50 -0000 1.26
+++ SiTrackerBarrelConverter.java 6 Dec 2007 01:26:34 -0000 1.27
@@ -50,7 +50,8 @@
import org.lcsim.geometry.subdetector.SiTrackerBarrel;
public class SiTrackerBarrelConverter
- implements ISubdetectorConverter
+extends AbstractSubdetectorConverter
+implements ISubdetectorConverter
{
public void convert( Subdetector subdet, Detector detector)
{
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.13 -r1.14
--- SiTrackerEndcapConverter.java 6 Dec 2007 01:23:16 -0000 1.13
+++ SiTrackerEndcapConverter.java 6 Dec 2007 01:26:34 -0000 1.14
@@ -24,6 +24,7 @@
import org.lcsim.detector.RotationPassiveXYZ;
import org.lcsim.detector.Transform3D;
import org.lcsim.detector.Translation3D;
+import org.lcsim.detector.DetectorIdentifierHelper.SystemMap;
import org.lcsim.detector.identifier.ExpandedIdentifier;
import org.lcsim.detector.identifier.IIdentifier;
import org.lcsim.detector.identifier.IIdentifierDictionary;
@@ -46,6 +47,7 @@
import org.lcsim.detector.tracker.silicon.SiSensor;
import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
import org.lcsim.detector.tracker.silicon.SiStrips;
+import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper;
import org.lcsim.detector.tracker.silicon.SiTrackerModule;
import org.lcsim.geometry.compact.Detector;
import org.lcsim.geometry.compact.Subdetector;
@@ -55,14 +57,30 @@
* Converter for SiTrackerEndcap.
*
* @author Jeremy McCormick, Tim Nelson
- * @version $Id: SiTrackerEndcapConverter.java,v 1.13 2007/12/06 01:23:16 tknelson Exp $
+ * @version $Id: SiTrackerEndcapConverter.java,v 1.14 2007/12/06 01:26:34 jeremy Exp $
*/
public class SiTrackerEndcapConverter
- implements ISubdetectorConverter
+extends AbstractSubdetectorConverter
+implements ISubdetectorConverter
{
private ModuleParameters moduleParameters = null;
+ public IIdentifierHelper makeIdentifierHelper(Subdetector subdetector, SystemMap systemMap)
+ {
+ try {
+ return new SiTrackerIdentifierHelper(makeIdentifierDictionary(subdetector), systemMap);
+ }
+ catch (FieldNotFoundException x)
+ {
+ throw new RuntimeException(x);
+ }
+ catch (InvalidIndexException x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
+
public void convert(Subdetector subdet, Detector detector)
{
IPhysicalVolume trackingPV = detector.getTrackingVolume();
CVSspam 0.2.8