13 modified files
GeomConverter/src/org/lcsim/detector
diff -u -r1.3 -r1.4
--- DetectorIdentifierHelper.java 6 Dec 2007 01:25:57 -0000 1.3
+++ DetectorIdentifierHelper.java 11 Dec 2007 07:27:48 -0000 1.4
@@ -7,8 +7,6 @@
import org.lcsim.detector.identifier.IIdentifier;
import org.lcsim.detector.identifier.IIdentifierDictionary;
import org.lcsim.detector.identifier.IdentifierHelper;
-import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
/**
* <p>
@@ -240,7 +238,7 @@
}
}
- private void setup(IIdentifierDictionary dict, SystemMap systemMap) throws InvalidIndexException, FieldNotFoundException
+ private void setup(IIdentifierDictionary dict, SystemMap systemMap)
{
if (systemMap == null)
systemMap = makeDefaultSystemMap();
@@ -294,7 +292,7 @@
}
// Public ctor.
- public DetectorIdentifierHelper(IIdentifierDictionary dict, SystemMap systemMap) throws FieldNotFoundException, InvalidIndexException
+ public DetectorIdentifierHelper(IIdentifierDictionary dict, SystemMap systemMap)
{
super(dict);
try {
@@ -306,7 +304,7 @@
}
}
- private IIdentifier makeSubsysId(int system) throws InvalidIndexException
+ private IIdentifier makeSubsysId(int system)
{
IExpandedIdentifier expid =
new ExpandedIdentifier(getIdentifierDictionary().getNumberOfFields());
@@ -315,7 +313,7 @@
return id;
}
- private IIdentifier makeSubsysId(int system, int barrel) throws InvalidIndexException
+ private IIdentifier makeSubsysId(int system, int barrel)
{
IExpandedIdentifier expid =
new ExpandedIdentifier(getIdentifierDictionary().getNumberOfFields());
@@ -325,7 +323,7 @@
return id;
}
- private IIdentifier makeBarrelId(int barrel) throws InvalidIndexException
+ private IIdentifier makeBarrelId(int barrel)
{
IExpandedIdentifier expid =
new ExpandedIdentifier(getIdentifierDictionary().getNumberOfFields());
@@ -336,13 +334,7 @@
private boolean compareSystem(IIdentifier id, int system)
{
- try {
- return unpack(id).getValue(systemIndex) == system;
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ return unpack(id).getValue(systemIndex) == system;
}
public int getBarrelValue()
@@ -556,13 +548,7 @@
public boolean isBarrel(IIdentifier i)
{
- try {
- return unpack(i).getValue(barrelIndex) == barrelValue;
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ return unpack(i).getValue(barrelIndex) == barrelValue;
}
public boolean isEndcap(IIdentifier i)
@@ -572,24 +558,12 @@
public boolean isEndcapPositive(IIdentifier i)
{
- try {
- return unpack(i).getValue(barrelIndex) == endcapPositiveValue;
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ return unpack(i).getValue(barrelIndex) == endcapPositiveValue;
}
public boolean isEndcapNegative(IIdentifier i)
{
- try {
- return unpack(i).getValue(barrelIndex) == endcapNegativeValue;
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ return unpack(i).getValue(barrelIndex) == endcapNegativeValue;
}
public boolean isTracker(IIdentifier i)
@@ -819,38 +793,19 @@
public int getSystemValue(IIdentifier i)
{
- try {
- return unpack(i).getValue(systemIndex);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ return unpack(i).getValue(systemIndex);
}
public int getBarrelValue(IIdentifier i)
{
- try {
- return unpack(i).getValue(barrelIndex);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ return unpack(i).getValue(barrelIndex);
}
public int getLayerValue(IIdentifier i)
{
if (layerIndex == invalidIndex)
throw new RuntimeException("The layer number is not available, because " + getIdentifierDictionary().getName() + " does not have a layer field!");
- try
- {
- return unpack(i).getValue(layerIndex);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ return unpack(i).getValue(layerIndex);
}
public boolean layerEquals(IIdentifier i, int layer)
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.4 -r1.5
--- AbstractSubdetectorConverter.java 8 Dec 2007 02:19:03 -0000 1.4
+++ AbstractSubdetectorConverter.java 11 Dec 2007 07:27:50 -0000 1.5
@@ -13,9 +13,6 @@
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;
@@ -26,7 +23,7 @@
* some utilities and default method implementations for Subdetector conversion.
*
* @author Jeremy McCormick
- * @version $Id: AbstractSubdetectorConverter.java,v 1.4 2007/12/08 02:19:03 jeremy Exp $
+ * @version $Id: AbstractSubdetectorConverter.java,v 1.5 2007/12/11 07:27:50 jeremy Exp $
*/
public abstract class AbstractSubdetectorConverter implements ISubdetectorConverter
@@ -71,29 +68,16 @@
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)
+ if (iddict.hasField("system") && iddict.hasField("barrel"))
{
- throw new RuntimeException(x);
+ helper = new DetectorIdentifierHelper(iddict, systemMap);
}
- catch (InvalidIndexException x)
+ else
{
- throw new RuntimeException(x);
- }
-
+ // Make a generic IdentifierHelper if standard fields are not present.
+ helper = new IdentifierHelper(iddict);
+ }
+
return helper;
}
@@ -122,13 +106,7 @@
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);
- }
+ iddict.addField(field);
}
}
return iddict;
@@ -167,28 +145,16 @@
if (subdet.isBarrel())
{
expid.setValue(barrelIndex, 0);
- try {
- IIdentifier barrelId = idhelper.pack(expid);
- subdet.getDetectorElement().setIdentifier(barrelId);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ IIdentifier barrelId = idhelper.pack(expid);
+ subdet.getDetectorElement().setIdentifier(barrelId);
}
// 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);
- }
-
+ // Id for the endcap container DetectorElement.
+ IIdentifier endcapId = idhelper.pack(expid);
+ subdet.getDetectorElement().setIdentifier(endcapId);
+
// Ids for the positive and negative endcaps.
for (IDetectorElement endcap : subdet.getDetectorElement().getChildren())
{
@@ -203,15 +169,9 @@
expid.setValue(barrelIndex, 2);
}
- try {
- IIdentifier endcapSubId = idhelper.pack(expid);
+ IIdentifier endcapSubId = idhelper.pack(expid);
- endcap.setIdentifier(endcapSubId);
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ endcap.setIdentifier(endcapSubId);
}
}
}
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.19 -r1.20
--- DiskTrackerConverter.java 8 Dec 2007 02:01:46 -0000 1.19
+++ DiskTrackerConverter.java 11 Dec 2007 07:27:50 -0000 1.20
@@ -16,8 +16,6 @@
import org.lcsim.detector.identifier.IdentifierContext;
import org.lcsim.detector.identifier.IdentifierDictionaryManager;
import org.lcsim.detector.identifier.IdentifierUtil;
-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.Tube;
@@ -229,16 +227,10 @@
{
IIdentifierDictionary iddict = subdet.getDetectorElement().getIdentifierHelper().getIdentifierDictionary();
- int systemIndex, barrelIndex, layerIndex;
- try {
- systemIndex = iddict.getFieldIndex("system");
- barrelIndex = iddict.getFieldIndex("barrel");
- layerIndex = iddict.getFieldIndex("layer");
- }
- catch (FieldNotFoundException x)
- {
- throw new RuntimeException(x);
- }
+
+ 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});
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.15 -r1.16
--- MultiLayerTrackerConverter.java 8 Dec 2007 02:01:46 -0000 1.15
+++ MultiLayerTrackerConverter.java 11 Dec 2007 07:27:50 -0000 1.16
@@ -11,7 +11,6 @@
import org.lcsim.detector.identifier.IdentifierContext;
import org.lcsim.detector.identifier.IdentifierDictionaryManager;
import org.lcsim.detector.identifier.IdentifierUtil;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
import org.lcsim.detector.material.IMaterial;
import org.lcsim.detector.material.MaterialStore;
import org.lcsim.detector.solids.Tube;
@@ -121,14 +120,7 @@
ExpandedIdentifier expid = makeExpandedIdentifier(subdet.getIDDecoder(),tracker.getIDDecoder().getSystemNumber(),i);
IIdentifierDictionary iddict = IdentifierDictionaryManager.getInstance().getIdentifierDictionary( subdet.getReadout().getName() );
- IIdentifier id = null;
- try {
- id = IdentifierUtil.pack( iddict, expid );
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ IIdentifier id = IdentifierUtil.pack( iddict, expid );
new DetectorElement(name + "_layer" + layerNumber, tracker.getDetectorElement(), path, id);
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.29 -r1.30
--- SiTrackerBarrelConverter.java 8 Dec 2007 02:01:46 -0000 1.29
+++ SiTrackerBarrelConverter.java 11 Dec 2007 07:27:51 -0000 1.30
@@ -30,8 +30,6 @@
import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.detector.identifier.IdentifierDictionaryManager;
import org.lcsim.detector.identifier.IdentifierUtil;
-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;
@@ -65,17 +63,7 @@
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);
- }
+ return new SiTrackerIdentifierHelper(makeIdentifierDictionary(subdetector), systemMap);
}
public void convert( Subdetector subdet, Detector detector)
@@ -527,40 +515,25 @@
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"),((SiTrackerModule)module).getModuleId());
-
- // Set the sensor id for double-sided.
- expId.setValue(iddict.getFieldIndex("sensor"),sensorId);
- }
- catch (FieldNotFoundException x)
- {
- throw new RuntimeException(x);
- }
-
+
+ // 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"),((SiTrackerModule)module).getModuleId());
+
+ // Set the sensor id for double-sided.
+ expId.setValue(iddict.getFieldIndex("sensor"),sensorId);
+
// Create the packed id using util method.
// No IdentifierHelper is available yet.
- IIdentifier id = null;
- try
- {
- id = IdentifierUtil.pack( iddict, expId );
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ IIdentifier id = IdentifierUtil.pack( iddict, expId );
//System.out.println(pv.getName() + " is sens");
//System.out.println("path : " + modulePath.toString() + "/" + pv.getName());
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.19 -r1.20
--- SiTrackerEndcapConverter.java 7 Dec 2007 22:19:51 -0000 1.19
+++ SiTrackerEndcapConverter.java 11 Dec 2007 07:27:51 -0000 1.20
@@ -33,8 +33,6 @@
import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.detector.identifier.IdentifierDictionaryManager;
import org.lcsim.detector.identifier.IdentifierUtil;
-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;
@@ -58,7 +56,7 @@
* Converter for SiTrackerEndcap.
*
* @author Jeremy McCormick, Tim Nelson
- * @version $Id: SiTrackerEndcapConverter.java,v 1.19 2007/12/07 22:19:51 tknelson Exp $
+ * @version $Id: SiTrackerEndcapConverter.java,v 1.20 2007/12/11 07:27:51 jeremy Exp $
*/
public class SiTrackerEndcapConverter
@@ -78,18 +76,7 @@
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);
- }
+ return new SiTrackerIdentifierHelper(makeIdentifierDictionary(subdetector), systemMap);
}
public void convert(Subdetector subdet, Detector detector)
@@ -674,61 +661,46 @@
ExpandedIdentifier expId = new ExpandedIdentifier(iddict.getNumberOfFields());
- try
- {
- // Set the System ID.
- expId.setValue(iddict.getFieldIndex("system"), subdet.getSystemID());
-
- // Set the barrel-endcap flag.
- if (id_helper.isEndcapPositive(endcap.getIdentifier()))
- {
- expId.setValue(iddict.getFieldIndex("barrel"), id_helper.getEndcapPositiveValue());
- }
- else if (id_helper.isEndcapNegative(endcap.getIdentifier()))
- {
- expId.setValue(iddict.getFieldIndex("barrel"), id_helper.getEndcapNegativeValue());
- }
- else
- {
- throw new RuntimeException(endcap.getName() + " - not pos or neg endcap!");
- }
-
- //System.out.println("barrel flag set to " + expId.getValue(iddict.getFieldIndex("barrel")));
-
- // Set the layer number.
- expId.setValue(iddict.getFieldIndex("layer"), layer.getGeometry().getPath().getLeafVolume().getCopyNumber());
-
- // Set the wedge number.
- expId.setValue(iddict.getFieldIndex("wedge"), wedge.getGeometry().getPath().getLeafVolume().getCopyNumber());
-
- // Set the module id from the DetectorElement.
- expId.setValue(iddict.getFieldIndex("module"),((SiTrackerModule)module).getModuleId());
+ // Set the System ID.
+ expId.setValue(iddict.getFieldIndex("system"), subdet.getSystemID());
- // Set the sensor id for double-sided.
- expId.setValue(iddict.getFieldIndex("sensor"),sensorId);
- }
- catch (FieldNotFoundException x)
+ // Set the barrel-endcap flag.
+ if (id_helper.isEndcapPositive(endcap.getIdentifier()))
{
- throw new RuntimeException(x);
+ expId.setValue(iddict.getFieldIndex("barrel"), id_helper.getEndcapPositiveValue());
}
-
- // Create the packed id using util method.
- // No IdentifierHelper is available yet.
- IIdentifier id = null;
- try
+ else if (id_helper.isEndcapNegative(endcap.getIdentifier()))
{
- id = IdentifierUtil.pack( iddict, expId );
+ expId.setValue(iddict.getFieldIndex("barrel"), id_helper.getEndcapNegativeValue());
}
- catch (InvalidIndexException x)
+ else
{
- throw new RuntimeException(x);
+ throw new RuntimeException(endcap.getName() + " - not pos or neg endcap!");
}
-
+
+ //System.out.println("barrel flag set to " + expId.getValue(iddict.getFieldIndex("barrel")));
+
+ // Set the layer number.
+ expId.setValue(iddict.getFieldIndex("layer"), layer.getGeometry().getPath().getLeafVolume().getCopyNumber());
+
+ // Set the wedge number.
+ expId.setValue(iddict.getFieldIndex("wedge"), wedge.getGeometry().getPath().getLeafVolume().getCopyNumber());
+
+ // Set the module id from the DetectorElement.
+ expId.setValue(iddict.getFieldIndex("module"),((SiTrackerModule)module).getModuleId());
+
+ // Set the sensor id for double-sided.
+ expId.setValue(iddict.getFieldIndex("sensor"),sensorId);
+
+ // Create the packed id using util method.
+ // No IdentifierHelper is available yet.
+ IIdentifier id = IdentifierUtil.pack( iddict, expId );
+
String sensorPath = modulePath.toString() + "/" + pv.getName();
String sensorName = endcap.getName() +
- "_layer" + layer.getGeometry().getPhysicalVolume().getCopyNumber() +
- "_wedge" + wedge.getGeometry().getPath().getLeafVolume().getCopyNumber() +
- "_module" + ((SiTrackerModule)module).getModuleId() + "_sensor" + sensorId;
+ "_layer" + layer.getGeometry().getPhysicalVolume().getCopyNumber() +
+ "_wedge" + wedge.getGeometry().getPath().getLeafVolume().getCopyNumber() +
+ "_module" + ((SiTrackerModule)module).getModuleId() + "_sensor" + sensorId;
//System.out.println(sensorName + " -> " + expId);
//System.out.println(sensorName + " -> " + id);
GeomConverter/src/org/lcsim/detector/identifier
diff -u -r1.9 -r1.10
--- IIdentifierDictionary.java 13 Oct 2007 00:56:34 -0000 1.9
+++ IIdentifierDictionary.java 11 Dec 2007 07:27:52 -0000 1.10
@@ -7,7 +7,7 @@
* that define the fields of an {@link IIdentifier}.
*
* @author Jeremy McCormick
- * @version $Id: IIdentifierDictionary.java,v 1.9 2007/10/13 00:56:34 jeremy Exp $
+ * @version $Id: IIdentifierDictionary.java,v 1.10 2007/12/11 07:27:52 jeremy Exp $
*/
public interface IIdentifierDictionary
{
@@ -23,7 +23,7 @@
*
* @param field A field to add.
*/
- public void addField(IIdentifierField field) throws DuplicateFieldException;
+ public void addField(IIdentifierField field);
/**
* Get a field by name.
@@ -31,7 +31,7 @@
* @param fieldName The field.
* @return The field.
*/
- public IIdentifierField getField(String fieldName) throws FieldNotFoundException;
+ public IIdentifierField getField(String fieldName);
/**
* True if this <code>IdentifierDictionary</code> contains the field.
@@ -45,7 +45,7 @@
* @param fieldName The name of the field.
* @return The index index of the field.
*/
- public int getFieldIndex(String fieldName) throws FieldNotFoundException;
+ public int getFieldIndex(String fieldName);
/**
* Get a field by index.
@@ -53,7 +53,7 @@
* @param index The index.
* @return The field.
*/
- public IIdentifierField getField(int index) throws InvalidIndexException;
+ public IIdentifierField getField(int index);
/**
* Get the mapping of names to fields.
@@ -103,37 +103,4 @@
* @return The IdentifierContext associated with <code>name</code>.
*/
public IIdentifierContext getIdentifierContext(String name);
-
- /**
- * Thrown when a field lookup fails.
- */
- public final class FieldNotFoundException extends Exception
- {
- FieldNotFoundException(String field, IIdentifierDictionary dict)
- {
- super("The field " + field + " was not found in the dictionary " + dict.getName());
- }
- }
-
- /**
- * Thrown when an invalid index is passed as an argument.
- */
- public final class InvalidIndexException extends Exception
- {
- InvalidIndexException(int idx, IIdentifierDictionary dict)
- {
- super("The idx " + idx + " is invalid for the dictionary " + dict.getName());
- }
- }
-
- /**
- * Thrown when trying to add a field that already exists.
- */
- public final class DuplicateFieldException extends Exception
- {
- DuplicateFieldException(String field, IIdentifierDictionary dict)
- {
- super("The field " + field + " already exists in the dictionary " + dict.getName());
- }
- }
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/identifier
diff -u -r1.7 -r1.8
--- IIdentifierHelper.java 8 Dec 2007 01:50:07 -0000 1.7
+++ IIdentifierHelper.java 11 Dec 2007 07:27:52 -0000 1.8
@@ -1,8 +1,5 @@
package org.lcsim.detector.identifier;
-import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
-
/**
* This class has a reference to a single {@link IIdentifierDictionary}
* that specifies the fields for a 64-bit {@link IIdentifier}.
@@ -26,7 +23,7 @@
* @see IIdentifierDictionary
*
* @author Jeremy McCormick
- * @version $Id: IIdentifierHelper.java,v 1.7 2007/12/08 01:50:07 jeremy Exp $
+ * @version $Id: IIdentifierHelper.java,v 1.8 2007/12/11 07:27:52 jeremy Exp $
*/
public interface IIdentifierHelper
@@ -45,7 +42,7 @@
* @param id The ExpandedIdentifier to be packed.
* @return The compact identfier.
*/
- public IIdentifier pack( IExpandedIdentifier id ) throws InvalidIndexException;
+ public IIdentifier pack( IExpandedIdentifier id );
/**
* Get a single field value using an {@link IIdentifierField}.
@@ -63,7 +60,7 @@
* @param field The field index in the dictionary.
* @return The field value.
*/
- public int getValue( IIdentifier compact, int field ) throws InvalidIndexException;
+ public int getValue( IIdentifier compact, int field ) ;
/**
* Get a single field value by name.
@@ -72,7 +69,7 @@
* @param field The field index in the dictionary.
* @return The field value.
*/
- public int getValue( IIdentifier compact, String field ) throws FieldNotFoundException;
+ public int getValue( IIdentifier compact, String field );
/**
* Pack a subset of fields in an {@link IExpandedIdentifier}.
@@ -81,7 +78,7 @@
* @param start The start index in the ExpandedIdentifier.
* @return An Identifier with the packed fields.
*/
- public IIdentifier pack(IExpandedIdentifier id, int start) throws InvalidIndexException;
+ public IIdentifier pack(IExpandedIdentifier id, int start);
/**
* Pack a subset of fields in an {@link IExpandedIdentifier}.
@@ -91,7 +88,7 @@
* @param endIndex End index.
* @return An Identifier with the packed fields.
*/
- public IIdentifier pack(IExpandedIdentifier id, int startIndex, int endIndex ) throws InvalidIndexException;
+ public IIdentifier pack(IExpandedIdentifier id, int startIndex, int endIndex );
/**
* Upack the {@link IIdentifier} into an {@link IExpandedIdentifier}
@@ -100,7 +97,7 @@
* @param id The Identifier.
* @return An ExpandedIdentifier.
*/
- public IExpandedIdentifier unpack(IIdentifier id) throws InvalidIndexException;
+ public IExpandedIdentifier unpack(IIdentifier id);
/**
*
@@ -115,7 +112,7 @@
* @param endIndex The end index.
* @return An ExpandedIdentifier with the unpacked values.
*/
- public IExpandedIdentifier unpack(IIdentifier id, int startIndex, int endIndex ) throws InvalidIndexException;
+ public IExpandedIdentifier unpack(IIdentifier id, int startIndex, int endIndex );
/**
* Upack the {@link IIdentifier} into an {@link IExpandedIdentifier}
@@ -128,7 +125,7 @@
* @param startIndex The start field index.
* @return An ExpandedIdentifier with the unpacked values.
*/
- public IExpandedIdentifier unpack(IIdentifier id, int startIndex) throws InvalidIndexException;
+ public IExpandedIdentifier unpack(IIdentifier id, int startIndex);
/**
* Wraps {@link IIdentifierDictionary#getFieldIndex(String)}.
@@ -137,7 +134,7 @@
* @return
* @throws FieldNotFoundException
*/
- public int getFieldIndex(String fieldName) throws FieldNotFoundException;
+ public int getFieldIndex(String fieldName);
public void setValue(IExpandedIdentifier expid, String field, int value);
GeomConverter/src/org/lcsim/detector/identifier
diff -u -r1.6 -r1.7
--- IdentifierDictionary.java 13 Oct 2007 00:56:34 -0000 1.6
+++ IdentifierDictionary.java 11 Dec 2007 07:27:52 -0000 1.7
@@ -8,7 +8,7 @@
* Implementation of {@link IIdentifierDictionary}.
*
* @author Jeremy McCormick
- * @version $Id: IdentifierDictionary.java,v 1.6 2007/10/13 00:56:34 jeremy Exp $
+ * @version $Id: IdentifierDictionary.java,v 1.7 2007/12/11 07:27:52 jeremy Exp $
*/
public class IdentifierDictionary implements IIdentifierDictionary
@@ -29,11 +29,11 @@
return name;
}
- public void addField(IIdentifierField field) throws DuplicateFieldException
+ public void addField(IIdentifierField field)
{
if ( fields.containsKey( field.getLabel() ) )
{
- throw new DuplicateFieldException(field.getLabel(),this);
+ throw new RuntimeException("Duplicate field: " + field.getLabel());
}
// Put into the field map.
@@ -46,26 +46,26 @@
nameOrder.put( field.getLabel(), field.getOrder() );
}
- public IIdentifierField getField(String fieldName) throws FieldNotFoundException
+ public IIdentifierField getField(String fieldName)
{
if (!fields.containsKey(fieldName))
{
- throw new FieldNotFoundException(fieldName, this);
+ throw new RuntimeException("Field not found: " + fieldName);
}
return fields.get(fieldName);
}
- public int getFieldIndex(String fieldName) throws FieldNotFoundException
+ public int getFieldIndex(String fieldName)
{
if (!nameOrder.containsKey(fieldName))
- throw new FieldNotFoundException(fieldName,this);
+ throw new IllegalArgumentException("Field not found: " + fieldName);
return nameOrder.get(fieldName);
}
- public IIdentifierField getField(int index) throws InvalidIndexException
+ public IIdentifierField getField(int index)
{
if (!isValidIndex(index))
- throw new InvalidIndexException(index, this);
+ throw new IllegalArgumentException("Invalid index: " + index);
return (IIdentifierField)fields.values().toArray()[index];
}
GeomConverter/src/org/lcsim/detector/identifier
diff -u -r1.12 -r1.13
--- IdentifierHelper.java 8 Dec 2007 01:50:08 -0000 1.12
+++ IdentifierHelper.java 11 Dec 2007 07:27:52 -0000 1.13
@@ -1,14 +1,11 @@
package org.lcsim.detector.identifier;
-import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
-
/**
*
* Implementation of {@link IIdentifierHelper}.
*
* @author Jeremy McCormick
- * @version $Id: IdentifierHelper.java,v 1.12 2007/12/08 01:50:08 jeremy Exp $
+ * @version $Id: IdentifierHelper.java,v 1.13 2007/12/11 07:27:52 jeremy Exp $
*/
public class IdentifierHelper
@@ -16,12 +13,12 @@
{
private IIdentifierDictionary iddict=null;
- public IExpandedIdentifier unpack( IIdentifier id, int start, int nfields) throws InvalidIndexException
+ public IExpandedIdentifier unpack( IIdentifier id, int start, int nfields)
{
return IdentifierUtil.unpack( iddict, id, start, nfields );
}
- public IExpandedIdentifier unpack( IIdentifier id, int start) throws InvalidIndexException
+ public IExpandedIdentifier unpack( IIdentifier id, int start)
{
return IdentifierUtil.unpack( iddict, id, start );
}
@@ -36,12 +33,12 @@
return iddict;
}
- public IIdentifier pack( IExpandedIdentifier id ) throws InvalidIndexException
+ public IIdentifier pack( IExpandedIdentifier id )
{
return IdentifierUtil.pack(getIdentifierDictionary(), id );
}
- public IExpandedIdentifier unpack( IIdentifier id ) throws InvalidIndexException
+ public IExpandedIdentifier unpack( IIdentifier id )
{
return IdentifierUtil.unpack( iddict, id );
}
@@ -51,50 +48,37 @@
return IdentifierUtil.getValue( compact, desc );
}
- public int getValue( IIdentifier compact, int field ) throws InvalidIndexException
+ public int getValue( IIdentifier compact, int field )
{
return IdentifierUtil.getValue( iddict, compact, field );
}
public void setValue(IExpandedIdentifier expid, String field, int value)
{
- try {
- expid.setValue(getFieldIndex(field), value);
- }
- catch (Exception x)
- {
- throw new RuntimeException(x);
- }
+ expid.setValue(getFieldIndex(field), value);
}
public void setValue(IExpandedIdentifier expid, int index, int value)
{
- try {
- expid.setValue(index, value);
- }
- catch (Exception x)
- {
- throw new RuntimeException(x);
- }
-
+ expid.setValue(index, value);
}
- public int getFieldIndex(String fieldName) throws FieldNotFoundException
+ public int getFieldIndex(String fieldName)
{
return iddict.getFieldIndex(fieldName);
}
- public int getValue( IIdentifier compact, String field ) throws FieldNotFoundException
+ public int getValue( IIdentifier compact, String field )
{
return IdentifierUtil.getValue( iddict, compact, field );
}
- public IIdentifier pack(IExpandedIdentifier id, int start) throws InvalidIndexException
+ public IIdentifier pack(IExpandedIdentifier id, int start)
{
return IdentifierUtil.pack( iddict, id, start );
}
- public IIdentifier pack(IExpandedIdentifier id, int start, int nfields) throws InvalidIndexException
+ public IIdentifier pack(IExpandedIdentifier id, int start, int nfields)
{
return IdentifierUtil.pack( iddict, id, start, nfields );
}
GeomConverter/src/org/lcsim/detector/identifier
diff -u -r1.7 -r1.8
--- IdentifierUtil.java 1 Nov 2007 00:49:07 -0000 1.7
+++ IdentifierUtil.java 11 Dec 2007 07:27:52 -0000 1.8
@@ -1,8 +1,5 @@
package org.lcsim.detector.identifier;
-import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
-
/**
* Identifier utility methods for packing {@link IIdentifier}s and
* unpacking {@link IExpandedIdentifier}s using information from an
@@ -18,7 +15,7 @@
* @see IExpandedIdentifier
*
* @author Jeremy McCormick
- * @version $Id: IdentifierUtil.java,v 1.7 2007/11/01 00:49:07 jeremy Exp $
+ * @version $Id: IdentifierUtil.java,v 1.8 2007/12/11 07:27:52 jeremy Exp $
*/
public final class IdentifierUtil
{
@@ -28,17 +25,17 @@
private IdentifierUtil()
{}
- public static IExpandedIdentifier unpack( IIdentifierDictionary iddict, IIdentifier compact, int startIndex ) throws InvalidIndexException
+ public static IExpandedIdentifier unpack( IIdentifierDictionary iddict, IIdentifier compact, int startIndex )
{
return IdentifierUtil.unpack( iddict, compact, startIndex, -1 );
}
- public static IExpandedIdentifier unpack( IIdentifierDictionary iddict, IIdentifier compact ) throws InvalidIndexException
+ public static IExpandedIdentifier unpack( IIdentifierDictionary iddict, IIdentifier compact )
{
return IdentifierUtil.unpack( iddict, compact, 0 );
}
- public static IExpandedIdentifier unpack( IIdentifierDictionary iddict, IIdentifier compact, int startIndex, int endIndex ) throws InvalidIndexException
+ public static IExpandedIdentifier unpack( IIdentifierDictionary iddict, IIdentifier compact, int startIndex, int endIndex )
{
ExpandedIdentifier buffer = new ExpandedIdentifier();
@@ -102,17 +99,17 @@
return desc.unpack(compact);
}
- public static int getValue( IIdentifierDictionary iddict, IIdentifier compact, int field ) throws InvalidIndexException
+ public static int getValue( IIdentifierDictionary iddict, IIdentifier compact, int field )
{
return IdentifierUtil.getValue( compact, iddict.getField( field ) );
}
- public static int getValue( IIdentifierDictionary iddict, IIdentifier compact, String field ) throws FieldNotFoundException
+ public static int getValue( IIdentifierDictionary iddict, IIdentifier compact, String field )
{
return IdentifierUtil.getValue( compact, iddict.getField(field) );
}
- public static IIdentifier pack( IIdentifierDictionary iddict, IExpandedIdentifier id, int startIndex, int endIndex ) throws InvalidIndexException
+ public static IIdentifier pack( IIdentifierDictionary iddict, IExpandedIdentifier id, int startIndex, int endIndex )
{
long result=0;
@@ -155,12 +152,12 @@
return new Identifier( result );
}
- public static IIdentifier pack( IIdentifierDictionary iddict, IExpandedIdentifier id ) throws InvalidIndexException
+ public static IIdentifier pack( IIdentifierDictionary iddict, IExpandedIdentifier id )
{
return IdentifierUtil.pack( iddict, id, 0 );
}
- public static IIdentifier pack( IIdentifierDictionary iddict, IExpandedIdentifier id, int startIndex ) throws InvalidIndexException
+ public static IIdentifier pack( IIdentifierDictionary iddict, IExpandedIdentifier id, int startIndex )
{
return IdentifierUtil.pack( iddict, id, startIndex, -1 );
}
GeomConverter/src/org/lcsim/detector/tracker/silicon
diff -u -r1.20 -r1.21
--- SiSensor.java 8 Dec 2007 02:01:47 -0000 1.20
+++ SiSensor.java 11 Dec 2007 07:27:52 -0000 1.21
@@ -26,8 +26,6 @@
import org.lcsim.detector.identifier.IIdentifier;
import org.lcsim.detector.identifier.IIdentifierDictionary;
import org.lcsim.detector.identifier.IIdentifierHelper;
-import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
import org.lcsim.detector.solids.GeomOp3D;
import org.lcsim.detector.solids.Point3D;
import org.lcsim.detector.solids.Polygon3D;
@@ -321,25 +319,11 @@
IIdentifierHelper helper = getIdentifierHelper();
IIdentifierDictionary dict = helper.getIdentifierDictionary();
- try
- {
- // Fill in the side and strip numbers.
- id.setValue(dict.getFieldIndex("side"), sideNumber);
- id.setValue(dict.getFieldIndex("strip"), stripNumber);
- }
- catch (FieldNotFoundException x)
- {
- throw new RuntimeException(x);
- }
-
- try
- {
- // Pack and return the id.
- return helper.pack( id );
- }
- catch (InvalidIndexException x)
- {
- throw new RuntimeException(x);
- }
+ // Fill in the side and strip numbers.
+ id.setValue(dict.getFieldIndex("side"), sideNumber);
+ id.setValue(dict.getFieldIndex("strip"), stripNumber);
+
+ // Pack and return the id.
+ return helper.pack( id );
}
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/tracker/silicon
diff -u -r1.2 -r1.3
--- SiTrackerIdentifierHelper.java 13 Nov 2007 23:21:57 -0000 1.2
+++ SiTrackerIdentifierHelper.java 11 Dec 2007 07:27:53 -0000 1.3
@@ -5,14 +5,12 @@
import org.lcsim.detector.identifier.IIdentifier;
import org.lcsim.detector.identifier.IIdentifierDictionary;
import org.lcsim.detector.identifier.IIdentifierField;
-import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
-import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
/**
* Decode identifier fields that are specific to the tracking sub-system.
*
* @author Jeremy McCormick
- * @version $Id: SiTrackerIdentifierHelper.java,v 1.2 2007/11/13 23:21:57 jeremy Exp $
+ * @version $Id: SiTrackerIdentifierHelper.java,v 1.3 2007/12/11 07:27:53 jeremy Exp $
*/
public class SiTrackerIdentifierHelper
extends DetectorIdentifierHelper
@@ -27,26 +25,21 @@
IIdentifierField sideField = null;
IIdentifierField stripField = null;
- public SiTrackerIdentifierHelper(IIdentifierDictionary iddict, SystemMap sysMap) throws InvalidIndexException, FieldNotFoundException
+ public SiTrackerIdentifierHelper(IIdentifierDictionary iddict, SystemMap sysMap)
{
super(iddict, sysMap);
- try {
- moduleIdx = iddict.getFieldIndex("module");
- sensorIdx = iddict.getFieldIndex("sensor");
- sideIdx = iddict.getFieldIndex("side");
- stripIdx = iddict.getFieldIndex("strip");
-
- moduleField = iddict.getField(moduleIdx);
- sensorField = iddict.getField(sensorIdx);
- sideField = iddict.getField(sideIdx);
- stripField = iddict.getField(stripIdx);
- }
- catch (Exception x)
- {
- throw new RuntimeException(x);
- }
+
+ moduleIdx = iddict.getFieldIndex("module");
+ sensorIdx = iddict.getFieldIndex("sensor");
+ sideIdx = iddict.getFieldIndex("side");
+ stripIdx = iddict.getFieldIndex("strip");
+
+ moduleField = iddict.getField(moduleIdx);
+ sensorField = iddict.getField(sensorIdx);
+ sideField = iddict.getField(sideIdx);
+ stripField = iddict.getField(stripIdx);
}
-
+
/**
* The module number.
* @return The module number.
CVSspam 0.2.8