GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.51 -r1.52
--- DetectorConverter.java 22 Jun 2011 21:30:05 -0000 1.51
+++ DetectorConverter.java 18 Jul 2011 21:01:53 -0000 1.52
@@ -33,7 +33,7 @@
public class DetectorConverter implements IDetectorConverter
{
// Map of class to converter.
- Map< Class, ISubdetectorConverter > subdetectorConverters = new HashMap< Class, ISubdetectorConverter >();
+ Map<Class, ISubdetectorConverter> subdetectorConverters = new HashMap<Class, ISubdetectorConverter>();
// The parameters converter.
ParametersConverter paramCnv = new ParametersConverter();
@@ -46,38 +46,39 @@
// The SystemMap for setting up the IdentifierHelpers.
SystemMap sysMap;
- public IPhysicalVolume convert( Detector detector, Document doc ) throws JDOMException, IOException
+ public IPhysicalVolume convert(Detector detector, Document doc) throws JDOMException,
+ IOException
{
// Clear out old DetectorStore store before building new detector.
DetectorStore.getInstance().clear();
// Convert materials.
- convertMaterials( "/org/lcsim/material/elements.xml" );
- convertMaterials( "/org/lcsim/material/materials.xml" );
- convertMaterials( doc );
+ convertMaterials("/org/lcsim/material/elements.xml");
+ convertMaterials("/org/lcsim/material/materials.xml");
+ convertMaterials(doc);
// Construct the world volume.
- IPhysicalVolume pvWorld = buildWorldVolume( detector );
+ IPhysicalVolume pvWorld = buildWorldVolume(detector);
// Make the default navigator.
PhysicalVolumeNavigatorStore.getInstance().reset();
- PhysicalVolumeNavigatorStore.getInstance().createDefault( pvWorld );
+ PhysicalVolumeNavigatorStore.getInstance().createDefault(pvWorld);
// Set the Detector's DetectorElement.
- IDetectorElement deDet = new DeDetector( detector );
- detector.setDetectorElement( deDet );
+ IDetectorElement deDet = new DeDetector(detector);
+ detector.setDetectorElement(deDet);
// Construct the tracking volume.
- buildTrackingVolume( pvWorld.getLogicalVolume(), detector );
+ buildTrackingVolume(pvWorld.getLogicalVolume(), detector);
// Set the world volume.
- detector.setWorldVolume( pvWorld );
+ detector.setWorldVolume(pvWorld);
// Make the SystemMap.
- sysMap = makeSystemMap( detector );
+ sysMap = makeSystemMap(detector);
// Convert Subdetectors including creation of IdentifierHelpers.
- convertSubdetectors( detector );
+ convertSubdetectors(detector);
// Return the world volume.
return pvWorld;
@@ -86,258 +87,270 @@
public DetectorConverter()
{
// Simple cylindrical detectors.
- addSubdetectorConverter( new CylindricalBarrelCalorimeterConverter() );
- addSubdetectorConverter( new CylindricalEndcapCalorimeterConverter() );
- addSubdetectorConverter( new MultiLayerTrackerConverter() );
- addSubdetectorConverter( new DiskTrackerConverter() );
+ addSubdetectorConverter(new CylindricalBarrelCalorimeterConverter());
+ addSubdetectorConverter(new CylindricalEndcapCalorimeterConverter());
+ addSubdetectorConverter(new MultiLayerTrackerConverter());
+ addSubdetectorConverter(new DiskTrackerConverter());
// Detailed tracker models.
- addSubdetectorConverter( new SiTrackerBarrelConverter() );
- addSubdetectorConverter( new SiTrackerEndcapConverter() );
- addSubdetectorConverter( new SiTrackerEndcap2Converter() );
- addSubdetectorConverter( new SiTrackerFixedTargetConverter() );
- addSubdetectorConverter( new SiTrackerFixedTarget2Converter() );
- addSubdetectorConverter( new SiTrackerSpectrometerConverter() );
+ addSubdetectorConverter(new SiTrackerBarrelConverter());
+ addSubdetectorConverter(new SiTrackerEndcapConverter());
+ addSubdetectorConverter(new SiTrackerEndcap2Converter());
+ addSubdetectorConverter(new SiTrackerFixedTargetConverter());
+ addSubdetectorConverter(new SiTrackerFixedTarget2Converter());
+ addSubdetectorConverter(new SiTrackerSpectrometerConverter());
// Detailed calorimeter models.
- addSubdetectorConverter( new PolyhedraBarrelCalorimeterConverter() );
- addSubdetectorConverter( new PolyhedraBarrelCalorimeter2Converter() );
- addSubdetectorConverter( new PolyhedraEndcapCalorimeter2Converter() );
- addSubdetectorConverter( new PolyhedraEndcapCalorimeterConverter() );
- addSubdetectorConverter( new EcalBarrelConverter() );
+ addSubdetectorConverter(new PolyhedraBarrelCalorimeterConverter());
+ addSubdetectorConverter(new PolyhedraBarrelCalorimeter2Converter());
+ addSubdetectorConverter(new PolyhedraEndcapCalorimeter2Converter());
+ addSubdetectorConverter(new PolyhedraEndcapCalorimeterConverter());
+ addSubdetectorConverter(new EcalBarrelConverter());
+
+ // HPS
+ addSubdetectorConverter(new HPSEcalConverter());
+ addSubdetectorConverter(new HPSEcal2Converter());
// Support structures.
- addSubdetectorConverter( new PolyconeSupportConverter() );
- addSubdetectorConverter( new TubeSegmentConverter() );
+ addSubdetectorConverter(new PolyconeSupportConverter());
+ addSubdetectorConverter(new TubeSegmentConverter());
}
- private void addSubdetectorConverter( ISubdetectorConverter s )
+ private void addSubdetectorConverter(ISubdetectorConverter s)
{
- if ( subdetectorConverters.get( s.getSubdetectorType() ) != null )
+ if (subdetectorConverters.get(s.getSubdetectorType()) != null)
{
- throw new IllegalArgumentException( "Already have converter for <" + s.getSubdetectorType()
- .getCanonicalName() + "> !" );
+ throw new IllegalArgumentException("Already have converter for <"
+ + s.getSubdetectorType().getCanonicalName() + "> !");
}
- subdetectorConverters.put( s.getSubdetectorType(), s );
+ subdetectorConverters.put(s.getSubdetectorType(), s);
}
- private ISubdetectorConverter getSubdetectorConverter( Class klass )
+ private ISubdetectorConverter getSubdetectorConverter(Class klass)
{
- return subdetectorConverters.get( klass );
+ return subdetectorConverters.get(klass);
}
- public IPhysicalVolume convert( Detector detector, String resource ) throws JDOMException, IOException
+ public IPhysicalVolume convert(Detector detector, String resource) throws JDOMException,
+ IOException
{
- return convert( detector, CompactDocumentBuilder.build( resource ) );
+ return convert(detector, CompactDocumentBuilder.build(resource));
}
- private void convertMaterials( Document doc ) throws JDOMException
+ private void convertMaterials(Document doc) throws JDOMException
{
- materialCnv.convert( doc );
+ materialCnv.convert(doc);
}
- private void convertMaterials( String resource ) throws JDOMException, IOException
+ private void convertMaterials(String resource) throws JDOMException, IOException
{
- Document doc = CompactDocumentBuilder.build( resource );
+ Document doc = CompactDocumentBuilder.build(resource);
- for ( Object obj : doc.getRootElement().getChildren() )
+ for (Object obj : doc.getRootElement().getChildren())
{
- Element e = ( Element ) obj;
- if ( e.getName().equals( "element" ) )
+ Element e = (Element) obj;
+ if (e.getName().equals("element"))
{
- elemCnv.convert( e );
+ elemCnv.convert(e);
}
- else if ( e.getName().equals( "material" ) )
+ else if (e.getName().equals("material"))
{
- matCnv.convert( e );
+ matCnv.convert(e);
}
}
}
- private void convertSubdetectors( Detector detector )
+ private void convertSubdetectors(Detector detector)
{
// Process all Subdetectors in the Detector.
- for ( Subdetector subdetector : detector.getSubdetectors().values() )
+ for (Subdetector subdetector : detector.getSubdetectors().values())
{
// System.out.println("subdetector: " + subdetector.getName());
// Find a converter for this type.
- ISubdetectorConverter cnv = getSubdetectorConverter( subdetector.getClass() );
+ ISubdetectorConverter cnv = getSubdetectorConverter(subdetector.getClass());
- if ( cnv != null )
+ if (cnv != null)
{
// System.out.println("found cnv handling: " +
// cnv.getSubdetectorType().getCanonicalName());
- DetectorElement subdetectorDE = ( DetectorElement ) cnv.makeSubdetectorDetectorElement(
- detector,
- subdetector );
+ DetectorElement subdetectorDE = (DetectorElement) cnv
+ .makeSubdetectorDetectorElement(detector, subdetector);
- // System.out.println("made subdet DE: " + subdetectorDE.getName());
+ // System.out.println("made subdet DE: " +
+ // subdetectorDE.getName());
// Make the IdentifierHelper for this Subdetector.
- IIdentifierHelper helper = cnv.makeIdentifierHelper( subdetector, sysMap );
+ IIdentifierHelper helper = cnv.makeIdentifierHelper(subdetector, sysMap);
// Convert the parameters.
try
{
- paramCnv.convert( subdetector.getNode() );
+ paramCnv.convert(subdetector.getNode());
}
- catch ( JDOMException x )
+ catch (JDOMException x)
{
- throw new RuntimeException( x );
+ throw new RuntimeException(x);
}
- if ( subdetectorDE != null )
- subdetectorDE.setIdentifierHelper( helper );
+ if (subdetectorDE != null)
+ subdetectorDE.setIdentifierHelper(helper);
- // Build the Subdetector's geometry and associated DetectorElement(s).
- cnv.convert( subdetector, detector );
+ // Build the Subdetector's geometry and associated
+ // DetectorElement(s).
+ cnv.convert(subdetector, detector);
// Get the top level Subdetector node back.
- DetectorElement subdetDE = ( DetectorElement ) subdetector.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
+ // 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 )
+ if (subdetDE != null)
{
// Make the Parameters from the compact detector element
// and assign to the Subdetector's DetectorElement.
- subdetDE.setParameters( ParametersStore.getInstance().get( subdetector.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 && subdetectorDE.getIdentifierHelper() == null )
- subdetDE.setIdentifierHelper( helper );
+ if (helper != null && subdetectorDE.getIdentifierHelper() == null)
+ subdetDE.setIdentifierHelper(helper);
// Make the identifiers for this Subdetector.
- cnv.makeIdentifiers( subdetector );
+ cnv.makeIdentifiers(subdetector);
}
}
// else
// {
- // System.out.println("no converter found for " + subdetector.getName());
+ // System.out.println("no converter found for " +
+ // subdetector.getName());
// }
// System.out.println();
}
}
- private void buildTrackingVolume( ILogicalVolume world, Detector detector )
+ private void buildTrackingVolume(ILogicalVolume world, Detector detector)
{
- Map< String, Constant > constants = detector.getConstants();
+ Map<String, Constant> constants = detector.getConstants();
- if ( constants.get( "tracking_region_zmax" ) == null || constants.get( "tracking_region_radius" ) == null )
+ if (constants.get("tracking_region_zmax") == null
+ || constants.get("tracking_region_radius") == null)
{
- throw new RuntimeException( "Missing parameters for defining tracking region!" );
+ throw new RuntimeException("Missing parameters for defining tracking region!");
}
- double zmax = constants.get( "tracking_region_zmax" ).getValue();
- double radius = constants.get( "tracking_region_radius" ).getValue();
+ double zmax = constants.get("tracking_region_zmax").getValue();
+ double radius = constants.get("tracking_region_radius").getValue();
- Tube trackingTube = new Tube( "tracking_region_tube", 0, radius, zmax );
+ Tube trackingTube = new Tube("tracking_region_tube", 0, radius, zmax);
- LogicalVolume trackingLV = new LogicalVolume( "tracking_region", trackingTube, MaterialStore.getInstance().get(
- "Air" ) );
+ LogicalVolume trackingLV = new LogicalVolume("tracking_region", trackingTube, MaterialStore
+ .getInstance().get("Air"));
- new PhysicalVolume( null, "tracking_region", trackingLV, world, 0 );
+ new PhysicalVolume(null, "tracking_region", trackingLV, world, 0);
}
- private IPhysicalVolume buildWorldVolume( Detector detector )
+ private IPhysicalVolume buildWorldVolume(Detector detector)
{
- Map< String, Constant > constants = detector.getConstants();
+ Map<String, Constant> constants = detector.getConstants();
- if ( constants.get( "world_x" ) == null || constants.get( "world_y" ) == null || constants.get( "world_z" ) == null )
+ if (constants.get("world_x") == null || constants.get("world_y") == null
+ || constants.get("world_z") == null)
{
- throw new RuntimeException( "Missing world_x, world_y, or world_z!" );
+ throw new RuntimeException("Missing world_x, world_y, or world_z!");
}
- double x = constants.get( "world_x" ).getValue();
- double y = constants.get( "world_y" ).getValue();
- double z = constants.get( "world_z" ).getValue();
+ double x = constants.get("world_x").getValue();
+ double y = constants.get("world_y").getValue();
+ double z = constants.get("world_z").getValue();
- IMaterial air = MaterialStore.getInstance().get( "Air" );
+ IMaterial air = MaterialStore.getInstance().get("Air");
- Box boxWorld = new Box( "world_box", x, y, z );
+ Box boxWorld = new Box("world_box", x, y, z);
- LogicalVolume lvWorld = new LogicalVolume( "world", boxWorld, air );
+ LogicalVolume lvWorld = new LogicalVolume("world", boxWorld, air);
- PhysicalVolume pvWorld = new PhysicalVolume( null, "world", lvWorld, null, 0 );
+ PhysicalVolume pvWorld = new PhysicalVolume(null, "world", lvWorld, null, 0);
return pvWorld;
}
- // Converts the subdetectors in a detector to a map of subsystems to system id.
+ // Converts the subdetectors in a detector to a map of subsystems to system
+ // id.
// TODO: Must be a better way to setup these associations in the
// DetectorIdentifierHelper.
- public static final SystemMap makeSystemMap( Detector d )
+ public static final SystemMap makeSystemMap(Detector d)
{
SystemMap m = new SystemMap();
- for ( Subdetector subdet : d.getSubdetectors().values() )
+ for (Subdetector subdet : d.getSubdetectors().values())
{
String name = subdet.getName();
int sys = subdet.getSystemID();
// Based on naming conventions from sid01 and sid02.
- if ( !name.contains( "Support" ) && !( subdet instanceof PolyconeSupport ) )
+ if (!name.contains("Support") && !(subdet instanceof PolyconeSupport))
{
- if ( name.contains( "VertexBarrel" ) )
+ if (name.contains("VertexBarrel"))
{
- m.put( "vtxBarrel", sys );
+ m.put("vtxBarrel", sys);
}
- else if ( name.contains( "VertexEndcap" ) )
+ else if (name.contains("VertexEndcap"))
{
- m.put( "vtxEndcap", sys );
+ m.put("vtxEndcap", sys);
}
- else if ( name.contains( "TrackerBarrel" ) )
+ else if (name.contains("TrackerBarrel"))
{
- m.put( "sitBarrel", sys );
+ m.put("sitBarrel", sys);
}
- else if ( name.contains( "TrackerEndcap" ) )
+ else if (name.contains("TrackerEndcap"))
{
- m.put( "sitEndcap", sys );
+ m.put("sitEndcap", sys);
}
- else if ( name.contains( "TrackerForward" ) )
+ else if (name.contains("TrackerForward"))
{
- m.put( "sitForward", sys );
+ m.put("sitForward", sys);
}
- else if ( name.contains( "TPC" ) )
+ else if (name.contains("TPC"))
{
- m.put( "tpc", sys );
+ m.put("tpc", sys);
}
- else if ( name.contains( "EMBarrel" ) )
+ else if (name.contains("EMBarrel"))
{
- m.put( "ecalBarrel", sys );
+ m.put("ecalBarrel", sys);
}
- else if ( name.contains( "EMEndcap" ) && !name.contains( "Forward" ) )
+ else if (name.contains("EMEndcap") && !name.contains("Forward"))
{
- m.put( "ecalEndcap", sys );
+ m.put("ecalEndcap", sys);
}
- else if ( name.contains( "HADBarrel" ) )
+ else if (name.contains("HADBarrel"))
{
- m.put( "hcalBarrel", sys );
+ m.put("hcalBarrel", sys);
}
- else if ( name.contains( "HADEndcap" ) )
+ else if (name.contains("HADEndcap"))
{
- m.put( "hcalEndcap", sys );
+ m.put("hcalEndcap", sys);
}
- else if ( name.contains( "MuonBarrel" ) )
+ else if (name.contains("MuonBarrel"))
{
- m.put( "muonBarrel", sys );
+ m.put("muonBarrel", sys);
}
- else if ( name.contains( "MuonEndcap" ) )
+ else if (name.contains("MuonEndcap"))
{
- m.put( "muonEndcap", sys );
+ m.put("muonEndcap", sys);
}
- else if ( name.contains( "LuminosityMonitor" ) || name.contains( "LumiCal" ) )
+ else if (name.contains("LuminosityMonitor") || name.contains("LumiCal"))
{
- m.put( "lumi", sys );
+ m.put("lumi", sys);
}
- else if ( name.contains( "ForwardEMEndcap" ) )
+ else if (name.contains("ForwardEMEndcap"))
{
- m.put( "ecalForward", sys );
+ m.put("ecalForward", sys);
}
}
}