Commit in hps-java/src/main/java/org/lcsim/hps on MAIN
evio/EvioConsumer.java+17-1381.11 -> 1.12
    /LCSimEventBuilder.java+40-391.1 -> 1.2
monitoring/ConnectionPanel.java+237added 1.1
+294-177
1 added + 2 modified, total 3 files
working copies

hps-java/src/main/java/org/lcsim/hps/evio
EvioConsumer.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- EvioConsumer.java	22 Mar 2012 02:21:16 -0000	1.11
+++ EvioConsumer.java	22 Mar 2012 03:54:53 -0000	1.12
@@ -18,8 +18,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
@@ -54,6 +52,7 @@
 import org.lcsim.event.Track;
 import org.lcsim.event.TrackerHit;
 import org.lcsim.geometry.Detector;
+import org.lcsim.hps.monitoring.ConnectionPanel;
 import org.lcsim.hps.monitoring.ConnectionParameters;
 import org.lcsim.hps.monitoring.ConnectionParameters.ConnectionParametersException;
 import org.lcsim.job.JobControlManager;
@@ -68,13 +67,15 @@
  *
  * @author Jeremy McCormick
  */
-// FIXME Try to put plots into separate Driver which can be called from the .lcsim file, in order to cleanup this class.
+// TODO Move plots into separate Driver which can be called from the .lcsim file, in order to cleanup this class.
+// TODO Move the code that wraps Driver and event loop into the JobControlManager.
+// TODO The main class should be renamed to "TestRunMonitoringGui" or something similar.
+// TODO Integrate the ConnectionPanel so that it can be used for changing connection parameters.
 public class EvioConsumer {
     
-    //private static final String trackCollectionName = "MatchedTracks";
+    // TODO Next three should be settable as job options.
     private static final String detectorName = "HPS-Test-JLAB-v4pt0";
-    private static final String trackerHitCollectionName = "StripClusterer_SiTrackerHitStrip1D";
-    
+    private static final String trackerHitCollectionName = "StripClusterer_SiTrackerHitStrip1D";    
     private static final String lcsimXml = "/org/lcsim/hps/steering/EtTest.lcsim";
     
     private static Detector detector;
@@ -140,6 +141,7 @@
         plotter.show();
                                 
         // Make a list of sensors in the SVT.
+        // FIXME Hard-coded reference to subdetector name.
         List<SiSensor> sensors = detector.getSubdetector("Tracker").getDetectorElement().findDescendants(SiSensor.class);            
         
         // Setup occupancy plots.
@@ -248,13 +250,8 @@
             DriverAdapter driverAdapter = new DriverAdapter(topDriver);
                                     
             // Call wrapper to startOfData() on DriverAdapter.
-            driverAdapter.configure(null);            
-            
-            // Create a dummy event in order to get Detector conditions.
-            //BaseLCSimEvent dummyEvent = new BaseLCSimEvent(0, 0, detectorName);
-            //Detector detector = dummyEvent.getDetector();
-            //EvioConsumer.detector = detector;
-            
+            driverAdapter.configure(null);
+                        
             // Make the builder for creating LCSim events from EVIO data.
             LCSimEventBuilder eventBuilder = new LCSimEventBuilder(detectorName);
             eventBuilder.setDebug(true);
@@ -276,6 +273,8 @@
             // Show GUI.
             EvioConsumerGui.main(new String[]{});
             Thread.sleep(1000); 
+            
+            ConnectionPanel.main(new String[]{});
                                                                                                           
             // Number of current event from 0.
             //int eventCount = 0;                     
@@ -298,10 +297,7 @@
                     long jobEndTime = System.currentTimeMillis();
                     long jobTime = jobEndTime - jobStartTime;
                     System.out.println("Job time: " + jobTime / 1000 + " seconds");
-                    
-                    //long avgEventTime = jobTime / (eventCount);
-                    //System.out.println("Avg event processing time: " + avgEventTime + " ms");
-                    
+                                        
                     // Call wrapper to endOfData() on DriverAdapter.
                     driverAdapter.finish(null);
                                                             
@@ -387,8 +383,8 @@
                     }
                     occuPlot.show();
 
