Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/evio on MAIN
ECalEvioWriter.java+172added 1.1
EvioWriter.java+22added 1.1
SVTEvioWriter.java+77added 1.1
TestRunTriggeredReconToEvio.java+52-2231.3 -> 1.4
+323-223
3 added + 1 modified, total 4 files
broke out EVIO writers into individual classes

hps-java/src/main/java/org/lcsim/hps/evio
ECalEvioWriter.java added at 1.1
diff -N ECalEvioWriter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ECalEvioWriter.java	5 Apr 2012 20:20:28 -0000	1.1
@@ -0,0 +1,172 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.evio;
+
+import org.jlab.coda.jevio.CompositeData;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.jlab.coda.jevio.DataType;
+import org.jlab.coda.jevio.EventBuilder;
+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.geometry.IDDecoder;
+import org.lcsim.hps.recon.ecal.HPSEcalDaqIDConverter;
+
+import static org.lcsim.hps.evio.EventConstants.ECAL_BANK_NUMBER;
+import static org.lcsim.hps.evio.EventConstants.ECAL_BOTTOM_BANK_TAG;
+import static org.lcsim.hps.evio.EventConstants.ECAL_PULSE_INTEGRAL_FORMAT;
+import static org.lcsim.hps.evio.EventConstants.ECAL_PULSE_INTEGRAL_BANK_TAG;
+import static org.lcsim.hps.evio.EventConstants.ECAL_TOP_BANK_TAG;
+
+/**
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: ECalEvioWriter.java,v 1.1 2012/04/05 20:20:28 meeg Exp $
+ */
+public class ECalEvioWriter implements EvioWriter {
+
+	private String rawCalorimeterHitCollectionName = "EcalReadoutHits";
+	private String ecalName = "Ecal";
+	private HPSEcalDaqIDConverter ecalIDConverter = null;
+
+	public ECalEvioWriter() {
+	}
+
+	public void setEcalName(String ecalName) {
+		this.ecalName = ecalName;
+	}
+
+	public void setRawCalorimeterHitCollectionName(String rawCalorimeterHitCollectionName) {
+		this.rawCalorimeterHitCollectionName = rawCalorimeterHitCollectionName;
+	}
+
+	public boolean hasData(EventHeader event) {
+		return event.hasCollection(RawCalorimeterHit.class, rawCalorimeterHitCollectionName);
+	}
+
+	public void writeData(EventHeader event, EventBuilder builder) {
+		if (ecalIDConverter == null) {
+			ecalIDConverter = new HPSEcalDaqIDConverter();
+			ecalIDConverter.fillDaqCellMap(event.getDetector().getSubdetector(ecalName));
+		}
+		List<RawCalorimeterHit> rawCalorimeterHits = event.get(RawCalorimeterHit.class, rawCalorimeterHitCollectionName);
+		LCMetaData meta = event.getMetaData(rawCalorimeterHits);
+		writeRawCalorimeterHits(meta, rawCalorimeterHits, builder);
+		System.out.println("Writing ECal data, event " + event.getEventNumber());
+	}
+
+	private void writeRawCalorimeterHitCollection(List<RawCalorimeterHit> hits, LCMetaData meta, int bankTag, EventBuilder builder) {
+		// Get the ID decoder.
+		IDDecoder dec = meta.getIDDecoder();
+
+		// Make a hit map; allow for multiple hits in a crystal.
+		Map<Long, List<RawCalorimeterHit>> hitMap = new HashMap<Long, List<RawCalorimeterHit>>();
+		for (RawCalorimeterHit hit : hits) {
+			if (hitMap.get(hit.getCellID()) == null) {
+				hitMap.put(hit.getCellID(), new ArrayList<RawCalorimeterHit>());
+			}
+			List<RawCalorimeterHit> channelHits = hitMap.get(hit.getCellID());
+			channelHits.add(hit);
+		}
+
+		// Make map of slot number to hit IDs.
+		Map<Integer, List<Long>> slotMap = new HashMap<Integer, List<Long>>();
+		for (Long id : hitMap.keySet()) {
+			dec.setID(id);
+//			System.out.println(dec.getIDDescription());
+//			System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
+			Long daqID = ecalIDConverter.physicalToDaqID(id);
+//			System.out.printf("physicalID %d, daqID %d\n", id, daqID);
+			int slot = HPSEcalDaqIDConverter.getSlot(daqID);
+			if (slotMap.get(slot) == null) {
+				slotMap.put(slot, new ArrayList<Long>());
+			}
+			List<Long> slots = slotMap.get(slot);
+			slots.add(id);
+		}
+
+		// Make a new bank for this crate.
+		EvioBank crateBank = new EvioBank(bankTag, DataType.BANK, ECAL_BANK_NUMBER);
+
+		// Loop over the slots in the map.
+		for (int slot : slotMap.keySet()) {
+
+			// New bank for this slot.
+			EvioBank slotBank = new EvioBank(ECAL_PULSE_INTEGRAL_BANK_TAG, DataType.COMPOSITE, slot);
+
+			// Create composite data for this slot and its channels.
+			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 channel = HPSEcalDaqIDConverter.getChannel(ecalIDConverter.physicalToDaqID(id));
+				data.addUchar((byte) channel); // channel #
+				List<RawCalorimeterHit> channelHits = hitMap.get(id);
+				data.addN(channelHits.size()); // number of pulses
+				for (RawCalorimeterHit hit : channelHits) {
+					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(ECAL_PULSE_INTEGRAL_FORMAT, 1, data, ECAL_PULSE_INTEGRAL_BANK_TAG, 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) {
+		System.out.println("Writing " + rawCalorimeterHits.size() + " ECal hits");
+
+		// 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, ECAL_TOP_BANK_TAG, builder);
+		writeRawCalorimeterHitCollection(bottomHits, meta, ECAL_BOTTOM_BANK_TAG, builder);
+	}
+}

hps-java/src/main/java/org/lcsim/hps/evio
EvioWriter.java added at 1.1
diff -N EvioWriter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ EvioWriter.java	5 Apr 2012 20:20:28 -0000	1.1
@@ -0,0 +1,22 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.evio;
+
+import org.jlab.coda.jevio.EventBuilder;
+import org.lcsim.event.EventHeader;
+
+/**
+ * Interface to be implemented by classes that convert LCSim data to EVIO.
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: EvioWriter.java,v 1.1 2012/04/05 20:20:28 meeg Exp $
+ */
+public interface EvioWriter {
+
+	//checks whether the event contains data readable by this writer
+	public boolean hasData(EventHeader event);
+
+	//writes data from the event to the EVIO builder
+	public void writeData(EventHeader event, EventBuilder builder);
+}

hps-java/src/main/java/org/lcsim/hps/evio
SVTEvioWriter.java added at 1.1
diff -N SVTEvioWriter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SVTEvioWriter.java	5 Apr 2012 20:20:28 -0000	1.1
@@ -0,0 +1,77 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.evio;
+
+import static org.lcsim.hps.evio.EventConstants.SVT_BANK_NUMBER;
+import static org.lcsim.hps.evio.EventConstants.SVT_BANK_TAG;
+
+import java.util.List;
+
+import org.jlab.coda.jevio.DataType;
+import org.jlab.coda.jevio.EventBuilder;
+import org.jlab.coda.jevio.EvioBank;
+import org.jlab.coda.jevio.EvioException;
+import org.lcsim.event.EventHeader;
+import org.lcsim.hps.recon.tracking.HPSSVTData;
+
+/**
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: SVTEvioWriter.java,v 1.1 2012/04/05 20:20:28 meeg Exp $
+ */
+public class SVTEvioWriter implements EvioWriter {
+
+	public SVTEvioWriter() {
+	}
+
+	public boolean hasData(EventHeader event) {
+		List<List<HPSSVTData>> svtDataList = event.get(HPSSVTData.class);
+		return (svtDataList != null && svtDataList.size() > 0 && svtDataList.get(0) != null);
+	}
+
+	public void writeData(EventHeader event, EventBuilder builder) {
+		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), builder);
+					System.out.println("Writing SVT data, event " + event.getEventNumber());
+				}
+			}
+		}
+	}
+
+	private void writeSVTData(List<HPSSVTData> data, EventBuilder builder) {
+		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(SVT_BANK_TAG, DataType.UINT32, SVT_BANK_NUMBER);
+		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);
+		}
+	}
+}

