Commit in GeomConverter/src/org/lcsim on MAIN
detector/converter/compact/DetectorConverter.java+11.55 -> 1.56
geometry/compact/Detector.java+122-1511.32 -> 1.33
geometry/compact/converter/lcdd/LCDDDetector.java+56-971.26 -> 1.27
+179-248
3 modified files
format

GeomConverter/src/org/lcsim/detector/converter/compact
DetectorConverter.java 1.55 -> 1.56
diff -u -r1.55 -r1.56
--- DetectorConverter.java	11 Apr 2012 23:07:34 -0000	1.55
+++ DetectorConverter.java	24 Jan 2013 22:27:16 -0000	1.56
@@ -113,6 +113,7 @@
         addSubdetectorConverter(new HPSEcalConverter());
         addSubdetectorConverter(new HPSEcal2Converter());
         addSubdetectorConverter(new HPSEcal3Converter());
+        addSubdetectorConverter(new HPSMuonCalorimeterConverter());
 
         // Support structures.
         addSubdetectorConverter(new PolyconeSupportConverter());

GeomConverter/src/org/lcsim/geometry/compact
Detector.java 1.32 -> 1.33
diff -u -r1.32 -r1.33
--- Detector.java	12 Mar 2011 00:37:28 -0000	1.32
+++ Detector.java	24 Jan 2013 22:27:16 -0000	1.33
@@ -22,298 +22,269 @@
  * @author tonyj
  * @author jeremym
  */