-                    // Get Tracks from event.
-                    //List<Track> tracks = lcsimEvent.get(Track.class, trackCollectionName);
+                    // Get Track list from event.  
+                    // This breaks if there is more than one Track collection generated by LCSim.
                     List<Track> tracks = lcsimEvent.get(Track.class).get(0);
 
                     // Plot number of Tracks.
@@ -434,8 +430,8 @@
 
                 }
                                                 
-                // put events back into ET system
-                // FIXME Is this even necessary when running in read-only mode?
+                // Put events back into ET system.
+                // FIXME Is this necessary when running in read-only mode?
                 sys.putEvents(att, mevs);
             }
         }
@@ -452,124 +448,7 @@
             aida.cloud1D("Amplitude").fill(hit.getAmplitude());
         }
     }
-    
-    static class ConnectionPanel extends JPanel implements ActionListener {
-
-        JTextField etName;
-        JTextField host;
-        JTextField port;
-        
-        String defaultEtName = "ETBuffer";
-                       
-        ConnectionParameters connectionParameters;
-                
-        ConnectionPanel() {
-            setLayout(new GridBagLayout());
-            
-            GridBagConstraints c = new GridBagConstraints();
-            
-            c.gridx = 0;
-            c.gridy = 0;
-            c.anchor = GridBagConstraints.WEST;
-            JLabel etNameLabel = new JLabel("ET Name:"); 
-            etNameLabel.setHorizontalAlignment(JLabel.LEFT); 
-            add(etNameLabel, c);
-            
-            c = new GridBagConstraints();
-            c.gridx = 1;
-            c.gridy = 0;
-            c.anchor = GridBagConstraints.EAST;
-            etName = new JTextField("", 20);
-            etName.setText(defaultEtName);
-            etName.setHorizontalAlignment(JTextField.RIGHT);
-            add(etName, c);
-            
-            c = new GridBagConstraints();
-            c.gridx = 0;
-            c.gridy = 1;
-            c.anchor = GridBagConstraints.WEST;
-            JLabel hostLabel = new JLabel("Host:");
-            hostLabel.setHorizontalAlignment(JLabel.LEFT);
-            add(hostLabel, c);
-            
-            InetAddress addr;
-            try {
-                addr = InetAddress.getLocalHost();
-            } catch (UnknownHostException e) {
-                throw new RuntimeException(e);
-            }
-            String hostname = addr.getHostName();
-            
-            c = new GridBagConstraints();
-            c.gridx = 1;
-            c.gridy = 1;
-            c.anchor = GridBagConstraints.EAST;
-            host = new JTextField("", 20);
-            host.setText(hostname);
-            host.setHorizontalAlignment(JTextField.RIGHT);
-            add(host, c);
-            
-            c = new GridBagConstraints();
-            c.gridx = 0;
-            c.gridy = 2;
-            c.anchor = GridBagConstraints.WEST;
-            JLabel portLabel = new JLabel("Port:");
-            portLabel.setHorizontalAlignment(JLabel.LEFT);
-            add(portLabel, c);
-            
-            c = new GridBagConstraints();
-            c.gridx = 1;
-            c.gridy = 2;
-            port = new JTextField("", 5);
-            port.setHorizontalAlignment(JTextField.RIGHT);
-            add(port, c);
-            
-            c = new GridBagConstraints();
-            c.gridx = 0;
-            c.gridy = 3;
-            JLabel nonBlockingLabel = new JLabel("Non-Blocking IO:");
-            nonBlockingLabel.setHorizontalAlignment(JLabel.LEFT);
-            add(nonBlockingLabel, c);
-            
-            // TODO Add rest of fields here.
-            // TODO Add "connect" and "cancel" buttons here.
-        }
         
-        ConnectionParameters fillConnectionParameters() {
-            ConnectionParameters c = new ConnectionParameters();
-            c.etName = etName.getText();
-            return c;
-        }
-
-        public void actionPerformed(ActionEvent e) {
-            // TODO Auto-generated method stub            
-        }               
-        
-        public ConnectionParameters getConnectionParameters() {
-           return connectionParameters; 
-        }
-        
-        public static void createAndShow() {     
-            JFrame frame = new JFrame("Connection Dialog");
-            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-            
-            JPanel c = new ConnectionPanel();
-            c.setOpaque(true);
-            frame.setContentPane(c);
-            
-            frame.pack();
-            frame.setVisible(true);
-        }
-        
-        public static void main(String[] args) {
-            javax.swing.SwingUtilities.invokeLater(new Runnable() {
-                public void run() {
-                    createAndShow();
-                }            
-            });
-        }
-    }
-    
     static class EvioConsumerGui extends JPanel implements ActionListener {
         
         JButton resetButton;

hps-java/src/main/java/org/lcsim/hps/evio
LCSimEventBuilder.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- LCSimEventBuilder.java	22 Mar 2012 02:21:16 -0000	1.1
+++ LCSimEventBuilder.java	22 Mar 2012 03:54:53 -0000	1.2
@@ -34,33 +34,27 @@
  */
 public class LCSimEventBuilder {
     
-    // Name of SVT detector.
-    //private String trackerName = "Tracker";
-    //private String calorimeterName = "Ecal";
+    // Names of subdetectors.
     private String trackerName;
     private String calorimeterName;
     
-    // Names of raw data collections with defaults.
+    // Names of raw data collections with default settings.
     private String rawTrackerHitCollectionName = "RawTrackerHitMaker_RawTrackerHits";
     private String rawCalorimeterHitCollectionName = "EcalRawHits";
-    
-    // Names of readouts with defaults.
-    //private String trackerReadoutName = "TrackerHits";
-    //private String ecalReadoutName = "EcalHits";
-    
-    // Detector conditions.
+        
+    // Detector conditions object.
     private Detector detector;
-    //private String detectorName;
     
+    // Debug flag.
     private boolean debug = false;
        
-    LCSimEventBuilder(String detectorName) {
+    public LCSimEventBuilder(String detectorName) {
         
-        // Make a dummy event to setup conditions system.
+        // Make a dummy event to setup the conditions system.
         EventHeader dummyEvent = new BaseLCSimEvent(0, 0, detectorName);
         detector = dummyEvent.getDetector();
         
-        // Set default detector names based on HPS detector types.
+        // Set default detector names by looking for HPS detector types.
         for (Subdetector subdet : detector.getSubdetectorList()) {
             if (subdet instanceof HPSTracker) {
                 trackerName = subdet.getName();
@@ -161,23 +155,21 @@
     private List<RawTrackerHit> makeRawTrackerHits(CompositeData cdata) {
         
         // Get some ID info before looping in order to strip out irrelevant fields.
-        // TODO Next three can be removed from here and done only once at start of run. 
+        // TODO Next three should be cached so as to avoid calling every event. 
         IIdentifierDictionary dict = detector.getSubdetector(trackerName).getDetectorElement().getIdentifierHelper().getIdentifierDictionary();
         int fieldIdx = dict.getFieldIndex("side");
         int sideIdx = dict.getFieldIndex("strip");
         
-        // List of hits to be returned.
+        // List of hits to return.
         List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>();
         
         // Loop over the items in the CompositeData.
-        List<Object> items = cdata.getItems();                        
-        //int n = items.size();
         int n = cdata.getNValue();
         if (debug)
             System.out.println("RawTrackerHit.N = " + n);
         for (int i=0; i<n; i++) {
             
-            // Get values for hit.
+            // Get values for hit from composite data.
             Long id = cdata.getLong();
             int time = cdata.getInt();
             int adcValue = cdata.getInt();
@@ -185,30 +177,16 @@
             // Make the new hit.
             RawTrackerHit hit = new BaseRawTrackerHit(id, time, new short[] {(short)adcValue});
                                                             
-            // The "side" and "strip" fields needs to be taken out of the ID or the geometry lookup will fail.
-            IExpandedIdentifier expId = dict.unpack(hit.getIdentifier());            
+            // The "side" and "strip" fields needs to be stripped from the ID for sensor lookup.
+            IExpandedIdentifier expId = dict.unpack(hit.getIdentifier());
             expId.setValue(fieldIdx, 0);
             expId.setValue(sideIdx, 0);
             IIdentifier strippedId = dict.pack(expId);
             
-            // Find the SiSensor of this hit.  This is more complicated than it should be,
-            // because DetectorElements are not guaranteed to have unique IDs.
-            List<IDetectorElement> des = DetectorElementStore.getInstance().find(strippedId);
-            SiSensor sensor = null;
-            if (des == null || des.size() == 0) {
-                throw new RuntimeException("Failed to find DetectorElement for hit with id 0x"+Long.toHexString(strippedId.getValue()));
-            }
-            else if (des.size() == 1) {
-                sensor = (SiSensor)des.get(0);
-            }
-            else {
-                for (IDetectorElement de : des) {
-                    if (de instanceof SiSensor) {
-                        sensor = (SiSensor)de;
-                        break;
-                    }
-                }
-            }                        
+            // Find the sensor for this hit using the stripped ID.
+            SiSensor sensor = findSensor(strippedId);
+            
+            // Assign sensor to hit.
             hit.setDetectorElement(sensor);
                  
             // Add this hit to the list.
@@ -221,6 +199,29 @@
         return hits;
     }
     
+    private SiSensor findSensor(IIdentifier id) {        
+        List<IDetectorElement> des = DetectorElementStore.getInstance().find(id);
+        SiSensor sensor = null;
+        if (des == null || des.size() == 0) {
+            throw new RuntimeException("Failed to find any DetectorElements with ID <0x" + Long.toHexString(id.getValue()) + ">.");
+        }
+        else if (des.size() == 1) {
+            sensor = (SiSensor)des.get(0);
+        }
+        else {
+            for (IDetectorElement de : des) {
+                if (de instanceof SiSensor) {
+                    sensor = (SiSensor)de;
+                    break;
+                }
+            }
+        }   
+        if (sensor == null) {
+            throw new RuntimeException("No sensor was found with ID <0x" + Long.toHexString(id.getValue()) + ">.");
+        }
+        return sensor;
+    }
+    
     private List<RawCalorimeterHit> makeRawCalorimeterHits(EvioEvent event) {
         List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>();        
         for (BaseStructure bank : event.getChildren()) {

hps-java/src/main/java/org/lcsim/hps/monitoring
ConnectionPanel.java added at 1.1
diff -N ConnectionPanel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ConnectionPanel.java	22 Mar 2012 03:54:53 -0000	1.1
@@ -0,0 +1,237 @@
+package org.lcsim.hps.monitoring;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+public class ConnectionPanel extends JPanel implements ActionListener {
+
+    JTextField etNameField;
+    JTextField hostField;
+    JTextField portField;
+    JCheckBox blockingField;
+    JCheckBox verboseField;
+    JTextField statNameField;
+    JTextField chunkField;
+    JTextField qSizeField;
+    JTextField positionField;
+    JTextField ppositionField;
+    
+    ConnectionParameters connectionParameters;
+
+    ConnectionPanel() {
+        
+        // Starting GUI values will be assigned from default connection parameters. 
+        connectionParameters = new ConnectionParameters();
+        
+        setLayout(new GridBagLayout());
+
+        GridBagConstraints c = new GridBagConstraints();
+
+        c.gridx = 0;
+        c.gridy = 0;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel etNameLabel = new JLabel("ET Name:");
+        etNameLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(etNameLabel, c);
+
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 0;
+        c.anchor = GridBagConstraints.EAST;
+        etNameField = new JTextField("", 20);
+        etNameField.setText(connectionParameters.etName);
+        etNameField.setHorizontalAlignment(JTextField.RIGHT);
+        add(etNameField, c);
+
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 1;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel hostLabel = new JLabel("Host:");
+        hostLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(hostLabel, c);
+
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 1;
+        c.anchor = GridBagConstraints.EAST;
+        hostField = new JTextField("", 20);
+        hostField.setText(connectionParameters.host);
+        hostField.setHorizontalAlignment(JTextField.RIGHT);
+        add(hostField, c);
+
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 2;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel portLabel = new JLabel("Port:");
+        portLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(portLabel, c);
+
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 2;
+        c.anchor = GridBagConstraints.EAST;
+        portField = new JTextField(Integer.toString(connectionParameters.port), 5);
+        portField.setHorizontalAlignment(JTextField.RIGHT);
+        add(portField, c);
+
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 3;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel blockingLabel = new JLabel("Blocking:");
+        blockingLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(blockingLabel, c);
+
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 3;
+        c.anchor = GridBagConstraints.EAST;
+        blockingField = new JCheckBox();
+        blockingField.setSelected(connectionParameters.blocking);
+        add(blockingField, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 4;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel verboseLabel = new JLabel("Verbose:");
+        verboseLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(verboseLabel, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 4;
+        c.anchor = GridBagConstraints.EAST;
+        verboseField = new JCheckBox();
+        verboseField.setSelected(connectionParameters.verbose);
+        add(verboseField, c);
+                
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 5;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel statNameLabel = new JLabel("Station Name:");
+        statNameLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(statNameLabel, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 5;
+        c.anchor = GridBagConstraints.EAST;
+        statNameField = new JTextField(connectionParameters.statName, 10);
+        statNameField.setHorizontalAlignment(JTextField.RIGHT);
+        add(statNameField, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 6;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel chunkLabel = new JLabel("Chunk Size:");
+        chunkLabel.setToolTipText("Number of events returned in array.");
+        chunkLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(chunkLabel, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 6;
+        c.anchor = GridBagConstraints.EAST;
+        chunkField = new JTextField(Integer.toString(connectionParameters.chunk), 3);
+        chunkField.setHorizontalAlignment(JTextField.RIGHT);
+        add(chunkField, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 7;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel qSizeLabel = new JLabel("Queue Size:");
+        qSizeLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(qSizeLabel, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 7;
+        c.anchor = GridBagConstraints.EAST;
+        qSizeField = new JTextField(Integer.toString(connectionParameters.qSize), 3);
+        qSizeField.setHorizontalAlignment(JTextField.RIGHT);
+        add(qSizeField, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 8;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel positionLabel = new JLabel("Station Position:");
+        positionLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(positionLabel, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 8;
+        c.anchor = GridBagConstraints.EAST;
+        positionField = new JTextField(Integer.toString(connectionParameters.position), 3);
+        add(positionField, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 9;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel ppositionLabel = new JLabel("Station Parallel Position:");
+        ppositionLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(ppositionLabel, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 9;
+        c.anchor = GridBagConstraints.EAST;
+        ppositionField = new JTextField(Integer.toString(connectionParameters.pposition), 3);
+        add(ppositionField, c);
+    }
+
+    ConnectionParameters getConnectionParameters() {
+        connectionParameters = new ConnectionParameters();
+        connectionParameters.etName = etNameField.getText();
+        connectionParameters.host = hostField.getText();
+        connectionParameters.port = Integer.parseInt(portField.getText());
+        connectionParameters.blocking = blockingField.isSelected();
+        connectionParameters.verbose = verboseField.isSelected();
+        connectionParameters.statName = statNameField.getText();
+        connectionParameters.chunk = Integer.parseInt(chunkField.getText());
+        connectionParameters.qSize = Integer.parseInt(qSizeField.getText());
+        connectionParameters.position = Integer.parseInt(positionField.getText());
+        connectionParameters.pposition = Integer.parseInt(ppositionField.getText());
+        return connectionParameters;
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        // TODO Auto-generated method stub
+    }
+
+    public static void createAndShow() {
+        JFrame frame = new JFrame("Connection Dialog");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        JPanel c = new ConnectionPanel();
+        c.setOpaque(true);
+        frame.setContentPane(c);
+
+        frame.pack();
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) {
+        javax.swing.SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                createAndShow();
+            }
+        });
+    }
+}
\ No newline at end of file
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