hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.4 -r1.5
--- TestRunReconToEvio.java 3 Apr 2012 18:36:48 -0000 1.4
+++ TestRunReconToEvio.java 5 Apr 2012 23:56:37 -0000 1.5
@@ -3,8 +3,8 @@
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_CHANNEL_OFFSET;
-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_PULSE_INTEGRAL_FORMAT;
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;
@@ -26,6 +26,7 @@
import org.lcsim.event.RawCalorimeterHit;
import org.lcsim.geometry.IDDecoder;
import org.lcsim.hps.recon.tracking.HPSSVTData;
+import org.lcsim.hps.recon.tracking.HPSSVTDataBuffer;
import org.lcsim.util.Driver;
/**
@@ -80,6 +81,19 @@
}
protected void process(EventHeader event) {
+
+ // Skip if no SVT data in event.
+ List<HPSSVTData> svtData = null;
+ try {
+ svtData = event.get(HPSSVTData.class, svtCollectionName);
+ } catch (IllegalArgumentException e) {
+ //System.out.println(svtCollectionName + " does not exit; skipping event");
+ return;
+ }
+ if (svtData.size() == 0) {
+ //System.out.println(svtCollectionName + " is empty; skipping event");
+ return;
+ }
// Make a new EVIO event.
builder = new EventBuilder(0, DataType.BANK, event.getEventNumber());
@@ -111,50 +125,39 @@
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));
- }
+
+ // SVT container bank.
+ EvioBank svtBank = new EvioBank(SVT_BANK_TAG, DataType.BANK, SVT_BANK_NUMBER);
+
+ int nfpgas = 8;
+ for (int i=0; i<nfpgas; i++) {
+
+ // Get the raw int data buffer for this FPGA.
+ int[] dataBuffer = HPSSVTDataBuffer.readoutBuffer(i);
+
+ System.out.println("FPGA["+i+"] has data of size " + dataBuffer.length);
+
+ // Bank for this FPGA's frame data.
+ // FIXME: Need actual FPGA numbers.
+ EvioBank frameBank = new EvioBank(i, DataType.UINT32, i);
+ try {
+ frameBank.appendIntData(dataBuffer);
+ builder.addChild(svtBank, frameBank);
+ } catch (EvioException e) {
+ throw new RuntimeException(e);
}
}
- }
-
- 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(SVT_BANK_TAG, DataType.UINT32, SVT_BANK_NUMBER);
+
+ // Add top bank to event.
try {
- bank.appendIntData(evioIntData);
+ builder.addChild(builder.getEvent(), svtBank);
} 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.