Print

Print


Commit in hps-java/src on MAIN
main/java/org/lcsim/hps/conditions/BadChannelConverter.java+99added 1.1
                                  /ChannelCollection.java+6added 1.1
                                  /ConditionsLoader.java+33added 1.1
                                  /ConditionsConstants.java+8-21.5 -> 1.6
                                  /DatabaseConditionsReader.java+26-71.11 -> 1.12
main/java/org/lcsim/hps/conditions/ecal/EcalChannelMapConverter.java+96added 1.1
                                       /EcalCalibration.java+3-151.1 -> 1.2
                                       /EcalCalibrationCollection.java+2-21.1 -> 1.2
                                       /EcalCalibrationConverter.java+1-11.1 -> 1.2
                                       /EcalChannel.java+1-11.3 -> 1.4
                                       /EcalConditions.java+80-1011.4 -> 1.5
                                       /EcalConditionsLoader.java+17-101.4 -> 1.5
                                       /EcalGain.java+2-141.2 -> 1.3
                                       /EcalGainCollection.java+2-21.3 -> 1.4
                                       /EcalGainConverter.java+2-21.3 -> 1.4
                                       /EcalBadChannelCollection.java-121.1 removed
                                       /EcalBadChannelConverter.java-951.1 removed
                                       /EcalChannelConverter.java-911.2 removed
main/java/org/lcsim/hps/conditions/svt/PulseParameters.java+66added 1.1
                                      /PulseParametersCollection.java+10added 1.1
                                      /PulseParametersConverter.java+103added 1.1
                                      /SvtGain.java+47added 1.1
                                      /SvtGainCollection.java+12added 1.1
                                      /SvtGainConverter.java+106added 1.1
                                      /ChannelConstants.java+70-561.4 -> 1.5
                                      /SvtCalibration.java+28-91.1 -> 1.2
                                      /SvtCalibrationCollection.java+7-21.1 -> 1.2
                                      /SvtCalibrationConverter.java+3-31.12 -> 1.13
                                      /SvtChannel.java+48-21.1 -> 1.2
                                      /SvtChannelMap.java+17-31.1 -> 1.2
                                      /SvtChannelMapConverter.java+20-31.1 -> 1.2
                                      /SvtConditions.java+96-711.7 -> 1.8
                                      /SvtConditionsLoader.java+35-271.6 -> 1.7
                                      /SvtBadChannelCollection.java-61.1 removed
                                      /SvtBadChannelConverter.java-951.1 removed
test/java/org/lcsim/hps/conditions/ConditionsLoaderTest.java+64added 1.1
                                  /DatabaseConditionsReaderTest.java+1-71.7 -> 1.8
test/java/org/lcsim/hps/conditions/svt/SvtConditionsLoaderTest.java+3-471.2 -> 1.3
+1114-686
11 added + 5 removed + 22 modified, total 38 files
more work on ye olde conditions system; implement SVT gain and ECAL pulse parameters; pretty printing of conditions objects; refactored ECAL code to be more like SVT implementation; add top level ConditionsLoader class; other minor changes

