GeomConverter/src/org/lcsim/geometry
diff -u -r1.16 -r1.17
--- Detector.java 11 Jun 2005 01:17:53 -0000 1.16
+++ Detector.java 1 Jul 2005 00:12:55 -0000 1.17
@@ -17,72 +17,85 @@
*
* @author tonyj
*/
-public class Detector extends org.lcsim.geometry.compact.Detector implements HepRepProvider {
+public class Detector extends org.lcsim.geometry.compact.Detector implements HepRepProvider
+{
private FieldMap fieldMap;
- Detector(Element node) {
+ Detector(Element node)
+ {
super(node);
}
- public IDDecoder getDecoder(String readout) {
+ public IDDecoder getDecoder(String readout)
+ {
return (IDDecoder) getReadouts().get(readout).getSegmentation();
}
- protected void addSubdetector(org.lcsim.geometry.compact.Subdetector sub) {
+ protected void addSubdetector(org.lcsim.geometry.compact.Subdetector sub)
+ {
super.addSubdetector(sub);
Readout r = sub.getReadout();
- if (r != null) {
+ if (r != null)
+ {
Segmentation s = r.getSegmentation();
- if ( s != null ) {
+ if ( s != null )
+ {
- SegmentationImpl si = (SegmentationImpl) r.getSegmentation();
-
- if ( si != null ) {
+ SegmentationImpl si = (SegmentationImpl) r.getSegmentation();
- if ( sub instanceof org.lcsim.geometry.compact.LayeredSubdetector )
- {
- LayeredSubdetector layeredSubdet = (LayeredSubdetector) sub;
+ if ( si != null )
+ {
- if ( layeredSubdet == null )
+ if ( sub instanceof org.lcsim.geometry.compact.LayeredSubdetector )
{
- throw new RuntimeException("Failed cast to LayeredSubdetector.");
- }
-
- /**
- * TODO: Segmentation should not store a reference to its subdetector. --JM
- */
- si.setSubdetector(layeredSubdet);
+ LayeredSubdetector layeredSubdet = (LayeredSubdetector) sub;
+
+ if ( layeredSubdet == null )
+ {
+ throw new RuntimeException("Failed cast to LayeredSubdetector.");
+ }
+
+ /**
+ * TODO: Segmentation should not store a reference to its subdetector. --JM
+ */
+ si.setSubdetector(layeredSubdet);
}
}
- else {
+ else
+ {
throw new RuntimeException("Failed cast to SegmentationImpl.");
}
- }
+ }
}
}
- protected void addReadout(Readout r) {
+ protected void addReadout(Readout r)
+ {
super.addReadout(r);
Segmentation s = r.getSegmentation();
- if ( s != null ) {
-
+ if ( s != null )
+ {
+
SegmentationImpl si = (SegmentationImpl) s;
-
- if ( si != null ) {
+
+ if ( si != null )
+ {
si.setIDDescription(r.getIDDescriptor());
}
- else {
- throw new RuntimeException("Failed cast to SegmentationImpl.");
+ else
+ {
+ throw new RuntimeException("Failed cast to SegmentationImpl.");
}
- }
+ }
}
- public void appendHepRep(HepRepFactory factory, HepRep heprep) {
+ public void appendHepRep(HepRepFactory factory, HepRep heprep)
+ {
HepRepTreeID treeID = factory.createHepRepTreeID("DetectorType", "1.0");
HepRepTypeTree typeTree = factory.createHepRepTypeTree(treeID);
heprep.addTypeTree(typeTree);
@@ -98,17 +111,21 @@
HepRepType endcap = factory.createHepRepType(typeTree, "Endcap");
endcap.addAttValue("layer",detectorLayer);
- for (Object sub: getSubdetectors().values()) {
- if (sub instanceof HepRepProvider) {
+ for (Object sub: getSubdetectors().values())
+ {
+ if (sub instanceof HepRepProvider)
+ {
((HepRepProvider) sub).appendHepRep(factory,heprep);
}
}
}
- public FieldMap getFieldMap() {
+ public FieldMap getFieldMap()
+ {
return fieldMap;
}
- protected void addField(Field field) {
+ protected void addField(Field field)
+ {
super.addField(field);
fieldMap = (FieldMap) field; // assumes single field for now
}