Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
HPSSVTData.java+103-451.4 -> 1.5
Added temperature decoding and hit time

hps-java/src/main/java/org/lcsim/hps/recon/tracking
HPSSVTData.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- HPSSVTData.java	31 Mar 2012 02:22:48 -0000	1.4
+++ HPSSVTData.java	25 Apr 2012 05:10:19 -0000	1.5
@@ -1,23 +1,28 @@
 
 package org.lcsim.hps.recon.tracking;
 
+//--- Constants ---//
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.APV_MASK;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.HYBRID_MASK;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.FPGA_MASK;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.CHANNEL_MASK;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.SAMPLE_MASK;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TEMP_MASK;
+import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_NUMBER_OF_SAMPLES;
+
 /**
  * 
  * 
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSSVTData.java,v 1.4 2012/03/31 02:22:48 omoreno Exp $
+ * @version $Id: HPSSVTData.java,v 1.5 2012/04/25 05:10:19 omoreno Exp $
  */
 public class HPSSVTData {
     
-    // Masks used to encode SVT hit information
-    public static final int HYBRID_MASK = 0x3;
-    public static final int APV_MASK = 0x7;
-    public static final int CHANNEL_MASK = 0x7F;
-    public static final int FPGA_MASK = 0xFFFF;
-    public static final int SAMPLE_MASK = 0x3FFF;
-    
     // 4x32 
-    int[] sample = new int[4];
+    int[] data = new int[4];
+    
+    // Time of the hit
+    int hitTime = 0;
     
     
     /**
@@ -51,10 +56,10 @@
      */
     public HPSSVTData(int[] data)
     {
-        if(sample.length != 4) 
+        if(data.length != 4) 
             throw new RuntimeException("Data sample size is not valid!");
         
-        this.sample = data;
+        this.data = data;
     }
     
     /**
@@ -63,7 +68,7 @@
      *      The packed data as an int array of size 4.
      */
     public int[] getData() {
-    	return sample;
+    	return data;
     }
     
     
@@ -75,63 +80,63 @@
     {
         /*
          * Sample Data consists of the following: Z[xx:xx] = Zeros, O[xx:xx] = Ones
-         * sample[0] = O[0], Z[0], Hybrid[1:0], Z[0], ApvChip[2:0], Z[0], Channel[6:0], FpgaAddress[15:0]
-         * sample[1] = Z[1:0], Sample1[13:0]], Z[1:0], Sample0[13:0]
-         * sample[2] = Z[1:0], Sample3[13:0]], Z[1:0], Sample2[13:0]
-         * sample[3] = Z[1:0], Sample5[13:0]], Z[1:0], Sample4[13:0]
+         * data[0] = O[0], Z[0], Hybrid[1:0], Z[0], ApvChip[2:0], Z[0], Channel[6:0], FpgaAddress[15:0]
+         * data[1] = Z[1:0], Sample1[13:0]], Z[1:0], Sample0[13:0]
+         * data[2] = Z[1:0], Sample3[13:0]], Z[1:0], Sample2[13:0]
+         * data[3] = Z[1:0], Sample5[13:0]], Z[1:0], Sample4[13:0]
          * 
          */ 
     
-        //--- sample[0] ---//
+        //--- data[0] ---//
         //-----------------//
         
-        // The most significant digit of sample[0] is set to 1
-        sample[0] |= 0x80000000;
+        // The most significant digit of data[0] is set to 1
+        data[0] |= 0x80000000;
         
         // Insert the hybrid number
-        sample[0] = (sample[0] &= ~(HYBRID_MASK << 28)) | ((hybridNumber & HYBRID_MASK) << 28); 
+        data[0] = (data[0] &= ~(HYBRID_MASK << 28)) | ((hybridNumber & HYBRID_MASK) << 28); 
         
         // Insert the APV number
-        sample[0] = (sample[0] &= ~(APV_MASK << 24)) | ((apvNumber & APV_MASK) << 24); 
+        data[0] = (data[0] &= ~(APV_MASK << 24)) | ((apvNumber & APV_MASK) << 24); 
         
         // Insert the channel number
-        sample[0] = (sample[0] &= ~(CHANNEL_MASK << 16)) | ((channelNumber & CHANNEL_MASK) << 16); 
+        data[0] = (data[0] &= ~(CHANNEL_MASK << 16)) | ((channelNumber & CHANNEL_MASK) << 16); 
         
         // Insert the FPGA address
-        sample[0] = (sample[0] &= ~FPGA_MASK) | (fpgaAddress & FPGA_MASK);
+        data[0] = (data[0] &= ~FPGA_MASK) | (fpgaAddress & FPGA_MASK);
         
         
-        //--- sample[1] ----//
+        //--- data[1] ----//
         //------------------//
         
-        // Add sample 0
-        sample[1] = (sample[1] &= ~SAMPLE_MASK) | (adc[0] & SAMPLE_MASK);
+        // Add data 0
+        data[1] = (data[1] &= ~SAMPLE_MASK) | (adc[0] & SAMPLE_MASK);
         
-        // Add sample 1
-        sample[1] = (sample[1] &= ~(SAMPLE_MASK << 16)) | ((adc[1] & SAMPLE_MASK) << 16);
+        // Add data 1
+        data[1] = (data[1] &= ~(SAMPLE_MASK << 16)) | ((adc[1] & SAMPLE_MASK) << 16);
 
         
         
-        //--- sample[2] ----//
+        //--- data[2] ----//
         //------------------//
         
         // Add sample 2
-        sample[2] = (sample[2] &= ~SAMPLE_MASK) | (adc[2] & SAMPLE_MASK);
+        data[2] = (data[2] &= ~SAMPLE_MASK) | (adc[2] & SAMPLE_MASK);
 
         
         // Add sample 3
-        sample[2] = (sample[2] &= ~(SAMPLE_MASK << 16)) | ((adc[3] & SAMPLE_MASK) << 16);
+        data[2] = (data[2] &= ~(SAMPLE_MASK << 16)) | ((adc[3] & SAMPLE_MASK) << 16);
 
         
-        //--- sample[3] ----//
+        //--- data[3] ----//
         //------------------//
         
         // Add sample 4
-        sample[3] = (sample[3] &= ~SAMPLE_MASK) | (adc[4] & SAMPLE_MASK);
+        data[3] = (data[3] &= ~SAMPLE_MASK) | (adc[4] & SAMPLE_MASK);
 
         
         // Add sample 5
-        sample[3] = (sample[3] &= ~(SAMPLE_MASK << 16)) | ((adc[5] & SAMPLE_MASK) << 16);
+        data[3] = (data[3] &= ~(SAMPLE_MASK << 16)) | ((adc[5] & SAMPLE_MASK) << 16);
 
     }
     
@@ -141,7 +146,7 @@
      */
     public int getHybridNumber()
     {
-        return (sample[0] >>> 28) & HYBRID_MASK;
+        return (data[0] >>> 28) & HYBRID_MASK;
     }
     
     /**
@@ -150,7 +155,7 @@
      */
     public int getAPVNumber()
     {
-        return (sample[0] >>> 24) & APV_MASK;
+        return (data[0] >>> 24) & APV_MASK;
     }
     
     /**
@@ -159,7 +164,7 @@
      */
     public int getChannelNumber()
     {
-        return (sample[0] >>> 16) & CHANNEL_MASK;
+        return (data[0] >>> 16) & CHANNEL_MASK;
     }
     
     /**
@@ -168,7 +173,7 @@
      */
     public int getFPGAAddress()
     {
-        return sample[0] & FPGA_MASK;
+        return data[0] & FPGA_MASK;
     }
     
     /**
@@ -185,20 +190,73 @@
         
         switch(n) {
             case 0: 
-                return sample[1] & SAMPLE_MASK;
+                return data[1] & SAMPLE_MASK;
             case 1:
-                return (sample[1] >>> 16) & SAMPLE_MASK;
+                return (data[1] >>> 16) & SAMPLE_MASK;
             case 2:
-                return sample[2] & SAMPLE_MASK;
+                return data[2] & SAMPLE_MASK;
             case 3:
-                return (sample[2] >>> 16) & SAMPLE_MASK;
+                return (data[2] >>> 16) & SAMPLE_MASK;
             case 4: 
-                return sample[3] & SAMPLE_MASK;
+                return data[3] & SAMPLE_MASK;
             case 5:
-                return (sample[3] >>> 16) & SAMPLE_MASK;
+                return (data[3] >>> 16) & SAMPLE_MASK;
             default:
                 throw new RuntimeException("Invalid sample number! Valid range of values for n are from 0 - 5");
         }
-           
+    }
+    
+    /**
+     *	Get all SVT samples
+     *
+     * 	@return An array containing all SVT Shaper signal samples
+     */
+    public short[] getAllSamples()
+    {
+    	short[] samples = new short[TOTAL_NUMBER_OF_SAMPLES];
+    
+    	// Get all SVT Samples
+    	for(int index = 0; index < TOTAL_NUMBER_OF_SAMPLES; index++){
+    		samples[index] = (short) this.getSample(index);
+    	}
+  
+    	return samples;
+    }
+    
+    /**
+     * Get the hit time at which the hit occurred
+     * 
+     * @return The time at which the hit occurred with respect to the trigger
+     */
+    public int getHitTime()
+    {
+    	return hitTime;
+    }
+    
+    /**
+     * Set the hit time at which the hit occurred
+     * 
+     * @param hitTime : Time at which the hit occurred 
+     */
+    public void setHitTime(int hitTime)
+    {
+    	this.hitTime = hitTime;
+    }    
+    
+    /**
+     * 
+     */
+    public static double[] getTemperature(int[] data)
+    {
+    	double[] temperatures = new double[(data.length)*2];
+    
+    	int tempIndex = 0;
+    	for(int index = 0; index < data.length; index++){
+    		temperatures[tempIndex] = data[index] & TEMP_MASK;
+    		temperatures[tempIndex+1] = (data[index] >>> 16) & TEMP_MASK;
+    		tempIndex+=2;
+    	}
+    	
+    	return temperatures;
     }
 }
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