hps-java/src/main/java/org/lcsim/hps/evio
TestRunTriggeredReconToEvio.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- TestRunTriggeredReconToEvio.java	5 Apr 2012 19:05:23 -0000	1.3
+++ TestRunTriggeredReconToEvio.java	5 Apr 2012 20:20:28 -0000	1.4
@@ -1,36 +1,17 @@
 package org.lcsim.hps.evio;
 
-import static org.lcsim.hps.evio.EventConstants.ECAL_BANK_NUMBER;
-import static org.lcsim.hps.evio.EventConstants.ECAL_BOTTOM_BANK_TAG;
-import static org.lcsim.hps.evio.EventConstants.ECAL_PULSE_INTEGRAL_FORMAT;
-import static org.lcsim.hps.evio.EventConstants.ECAL_PULSE_INTEGRAL_BANK_TAG;
-import static org.lcsim.hps.evio.EventConstants.ECAL_TOP_BANK_TAG;
-import static org.lcsim.hps.evio.EventConstants.SVT_BANK_NUMBER;
-import static org.lcsim.hps.evio.EventConstants.SVT_BANK_TAG;
-import static org.lcsim.hps.evio.EventConstants.ECAL_LAYER;
-
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
 
+import java.util.List;
 import java.util.Queue;
-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.geometry.IDDecoder;
-import org.lcsim.geometry.Subdetector;
-import org.lcsim.geometry.util.IDEncoder;
 import org.lcsim.hps.recon.ecal.HPSEcalDaqIDConverter;
