Print

Print


Author: [log in to unmask]
Date: Fri Jan 30 12:55:42 2015
New Revision: 2009

Log:
Updated the SSPData object to create lists of SSPCluster and SSPTrigger objects. Additionally added documentation and removed some unused variables. Note that the SSPData object should still be treated as under construction; several methods require additional input before they can be handled. Also updated SSPCluster and SSPTrigger to ensure consistency in the treatment of the time variable.

Modified:
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPCluster.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPData.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPTrigger.java

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPCluster.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPCluster.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPCluster.java	Fri Jan 30 12:55:42 2015
@@ -29,8 +29,7 @@
 	 * @param iy - The y-index of the cluster.
 	 * @param energy - The cluster energy in MeV.
 	 * @param hits - The cluster hit count.
-	 * @param time - The time at which the cluster occurred in 4 ns
-	 * clock-cycles.
+	 * @param time - The time at which the cluster occurred in ns.
 	 */
 	public SSPCluster(int ix, int iy, int energy, int hits, int time) {
 		// Make sure that the input values are valid.
@@ -50,7 +49,7 @@
 		this.ix = ix;
 		this.iy = iy;
 		this.e = energy / 1000.0;
-		this.t = 4 * time;
+		this.t = time;
 		this.n = hits;
 		
 		// Indicate that the cluster was made.

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPData.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPData.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPData.java	Fri Jan 30 12:55:42 2015
@@ -6,27 +6,25 @@
 import java.util.List;
 
 /**
- *
+ * Parses the trigger bank information in the SSP trigger bank and
+ * converts it into <code>SSPCluster</code> and <code>SSPTrigger</code>
+ * objects.
+ * 
  * @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 $
+ * @author Kyle McCarty <[log in to unmask]>
  */
 public class SSPData extends AbstractIntData {
-
+	// The EVIO header tag for SSP trigger banks.
     public static final int BANK_TAG = 0xe10c;
-
-//    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
+    
+    // EVIO 5-bit word identifiers for cluster parameters.
     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;
-
+    
+    // EVIO trigger type identifiers.
     public static final int TRIG_TYPE_COSMIC_TOP = 0x0;
     public static final int TRIG_TYPE_COSMIC_BOT = 0x1;
     public static final int TRIG_TYPE_SINGLES0_TOP = 0x2;
@@ -35,13 +33,13 @@
     public static final int TRIG_TYPE_SINGLES1_BOT = 0x5;
     public static final int TRIG_TYPE_PAIR0 = 0x6;
     public static final int TRIG_TYPE_PAIR1 = 0x7;
-
-//    public static final String TRIG_COLLECTION = "TriggerBank";
-    private long trigTime = 0;
-    private int eventNum;
-
-    private int nCluster, nClusterTop, nClusterBottom = 0;
-
+    
+    // TODO: These should not be persisted past their use in initial
+    //        bank parsing They are now superseded by the SSPCluster
+    //        and SSPTrigger objects, which contain the same information
+    //        in a more user-friendly fashion. These should be removed
+    //        once all functions calling on them have been modified to
+    //        use the SSPCluster and SSPTrigger collections instead.
     private final List<Integer> clusterX = new ArrayList<Integer>();
     private final List<Integer> clusterY = new ArrayList<Integer>();
     private final List<Integer> clusterE = new ArrayList<Integer>();
@@ -50,22 +48,44 @@
     private final List<Integer> trigType = new ArrayList<Integer>();
     private final List<Integer> trigTypeData = new ArrayList<Integer>();
     private final List<Integer> trigTypeTime = new ArrayList<Integer>(); //SSP can report more than 1 trigger type (if the event satisfies more than 1 trigger equation)
-
+    
+    // Collections for storing the decoded SSP bank data.
+    private final List<SSPCluster> clusterList = new ArrayList<SSPCluster>();
+    private final List<SSPTrigger> triggerList = new ArrayList<SSPTrigger>();
+    
+    // Other SSP bank information.
+    private int eventNumber = 0;
+    private long triggerTime = 0;
+    
+    /**
+     * Instantiates an <code>SSPData</code> object from a bank of
+     * integer primitives defining an EVIO-encoded SSP trigger bank.
+     * @param bank - The EVIO bank from which to generate the object.
+     */
     public SSPData(int[] bank) {
         super(bank);
         decodeData();
     }
-
+    
+    /**
+     * Instantiates an <code>SSPData</code> object from an LCIO
+     * <code>GenericObject</code> object that contains an EVIO-encoded
+     * bank of integer primitives which represent an SSP trigger bank.
+     * @param sspData - The <code>GenericObject</code> containing the
+     * integer bank from which to generate the object.
+     */
     public SSPData(GenericObject sspData) {
         super(sspData, BANK_TAG);
         decodeData();
     }
-
+    
     @Override
     public int getTag() {
         return BANK_TAG;
     }
-
+    
+    // NOTE :: Cluster time is already corrected to be in ns; trigger
+    //         time was left in units of clock-cycles!
     @Override
     protected final void decodeData() {
         /*A. C.: decode here the trigger bank*/
@@ -78,10 +98,11 @@
 
             //event header
             if (((this_word >> 27) & (0x1f)) == TRIG_HEADER) {
-                eventNum = this_word & 0x7FFFFFF;
-            } //trigger time
+            	eventNumber = this_word & 0x7FFFFFF;
+            }
+            //trigger time
             else if (((this_word >> 27) & (0x1f)) == TRIG_TIME) {
-                trigTime = (bank[ii + 1] << 24) | (this_word & 0xffffff);
+            	triggerTime = (bank[ii + 1] << 24) | (this_word & 0xffffff);
             } //trigger type
             else if (((this_word >> 27) & (0x1f)) == TRIG_TYPE) {
                 trigType.add((this_word >> 23) & 0xf); //this is the trigbit, from 0 to 7
@@ -103,12 +124,6 @@
                 	this_clusterY *=-1;
                 }
                 clusterY.add(this_clusterY);
-                
-                if (this_clusterY > 0) {
-                    nClusterTop++;
-                } else if (this_clusterY < 0) {
-                    nClusterBottom++;
-                }
 
                 this_clusterX = (this_word) & 0x3f;    
                 /*Need to do hand-made 2 complement, since this is a 6-bit word (and not a 32-bit integer!)*/
@@ -122,20 +137,66 @@
 
                 this_clusterT = (bank[ii + 1]) & 0x3ff;
                 clusterT.add(this_clusterT * 4); //*4 since the time is reported in 4 ns ticks
-
-                nCluster++;
-            }
-        }
-    }
-
-    public long getTime() {
-        return trigTime;
-    }
-
+            }
+        }
+        
+        // Convert the cluster lists into a single list of SSPCluster
+        // objects and place them into the cluster list.
+        int clusters = clusterX.size();
+        for(int i = 0; i < clusters; i++) {
+        	SSPCluster cluster = new SSPCluster(clusterX.get(i), clusterY.get(i),
+        			clusterE.get(i), clusterNhits.get(i), clusterT.get(i));
+        	clusterList.add(cluster);
+        }
+        
+        // Convert the trigger lists into a single list of SSPTrigger
+        // objects and place them into the trigger list.
+        int triggers = trigType.size();
+        for(int i = 0; i < triggers; i++) {
+        	SSPTrigger trigger = SSPTriggerFactory.makeTrigger(trigType.get(i),
+        			trigTypeTime.get(i) * 4, trigTypeData.get(i));
+        	triggerList.add(trigger);
+        }
+    }
+    
+    /**
+     * Gets the list of clusters reported by the SSP.
+     * @return Returns the clusters as a <code>List</code> collection
+     * of <code>SSPCluster</code> objects.
+     */
+    public List<SSPCluster> getClusters() {
+    	return clusterList;
+    }
+    
+    /**
+     * Gets the list of triggers reported by the SSP.
+     * @return Returns the triggers as a <code>List</code> collection
+     * of <code>SSPTrigger</code> objects. These can vary in which
+     * subclass they are, as appropriate to their type code.
+     */
+    public List<SSPTrigger> getTriggers() {
+    	return triggerList;
+    }
+    
+    /**
+     * Gets the trigger time reported by the SSP.
+     * @return Returns the trigger time as a <code>long</code>.
+     */
+    public long getTime() { return triggerTime; }
+    
+    /**
+     * Gets the event number reported by the SSP.
+     * @return Returns the event number as an <code>int</code>.
+     */
+    public int getEventNumber() { return eventNumber; }
+    
     /*
      * Returns the trigger time, relative to the SSP window, of the FIRST Cluster singles trigger (0/1) (any crate)
      * Returns in ns.
      */
