LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  March 2015

HPS-SVN March 2015

Subject:

r2249 - /java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Thu, 5 Mar 2015 08:37:52 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (1509 lines)

Author: [log in to unmask]
Date: Thu Mar  5 00:37:41 2015
New Revision: 2249

Log:
Created an API for accessing parsed DAQ configuration data in a user friendly manner. This data can be accessed by running the DAQConfigDriver, preferably before any analysis code. The new structure creates a static class that can be accessed by any driver to get DAQ information easily, and also allows for drivers to register ActionListener objects with it so as to receive updates on when a new DAQ configuration is loaded. The static manager class will not give a DAQ configuration object before one is loaded as a failsafe against accidently using an 'empty' DAQ condiguration object. Eventually, more work will need to be done to clean up the TriggerConfig file and possibly fold it into the DAQConfigDriver. Additionally, note that TriggerConfig has been relocated to a new package, org.hps.readout.ecal.daqconfig, along with the new API classes.

Added:
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/AbstractConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ConfigurationManager.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/DAQConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/DAQConfigDriver.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ESBCutConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/FADCConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/IDAQConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/LBOCutConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/PairTriggerConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/SSPConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/SinglesTriggerConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/TriggerConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/UBOCutConfig.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ULBCutConfig.java

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/AbstractConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/AbstractConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/AbstractConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,83 @@
+package org.hps.readout.ecal.daqconfig;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Abstract class <code>AbstractCutConfig</code> holds a given number
+ * of values and allows implementing classes to access them. It also
+ * stores whether the configuration object is enabled.
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+abstract class AbstractConfig<E> {
+	// Store the cut values.
+	private final List<E> values;
+	private boolean enabled = false;
+	
+	/**
+	 * Instantiates an <code>AbstractConfig</code> with the indicated
+	 * number of values.
+	 * @param count - The number of values that the object should store.
+	 */
+	AbstractConfig(int count) {
+		// A configuration object must have at least one value.
+		if(count <= 0) {
+			throw new IllegalArgumentException("There must be at least one value.");
+		}
+		
+		// Instantiate the value array.
+		values = new ArrayList<E>(count);
+	}
+	
+	/**
+	 * Gets the value of the cut with the associated value ID.
+	 * @param valueIndex - The ID corresponding to the desired value.
+	 * @return Returns the value as a parameterized <code>E</code>
+	 * object.
+	 */
+	protected E getValue(int valueIndex) {
+		validateValueIndex(valueIndex);
+		return values.get(valueIndex);
+	}
+	
+	/**
+	 * Indicates whether the object is enabled or not.
+	 * @return Returns <code>true</code> if the object is enabled and
+	 * <code>false</code> otherwise.
+	 */
+	public boolean isEnabled() {
+		return enabled;
+	}
+	
+	/**
+	 * Sets the value corresponding to the argument value ID to a new
+	 * object.
+	 * @param valueIndex - The ID corresponding to the desired value.
+	 * @param value - The new value.
+	 */
+	protected void setValue(int valueIndex, E value) {
+		validateValueIndex(valueIndex);
+		values.set(valueIndex, value);
+	}
+	
+	/**
+	 * Sets whether the configuration object is enabled.
+	 * @param state <code>true</code> means that the object is enabled
+	 * and <code>false</code> that it is disabled.
+	 */
+	protected void setIsEnabled(boolean state) {
+		enabled = state;
+	}
+	
+	/**
+	 * Throws an exception if the argument index does not correspond to
+	 * any value.
+	 * @param index - The index to check.
+	 */
+	private final void validateValueIndex(int index) {
+		if(index < 0 || index >= values.size()) {
+			throw new IndexOutOfBoundsException("Value index \"" + index + "\" is invalid.");
+		}
+	}
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ConfigurationManager.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ConfigurationManager.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ConfigurationManager.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,100 @@
+package org.hps.readout.ecal.daqconfig;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Class <code>ConfigurationManager</code> provides static access to
+ * the DAQ configuration that can be parsed from EVIO files. It works
+ * in conjunction with the <code>DAQConfigDriver</code>, which obtains
+ * the configuration parser object when available and passes it to this
+ * manager, and <code>TriggerConfig</code>, which parses the EVIO data.
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ * @see DAQConfigDriver
+ * @see TriggerConfig
+ */
+public class ConfigurationManager {
+	// Store the configuration object.
+	private static final DAQConfig DAQ_CONFIG = new DAQConfig();
+	
+	// Track whether a DAQ configuration has been read yet.
+	private static boolean INITIALIZED = false;
+	
+	// Store listeners to alert other classes when an update occurs.
+	private static final List<ActionListener> AL_LIST = new ArrayList<ActionListener>();
+	private static final ActionEvent EVENT = new ActionEvent(DAQ_CONFIG, ActionEvent.RESERVED_ID_MAX + 12, "update");
+	
+	/**
+	 * Gets an instance of the DAQ configuration settings object if it
+	 * exists. If no configuration has been read, this will return
+	 * <code>null</code> instead.
+	 * @return Returns the DAQ settings as a <code>DAQConfig</code>
+	 * object or <code>null</code>.
+	 */
+	public static final DAQConfig getInstance() {
+		if(INITIALIZED) { return DAQ_CONFIG; }
+		else { return null; }
+	}
+	
+	/**
+	 * Adds a listener to track when updates occur in the DAQ settings.
+	 * @param listener - The listener.
+	 */
+	public static final void addActionListener(ActionListener listener) {
+		if(listener != null) { AL_LIST.add(listener); }
+	}
+	
+	/**
+	 * Gets the list of all listeners attached to the manager.
+	 * @return Returns a <code>List</code> collection containing the
+	 * <code>ActionListener</code> objects attached to the manager.
+	 */
+	public static final List<ActionListener> getActionListeners() {
+		return AL_LIST;
+	}
+	
+	/**
+	 * Indicates whether a DAQ configuration has been received yet.
+	 * If <code>false</code>, then calls to <code>getInstance</code>
+	 * will return <code>null</code>.
+	 * @return Returns <code>true</code> if a DAQ configuration has
+	 * been read and <code>false</code> otherwise.
+	 */
+	public static final boolean isInitialized() {
+		return INITIALIZED;
+	}
+	
+	/**
+	 * Removes an listener so that it will no longer receive updates
+	 * when the DAQ configuration changes.
+	 * @param listener - The listener to remove.
+	 */
+	public static final void removeActionListener(ActionListener listener) {
+		if(listener != null) { AL_LIST.remove(listener); }
+	}
+	
+	/**
+	 * Updates the DAQ configuration with the given EVIO parser. The
+	 * manager will also note that it is initialized and inform any
+	 * associated listeners that an update has occurred.
+	 * @param parser - The updated DAQ information.
+	 */
+	static final void updateConfiguration(TriggerConfig parser) {
+		DAQ_CONFIG.loadConfig(parser);
+		INITIALIZED = true;
+		updateListeners();
+	}
+	
+	/**
+	 * Sends an update event to all associated listeners.
+	 */
+	private static final void updateListeners() {
+		for(ActionListener al : AL_LIST) {
+			al.actionPerformed(EVENT);
+		}
+	}
+	
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/DAQConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/DAQConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/DAQConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,24 @@
+package org.hps.readout.ecal.daqconfig;
+
+
+public class DAQConfig extends IDAQConfig {
+	// Store the configuration objects.
+	private SSPConfig sspConfig = new SSPConfig();
+	private FADCConfig fadcConfig = new FADCConfig();
+	
+	@Override
+	void loadConfig(TriggerConfig parser) {
+		// Pass the configuration parser to the system-specific objects.
+		sspConfig.loadConfig(parser);
+		fadcConfig.loadConfig(parser);
+	}
+
+	@Override
+	public void printConfig() {
+		// Print the system-specific objects.
+		fadcConfig.printConfig();
+		System.out.println();
+		sspConfig.printConfig();
+	}
+	
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/DAQConfigDriver.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/DAQConfigDriver.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/DAQConfigDriver.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,29 @@
+package org.hps.readout.ecal.daqconfig;
+
+import java.util.List;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+
+public class DAQConfigDriver extends Driver {
+	
+	@Override
+	public void process(EventHeader event) {
+		// Check if a trigger configuration bank exists.
+		if(event.hasCollection(TriggerConfig.class, "TriggerConfig")) {
+			// Get the trigger configuration bank. There should only be
+			// one in the list.
+			List<TriggerConfig> configList = event.get(TriggerConfig.class, "TriggerConfig");
+			TriggerConfig daqConfig = configList.get(0);
+			
+			// Perform a debug print of the configuration to test that
+			// it is being read properly.
+			daqConfig.printVars();
+			
+			// Get the DAQ configuration and update it with the new
+			// configuration object.
+			ConfigurationManager.updateConfiguration(daqConfig);
+		}
+	}
+	
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ESBCutConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ESBCutConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ESBCutConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,52 @@
+package org.hps.readout.ecal.daqconfig;
+
+/**
+ * Class <code>ESBCutConfig</code> is an implementation of the abstract
+ * <code>AbstractCutConfig</code> for cuts the energy slope cut. It
+ * stores both the cut lower bound and the parameter F used in the slope
+ * equation. These values may also be set by classes within the same
+ * package.
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+public class ESBCutConfig extends AbstractConfig<Double> {
+	private static final int ENERGY_SLOPE_THRESHOLD = 0;
+	private static final int PARAMETER_F = 1;
+	
+	/**
+	 * Instantiates a new <code>ESBCutConfig</code> object.
+	 */
+	ESBCutConfig() { super(2); }
+	
+	/**
+	 * Gets the lower bound of the cut.
+	 * @return Returns the lower bound as a <code>double</code>.
+	 */
+	public double getLowerBound() {
+		return getValue(ENERGY_SLOPE_THRESHOLD);
+	}
+	
+	/**
+	 * Gets the parameter F in the energy slope equation.
+	 * @return Returns the parameter as a <code>double</code>.
+	 */
+	public double getParameterF() {
+		return getValue(PARAMETER_F);
+	}
+	
+	/**
+	 * Sets the lower bound of the cut to the specified value.
+	 * @param value - The new lower bound for the cut.
+	 */
+	void setLowerBound(double value) {
+		setValue(ENERGY_SLOPE_THRESHOLD, value);
+	}
+	
+	/**
+	 * Sets the parameter F in the energy slope equation.
+	 * @param value - The new parameter for the cut.
+	 */
+	void setParameterF(double value) {
+		setValue(PARAMETER_F, value);
+	}
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/FADCConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/FADCConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/FADCConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,257 @@
+package org.hps.readout.ecal.daqconfig;
+
+import java.awt.Point;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hps.conditions.database.DatabaseConditionsManager;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+
+/**
+ * Class <code>FADCConfig</code> stores FADC configuration settings
+ * parsed from the an EVIO file. This class manages the following
+ * properties:
+ * <ul>
+ * <li>FADC Mode</li>
+ * <li>NSA</li>
+ * <li>NSB</li>
+ * <li>FADC Window Width</li>
+ * <li>FADC Window Time Offset</li>
+ * <li>Crystal Gains</li>
+ * <li>Crystal Thresholds</li>
+ * <li>Crystal Pedestals</li>
+ * </ul>
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+public class FADCConfig extends IDAQConfig {
+	// Store basic FADC information.
+	private int mode        = -1;
+	private int nsa         = -1;
+	private int nsb         = -1;
+	private int windowWidth = -1;
+	private int offset      = -1;
+	private int npeak       = -1;
+	
+	// Store a map of calorimeter channel number to crystal indices.
+	private Map<Point, Integer> indexChannelMap = new HashMap<Point, Integer>();
+	
+	// Store crystal calibrations and energy conversion factors.
+	private float[] gains = new float[443];
+	private float[] pedestals = new float[443];
+	private int[] thresholds = new int[443];
+	
+	@Override
+	void loadConfig(TriggerConfig parser) {
+		// Store the basic FADC information.
+		mode = parser.fadcMODE;
+		nsa = parser.fadcNSA;
+		nsb = parser.fadcNSB;
+		windowWidth = parser.fadcWIDTH;
+		offset = parser.fadcOFFSET;
+		npeak = parser.fadcNPEAK;       // TODO: Make this obtainable.
+		
+		// Get the channel collection from the database.
+		DatabaseConditionsManager database = DatabaseConditionsManager.getInstance();
+		EcalChannelCollection channels = database.getCollection(EcalChannelCollection.class);
+		
+		// Create a mapping of calorimeter crystal positions to their
+		// corresponding channels. Also place the mapped values into
+		// an array by their channel ID.
+		indexChannelMap.clear();
+		for(EcalChannel ecalChannel : channels) {
+			// Map the channel IDs to the crystal position.
+			int channel = ecalChannel.getChannelId();
+			int ix = ecalChannel.getX();
+			int iy = ecalChannel.getY();
+			indexChannelMap.put(new Point(ix, iy), new Integer(channel));
+			
+			// Place the mapped values into the arrays.
+			gains[ecalChannel.getChannelId()]      = parser.GAIN.get(ecalChannel);
+			pedestals[ecalChannel.getChannelId()]  = parser.PEDESTAL.get(ecalChannel);
+			thresholds[ecalChannel.getChannelId()] = parser.THRESHOLD.get(ecalChannel);
+		}
+	}
+	
+	/**
+	 * Gets the gain for a crystal.
+	 * @param channel - The channel object corresponding to the crystal.
+	 * @return Returns the gain as a <code>float</code>.
+	 */
+	public float getGain(EcalChannel channel) {
+		return getGain(channel.getChannelId());
+	}
+	
+	/**
+	 * Gets the gain for a crystal.
+	 * @param channelID - The channel ID corresponding to the crystal.
+	 * @return Returns the gain as a <code>float</code>.
+	 */
+	public float getGain(int channelID) {
+		validateChannelID(channelID);
+		return gains[channelID];
+	}
+	
+	/**
+	 * Gets the gain for a crystal.
+	 * @param ix - The x-index of the crystal.
+	 * @param iy - The y-index of the crystal.
+	 * @return Returns the gain as a <code>float</code>.
+	 */
+	public float getGain(int ix, int iy) {
+		return getGain(new Point(ix, iy));
+	}
+	
+	/**
+	 * Gets the gain for a crystal.
+	 * @param ixy - The a point representing the x/y-indices of the
+	 * crystal.
+	 * @return Returns the gain as a <code>float</code>.
+	 */
+	public float getGain(Point ixy) {
+		return getGain(indexChannelMap.get(ixy));
+	}
+	
+	/**
+	 * Gets the mode in which FADC data is written.
+	 * @return Returns the mode as an <code>int</code>; either 1, 3,
+	 * or 7.
+	 */
+	public int getMode() {
+		return mode;
+	}
+	
+	/**
+	 * Gets the number of samples (4 ns clock-cycles) that a pulse will
+	 * be integrated by the FADC after a threshold-crossing event.
+	 * @return Returns the samples as an <code>int</code> in clock-cycles.
+	 */
+	public int getNSA() {
+		return nsa;
+	}
+	
+	/**
+	 * Gets the number of samples (4 ns clock-cycles) that a pulse will
+	 * be integrated by the FADC before a threshold-crossing event.
+	 * @return Returns the samples as an <code>int</code> in clock-cycles.
+	 */
+	public int getNSB() {
+		return nsb;
+	}
+	
+	/**
+	 * Gets the pedestal for a crystal.
+	 * @param channel - The channel object corresponding to the crystal.
+	 * @return Returns the pedestal as a <code>float</code>.
+	 */
+	public float getPedestal(EcalChannel channel) {
+		return getPedestal(channel.getChannelId());
+	}
+	
+	/**
+	 * Gets the pedestal for a crystal.
+	 * @param channelID - The channel ID corresponding to the crystal.
+	 * @return Returns the pedestal as a <code>float</code>.
+	 */
+	public float getPedestal(int channelID) {
+		validateChannelID(channelID);
+		return pedestals[channelID];
+	}
+	
+	/**
+	 * Gets the pedestal for a crystal.
+	 * @param ix - The x-index of the crystal.
+	 * @param iy - The y-index of the crystal.
+	 * @return Returns the pedestal as a <code>float</code>.
+	 */
+	public float getPedestal(int ix, int iy) {
+		return getPedestal(new Point(ix, iy));
+	}
+	
+	/**
+	 * Gets the pedestal for a crystal.
+	 * @param ixy - The a point representing the x/y-indices of the
+	 * crystal.
+	 * @return Returns the pedestal as a <code>float</code>.
+	 */
+	public float getPedestal(Point ixy) {
+		return getPedestal(indexChannelMap.get(ixy));
+	}
+	
+	/**
+	 * Gets the threshold for a crystal.
+	 * @param channel - The channel object corresponding to the crystal.
+	 * @return Returns the threshold as a <code>int</code>.
+	 */
+	public int getThreshold(EcalChannel channel) {
+		return getThreshold(channel.getChannelId());
+	}
+	
+	/**
+	 * Gets the threshold for a crystal.
+	 * @param channelID - The channel ID corresponding to the crystal.
+	 * @return Returns the threshold as a <code>int</code>.
+	 */
+	public int getThreshold(int channelID) {
+		validateChannelID(channelID);
+		return thresholds[channelID];
+	}
+	
+	/**
+	 * Gets the threshold for a crystal.
+	 * @param ix - The x-index of the crystal.
+	 * @param iy - The y-index of the crystal.
+	 * @return Returns the threshold as a <code>int</code>.
+	 */
+	public int getThreshold(int ix, int iy) {
+		return getThreshold(new Point(ix, iy));
+	}
+	
+	/**
+	 * Gets the threshold for a crystal.
+	 * @param ixy - The a point representing the x/y-indices of the
+	 * crystal.
+	 * @return Returns the threshold as a <code>int</code>.
+	 */
+	public int getThreshold(Point ixy) {
+		return getThreshold(indexChannelMap.get(ixy));
+	}
+	
+	/**
+	 * Gets the length of the readout window for the FADC in nanoseconds.
+	 * @return Returns the window length.
+	 */
+	public int getWindowWidth() {
+		return windowWidth;
+	}
+	
+	/**
+	 * Gets the time in nanoseconds that the readout window is offset.
+	 * @return Returns the offset time in nanoseconds.
+	 */
+	public int getWindowOffset() {
+		return offset;
+	}
+	
+	@Override
+	public void printConfig() {
+		System.out.println("FADC Configuration:");
+		System.out.printf("\tMode          :: %d%n", mode);
+		System.out.printf("\tNSA           :: %d%n", nsa);
+		System.out.printf("\tNSB           :: %d%n", nsb);
+		System.out.printf("\tWindow Width  :: %d%n", windowWidth);
+		System.out.printf("\tWindow Offset :: %d%n", offset);
+	}
+	
+	/**
+	 * Throws an exception if the argument channel ID is not within
+	 * the allowed range.
+	 * @param channelID - The channel ID to validate.
+	 */
+	private static final void validateChannelID(int channelID) {
+		if(channelID < 1 || channelID > 442) {
+			throw new IndexOutOfBoundsException(String.format("Channel ID \"%d\" is invalid. Channel IDs must be between 1 and 442.", channelID));
+		}
+	}
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/IDAQConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/IDAQConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/IDAQConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,24 @@
+package org.hps.readout.ecal.daqconfig;
+
+
+/**
+ * Interface <code>DAQConfig</code> represents a configuration bank
+ * generated from the DAQ configuration bank. This requires that all
+ * implementing classes have the ability to load settings from the DAQ
+ * bank parser and also print their contents to the terminal.
+ * 
+ * @author Kyle McCarty
+ */
+abstract class IDAQConfig {
+	/**
+	 * Updates the stored settings based on the argument parser.
+	 * @param parser - The EVIO DAQ bank parser.
+	 */
+	abstract void loadConfig(TriggerConfig parser);
+	
+	/**
+	 * Prints a textual representation of the configuration bank to the
+	 * terminal.
+	 */
+	public abstract void printConfig();
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/LBOCutConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/LBOCutConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/LBOCutConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,34 @@
+package org.hps.readout.ecal.daqconfig;
+
+/**
+ * Class <code>LBOCutConfig</code> is an implementation of the abstract
+ * <code>AbstractCutConfig</code> for cuts that have only a lower bound.
+ * It provides the means to access this value and, for package classes,
+ * set it.
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+public class LBOCutConfig extends AbstractConfig<Double> {
+	private static final int LOWER_BOUND = 0;
+	
+	/**
+	 * Instantiates a new <code>LBOCutConfig</code> object.
+	 */
+	LBOCutConfig() { super(1); }
+	
+	/**
+	 * Gets the lower bound of the cut.
+	 * @return Returns the lower bound as a <code>double</code>.
+	 */
+	public double getLowerBound() {
+		return getValue(LOWER_BOUND);
+	}
+	
+	/**
+	 * Sets the lower bound of the cut to the specified value.
+	 * @param value - The new lower bound for the cut.
+	 */
+	void setLowerBound(double value) {
+		setValue(LOWER_BOUND, value);
+	}
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/PairTriggerConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/PairTriggerConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/PairTriggerConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,109 @@
+package org.hps.readout.ecal.daqconfig;
+
+/**
+ * Class <code>PairTriggerConfig</code> holds the configuration data
+ * for a pair trigger.
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+public class PairTriggerConfig extends AbstractConfig<AbstractConfig<Double>> {
+	private static final int CUT_ENERGY_MIN   = 0;
+	private static final int CUT_ENERGY_MAX   = 1;
+	private static final int CUT_HIT_COUNT    = 2;
+	private static final int CUT_ENERGY_SUM   = 3;
+	private static final int CUT_ENERGY_DIFF  = 4;
+	private static final int CUT_ENERGY_SLOPE = 5;
+	private static final int CUT_COPLANARITY  = 6;
+	private static final int CUT_TIME_DIFF    = 7;
+	
+	/**
+	 * Creates a new <code>PairTriggerConfig</code> object.
+	 */
+	PairTriggerConfig() {
+		// Instantiate the superclass.
+		super(6);
+		
+		// Define the pair cuts.
+		setValue(CUT_ENERGY_MIN,   new LBOCutConfig());
+		setValue(CUT_ENERGY_MAX,   new UBOCutConfig());
+		setValue(CUT_HIT_COUNT,    new LBOCutConfig());
+		setValue(CUT_ENERGY_SUM,   new ULBCutConfig());
+		setValue(CUT_ENERGY_DIFF,  new UBOCutConfig());
+		setValue(CUT_ENERGY_SLOPE, new ESBCutConfig());
+		setValue(CUT_COPLANARITY,  new UBOCutConfig());
+		setValue(CUT_TIME_DIFF,    new UBOCutConfig());
+	}
+	
+	/**
+	 * Gets the configuration object for the cluster energy lower bound
+	 * cut. Note that cuts are in units of GeV.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public LBOCutConfig getEnergyMinCutConfig() {
+		return (LBOCutConfig) getValue(CUT_ENERGY_MIN);
+	}
+	
+	/**
+	 * Gets the configuration object for the cluster energy upper bound
+	 * cut. Note that cuts are in units of GeV.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public UBOCutConfig getEnergyMaxCutConfig() {
+		return (UBOCutConfig) getValue(CUT_ENERGY_MAX);
+	}
+	
+	/**
+	 * Gets the configuration object for the cluster hit count cut.
+	 * Note that cuts are in units of calorimeter hits.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public LBOCutConfig getHitCountCutConfig() {
+		return (LBOCutConfig) getValue(CUT_HIT_COUNT);
+	}
+	
+	/**
+	 * Gets the configuration object for the pair energy sum cut. Note
+	 * that cuts are in units of GeV.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public ULBCutConfig getEnergySumCutConfig() {
+		return (ULBCutConfig) getValue(CUT_ENERGY_SUM);
+	}
+	
+	/**
+	 * Gets the configuration object for the pair energy difference
+	 * cut. Note that cuts are in units of GeV.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public UBOCutConfig getEnergyDifferenceCutConfig() {
+		return (UBOCutConfig) getValue(CUT_ENERGY_DIFF);
+	}
+	
+	/**
+	 * Gets the configuration object for the pair energy slope cut.
+	 * Note that cuts are in units of GeV and mm.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public ESBCutConfig getEnergySlopeCutConfig() {
+		return (ESBCutConfig) getValue(CUT_ENERGY_SLOPE);
+	}
+	
+	/**
+	 * Gets the configuration object for the pair coplanarity cut.
+	 * Note that cuts are in units of degrees.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public UBOCutConfig getCoplanarityCutConfig() {
+		return (UBOCutConfig) getValue(CUT_COPLANARITY);
+	}
+	
+	/**
+	 * Gets the configuration object for the pair time coincidence cut.
+	 * Note that cuts are in units of nanoseconds.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public UBOCutConfig getTimeDifferenceCutConfig() {
+		return (UBOCutConfig) getValue(CUT_TIME_DIFF);
+	}
+	
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/SSPConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/SSPConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/SSPConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,161 @@
+package org.hps.readout.ecal.daqconfig;
+
+
+/**
+ * Class <code>SSPConfig</code> stores SSP configuration settings
+ * parsed from the an EVIO file. This class manages the following
+ * properties:
+ * <ul>
+ * <li>Singles 1 Trigger</li>
+ * <li>Singles 2 Trigger</li>
+ * <li>Pair 1 Trigger</li>
+ * <li>Pair 2 Trigger</li>
+ * </ul>
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+public class SSPConfig extends IDAQConfig {
+	// Store trigger configuration parameters.
+	private PairTriggerConfig[] pairTrigger = { new PairTriggerConfig(), new PairTriggerConfig() };
+	private SinglesTriggerConfig[] singlesTrigger = { new SinglesTriggerConfig(), new SinglesTriggerConfig() };
+	
+	@Override
+	void loadConfig(TriggerConfig parser) {
+		// Set the trigger parameters.
+		for(int triggerNum = 0; triggerNum < 2; triggerNum++) {
+			// Set whether the triggers are enabled or not.
+			singlesTrigger[triggerNum].setIsEnabled(parser.singlesEn[triggerNum]);
+			pairTrigger[triggerNum].setIsEnabled(parser.pairsEn[triggerNum]);
+			
+			// Set the cut enabled statuses for the singles trigger.
+			singlesTrigger[triggerNum].getEnergyMinCutConfig().setIsEnabled(parser.singlesEnergyMinEn[triggerNum]);
+			singlesTrigger[triggerNum].getEnergyMaxCutConfig().setIsEnabled(parser.singlesEnergyMaxEn[triggerNum]);
+			singlesTrigger[triggerNum].getHitCountCutConfig().setIsEnabled(parser.singlesNhitsEn[triggerNum]);
+			
+			// The pair trigger singles cuts are always enabled.
+			pairTrigger[triggerNum].getEnergyMinCutConfig().setIsEnabled(true);
+			pairTrigger[triggerNum].getEnergyMaxCutConfig().setIsEnabled(true);
+			pairTrigger[triggerNum].getHitCountCutConfig().setIsEnabled(true);
+			
+			// Set the pair cut enabled statuses for the pair trigger.
+			pairTrigger[triggerNum].getEnergySumCutConfig().setIsEnabled(parser.pairsEnergySumMinEn[triggerNum]);
+			pairTrigger[triggerNum].getEnergyDifferenceCutConfig().setIsEnabled(parser.pairsEnergyDiffEn[triggerNum]);
+			pairTrigger[triggerNum].getEnergySlopeCutConfig().setIsEnabled(parser.pairsEnergyDistEn[triggerNum]);
+			pairTrigger[triggerNum].getCoplanarityCutConfig().setIsEnabled(parser.pairsCoplanarityEn[triggerNum]);
+			pairTrigger[triggerNum].getTimeDifferenceCutConfig().setIsEnabled(parser.pairsTimeDiffEn[triggerNum]);
+			
+			// Set the individual cut values.
+			singlesTrigger[triggerNum].getEnergyMinCutConfig().setLowerBound(parser.singlesEnergyMin[triggerNum] / 1000.0);
+			singlesTrigger[triggerNum].getEnergyMaxCutConfig().setUpperBound(parser.singlesEnergyMax[triggerNum] / 1000.0);
+			singlesTrigger[triggerNum].getHitCountCutConfig().setLowerBound(parser.singlesNhits[triggerNum]);
+			
+			// Set the individual cut values.
+			pairTrigger[triggerNum].getEnergyMinCutConfig().setLowerBound(parser.pairsEnergyMin[triggerNum] / 1000.0);
+			pairTrigger[triggerNum].getEnergyMaxCutConfig().setUpperBound(parser.pairsEnergyMax[triggerNum] / 1000.0);
+			//pairTrigger[triggerNum].getHitCountCutConfig().setLowerBound(parser.pairsNhits[triggerNum]);
+			pairTrigger[triggerNum].getEnergySumCutConfig().setLowerBound(parser.pairsEnergySumMin[triggerNum] / 1000.0);
+			pairTrigger[triggerNum].getEnergySumCutConfig().setUpperBound(parser.pairsEnergySumMax[triggerNum] / 1000.0);
+			pairTrigger[triggerNum].getEnergyDifferenceCutConfig().setUpperBound(parser.pairsEnergyDiffMax[triggerNum] / 1000.0);
+			pairTrigger[triggerNum].getEnergySlopeCutConfig().setLowerBound(parser.pairsEnergyDistMin[triggerNum] / 1000.0);
+			pairTrigger[triggerNum].getEnergySlopeCutConfig().setParameterF(parser.pairsEnergyDistSlope[triggerNum] / 1000.0);
+			pairTrigger[triggerNum].getCoplanarityCutConfig().setUpperBound(parser.pairsCoplanarityMax[triggerNum]);
+			pairTrigger[triggerNum].getTimeDifferenceCutConfig().setUpperBound(parser.pairsTimeDiffMax[triggerNum]);
+		}
+	}
+	
+	/**
+	 * Gets the configuration parameters for the first singles trigger.
+	 * @return Returns the first singles trigger configuration.
+	 */
+	public SinglesTriggerConfig getSingles1Config() {
+		return singlesTrigger[0];
+	}
+	
+	/**
+	 * Gets the configuration parameters for the second singles trigger.
+	 * @return Returns the second singles trigger configuration.
+	 */
+	public SinglesTriggerConfig getSingles2Config() {
+		return singlesTrigger[1];
+	}
+	
+	/**
+	 * Gets the configuration parameters for the first pair trigger.
+	 * @return Returns the first pair trigger configuration.
+	 */
+	public PairTriggerConfig getPair1Config() {
+		return pairTrigger[0];
+	}
+	
+	/**
+	 * Gets the configuration parameters for the second pair trigger.
+	 * @return Returns the second trigger trigger configuration.
+	 */
+	public PairTriggerConfig getPair2Config() {
+		return pairTrigger[1];
+	}
+	
+	@Override
+	public void printConfig() {
+		// Print the configuration header.
+		System.out.println("SSP Configuration:");
+		
+		// Print the singles triggers.
+		for(int triggerNum = 0; triggerNum < 2; triggerNum++) {
+			System.out.printf("\tSingles Trigger %d%n", (triggerNum + 1));
+			System.out.println("\t\tCluster Energy Lower Bound Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", singlesTrigger[triggerNum].getEnergyMinCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %5.3f GeV%n", singlesTrigger[triggerNum].getEnergyMinCutConfig().getLowerBound());
+			
+			System.out.println("\t\tCluster Energy Upper Bound Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", singlesTrigger[triggerNum].getEnergyMaxCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %5.3f GeV%n", singlesTrigger[triggerNum].getEnergyMaxCutConfig().getUpperBound());
+			
+			System.out.println("\t\tCluster Hit Count Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", singlesTrigger[triggerNum].getHitCountCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %1.0f hits%n", singlesTrigger[triggerNum].getHitCountCutConfig().getLowerBound());
+			System.out.println();
+		}
+		
+		// Print the pair triggers.
+		for(int triggerNum = 0; triggerNum < 2; triggerNum++) {
+			System.out.printf("\tPair Trigger %d%n", (triggerNum + 1));
+			System.out.println("\t\tCluster Energy Lower Bound Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", pairTrigger[triggerNum].getEnergyMinCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %5.3f GeV%n", pairTrigger[triggerNum].getEnergyMinCutConfig().getLowerBound());
+			
+			System.out.println("\t\tCluster Energy Upper Bound Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", pairTrigger[triggerNum].getEnergyMaxCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %5.3f GeV%n", pairTrigger[triggerNum].getEnergyMaxCutConfig().getUpperBound());
+			
+			System.out.println("\t\tCluster Hit Count Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", pairTrigger[triggerNum].getHitCountCutConfig().isEnabled());
+			//System.out.printf("\t\t\tValue   :: %1.0f hits%n", pairTrigger[triggerNum].getHitCountCutConfig().getLowerBound());
+			System.out.printf("\t\t\tValue   :: ??? hits%n");
+			
+			System.out.println("\t\tPair Energy Sum Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", pairTrigger[triggerNum].getEnergySumCutConfig().isEnabled());
+			System.out.printf("\t\t\tMin     :: %5.3f GeV%n", pairTrigger[triggerNum].getEnergySumCutConfig().getLowerBound());
+			System.out.printf("\t\t\tMax     :: %5.3f GeV%n", pairTrigger[triggerNum].getEnergySumCutConfig().getUpperBound());
+			
+			System.out.println("\t\tPair Energy Difference Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", pairTrigger[triggerNum].getEnergyDifferenceCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %5.3f GeV%n", pairTrigger[triggerNum].getEnergyDifferenceCutConfig().getUpperBound());
+			
+			System.out.println("\t\tPair Energy Slope Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", pairTrigger[triggerNum].getEnergySlopeCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %5.3f GeV%n", pairTrigger[triggerNum].getEnergySlopeCutConfig().getLowerBound());
+			System.out.printf("\t\t\tParam F :: %6.4f GeV/mm%n", pairTrigger[triggerNum].getEnergySlopeCutConfig().getParameterF());
+			
+			System.out.println("\t\tPair Coplanarity Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", pairTrigger[triggerNum].getCoplanarityCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %3.0f degrees%n", pairTrigger[triggerNum].getCoplanarityCutConfig().getUpperBound());
+			
+			System.out.println("\t\tPair Time Coincidence Cut");
+			System.out.printf("\t\t\tEnabled :: %b%n", pairTrigger[triggerNum].getTimeDifferenceCutConfig().isEnabled());
+			System.out.printf("\t\t\tValue   :: %1.0f clock-cycles%n", pairTrigger[triggerNum].getTimeDifferenceCutConfig().getUpperBound());
+			System.out.println();
+		}
+	}
+	
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/SinglesTriggerConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/SinglesTriggerConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/SinglesTriggerConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,53 @@
+package org.hps.readout.ecal.daqconfig;
+
+/**
+ * Class <code>SinglesTriggerConfig</code> holds the configuration data
+ * for a singles trigger.
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+public class SinglesTriggerConfig extends AbstractConfig<AbstractConfig<Double>> {
+	private static final int CUT_ENERGY_MIN = 0;
+	private static final int CUT_ENERGY_MAX = 1;
+	private static final int CUT_HIT_COUNT  = 2;
+	
+	/**
+	 * Creates a new <code>SinglesTriggerConfig</code> object.
+	 */
+	SinglesTriggerConfig() {
+		// Instantiate the base object.
+		super(3);
+		
+		// Define the singles cuts.
+		setValue(CUT_ENERGY_MIN, new LBOCutConfig());
+		setValue(CUT_ENERGY_MAX, new UBOCutConfig());
+		setValue(CUT_HIT_COUNT,  new LBOCutConfig());
+	}
+	
+	/**
+	 * Gets the configuration object for the cluster energy lower bound
+	 * cut. Note that cuts are in units of GeV.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public LBOCutConfig getEnergyMinCutConfig() {
+		return (LBOCutConfig) getValue(CUT_ENERGY_MIN);
+	}
+	
+	/**
+	 * Gets the configuration object for the cluster energy upper bound
+	 * cut. Note that cuts are in units of GeV.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public UBOCutConfig getEnergyMaxCutConfig() {
+		return (UBOCutConfig) getValue(CUT_ENERGY_MAX);
+	}
+	
+	/**
+	 * Gets the configuration object for the cluster hit count cut.
+	 * Note that cuts are in units of calorimeter hits.
+	 * @return Returns the configuration object for the cut.
+	 */
+	public LBOCutConfig getHitCountCutConfig() {
+		return (LBOCutConfig) getValue(CUT_HIT_COUNT);
+	}
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/TriggerConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/TriggerConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/TriggerConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,390 @@
+package org.hps.readout.ecal.daqconfig;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hps.conditions.database.DatabaseConditionsManager;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalConditions;
+
+public class TriggerConfig {
+
+    /*
+     * Read/Parse/Save the DAQ trigger configuration settings.
+     * These settings arrive in multiple banks, but they *should* be in the same event.
+     *
+     * Currently this is set up to read SSP and ECAL configurations,
+     * which is all that is currently available in EVIO as of Feb 28, 2015.
+     * 
+     * GTP settings and Prescale factors will need to be added to this class when added to EVIO.
+     *
+     * TODO: Error in EVIO format for Crate 39 for 2014 data requires another JEVIO workaround (realized Feb 16).
+     *       ** This was fixed in EVIO for data after run 4044.
+     *       
+     * TODO: Manually put in GTP settings based on run number for 2014 data.
+     * TODO: Manually deal with change in format of SSP_HPS_SINGLES_NMIN (at 3312(?)).
+     *
+     * TODO: Restructure, clean up..
+     *  
+     *  @author <[log in to unmask]>
+     */
+  
+    public int nBanks=0;
+    
+    public static final int BANK_TAG = 0xE10E;
+  
+    // need to know these in order to interpret DAQ strings:
+    private static final int[] singlesIOsrc={20,21};
+    private static final int[] pairsIOsrc={22,23};
+  
+	// Dump everything read from the DAQ Configuration Bank, minimal interpretation:
+	public Map<String,List<String>> configMap=new HashMap<String,List<String>>();
+  
+	// link ECAL FADC channel settings to EcalChannels:
+	public Map<EcalChannel,Float> GAIN=new HashMap<EcalChannel,Float>();
+	public Map<EcalChannel,Float> PEDESTAL=new HashMap<EcalChannel,Float>();
+	public Map<EcalChannel,Integer> THRESHOLD=new HashMap<EcalChannel,Integer>();
+	
+//	private boolean debug=true;
+	private boolean debug=false;
+
+	// FADC Config:
+	public int fadcNSA=0;
+	public int fadcNSB=0;
+	public int fadcNPEAK=0;
+	public int fadcMODE=0;
+	public int fadcWIDTH=0;
+	public int fadcOFFSET=0;
+
+	// GTP Clustering Cut Values:
+	public int clusterMinSeedEnergy=0;
+	public int clusterMinHitTimeDiff=0;
+	public int clusterMaxHitTimeDiff=0;
+	
+	// Triggers Enabled:
+	public boolean[] singlesEn={false,false};
+	public boolean[] pairsEn={false,false};
+
+	// Singles Cuts Enabled:
+	public boolean[] singlesNhitsEn={false,false};
+	public boolean[] singlesEnergyMinEn={false,false};
+	public boolean[] singlesEnergyMaxEn={false,false};
+	
+	// Pairs Cuts Enabled:
+	public boolean[] pairsEnergySumMinEn={false,false};
+	public boolean[] pairsEnergySumMaxEn={false,false};
+	public boolean[] pairsEnergyDiffEn={false,false};
+	public boolean[] pairsCoplanarityEn={false,false};
+	public boolean[] pairsEnergyDistEn={false,false};
+	public boolean[] pairsTimeDiffEn={false,false};
+	
+	// Singles Cut Values:
+	public int[] singlesNhits={0,0};
+	public int[] singlesEnergyMin={0,0};
+	public int[] singlesEnergyMax={0,0};
+	
+	// Pairs Cut Values:
+	public int[] pairsEnergyMin={0,0};
+	public int[] pairsEnergyMax={0,0};
+	public int[] pairsEnergySumMin={0,0};
+	public int[] pairsEnergySumMax={0,0};
+	public int[] pairsEnergyDiffMax={0,0};
+	public int[] pairsCoplanarityMax={0,0};
+	public int[] pairsTimeDiffMax={0,0};
+	public int[] pairsEnergyDistMin={0,0};
+	
+	// Pairs Cut Parameters:
+	public float[] pairsEnergyDistSlope={0,0};
+
+	// Have to remember the previous slot line in order to interpret the data:
+	private int thisFadcSlot=0;
+
+	// Cache local set of EcalChannels:
+    private EcalConditions ecalConditions = null;
+    private List<EcalChannel> channels=new ArrayList<EcalChannel>();
+    
+    public TriggerConfig() {
+        ecalConditions = DatabaseConditionsManager.getInstance().getEcalConditions();
+        for (int ii = 0; ii < 442; ii++) {
+            channels.add(findChannel(ii+1));
+        } 
+	}
+    
+    public void parse(int crate,int runNumber,String[] dump) {
+        
+        nBanks++;
+        
+        loadConfigMap(crate,dump); 
+    	if (debug) printMap();
+        fixConfigMap2014Run(runNumber);
+        parseConfigMap();
+        
+        if (nBanks==3) printVars();
+    }
+
+    public void parseConfigMap()
+    {
+//        System.err.println("PARSECONFIGMAP ..................");
+       
+        fadcNSA=Integer.valueOf(getConfig("FADC250_NSA",0));
+        fadcNSB=Integer.valueOf(getConfig("FADC250_NSB",0));
+        fadcNPEAK=Integer.valueOf(getConfig("FADC250_NPEAK",0));
+        fadcMODE=Integer.valueOf(getConfig("FADC250_MODE",0));
+        fadcWIDTH=Integer.valueOf(getConfig("FADC250_W_WIDTH",0));
+        fadcOFFSET=Integer.valueOf(getConfig("FADC250_W_OFFSET",0));
+        
+        clusterMinSeedEnergy=Integer.valueOf(getConfig("GTP_CLUSTER_THRESH",0));
+        clusterMinHitTimeDiff=Integer.valueOf(getConfig("GTP_TIMEDIFF",0));
+        clusterMaxHitTimeDiff=Integer.valueOf(getConfig("GTP_TIMEDIFF",1));
+       
+        for (int ii=0; ii<2; ii++) {
+            //singlesEn[ii]=getBoolConfigSSP(ii,"SINGLES_EN",0);
+            //pairsEn[ii]=getBoolConfigSSP(ii,"PAIRS_EN",0);
+            
+            singlesNhitsEn[ii]=getBoolConfigSSP(ii,"SINGLES_NMIN",1);
+            singlesEnergyMinEn[ii]=getBoolConfigSSP(ii,"SINGLES_EMIN",1);
+            singlesEnergyMaxEn[ii]=getBoolConfigSSP(ii,"SINGLES_EMAX",1);
+
+            pairsEnergySumMinEn[ii]=getBoolConfigSSP(ii,"PAIRS_SUMMAX_MIN",2);
+            pairsEnergySumMaxEn[ii]=getBoolConfigSSP(ii,"PAIRS_SUMMAX_MIN",2);
+            pairsEnergyDiffEn[ii]=getBoolConfigSSP(ii,"PAIRS_DIFFMAX",1);
+            pairsCoplanarityEn[ii]=getBoolConfigSSP(ii,"PAIRS_COPLANARITY",1);
+            pairsEnergyDistEn[ii]=getBoolConfigSSP(ii,"PAIRS_ENERGYDIST",1);
+            //pairsTimeDiffEn[ii]=getBoolConfigSSP(ii,"PAIRS_TIMECOINCIDENCE",0);
+            //pairsEnergyMin[ii]=getIntConfigSSP(ii,"PAIRS_EMIN",0);
+            //pairsEnergyMax[ii]=getIntConfigSSP(ii,"PAIRS_EMAX",0);
+
+            singlesNhits[ii]=getIntConfigSSP(ii,"SINGLES_NMIN",0);
+            singlesEnergyMin[ii]=getIntConfigSSP(ii,"SINGLES_EMIN",0);
+            singlesEnergyMax[ii]=getIntConfigSSP(ii,"SINGLES_EMAX",0);
+
+            pairsEnergyMin[ii]=getIntConfigSSP(ii,"PAIRS_EMIN",0);
+            pairsEnergyMax[ii]=getIntConfigSSP(ii,"PAIRS_EMAX",0);
+            pairsEnergySumMin[ii]=getIntConfigSSP(ii,"PAIRS_SUMMAX_MIN",1);
+            pairsEnergySumMax[ii]=getIntConfigSSP(ii,"PAIRS_SUMMAX_MIN",0);
+            pairsEnergyDiffMax[ii]=getIntConfigSSP(ii,"PAIRS_DIFFMAX",0);
+            pairsCoplanarityMax[ii]=getIntConfigSSP(ii,"PAIRS_COPLANARITY",0);
+            pairsTimeDiffMax[ii]=getIntConfigSSP(ii,"PAIRS_TIMECOINCIDENCE",0);
+            pairsEnergyDistSlope[ii]=getFloatConfigSSP(ii,"PAIRS_ENERGYDIST",0);
+            pairsEnergyDistMin[ii]=getIntConfigSSP(ii,"PAIRS_ENERGYDIST",1);
+        }
+//        System.err.println("DONE PARSECONFIGMAP.");
+    }
+    
+   
+      
+    private void fixConfigMap2014Run(int runNumber) {
+        if (runNumber>3470 || runNumber < 3100) return;
+     	// TODO: port datacat/python/engrun/engrun_metadata.py
+        // 1. SET GTP SETTINGS MANUALLY BASED ON RUN NUMBER
+        // 2. FIX SINGLES_NMIN prior to 3312
+    	for (String key : configMap.keySet()) {
+    	}
+    	List<String> tmp=new ArrayList<String>();
+    	tmp.add("0");
+    	tmp.add("0");
+    	tmp.add("0");
+    	tmp.add("0");
+    	configMap.put("GTP_CLUSTER_THRESH",tmp);
+    	configMap.put("GTP_TIMEDIFF",tmp);
+    }
+    
+    private void parseFADC(int crate,String key,List<String> vals)
+    {
+//        System.err.println(crate);
+        if (key.equals("FADC250_SLOT")) {
+            thisFadcSlot=Integer.valueOf(vals.get(0));
+        }
+        else if (key.equals("FADC250_ALLCH_TET")) {
+            setChannelParsInt(crate,thisFadcSlot,THRESHOLD,vals);
+        }
+        else if (key.equals("FADC250_ALLCH_PED")) {
+            setChannelParsFloat(crate,thisFadcSlot,PEDESTAL,vals);    
+        }
+        else if (key.equals("FADC250_ALLCH_GAIN")) {
+            setChannelParsFloat(crate,thisFadcSlot,GAIN,vals);
+        }
+    }
+   
+    private void setChannelParsFloat(int crate,int slot,Map<EcalChannel,Float>map, List<String> vals)
+    {
+        for (int ii=0; ii<16; ii++) {
+            map.put(findChannel(crate,slot,ii),Float.valueOf(vals.get(ii)));
+        }
+    }
+    private void setChannelParsInt(int crate,int slot,Map<EcalChannel,Integer>map, List<String> vals)
+    {
+        for (int ii=0; ii<16; ii++) {
+            map.put(findChannel(crate,slot,ii),Integer.valueOf(vals.get(ii)));
+        }
+    }
+    
+    private void loadConfigMap(int crate,String[] dump) {
+  
+        for (String dump1 : dump) {
+            for (String line : dump1.trim().split("\n")) {
+
+                String[] cols=line.trim().split(" +",2);
+                if (cols.length < 2) continue;
+
+                String key=cols[0];
+                List<String> vals=new ArrayList<String>
+                    (Arrays.asList(cols[1].trim().split(" +")));
+
+                if (vals.size() < 1) {
+                	continue;
+                }
+                
+                if (key.startsWith("FADC250")) {
+                    parseFADC(crate,key.trim(),vals);
+                }
+                else if (key.startsWith("SSP_HPS_SET_IO_SRC")) {
+                    for (int ii=0; ii<pairsIOsrc.length; ii++)
+                    {
+                        int trig = Integer.valueOf(vals.get(1));
+                        if (trig == singlesIOsrc[ii]) {
+                            singlesEn[ii]=true;
+                        }
+                        else if (trig == pairsIOsrc[ii]) {
+                            pairsEn[ii]=true;
+                        }
+                    }
+                }
+                
+                // Append trigger# onto key:
+                if (vals.size() > 1 && key.startsWith("SSP"))
+                {
+                    key += "_"+vals.remove(0);
+                }
+               
+                // dump it into the map:
+                configMap.put(key,vals);
+            }
+        }
+    }
+    
+    public void printMap() {
+        System.err.print("\nTriggerConfigMap::::::::::::::::::::::::::::\n");
+        for (String key : configMap.keySet()) {
+            System.err.printf("%s: ",key);
+            for (String val : configMap.get(key)) {
+                System.err.printf("%s ",val);
+            }
+            System.err.printf("\n");
+        }
+        System.err.println("::::::::::::::::::::::::::::::::::::::::::::");
+    }
+
+    public void printVars()
+	{
+        System.err.println("\nTriggerConfigVars%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
+        System.err.println();
+	    System.err.println(String.format("GTPMINSEED: %d",clusterMinSeedEnergy));
+	    System.err.println(String.format("GTPMINHITDT: %d",clusterMinHitTimeDiff));
+	    System.err.println(String.format("GTPMAXHITDT: %d",clusterMaxHitTimeDiff));
+	    System.err.println();
+	    System.err.println(String.format("FADC250_NSA: %d",fadcNSA));
+	    System.err.println(String.format("FADC250_NSB: %d",fadcNSB));
+	    System.err.println(String.format("FADC250_NPEAK: %d",fadcNPEAK));
+	    System.err.println(String.format("FADC250_MODE: %d",fadcMODE));
+	    System.err.println(String.format("FADC250_WIDTH: %d",fadcWIDTH));
+	    System.err.println(String.format("FADC250_OFFSET: %d",fadcOFFSET));
+        for (EcalChannel cc : ecalConditions.getChannelCollection()) {
+            //System.err.print(String.format("SLOT%d CHAN%d --",cc.getSlot(),cc.getChannel()));
+            if (!PEDESTAL.containsKey(cc)) {
+                System.err.println("\nP !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+            }
+            if (!THRESHOLD.containsKey(cc)) {
+                System.err.println("\nT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+            }
+            if (!GAIN.containsKey(cc)) {
+                System.err.println("\nG !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+            }
+            //System.err.println(String.format(" %f %d %f",
+            //        PEDESTAL.get(cc),THRESHOLD.get(cc),GAIN.get(cc)));
+        }
+	    System.err.println();
+	    for (int ii=0; ii<2; ii++)
+	    {
+	        System.err.println(String.format("SINGLESEN-%d: %b ",ii,singlesEn[ii]));
+	        System.err.println(String.format("PAIRSEN-%d: %b: ",ii,pairsEn[ii]));
+	        
+	        System.err.println(String.format("SINGLESNHITSEN %d %b:  ",ii,singlesNhitsEn[ii]));
+	        System.err.println(String.format("SINGLESEMINEN %d %b",ii,singlesEnergyMinEn[ii]));
+	        System.err.println(String.format("SINGLESEMAXEN %d %b",ii,singlesEnergyMaxEn[ii]));
+	        
+	        System.err.println(String.format("PAIRSSUMMINEN %d %b",ii,pairsEnergySumMinEn[ii]));
+	        System.err.println(String.format("PAIRSSUMMAXEN %d %b",ii,pairsEnergySumMaxEn[ii]));
+	        System.err.println(String.format("PAIRSENERGYDIFFEN %d %b",ii,pairsEnergyDiffEn[ii]));
+	        System.err.println(String.format("PAIRSCOPEN %d %b",ii,pairsCoplanarityEn[ii]));
+	        System.err.println(String.format("PAIRSEDISTEN %d %b",ii,pairsEnergyDistEn[ii]));
+	        System.err.println(String.format("PAIRSTIMEDIFFEN %d %b",ii,pairsTimeDiffEn[ii]));
+	        
+	        System.err.println(String.format("SINGLESNHTIS %d %d",ii,singlesNhits[ii]));
+	        System.err.println(String.format("SINGLESEMIN %d %d",ii,singlesEnergyMin[ii]));
+	        System.err.println(String.format("SINGLESEMAX %d %d",ii,singlesEnergyMax[ii]));
+	        
+	        System.err.println(String.format("PAIRSSUMMIN %d %d",ii,pairsEnergySumMin[ii]));
+	        System.err.println(String.format("PRISSUMMAX %d %d",ii,pairsEnergySumMax[ii]));
+	        System.err.println(String.format("PAIRSENERGYDIFF %d %d",ii,pairsEnergyDiffMax[ii]));
+	        System.err.println(String.format("PAIRSCOPMAX %d %d",ii,pairsCoplanarityMax[ii]));
+	        System.err.println(String.format("PAIRSTDIFFMAAX %d %d",ii,pairsTimeDiffMax[ii]));
+	        System.err.println(String.format("PAIRSEDISTMIN %d %d",ii,pairsEnergyDistMin[ii]));
+	        System.err.println(String.format("PAIRSEDISTSLOP %d %f",ii,pairsEnergyDistSlope[ii]));
+	    }
+	    System.err.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
+	}
+  
+    public float getFloatConfigSSP(int itrig,String stub,int ival) {
+        return Float.valueOf(getConfigSSP(itrig,stub,ival));
+    }
+
+    public int getIntConfigSSP(int itrig,String stub,int ival) {
+        return Integer.valueOf(getConfigSSP(itrig,stub,ival));
+    }
+
+    public boolean getBoolConfigSSP(int itrig,String stub,int ival) {
+        return "1".equals(getConfigSSP(itrig,stub,ival));
+    }
+
+    public String getConfigSSP(int itrig,String stub,int ival) {
+    	String key="SSP_HPS_"+stub+"_"+itrig;
+    	return getConfig(key,ival);
+    }
+    
+    public String getConfig(String key, int ival) {
+        if (configMap.containsKey(key)) {
+        	List<String> vals=configMap.get(key);
+        	if (ival<vals.size()) {
+            	return configMap.get(key).get(ival);
+        	} else {
+        		System.err.println("configMap too short:  "+ival+configMap.get(key));
+        		return "0";
+        	}
+        } else {
+            // this is not an error, we have to wait on 3 banks.
+            // leave here for now.
+        	System.err.println("configMap missing key:  "+key);
+        	return "0";
+        }
+    }
+
+    public EcalChannel findChannel(int crate,int fadcSlot,int fadcChan)
+    {
+        for (EcalChannel cc : channels) {
+            // EcalChannel follows different convention on crate numbering:
+            if ((cc.getCrate()-1)*2 == crate-37 && 
+                cc.getSlot() == fadcSlot && cc.getChannel() == fadcChan)
+            {
+                return cc;
+            }
+        }
+        return null;
+    }
+    public EcalChannel findChannel(int channel_id) {
+        return ecalConditions.getChannelCollection().findChannel(channel_id);
+    }
+} 

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/UBOCutConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/UBOCutConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/UBOCutConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,34 @@
+package org.hps.readout.ecal.daqconfig;
+
+/**
+ * Class <code>UBOCutConfig</code> is an implementation of the abstract
+ * <code>AbstractCutConfig</code> for cuts that have only an upper bound.
+ * It provides the means to access this value and, for package classes,
+ * set it.
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+public class UBOCutConfig extends AbstractConfig<Double> {
+	private static final int UPPER_BOUND = 0;
+	
+	/**
+	 * Instantiates a new <code>UBOCutConfig</code> object.
+	 */
+	UBOCutConfig() { super(1); }
+	
+	/**
+	 * Gets the upper bound of the cut.
+	 * @return Returns the upper bound as a <code>double</code>.
+	 */
+	public double getUpperBound() {
+		return getValue(UPPER_BOUND);
+	}
+	
+	/**
+	 * Sets the upper bound of the cut to the specified value.
+	 * @param value - The new upper bound for the cut.
+	 */
+	void setUpperBound(double value) {
+		setValue(UPPER_BOUND, value);
+	}
+}

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ULBCutConfig.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ULBCutConfig.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/daqconfig/ULBCutConfig.java	Thu Mar  5 00:37:41 2015
@@ -0,0 +1,51 @@
+package org.hps.readout.ecal.daqconfig;
+
+/**
+ * Class <code>ULBCutConfig</code> is an implementation of the abstract
+ * <code>AbstractCutConfig</code> for cuts that have both an upper and
+ * a lower bound. It provides the means to access these values and, for
+ * package classes, set them.
+ * 
+ * @author Kyle McCarty <[log in to unmask]>
+ */
+public class ULBCutConfig extends AbstractConfig<Double> {
+	private static final int LOWER_BOUND = 0;
+	private static final int UPPER_BOUND = 1;
+	
+	/**
+	 * Instantiates a new <code>ULBCutConfig</code> object.
+	 */
+	ULBCutConfig() { super(2); }
+	
+	/**
+	 * Gets the lower bound of the cut.
+	 * @return Returns the lower bound as a <code>double</code>.
+	 */
+	public double getLowerBound() {
+		return getValue(LOWER_BOUND);
+	}
+	
+	/**
+	 * Gets the upper bound of the cut.
+	 * @return Returns the upper bound as a <code>double</code>.
+	 */
+	public double getUpperBound() {
+		return getValue(UPPER_BOUND);
+	}
+	
+	/**
+	 * Sets the lower bound of the cut to the specified value.
+	 * @param value - The new lower bound for the cut.
+	 */
+	void setLowerBound(double value) {
+		setValue(LOWER_BOUND, value);
+	}
+	
+	/**
+	 * Sets the upper bound of the cut to the specified value.
+	 * @param value - The new upper bound for the cut.
+	 */
+	void setUpperBound(double value) {
+		setValue(UPPER_BOUND, value);
+	}
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use