GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.1 -r1.2
--- AbstractSubdetectorConverter.java 6 Dec 2007 01:26:33 -0000 1.1
+++ AbstractSubdetectorConverter.java 6 Dec 2007 22:27:11 -0000 1.2
@@ -1,5 +1,6 @@
package org.lcsim.detector.converter.compact;
+import org.lcsim.detector.DetectorElement;
import org.lcsim.detector.DetectorIdentifierHelper;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.DetectorIdentifierHelper.SystemMap;
@@ -26,7 +27,7 @@
* 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 $
+ * @version $Id: AbstractSubdetectorConverter.java,v 1.2 2007/12/06 22:27:11 jeremy Exp $
*/
public abstract class AbstractSubdetectorConverter implements ISubdetectorConverter
@@ -38,10 +39,13 @@
public IDetectorElement makeSubdetectorDetectorElement(Detector detector, Subdetector subdetector)
{
- // Default is a no-op.
return null;
+ // FIXME: put this in
+ //IDetectorElement subdetectorDE = new DetectorElement(subdetector.getName(), detector.getDetectorElement());
+ //subdetector.setDetectorElement(subdetectorDE);
+ //return subdetectorDE;
}
-
+
/**
* Sub-classes must implement this.
*/
@@ -59,9 +63,14 @@
*/
public IIdentifierHelper makeIdentifierHelper(Subdetector subdetector, SystemMap systemMap)
{
+ System.out.println("AbstractSubdetector.makeIdentifierHelper - " + subdetector.getName());
+
// Do not create helper if there is no Readout.
if (subdetector.getReadout() == null)
+ {
+ System.out.println(subdetector.getName() + " has not readout so no helper was made!");
return null;
+ }
// Make the IdentifierDictionary.
IIdentifierDictionary iddict = makeIdentifierDictionary(subdetector);
@@ -89,7 +98,9 @@
catch (InvalidIndexException x)
{
throw new RuntimeException(x);
- }
+ }
+
+ System.out.println("made helper -> " + helper.getIdentifierDictionary().getName());
return helper;
}
@@ -133,12 +144,16 @@
public void makeIdentifiers(Subdetector subdet)
{
+ System.out.println("makeIdentifiers");
+
if (subdet.getDetectorElement() == null)
return;
if (subdet.getDetectorElement().getIdentifierHelper() == null)
return;
+ System.out.println("ok");
+
IIdentifierHelper idhelper = subdet.getDetectorElement().getIdentifierHelper();
IIdentifierDictionary iddict = idhelper.getIdentifierDictionary();
@@ -202,6 +217,9 @@
try {
IIdentifier endcapSubId = idhelper.pack(expid);
+
+ System.out.println("endcap id - " + endcap.getName() + "-" + expid);
+
endcap.setIdentifier(endcapSubId);
}
catch (InvalidIndexException x)
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.34 -r1.35
--- DetectorConverter.java 6 Dec 2007 01:29:14 -0000 1.34
+++ DetectorConverter.java 6 Dec 2007 22:27:12 -0000 1.35
@@ -139,30 +139,44 @@
private void convertSubdetectors(Detector detector)
{
// Process all Subdetectors in the Detector.
- for ( Subdetector subdet : detector.getSubdetectors().values())
+ for ( Subdetector subdetector : detector.getSubdetectors().values())
{
// Find a converter for this type.
- ISubdetectorConverter cnv = getSubdetectorConverter(subdet.getClass());
+ ISubdetectorConverter cnv = getSubdetectorConverter(subdetector.getClass());
if ( cnv != null )
{
+ DetectorElement subdetectorDE = (DetectorElement)cnv.makeSubdetectorDetectorElement(detector, subdetector);
+
// Make the IdentifierHelper for this Subdetector.
- IIdentifierHelper helper = cnv.makeIdentifierHelper(subdet, sysMap);
+ IIdentifierHelper helper = cnv.makeIdentifierHelper(subdetector, sysMap);
+ if (helper != null)
+ {
+ System.out.println(subdetector.getName() + " - helper is null!");
+ }
+ else
+ {
+ System.out.println(subdetector.getName() + " - " + helper.getIdentifierDictionary().getName());
+ }
+
// Convert the parameters.
try {
- paramCnv.convert(subdet.getNode());
+ paramCnv.convert(subdetector.getNode());
}
catch ( JDOMException x )
{
throw new RuntimeException(x);
}
+ if (subdetectorDE != null)
+ subdetectorDE.setIdentifierHelper(helper);
+
// Build the Subdetector's geometry and associated DetectorElement(s).
- cnv.convert(subdet, detector);
+ cnv.convert(subdetector, detector);
// Get the top level Subdetector node back.
- DetectorElement subdetDE = (DetectorElement)subdet.getDetectorElement();
+ DetectorElement subdetDE = (DetectorElement)subdetector.getDetectorElement();
// Check if a DetectorElement was created. Some compact "detector" objects
// are not really detectors but dead material so this check is necessary
@@ -171,15 +185,15 @@
{
// Make the Parameters from the compact detector element
// and assign to the Subdetector's DetectorElement.
- subdetDE.setParameters(ParametersStore.getInstance().get(subdet.getName()));
+ subdetDE.setParameters(ParametersStore.getInstance().get(subdetector.getName()));
// Make the Subdetector IdentifierHelper from the IDDecoder
// and assign to the Subdetector's DetectorElement.
- if (helper != null)
+ if (helper != null && subdetectorDE.getIdentifierHelper() == null)
subdetDE.setIdentifierHelper(helper);
// Make the identifiers for this Subdetector.
- cnv.makeIdentifiers(subdet);
+ cnv.makeIdentifiers(subdetector);
}
}
}
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.16 -r1.17
--- SiTrackerEndcapConverter.java 6 Dec 2007 19:12:34 -0000 1.16
+++ SiTrackerEndcapConverter.java 6 Dec 2007 22:27:12 -0000 1.17
@@ -11,6 +11,7 @@
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;
@@ -26,11 +27,11 @@
import org.lcsim.detector.Translation3D;
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.IIdentifierHelper;
import org.lcsim.detector.identifier.IdentifierDictionaryManager;
-import org.lcsim.detector.identifier.IdentifierHelper;
import org.lcsim.detector.identifier.IdentifierUtil;
import org.lcsim.detector.identifier.IIdentifierDictionary.FieldNotFoundException;
import org.lcsim.detector.identifier.IIdentifierDictionary.InvalidIndexException;
@@ -57,13 +58,20 @@
* Converter for SiTrackerEndcap.
*
* @author Jeremy McCormick, Tim Nelson
- * @version $Id: SiTrackerEndcapConverter.java,v 1.16 2007/12/06 19:12:34 tknelson Exp $
+ * @version $Id: SiTrackerEndcapConverter.java,v 1.17 2007/12/06 22:27:12 jeremy Exp $
*/
public class SiTrackerEndcapConverter
extends AbstractSubdetectorConverter
implements ISubdetectorConverter
{
+ public IDetectorElement makeSubdetectorDetectorElement(Detector detector, Subdetector subdetector)
+ {
+ IDetectorElement endcapDE = new DetectorElement(subdetector.getName(), detector.getDetectorElement());
+ subdetector.setDetectorElement(endcapDE);
+ return endcapDE;
+ }
+
private ModuleParameters moduleParameters = null;
public IIdentifierHelper makeIdentifierHelper(Subdetector subdetector, SystemMap systemMap)
@@ -88,14 +96,33 @@
Element node = subdet.getNode();
- IDetectorElement endcapDE = new DetectorElement(subdet.getName(), detector.getDetectorElement());
- subdet.setDetectorElement(endcapDE);
+ IDetectorElement endcapDE = subdet.getDetectorElement();
- // Positive endcap DE.
- IDetectorElement endcapPosDE = new DetectorElement(subdet.getName() + "_positive", endcapDE);
-
- // Negative endcap DE.
- IDetectorElement endcapNegDE = new DetectorElement(subdet.getName() + "_negative", endcapDE);
+ DetectorIdentifierHelper helper = (DetectorIdentifierHelper)endcapDE.getIdentifierHelper();
+ int nfields = helper.getIdentifierDictionary().getNumberOfFields();
+
+ IDetectorElement endcapPosDE = null;
+ IDetectorElement endcapNegDE = null;
+ try {
+ // Positive endcap DE
+ IExpandedIdentifier endcapPosId = new ExpandedIdentifier(nfields);
+ endcapPosId.setValue(helper.getFieldIndex("system"), subdet.getSystemID());
+ endcapPosId.setValue(helper.getFieldIndex("barrel"), helper.getEndcapPositiveValue());
+ endcapPosDE = new DetectorElement(subdet.getName() + "_positive", endcapDE);
+ endcapPosDE.setIdentifier(helper.pack(endcapPosId));
+
+ // Negative endcap DE.
+ IExpandedIdentifier endcapNegId = new ExpandedIdentifier(nfields);
+ endcapNegId.setValue(helper.getFieldIndex("system"), subdet.getSystemID());
+ endcapNegId.setValue(helper.getFieldIndex("barrel"), helper.getEndcapNegativeValue());
+ endcapNegDE = new DetectorElement(subdet.getName() + "_negative", endcapDE);
+ endcapNegDE.setIdentifier(helper.pack(endcapNegId));
+
+ }
+ catch (Exception x)
+ {
+ throw new RuntimeException(x);
+ }
// Set static module parameters.
moduleParameters = new ModuleParameters(node.getChild("module"));
@@ -608,10 +635,11 @@
// TODO: Need to have SiTrackerIdentifierHelper available before this is called.
private void setupSensorDetectorElements(Subdetector subdet) throws Exception
- {
- IIdentifierHelper id_helper = new IdentifierHelper(IdentifierDictionaryManager.getInstance().getIdentifierDictionary(subdet.getReadout().getName()));
+ {
+ SiTrackerIdentifierHelper id_helper = (SiTrackerIdentifierHelper)subdet.getDetectorElement().getIdentifierHelper();
- //SiTrackerIdentifierHelper id_helper = (SiTrackerIdentifierHelper)subdet.getDetectorElement().getIdentifierHelper();
+ if (id_helper == null)
+ throw new RuntimeException("helper is null!!!!!!!!!");
int moduleId=0;
@@ -646,21 +674,23 @@
{
// Set the System ID.
expId.setValue(iddict.getFieldIndex("system"), subdet.getSystemID());
-
+
// Set the barrel-endcap flag.
- //if (id_helper.isEndcapPositive(endcap.getIdentifier()))
- if (id_helper.getValue(endcap.getIdentifier(), "barrel") == 1)
+ 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.getEndcapPositiveValue());
- expId.setValue(iddict.getFieldIndex("barrel"), 1);
+ expId.setValue(iddict.getFieldIndex("barrel"), id_helper.getEndcapNegativeValue());
}
- if (id_helper.getValue(endcap.getIdentifier(), "barrel") == 2)
- //else if (id_helper.isEndcapNegative(endcap.getIdentifier()))
+ else
{
- //expId.setValue(iddict.getFieldIndex("barrel"), id_helper.getEndcapNegativeValue());
- expId.setValue(iddict.getFieldIndex("barrel"), 2);
+ 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());
@@ -671,7 +701,7 @@
expId.setValue(iddict.getFieldIndex("module"),((SiTrackerModule)module).getModuleId());
// Set the sensor id for double-sided.
- expId.setValue(iddict.getFieldIndex("sensor"),sensorId);
+ expId.setValue(iddict.getFieldIndex("sensor"),sensorId);
}
catch (FieldNotFoundException x)
{
@@ -690,18 +720,15 @@
throw new RuntimeException(x);
}
- //System.out.println(pv.getName() + " is sens");
- //System.out.println("path : " + modulePath.toString() + "/" + pv.getName());
String sensorPath = modulePath.toString() + "/" + pv.getName();
- //String sensorName = subdet.getName() + "_layer" + layer.getGeometry().getPhysicalVolume().getCopyNumber() + "_module" + moduleId + "_sensor" + sensorId;
String sensorName = endcap.getName() +
"_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);
- System.out.println();
+ //System.out.println(sensorName + " -> " + expId);
+ //System.out.println(sensorName + " -> " + id);
+ //System.out.println();
SiSensor sensor = new SiSensor(sensorId,sensorName,module,sensorPath,id);
//sensor.setIdentifier(id);
@@ -732,17 +759,17 @@
// strip_angle = -1*strip_angle_magnitude;
}
- System.out.println("Plane of p_side polygon has... ");
- System.out.println(" normal: "+p_side.getNormal());
- System.out.println(" distance: "+p_side.getDistance());
- for (Point3D point : p_side.getVertices())
- {
- System.out.println(" Vertex: "+point);
- }
-
- System.out.println("Plane of n_side polygon has... ");
- System.out.println(" normal: "+n_side.getNormal());
- System.out.println(" distance: "+n_side.getDistance());
+ //System.out.println("Plane of p_side polygon has... ");
+ //System.out.println(" normal: "+p_side.getNormal());
+ //System.out.println(" distance: "+p_side.getDistance());
+ //for (Point3D point : p_side.getVertices())
+ //{
+ // System.out.println(" Vertex: "+point);
+ //}
+
+ //System.out.println("Plane of n_side polygon has... ");
+ //System.out.println(" normal: "+n_side.getNormal());
+ //System.out.println(" distance: "+n_side.getDistance());
// Bias the sensor
sensor.setBiasSurface(ChargeCarrier.HOLE,p_side);
@@ -750,15 +777,15 @@
double strip_angle = Math.PI/nwedges;
- System.out.println(" side = : "+side);
+ //System.out.println(" side = : "+side);
ITranslation3D electrodes_position = new Translation3D(VecOp.mult(-p_side.getDistance(),new BasicHep3Vector(0,0,1))); // translate to outside of polygon
// ITranslation3D electrodes_position = new Translation3D(VecOp.mult(-p_side.getDistance(),p_side.getNormal())); // translate to p_side
IRotation3D electrodes_rotation = new RotationPassiveXYZ(side*(Math.PI/2),0,0*strip_angle); //
Transform3D electrodes_transform = new Transform3D(electrodes_position, electrodes_rotation);
- System.out.println(" electrodes_transform translation: \n"+electrodes_transform.getTranslation().getTranslationVector());
- System.out.println(" electrodes_transform rotation: \n"+electrodes_transform.getRotation().getRotationMatrix());
+ //System.out.println(" electrodes_transform translation: \n"+electrodes_transform.getTranslation().getTranslationVector());
+ //System.out.println(" electrodes_transform rotation: \n"+electrodes_transform.getRotation().getRotationMatrix());
// Free calculation of sense electrodes, readout electrodes determined thereon
SiSensorElectrodes sense_electrodes = new SiStrips(ChargeCarrier.HOLE,0.025,sensor,electrodes_transform);