+    // TODO: Get information from Andrea on what this is for. It seems
+    //       to be something specialized. Maybe it should be placed in
+    //       the analysis driver in which it is used?
     public int getOrTrig() {
         int TopTime = this.getTopTrig();
         int BotTime = this.getBotTrig();
@@ -147,11 +208,14 @@
         }
 
     }
-
+    
     /*
      * Returns the trigger time, relative to the SSP window, of the FIRST Cluster singles trigger (0/1) from TOP crate 
      * Returns in ns.
      */
+    // TODO: Get information from Andrea on what this is for. It seems
+    //       to be something specialized. Maybe it should be placed in
+    //       the analysis driver in which it is used?
     public int getTopTrig() {
         int TopTime = 1025; //time is 10 bits, so is always smaller than 1024.
         for (int ii = 0; ii < trigType.size(); ii++) {
@@ -161,12 +225,14 @@
         }
         return TopTime * 4;
     }
-
-
+    
     /*
      * Returns the trigger time, relative to the SSP window, of the FIRST Cluster singles trigger (0/1) from BOT crate 
      * Returns in ns.
      */
+    // TODO: Get information from Andrea on what this is for. It seems
+    //       to be something specialized. Maybe it should be placed in
+    //       the analysis driver in which it is used?
     public int getBotTrig() {
         int BotTime = 1025; //time is 10 bits, so is always smaller than 1024.
         for (int ii = 0; ii < trigType.size(); ii++) {
@@ -176,7 +242,8 @@
         }
         return BotTime * 4;
     }
-
+    
+    // TODO: This does not seem to do anything. Can it be deleted?
     public int getAndTrig() {
         return 0;
     }

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPTrigger.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPTrigger.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/SSPTrigger.java	Fri Jan 30 12:55:42 2015
@@ -26,8 +26,7 @@
 	 * Instantiates a new <code>SSPTrigger</code> with the indicated
 	 * trigger data.
 	 * @param type - The type of trigger.
-	 * @param time - The time at which the trigger occurred in 4 ns
-	 * clock-cycles.
+	 * @param time - The time at which the trigger occurred in ns.
 	 * @param data - The trigger bit data.
 	 */
 	public SSPTrigger(int type, int time, int data) {
@@ -38,7 +37,7 @@
 		
 		// Store the trigger data.
 		this.type = type;
-		this.time = 4 * time;
+		this.time = time;
 		this.data = data;
 		
 		// Note that a trigger was made.