-public class Detector
-{
+public class Detector {
+    
     private Header header;
-    private Map<String,Constant> constants = new HashMap<String,Constant>();
-    private Map<String,Subdetector> subdetectors = new HashMap<String,Subdetector>();
-    private Map<String,Readout> readouts = new HashMap<String,Readout>();
-    private Map<String,Field> fields = new HashMap<String,Field>();
-    private Map<String,LimitSet> limits = new HashMap<String,LimitSet>();
-    private Map<String,Region> regions = new HashMap<String,Region>();
-    private Map<String,VisAttributes> display = new HashMap<String,VisAttributes>();
+    private Map<String, Constant> constants = new HashMap<String, Constant>();
+    private Map<String, Subdetector> subdetectors = new HashMap<String, Subdetector>();
+    private Map<String, Readout> readouts = new HashMap<String, Readout>();
+    private Map<String, Field> fields = new HashMap<String, Field>();
+    private Map<String, LimitSet> limits = new HashMap<String, LimitSet>();
+    private Map<String, Region> regions = new HashMap<String, Region>();
+    private Map<String, VisAttributes> display = new HashMap<String, VisAttributes>();
     private XMLMaterialManager materialMgr; // Setup externally by CompactReader.
     private List<URL> gdmlReferences = new ArrayList<URL>();
-    
+
     private SystemIDMap idmap = new SystemIDMap();
-    
+
     private IPhysicalVolume worldVolume;
     private IPhysicalVolume trackingVolume;
     private IPhysicalVolumeNavigator navigator;
 
     private IDetectorElement de;
-    
+
     String name;
-    
+
     /**
      * Called by the reader to create a new Detector
+     * 
      * @param element The JDOM element corresponding to the detector definition in the XML file.
      */
-    protected Detector(Element element)
-    {
-        if (element != null)
-        {
-            name = element.getChild("info").getAttributeValue("name");                
-        }        
+    protected Detector(Element element) {
+        if (element != null) {
+            name = element.getChild("info").getAttributeValue("name");
+        }
     }
-    
-    protected void setXMLMaterialManager(XMLMaterialManager xmat)
-    {
+
+    protected void setXMLMaterialManager(XMLMaterialManager xmat) {
         materialMgr = xmat;
     }
-    
-    public String getName()
-    {
+
+    public String getName() {
         return name;
     }
-    
-    public IPhysicalVolume getWorldVolume()
-    {
+
+    public IPhysicalVolume getWorldVolume() {
         return worldVolume;
     }
-    
-    public void setWorldVolume(IPhysicalVolume worldVolume)
-    {
+
+    public void setWorldVolume(IPhysicalVolume worldVolume) {
         this.worldVolume = worldVolume;
-        navigator = new PhysicalVolumeNavigator("world",worldVolume);
+        navigator = new PhysicalVolumeNavigator("world", worldVolume);
         trackingVolume = navigator.getPath("/tracking_region").getLeafVolume();
     }
-    
-    public IPhysicalVolume getTrackingVolume()
-    {
+
+    public IPhysicalVolume getTrackingVolume() {
         return trackingVolume;
     }
-    
-    public IPhysicalVolumeNavigator getNavigator()
-    {
+
+    public IPhysicalVolumeNavigator getNavigator() {
         return navigator;
     }
-    
+
     /**
      * Called by the reader to associate a header with this detector
+     * 
      * @param header The header.
      */
-    protected void setHeader(Header header)
-    {
+    protected void setHeader(Header header) {
         this.header = header;
     }
+
     /**
      * Get the header associated with this detector.
+     * 
      * @return The header
      */
-    public Header getHeader()
-    {
+    public Header getHeader() {
         return header;
     }
-    
+
     /**
      * Get the detector name from the header.
+     * 
      * @return the detector name
      */
-    public String getDetectorName()
-    {
+    public String getDetectorName() {
         return getHeader().getDetectorName();
     }
-    
+
     /**
      * Called by the reader to add a constant to this detector.
+     * 
      * @param c The constant to add.
      */
-    protected void addConstant(Constant c)
-    {
-        constants.put(c.getName(),c);
+    protected void addConstant(Constant c) {
+        constants.put(c.getName(), c);
     }
+
     /**
      * Get the constants associated with this detector.
+     * 
      * @return A map of containing all of the constants, indexed by name.
      */
-    public Map<String,Constant> getConstants()
-    {
+    public Map<String, Constant> getConstants() {
         return constants;
     }
+
     /**
      * Called by the reader to add a new Readout to this detector.
+     * 
      * @param r The readout to add.
      */
-    protected void addReadout(Readout r)
-    {
-        //System.out.println("geometry.compact.Detector.addReadout() - " + r.getName() );
-        readouts.put(r.getName(),r);
+    protected void addReadout(Readout r) {
+        // System.out.println("geometry.compact.Detector.addReadout() - " + r.getName() );
+        readouts.put(r.getName(), r);
     }
+
     /**
      * Get the readouts associated with this detector.
+     * 
      * @return A map of containing all of the readouts, indexed by name.
      */
-    public Map<String, Readout> getReadouts()
-    {
+    public Map<String, Readout> getReadouts() {
         return readouts;
     }
-    
+
     /**
      * Convenience method to get readout by name.
      **/
-    public Readout getReadout(String rn)
-    {
+    public Readout getReadout(String rn) {
         return readouts.get(rn);
     }
-    
+
     /**
      * Called by the reader to add a sub-detector to this detector.
+     * 
      * @param sub The sub-detector to add.
      */
-    protected void addSubdetector(Subdetector sub)
-    {        
+    protected void addSubdetector(Subdetector sub) {
         // Check for a duplicate name.
-        if (subdetectors.get(sub.getName()) != null)
-        {
-            throw new RuntimeException("The subdetector " + sub.getName() + " in detector " + this.getDetectorName()
-                    + " has the same name as another subdetector, which is not allowed.");
+        if (subdetectors.get(sub.getName()) != null) {
+            throw new RuntimeException("The subdetector " + sub.getName() + " in detector " + this.getDetectorName() + " has the same name as another subdetector, which is not allowed.");
         }
-        subdetectors.put(sub.getName(),sub);
-     
+        subdetectors.put(sub.getName(), sub);
+
         // Check for a duplicate system id.
-        if (sub.getSystemID() != 0 && idmap.get(sub.getSystemID()) != null)
-        {
-            throw new RuntimeException("The subdetector " + sub.getName() + " in detector " + this.getDetectorName()
-                    + " duplicates the system ID " + sub.getSystemID()
-                    + " of the existing subdetector " + idmap.get(sub.getSystemID()));
+        if (sub.getSystemID() != 0 && idmap.get(sub.getSystemID()) != null) {
+            throw new RuntimeException("The subdetector " + sub.getName() + " in detector " + this.getDetectorName() + " duplicates the system ID " + sub.getSystemID() + " of the existing subdetector " + idmap.get(sub.getSystemID()));
         }
-        
+
         idmap.add(sub.getSystemID(), sub);
     }
-    
+
     /**
      * Get a Subdetector by system ID.
+     * 
      * @param sysid The system identifier.
-     */    
-    public Subdetector getSubdetector(int sysid)
-    {
+     */
+    public Subdetector getSubdetector(int sysid) {
         return idmap.get(sysid);
     }
-    
+
     /**
      * Convenience method to retrieve subdetector by name.
+     * 
      * @param subdetector with this name (null if doesn't exist)
      */
-    public Subdetector getSubdetector(String name)
-    {
+    public Subdetector getSubdetector(String name) {
         return subdetectors.get(name);
     }
 
     /**
      * Convenience method to retrieve set of detector names.
+     * 
      * @return set of subdetector name strings
      */
-    public Set<String> getSubdetectorNames()
-    {
+    public Set<String> getSubdetectorNames() {
         return getSubdetectors().keySet();
     }
-    
+
     /**
      * Get the sub-detectors associated with this detector.
+     * 
      * @return A map of containing all of the sub-detectors, indexed by name.
      */
-    public Map<String,Subdetector> getSubdetectors()
-    {
+    public Map<String, Subdetector> getSubdetectors() {
         return subdetectors;
     }
-    
-    protected void addField(Field field)
-    {
-        fields.put(field.getName(),field);
+
+    protected void addField(Field field) {
+        fields.put(field.getName(), field);
     }
-    
-    public Map<String,Field> getFields()
-    {
+
+    public Map<String, Field> getFields() {
         return fields;
     }
 
-    public final XMLMaterialManager getXMLMaterialManager()
-    {
+    public final XMLMaterialManager getXMLMaterialManager() {
         return materialMgr;
     }
 
-    public MaterialManager getMaterialManager()
-    {
+    public MaterialManager getMaterialManager() {
         return MaterialManager.instance();
     }
-    
-    public void addLimitSet(LimitSet limitset)
-    {
+
+    public void addLimitSet(LimitSet limitset) {
         limits.put(limitset.getName(), limitset);
     }
-    
-    public LimitSet getLimitSet(String name)
-    {
+
+    public LimitSet getLimitSet(String name) {
         return limits.get(name);
     }
-    
-    public Map<String, LimitSet> getLimits()
-    {
+
+    public Map<String, LimitSet> getLimits() {
         return limits;
     }
-    
-    public void addRegion(Region region)
-    {
+
+    public void addRegion(Region region) {
         regions.put(region.getName(), region);
     }
-    
-    public Region getRegion(String name)
-    {
+
+    public Region getRegion(String name) {
         return regions.get(name);
     }
-    
-    public Map<String,Region> getRegions()
-    {
+
+    public Map<String, Region> getRegions() {
         return regions;
     }
-    
-    public void addVisAttributes(VisAttributes vis)
-    {
-    	display.put(vis.getName(), vis);
+
+    public void addVisAttributes(VisAttributes vis) {
+        display.put(vis.getName(), vis);
     }
-    
-    public Map<String,VisAttributes> getVisAttributes()
-    {
-    	return display;
+
+    public Map<String, VisAttributes> getVisAttributes() {
+        return display;
     }
-    
-    public IDetectorElement getDetectorElement()
-    {
-    	return de;
+
+    public IDetectorElement getDetectorElement() {
+        return de;
     }
-    
-    public void setDetectorElement(IDetectorElement de)
-    {
-    	this.de = de;
+
+    public void setDetectorElement(IDetectorElement de) {
+        this.de = de;
     }
-    
-    public void addGDMLReference(URL url)
-    {
+
+    public void addGDMLReference(URL url) {
         gdmlReferences.add(url);
     }
-    
-    public List<URL> getGDMLReferences()
-    {
+
+    public List<URL> getGDMLReferences() {
         return gdmlReferences;
     }
-    
-    public Calorimeter getCalorimeterByType(Calorimeter.CalorimeterType calType)
-    {
-        for (Subdetector subdet : this.subdetectors.values())
-        {
-            if (subdet.isCalorimeter())
-            {
-                Calorimeter cal = (Calorimeter)subdet;
+
+    public Calorimeter getCalorimeterByType(Calorimeter.CalorimeterType calType) {
+        for (Subdetector subdet : this.subdetectors.values()) {
+            if (subdet.isCalorimeter()) {
+                Calorimeter cal = (Calorimeter) subdet;
                 if (cal.getCalorimeterType() == calType)
-                    return (Calorimeter)subdet;
+                    return (Calorimeter) subdet;
             }
         }
         return null;
     }
-    
-    public List<Subdetector> getSubdetectorList()    
-    {
+
+    public List<Subdetector> getSubdetectorList() {
         return new ArrayList<Subdetector>(getSubdetectors().values());
     }
 }

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
LCDDDetector.java 1.26 -> 1.27
diff -u -r1.26 -r1.27
--- LCDDDetector.java	25 Apr 2011 23:06:18 -0000	1.26
+++ LCDDDetector.java	24 Jan 2013 22:27:16 -0000	1.27
@@ -46,22 +46,20 @@
  * 
  * @author tonyj
  */
-class LCDDDetector extends org.lcsim.geometry.compact.Detector
-{
+class LCDDDetector extends org.lcsim.geometry.compact.Detector {
+    
     // Reference to compact doc.
     private Element compact;
-    
+
     // Checksum of LCDD file.
     private long checksum;
 
-    LCDDDetector(Element node)
-    {
+    LCDDDetector(Element node) {
         super(node);
         this.compact = node;
     }
 
-    Document writeLCDD(String filename) throws IOException, JDOMException
-    {
+    Document writeLCDD(String filename) throws IOException, JDOMException {
         LCDD lcdd = new LCDD();
 
         checksum = calculateChecksum(compact);
@@ -92,8 +90,7 @@
         define.addPosition(position);
 
         /* constants */
-        for (org.lcsim.geometry.compact.Constant c : getConstants().values())
-        {
+        for (org.lcsim.geometry.compact.Constant c : getConstants().values()) {
             define.addConstant(new Constant(c.getName(), String.valueOf(c.getValue())));
         }
 
@@ -103,7 +100,7 @@
         // Readouts.
         Map<Readout, IDSpec> idMap = writeReadouts(lcdd);
 
-        // Regions.        
+        // Regions.
         writeRegions(lcdd);
 
         // Limits.
@@ -126,98 +123,75 @@
         // Make LCDD document.
         Document doc = new Document();
         doc.setRootElement(lcdd);
-        
+
         return doc;
     }
 
-    private void writeGDMLRefs(LCDD lcdd) throws IOException, FileNotFoundException
-    {
+    private void writeGDMLRefs(LCDD lcdd) throws IOException, FileNotFoundException {
         FileCache cache = new FileCache();
-        for (URL gdmlFile : getGDMLReferences())
-        {
+        for (URL gdmlFile : getGDMLReferences()) {
             lcdd.mergeGDML(new FileInputStream(cache.getCachedFile(gdmlFile)));
         }
     }
 
-    private void writeFields(LCDD lcdd) throws JDOMException
-    {
-        for (Field field : getFields().values())
-        {
-            ((LCDDField)field).addToLCDD(lcdd);
+    private void writeFields(LCDD lcdd) throws JDOMException {
+        for (Field field : getFields().values()) {
+            ((LCDDField) field).addToLCDD(lcdd);
         }
     }
 
-    private void writeSubdetectors(LCDD lcdd, Map<Readout, IDSpec> idMap) throws JDOMException
-    {
-        for (Subdetector sub : getSubdetectors().values())
-        {
+    private void writeSubdetectors(LCDD lcdd, Map<Readout, IDSpec> idMap) throws JDOMException {
+        for (Subdetector sub : getSubdetectors().values()) {
             SensitiveDetector sens = null;
             Readout readout = sub.getReadout();
-            if (readout != null)
-            {
-                if (sub.isTracker())
-                {
+            if (readout != null) {
+                if (sub.isTracker()) {
                     sens = new Tracker(sub.getName());
-                }
-                else if (sub.isCalorimeter())
-                {
+                } else if (sub.isCalorimeter()) {
                     // Standard segmented calorimeter.
-                    if (readout.getSegmentation() != null && readout.getSegmentation().useForHitPosition())
-                    {
+                    if (readout.getSegmentation() != null && readout.getSegmentation().useForHitPosition()) {
                         sens = new Calorimeter(sub.getName());
                     }
                     // Unsegmented calorimeter for detailed readout studies.
                     // May still have Segmentation but not used for hit positions.
-                    else
-                    {
+                    else {
                         sens = new UnsegmentedCalorimeter(sub.getName());
                     }
                 }
                 // TODO Add optical cal handling here.
 
-                if (sens != null)
-                {
+                if (sens != null) {
                     sens.setIDSpec(idMap.get(readout));
                     sens.setHitsCollection(readout.getName());
                     lcdd.addSensitiveDetector(sens);
                 }
 
-                if (sub.isCalorimeter())
-                {
-                    try
-                    {
-                        if (readout.getSegmentation() != null)
-                        {
+                if (sub.isCalorimeter()) {
+                    try {
+                        if (readout.getSegmentation() != null) {
                             // System.out.println(readout.getSegmentation().getClass().getCanonicalName());
-                            LCDDSegmentation seg = (LCDDSegmentation)readout.getSegmentation();
-                            seg.setSegmentation((Calorimeter)sens);
+                            LCDDSegmentation seg = (LCDDSegmentation) readout.getSegmentation();
+                            seg.setSegmentation((Calorimeter) sens);
                         }
-                    }
-                    catch (Throwable x)
-                    {
+                    } catch (Throwable x) {
                         throw new RuntimeException("Readout " + readout.getName() + " is not a valid Segmentation object.", x);
                     }
                 }
             }
-            
-            //System.out.println("class:" + sub.getClass().getCanonicalName());
 
-            if (sub instanceof LCDDSubdetector)
-            {
-                ((LCDDSubdetector)sub).addToLCDD(lcdd, sens);
-            }
-            else
-            {
+            // System.out.println("class:" + sub.getClass().getCanonicalName());
+
+            if (sub instanceof LCDDSubdetector) {
+                ((LCDDSubdetector) sub).addToLCDD(lcdd, sens);
+            } else {
                 throw new RuntimeException("Subdetector is not an instanceof LCDDSubdetector.");
             }
         }
     }
 
-    private void writeVisAttribs(LCDD lcdd)
-    {
+    private void writeVisAttribs(LCDD lcdd) {
         // Visualization attributes.
-        for (org.lcsim.geometry.compact.VisAttributes vis : getVisAttributes().values())
-        {
+        for (org.lcsim.geometry.compact.VisAttributes vis : getVisAttributes().values()) {
             VisAttributes lcddvis = new VisAttributes(vis.getName());
 
             float rgba[] = vis.getRGBA();
@@ -231,13 +205,10 @@
         }
     }
 
-    private void writeLimits(LCDD lcdd)
-    {
-        for (org.lcsim.geometry.compact.LimitSet limitset : getLimits().values())
-        {
+    private void writeLimits(LCDD lcdd) {
+        for (org.lcsim.geometry.compact.LimitSet limitset : getLimits().values()) {
             LimitSet lcddLimitSet = new LimitSet(limitset.getName());
-            for (org.lcsim.geometry.compact.Limit limit : limitset.getLimits().values())
-            {
+            for (org.lcsim.geometry.compact.Limit limit : limitset.getLimits().values()) {
                 Limit lcddLimit = new Limit(limit.getName());
 
                 lcddLimit.setParticles(limit.getParticles());
@@ -250,10 +221,8 @@
         }
     }
 
-    private void writeRegions(LCDD lcdd)
-    {
-        for (org.lcsim.geometry.compact.Region region : getRegions().values())
-        {
+    private void writeRegions(LCDD lcdd) {
+        for (org.lcsim.geometry.compact.Region region : getRegions().values()) {
             Region lcddRegion = new Region(region.getName());
             lcddRegion.setStoreSecondaries(region.getStoreSecondaries());
             lcddRegion.setThreshold(region.getEnergyThreshold());
@@ -264,18 +233,15 @@
         }
     }
 
-    private Map<Readout, IDSpec> writeReadouts(LCDD lcdd)
-    {
+    private Map<Readout, IDSpec> writeReadouts(LCDD lcdd) {
         // Loop over the readouts
         Map<Readout, IDSpec> idMap = new HashMap<Readout, IDSpec>();
-        for (Readout readout : getReadouts().values())
-        {
+        for (Readout readout : getReadouts().values()) {
             IDDescriptor id = readout.getIDDescriptor();
             IDSpec idspec = new IDSpec(readout.getName());
             idspec.setLength(id.getMaxBit());
 
-            for (int i = 0; i < id.fieldCount(); i++ )
-            {
+            for (int i = 0; i < id.fieldCount(); i++) {
                 IDField field = new IDField();
                 field.setLabel(id.fieldName(i));
                 field.setLength(id.fieldLength(i));
@@ -289,34 +255,28 @@
         return idMap;
     }
 
-    private void setupMaterials(LCDD lcdd) throws JDOMException
-    {               
+    private void setupMaterials(LCDD lcdd) throws JDOMException {
         LCDDMaterialHelper helper = new LCDDMaterialHelper(getXMLMaterialManager());
-        helper.copyToLCDD(compact, lcdd);        
+        helper.copyToLCDD(compact, lcdd);
     }
 
-    public String getName()
-    {
+    public String getName() {
         return "GeomConverter";
     }
 
-    private String getVersion()
-    {
+    private String getVersion() {
         return "1.0";
     }
 
-    private long getChecksum()
-    {
+    private long getChecksum() {
         return checksum;
     }
 
-    private long calculateChecksum(Element top) throws IOException
-    {
+    private long calculateChecksum(Element top) throws IOException {
         // Write out in canonical format to calculate checksum
         // ignoring comments and whitespace
         Iterator iter = top.getDescendants(new ContentFilter(ContentFilter.COMMENT));
-        while (iter.hasNext())
-        {
+        while (iter.hasNext()) {
             iter.next();
             iter.remove();
         }
@@ -331,15 +291,14 @@
         return check.getValue();
     }
 
-    private static class NullOutputStream extends OutputStream
-    {
-        public void write(byte[] b, int off, int len) throws IOException
-        {}
+    private static class NullOutputStream extends OutputStream {
+        public void write(byte[] b, int off, int len) throws IOException {
+        }
 
-        public void write(byte[] b) throws IOException
-        {}
+        public void write(byte[] b) throws IOException {
+        }
 
-        public void write(int b) throws IOException
-        {}
+        public void write(int b) throws IOException {
+        }
     }
 }
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1