GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.22 -r1.23
--- DetectorConverter.java 11 Sep 2007 20:18:33 -0000 1.22
+++ DetectorConverter.java 14 Sep 2007 23:19:53 -0000 1.23
@@ -25,6 +25,7 @@
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;
@@ -48,6 +49,7 @@
Map<Class,ISubdetectorConverter> subdetectorConverters =
new HashMap<Class,ISubdetectorConverter>();
+ /*
SystemMap systemMap = null;
int systemIndex = -1;
int systemLength = -1;
@@ -57,8 +59,9 @@
int barrelLength = -1;
int barrelOffset = -1;
int barrelOrder = -1;
+ */
- boolean useSingleDetectorIdHelper = false;
+ //boolean useSingleDetectorIdHelper = false;
public IPhysicalVolume convert(Detector detector, Document doc) throws JDOMException, IOException
{
@@ -87,14 +90,14 @@
convertMaterials(doc);
// Make a system map of subdetector types to system id.
- systemMap = makeSystemMap(detector);
+ //systemMap = makeSystemMap(detector);
// Convert Subdetectors including creation of IdentifierHelpers.
convertSubdetectors(detector);
// Create the top level IdentifierHelper for the detector if possible.
- if (useSingleDetectorIdHelper)
- makeDetectorIdHelper(detector);
+ //if (useSingleDetectorIdHelper)
+ // makeDetectorIdHelper(detector);
//System.out.println("Done converting " + detector.getName() + " !");
@@ -111,6 +114,7 @@
addSubdetectorConverter( new DiskTrackerConverter() );
addSubdetectorConverter( new SiTrackerBarrelConverter() );
addSubdetectorConverter( new PolyconeSupportConverter() );
+ //addSubdetectorConverter( new PolyhedraBarrelCalorimeterConverter() );
}
private void addSubdetectorConverter(ISubdetectorConverter s)
@@ -178,8 +182,8 @@
// An IdentifierDictionary is created for all Subdetectors,
// not only those converted to the detailed description.
IIdentifierDictionary iddict = createIdentifierDictionary(subdet);
-
- checkIdDict(iddict);
+
+ //checkIdDict(iddict);
// Convert to detailed description if a suitable converter exists.
if ( cnv != null )
@@ -209,6 +213,7 @@
if (iddict != null)
{
// Setup the IdentifierHelper for this subdetector.
+ /*
DetectorIdHelper idhelper = null;
boolean useDetectorIdHelper=true;
try {
@@ -223,27 +228,37 @@
useDetectorIdHelper=false;
}
+ */
+
+ //if (useDetectorIdHelper)
+ //{
+ // ((DetectorElement)subdet.getDetectorElement()).setIdentifierHelper(idhelper);
- if (useDetectorIdHelper)
- {
- ((DetectorElement)subdet.getDetectorElement()).setIdentifierHelper(idhelper);
-
- // Create identifiers for the Subdetector and (possibly) its top-level subcomponents.
- makeIdentifiers(subdet);
- }
+ // Create identifiers for the Subdetector and (possibly) its top-level subcomponents.
+ try {
+ makeIdentifiers(subdet);
+ }
+ catch (Exception x)
+ {
+ throw new RuntimeException(x);
+ }
}
}
}
}
}
- private static void makeIdentifiers(Subdetector subdet)
+ private static void makeIdentifiers(Subdetector subdet) throws Exception
{
- DetectorIdHelper idhelper = (DetectorIdHelper)subdet.getDetectorElement().getIdentifierHelper();
-
- int sys = subdet.getSystemID();
- int sysIndex = idhelper.getSystemIndex();
- int barrelIndex = idhelper.getBarrelIndex();
+ //DetectorIdHelper idhelper = (DetectorIdHelper)subdet.getDetectorElement().getIdentifierHelper();
+ IIdentifierHelper idhelper = subdet.getDetectorElement().getIdentifierHelper();
+ IIdentifierDictionary iddict = idhelper.getIdentifierDictionary();
+
+ int sys = subdet.getSystemID();
+ //int sysIndex = idhelper.getSystemIndex();
+ int sysIndex = iddict.getFieldIndex("system");
+ //int barrelIndex = idhelper.getBarrelIndex();
+ int barrelIndex = iddict.getFieldIndex("barrel");
IExpandedIdentifier expid = new ExpandedIdentifier(idhelper.getIdentifierDictionary().getNumberOfFields());
@@ -252,7 +267,7 @@
// Barrel.
if (subdet.isBarrel())
{
- expid.setValue(barrelIndex, idhelper.getBarrelValue());
+ expid.setValue(barrelIndex, 0);
try {
IIdentifier barrelId = idhelper.pack(expid);
subdet.getDetectorElement().setIdentifier(barrelId);
@@ -281,12 +296,14 @@
// Positive endcap.
if (endcap.getName().contains("positive"))
{
- expid.setValue(barrelIndex, idhelper.getEndcapPositiveValue());
+ //expid.setValue(barrelIndex, idhelper.getEndcapPositiveValue());
+ expid.setValue(barrelIndex, 1);
}
// Negative endcap.
else if (endcap.getName().contains("negative"))
{
- expid.setValue(barrelIndex, idhelper.getEndcapNegativeValue());
+ //expid.setValue(barrelIndex, idhelper.getEndcapNegativeValue());
+ expid.setValue(barrelIndex, 2);
}
try {
@@ -409,6 +426,7 @@
// Put here instead of org.lcsim.detector.DetectorIdHelper
// to avoid a dependence on Detector.
+ /*
public static final SystemMap makeSystemMap(Detector d)
{
SystemMap m = new SystemMap();
@@ -481,14 +499,16 @@
}
return m;
- }
+ }
+ */
+ /*
private void makeDetectorIdHelper(Detector detector)
{
// If systemIndex was never set, then it is assumed that the compact description
// did not have any readouts or at least not any with a system field. This is
- // possible, e.g. for tests and the like. In this case, the Detector's IdentifierHelper
- // is left null.
+ // possible, e.g. for tests, foreign data files, and the like. In this case,
+ // the Detector's IdentifierHelper is left null.
if (systemIndex != -1)
{
IdentifierDictionary iddict = new IdentifierDictionary(detector.getName());
@@ -507,12 +527,17 @@
((DetectorElement)detector.getDetectorElement()).setIdentifierHelper(new IdentifierHelper(iddict));
}
}
+ */
+ /*
private void checkIdDict(IIdentifierDictionary iddict)
{
// Sanity checks on the system and barrel fields for all Subdetectors.
// All system and barrel fields in the same compact description must
- // result in identical IdentifierFields.
+ // result in identical IdentifierFields.
+
+ useSingleDetectorIdHelper = true;
+
if (iddict != null)
{
if (iddict.hasField("system"))
@@ -530,17 +555,22 @@
else
{
if (iddict.getFieldIndex("system") != systemIndex)
- throw new RuntimeException("Different indices for system field in same compact description!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException("Different indices for system field in same compact description!");
if (systemField.getNumberOfBits() != systemLength)
- throw new RuntimeException("Different lengths for system field in same compact description!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException("Different lengths for system field in same compact description!");
if (systemField.getOrder() != systemOrder)
- throw new RuntimeException("Different order for system field in same compact description!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException("Different order for system field in same compact description!");
if (systemField.isSigned())
- throw new RuntimeException("The system field is not supposed to be signed!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException("The system field is not supposed to be signed!");
}
if (!iddict.hasField("barrel"))
- throw new RuntimeException(iddict.getName() + " is missing the barrel field!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException(iddict.getName() + " is missing the barrel field!");
IIdentifierField barrelField = iddict.getField("barrel");
@@ -554,22 +584,34 @@
else
{
if (iddict.getFieldIndex("barrel") != barrelIndex)
- throw new RuntimeException("Different indices for barrel in same compact description!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException("Different indices for barrel in same compact description!");
if (barrelField.getNumberOfBits() != barrelLength)
- throw new RuntimeException("Different lengths for barrel field in same compact description!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException("Different lengths for barrel field in same compact description!");
if (barrelField.getOrder() != barrelOrder)
- throw new RuntimeException("Different order for barrel field in same compact description!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException("Different order for barrel field in same compact description!");
if (barrelField.isSigned())
- throw new RuntimeException("The barrel field is not supposed to be signed!");
+ useSingleDetectorIdHelper = false;
+ //throw new RuntimeException("The barrel field is not supposed to be signed!");
}
- useSingleDetectorIdHelper = true;
+ //useSingleDetectorIdHelper = true;
}
catch (Exception x)
{
throw new RuntimeException(x);
}
}
- }
+ else {
+ useSingleDetectorIdHelper = false;
+ }
+ }
+ else
+ {
+ useSingleDetectorIdHelper = false;
+ }
}
-}
+ */
+}
\ No newline at end of file