Commit in hps-java/src on MAIN
main/java/org/lcsim/hps/evio/TestRunReconToEvio.java+281added 1.1
                            /MCRawDataToEvio4Converter2.java-2541.2 removed
main/java/org/lcsim/hps/monitoring/MonitoringApplicationMain.java+132added 1.1
                                  /ConnectionPanel.java+34-21.8 -> 1.9
                                  /ConnectionParameters.java+11-111.6 -> 1.7
                                  /EtConnection.java+51.2 -> 1.3
                                  /MonitoringApplication.java+7-51.4 -> 1.5
                                  /MonitoringExample.java+1-11.4 -> 1.5
main/resources/org/lcsim/hps/steering/HPSTestRunReconToEvio.lcsim+12-31.1 -> 1.2
test/java/org/lcsim/hps/evio/TestRunReconToEvio_Test.java+146added 1.1
test/java/org/lcsim/hps/recon/tracking/SVTDAQIO_Test.java-871.3 removed
+629-363
3 added + 2 removed + 6 modified, total 11 files
end of day check in; moved some files around and renamed; working version (yes it works) of test recon to EVIO

hps-java/src/main/java/org/lcsim/hps/evio
TestRunReconToEvio.java added at 1.1
diff -N TestRunReconToEvio.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TestRunReconToEvio.java	29 Mar 2012 03:52:57 -0000	1.1
@@ -0,0 +1,281 @@
+package org.lcsim.hps.evio;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jlab.coda.jevio.BaseStructure;
+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.EventHeader.LCMetaData;
+import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.hps.recon.tracking.HPSSVTData;
+import org.lcsim.util.Driver;
+
+/**
+ * 
+ * See MCRawDataToEvio4Converter2.  This version is for writing
+ * EVIO output that is the same as the format that will come
+ * off of the test run ET ring.  (not done yet!)
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class TestRunReconToEvio extends Driver {
+        
+    // These correspond to ROC (readout crate) IDs from the DAQ system.
+    public static final int ecalTopBankTag = 0x1;
+    public static final int ecalBottomBankTag = 0x2;
+    public static final int trackerBankTag = 0x3;
+        
+    public static final int trackerBankNumber = 1;
+    public static final int ecalBankNumber = 2;
+    
+    final String ecalFormatString = "c,i,l,N(c,N(s,i))";    
+    final int ecalChannelOffset = 23;    
+    final int ecalPulseIntegralTag = 0xe103;
+    
+    String evioOutputFile = "MCRawData.evio";
+    EventWriter writer;
+    
+    String rawCalorimeterHitCollectionName = "EcalDigitizedHits";
+    String svtCollectionName = "SVTData";
+    
+    EventBuilder builder = null;    
+              
+    private int eventsWritten = 0;
+    
+    boolean debug = false;
+    
+    public TestRunReconToEvio() 
+    {}
+    
+    public void setDebug(boolean debug) {
+    	this.debug = debug;
+    }
+    
+    public void setEvioOutputFile(String evioOutputFile) {
+        this.evioOutputFile = evioOutputFile;
+    }
+        
+    public void setSVTDataCollectionName(String svtCollectionName) {
+    	this.svtCollectionName = svtCollectionName;
+    }
+    
+    public void setRawCalorimeterHitCollectionName(String rawCalorimeterHitCollectionName) {
+        this.rawCalorimeterHitCollectionName = rawCalorimeterHitCollectionName;
+    }
+    
+    protected void startOfData() {
+        try {
+            writer = new EventWriter(evioOutputFile);
+        }
+        catch (EvioException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    protected void endOfData() {
+        System.out.println(this.getClass().getSimpleName() + " - wrote " + eventsWritten + " EVIO events in job.");
+        try {
+            writer.close();
+        } catch (EvioException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+        
+    protected void process(EventHeader event) {
+        
+        // Make a new EVIO event.
+        builder = new EventBuilder(0, DataType.BANK, event.getEventNumber());
+                
+        // Write SVTData.
+        writeSVTData(event);        
+        
+        // Write RawCalorimeterHit collection.
+        writeRawCalorimeterHits(event);        
+        
+        // Write this EVIO event.
+        writeEvioEvent();
+    }
+
+	private void writeEvioEvent() {
+		builder.setAllHeaderLengths();
+        try {
+            writer.writeEvent(builder.getEvent());
+            ++eventsWritten;
+        } catch (EvioException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+	}
+
+	private void writeRawCalorimeterHits(EventHeader event) {
+		List<RawCalorimeterHit> rawCalorimeterHits = event.get(RawCalorimeterHit.class, rawCalorimeterHitCollectionName); 
+        LCMetaData meta = event.getMetaData(rawCalorimeterHits);
+        writeRawCalorimeterHits(meta, rawCalorimeterHits, builder);        
+	}
+
+	private void writeSVTData(EventHeader event) {
+		List<List<HPSSVTData>> svtDataList = event.get(HPSSVTData.class);
+        if (svtDataList != null) {
+        	if (svtDataList.size() > 0) {
+        		if (svtDataList.get(0) != null) {
+        			this.writeSVTData(svtDataList.get(0));
+        		} else {
+        			System.out.println("No HPSSVTData in event!");
+        		}
+        	}
+        } else {
+        	System.out.println("No lists with type HPSSVTData.class in event!");
+        }
+	}
+	
+    private void writeSVTData(List<HPSSVTData> data) {
+    	if (data == null) {
+    		throw new RuntimeException("The list points to null.");
+    	}
+    	
+    	int nsamples = data.size();
+    	int evioIntData[] = new int[nsamples*4];
+    	
+    	int i = 0;
+    	for (HPSSVTData sample : data) {
+    		int[] sampleData = sample.getData();
+    		//System.out.println(Integer.toHexString(sampleData[0]) + ":" + Integer.toHexString(sampleData[1])+ ":" + Integer.toHexString(sampleData[2])+ ":" + Integer.toHexString(sampleData[3]));
+    		evioIntData[i] = sampleData[0];
+    		evioIntData[i+1] = sampleData[1];
+    		evioIntData[i+2] = sampleData[2];
+    		evioIntData[i+3] = sampleData[3];
+    		i += 4;    		
+    	}    	    
+    	EvioBank bank = new EvioBank(trackerBankTag, DataType.UINT32, trackerBankNumber);
+    	try {
+    		bank.appendIntData(evioIntData);
+    	} catch (EvioException e) {
+    		throw new RuntimeException(e);
+    	}
+    	bank.setAllHeaderLengths();
+        try {
+            builder.addChild(builder.getEvent(), bank);
+        } catch (EvioException e) {
+            throw new RuntimeException(e);
+        }
+    }          
+
+    private void writeRawCalorimeterHitCollection(List<RawCalorimeterHit> hits, LCMetaData meta, int bankTag, EventBuilder builder) {
+    	
+    	// Get the ID decoder.
+    	IDDecoder dec = meta.getIDDecoder();
+    	
+    	// Make a hit map.
+    	Map<Long,RawCalorimeterHit> hitMap = new HashMap<Long,RawCalorimeterHit>();
+    	for (RawCalorimeterHit hit : hits) {
+    		hitMap.put(hit.getCellID(), hit);
+    	}
+    	
+    	// Make map of slot number to IDs.
+    	Map<Integer,List<Long>> slotMap = new HashMap<Integer,List<Long>>();
+    	for (Long id : hitMap.keySet()) {
+    		dec.setID(id);
+    		int iy = dec.getValue("iy"); // treating as slot number    		
+    		int slot = Math.abs(iy);    		
+    		if (slotMap.get(slot) == null) {
+    			slotMap.put(slot, new ArrayList<Long>());
+    		}
+    		List<Long> slots = slotMap.get(slot);    		
+    		slots.add(id);    		
+    	}
+    	
+    	EvioBank crateBank = new EvioBank(bankTag, DataType.BANK, ecalBankNumber);
+    	    	    	
+    	for (int slot : slotMap.keySet()) {
+    		
+    		//System.out.println("making evio data for slot " + slot);
+    		
+    		// New bank for this slot.
+    		EvioBank slotBank = new EvioBank(ecalPulseIntegralTag, DataType.COMPOSITE, slot);
+    		
+    		// "c,i,l,N(c,N(s,i))
+    		
+    		// Create composite data for slot.
+    		CompositeData.Data data = new CompositeData.Data();    		
+    		data.addUchar((byte)slot); // slot #
+    		data.addUint(0); // trigger #
+    		data.addUlong(0); // timestamp    		
+    		List<Long> hitIDs = slotMap.get(slot);
+    		int nhits = hitIDs.size();    		
+    		data.addN(nhits); // number of channels
+    		for (Long id : hitIDs) {
+    			dec.setID(id);
+    			int ix = dec.getValue("ix");
+    			int channel = ix + ecalChannelOffset;
+    			data.addUchar((byte)channel); // channel #
+    			data.addN(1); // number of pulses
+    			RawCalorimeterHit hit = hitMap.get(id);
+    			data.addUshort((short)hit.getTimeStamp()); // pulse time
+    			data.addUint((int)hit.getAmplitude()); // pulse integral
+    		}    		  
+    		    		
+    		// Add CompositeData to bank.
+    		CompositeData cdata = null;
+            try {            	            
+                cdata = new CompositeData(ecalFormatString, 1, data, ecalPulseIntegralTag, slot);
+                slotBank.appendCompositeData(cdata);
+            }
+            catch (EvioException e) {
+                throw new RuntimeException(e);
+            }                        
+    		
+            // Add slot bank to crate bank.
+        	slotBank.setAllHeaderLengths();
+        	try {
+        		builder.addChild(crateBank, slotBank);
+            } catch (EvioException e) {
+                throw new RuntimeException(e);
+            }    	    
+    	}    	
+    	try {
+    		crateBank.setAllHeaderLengths();
+            builder.addChild(builder.getEvent(), crateBank);
+        } catch (EvioException e) {
+            throw new RuntimeException(e);
+        }    	    
+    }
+    
+    private void writeRawCalorimeterHits(LCMetaData meta, List<RawCalorimeterHit> rawCalorimeterHits, EventBuilder builder) {        
+
+    	// Make two lists containing the hits from top and bottom sections, which go into separate EVIO data banks.
+        IDDecoder dec = meta.getIDDecoder();
+        List<RawCalorimeterHit> topHits = new ArrayList<RawCalorimeterHit>();
+        List<RawCalorimeterHit> bottomHits = new ArrayList<RawCalorimeterHit>();        
+        for (RawCalorimeterHit hit : rawCalorimeterHits) {
+            dec.setID(hit.getCellID());
+            int iy = dec.getValue("iy");
+            // Negative iy should be bottom section.
+            if (iy < 0) {
+                bottomHits.add(hit);
+            }
+            // Positive iy should be top section.
+            else {
+                topHits.add(hit);
+            }
+        }
+        
+        // Write the two collections for top and bottom hits to separate EVIO banks.
+        writeRawCalorimeterHitCollection(topHits, meta, ecalTopBankTag, builder);
+        writeRawCalorimeterHitCollection(bottomHits, meta, ecalBottomBankTag, builder);
+    }      
+   
+}
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/evio
MCRawDataToEvio4Converter2.java removed after 1.2
diff -N MCRawDataToEvio4Converter2.java
--- MCRawDataToEvio4Converter2.java	28 Mar 2012 18:42:33 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,254 +0,0 @@
-package org.lcsim.hps.evio;
-
-import java.io.IOException;
-import java.util.ArrayList;
-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.EventHeader.LCMetaData;
-import org.lcsim.event.RawCalorimeterHit;
-import org.lcsim.event.RawTrackerHit;
-import org.lcsim.geometry.IDDecoder;
-import org.lcsim.hps.recon.tracking.HPSSVTData;
-import org.lcsim.util.Driver;
-
-/**
- * 
- * See MCRawDataToEvio4Converter2.  This version is for writing
- * EVIO output that is the same as the format that will come
- * off of the test run ET ring.  (not done yet!)
- * 
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class MCRawDataToEvio4Converter2 extends Driver {
-        
-    // These correspond to ROC (readout crate) IDs from the DAQ system.
-    public static final int ecalTopBankTag = 0x1;
-    public static final int ecalBottomBankTag = 0x2;
-    public static final int trackerBankTag = 0x3;
-        
-    // CompositeData formats.
-    public static final String trackerFormat = "N(L,I,I)";
-    public static final String ecalFormat = "N(L,I,I)";
-    
-    //public static final int ecalBankTag = 0xe103;
-    public static final int trackerBankNumber = 1;
-    public static final int ecalBankNumber = 2;
-    
-    String evioOutputFile = "MCRawData.evio";
-    EventWriter writer;
-    
-    String rawTrackerHitCollectionName = "RawTrackerHitMaker_RawTrackerHits";
-    String rawCalorimeterHitCollectionName = "EcalRawHits";    
-    String svtCollectionName = "SVTData";
-    
-    EventBuilder builder = null;
-
-    private int eventsWritten = 0;
-    
-    public MCRawDataToEvio4Converter2() 
-    {}
-    
-    public void setEvioOutputFile(String evioOutputFile) {
-        this.evioOutputFile = evioOutputFile;
-    }
-    
-    public void setRawTrackerHitCollectionName(String rawTrackerHitCollectionName) {
-        this.rawTrackerHitCollectionName = rawTrackerHitCollectionName;
-    }
-    
-    public void setSVTDataCollectionName(String svtCollectionName) {
-    	this.svtCollectionName = svtCollectionName;
-    }
-    
-    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() {
-        System.out.println("wrote " + eventsWritten + " events");
-        try {
-            writer.close();
-        } catch (EvioException e) {
-            throw new RuntimeException(e);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-        
-    public void process(EventHeader event) {
-        
-        // Make a new EVIO event.
-        builder = new EventBuilder(0, DataType.BANK, event.getEventNumber());
-        
-        // Write RawTrackerHit collection.
-        // TODO Check for null.
-        //writeRawTrackerHits(event.get(RawTrackerHit.class, rawTrackerHitCollectionName), builder);
-        
-        // Write SVTData.
-        List<List<HPSSVTData>> svtDataList = event.get(HPSSVTData.class);
-        if (svtDataList != null) {
-        	if (svtDataList.size() > 0) {
-        		if (svtDataList.get(0) != null) {
-        			this.writeSVTData(svtDataList.get(0));
-        		} else {
-        			System.out.println("No HPSSVTData in event!");
-        		}
-        	}
-        } else {
-        	System.out.println("No lists with type HPSSVTData.class in event!");
-        }
-        
-        // Write RawCalorimeterHit collection.
-        List<RawCalorimeterHit> rawCalorimeterHits = event.get(RawCalorimeterHit.class, rawCalorimeterHitCollectionName); 
-        LCMetaData meta = event.getMetaData(rawCalorimeterHits);
-        writeRawCalorimeterHits(meta, rawCalorimeterHits, builder);
-        
-        // Write this EVIO event.
-        builder.setAllHeaderLengths();
-        try {
-            writer.writeEvent(builder.getEvent());
-            ++eventsWritten;
-        } 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();
-        
-        //System.out.println("writeRawTrackerHits will write " + dataSize + " hits");
-                                             
-        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 writeRawCalorimeterHitCollection(List<RawCalorimeterHit> hits, int bankTag, EventBuilder builder) {
-        CompositeData.Data data = new CompositeData.Data();
-        int nTopHits = hits.size();
-        data.addN(nTopHits);
-        for (RawCalorimeterHit hit : hits) {
-            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(bankTag, 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);
-        }
-    }
-    
-    public void writeRawCalorimeterHits(LCMetaData meta, List<RawCalorimeterHit> rawCalorimeterHits, EventBuilder builder) {
-        
-        // Make two lists containing the hits from top and bottom sections, which go into separate EVIO data banks.
-        IDDecoder dec = meta.getIDDecoder();
-        List<RawCalorimeterHit> topHits = new ArrayList<RawCalorimeterHit>();
-        List<RawCalorimeterHit> bottomHits = new ArrayList<RawCalorimeterHit>();        
-        for (RawCalorimeterHit hit : rawCalorimeterHits) {
-            dec.setID(hit.getCellID());
-            int iy = dec.getValue("iy");
-            // Negative iy should be bottom section.
-            if (iy < 0) {
-                bottomHits.add(hit);
-            }
-            // Positive iy should be top section.
-            else {
-                topHits.add(hit);
-            }
-        }
-        
-        // Write the two collections for top and bottom hits to separate EVIO banks.
-        writeRawCalorimeterHitCollection(topHits, ecalTopBankTag, builder);
-        writeRawCalorimeterHitCollection(bottomHits, ecalBottomBankTag, builder);        
-    }      
-    
-    public void writeSVTData(List<HPSSVTData> data) {
-    	if (data == null) {
-    		throw new RuntimeException("The list points to null.");
-    	}
-    	
-    	int nsamples = data.size();
-    	int evioIntData[] = new int[nsamples*4];
-    	
-    	int i = 0;
-    	for (HPSSVTData sample : data) {
-    		int[] sampleData = sample.getData();
-    		//System.out.println(Integer.toHexString(sampleData[0]) + ":" + Integer.toHexString(sampleData[1])+ ":" + Integer.toHexString(sampleData[2])+ ":" + Integer.toHexString(sampleData[3]));
-    		evioIntData[i] = sampleData[0];
-    		evioIntData[i+1] = sampleData[1];
-    		evioIntData[i+2] = sampleData[2];
-    		evioIntData[i+3] = sampleData[3];
-    		i += 4;    		
-    	}    	
-    	
-    	EvioBank bank = new EvioBank(trackerBankTag, DataType.INT32, trackerBankNumber);
-    	try {
-    		bank.appendIntData(evioIntData);
-    	} 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

hps-java/src/main/java/org/lcsim/hps/monitoring
MonitoringApplicationMain.java added at 1.1
diff -N MonitoringApplicationMain.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MonitoringApplicationMain.java	29 Mar 2012 03:52:57 -0000	1.1
@@ -0,0 +1,132 @@
+package org.lcsim.hps.monitoring;
+
+import java.nio.ByteBuffer;
+
+import javax.swing.SwingUtilities;
+
+import org.jlab.coda.et.EtAttachment;
+import org.jlab.coda.et.EtEvent;
+import org.jlab.coda.et.EtSystem;
+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.EvioEvent;
+import org.jlab.coda.jevio.EvioReader;
+import org.lcsim.hps.monitoring.ConnectionStatusPanel.ConnectionStatus;
+
+/**
+ * This runs the {@link MonitoringApplication} without any LCSim binding. 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class MonitoringApplicationMain {
+                               
+    public MonitoringApplicationMain() 
+    {}
+    
+    public static void main(String [] args) {
+        MonitoringApplicationMain app = new MonitoringApplicationMain();
+        app.run();        
+    }
+                
+    public void run()
+    {        	
+    	// Start the GUI.
+    	final MonitoringApplication gui = new MonitoringApplication();
+		SwingUtilities.invokeLater(new Runnable() {
+			public void run() {
+				gui.start();
+			}
+		});
+    	    	
+    	// Get ConnectionPanel which can be used to connect/disconnect from ET system.
+		ConnectionPanel connectionPanel = gui.getConnectionPanel();
+    	
+    	// GUI loop.  Use 'Exit' command from GUI to quit.
+    	while (true) {
+
+    		// Wait for connection request from GUI.
+    		while (!connectionPanel.connectRequested()) {
+    			try { Thread.sleep(1000); } catch (InterruptedException e)  {};
+    		}        
+    		ConnectionParameters cn = connectionPanel.getConnectionParameters();
+    		    		
+    		// This makes sure applicable menu items are enabled/disabled.
+    		gui.connect();
+    		gui.getConnectionStatusPanel().setStatus(ConnectionStatus.CONNECTING);
+
+    		// Try block is mostly for EtExceptions and friends.
+    		try {        	
+
+    			// Setup connection to ET system.
+    			EtConnection et = EtConnection.makeEtConnection(cn);
+    			EtSystem sys = et.getEtSystem();
+    			EtAttachment att = et.getEtAttachment();   
+
+    			// Start job timer.
+    			EventPanel eventPanel = gui.getEventPanel();
+    			eventPanel.updateJobStartTime();
+
+    			// array of events
+    			EtEvent[] mevs = null;
+    			
+    			Mode waitMode = cn.waitMode;
+    			int waitTime = cn.waitTime;
+    			int chunk = cn.chunk;
+    			    			
+    			gui.getConnectionStatusPanel().setStatus(ConnectionStatus.CONNECTED);
+
+    			// EtEvent loop.
+    			while (true) { 
+    				try {           
+    					// Get EtEvents.
+    					mevs = sys.getEvents(att, waitMode, Modify.NOTHING, waitTime, chunk);
+
+    					// Loop over retrieved EtEvents.
+    					for (EtEvent mev : mevs) {
+
+    						// Update GUI's event count.
+    						eventPanel.updateEventCount();                    
+
+    						// Get EvioEvent and check for errors.
+    						ByteBuffer buf = mev.getDataBuffer();
+    						EvioReader reader = new EvioReader(buf);
+    						EvioEvent evioEvent = null;
+    						try {
+    							evioEvent = reader.parseNextEvent();
+    						} catch (java.nio.BufferUnderflowException e) {
+    							// Error will be caught by subsequent check on null event.
+    						}
+    						if (evioEvent == null) {
+    							eventPanel.updateBadEventCount();
+    							continue;
+    						}
+
+    						// Update the average event rate.
+    						eventPanel.updateAverageEventRate();                    
+
+    						// Update elapsed time.
+    						eventPanel.updateElapsedTime();
+    					}
+
+    					// Put events back into the ET system.
+    					sys.putEvents(att, mevs);   
+    					
+    					// Break out of event loop if GUI wants disconnect. 
+    					if (connectionPanel.disconnectRequested()) {
+    						gui.getConnectionStatusPanel().setStatus(ConnectionStatus.DISCONNECTING); 
+    						gui.disconnect();
+    						break;
+    					}
+    				// Session timed out.
+    				} catch (EtTimeoutException e) {
+    					gui.getConnectionStatusPanel().setStatus(ConnectionStatus.TIMED_OUT);
+    					break;
+    				}
+    			}
+    		} catch (Exception ex) {
+    			System.out.println("Error using ET system as consumer.");
+    			ex.printStackTrace();
+    		}
+    	}      
+    }
+}
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/monitoring
ConnectionPanel.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- ConnectionPanel.java	27 Mar 2012 20:31:49 -0000	1.8
+++ ConnectionPanel.java	29 Mar 2012 03:52:57 -0000	1.9
@@ -43,6 +43,7 @@
     private JTextField ppositionField;
     private JComboBox waitComboBox; 
     private JTextField waitTimeField;
+    private JTextField prescaleField;
                     
     private ConnectionParameters connectionParameters;
         
@@ -253,6 +254,23 @@
         waitTimeField.setHorizontalAlignment(JLabel.RIGHT);
         add(waitTimeField, c);
         
+        c = new GridBagConstraints();
+        c.gridx = 0;
+        c.gridy = 12;
+        c.anchor = GridBagConstraints.WEST;
+        JLabel prescaleLabel = new JLabel("Prescale:");
+        prescaleLabel.setHorizontalAlignment(JLabel.LEFT);
+        add(prescaleLabel, c);
+        
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 12;
+        c.anchor = GridBagConstraints.EAST;
+        prescaleField = new JTextField(8);
+        prescaleField.setBackground(Color.WHITE);
+        prescaleField.setHorizontalAlignment(JLabel.RIGHT);
+        add(prescaleField, c);
+        
         // Set default connection parameters which are pushed to GUI.
         setConnectionParameters(new ConnectionParameters());
     }
@@ -271,14 +289,22 @@
         connectionParameters.pposition = Integer.parseInt(ppositionField.getText());
         connectionParameters.waitMode = getWaitMode();
         connectionParameters.waitTime = Integer.parseInt(waitTimeField.getText());
+        connectionParameters.prescale = Integer.parseInt(prescaleField.getText());
         return connectionParameters;
     }
     
     private Mode getWaitMode() {
-    	Mode mode = Mode.SLEEP;
+    	Mode mode = null;
     	String sel = (String)waitComboBox.getSelectedItem();
-    	if ("wait".equals(sel.toLowerCase())) {
+    	if ("wait".equalsIgnoreCase(sel)) {
     		mode = Mode.TIMED;
+    	} else if ("async".equalsIgnoreCase(sel)) {
+    		mode = Mode.ASYNC;
+    	} else if ("sleep".equalsIgnoreCase(sel)) {
+    		mode = Mode.SLEEP;
+    	// Values are constrained by combo box so shouldn't happen but check anyways.
+    	} else {
+    		throw new RuntimeException("Invalid wait mode.");
     	}
     	return mode;
     }
@@ -306,6 +332,7 @@
         ppositionField.setText(Integer.toString(cn.pposition));
         setWaitMode(cn.waitMode);
         waitTimeField.setText(Integer.toString(cn.waitTime));
+        prescaleField.setText(Integer.toString(cn.prescale));
     	this.connectionParameters = cn;
     }
                 
@@ -334,6 +361,7 @@
         ppositionField.setEnabled(e);
         waitComboBox.setEnabled(e);
         waitTimeField.setEnabled(e);
+        prescaleField.setEnabled(e);
     }
     
     boolean connectRequested() {
@@ -384,6 +412,7 @@
                 
     private void writePropertiesFile(File file) {
     	Properties prop = new Properties();
+    	prop.setProperty("etName", etNameField.getText());
     	prop.setProperty("host", hostField.getText());
     	prop.setProperty("port", portField.getText());
     	prop.setProperty("blocking", blockingField.getText());
@@ -395,6 +424,7 @@
     	prop.setProperty("pposition", ppositionField.getText());
     	prop.setProperty("waitMode", (String)waitComboBox.getSelectedItem());
     	prop.setProperty("waitTime", waitTimeField.getText());
+    	prop.setProperty("prescale", prescaleField.getText());
     	try {
     		prop.store(new FileOutputStream(file), null);
     	} catch (Exception e) {
@@ -420,6 +450,7 @@
     	Properties prop = new Properties();
     	try {
     		prop.load(new FileInputStream(file));
+    		etNameField.setText(prop.getProperty("etName"));
     		hostField.setText(prop.getProperty("host"));
     		portField.setText(prop.getProperty("port"));
     		blockingField.setText(prop.getProperty("blocking"));
@@ -431,6 +462,7 @@
     		ppositionField.setText(prop.getProperty("pposition"));
     		setWaitMode(prop.getProperty("waitMode"));    		
     		waitTimeField.setText(prop.getProperty("waitTime"));
+    		prescaleField.setText(prop.getProperty("prescale"));
     	} catch (FileNotFoundException e) {
     		showErrorDialog(e.getLocalizedMessage());
     	} catch (IOException e) {

hps-java/src/main/java/org/lcsim/hps/monitoring
ConnectionParameters.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- ConnectionParameters.java	27 Mar 2012 05:02:37 -0000	1.6
+++ ConnectionParameters.java	29 Mar 2012 03:52:57 -0000	1.7
@@ -25,14 +25,10 @@
     public int flowMode = EtConstants.stationSerial;
     public Mode waitMode = Mode.SLEEP; // sleep, timed or async
     public int waitTime = 20000000; // wait time in microseconds
-    
-    public enum WaitMode {
-    	SLEEP,
-    	WAIT
-    }
-               
+    public int prescale = 1;
+                   
     public ConnectionParameters() {
-        // Set the default host.
+        // Set the default host to this machine.
         try {
             InetAddress addr = InetAddress.getLocalHost();
             host = addr.getHostName();
@@ -56,11 +52,11 @@
                 "       -q     queue size if creating nonblocking station\n" +
                 "       -pos   position of created station in station list (1,2,...)\n" +
                 "       -ppos  position of created station within a group of parallel stations (-1=end, -2=head)\n" +
-                "       -a     run in async mode which needs immediate connection (no wait)\n" +
+                "       -a     run in async mode which looks for immediate connection to ET system\n" +
                 "       -t     time to wait for events before timing out\n\n" +
+                "       -e     set event prescaling where argument is every N events to read\n" +
                 "        This consumer works by making a direct connection\n" +
                 "        to the ET system's tcp server port.\n");
-//      "       -w     wait for events for specified time period in microseconds rather than sleeping" +
     }
     
     public void loadPropertiesFile(File propFile) {    	
@@ -137,8 +133,6 @@
                 } catch (NumberFormatException ex) {
                     throw new ConnectionParametersException("Did not specify a proper parallel position number.");
                 }                
-            } else if (args[i].equalsIgnoreCase("-w")) {
-            	waitMode = Mode.TIMED;
             } else if (args[i].equalsIgnoreCase("-a")) {
             	waitMode = Mode.ASYNC;
             	if (waitTime != 0) {
@@ -151,6 +145,11 @@
             	if (waitTime < 0) {
             		throw new ConnectionParametersException("Invalid wait time specified.");
             	}
+            } else if (args[i].equalsIgnoreCase("-e")) { 
+            	prescale = Integer.parseInt(args[++i]);
+            	if (prescale < 0) {
+            		throw new ConnectionParametersException("Prescale value is invalid.");
+            	}
             } else {
                 throw new ConnectionParametersException("Arguments included invalid command line parameter:" + args[i]);
             }
@@ -182,6 +181,7 @@
     	buf.append("flowMode: " + flowMode + '\n');
     	buf.append("waitMode: " + waitMode + '\n');
     	buf.append("waitTime: " + waitTime + '\n');
+    	buf.append("prescale: " + prescale + '\n');
     	return buf.toString();
     }
 }
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/monitoring
EtConnection.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- EtConnection.java	27 Mar 2012 03:18:21 -0000	1.2
+++ EtConnection.java	29 Mar 2012 03:52:57 -0000	1.3
@@ -46,6 +46,11 @@
 	            statConfig.setCue(cn.qSize);
 	        }
 	    }
+	    // Set prescale.  Only values > 1 are used, as 1 means select every event.  
+	    // Invalid values of 0 or negative numbers are simply ignored.
+	    if (cn.prescale > 1) {
+	    	statConfig.setPrescale(cn.prescale);
+	    }
 
 	    // create station
 	    EtStation stat = sys.createStation(statConfig, cn.statName, cn.position, cn.pposition);

hps-java/src/main/java/org/lcsim/hps/monitoring
MonitoringApplication.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- MonitoringApplication.java	27 Mar 2012 20:31:49 -0000	1.4
+++ MonitoringApplication.java	29 Mar 2012 03:52:57 -0000	1.5
@@ -186,11 +186,13 @@
     }
 	
 	synchronized void resetDrivers() {
-		 for (Driver driver : mgr.getDriverExecList()) {
-			 if (driver instanceof Resettable) {
-				 ((Resettable) driver).reset();
-			 }
-		 }
+		if (mgr != null) {
+			for (Driver driver : mgr.getDriverExecList()) {
+				if (driver instanceof Resettable) {
+					((Resettable) driver).reset();
+				}
+			}
+		}
 	 }
 		
 	public void actionPerformed(ActionEvent e) {

hps-java/src/main/java/org/lcsim/hps/monitoring
MonitoringExample.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- MonitoringExample.java	27 Mar 2012 20:31:49 -0000	1.4
+++ MonitoringExample.java	29 Mar 2012 03:52:57 -0000	1.5
@@ -111,7 +111,7 @@
     			Mode waitMode = cn.waitMode;
     			int waitTime = cn.waitTime;
     			int chunk = cn.chunk;
-    			
+    			    			
     			gui.getConnectionStatusPanel().setStatus(ConnectionStatus.CONNECTED);
 
     			// EtEvent loop.

hps-java/src/main/resources/org/lcsim/hps/steering
HPSTestRunReconToEvio.lcsim 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- HPSTestRunReconToEvio.lcsim	28 Mar 2012 19:00:49 -0000	1.1
+++ HPSTestRunReconToEvio.lcsim	29 Mar 2012 03:52:58 -0000	1.2
@@ -9,10 +9,11 @@
        xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
        
     <inputFiles>
-        <file>${inputFile}.slcio</file>
+        <file>${inputFile}</file>
     </inputFiles>
 
 	<execute>
+	    <driver name="HPSEcalConverterAtoDDriver"/>
 		<driver name="EcalReadout"/>
 		<driver name="EcalConverter"/>
 		<driver name="EcalClusterer"/>
@@ -21,12 +22,20 @@
 		<driver name="SVTDAQMapCreation"/>
 		<driver name="SVTReadout"/>
 		<driver name="ClockDriver"/>
-		<driver name="MCRawDataToEvio4Converter2"/>
+		<driver name="TestRunReconToEvio"/>
 	</execute> 
 
 	<drivers>
 	
-	    <driver name="MCRawDataToEvio4Converter2" type="org.lcsim.hps.evio.MCRawDataToEvio4Converter2"/>
+	    <driver name="HPSEcalConverterAtoDDriver" type="org.lcsim.hps.recon.ecal.HPSEcalConverterAtoDDriver">
+	        <scale>0.0001</scale>
+                <ecalCollectionName>EcalHits</ecalCollectionName>
+                <ecalName>Ecal</ecalName>
+	    </driver>
+	
+	    <driver name="TestRunReconToEvio" type="org.lcsim.hps.evio.TestRunReconToEvio">
+	        <evioOutputFile>${evioFile}</evioOutputFile>
+	    </driver>
 			
 		<driver name="EcalReadout"
                         type="org.lcsim.hps.recon.ecal.HPSEcalFADCReadoutDriver">

hps-java/src/test/java/org/lcsim/hps/evio
TestRunReconToEvio_Test.java added at 1.1
diff -N TestRunReconToEvio_Test.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TestRunReconToEvio_Test.java	29 Mar 2012 03:52:58 -0000	1.1
@@ -0,0 +1,146 @@
+package org.lcsim.hps.evio;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jlab.coda.jevio.BaseStructure;
+import org.jlab.coda.jevio.BaseStructureHeader;
+import org.jlab.coda.jevio.CompositeData;
+import org.jlab.coda.jevio.EvioEvent;
+import org.jlab.coda.jevio.EvioException;
+import org.jlab.coda.jevio.EvioReader;
+import org.lcsim.hps.evio.TestRunReconToEvio;
+import org.lcsim.hps.recon.tracking.HPSTrackerSample;
+import org.lcsim.job.JobControlManager;
+import org.lcsim.util.cache.FileCache;
+
+/**
+ * Run the test run recon and produce an EVIO output file.
+ * WARNING: Only works from SLAC NFS due to accessing local data file.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class TestRunReconToEvio_Test extends TestCase {
+
+	final String lcsimXmlResource = "/org/lcsim/hps/steering/HPSTestRunReconToEvio.lcsim";
+	final String testUrl = "http://www.lcsim.org/test/hps";
+	final String slicFileName = "beam_and_tridents_1_SLIC-v2r11p1_geant4-v9r3p2_QGSP_BERT_HPS-Test-JLAB-v4pt0.slcio";
+	final String evioFileName = "MCRawData.evio";
+
+	public void testIt() throws Exception {
+		
+		// Get some sample events.
+		FileCache cache = new FileCache();
+		cache.setCacheDirectory(new File(".testdata"));
+		File f = cache.getCachedFile(new URL(testUrl + "/" + slicFileName));
+
+		// Create EVIO file.
+		JobControlManager mgr = new JobControlManager();
+		mgr.addVariableDefinition("inputFile", f.getCanonicalPath());
+		mgr.addVariableDefinition("evioFile", evioFileName);
+		mgr.setup(lcsimXmlResource);
+		mgr.run();
+
+		// Dump EVIO file contents.
+		debugPrintEvioEvents();
+	}
+
+	private void debugPrintEvioEvents() throws EvioException {
+		// Read back EVIO file.
+		EvioReader reader = null;
+		try {
+			reader = new EvioReader(evioFileName);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		EvioEvent event = null;
+		event = reader.parseNextEvent();
+		while (event != null) {
+
+			System.out.println("event has " + event.getChildCount() + " children");
+			if (event.getChildren() != null) {
+				for (BaseStructure topBank : event.getChildren()) {				
+					BaseStructureHeader header = topBank.getHeader();
+					if (topBank.getChildren() == null) {
+						System.out.println("subbank has no children");
+					} else {
+						System.out.println("subbank has " + topBank.getChildCount() + " children");
+					}
+					if (header.getTag() == TestRunReconToEvio.trackerBankTag) {		
+						int[] intData = topBank.getIntData();
+						if (intData.length % 4 != 0) {
+							throw new RuntimeException("Size of int array not divisible by 4!");
+						}
+						int n = intData.length;
+						for (int i=0; i<n; i+=4) {
+
+							int[] sampleData = new int[4];
+							sampleData[0] = intData[i];
+							sampleData[1] = intData[i+1];
+							sampleData[2] = intData[i+2];
+							sampleData[3] = intData[i+3];
+
+							HPSTrackerSample trackerSample = new HPSTrackerSample();
+							trackerSample.setData(sampleData);
+
+							int fpga = trackerSample.fpgaAddress();
+							int hybrid = trackerSample.hybrid();
+							int channel = trackerSample.channel();
+							int apv = trackerSample.apv();
+
+							System.out.println("fpga=" + fpga + "; hybrid=" + hybrid + "; channel=" + channel + "; apv=" + apv);
+
+							for (int j=0; j<6; j++) {
+								int val = trackerSample.value(j);
+								System.out.println("  sample[" + j + "]="+val);
+							}										
+						}
+					} else if (header.getTag() == TestRunReconToEvio.ecalTopBankTag || header.getTag() == TestRunReconToEvio.ecalBottomBankTag) {				
+						System.out.println("got ecal bank from event: " + Integer.toHexString(header.getTag()));
+						if (topBank.getChildCount() > 0) {
+							for (BaseStructure slotBank : topBank.getChildren()) {
+								CompositeData cdata = slotBank.getCompositeData();
+								System.out.println("bank.tag="+Integer.toHexString(slotBank.getHeader().getTag()));
+								System.out.println("cdata has " + cdata.getItems().size() + " items");
+								System.out.println("cdata has " + cdata.getTypes().size() + " types");
+								System.out.println("cdata has " + cdata.getNValues().size() + " N values");
+								int n = cdata.getNValues().size();
+								for (int i=0; i<n; i++) {
+									System.out.println("N["+i+"]="+cdata.getNValues().get(i));
+								}
+								int ni = cdata.getItems().size();
+								for (int i=0; i<ni; i++) {
+									System.out.println("type["+i+"]="+cdata.getTypes().get(i));
+								}
+								int slot = cdata.getByte();
+								int trigger = cdata.getInt();
+								long timestamp = cdata.getLong();
+								int nchannels = cdata.getNValue();
+								System.out.println("slot#="+slot+"; trigger="+trigger+"; timestamp="+timestamp+"; nchannels="+nchannels);
+								for (int i=0; i<nchannels; i++) {
+									int channelNumber = cdata.getByte();
+									int npulses = cdata.getNValue();
+									System.out.println("  channel="+channelNumber+"; npulses="+npulses);
+									for (int j=0; j<npulses; j++) {
+										short pulseTime = cdata.getShort();
+										int pulseIntegral = cdata.getInt();								
+										System.out.println("    pulseTime="+pulseTime+"; pulseIntegral="+pulseIntegral);
+									}
+								}							
+							}
+						} else {
+							System.out.println("ecal bank has no children");
+						}
+					}
+				}
+
+				if (reader.getNumEventsRemaining() == 0) {
+					break;
+				}
+				event = reader.parseNextEvent();
+			}
+		}
+	}
+}

hps-java/src/test/java/org/lcsim/hps/recon/tracking
SVTDAQIO_Test.java removed after 1.3
diff -N SVTDAQIO_Test.java
--- SVTDAQIO_Test.java	28 Mar 2012 18:59:09 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-package org.lcsim.hps.recon.tracking;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.jlab.coda.jevio.BaseStructure;
-import org.jlab.coda.jevio.BaseStructureHeader;
-import org.jlab.coda.jevio.EvioEvent;
-import org.jlab.coda.jevio.EvioReader;
-import org.lcsim.hps.evio.MCRawDataToEvio4Converter2;
-import org.lcsim.job.JobControlManager;
-
-/**
- * Run the test run recon and produce an EVIO output file.
- * WARNING: Only works from SLAC NFS due to accessing local data file.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class SVTDAQIO_Test extends TestCase {
-	
-	String lcsimXmlResource = "/org/lcsim/hps/steering/HPSTestRunReconToEvio.lcsim";
-	String slicFile = "/nfs/slac/g/hps/omoreno/event_generation/ap_75MeV_v4pt0.slcio";
-	String evioFile = "TrackerTest.evio";
-	
-	public void testIt() throws Exception {
-		
-		// Create EVIO file.
-		JobControlManager mgr = new JobControlManager();
-		mgr.addVariableDefinition("inputFile", slicFile);
-		mgr.setup(lcsimXmlResource);
-		mgr.run();
-		
-		// Read back EVIO file.
-		EvioReader reader = null;
-		try {
-			reader = new EvioReader(evioFile);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		EvioEvent event = null;
-		event = reader.parseNextEvent();
-		while (event != null) {
-			
-			for (BaseStructure bank : event.getChildren()) {
-				BaseStructureHeader header = bank.getHeader();
-				if (header.getTag() == MCRawDataToEvio4Converter2.trackerBankTag) {									
-					int[] intData = bank.getIntData();
-					if (intData.length % 4 != 0) {
-						throw new RuntimeException("Size of int array not divisible by 4!");
-					}
-					int n = intData.length;
-					for (int i=0; i<n; i+=4) {
-
-						int[] sampleData = new int[4];
-						sampleData[0] = intData[i];
-						sampleData[1] = intData[i+1];
-						sampleData[2] = intData[i+2];
-						sampleData[3] = intData[i+3];
-						
-						HPSTrackerSample trackerSample = new HPSTrackerSample();
-						trackerSample.setData(sampleData);
-
-						int fpga = trackerSample.fpgaAddress();
-						int hybrid = trackerSample.hybrid();
-						int channel = trackerSample.channel();
-						int apv = trackerSample.apv();
-
-						System.out.println("fpga=" + fpga + "; hybrid=" + hybrid + "; channel=" + channel + "; apv=" + apv);
-
-						for (int j=0; j<6; j++) {
-							int val = trackerSample.value(j);
-							System.out.println("  val[" + j + "]="+val);
-						}										
-					}
-				}
-			}
-			
-			
-			if (reader.getNumEventsRemaining() == 0) {
-				break;
-			}
-			event = reader.parseNextEvent();
-		}
-		
-	}
-
-}
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