Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/util on MAIN
HPSTrigger.java+71added 1.1
Initial Commit

hps-java/src/main/java/org/lcsim/hps/util
HPSTrigger.java added at 1.1
diff -N HPSTrigger.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HPSTrigger.java	11 Oct 2011 16:13:57 -0000	1.1
@@ -0,0 +1,71 @@
+
+package org.lcsim.hps.util;
+
+//--- Java ---//
+import java.util.ArrayList;
+import java.util.List;
+
+
+//--- org.lcsim ---//
+import org.lcsim.event.EventHeader;
+
+//--- hps-java ---//
+//import org.lcsim.hps.users.omoreno.tracking.HPSAPV25;
+import org.lcsim.util.Driver;
+
+
+/**
+ * Receives the ECal trigger signal and applies a trigger latency before
+ * sending the signal to other HPS detectors.
+ * Note: Currently, only the SVT is supported
+ * 
+ * @author Omar Moreno
+ * @version $Id: HPSTrigger.java,v 1.1 2011/10/11 16:13:57 omoreno Exp $
+ */
+public class HPSTrigger extends Driver {
+    
+    // Stores the trigger time stamp shifted by the trigger latency
+    public static final List<Double> trigger = new ArrayList<Double>();
+    
+    // Once the trigger latency is set, it should not change
+    public static final double triggerLatency = 80.0;  // ns
+    
+    /**
+     * Constructor
+     */
+    public HPSTrigger( ){ };
+    
+    /**
+     * Add a trigger signal to the queue
+     * 
+     */
+    public static void addTrigger( )
+    {
+       trigger.add( ClockSingleton.getTime() + triggerLatency );
+    }
+    
+    /**
+     * Checks if there has been a trigger signal sent on a event
+     * by event basis.  If a trigger signal has been sent and its
+     * timestamp, after applying the trigger latency, matches the
+     * system time, a trigger signal is sent to all HPS detectors.
+     * 
+     */
+    @Override
+    public void process(  EventHeader event  )
+    {
+        super.process(event);
+        
+        // Check if there are any pending triggers
+        if(  !( trigger.isEmpty() ) ){
+            if( ClockSingleton.getTime() == trigger.get( 0 ) ){
+                
+                // Send a trigger signal to the SVT
+                System.out.println(  "System has been triggered." );
+//                HPSAPV25._trigger_bit = true;
+                trigger.remove( 0 );
+            }
+        } 
+        
+    }    
+}
CVSspam 0.2.8