-import org.lcsim.hps.recon.tracking.HPSSVTData;
 import org.lcsim.util.Driver;
 
 /**
@@ -45,13 +26,14 @@
 
 	EventWriter writer;
 	String rawCalorimeterHitCollectionName = "EcalReadoutHits";
-	String svtCollectionName = "SVTData";
+//	String svtCollectionName = "SVTData";
 	String evioOutputFile = "TestRunData.evio";
 	String ecalName = "Ecal";
 	Queue<QueuedEtEvent> builderQueue = null;
 	private int eventsWritten = 0;
 	public static boolean triggerBit = false;
 	HPSEcalDaqIDConverter ecalIDConverter = null;
+	List<EvioWriter> writers = null;
 
 	public TestRunTriggeredReconToEvio() {
 	}
@@ -60,10 +42,9 @@
 		this.evioOutputFile = evioOutputFile;
 	}
 
-	public void setSVTDataCollectionName(String svtCollectionName) {
-		this.svtCollectionName = svtCollectionName;
-	}
-
+//	public void setSVTDataCollectionName(String svtCollectionName) {
+//		this.svtCollectionName = svtCollectionName;
+//	}
 	public void setRawCalorimeterHitCollectionName(String rawCalorimeterHitCollectionName) {
 		this.rawCalorimeterHitCollectionName = rawCalorimeterHitCollectionName;
 	}
@@ -74,6 +55,17 @@
 		} catch (EvioException e) {
 			throw new RuntimeException(e);
 		}
+
+		writers = new ArrayList<EvioWriter>();
+
+		ECalEvioWriter ecalWriter = new ECalEvioWriter();
+		ecalWriter.setEcalName(ecalName);
+		ecalWriter.setRawCalorimeterHitCollectionName(rawCalorimeterHitCollectionName);
+		writers.add(ecalWriter);
+
+		SVTEvioWriter svtWriter = new SVTEvioWriter();
+		writers.add(svtWriter);
+
 		builderQueue = new LinkedList<QueuedEtEvent>();
 	}
 
@@ -92,44 +84,29 @@
 		if (triggerBit) {
 			// Make a new EVIO event.
 			EventBuilder builder = new EventBuilder(0, DataType.BANK, event.getEventNumber());
-			builderQueue.add(new QueuedEtEvent(builder));
+			builderQueue.add(new QueuedEtEvent(builder, writers.size()));
 			triggerBit = false;
 		}
 
-		List<List<HPSSVTData>> svtDataList = event.get(HPSSVTData.class);
-		if (svtDataList != null && svtDataList.size() > 0 && svtDataList.get(0) != null) {
-			System.out.println("try to write SVT data, event " + event.getEventNumber());
-			EventBuilder builder = null;
-
-			for (QueuedEtEvent queuedEvent : builderQueue) {
-				if (!queuedEvent.readSVT) {
-					builder = queuedEvent.getBuilder();
-					queuedEvent.readSVT = true;
-					break;
+		for (int i = 0; i < writers.size(); i++) {
+			EvioWriter evioWriter = writers.get(i);
+			if (evioWriter.hasData(event)) {
+				System.out.println("try to write SVT data, event " + event.getEventNumber());
+				EventBuilder builder = null;
+
+				for (QueuedEtEvent queuedEvent : builderQueue) {
+					if (!queuedEvent.getRead(i)) {
+						builder = queuedEvent.getBuilder();
+						queuedEvent.setRead(i);
+						break;
+					}
 				}
-			}
-			if (builder == null) {
-				throw new RuntimeException("no queued ET events waiting for an SVT bank");
-			}
-			// Write SVTData.
-			writeSVTData(event, builder);
-		}
-
-		if (event.hasCollection(RawCalorimeterHit.class, rawCalorimeterHitCollectionName)) {
-			System.out.println("try to write ECal data, event " + event.getEventNumber());
-			EventBuilder builder = null;
-			for (QueuedEtEvent queuedEvent : builderQueue) {
-				if (!queuedEvent.readECal) {
-					builder = queuedEvent.getBuilder();
-					queuedEvent.readECal = true;
-					break;
+				if (builder == null) {
+					throw new RuntimeException("no queued ET events waiting for an SVT bank");
 				}
+				// Write data.
+				evioWriter.writeData(event, builder);
 			}
-			if (builder == null) {
-				throw new RuntimeException("no queued ET events waiting for ECal banks");
-			}
-			// Write RawCalorimeterHit collection.
-			writeRawCalorimeterHits(event, builder);
 		}
 
 		while (!builderQueue.isEmpty() && builderQueue.peek().banksFilled()) {
@@ -142,7 +119,7 @@
 
 	private void writeEvioEvent(EventBuilder builder) {
 		builder.setAllHeaderLengths();
-		System.out.printf("Writing event with %d bytes\n",builder.getEvent().getTotalBytes());
+		System.out.printf("Writing event with %d bytes\n", builder.getEvent().getTotalBytes());
 		try {
 			writer.writeEvent(builder.getEvent());
 			++eventsWritten;
@@ -153,177 +130,24 @@
 		}
 	}
 
-	private void writeRawCalorimeterHits(EventHeader event, EventBuilder builder) {
-		if (ecalIDConverter == null) {
-			ecalIDConverter = new HPSEcalDaqIDConverter();
-			ecalIDConverter.fillDaqCellMap(event.getDetector().getSubdetector(ecalName));
-		}
-		List<RawCalorimeterHit> rawCalorimeterHits = event.get(RawCalorimeterHit.class, rawCalorimeterHitCollectionName);
-		LCMetaData meta = event.getMetaData(rawCalorimeterHits);
-		writeRawCalorimeterHits(meta, rawCalorimeterHits, builder);
-		System.out.println("Writing ECal data, event " + event.getEventNumber());
-	}
-
-	private void writeSVTData(EventHeader event, EventBuilder builder) {
-		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), builder);
-					System.out.println("Writing SVT data, event " + event.getEventNumber());
-				}
-			}
-		}
-	}
-
-	private void writeSVTData(List<HPSSVTData> data, EventBuilder builder) {
-		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(SVT_BANK_TAG, DataType.UINT32, SVT_BANK_NUMBER);
-		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; allow for multiple hits in a crystal.
-		Map<Long, List<RawCalorimeterHit>> hitMap = new HashMap<Long, List<RawCalorimeterHit>>();
-		for (RawCalorimeterHit hit : hits) {
-			if (hitMap.get(hit.getCellID()) == null) {
-				hitMap.put(hit.getCellID(), new ArrayList<RawCalorimeterHit>());
-			}
-			List<RawCalorimeterHit> channelHits = hitMap.get(hit.getCellID());
-			channelHits.add(hit);
-		}
-
-		// Make map of slot number to hit IDs.
-		Map<Integer, List<Long>> slotMap = new HashMap<Integer, List<Long>>();
-		for (Long id : hitMap.keySet()) {
-			dec.setID(id);
-//			System.out.println(dec.getIDDescription());
-//			System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
-			Long daqID = ecalIDConverter.physicalToDaqID(id);
-//			System.out.printf("physicalID %d, daqID %d\n", id, daqID);
-			int slot = HPSEcalDaqIDConverter.getSlot(daqID);
-			if (slotMap.get(slot) == null) {
-				slotMap.put(slot, new ArrayList<Long>());
-			}
-			List<Long> slots = slotMap.get(slot);
-			slots.add(id);
-		}
-
-		// Make a new bank for this crate.
-		EvioBank crateBank = new EvioBank(bankTag, DataType.BANK, ECAL_BANK_NUMBER);
-
-		// Loop over the slots in the map.
-		for (int slot : slotMap.keySet()) {
-
-			// New bank for this slot.
-			EvioBank slotBank = new EvioBank(ECAL_PULSE_INTEGRAL_BANK_TAG, DataType.COMPOSITE, slot);
-
-			// Create composite data for this slot and its channels.
-			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 channel = HPSEcalDaqIDConverter.getChannel(ecalIDConverter.physicalToDaqID(id));
-				data.addUchar((byte) channel); // channel #
-				List<RawCalorimeterHit> channelHits = hitMap.get(id);
-				data.addN(channelHits.size()); // number of pulses
-				for (RawCalorimeterHit hit : channelHits) {
-					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(ECAL_PULSE_INTEGRAL_FORMAT, 1, data, ECAL_PULSE_INTEGRAL_BANK_TAG, 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) {
-		System.out.println("Writing " + rawCalorimeterHits.size() + " ECal hits");
-
-		// 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, ECAL_TOP_BANK_TAG, builder);
-		writeRawCalorimeterHitCollection(bottomHits, meta, ECAL_BOTTOM_BANK_TAG, builder);
-	}
-
 	private class QueuedEtEvent {
 
 		private EventBuilder builder;
 		public boolean readSVT = false;
 		public boolean readECal = false;
+		private boolean[] readData = null;
 
-		public QueuedEtEvent(EventBuilder builder) {
+		public QueuedEtEvent(EventBuilder builder, int numData) {
 			this.builder = builder;
+			readData = new boolean[numData];
+		}
+
+		public void setRead(int i) {
+			readData[i] = true;
+		}
+
+		public boolean getRead(int i) {
+			return readData[i];
 		}
 
 		public EventBuilder getBuilder() {
@@ -331,7 +155,12 @@
 		}
 
 		public boolean banksFilled() {
-			return (readSVT && readECal);
+			for (boolean x : readData) {
+				if (!x) {
+					return false;
+				}
+			}
+			return true;
 		}
 	}
 }
\ 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