Commit in hps-java/src on MAIN | |||
main/java/org/lcsim/hps/evio/MCRawDataToEvio4Converter.java | +161 | added 1.1 | |
/EvioConsumer.java | +464 | -48 | 1.9 -> 1.10 |
test/java/org/lcsim/hps/evio/MCRawDataToEvio4Converter_Test.java | +51 | added 1.1 | |
+676 | -48 |
check in working copies of these before I change around the EVIO format
diff -N MCRawDataToEvio4Converter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ MCRawDataToEvio4Converter.java 21 Mar 2012 20:19:13 -0000 1.1 @@ -0,0 +1,161 @@
+package org.lcsim.hps.evio; + +import java.io.IOException; +import java.util.List; + +import org.jlab.coda.jevio.CompositeData; +import org.jlab.coda.jevio.DataType; +import org.jlab.coda.jevio.EventBuilder; +import org.jlab.coda.jevio.EventWriter; +import org.jlab.coda.jevio.EvioBank; +import org.jlab.coda.jevio.EvioException; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawCalorimeterHit; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.util.Driver; + +/** + * This Driver creates an EVIO data file using raw data generated from HPS MC data, + * e.g. output from slic simulation in LCIO format. + * + * The EVIO event structure is as follows, and subject to change. + * + * event + * bank + * composite data + * bank + * composite data + * + * The tracker data bank has number = 1 and the ecal data bank has number = 2. + * + * For now the data formats do not match raw data that would come off the ET ring + * but I plan to add this soon. + * + * @author Jeremy McCormick <[log in to unmask]> + */ +public class MCRawDataToEvio4Converter extends Driver { + + String evioOutputFile = "MCRawData.evio"; + EventWriter writer; + + String rawTrackerHitCollectionName = "RawTrackerHitMaker_RawTrackerHits"; + String rawCalorimeterHitCollectionName = "EcalRawHits"; + + public static final int trackerBankTag = 0x0; + public static final int trackerBankNumber = 1; + public static final String trackerFormat = "N(L,I,I)"; + + public static final int ecalBankTag = 0xe103; + public static final int ecalBankNumber = 2; + public static final String ecalFormat = "N(L,I,I)"; + + public MCRawDataToEvio4Converter() + {} + + public void setEvioOutputFile(String evioOutputFile) { + this.evioOutputFile = evioOutputFile; + } + + public void setRawTrackerHitCollectionName(String rawTrackerHitCollectionName) { + this.rawTrackerHitCollectionName = rawTrackerHitCollectionName; + } + + public void setRawCalorimeterHitCollectionName(String rawCalorimeterHitCollectionName) { + this.rawCalorimeterHitCollectionName = rawCalorimeterHitCollectionName; + } + + public void startOfData() { + try { + writer = new EventWriter(evioOutputFile); + } + catch (EvioException e) { + throw new RuntimeException(e); + } + } + + public void endOfData() { + try { + writer.close(); + } catch (EvioException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public void process(EventHeader event) { + + EventBuilder builder = new EventBuilder(0, DataType.BANK, event.getEventNumber()); + writeRawTrackerHits(event.get(RawTrackerHit.class, rawTrackerHitCollectionName), builder); + writeRawCalorimeterHits(event.get(RawCalorimeterHit.class, rawCalorimeterHitCollectionName), builder); + builder.setAllHeaderLengths(); + try { + writer.writeEvent(builder.getEvent()); + } catch (EvioException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public void writeRawTrackerHits(List<RawTrackerHit> rawTrackerHits, EventBuilder builder) { + + int dataSize = rawTrackerHits.size(); + CompositeData.Data data = new CompositeData.Data(); + data.addN(dataSize); + for (RawTrackerHit hit : rawTrackerHits) { + data.addLong(hit.getCellID()); + data.addInt(hit.getTime()); + data.addInt(hit.getADCValues()[0]); + } + CompositeData cdata = null; + try { + cdata = new CompositeData(trackerFormat, 1, data, 0 ,0); + } + catch (EvioException e) { + throw new RuntimeException(e); + } + EvioBank bank = new EvioBank(trackerBankTag, DataType.COMPOSITE, trackerBankNumber); + try { + bank.appendCompositeData(cdata); + } catch (EvioException e) { + throw new RuntimeException(e); + } + bank.setAllHeaderLengths(); + try { + builder.addChild(builder.getEvent(), bank); + } catch (EvioException e) { + throw new RuntimeException(e); + } + } + + public void writeRawCalorimeterHits(List<RawCalorimeterHit> rawCalorimeterHits, EventBuilder builder) { + CompositeData.Data data = new CompositeData.Data(); + int nhits = rawCalorimeterHits.size(); + data.addN(nhits); + for (RawCalorimeterHit hit : rawCalorimeterHits) { + data.addLong(hit.getCellID()); + data.addInt(hit.getAmplitude()); + data.addInt(hit.getTimeStamp()); + } + CompositeData cdata = null; + try { + cdata = new CompositeData(ecalFormat, 1, data, 0 ,0); + } + catch (EvioException e) { + throw new RuntimeException(e); + } + EvioBank bank = new EvioBank(ecalBankTag, DataType.COMPOSITE, ecalBankNumber); + try { + bank.appendCompositeData(cdata); + } catch (EvioException e) { + throw new RuntimeException(e); + } + bank.setAllHeaderLengths(); + try { + builder.addChild(builder.getEvent(), bank); + } catch (EvioException e) { + throw new RuntimeException(e); + } + } +}
\ No newline at end of file
diff -u -r1.9 -r1.10 --- EvioConsumer.java 17 Mar 2012 02:23:26 -0000 1.9 +++ EvioConsumer.java 21 Mar 2012 20:19:13 -0000 1.10 @@ -9,12 +9,19 @@
import hep.aida.IPlotterStyle; import hep.aida.ITree;
+import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; 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; import java.util.HashMap; import java.util.List;
@@ -23,7 +30,9 @@
import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame;
+import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.JTextField;
import org.freehep.record.loop.event.RecordSuppliedEvent; import org.jlab.coda.et.EtAttachment;
@@ -36,6 +45,7 @@
import org.jlab.coda.et.enums.Mode; import org.jlab.coda.et.enums.Modify; import org.jlab.coda.et.exception.EtTimeoutException;
+import org.jlab.coda.jevio.BaseStructure;
import org.jlab.coda.jevio.CompositeData; import org.jlab.coda.jevio.EvioEvent; import org.jlab.coda.jevio.EvioReader;
@@ -45,16 +55,19 @@
import org.lcsim.detector.identifier.IIdentifier; import org.lcsim.detector.identifier.IIdentifierDictionary; import org.lcsim.detector.tracker.silicon.SiSensor;
+import org.lcsim.event.RawCalorimeterHit;
import org.lcsim.event.RawTrackerHit; import org.lcsim.event.Track; import org.lcsim.event.TrackerHit; import org.lcsim.event.base.BaseLCSimEvent;
+import org.lcsim.event.base.BaseRawCalorimeterHit;
import org.lcsim.event.base.BaseRawTrackerHit; import org.lcsim.geometry.Detector; import org.lcsim.job.JobControlManager; import org.lcsim.util.Driver; import org.lcsim.util.DriverAdapter; import org.lcsim.util.aida.AIDA;
+import org.lcsim.util.lcio.LCIOConstants;
/** * This class is an example of an event consumer for an ET system.
@@ -66,16 +79,24 @@
public class EvioConsumer { private static final String detectorName = "HPS-Test-JLAB-v4pt0";
+
private static final String trackerName = "Tracker"; private static final String rawTrackerHitCollectionName = "RawTrackerHitMaker_RawTrackerHits";
- private static final String readoutName = "TrackerHits";
+ private static final String trackerReadoutName = "TrackerHits";
private static final String trackCollectionName = "MatchedTracks"; private static final String trackerHitCollectionName = "StripClusterer_SiTrackerHitStrip1D";
+ + private static final String rawCalorimeterHitCollectionName = "EcalRawHits"; + private static final String ecalReadoutName = "EcalHits"; +
private static final String lcsimXml = "/org/lcsim/hps/steering/EtTest.lcsim"; private static final boolean debug = false; private static Detector detector;
- static Map<SiSensor,int[]> occupancyMap; - static IPlotter occuPlot;
+ private static Map<SiSensor,int[]> occupancyMap; + private static IPlotter occuPlot; + private static EvioConsumerGui gui; + private static long jobStartTime; + private static int eventCount;
private static List<IPlotter> plotters = new ArrayList<IPlotter>();
@@ -187,6 +208,18 @@
} plotter3.show(); }
+ + // Ecal plots. + IPlotter plotter4 = fac.createPlotterFactory().create("HPS ECAL Plots"); + plotters.add(plotter4); + ICloud1D ecalTimePlot = aida.cloud1D("Timestamp"); + ICloud1D ecalAmplitudePlot = aida.cloud1D("Amplitude"); + ICloud1D ecalHitsPlot = aida.cloud1D("Number of Hits"); + plotter4.createRegions(2, 2); + plotter4.region(0).plot(ecalTimePlot); + plotter4.region(1).plot(ecalAmplitudePlot); + plotter4.region(2).plot(ecalHitsPlot); + plotter4.show();
} public static void main(String[] args) {
@@ -360,15 +393,20 @@
// The default AIDA instance. AIDA aida = AIDA.defaultInstance();
+ ConnectionPanel.main(new String[]{}); +
// Show GUI. EvioConsumerGui.main(new String[]{});
-
+ Thread.sleep(1000); +
// Number of current event from 0.
- int eventCount = 0; - long jobStartTime = System.currentTimeMillis();
+ //int eventCount = 0; + jobStartTime = System.currentTimeMillis(); + long eventRateStart = System.nanoTime(); + final int eventRateInterval = 10;
while (true) {
- long startTime = System.nanoTime();
+ //long startTime = System.nanoTime();
// get events from ET system //mevs = sys.getEvents(att, Mode.SLEEP, null, 0, chunk);
@@ -385,28 +423,20 @@
long jobTime = jobEndTime - jobStartTime; System.out.println("Job time: " + jobTime / 1000 + " seconds");
- long avgEventTime = jobTime / (eventCount + 1);
+ long avgEventTime = jobTime / (eventCount);
System.out.println("Avg event processing time: " + avgEventTime + " ms"); // Call wrapper to endOfData() on DriverAdapter. driverAdapter.finish(null);
- - // Save AIDA plots. - try { - aida.saveAs("EtTestPlots.aida"); - } catch (java.lang.NoClassDefFoundError e) { - System.out.println("AIDA doesn't appear to be setup correctly to save output files!"); - e.printStackTrace(); - } - - // Exit after user pressed enter.
+ + // Exit after user presses enter.
System.out.println("Press ENTER to exit ..."); System.console().readLine(); System.exit(0);
- }
+ }
- if (debug) - System.out.println("EvioConsumer read event #" + eventCount);
+ //if (debug) + // System.out.println("EvioConsumer read event #" + eventCount);
if (mevs.length > 1) { throw new RuntimeException("Did not expect to get more than one EtEvent!");
@@ -432,26 +462,42 @@
} // Make CompositeData from data buffer.
- CompositeData cdata = evioEvent.getCompositeData();
+ //CompositeData cdata = evioEvent.getCompositeData();
- // Make LCSim RawTrackerHits from CompositeData. - List<RawTrackerHit> hits = makeRawTrackerHits(detector, cdata); - - // Create a new LCSimEvent and add the hits.
+ // Convert from EVIO to LCIO objects. + List<RawTrackerHit> rawTrackerHits = null; + List<RawCalorimeterHit> rawCalorimeterHits = null; + for (BaseStructure bank : evioEvent.getChildren()) { + if (bank.getHeader().getNumber() == MCRawDataToEvio4Converter.trackerBankNumber) { + rawTrackerHits = makeRawTrackerHits(detector, bank.getCompositeData()); + } + else if (bank.getHeader().getNumber() == MCRawDataToEvio4Converter.ecalBankNumber) { + rawCalorimeterHits = makeRawCalorimeterHits(detector, bank.getCompositeData()); + } + } + + //System.out.println("rawTrackerHits.size = " + rawTrackerHits.size()); + //System.out.println("rawCalorimeterHits.size = " + rawCalorimeterHits.size()); + + // Create a new LCSimEvent and add the hit collections.
BaseLCSimEvent lcsimEvent = new BaseLCSimEvent(0, eventCount, detectorName);
- lcsimEvent.put(rawTrackerHitCollectionName, hits, RawTrackerHit.class, 0, readoutName);
+ lcsimEvent.put(rawTrackerHitCollectionName, rawTrackerHits, RawTrackerHit.class, (1 << LCIOConstants.TRAWBIT_ID1), trackerReadoutName); + lcsimEvent.put(rawCalorimeterHitCollectionName, rawCalorimeterHits, RawCalorimeterHit.class, 0, ecalReadoutName);
// Make a new event for DriverAdapter. RecordSuppliedEvent loopEvent = new RecordSuppliedEvent(new Object(), lcsimEvent); // Call process methods via Driver Adapter. driverAdapter.recordSupplied(loopEvent);
+ + // Make ECal plots. + makeEcalPlots(aida, rawCalorimeterHits);
// Fill RawTrackerHit count.
- aida.histogram1D("Number of RawTrackerHits in Event").fill(hits.size());
+ aida.histogram1D("Number of RawTrackerHits in Event").fill(rawTrackerHits.size());
// Loop over RawTrackerHit collection.
- for (RawTrackerHit hit : hits) {
+ for (RawTrackerHit hit : rawTrackerHits) {
// Fill ADC value plot. aida.histogram1D("ADC Value").fill(hit.getADCValues()[0]);
@@ -509,31 +555,52 @@
sys.putEvents(att, mevs); // Compute event processing time.
- long endTime = System.nanoTime(); - long elapsed = endTime - startTime;
+ //long endTime = System.nanoTime(); + //long elapsed = endTime - startTime;
//System.out.println("processed event in " + elapsed + " ns"); // Compute instantaneous event rate e.g. this event only.
- double eventRate = 10e9 / elapsed;
+ //double eventRate = 10e9 / elapsed;
//System.out.println("instantaneous event rate = " + eventRate + " hz"); // Fill event rate plot.
- aida.cloud1D("Event Rate [Hz]").fill(eventRate); -
+ //aida.cloud1D("Event Rate [Hz]").fill(eventRate); + + long currTime = System.currentTimeMillis() - jobStartTime; + gui.setElapsedTime(currTime); +
// Increment event count. ++eventCount;
+ + // Periodically compute event rate. + if (eventCount % eventRateInterval == 0) { + long eventRateEnd = System.nanoTime(); + long eventElapsed = eventRateEnd - eventRateStart; + long nsPerEvent = eventElapsed / eventRateInterval; + double eventRate = 10e9 / nsPerEvent; + gui.setEventRate(eventRate); + eventRateStart = System.nanoTime(); + } + + gui.incrEventCount(); + + // Compute rolling average event processing time. + double avgProcTime = (System.currentTimeMillis() - jobStartTime) / (double)eventCount; + double avgEventRate = 1000 / avgProcTime; + gui.setAverageEventRate(avgEventRate);
- if (debug) - System.out.println("----------------------");
+ //if (debug) + // System.out.println("----------------------");
} } catch (Exception ex) {
- System.out.println("Error using ET system as consumer");
+ System.out.println("Error using ET system as consumer.");
ex.printStackTrace(); } }
-
+
private static boolean HIT_MAKING_DEBUG = false;
+
private static List<RawTrackerHit> makeRawTrackerHits(Detector detector, CompositeData cdata) { // Get some ID info before looping in order to strip out irrelevant fields.
@@ -547,8 +614,10 @@
// Loop over the items in the CompositeData. List<Object> items = cdata.getItems();
- int n = items.size(); - for (int i=0; i<n; i+=3) {
+ //int n = items.size(); + int n = cdata.getNValue(); + System.out.println("RawTrackerHit.N = " + n); + for (int i=1; i<n; i+=3) {
// Get values for hit. Long id = (Long)items.get(i);
@@ -594,38 +663,381 @@
return hits; }
- public static class EvioConsumerGui extends JPanel implements ActionListener {
+ private static List<RawCalorimeterHit> makeRawCalorimeterHits(Detector detector, CompositeData cdata) { + List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); + List<Object> items = cdata.getItems(); + //int n = items.size(); + int n = cdata.getNValue(); + System.out.println("RawCalHit.N = " + n); + for (int i=1; i<n; i+=3) { + long id = (Long)items.get(i); + int amplitude = (Integer)items.get(i+1); + int timestamp = (Integer)items.get(i+2); + hits.add(new BaseRawCalorimeterHit(id, amplitude, timestamp)); + } + return hits; + } + + private static void makeEcalPlots(AIDA aida, List<RawCalorimeterHit> hits) { + aida.cloud1D("Number of Hits").fill(hits.size()); + for (RawCalorimeterHit hit : hits) { + aida.cloud1D("Timestamp").fill(hit.getTimeStamp()); + aida.cloud1D("Amplitude").fill(hit.getAmplitude()); + } + } + + static class ConnectionParameters { + String etName; // x + String host; // x + int port; // x + boolean nonBlocking; + String stationName; + int neventsPerArray; + int queueSize; + int stationPos; + int stationParallelPos; + } + + 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; JButton saveButton; JButton quitButton;
+ JTextField eventCounter; + JTextField elapsedTime; + JTextField eventRate; + JTextField host; + JTextField port; + JTextField avgEventRate; + DecimalFormat rateFormat = new DecimalFormat("#.##");
EvioConsumerGui() {
+ + setLayout(new GridBagLayout()); + + GridBagConstraints c = new GridBagConstraints();
+ // Panel for labels and values. + c.gridx = 0; + c.gridy = 0; + JPanel fieldsPanel = new JPanel(); + fieldsPanel.setLayout(new GridBagLayout()); + add(fieldsPanel, c); + + // Panel for control buttons. + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 1; + JPanel buttonsPanel = new JPanel(); + buttonsPanel.setLayout(new GridBagLayout()); + add(buttonsPanel, c); + + /* + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 0; + c.anchor = GridBagConstraints.WEST; + JLabel hostLabel = new JLabel("Host:"); + hostLabel.setHorizontalAlignment(JLabel.LEFT); + fieldsPanel.add(hostLabel, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 0; + c.anchor = GridBagConstraints.EAST; + host = new JTextField("", 20); + host.setHorizontalAlignment(JTextField.RIGHT); + host.setEditable(false); + host.setBackground(Color.WHITE); + fieldsPanel.add(host, c); + + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 1; + c.anchor = GridBagConstraints.WEST; + JLabel portLabel = new JLabel("Port:"); + portLabel.setHorizontalAlignment(JLabel.LEFT); + fieldsPanel.add(portLabel, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 1; + c.anchor = GridBagConstraints.EAST; + port = new JTextField("", 6); + port.setHorizontalAlignment(JTextField.RIGHT); + port.setEditable(false); + port.setBackground(Color.WHITE); + fieldsPanel.add(port, c); + */ + + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 0; + c.anchor = GridBagConstraints.WEST; + JLabel eventLabel = new JLabel("Events Processed: "); + eventLabel.setHorizontalAlignment(JLabel.LEFT); + fieldsPanel.add(eventLabel, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 0; + c.anchor = GridBagConstraints.EAST; + eventCounter = new JTextField("0", 6); + eventCounter.setHorizontalAlignment(JTextField.RIGHT); + eventCounter.setEditable(false); + eventCounter.setBackground(Color.WHITE); + fieldsPanel.add(eventCounter, c); + + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 1; + c.anchor = GridBagConstraints.WEST; + JLabel timeLabel = new JLabel("Elapsed Time [ms]:"); + timeLabel.setHorizontalAlignment(JLabel.LEFT); + fieldsPanel.add(timeLabel, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 1; + c.anchor = GridBagConstraints.EAST; + elapsedTime = new JTextField("0", 10); + elapsedTime.setHorizontalAlignment(JTextField.RIGHT); + elapsedTime.setEditable(false); + elapsedTime.setBackground(Color.WHITE); + fieldsPanel.add(elapsedTime, c); + + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 2; + c.anchor = GridBagConstraints.WEST; + JLabel rateLabel = new JLabel("Event Rate [Hz]:"); + rateLabel.setHorizontalAlignment(JLabel.LEFT); + fieldsPanel.add(rateLabel, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 2; + c.anchor = GridBagConstraints.EAST; + eventRate = new JTextField("0", 4); + eventRate.setHorizontalAlignment(JTextField.RIGHT); + eventRate.setEditable(false); + eventRate.setBackground(Color.WHITE); + fieldsPanel.add(eventRate, c); + + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 3; + c.anchor = GridBagConstraints.WEST; + JLabel avgRateLabel = new JLabel("Average Event Rate [Hz]:"); + avgRateLabel.setHorizontalAlignment(JLabel.LEFT); + fieldsPanel.add(avgRateLabel, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 3; + c.anchor = GridBagConstraints.EAST; + avgEventRate = new JTextField("0", 6); + avgEventRate.setHorizontalAlignment(JTextField.RIGHT); + avgEventRate.setEditable(false); + avgEventRate.setBackground(Color.WHITE); + fieldsPanel.add(avgEventRate, c); + + // Button padding. + Insets buttonInsets = new Insets(1, 1, 1, 1); + + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 0; + c.fill = GridBagConstraints.BOTH; + c.insets = buttonInsets;
resetButton = new JButton("Reset"); resetButton.setActionCommand("reset"); resetButton.addActionListener(this); resetButton.setToolTipText("Reset the plots.");
- add(resetButton); -
+ buttonsPanel.add(resetButton, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 0; + c.fill = GridBagConstraints.BOTH; + c.insets = buttonInsets;
saveButton = new JButton("Save Plots"); saveButton.setActionCommand("save"); saveButton.addActionListener(this); saveButton.setToolTipText("Save the plots to an AIDA file.");
- add(saveButton);
+ buttonsPanel.add(saveButton, c);
+ c = new GridBagConstraints(); + c.gridx = 2; + c.gridy = 0; + c.fill = GridBagConstraints.BOTH; + c.insets = buttonInsets;
quitButton = new JButton("Quit"); quitButton.setActionCommand("quit"); quitButton.addActionListener(this); quitButton.setToolTipText("Quit the job.");
- add(quitButton);
+ buttonsPanel.add(quitButton, c);
}
+ public void incrEventCount() { + int e = Integer.parseInt(eventCounter.getText()); + e += 1; + eventCounter.setText(Integer.toString(e)); + } + + /* + + public void setHost(String host) { + this.host.setText(host); + } + + public void setPort(int port) { + this.port.setText(Integer.toString(port)); + } + */ + + public void setElapsedTime(long time) { + elapsedTime.setText(Long.toString(time)); + } + + public void setEventRate(double rate) { + eventRate.setText(rateFormat.format(rate)); + } + + public void setAverageEventRate(double rate) { + avgEventRate.setText(rateFormat.format(rate)); + } + + public void resetEventCount() { + eventCounter.setText("0"); + } + + public void resetTimer() { + jobStartTime = System.currentTimeMillis(); + } +
public static void createAndShow() { JFrame frame = new JFrame("EvioConsumer GUI"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- EvioConsumerGui gui = new EvioConsumerGui();
+ gui = new EvioConsumerGui();
gui.setOpaque(true); frame.setContentPane(gui);
@@ -655,7 +1067,11 @@
plotters.clear(); clearAidaTree();
- setupPlots();
+ setupPlots(); + resetEventCount(); + resetTimer(); + + eventCount = 0;
} private void save() {
@@ -678,7 +1094,7 @@
private void quit() { System.exit(0); }
-
+
public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() {
diff -N MCRawDataToEvio4Converter_Test.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ MCRawDataToEvio4Converter_Test.java 21 Mar 2012 20:19:13 -0000 1.1 @@ -0,0 +1,51 @@
+package org.lcsim.hps.evio; + +import java.io.File; + +import org.jlab.coda.jevio.BaseStructure; +import org.jlab.coda.jevio.CompositeData; +import org.jlab.coda.jevio.EvioEvent; +import org.jlab.coda.jevio.EvioReader; +import org.jlab.coda.jevio.test.CompositeTester; +import org.lcsim.util.loop.LCSimLoop; + +public class MCRawDataToEvio4Converter_Test { + + String fileName = "/u1/hps/trackerTest/ap2.2gev050mevsel_SLIC-v2r11p1_geant4-v9r3p2_QGSP_BERT_HPS-Test-JLAB-v4pt0_rawData.slcio"; + + public void testRawDataCnv() throws Exception { + File lcioFile = new File(fileName); + LCSimLoop loop = new LCSimLoop(); + loop.setLCIORecordSource(lcioFile); + MCRawDataToEvio4Converter driver = new MCRawDataToEvio4Converter(); + loop.add(driver); + loop.loop(-1, null); + loop.dispose(); + + /* + File evioFile = new File("MCRawData.evio"); + EvioReader reader = new EvioReader(evioFile); + EvioEvent event = reader.parseNextEvent(); + while (true) { + System.out.println("read event " + event.getHeader().getNumber()); + if (reader.getNumEventsRemaining() == 0) { + break; + } + event = reader.parseNextEvent(); + + for (BaseStructure bank : event.getChildren() ) { + System.out.println("read bank w/ tag = " + bank.getHeader().getTag() + "; number = " + bank.getHeader().getNumber()); + if (bank.getHeader().getNumber() == 1) { + System.out.println("read tracker bank"); + } + else if (bank.getHeader().getNumber() == 2) { + System.out.println("read ecal bank"); + } + CompositeData cdata = bank.getCompositeData(); + CompositeTester.printCompositeDataObject(cdata); + } + } + */ + } + +}
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