Print

Print


Author: [log in to unmask]
Date: Tue Mar 17 15:14:49 2015
New Revision: 2475

Log:
Added an option for the GTP clusterer to read from the DAQ configuration to acquire its settings. This is disabled by default. Activating this setting means that the GTP clusterer will not produce clusters until the DAQ configuration is initialized.

Modified:
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPOnlineClusterDriver.java

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPOnlineClusterDriver.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPOnlineClusterDriver.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPOnlineClusterDriver.java	Tue Mar 17 15:14:49 2015
@@ -1,4 +1,11 @@
 package org.hps.recon.ecal.cluster;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import org.hps.recon.ecal.daqconfig.ConfigurationManager;
+import org.hps.recon.ecal.daqconfig.GTPConfig;
+import org.lcsim.event.EventHeader;
 
 /**
  * Class <code>GTPOnlineClusterDriver</code> allows parameters for the
@@ -7,16 +14,49 @@
  * @author Kyle McCarty <[log in to unmask]>
  */
 public class GTPOnlineClusterDriver extends ClusterDriver {
-    // Store the clustering algorithm.
     private final GTPOnlineClusterer gtp;
+    private boolean useDAQConfig = false;
     
     /**
      * Instantiates a new clustering algorithm using the readout
      * variant of the GTP clustering algorithm.
      */
     public GTPOnlineClusterDriver() {
+    	// Instantiate the clusterer.
         clusterer = ClustererFactory.create("GTPOnlineClusterer");
         gtp = (GTPOnlineClusterer) clusterer;
+        
+        // Track the DAQ configuration status.
+        ConfigurationManager.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				// If DAQ configuration settings should be used, then
+				// update the clusterer.
+				if(useDAQConfig) {
+					// Get the GTP settings.
+					GTPConfig config = ConfigurationManager.getInstance().getGTPConfig();
+					
+					// Send the DAQ configuration settings to the clusterer.
+					gtp.setSeedLowThreshold(config.getSeedEnergyCutConfig().getLowerBound());
+					gtp.setWindowAfter(config.getTimeWindowAfter());
+					gtp.setWindowBefore(config.getTimeWindowBefore());
+					
+					// Print the updated settings.
+					logSettings();
+				}
+			}
+        });
+    }
+    
+    @Override
+    public void process(EventHeader event) {
+    	// Only process an event if either the DAQ configuration is not
+    	// in use or if it has been initialized.
+    	if((useDAQConfig && ConfigurationManager.isInitialized()) || !useDAQConfig) {
+    		super.process(event);
+    	} else {
+    		System.out.println("GTP Clusterer :: Skipping event; DAQ configuration is not initialized.");
+    	}
     }
     
     /**
@@ -25,19 +65,7 @@
     @Override
     public void startOfData() {
     	// VERBOSE :: Output the driver settings.
-    	if(gtp.isVerbose()) {
-			// Print the cluster driver header.
-			System.out.println();
-			System.out.println();
-			System.out.println("======================================================================");
-			System.out.println("=== GTP Readout Clusterer Settings ===================================");
-			System.out.println("======================================================================");
-			
-			// Output the driver settings.
-			System.out.printf("Seed Energy Threshold :: %.3f GeV%n", gtp.getSeedLowThreshold());
-			System.out.printf("Time Window (Before)  :: %.0f ns%n", gtp.getWindowBefore());
-			System.out.printf("Time Window (After)   :: %.0f ns%n", gtp.getWindowAfter());
-    	}
+    	if(gtp.isVerbose()) { logSettings(); }
     }
     
     /**
@@ -80,4 +108,28 @@
     public void setVerbose(boolean verbose) {
         gtp.setVerbose(verbose);
     }
+    
+    /**
+     * Sets whether GTP settings should be drawn from the EvIO data
+     * DAQ configuration or read from the steering file.
+     * @param state - <code>true</code> means that DAQ configuration
+     * will be used and <code>false</code> that it will not.
+     */
+    public void setUseDAQConfig(boolean state) {
+    	useDAQConfig = state;
+    }
+    
+    private void logSettings() {
+		// Print the cluster driver header.
+		System.out.println();
+		System.out.println();
+		System.out.println("======================================================================");
+		System.out.println("=== GTP Readout Clusterer Settings ===================================");
+		System.out.println("======================================================================");
+		
+		// Output the driver settings.
+		System.out.printf("Seed Energy Threshold :: %.3f GeV%n", gtp.getSeedLowThreshold());
+		System.out.printf("Time Window (Before)  :: %.0f ns%n", gtp.getWindowBefore());
+		System.out.printf("Time Window (After)   :: %.0f ns%n", gtp.getWindowAfter());
+    }
 }