hps-java/src/main/java/org/lcsim/hps/evio
diff -N SVTEvioReader.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SVTEvioReader.java 25 Apr 2012 04:59:32 -0000 1.1
@@ -0,0 +1,127 @@
+package org.lcsim.hps.evio;
+
+//--- java ---//
+import java.util.ArrayList;
+import java.util.List;
+
+//--- Coda ---//
+import org.jlab.coda.jevio.BaseStructure;
+import org.jlab.coda.jevio.EvioEvent;
+
+//--- org.lcsim ---//
+import org.lcsim.event.EventHeader;
+
+//--- hps-java ---//
+import org.lcsim.hps.recon.tracking.HPSSVTData;
+import org.lcsim.hps.recon.tracking.HPSSVTRawTrackerHitMaker;
+
+//--- Constants ---//
+import static org.lcsim.hps.evio.EventConstants.SVT_BANK_TAG;
+
+/**
+ *
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: SVTEvioReader.java,v 1.1 2012/04/25 04:59:32 omoreno Exp $
+ *
+ */
+public class SVTEvioReader extends EvioReader {
+
+
+ HPSSVTRawTrackerHitMaker hitMaker;
+
+ /**
+ *
+ */
+ public SVTEvioReader()
+ {
+ hitCollectionName = "SVTData";
+ debug = false;
+ };
+
+ /**
+ *
+ */
+ public void makeHits(EvioEvent event, EventHeader lcsimEvent)
+ {
+ // Create a list of HPSSVTData
+ List<HPSSVTData> svtData = new ArrayList<HPSSVTData>();
+ svtData.addAll(this.makeSVTData(event));
+
+ lcsimEvent.put(hitCollectionName, svtData, HPSSVTData.class, 0);
+ }
+
+ /**
+ *
+ * @param event
+ * @return
+ */
+ public List<HPSSVTData> makeSVTData(EvioEvent event)
+ {
+ // Create the HPSSVTData collection
+ List<HPSSVTData> svtDataCollection = new ArrayList<HPSSVTData>();
+
+ for(BaseStructure crateBank : event.getChildren()){
+ int crateTag = crateBank.getHeader().getTag();
+
+ // Process only events inside the SVT Bank
+ if(crateTag == SVT_BANK_TAG){
+ if(crateBank.getChildCount() == 0)
+ throw new RuntimeException("No children found in SVT bank!");
+
+ // Loop over all FPGA banks
+ for(BaseStructure fpgaBank : crateBank.getChildren()){
+
+ // The data contained in FPGA 7 is currently not used
+ if(fpgaBank.getHeader().getTag() == 7) continue;
+
+ // Get data
+ int[] data = fpgaBank.getIntData();
+
+ if(debug) System.out.println(this.getClass().getSimpleName() + ": The data size is " + data.length);
+
+ if(debug){
+ for(int index = 0; index < data.length; index++){
+ System.out.println("Data " + index + ": " + data[index]);
+ }
+ }
+
+ // Get the hybrid temperature data associated with this FPGA
+ int[] temperatureData = new int[6];
+ System.arraycopy(data, 0, temperatureData, 0, 6);
+
+ if(debug){
+ System.out.println(this.getClass().getSimpleName() + ": The temperatures are: ");
+ double[] temps = HPSSVTData.getTemperature(temperatureData);
+ for(int index = 0; index < temps.length; index++){
+ System.out.println("Temp " + index + ": " + temps[index]);
+ }
+ }
+
+ // Get all of the samples
+ int sampleLength = data.length - temperatureData.length - 1; // Tail length
+ int[] allSamples = new int[sampleLength];
+ System.arraycopy(data, 6, allSamples, 0, sampleLength);
+
+ if(debug){
+ for(int index = 0; index < allSamples.length; index++){
+ System.out.println("Sample " + index + ": " + allSamples[index]);
+ }
+ }
+
+ // Check whether a complete set of samples exist
+ if(allSamples.length % 4 != 0)
+ throw new RuntimeException("Size of samples array is not divisible by 4!");
+
+ // Loop over all samples and create HPSSVTData
+ for(int index = 0; index < allSamples.length; index +=4){
+ int[] samples = new int[4];
+ System.arraycopy(allSamples, index, samples, 0, samples.length);
+ svtDataCollection.add(new HPSSVTData(samples));
+ }
+ }
+ }
+ }
+ System.out.println("Adding SVTData Collection of Size " + svtDataCollection.size());
+ return svtDataCollection;
+ }
+}