hps-java/src/main/java/org/lcsim/hps/conditions
BadChannelConverter.java added at 1.1
diff -N BadChannelConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BadChannelConverter.java	4 Oct 2013 01:43:47 -0000	1.1
@@ -0,0 +1,99 @@
+package org.lcsim.hps.conditions;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.lcsim.conditions.ConditionsManager;
+
+/**
+ * This class creates a list of {@link EcalBadChannel} objects from the conditions database.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class BadChannelConverter extends DatabaseConditionsConverter<ChannelCollection> {
+
+    /**
+     * Create the collection from the conditions database. 
+     * @param manager The conditions manager.
+     * @param name The name of the conditions set.
+     */
+    public ChannelCollection getData(ConditionsManager manager, String name) {
+
+        // Collection to be returned to caller.
+        ChannelCollection badChannels = new ChannelCollection();
+
+        // Get the ConditionsRecord with the meta-data, which will use the
+        // current run number from the manager.
+        ConditionsRecord record = ConditionsRecord.find(manager, name);
+
+        // Get the table name, field name, and field value defining the
+        // applicable conditions.
+        String tableName = record.getTableName();
+        String fieldName = record.getFieldName();
+        int fieldValue = record.getFieldValue();
+
+        // References to database objects.
+        Statement statement = null;
+        ResultSet resultSet = null;
+        Connection connection = null;
+
+        try {
+
+            // Get a connection from the manager.
+            connection = ConnectionManager.createConnection();
+
+            // Get the name of the current database being used.
+            String database = ConnectionManager.getConnectionParameters().getDatabase();
+            
+            // Select the correct field name.
+            String idFieldName = "ecal_channel_id";
+            if (name == "svt_bad_channels") {
+                idFieldName = "svt_channel_id";
+            }
+
+            // Query for getting back bad channel records.
+            String query = "SELECT " + idFieldName + " FROM " 
+                    + database + "." + tableName + " WHERE " 
+                    + fieldName + " = " + fieldValue 
+                    + " ORDER BY id ASC";
+
+            // Execute the query and get the results.
+            statement = connection.createStatement();
+            resultSet = statement.executeQuery(query);
+
+            // Loop over the records.
+            while (resultSet.next()) {
+                int channelId = resultSet.getInt(1);
+                badChannels.add(channelId);
+            }
+        } catch (SQLException x) {
+            throw new RuntimeException("Database error.", x);
+        } finally {
+            // Cleanup the SQL statement.
+            if (statement != null) {
+                try {
+                    statement.close();
+                } catch (Exception xx) {
+                }
+            }
+            // Cleanup the connection.
+            if (connection != null) {
+                try {
+                    connection.close();
+                } catch (Exception x) {
+                }
+            }
+        }
+        return badChannels;
+    }
+
+    /**
+     * Get the type handled by this converter.
+     * 
+     * @return The type handled by this converter.
+     */
+    public Class<ChannelCollection> getType() {
+        return ChannelCollection.class;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/conditions
ChannelCollection.java added at 1.1
diff -N ChannelCollection.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ChannelCollection.java	4 Oct 2013 01:43:47 -0000	1.1
@@ -0,0 +1,6 @@
+package org.lcsim.hps.conditions;
+
+import java.util.HashSet;
+
+public class ChannelCollection extends HashSet<Integer> {
+}

hps-java/src/main/java/org/lcsim/hps/conditions
ConditionsLoader.java added at 1.1
diff -N ConditionsLoader.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ConditionsLoader.java	4 Oct 2013 01:43:47 -0000	1.1
@@ -0,0 +1,33 @@
+package org.lcsim.hps.conditions;
+
+import org.lcsim.hps.conditions.ecal.EcalConditions;
+import org.lcsim.hps.conditions.ecal.EcalConditionsLoader;
+import org.lcsim.hps.conditions.svt.SvtConditions;
+import org.lcsim.hps.conditions.svt.SvtConditionsLoader;
+
+public class ConditionsLoader {
+    
+    SvtConditions svtConditions = null;
+    EcalConditions ecalConditions = null;
+    
+    void load() {
+        
+        // Load SVT conditions.
+        SvtConditionsLoader loaderSvt = new SvtConditionsLoader();
+        loaderSvt.load();
+        svtConditions = loaderSvt.getSvtConditions();        
+        
+        // Load ECAL conditions.
+        EcalConditionsLoader loaderEcal = new EcalConditionsLoader();
+        loaderEcal.load();
+        ecalConditions = loaderEcal.getEcalConditions();        
+    }
+    
+    public SvtConditions getSvtConditions() {
+        return svtConditions;
+    }
+    
+    public EcalConditions getEcalConditions() {
+        return ecalConditions;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/conditions
ConditionsConstants.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- ConditionsConstants.java	2 Oct 2013 23:19:54 -0000	1.5
+++ ConditionsConstants.java	4 Oct 2013 01:43:47 -0000	1.6
@@ -19,10 +19,10 @@
     /** Conditions key for ECal calibration information. */
     public static final String ECAL_CALIBRATIONS = "ecal_calibrations";
     
-    /** Conditions key for SVT channel data. */
+    /** Table with SVT channel data. */
     public static final String SVT_CHANNELS = "svt_channels";
     
-    /** Conditions key for the SVT DAQ map. */
+    /** Table with the SVT DAQ map. */
     public static final String SVT_DAQ_MAP = "svt_daq_map";
             
     /** Conditions key for SVT calibration data. */ 
@@ -30,4 +30,10 @@
     
     /** Conditions key for SVT bad channels. */
     public static final String SVT_BAD_CHANNELS = "svt_bad_channels";
+    
+    /** Conditions key for SVT pulse parameters. */
+    public static final String SVT_PULSE_PARAMETERS = "svt_pulse_parameters";
+    
+    /** Conditions key for SVT gain data. */
+    public static final String SVT_GAINS = "svt_gains";
 }

hps-java/src/main/java/org/lcsim/hps/conditions
DatabaseConditionsReader.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- DatabaseConditionsReader.java	2 Oct 2013 23:19:54 -0000	1.11
+++ DatabaseConditionsReader.java	4 Oct 2013 01:43:47 -0000	1.12
@@ -12,13 +12,13 @@
 
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.conditions.ConditionsReader;
-import org.lcsim.hps.conditions.ecal.EcalBadChannelConverter;
 import org.lcsim.hps.conditions.ecal.EcalCalibrationConverter;
-import org.lcsim.hps.conditions.ecal.EcalChannelConverter;
+import org.lcsim.hps.conditions.ecal.EcalChannelMapConverter;
 import org.lcsim.hps.conditions.ecal.EcalGainConverter;
-import org.lcsim.hps.conditions.svt.SvtBadChannelConverter;
+import org.lcsim.hps.conditions.svt.PulseParametersConverter;
 import org.lcsim.hps.conditions.svt.SvtCalibrationConverter;
 import org.lcsim.hps.conditions.svt.SvtChannelMapConverter;
+import org.lcsim.hps.conditions.svt.SvtGainConverter;
 
 /**
  * <p>
@@ -46,7 +46,7 @@
  * </p>
  * 
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: DatabaseConditionsReader.java,v 1.11 2013/10/02 23:19:54 jeremy Exp $ 
+ * @version $Id: DatabaseConditionsReader.java,v 1.12 2013/10/04 01:43:47 jeremy Exp $ 
  */
 public class DatabaseConditionsReader extends ConditionsReader {
         
@@ -206,13 +206,32 @@
      * @param manager The ConditionsManager.
      */
     private void registerConditionsConverters(ConditionsManager manager) {
+        
+        // ConditionsRecords with validity meta data.
         manager.registerConditionsConverter(new ConditionsRecordConverter());
+        
+        // SVT channel map.
         manager.registerConditionsConverter(new SvtChannelMapConverter());
+        
+        // SVT calibrations.
         manager.registerConditionsConverter(new SvtCalibrationConverter());
-        manager.registerConditionsConverter(new SvtBadChannelConverter());
-        manager.registerConditionsConverter(new EcalChannelConverter());
+        
+        // SVT gains.
+        manager.registerConditionsConverter(new SvtGainConverter());
+        
+        // SVT and ECAL bad channels.  Same converter can be used.
+        manager.registerConditionsConverter(new BadChannelConverter());
+        
+        // ECAL channel map.
+        manager.registerConditionsConverter(new EcalChannelMapConverter());
+        
+        // ECAL gains.
         manager.registerConditionsConverter(new EcalGainConverter());
-        manager.registerConditionsConverter(new EcalBadChannelConverter());
+                
+        // ECAL calibrations.
         manager.registerConditionsConverter(new EcalCalibrationConverter());
+        
+        // ECAL pulse parameters.
+        manager.registerConditionsConverter(new PulseParametersConverter());
     }
 }

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalChannelMapConverter.java added at 1.1
diff -N EcalChannelMapConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ EcalChannelMapConverter.java	4 Oct 2013 01:43:47 -0000	1.1
@@ -0,0 +1,96 @@
+package org.lcsim.hps.conditions.ecal;
+
+import static org.lcsim.hps.conditions.ConditionsConstants.ECAL_CHANNELS;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.hps.conditions.ConnectionManager;
+import org.lcsim.hps.conditions.DatabaseConditionsConverter;
+
+/**
+ * This class creates the {@link EcalChannelMap} from the conditions table containing the channel data.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class EcalChannelMapConverter extends DatabaseConditionsConverter<EcalChannelMap> {
+
+    /**
+     * Load the data from the conditions database.
+     * @param manager The conditions manager.
+     * @param name The name of the conditions set. 
+     */
+     public EcalChannelMap getData(ConditionsManager manager, String name) {
+                  
+         // Collection to be returned to caller.
+         EcalChannelMap channels = new EcalChannelMap();
+                          
+         // References to database objects.
+         Statement statement = null;
+         ResultSet resultSet = null;
+         Connection connection = null;
+         
+         try {
+             
+             // Get a connection from the manager.
+             connection = ConnectionManager.createConnection();
+             
+             // Get the name of the current database being used.
+             String database = ConnectionManager.getConnectionParameters().getDatabase();
+             
+             // Assign default key name if none was given. 
+             if (name == null)
+                 name = ECAL_CHANNELS;
+                                       
+             // Query to retrieve channel data.
+             String query = "SELECT id, x, y, crate, slot, channel FROM "  
+                     + database + "." + name;
+                                      
+             // Execute the query and get the results.
+             statement = connection.createStatement();
+             resultSet = statement.executeQuery(query);
+                 
+             // Loop over the records.
+             while(resultSet.next()) {    
+                 
+                 int id = resultSet.getInt(1);
+                 int x = resultSet.getInt(2);
+                 int y = resultSet.getInt(3);
+                 int crate = resultSet.getInt(4);
+                 int slot = resultSet.getInt(5);
+                 int channel = resultSet.getInt(6);
+                 
+                 EcalChannel channelData = new EcalChannel(id, crate, slot, channel, x, y);
+                 channels.put(channelData.getId(), channelData);
+             }            
+         } catch (SQLException x) {
+             throw new RuntimeException("Database error.", x);
+         } finally {
+             // Cleanup the SQL statement.
+             if (statement != null) {
+                 try {
+                     statement.close();
+                 } catch (Exception xx) {
+                 }
+             }            
+             // Cleanup the connection.
+             if (connection != null) {
+                 try {
+                     connection.close();
+                 } catch (Exception x) {
+                 }
+             }
+         }        
+         return channels;
+    }
+
+     /**
+      * Get the type that this converter handles.
+      * @return The type handled by this converter.
+      */
+    public Class<EcalChannelMap> getType() {
+        return EcalChannelMap.class;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalCalibration.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- EcalCalibration.java	1 Oct 2013 00:34:29 -0000	1.1
+++ EcalCalibration.java	4 Oct 2013 01:43:47 -0000	1.2
@@ -7,10 +7,7 @@
  * @author Jeremy McCormick <[log in to unmask]>
  */
 class EcalCalibration {
-   
-    /** The database ID of the ecal channel. */
-    private int id;
-    
+       
     /** The pedestal value. */
     private double pedestal;
     
@@ -22,20 +19,11 @@
      * @param id
      * @param gain
      */
-    EcalCalibration(int id, double pedestal, double noise) {
-        this.id = id;
+    EcalCalibration(double pedestal, double noise) {
         this.pedestal = pedestal;
         this.noise = noise;
     }
-    
-    /**
-     * Get the database ID of the ecal channel.
-     * @return The database ID.
-     */
-    public int getId() {
-        return id;
-    }
-    
+        
     /**
      * Get the pedestal value.
      * @return The gain value.

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalCalibrationCollection.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- EcalCalibrationCollection.java	1 Oct 2013 00:34:29 -0000	1.1
+++ EcalCalibrationCollection.java	4 Oct 2013 01:43:47 -0000	1.2
@@ -1,10 +1,10 @@
 package org.lcsim.hps.conditions.ecal;
 
-import java.util.ArrayList;
+import java.util.LinkedHashMap;
 
 /**
  * This class represents a list of {@link EcalCalibration} objects.
  * @author Jeremy McCormick <[log in to unmask]>
  */
-public class EcalCalibrationCollection extends ArrayList<EcalCalibration> {
+public class EcalCalibrationCollection extends LinkedHashMap<Integer,EcalCalibration> {
 }

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalCalibrationConverter.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- EcalCalibrationConverter.java	1 Oct 2013 00:34:29 -0000	1.1
+++ EcalCalibrationConverter.java	4 Oct 2013 01:43:47 -0000	1.2
@@ -63,7 +63,7 @@
                 int channelId = resultSet.getInt(1);
                 double pedestal = resultSet.getDouble(2);
                 double noise = resultSet.getDouble(3);
-                calibrations.add(new EcalCalibration(channelId, pedestal, noise));
+                calibrations.put(channelId, new EcalCalibration(pedestal, noise));
             }
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalChannel.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- EcalChannel.java	1 Oct 2013 00:34:29 -0000	1.3
+++ EcalChannel.java	4 Oct 2013 01:43:47 -0000	1.4
@@ -95,7 +95,7 @@
         if (!(o instanceof EcalChannel)) {
             return false;
         }
-        if (o.equals(this)) {
+        if (o == this) {
             return true;
         }
         EcalChannel c = (EcalChannel)o;

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalConditions.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- EcalConditions.java	1 Oct 2013 01:22:33 -0000	1.4
+++ EcalConditions.java	4 Oct 2013 01:43:47 -0000	1.5
@@ -1,9 +1,7 @@
 package org.lcsim.hps.conditions.ecal;
 
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * This class provides access to all ECal conditions from the database,
@@ -14,16 +12,11 @@
 public class EcalConditions {
     
     /** Channel map. */
-    EcalChannelMap channels = new EcalChannelMap();
-     
-    /**
-     * Data structures for retrieving conditions by channel.
-     */
-    Map<EcalChannel, Double> gains = new HashMap<EcalChannel, Double>();
-    Map<EcalChannel, Double> pedestals = new HashMap<EcalChannel, Double>();
-    Map<EcalChannel, Double> noises = new HashMap<EcalChannel, Double>();
-    Set<EcalChannel> badChannels = new HashSet<EcalChannel>();
-        
+    EcalChannelMap channelMap = new EcalChannelMap();
+    
+    /** Map between channels and conditions data. */
+    Map<EcalChannel,EcalChannelConstants> channelData = new HashMap<EcalChannel,EcalChannelConstants>();
+             
     /**
      * Class constructor, which is package protected.
      */
@@ -31,110 +24,96 @@
     }
     
     /**
-     * Get the gain value by channel.  
-     * This value is multiplied by an ADC count to get an energy value.
-     * @param channel The channel.
-     * @return The gain for this channel.
-     */
-    public Double getGain(EcalChannel channel) {
-        return gains.get(channel);
-    } 
-    
-    /**
-     * Get the pedestal by channel.
-     * @param channel The channel.
-     * @return The pedestal value for this channel.
-     */
-    public Double getPedestal(EcalChannel channel) {
-        return pedestals.get(channel);
-    }
-    
-    /**
-     * Get the noise by channel.
-     * @param channel The channel.
-     * @return The noise value for this channel
-     */
-    public Double getNoise(EcalChannel channel) {
-        return noises.get(channel);
-    }
-    
-    /**
-     * Get whether or not the given channel is "bad" in some way, 
-     * meaning it should not be used for reconstruction, etc.
-     * @param channel The channel.
-     * @return True if channel is bad; false if not.
+     * Set the channel map.
+     * @param channels The channel map.
      */
-    public boolean isBadChannel(EcalChannel channel) {        
-        return badChannels.contains(channel);
+    void setChannelMap(EcalChannelMap channelMap) {
+        this.channelMap = channelMap;
     }
-    
+        
     /**
      * Get the map between database IDs and <code>EcalChannel</code> objects.
      * @return The channel map.
      */
     public EcalChannelMap getChannelMap() {
-        return channels;
+        return channelMap;
     }
-    
+       
     /**
-     * Set the gain for the channel.
-     * @param channel The channel.
-     * @param gain The gain.
-     */
-    void setGain(EcalChannel channel, double gain) {
-        gains.put(channel, gain);
-    }
-    
-    /**
-     * Set the pedestal for the channel.
-     * @param channel The channel. 
-     * @param pedestal The pedestal.
-     */
-    void setPedestal(EcalChannel channel, double pedestal) {
-        pedestals.put(channel, pedestal);
-    } 
-    
-    /**
-     * Set the noise for the channel.
-     * @param channel The channel.
-     * @param noise The noise value.
-     */
-    void setNoise(EcalChannel channel, double noise) {
-        noises.put(channel, noise);
-    }
-    
-    /**
-     * Flag a channel as bad.
-     * @param channel The channel.
-     */
-    void addBadChannel(EcalChannel channel) {
-        badChannels.add(channel);
-    }
-    
-    /**
-     * Set the channel map.
-     * @param channels The channel map.
-     */
-    void setChannelMap(EcalChannelMap channels) {
-        this.channels = channels;
-    }
-    
+     * Get the conditions constants for a specific channel.  These will be
+     * created if they do not exist for the given channel, BUT only channels
+     * in the current channel map are allowed as an argument.
+     * @param channel The ECAL channel.
+     * @return The conditions constants for the channel.
+     * @throws IllegalArgumentException if channel does not exist in the channel map.
+     */
+    public EcalChannelConstants getChannelConstants(EcalChannel channel) {
+        // This channel must come from the map.
+        if (!channelMap.containsValue(channel)) {
+            System.err.println("Channel not found in map => " + channel);
+            throw new IllegalArgumentException("Channel was not found in map.");
+        }
+        // If channel has no data yet, then add it.
+        if (!channelData.containsKey(channel))
+            channelData.put(channel, new EcalChannelConstants());
+        return channelData.get(channel);
+    }         
+            
     /**
      * Convert this object to a string.
      * @return A string representation of this object.
      */
     public String toString() {
         StringBuffer buff = new StringBuffer();
-        for (EcalChannel channel : channels.values()) {
-            boolean badChannel = badChannels.contains(channel);
-            Double gain = getGain(channel);
-            Double pedestal = getPedestal(channel);
-            Double noise = getNoise(channel);
-            buff.append(channel 
-                    + ", gain: " + (gain == null ? "NONE" : gain)
-                    + ", pedestal: " + (pedestal == null ? "NONE" : pedestal)
-                    + ", noise: " + (noise == null ? "NONE" : noise)
-                    + ", badChannel: " + badChannel + '\n');
+        
+        // Table header:
+        buff.append("id");
+        buff.append("    ");
+        buff.append("crate");
+        buff.append("  ");
+        buff.append("slot");        
+        buff.append("   ");
+        buff.append("channel");        
+        buff.append("  ");
+        buff.append("x");
+        buff.append("      ");
+        buff.append("y");        
+        buff.append("     ");
+        buff.append("gain");
+        buff.append("       ");
+        buff.append("pedestal");
+        buff.append("   ");
+        buff.append("noise");
+        buff.append("      ");
+        buff.append("bad");
+        buff.append('\n');
+        for (int i=0; i<80; i++) {
+            buff.append("-");
+        }        
+        buff.append('\n');
+        
+        // Loop over all channels.
+        for (EcalChannel channel : channelMap.values()) {
+            
+            EcalChannelConstants constants = getChannelConstants(channel);
+            
+            double gain = constants.getGain().getGain();
+            double pedestal = constants.getCalibration().getPedestal();
+            double noise = constants.getCalibration().getNoise();
+            boolean bad = constants.isBadChannel();
+            
+            // Channel data.
+            buff.append(String.format("%-5d %-6d %-6d %-8d %-6d %-6d", 
+                    channel.getId(), channel.getCrate(), channel.getSlot(), channel.getChannel(), 
+                    channel.getX(), channel.getY()));
+            
+            // Constants.
+            buff.append(String.format("%-10.4f %-10.4f %-10.4f ", gain, pedestal, noise));
+            
+            // Bad channel.
+            buff.append(bad);
+            
+            buff.append('\n');
         }
         return buff.toString();
     }

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalConditionsLoader.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- EcalConditionsLoader.java	2 Oct 2013 01:55:53 -0000	1.4
+++ EcalConditionsLoader.java	4 Oct 2013 01:43:47 -0000	1.5
@@ -2,9 +2,13 @@
 
 import static org.lcsim.hps.conditions.ConditionsConstants.ECAL_BAD_CHANNELS;
 import static org.lcsim.hps.conditions.ConditionsConstants.ECAL_CALIBRATIONS;
+import static org.lcsim.hps.conditions.ConditionsConstants.ECAL_CHANNELS;
 import static org.lcsim.hps.conditions.ConditionsConstants.ECAL_GAINS;
 
+import java.util.Map.Entry;
+
 import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.hps.conditions.ChannelCollection;
 
 /**
  * This class loads all ecal conditions into an {@link EcalConditions} object.
@@ -27,31 +31,34 @@
         ConditionsManager manager = ConditionsManager.defaultInstance();
                                
         // Get the channel information from the database.                
-        EcalChannelMap channelMap = manager.getCachedConditions(EcalChannelMap.class, null).getCachedData();
+        EcalChannelMap channelMap = manager.getCachedConditions(EcalChannelMap.class, ECAL_CHANNELS).getCachedData();
         
         // Set the channel map.
         conditions.setChannelMap(channelMap);
                                        
         // Add gains.
         EcalGainCollection gains = manager.getCachedConditions(EcalGainCollection.class, ECAL_GAINS).getCachedData();        
-        for (EcalGain gain : gains) {
-            conditions.setGain(channelMap.get(gain.getId()), gain.getGain());
+        for (Entry<Integer,EcalGain> entry : gains.entrySet()) {
+            EcalChannel channel = channelMap.get(entry.getKey());
+            EcalGain gain = entry.getValue();
+            conditions.getChannelConstants(channel).setGain(gain);
         }
         
         // Add bad channels.
-        EcalBadChannelCollection badChannels = manager.getCachedConditions(
-                EcalBadChannelCollection.class, ECAL_BAD_CHANNELS).getCachedData();
+        ChannelCollection badChannels = manager.getCachedConditions(
+                ChannelCollection.class, ECAL_BAD_CHANNELS).getCachedData();
         for (Integer badChannel : badChannels) {
-            conditions.addBadChannel(channelMap.get(badChannel));
+            EcalChannel channel = channelMap.get(badChannel);
+            conditions.getChannelConstants(channel).setBadChannel(true);
         }
         
         // Add calibrations including pedestal and noise values.
         EcalCalibrationCollection calibrations = 
                 manager.getCachedConditions(EcalCalibrationCollection.class, ECAL_CALIBRATIONS).getCachedData();
-        for (EcalCalibration calibration : calibrations) {
-            EcalChannel channel = channelMap.get(calibration.getId());
-            conditions.setPedestal(channel, calibration.getPedestal());
-            conditions.setNoise(channel, calibration.getNoise());
+        for (Entry<Integer,EcalCalibration> entry : calibrations.entrySet()) {
+            EcalChannel channel = channelMap.get(entry.getKey());
+            EcalCalibration calibration = entry.getValue();
+            conditions.getChannelConstants(channel).setCalibration(calibration);
         }       
     }
     

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalGain.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- EcalGain.java	25 Sep 2013 22:36:52 -0000	1.2
+++ EcalGain.java	4 Oct 2013 01:43:47 -0000	1.3
@@ -10,10 +10,7 @@
  * @author Jeremy McCormick <[log in to unmask]>
  */
 class EcalGain {
-   
-    /** The database ID. */
-    private int id;
-    
+       
     /** The gain value. */
     private double gain;
     
@@ -22,20 +19,11 @@
      * @param id
      * @param gain
      */
-    EcalGain(int id, double gain) {
-        this.id = id;
+    EcalGain(double gain) {
         this.gain = gain;
     }
     
     /**
-     * Get the database ID.
-     * @return The database ID.
-     */
-    public int getId() {
-        return id;
-    }
-    
-    /**
      * Get the gain value.
      * @return The gain value.
      */

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalGainCollection.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- EcalGainCollection.java	1 Oct 2013 00:34:29 -0000	1.3
+++ EcalGainCollection.java	4 Oct 2013 01:43:47 -0000	1.4
@@ -1,9 +1,9 @@
 package org.lcsim.hps.conditions.ecal;
 
-import java.util.ArrayList;
+import java.util.LinkedHashMap;
 
 /**
  * This class maps integer IDs from the database to ECal gain parameters.
  */
-class EcalGainCollection extends ArrayList<EcalGain> {
+class EcalGainCollection extends LinkedHashMap<Integer,EcalGain> {
 }

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalGainConverter.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- EcalGainConverter.java	1 Oct 2013 00:34:29 -0000	1.3
+++ EcalGainConverter.java	4 Oct 2013 01:43:47 -0000	1.4
@@ -58,8 +58,8 @@
             // Loop over the records.
             while(resultSet.next()) {
                 int channelId = resultSet.getInt(1);
-                double gain = resultSet.getDouble(2);                
-                gains.add(new EcalGain(channelId, gain));
+                double gain = resultSet.getDouble(2);
+                gains.put(channelId, new EcalGain(gain));
             }            
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalBadChannelCollection.java removed after 1.1
diff -N EcalBadChannelCollection.java
--- EcalBadChannelCollection.java	1 Oct 2013 00:34:29 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-package org.lcsim.hps.conditions.ecal;
-
-import java.util.HashSet;
-
-/**
- * This class represents a set of bad channels in the ECal.  The integer
- * values are database IDs of the channels from the ecal_channels table.
- * @author jeremym
- */
-public class EcalBadChannelCollection extends HashSet<Integer> { 
-
-}

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalBadChannelConverter.java removed after 1.1
diff -N EcalBadChannelConverter.java
--- EcalBadChannelConverter.java	1 Oct 2013 00:34:29 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,95 +0,0 @@
-package org.lcsim.hps.conditions.ecal;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.hps.conditions.ConditionsRecord;
-import org.lcsim.hps.conditions.ConnectionManager;
-import org.lcsim.hps.conditions.DatabaseConditionsConverter;
-
-/**
- * This class creates a list of {@link EcalBadChannel} objects from the conditions database.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class EcalBadChannelConverter extends DatabaseConditionsConverter<EcalBadChannelCollection> {
-
-    /**
-     * Create the collection from the conditions database. 
-     * @param manager The conditions manager.
-     * @param name The name of the conditions set.
-     */
-    public EcalBadChannelCollection getData(ConditionsManager manager, String name) {
-
-        // Collection to be returned to caller.
-        EcalBadChannelCollection badChannels = new EcalBadChannelCollection();
-
-        // Get the ConditionsRecord with the meta-data, which will use the
-        // current run number from the manager.
-        ConditionsRecord record = ConditionsRecord.find(manager, name);
-
-        // Get the table name, field name, and field value defining the
-        // applicable conditions.
-        String tableName = record.getTableName();
-        String fieldName = record.getFieldName();
-        int fieldValue = record.getFieldValue();
-
-        // References to database objects.
-        Statement statement = null;
-        ResultSet resultSet = null;
-        Connection connection = null;
-
-        try {
-
-            // Get a connection from the manager.
-            connection = ConnectionManager.createConnection();
-
-            // Get the name of the current database being used.
-            String database = ConnectionManager.getConnectionParameters().getDatabase();
-
-            String query = "SELECT ecal_channel_id FROM " 
-                    + database + "." + tableName + " WHERE " 
-                    + fieldName + " = " + fieldValue 
-                    + " ORDER BY id ASC";
-
-            // Execute the query and get the results.
-            statement = connection.createStatement();
-            resultSet = statement.executeQuery(query);
-
-            // Loop over the records.
-            while (resultSet.next()) {
-                int channelId = resultSet.getInt(1);
-                badChannels.add(channelId);
-            }
-        } catch (SQLException x) {
-            throw new RuntimeException("Database error.", x);
-        } finally {
-            // Cleanup the SQL statement.
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (Exception xx) {
-                }
-            }
-            // Cleanup the connection.
-            if (connection != null) {
-                try {
-                    connection.close();
-                } catch (Exception x) {
-                }
-            }
-        }
-        return badChannels;
-    }
-
-    /**
-     * Get the type handled by this converter.
-     * 
-     * @return The type handled by this converter.
-     */
-    public Class<EcalBadChannelCollection> getType() {
-        return EcalBadChannelCollection.class;
-    }
-}

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalChannelConverter.java removed after 1.2
diff -N EcalChannelConverter.java
--- EcalChannelConverter.java	25 Sep 2013 22:36:52 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-package org.lcsim.hps.conditions.ecal;
-
-import static org.lcsim.hps.conditions.ConditionsConstants.ECAL_CHANNELS;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.hps.conditions.ConnectionManager;
-import org.lcsim.hps.conditions.DatabaseConditionsConverter;
-
-/**
- * This class creates the {@link EcalChannelMap} from the conditions table containing the channel data.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class EcalChannelConverter extends DatabaseConditionsConverter<EcalChannelMap> {
-
-    /**
-     * Load the data from the conditions database.
-     * @param manager The conditions manager.
-     * @param name The name of the conditions set. 
-     */
-     public EcalChannelMap getData(ConditionsManager manager, String name) {
-                  
-         // Collection to be returned to caller.
-         EcalChannelMap channels = new EcalChannelMap();
-                          
-         // References to database objects.
-         Statement statement = null;
-         ResultSet resultSet = null;
-         Connection connection = null;
-         
-         try {
-             
-             // Get a connection from the manager.
-             connection = ConnectionManager.createConnection();
-             
-             // Get the name of the current database being used.
-             String database = ConnectionManager.getConnectionParameters().getDatabase();
-                                       
-             String query = "SELECT id, x, y, crate, slot, channel FROM "  
-                     + database + "." + ECAL_CHANNELS;
-                                      
-             // Execute the query and get the results.
-             statement = connection.createStatement();
-             resultSet = statement.executeQuery(query);
-                 
-             // Loop over the records.
-             while(resultSet.next()) {    
-                 
-                 int id = resultSet.getInt(1);
-                 int x = resultSet.getInt(2);
-                 int y = resultSet.getInt(3);
-                 int crate = resultSet.getInt(4);
-                 int slot = resultSet.getInt(5);
-                 int channel = resultSet.getInt(6);
-                 
-                 EcalChannel channelData = new EcalChannel(id, crate, slot, channel, x, y);
-                 channels.put(channelData.getId(), channelData);
-             }            
-         } catch (SQLException x) {
-             throw new RuntimeException("Database error.", x);
-         } finally {
-             // Cleanup the SQL statement.
-             if (statement != null) {
-                 try {
-                     statement.close();
-                 } catch (Exception xx) {
-                 }
-             }            
-             // Cleanup the connection.
-             if (connection != null) {
-                 try {
-                     connection.close();
-                 } catch (Exception x) {
-                 }
-             }
-         }        
-         return channels;
-    }
-
-     /**
-      * Get the type that this converter handles.
-      * @return The type handled by this converter.
-      */
-    public Class<EcalChannelMap> getType() {
-        return EcalChannelMap.class;
-    }
-}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
PulseParameters.java added at 1.1
diff -N PulseParameters.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PulseParameters.java	4 Oct 2013 01:43:48 -0000	1.1
@@ -0,0 +1,66 @@
+package org.lcsim.hps.conditions.svt;
+
+/**
+ * This class represents the pulse parameters for an SVT channel.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class PulseParameters {
+    
+    double amplitude = Double.NaN;
+    double t0 = Double.NaN;
+    double tp = Double.NaN;
+    double chisq = Double.NaN;
+
+    /**
+     * Full qualified class constructor.
+     * @param amplitude The amplitude.
+     * @param t0 The start time.
+     * @param tp The shaping time.
+     * @param chisq The chisq of the measurement.
+     */
+    PulseParameters(double amplitude, double t0, double tp, double chisq) {
+        this.amplitude = amplitude;
+        this.t0 = t0;
+        this.tp = tp;
+        this.chisq = chisq;
+    }
+    
+    /**
+     * Get the amplitude.
+     * @return The amplifude.
+     */
+    double getAmplitude() {
+        return amplitude;
+    }
+    
+    /**
+     * Get the starting time.
+     * @return The starting time.
+     */
+    double getT0() {
+        return t0;
+    }
+    
+    /**
+     * Get the time shift.
+     * @return The time shift.
+     */
+    double getTimeShift() {
+        return tp;
+    }
+    
+    /**
+     * Get the chisq.
+     * @return The chisq.
+     */
+    double getChisq() {
+        return chisq;
+    }
+    
+    /**
+     * Convert this object to a human readable string.
+     */
+    public String toString() {
+        return "amp: " + amplitude + ", t0: " + t0 + ", shift: " + tp + ", chisq: " + chisq;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
PulseParametersCollection.java added at 1.1
diff -N PulseParametersCollection.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PulseParametersCollection.java	4 Oct 2013 01:43:48 -0000	1.1
@@ -0,0 +1,10 @@
+package org.lcsim.hps.conditions.svt;
+
+import java.util.LinkedHashMap;
+
+/**
+ * A collection of {@link PulseParameters} objects stored by SVT channel key.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class PulseParametersCollection extends LinkedHashMap<Integer,PulseParameters> {
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
PulseParametersConverter.java added at 1.1
diff -N PulseParametersConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PulseParametersConverter.java	4 Oct 2013 01:43:48 -0000	1.1
@@ -0,0 +1,103 @@
+package org.lcsim.hps.conditions.svt;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.hps.conditions.ConditionsRecord;
+import org.lcsim.hps.conditions.ConnectionManager;
+import org.lcsim.hps.conditions.DatabaseConditionsConverter;
+
+/**
+ * This class creates a {@link PulseParametersCollection} object from the conditions database.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class PulseParametersConverter extends DatabaseConditionsConverter<PulseParametersCollection> {
+    
+    /**
+     * Get the pulse parameters by channel for this run by named conditions set.
+     * @param manager The current conditions manager.
+     * @param name The name of the conditions set.
+     * @return The channel constants data.
+     */
+    public PulseParametersCollection getData(ConditionsManager manager, String name) {
+        
+        // Get the ConditionsRecord with the meta-data, which will use the current run number from the manager.
+        ConditionsRecord record = ConditionsRecord.find(manager, name);
+               
+        // Get the table name, field name, and field value defining the applicable conditions.
+        String tableName = record.getTableName();
+        String fieldName = record.getFieldName();
+        int fieldValue = record.getFieldValue();
+                
+        // References to database objects.
+        Statement statement = null;
+        ResultSet resultSet = null;
+        Connection connection = null;
+
+        // Objects for building the return value.
+        PulseParametersCollection collection = new PulseParametersCollection();
+        
+        try {
+                                                 
+            // Get a connection from the manager.
+            connection = ConnectionManager.createConnection();
+            
+            // Get the name of the current database being used.
+            String database = ConnectionManager.getConnectionParameters().getDatabase();
+                                
+            // Construct the query to find matching calibration records using the ID field.
+            String query = "SELECT svt_channel_id, amplitude, t0, tp, chisq FROM "
+                    + database + "." + tableName 
+                    + " WHERE "
+                    + fieldName + " = " + fieldValue
+                    + " ORDER BY id ASC";
+            
+            // Execute the query and get the results.
+            statement = connection.createStatement();
+            resultSet = statement.executeQuery(query);
+                
+            // Loop over the calibration records.
+            while(resultSet.next()) {    
+                              
+                // Get the calibration data for a single channel.
+                int channelId = resultSet.getInt(1);
+                double amplitude = resultSet.getDouble(2);
+                double t0 = resultSet.getDouble(3);
+                double tp = resultSet.getDouble(4);
+                double chisq = resultSet.getDouble(5);
+                
+                collection.put(channelId, new PulseParameters(amplitude, t0, tp, chisq));
+            }            
+        } catch (SQLException x) {
+            throw new RuntimeException("Database error.", x);
+        } finally {
+            // Cleanup the SQL statement.
+            if (statement != null) {
+                try {
+                    statement.close();
+                } catch (Exception xx) {
+                }
+            }            
+            // Cleanup the connection.
+            if (connection != null) {
+                try {
+                    connection.close();
+                } catch (Exception x) {
+                }
+            }
+        }
+        // Return the collection of channel constants to caller.
+        return collection;
+    }
+
+    /**
+     * Get the type handled by this converter.     
+     * @return The type handled by this converter, which is <code>ConditionsRecordCollection</code>.
+     */
+    public Class<PulseParametersCollection> getType() {
+        return PulseParametersCollection.class;
+    }        
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtGain.java added at 1.1
diff -N SvtGain.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtGain.java	4 Oct 2013 01:43:48 -0000	1.1
@@ -0,0 +1,47 @@
+package org.lcsim.hps.conditions.svt;
+
+/**
+ * This class represents gain measurements for a single SVT channel.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class SvtGain {
+
+    double gain = Double.NaN;
+    double offset = Double.NaN;
+    
+    /**
+     * Full qualified class constructor.
+     * @param gain The gain of the channel.
+     * @param offset The gain's offset.
+     */
+    SvtGain(double gain, double offset) {
+        this.gain = gain;
+        this.offset = offset;
+    }
+    
+    /**
+     * Get the gain.
+     * @return The gain value.
+     */
+    double getGain() {
+        return gain;
+    }
+    
+    /**
+     * Get the offset.
+     * @return The offset value.
+     */
+    double getOffset() {
+        return offset;
+    }
+    
+    /**
+     * Convert this object to a human-readable string.
+     * @return This object converted to a string.
+     */
+    public String toString() {
+        //return "gain: " + gain + ", offset: " + offset;
+        return "" + gain + '\t' + offset;
+    }
+    
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtGainCollection.java added at 1.1
diff -N SvtGainCollection.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtGainCollection.java	4 Oct 2013 01:43:48 -0000	1.1
@@ -0,0 +1,12 @@
+package org.lcsim.hps.conditions.svt;
+
+import java.util.LinkedHashMap;
+
+/**
+ * This class represents a list of {@link SvtGain} objects associated 
+ * with their SVT channel IDs from the database.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class SvtGainCollection extends LinkedHashMap<Integer, SvtGain> {
+
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtGainConverter.java added at 1.1
diff -N SvtGainConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtGainConverter.java	4 Oct 2013 01:43:48 -0000	1.1
@@ -0,0 +1,106 @@
+package org.lcsim.hps.conditions.svt;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.hps.conditions.ConditionsRecord;
+import org.lcsim.hps.conditions.ConnectionManager;
+import org.lcsim.hps.conditions.DatabaseConditionsConverter;
+
+/**
+ * This class creates a {@link SvtCalibrationCollection} from the conditions database.
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: SvtGainConverter.java,v 1.1 2013/10/04 01:43:48 jeremy Exp $
+ */
+public class SvtGainConverter extends DatabaseConditionsConverter<SvtGainCollection> {
+    
+    /**
+     * Class constructor.
+     */
+    public SvtGainConverter() {
+    }
+
+    /**
+     * Get the SVT channel constants for this run by named set.
+     * @param manager The current conditions manager.
+     * @param name The name of the conditions set.
+     * @return The channel constants data.
+     */
+    public SvtGainCollection getData(ConditionsManager manager, String name) {
+        
+        // Get the ConditionsRecord with the meta-data, which will use the current run number from the manager.
+        ConditionsRecord record = ConditionsRecord.find(manager, name);
+               
+        // Get the table name, field name, and field value defining the applicable conditions.
+        String tableName = record.getTableName();
+        String fieldName = record.getFieldName();
+        int fieldValue = record.getFieldValue();
+                
+        // References to database objects.
+        Statement statement = null;
+        ResultSet resultSet = null;
+        Connection connection = null;
+
+        // Objects for building the return value.
+        SvtGainCollection collection = new SvtGainCollection();
+        
+        try {
+                                                 
+            // Get a connection from the manager.
+            connection = ConnectionManager.createConnection();
+            
+            // Get the name of the current database being used.
+            String database = ConnectionManager.getConnectionParameters().getDatabase();
+                                
+            // Construct the query to find matching calibration records using the ID field.
+            String query = "SELECT svt_channel_id, gain, offset FROM "
+                    + database + "." + tableName 
+                    + " WHERE "
+                    + fieldName + " = " + fieldValue
+                    + " ORDER BY svt_channel_id ASC";
+            
+            // Execute the query and get the results.
+            statement = connection.createStatement();
+            resultSet = statement.executeQuery(query);
+                
+            // Loop over the calibration records.
+            while(resultSet.next()) {                                 
+                // Create the object with this channel's gain parameters.
+                int channelId = resultSet.getInt(1);
+                double gain = resultSet.getDouble(2);
+                double offset = resultSet.getDouble(3);
+                collection.put(channelId, new SvtGain(gain, offset));
+            }            
+        } catch (SQLException x) {
+            throw new RuntimeException("Database error.", x);
+        } finally {
+            // Cleanup the SQL statement.
+            if (statement != null) {
+                try {
+                    statement.close();
+                } catch (Exception xx) {
+                }
+            }            
+            // Cleanup the connection.
+            if (connection != null) {
+                try {
+                    connection.close();
+                } catch (Exception x) {
+                }
+            }
+        }
+        // Return the collection of channel constants to caller.
+        return collection;
+    }
+
+    /**
+     * Get the type handled by this converter.     
+     * @return The type handled by this converter, which is <code>ConditionsRecordCollection</code>.
+     */
+    public Class<SvtGainCollection> getType() {
+        return SvtGainCollection.class;
+    }        
+}
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/conditions/svt
ChannelConstants.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- ChannelConstants.java	2 Oct 2013 23:19:54 -0000	1.4
+++ ChannelConstants.java	4 Oct 2013 01:43:48 -0000	1.5
@@ -5,83 +5,97 @@
  * 
  * @author Omar Moreno <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: ChannelConstants.java,v 1.4 2013/10/02 23:19:54 jeremy Exp $
+ * @version $Id: ChannelConstants.java,v 1.5 2013/10/04 01:43:48 jeremy Exp $
  */
-class ChannelConstants {
+public class ChannelConstants {
 
-    private double pedestal = Double.NaN;
-    private double noise = Double.NaN;
-    private double tp = Double.NaN;
-    private double t0Shift = Double.NaN;
-    private double[][] pulseShape = null;
+    private SvtCalibration calibration = null;
+    private SvtGain gain = null;
+    private PulseParameters pulseParameters = null;
     private boolean badChannel = false;
 
     /**
-     * Default Ctor
+     * Class constructor.
      */
     ChannelConstants() {
-    }
-
-    ChannelConstants(double noise, double tp, double t0Shift, double[][] pulseShape, boolean badChannel) {
-        this.setPedestal(pedestal);
-        this.setNoise(noise);
-        this.setShapingTime(tp);
-        this.setT0Shift(t0Shift);
-        this.setPulseShape(pulseShape);
-        this.setBadChannel(badChannel);
-    }
-   
-    void setNoise(double noise) {
-        this.noise = noise;
-    }
-
-    void setPedestal(double pedestal) {
-        this.pedestal = pedestal;
-    }
+    }    
 
-    void setShapingTime(double tp) {
-        this.tp = tp;
-    }
-
-    void setT0Shift(double t0Shift) {
-        this.t0Shift = t0Shift;
+    /**
+     * Set the pulse parameters.
+     * @param pulseParameters The pulse parameters
+     */
+    void setPulseParameters(PulseParameters pulseParameters) {
+        this.pulseParameters = pulseParameters;
     }
-
-    void setPulseShape(double[][] pulseShape) {
-        this.pulseShape = pulseShape;
+    
+    /**
+     * Set the gain.
+     * @param gain The gain object.
+     */
+    void setGain(SvtGain gain) {
+        this.gain = gain;
     }
     
+    /**
+     * Set the calibration.
+     * @param calibration The calibration object.
+     */
+    void setCalibration(SvtCalibration calibration) {
+        this.calibration = calibration;
+    }      
+    
+    /**
+     * Set the bad channel flag.
+     * @param badChannel The bad channel flag value.
+     */
     void setBadChannel(boolean badChannel) {
         this.badChannel = badChannel;
     }
-
-    public double getNoise() {
-        return noise;
-    }
-
-    public double getPedestal() {
-        return pedestal;
+        
+    /**
+     * Check if this is a bad channel.
+     * @return True if channel is bad; false if not.
+     */
+    public boolean isBadChannel() {
+        return badChannel;
     }
-
-    public double getShapingTime() {
-        return tp;
+        
+    /**
+     * Get the pulse parameters.
+     * @return The pulse parameters.
+     */
+    public PulseParameters getPulseParameters() {
+        return pulseParameters;
     }
-
-    public double getT0Shift() {
-        return t0Shift;
+    
+    /**
+     * Get the gain.
+     * @return The gain.
+     */
+    public SvtGain getGain() {
+        return gain;
     }
-
-    public double[][] getPulseShape() {
-        return pulseShape;
+    
+    /**
+     * Get the calibration.
+     * @return The calibration.
+     */
+    public SvtCalibration getCalibration() {
+        return calibration;
     }
 
+    /**
+     * Convert this object to a string.
+     * @return This object converted to a string.
+     */
     public String toString() {
         StringBuffer buffer = new StringBuffer();        
-        buffer.append("pedestal: " + this.getPedestal() + ", ");
-        buffer.append("noise: " + this.getNoise() + ", ");
-        buffer.append("t0: " + this.getT0Shift() + ", ");
-        buffer.append("tp: " + this.getShapingTime());
-        // TODO: add print pulse shape here
+        buffer.append(getCalibration());
+        buffer.append(", ");
+        buffer.append(getGain());
+        buffer.append(", ");
+        buffer.append(getPulseParameters());
         return buffer.toString();
     }
 }
+

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtCalibration.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SvtCalibration.java	2 Oct 2013 23:19:54 -0000	1.1
+++ SvtCalibration.java	4 Oct 2013 01:43:48 -0000	1.2
@@ -1,26 +1,45 @@
 package org.lcsim.hps.conditions.svt;
 
+/**
+ * This class represents a noise and pedestal measurement for an SVT channel.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
 class SvtCalibration {
     
-    int channelId;
-    double pedestal = Double.NaN;
     double noise = Double.NaN;
+    double pedestal = Double.NaN;
     
-    SvtCalibration(int channelId, double noise, double pedestal) {
-        this.channelId = channelId;
+    /**
+     * Fully qualified constructor.
+     * @param noise The noise value.
+     * @param pedestal The pedestal value.
+     */
+    SvtCalibration(double noise, double pedestal) {
         this.noise = noise;
         this.pedestal = pedestal;
     }
-    
-    public int getChannelId() {
-        return channelId;
-    }
-    
+        
+    /**
+     * Get the noise value.
+     * @return The noise value.
+     */
     public double getNoise() {
         return noise;
     }
     
+    /**
+     * Get the pedestal value.
+     * @return The pedestal value.
+     */
     public double getPedestal() {
         return pedestal;
     }
+    
+    /**
+     * Convert this object to a human readable string.
+     * @return This object converted to a string.
+     */
+    public String toString() {
+        return "noise: " + noise + ", pedestal: " + pedestal;
+    }
 }

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtCalibrationCollection.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SvtCalibrationCollection.java	2 Oct 2013 23:19:54 -0000	1.1
+++ SvtCalibrationCollection.java	4 Oct 2013 01:43:48 -0000	1.2
@@ -1,6 +1,11 @@
 package org.lcsim.hps.conditions.svt;
 
-import java.util.ArrayList;
+import java.util.LinkedHashMap;
 
-public class SvtCalibrationCollection extends ArrayList<SvtCalibration> {
+/**
+ * This class is a collection of {@link SvtCalibration} objects associated to their 
+ * SVT channel IDs from the database.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class SvtCalibrationCollection extends LinkedHashMap<Integer,SvtCalibration> {
 }

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtCalibrationConverter.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- SvtCalibrationConverter.java	2 Oct 2013 23:19:54 -0000	1.12
+++ SvtCalibrationConverter.java	4 Oct 2013 01:43:48 -0000	1.13
@@ -11,10 +11,10 @@
 import org.lcsim.hps.conditions.DatabaseConditionsConverter;
 
 /**
- * Read SVT calibration data from the conditions database.
+ * This class creates a {@link SvtCalibrationCollection} from the conditions database.
  * @author Omar Moreno <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SvtCalibrationConverter.java,v 1.12 2013/10/02 23:19:54 jeremy Exp $
+ * @version $Id: SvtCalibrationConverter.java,v 1.13 2013/10/04 01:43:48 jeremy Exp $
  */
 public class SvtCalibrationConverter extends DatabaseConditionsConverter<SvtCalibrationCollection> {
     
@@ -75,7 +75,7 @@
                 double noise = resultSet.getDouble(2);
                 double pedestal = resultSet.getDouble(3);
 
-                collection.add(new SvtCalibration(channelId, noise, pedestal));
+                collection.put(channelId, new SvtCalibration(noise, pedestal));
             }            
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtChannel.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SvtChannel.java	2 Oct 2013 23:19:54 -0000	1.1
+++ SvtChannel.java	4 Oct 2013 01:43:48 -0000	1.2
@@ -1,13 +1,21 @@
 package org.lcsim.hps.conditions.svt;
 
 /**
- * This class represents SVT channel data including hybrid, FPGA, and channel numbers.
+ * This class represents SVT channel setup information, including hybrid, FPGA, and channel numbers.
  * @author Jeremy McCormick <[log in to unmask]>
  */
 public class SvtChannel {
 
+    /** Channel data. */
     private int id, hybrid, fpga, channel;
     
+    /**
+     * Fully qualified constructor.
+     * @param id The database record ID from the channel table.
+     * @param fpga The FPGA number (0 to 6).
+     * @param hybrid The hybrid number (0 to 2).
+     * @param channel The channel number (0 to 639).
+     */
     SvtChannel(int id, int fpga, int hybrid, int channel) {
         this.id = id;
         this.fpga = fpga;
@@ -15,23 +23,61 @@
         this.channel = channel;
     }
     
+    /**
+     * Get the channel ID.
+     * @return The channel ID.
+     */
     public int getId() {
         return id;
     }
     
+    /**
+     * Get the hybrid number.
+     * @return The hybrid number.
+     */
     public int getHybrid() {
         return hybrid;
     }
     
+    /**
+     * Get the FPGA number.
+     * @return The FPGA number.
+     */
     public int getFpga() {
         return fpga;
     }
     
+    /**
+     * Get the channel number.  This is different from the ID.
+     * @return The channel number.
+     */
     public int getChannel() {
         return channel;
     }    
     
+    /**
+     * Convert this object to a human readable string.
+     * @return This object as a string.
+     */
     public String toString() {
         return "id: " + id + ", fpga: " + fpga + ", hybrid: " + hybrid + ", channel: " + channel;
     }
-}
+    
+    /**
+     * Implementation of equals.
+     * @return True if the object equals this one; false if not.
+     */
+    public boolean equals(Object o) {
+        if (o == null)
+            return false;
+        if (!(o instanceof SvtChannel))
+            return false;
+        if (o == this)
+            return true;
+        SvtChannel channel = (SvtChannel)o;
+        return id == channel.getId() 
+                && hybrid == channel.getHybrid() 
+                && fpga == channel.getFpga() 
+                && hybrid == channel.getHybrid();
+    }    
+}
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtChannelMap.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SvtChannelMap.java	2 Oct 2013 23:19:54 -0000	1.1
+++ SvtChannelMap.java	4 Oct 2013 01:43:48 -0000	1.2
@@ -2,12 +2,26 @@
 
 import java.util.HashMap;
 
-public class SvtChannelMap extends HashMap<Integer, SvtChannel> {
+/**
+ * This class represents a map between channels and their database IDs from the channels table.
+ * It can be used to lookup information in the {@link SvtConditions} object.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class SvtChannelMap extends HashMap<Integer,SvtChannel> {
     
+    /**
+     * Constructor, which is package protected.  Users should not 
+     * create this class directly but retrieve it from the {@link SvtConditions}
+     * object instead.
+     */
     SvtChannelMap() {
     }
-    
-    public String toString() {
+               
+    /**
+     * Convert this object to a human readable string.
+     * @return This object converted to a string.
+     */
+    public String toString() {        
         StringBuffer buff = new StringBuffer();
         for (SvtChannel channel : values()) {
             buff.append(channel.toString() + '\n');

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtChannelMapConverter.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SvtChannelMapConverter.java	2 Oct 2013 23:19:54 -0000	1.1
+++ SvtChannelMapConverter.java	4 Oct 2013 01:43:48 -0000	1.2
@@ -11,10 +11,19 @@
 import org.lcsim.hps.conditions.ConnectionManager;
 import org.lcsim.hps.conditions.DatabaseConditionsConverter;
 
+/**
+ * This class converts conditions database records into an {@link SvtChannelMap}.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
 public class SvtChannelMapConverter extends DatabaseConditionsConverter<SvtChannelMap> {
 
+    /**
+     * Create the objects from the database.
+     * @param manager The current conditions manager.
+     * @param name The name of the conditions set.
+     */
     public SvtChannelMap getData(ConditionsManager manager, String name) {
-                                       
+                
         // References to database objects.
         Statement statement = null;
         ResultSet resultSet = null;
@@ -30,10 +39,14 @@
             
             // Get the name of the current database being used.
             String database = ConnectionManager.getConnectionParameters().getDatabase();
-                                
+            
+            // Assign default key name for channel data if none given.
+            if (name == null)
+                name = SVT_CHANNELS;
+            
             // Construct the query to find matching calibration records using the ID field.
             String query = "SELECT id, fpga, hybrid, channel FROM "
-                    + database + "." + SVT_CHANNELS;
+                    + database + "." + name;
             
             // Execute the query and get the results.
             statement = connection.createStatement();
@@ -70,6 +83,10 @@
         return channels;
     }
 
+    /**
+     * Get the type handled by this converter.
+     * @return The type handled by this converter.
+     */
     public Class<SvtChannelMap> getType() {
         return SvtChannelMap.class;
     }

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtConditions.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- SvtConditions.java	2 Oct 2013 23:19:54 -0000	1.7
+++ SvtConditions.java	4 Oct 2013 01:43:48 -0000	1.8
@@ -4,12 +4,14 @@
 import java.util.Map;
 
 /**
- * This class models all available SVT conditions data, including 
- * noise, pedestal, shaping time, and time shift by channel.
+ * This class contains all SVT conditions data by readout channel.
+ * {@link SvtChannel} objects from the {@linkSvtChannelMap} should be 
+ * used to lookup the conditions using the 
+ * {@link #getChannelConstants(SvtChannel)} method.
  * 
  * @author Omar Moreno <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SvtConditions.java,v 1.7 2013/10/02 23:19:54 jeremy Exp $
+ * @version $Id: SvtConditions.java,v 1.8 2013/10/04 01:43:48 jeremy Exp $
  */
 public class SvtConditions {
     
@@ -17,83 +19,106 @@
     private SvtChannelMap channelMap = null;
     
     /**
-     * Class constructor.
+     * Class constructor, which takes a channel map.
+     * @param channelMap The SVT channel map.
      */
-    SvtConditions() {
-    }     
-    
-    void setChannelMap(SvtChannelMap channelMap) {
+    SvtConditions(SvtChannelMap channelMap) {
         this.channelMap = channelMap;
-    }
-    
-    ChannelConstants getChannelConstants(SvtChannel channel) {
-        return channelData.get(channel);
-    }
-    
-    void setNoise(SvtChannel channel, double noise) {
-        if (channelData.get(channel) == null)
-            channelData.put(channel, new ChannelConstants());
-        channelData.get(channel).setNoise(noise);
-    }
-    
-    void setPedestal(SvtChannel channel, double pedestal) {
-        if (channelData.get(channel) == null)
-            channelData.put(channel, new ChannelConstants());
-        channelData.get(channel).setPedestal(pedestal);
-    }
-    
-    void setShapingTime(SvtChannel channel, double tp) {
-        if (channelData.get(channel) == null)
-            channelData.put(channel, new ChannelConstants());
-        channelData.get(channel).setShapingTime(tp);
-    }
-    
-    void setT0Shift(SvtChannel channel, double t0) {
-        if (channelData.get(channel) == null)
-            channelData.put(channel, new ChannelConstants());
-        channelData.get(channel).setT0Shift(t0);
-    }
-    
-    void setPulseShape(SvtChannel channel, double[][] pulseShape) {
-        if (channelData.get(channel) == null)
-            channelData.put(channel, new ChannelConstants());
-        channelData.get(channel).setPulseShape(pulseShape);
-    }
-    
-    void setBadChannel(SvtChannel channel) {
-        if (channelData.get(channel) == null)
+    }     
+        
+    /**
+     * Get the conditions constants for a specific channel.  These will be
+     * created if they do not exist for the given channel, BUT only channels
+     * in the current channel map are allowed as an argument.
+     * @param channel The SVT channel.
+     * @return The conditions constants for the channel.
+     * @throws IllegalArgumentException if .
+     */
+    public ChannelConstants getChannelConstants(SvtChannel channel) {
+        // This channel must come from the map.
+        if (!channelMap.containsValue(channel)) {
+            System.err.println("Channel not found in map => " + channel);
+            throw new IllegalArgumentException("Channel was not found in map.");
+        }
+        // If channel has no data yet, then add it.
+        if (!channelData.containsKey(channel))
             channelData.put(channel, new ChannelConstants());
-        channelData.get(channel).setBadChannel(true);
-    }
-    
+        return channelData.get(channel);
+    }         
+        
+    /**
+     * Get the {@link SvtChannelMap} for this set of conditions.
+     * @return The SVT channel map.
+     */
     public SvtChannelMap getChannelMap() {
         return channelMap;
     }
-    
-    public double getNoise(SvtChannel channel) {
-        return channelData.get(channel).getNoise();
-    }
-    
-    public double getPedestal(SvtChannel channel) {
-        return channelData.get(channel).getPedestal();
-    }
-    
-    public double getShapingTime(SvtChannel channel) {
-        return channelData.get(channel).getShapingTime();
-    }
-    
-    public double getT0Shift(SvtChannel channel) {
-        return channelData.get(channel).getT0Shift();
-    }
-        
+            
+    /**
+     * Convert this object to a human readable string.  This method prints a formatted table 
+     * independently of how its member objects implement their string conversion.
+     * @return This object converted to a string.
+     */
     public String toString() {
         StringBuffer buff = new StringBuffer();
-        for (SvtChannel channel : channelMap.values()) {            
-            buff.append(channel);
-            buff.append(", ");
-            buff.append(channelData.get(channel));
-            buff.append('\n');
+        // Table header:
+        buff.append("id");
+        buff.append("     ");
+        buff.append("fpga");
+        buff.append("  ");
+        buff.append("hybrid");
+        buff.append("   ");
+        buff.append("channel");
+        buff.append("  ");
+        buff.append("noise");
+        buff.append("     ");
+        buff.append("pedestal");
+        buff.append("    ");
+        buff.append("gain");
+        buff.append("   ");
+        buff.append("offset");
+        buff.append("    ");
+        buff.append("amplitude");
+        buff.append("  ");
+        buff.append("t0");
+        buff.append("       ");
+        buff.append("shift");
+        buff.append("    ");
+        buff.append("chisq");
+        buff.append("      ");
+        buff.append("bad");
+        buff.append('\n'); 
+        for (int i=0; i<115; i++) {
+            buff.append("-");
+        }        
+        buff.append('\n');
+        // Loop over channels.
+        for (SvtChannel channel : channelMap.values()) {
+            
+            // Get the conditions for the channel.
+            ChannelConstants constants = getChannelConstants(channel);
+            SvtGain gain = constants.getGain();
+            PulseParameters pulse = constants.getPulseParameters();
+            SvtCalibration calibration = constants.getCalibration();
+            
+            // Channel data.
+            buff.append(String.format("%-6d %-5d %-8d %-8d ", channel.getId(), channel.getFpga(), channel.getHybrid(), channel.getChannel()));
+
+            // Calibration.
+            buff.append(String.format("%-9.4f %-11.4f ", calibration.getNoise(), calibration.getPedestal()));
+            
+            // Gain.
+            buff.append(String.format("%-6.4f %-9.4f ", gain.getGain(), gain.getOffset()));
+            
+            // Pulse shape.
+            buff.append(String.format("%-10.4f %-8.4f %-8.4f %-10.4f ", pulse.getAmplitude(), pulse.getT0(), pulse.getTimeShift(), pulse.getChisq()));
+            
+            // Bad channel.
+            buff.append(constants.isBadChannel());
+            
+            buff.append('\n');                                  
         }
         return buff.toString();
     }
 }
+

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtConditionsLoader.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- SvtConditionsLoader.java	2 Oct 2013 23:19:54 -0000	1.6
+++ SvtConditionsLoader.java	4 Oct 2013 01:43:48 -0000	1.7
@@ -1,13 +1,19 @@
 package org.lcsim.hps.conditions.svt;
 
-import static org.lcsim.hps.conditions.ConditionsConstants.SVT_CALIBRATIONS;
 import static org.lcsim.hps.conditions.ConditionsConstants.SVT_BAD_CHANNELS;
+import static org.lcsim.hps.conditions.ConditionsConstants.SVT_CALIBRATIONS;
+import static org.lcsim.hps.conditions.ConditionsConstants.SVT_PULSE_PARAMETERS;
+import static org.lcsim.hps.conditions.ConditionsConstants.SVT_CHANNELS;
+import static org.lcsim.hps.conditions.ConditionsConstants.SVT_GAINS;
+
+import java.util.Map.Entry;
 
-import org.lcsim.conditions.CachedConditions;
 import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.hps.conditions.ChannelCollection;
 
 /**
- * This class creates an {@link SvtConditions} object from the conditions database.
+ * This class creates an {@link SvtConditions} object from the conditions database,
+ * based on the current run number known by the conditions manager.
  */
 public class SvtConditionsLoader {
         
@@ -21,37 +27,39 @@
                         
         // Get the default conditions manager.  This needs to be setup beforehand with the detector.        
         ConditionsManager manager = ConditionsManager.defaultInstance();
-        
-        // Reset the conditions object.
-        conditions = new SvtConditions();
-        
+                
         // Get the SVT channel map.
-        SvtChannelMap channels = manager.getCachedConditions(SvtChannelMap.class, null).getCachedData();
+        SvtChannelMap channels = manager.getCachedConditions(SvtChannelMap.class, SVT_CHANNELS).getCachedData();
         
-        /// Set the channel map reference in the conditions object.
-        conditions.setChannelMap(channels);
-        
-        // Print channel map.
-        //System.out.println(channels);
-                       
-        // Get the SVT calibrations from the database.
-        CachedConditions<SvtCalibrationCollection> c = 
-                manager.getCachedConditions(SvtCalibrationCollection.class, SVT_CALIBRATIONS);
-        SvtCalibrationCollection calibrations = c.getCachedData();
-        
-        // Set calibration values.
-        for (SvtCalibration calibration : calibrations) {
-            SvtChannel channel = channels.get(calibration.getChannelId());
-            conditions.setNoise(channel, calibration.getNoise());
-            conditions.setPedestal(channel, calibration.getPedestal());
+        // Reset the conditions object.
+        conditions = new SvtConditions(channels);
+                                       
+        // Add calibrations by channel.
+        SvtCalibrationCollection calibrations = manager.getCachedConditions(SvtCalibrationCollection.class, SVT_CALIBRATIONS).getCachedData();
+        for (Entry<Integer,SvtCalibration> entry : calibrations.entrySet()) {
+            SvtChannel channel = conditions.getChannelMap().get(entry.getKey());
+            conditions.getChannelConstants(channel).setCalibration(entry.getValue());
         }  
         
-        // Get the bad channel list.
-        SvtBadChannelCollection badChannels = manager.getCachedConditions(SvtBadChannelCollection.class, SVT_BAD_CHANNELS).getCachedData();
+        // Add pulse parameters by channel.
+        PulseParametersCollection pulseParameters = manager.getCachedConditions(PulseParametersCollection.class, SVT_PULSE_PARAMETERS).getCachedData();
+        for (Entry<Integer,PulseParameters> entry : pulseParameters.entrySet()) {
+            SvtChannel channel = conditions.getChannelMap().get(entry.getKey());
+            conditions.getChannelConstants(channel).setPulseParameters(entry.getValue());
+        }
         
         // Add bad channels.
+        ChannelCollection badChannels = manager.getCachedConditions(ChannelCollection.class, SVT_BAD_CHANNELS).getCachedData();        
         for (Integer badChannel : badChannels) {
-            conditions.setBadChannel(channels.get(badChannel));
+            SvtChannel channel = conditions.getChannelMap().get(badChannel);
+            conditions.getChannelConstants(channel).setBadChannel(true);
+        }
+        
+        // Add gains by channel.
+        SvtGainCollection gains = manager.getCachedConditions(SvtGainCollection.class, SVT_GAINS).getCachedData();
+        for (Entry<Integer,SvtGain> entry : gains.entrySet()) {
+            SvtChannel channel = conditions.getChannelMap().get(entry.getKey());
+            conditions.getChannelConstants(channel).setGain(entry.getValue());
         }
     }
     

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtBadChannelCollection.java removed after 1.1
diff -N SvtBadChannelCollection.java
--- SvtBadChannelCollection.java	2 Oct 2013 23:19:54 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
-package org.lcsim.hps.conditions.svt;
-
-import java.util.HashSet;
-
-public class SvtBadChannelCollection extends HashSet<Integer> {
-}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtBadChannelConverter.java removed after 1.1
diff -N SvtBadChannelConverter.java
--- SvtBadChannelConverter.java	2 Oct 2013 23:19:54 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,95 +0,0 @@
-package org.lcsim.hps.conditions.svt;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.hps.conditions.ConditionsRecord;
-import org.lcsim.hps.conditions.ConnectionManager;
-import org.lcsim.hps.conditions.DatabaseConditionsConverter;
-
-/**
- * This class creates a list of bad channel IDs.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class SvtBadChannelConverter extends DatabaseConditionsConverter<SvtBadChannelCollection> {
-
-    /**
-     * Create the collection from the conditions database. 
-     * @param manager The conditions manager.
-     * @param name The name of the conditions set.
-     */
-    public SvtBadChannelCollection getData(ConditionsManager manager, String name) {
-
-        // Collection to be returned to caller.
-        SvtBadChannelCollection badChannels = new SvtBadChannelCollection();
-
-        // Get the ConditionsRecord with the meta-data, which will use the
-        // current run number from the manager.
-        ConditionsRecord record = ConditionsRecord.find(manager, name);
-
-        // Get the table name, field name, and field value defining the
-        // applicable conditions.
-        String tableName = record.getTableName();
-        String fieldName = record.getFieldName();
-        int fieldValue = record.getFieldValue();
-
-        // References to database objects.
-        Statement statement = null;
-        ResultSet resultSet = null;
-        Connection connection = null;
-
-        try {
-
-            // Get a connection from the manager.
-            connection = ConnectionManager.createConnection();
-
-            // Get the name of the current database being used.
-            String database = ConnectionManager.getConnectionParameters().getDatabase();
-
-            String query = "SELECT svt_channel_id FROM " 
-                    + database + "." + tableName + " WHERE " 
-                    + fieldName + " = " + fieldValue 
-                    + " ORDER BY id ASC";
-
-            // Execute the query and get the results.
-            statement = connection.createStatement();
-            resultSet = statement.executeQuery(query);
-
-            // Loop over the records.
-            while (resultSet.next()) {
-                int channelId = resultSet.getInt(1);
-                badChannels.add(channelId);
-            }
-        } catch (SQLException x) {
-            throw new RuntimeException("Database error.", x);
-        } finally {
-            // Cleanup the SQL statement.
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (Exception xx) {
-                }
-            }
-            // Cleanup the connection.
-            if (connection != null) {
-                try {
-                    connection.close();
-                } catch (Exception x) {
-                }
-            }
-        }
-        return badChannels;
-    }
-
-    /**
-     * Get the type handled by this converter.
-     * 
-     * @return The type handled by this converter.
-     */
-    public Class<SvtBadChannelCollection> getType() {
-        return SvtBadChannelCollection.class;
-    }
-}

hps-java/src/test/java/org/lcsim/hps/conditions
ConditionsLoaderTest.java added at 1.1
diff -N ConditionsLoaderTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ConditionsLoaderTest.java	4 Oct 2013 01:43:48 -0000	1.1
@@ -0,0 +1,64 @@
+package org.lcsim.hps.conditions;
+
+import junit.framework.TestCase;
+
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
+import org.lcsim.hps.conditions.ecal.EcalConditions;
+import org.lcsim.hps.conditions.svt.SvtConditions;
+import org.lcsim.util.loop.LCSimConditionsManagerImplementation;
+
+/**
+ * This class tests the {@link ConditionsLoader} which loads SVT and ECAL conditions.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class ConditionsLoaderTest extends TestCase {
+    
+    /** An example detector from hps-detectors. */
+    private static final String detectorName = "HPS-conditions-test";
+    
+    /** The run number of the conditions set in the database. */
+    private static final int runNumber = 777;
+    
+    /** The number of channels that should be in the SVT channel map. */
+    private static final int SVT_CHANNELS = 12800;
+    
+    /** The number of channels that should be in the ECAL channel map. */
+    private static final int ECAL_CHANNELS = 442;
+    
+    public void test() {
+        
+        // Setup the conditions manager.        
+        ConditionsManager.setDefaultConditionsManager(new LCSimConditionsManagerImplementation());
+        ConditionsManager manager = ConditionsManager.defaultInstance();
+        try {
+            manager.setDetector(detectorName, runNumber);
+        } catch (ConditionsNotFoundException e) {
+            throw new RuntimeException(e);
+        }        
+        
+        // Load the SVT and ECAL conditions.
+        ConditionsLoader loader = new ConditionsLoader();
+        loader.load();
+        
+        // Check SVT conditions.
+        SvtConditions svt = loader.getSvtConditions();
+        System.out.println();
+        System.out.println("Printing SVT conditions ...");
+        System.out.println();
+        System.out.println(svt);
+        assertNotNull(svt);
+        assertEquals("Wrong number of SVT channels in map.", SVT_CHANNELS, svt.getChannelMap().size());
+                
+        // Check ECAL conditions.        
+        EcalConditions ecal = loader.getEcalConditions();
+        System.out.println();
+        System.out.println("Printing ECAL conditions ...");
+        System.out.println();
+        System.out.println(ecal);
+        assertNotNull(ecal);
+        assertEquals("Wrong number of ECAL channels in map.", ECAL_CHANNELS, ecal.getChannelMap().size());
+    }
+
+}
+

hps-java/src/test/java/org/lcsim/hps/conditions
DatabaseConditionsReaderTest.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- DatabaseConditionsReaderTest.java	2 Oct 2013 23:19:55 -0000	1.7
+++ DatabaseConditionsReaderTest.java	4 Oct 2013 01:43:48 -0000	1.8
@@ -41,13 +41,7 @@
 	} catch (ConditionsNotFoundException e) {
 	    throw new RuntimeException(e);
 	}
-	
-	//ConditionsSet conditions = manager.getConditions(conditionsSetName);
-	//ps.println("Got conditions " + conditionsSetName + " of size " + conditions.size());
-	//ps.println("table: " + conditions.getString("table"));
-	//ps.println("column: " + conditions.getString("column"));
-	//ps.println("id: " + conditions.getString("id"));
-		
+			
 	CachedConditions<ConditionsRecordCollection> c2 = manager.getCachedConditions(ConditionsRecordCollection.class, null);
 	ConditionsRecordCollection rc = c2.getCachedData();
 	for (ConditionsRecord r : rc.values()) {

hps-java/src/test/java/org/lcsim/hps/conditions/svt
SvtConditionsLoaderTest.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SvtConditionsLoaderTest.java	2 Oct 2013 23:19:55 -0000	1.2
+++ SvtConditionsLoaderTest.java	4 Oct 2013 01:43:48 -0000	1.3
@@ -1,13 +1,9 @@
 package org.lcsim.hps.conditions.svt;
 
-import java.util.List;
-
 import junit.framework.TestCase;
 
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
-import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.geometry.Detector;
 import org.lcsim.util.loop.LCSimConditionsManagerImplementation;
 
 /**
@@ -22,13 +18,7 @@
     
     /** The run number of the conditions set in the database. */
     private static final int runNumber = 777;
-    
-    /** Maximum channel number in a sensor. */
-    private static final int MAX_CHANNEL = 639;
-    
-    /** The total number of SVT channels on the detector. */
-    private static final int TOTAL_CHANNELS = 12800;
-        
+            
     /**
      * Load and check SVT channel conditions.
      */
@@ -42,46 +32,12 @@
         } catch (ConditionsNotFoundException e) {
             throw new RuntimeException(e);
         }
-        
-        // Now we need to setup the Detector for the conditions loader.
-        //Detector detector =
-        //        manager.getCachedConditions(Detector.class, "compact.xml").getCachedData();
-        //SvtUtils.getInstance().setup(detector);
-                                
+                                        
         // Test that the loader returns valid conditions.
         SvtConditionsLoader loader = new SvtConditionsLoader();
         loader.load();
         SvtConditions conditions = loader.getSvtConditions();
         assertNotNull(conditions);        
-        System.out.println(conditions);
-        
-        /*
-        // Get all the sensors on the detector.        
-        List<SiSensor> sensors = detector.getDetectorElement().findDescendants(SiSensor.class);
-        int totalChannelsFound = 0;
-        
-        // Loop over sensors.
-        for (SiSensor sensor : sensors) {
-            System.out.println(sensor.getName());
-            // Loop over channels in sensor.
-            for (int channel=0; channel <= MAX_CHANNEL; channel++ ) {
-                
-                // Get data for channel.
-                double noise = conditions.getNoise(sensor, channel);
-                double pedestal = conditions.getPedestal(sensor, channel);
-                
-                // Print channel data.
-                System.out.println("  channel: " + channel + ", noise: " + noise + ", pedestal: " + pedestal);
-                
-                // Assert values are not zero.
-                assertTrue("Noise value is zero.", noise != 0.0);
-                assertTrue("Pedestal valud is zero.", pedestal != 0.0);
-                
-                ++totalChannelsFound;
-            }
-        }
-        System.out.println("got conditions for " + totalChannelsFound + " channels");
-        assertEquals("Wrong number of total channels.", TOTAL_CHANNELS, totalChannelsFound);
-        */
+        System.out.println(conditions);        
     }
 }
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