Print

Print


Author: [log in to unmask]
Date: Tue Nov  4 20:47:24 2014
New Revision: 1430

Log:
extend TriggerData with Andrea's reader for the new SSP bank format

Added:
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SSPData.java
      - copied, changed from r1425, java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java
Modified:
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java

Copied: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SSPData.java (from r1425, java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java)
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SSPData.java	Tue Nov  4 20:47:24 2014
@@ -2,73 +2,160 @@
 
 import org.lcsim.event.GenericObject;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 /**
  *
  * @author Sho Uemura <[log in to unmask]>
+ * @author Andrea Celentano <[log in to unmask]>
  * @version $Id: TriggerData.java,v 1.3 2012/08/03 23:14:39 meeg Exp $
  */
-public class TriggerData implements GenericObject {
+public class SSPData extends TriggerData {
 
-    public static final int OR_TRIG = 3;
-    public static final int TOP_TRIG = 4;
-    public static final int BOT_TRIG = 5;
-    public static final int AND_TRIG = 6;
-    public static final int TIME = 7;
-    public static final int TRIG_BANK_SIZE = 8;
+//    public static final int OR_TRIG = 3;
+//    public static final int TOP_TRIG = 4;
+//    public static final int BOT_TRIG = 5;
+//    public static final int AND_TRIG = 6;
+//    public static final int TIME = 7;
+//    public static final int TRIG_BANK_SIZE = 8;
+    //Here goes the 5-bit identifiers for the word type
+    public static final int TRIG_HEADER = 0x12;
+    public static final int TRIG_TIME = 0x13;
+    public static final int TRIG_TYPE = 0x15;
+    public static final int CLUSTER_TYPE = 0x14;
+
     public static final String TRIG_COLLECTION = "TriggerBank";
     private int[] bank;
 
-    public TriggerData(int[] bank) {
-        this.bank = bank;
+    private long trigTime;
+    private int eventNum;
+
+    private int trigType;
+    private int trigTypeData;
+    private int trigTypeTime;
+
+    private int nCluster, nClusterTop, nClusterBottom;
+
+    private List<Integer> clusterX, clusterY, clusterE, clusterT, clusterNhits;
+
+    public SSPData(int[] bank) {
+        super(bank);
+
+        clusterX = new ArrayList<Integer>();
+        clusterY = new ArrayList<Integer>();
+        clusterE = new ArrayList<Integer>();
+        clusterT = new ArrayList<Integer>();
+        clusterNhits = new ArrayList<Integer>();
+
+        trigTime = 0;
+        trigType = -1;
+        trigTypeData = 0;
+
+        nCluster = nClusterTop = nClusterBottom = 0;
+
+        this.bank = Arrays.copyOf(bank, bank.length);
+        this.decodeTriggerBank();
+
     }
 
-    public int getTime() {
-        return getIntVal(TIME);
+    private void decodeTriggerBank() {
+        /*A. Celentano: decode here the trigger bank*/
+        /*We do not need to handle block header, block trayler since these are disentagled in the secondary CODA readout list*/
+        int this_word;
+        int this_clusterX, this_clusterY, this_clusterE, this_clusterT, this_clusterNhits;
+
+        for (int ii = 0; ii < bank.length; ii++) {
+            this_word = bank[ii];
+
+            //event header
+            if (((this_word >> 27) & (0x1f)) == TRIG_HEADER) {
+                eventNum = this_word & 0x7FFFFFF;
+            } //trigger time
+            else if (((this_word >> 27) & (0x1f)) == TRIG_TIME) {
+                trigTime = (bank[ii + 1] << 24) | (this_word & 0xffffff);
+            } //trigger type
+            else if (((this_word >> 27) & (0x1f)) == TRIG_TYPE) {
+                trigType = (this_word >> 23) & 0xf; //this is the trigbit, from 0 to 7
+                trigTypeData = (this_word >> 16) & 0x7f;
+                trigTypeTime = (this_word >> 16) & 0x3ff;
+            } //cluster 
+            else if (((this_word >> 27) & (0x1f)) == CLUSTER_TYPE) {
+                this_clusterNhits = (this_word >> 23) & 0xf;
+                clusterNhits.add(this_clusterNhits);
+
+                this_clusterE = (this_word >> 10) & 0x1fff;
+                clusterE.add(this_clusterE);
+
+                this_clusterY = (this_word >> 6) & 0xf;
+                clusterY.add(this_clusterY);
+                if (this_clusterY > 0) {
+                    nClusterTop++;
+                } else if (this_clusterY < 0) {
+                    nClusterBottom++;
+                }
+
+                this_clusterX = (this_word) & 0x3f;
+                clusterX.add(this_clusterX);
+
+                this_clusterT = (bank[ii + 1]) & 0x3ff;
+                clusterT.add(this_clusterT);
+
+                nCluster++;
+            }
+
+        }
     }
 
-    public int getOrTrig() {
-        return getIntVal(OR_TRIG);
+    @Override
+    public long getTime() {
+        return trigTime;
     }
 
-    public int getTopTrig() {
-        return getIntVal(TOP_TRIG);
-    }
-
-    public int getBotTrig() {
-        return getIntVal(BOT_TRIG);
-    }
-
-    public int getAndTrig() {
-        return getIntVal(AND_TRIG);
-    }
-
+//    public int getOrTrig() {
+//        return 0;
+//    }
+//
+//    public int getTopTrig() {
+//        return 0;
+//    }
+//
+//    public int getBotTrig() {
+//        return 0;
+//    }
+//
+//    public int getAndTrig() {
+//        return 0;
+//    }
     public int[] getBank() {
         return bank;
     }
 
-    public static int getTime(GenericObject object) {
-        return object.getIntVal(TIME);
+    public static long getTime(GenericObject object) {
+        return ((TriggerData) object).getTime();
     }
 
     public static int getOrTrig(GenericObject object) {
-        return object.getIntVal(OR_TRIG);
+        return ((TriggerData) object).getOrTrig();
     }
 
     public static int getTopTrig(GenericObject object) {
-        return object.getIntVal(TOP_TRIG);
+        return ((TriggerData) object).getTopTrig();
     }
 
     public static int getBotTrig(GenericObject object) {
-        return object.getIntVal(BOT_TRIG);
+        return ((TriggerData) object).getBotTrig();
     }
 
     public static int getAndTrig(GenericObject object) {
-        return object.getIntVal(AND_TRIG);
+        return ((TriggerData) object).getAndTrig();
     }
 
     public static int[] getBank(GenericObject object) {
-        int[] bank = new int[8];
-        for (int i = 0; i < 8; i++) {
+        int N = ((SSPData) object).bank.length;
+        int[] bank = new int[N];
+        for (int i = 0; i < N; i++) {
             bank[i] = object.getIntVal(i);
         }
         return bank;
@@ -76,7 +163,7 @@
 
     @Override
     public int getNInt() {
-        return TRIG_BANK_SIZE;
+        return bank.length;
     }
 
     @Override
@@ -106,6 +193,6 @@
 
     @Override
     public boolean isFixedSize() {
-        return true;
+        return false;
     }
 }

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java	Tue Nov  4 20:47:24 2014
@@ -22,7 +22,7 @@
         this.bank = bank;
     }
 
-    public int getTime() {
+    public long getTime() {
         return getIntVal(TIME);
     }
 
@@ -46,7 +46,7 @@
         return bank;
     }
 
-    public static int getTime(GenericObject object) {
+    public static long getTime(GenericObject object) {
         return object.getIntVal(TIME);
     }