Commit in hps-java/src on MAIN
main/java/org/lcsim/hps/conditions/ConditionsConstants.java+31.4 -> 1.5
                                  /DatabaseConditionsReader.java+6-21.10 -> 1.11
main/java/org/lcsim/hps/conditions/svt/SvtBadChannelCollection.java+6added 1.1
                                      /SvtBadChannelConverter.java+95added 1.1
                                      /SvtCalibration.java+26added 1.1
                                      /SvtCalibrationCollection.java+6added 1.1
                                      /SvtChannel.java+37added 1.1
                                      /SvtChannelMap.java+17added 1.1
                                      /SvtChannelMapConverter.java+77added 1.1
                                      /ChannelConstants.java+22-531.3 -> 1.4
                                      /ChannelConstantsCollection.java+1-11.2 -> 1.3
                                      /SvtCalibrationConverter.java+13-221.11 -> 1.12
                                      /SvtConditions.java+72-911.6 -> 1.7
                                      /SvtConditionsLoader.java+28-321.5 -> 1.6
                                      /SvtUtils.java-6281.1 removed
test/java/org/lcsim/hps/conditions/DatabaseConditionsReaderTest.java+5-51.6 -> 1.7
test/java/org/lcsim/hps/conditions/ecal/EcalConditionsLoaderTest.java+1-81.2 -> 1.3
test/java/org/lcsim/hps/conditions/svt/SvtConditionsLoaderTest.java+8-61.1 -> 1.2
+423-848
7 added + 1 removed + 10 modified, total 18 files
more work on SVT conditions; refactor calibrations code; add bad channels

hps-java/src/main/java/org/lcsim/hps/conditions
ConditionsConstants.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- ConditionsConstants.java	2 Oct 2013 17:57:59 -0000	1.4
+++ ConditionsConstants.java	2 Oct 2013 23:19:54 -0000	1.5
@@ -27,4 +27,7 @@
             
     /** Conditions key for SVT calibration data. */ 
     public static final String SVT_CALIBRATIONS = "svt_calibrations";
+    
+    /** Conditions key for SVT bad channels. */
+    public static final String SVT_BAD_CHANNELS = "svt_bad_channels";
 }

hps-java/src/main/java/org/lcsim/hps/conditions
DatabaseConditionsReader.java 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- DatabaseConditionsReader.java	1 Oct 2013 00:34:29 -0000	1.10
+++ DatabaseConditionsReader.java	2 Oct 2013 23:19:54 -0000	1.11
@@ -16,7 +16,9 @@
 import org.lcsim.hps.conditions.ecal.EcalCalibrationConverter;
 import org.lcsim.hps.conditions.ecal.EcalChannelConverter;
 import org.lcsim.hps.conditions.ecal.EcalGainConverter;
+import org.lcsim.hps.conditions.svt.SvtBadChannelConverter;
 import org.lcsim.hps.conditions.svt.SvtCalibrationConverter;
+import org.lcsim.hps.conditions.svt.SvtChannelMapConverter;
 
 /**
  * <p>
@@ -44,7 +46,7 @@
  * </p>
  * 
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: DatabaseConditionsReader.java,v 1.10 2013/10/01 00:34:29 jeremy Exp $ 
+ * @version $Id: DatabaseConditionsReader.java,v 1.11 2013/10/02 23:19:54 jeremy Exp $ 
  */
 public class DatabaseConditionsReader extends ConditionsReader {
         
@@ -205,10 +207,12 @@
      */
     private void registerConditionsConverters(ConditionsManager manager) {
         manager.registerConditionsConverter(new ConditionsRecordConverter());
+        manager.registerConditionsConverter(new SvtChannelMapConverter());
         manager.registerConditionsConverter(new SvtCalibrationConverter());
+        manager.registerConditionsConverter(new SvtBadChannelConverter());
         manager.registerConditionsConverter(new EcalChannelConverter());
         manager.registerConditionsConverter(new EcalGainConverter());
         manager.registerConditionsConverter(new EcalBadChannelConverter());
-        manager.registerConditionsConverter(new EcalCalibrationConverter());        
+        manager.registerConditionsConverter(new EcalCalibrationConverter());
     }
 }

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtBadChannelCollection.java added at 1.1
diff -N SvtBadChannelCollection.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtBadChannelCollection.java	2 Oct 2013 23:19:54 -0000	1.1
@@ -0,0 +1,6 @@
+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 added at 1.1
diff -N SvtBadChannelConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtBadChannelConverter.java	2 Oct 2013 23:19:54 -0000	1.1
@@ -0,0 +1,95 @@
+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/main/java/org/lcsim/hps/conditions/svt
SvtCalibration.java added at 1.1
diff -N SvtCalibration.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtCalibration.java	2 Oct 2013 23:19:54 -0000	1.1
@@ -0,0 +1,26 @@
+package org.lcsim.hps.conditions.svt;
+
+class SvtCalibration {
+    
+    int channelId;
+    double pedestal = Double.NaN;
+    double noise = Double.NaN;
+    
+    SvtCalibration(int channelId, double noise, double pedestal) {
+        this.channelId = channelId;
+        this.noise = noise;
+        this.pedestal = pedestal;
+    }
+    
+    public int getChannelId() {
+        return channelId;
+    }
+    
+    public double getNoise() {
+        return noise;
+    }
+    
+    public double getPedestal() {
+        return pedestal;
+    }
+}

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

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtChannel.java added at 1.1
diff -N SvtChannel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtChannel.java	2 Oct 2013 23:19:54 -0000	1.1
@@ -0,0 +1,37 @@
+package org.lcsim.hps.conditions.svt;
+
+/**
+ * This class represents SVT channel data including hybrid, FPGA, and channel numbers.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class SvtChannel {
+
+    private int id, hybrid, fpga, channel;
+    
+    SvtChannel(int id, int fpga, int hybrid, int channel) {
+        this.id = id;
+        this.fpga = fpga;
+        this.hybrid = hybrid;        
+        this.channel = channel;
+    }
+    
+    public int getId() {
+        return id;
+    }
+    
+    public int getHybrid() {
+        return hybrid;
+    }
+    
+    public int getFpga() {
+        return fpga;
+    }
+    
+    public int getChannel() {
+        return channel;
+    }    
+    
+    public String toString() {
+        return "id: " + id + ", fpga: " + fpga + ", hybrid: " + hybrid + ", channel: " + channel;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtChannelMap.java added at 1.1
diff -N SvtChannelMap.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtChannelMap.java	2 Oct 2013 23:19:54 -0000	1.1
@@ -0,0 +1,17 @@
+package org.lcsim.hps.conditions.svt;
+
+import java.util.HashMap;
+
+public class SvtChannelMap extends HashMap<Integer, SvtChannel> {
+    
+    SvtChannelMap() {
+    }
+    
+    public String toString() {
+        StringBuffer buff = new StringBuffer();
+        for (SvtChannel channel : values()) {
+            buff.append(channel.toString() + '\n');
+        }
+        return buff.toString();
+    }
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtChannelMapConverter.java added at 1.1
diff -N SvtChannelMapConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtChannelMapConverter.java	2 Oct 2013 23:19:54 -0000	1.1
@@ -0,0 +1,77 @@
+package org.lcsim.hps.conditions.svt;
+
+import static org.lcsim.hps.conditions.ConditionsConstants.SVT_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;
+
+public class SvtChannelMapConverter extends DatabaseConditionsConverter<SvtChannelMap> {
+
+    public SvtChannelMap getData(ConditionsManager manager, String name) {
+                                       
+        // References to database objects.
+        Statement statement = null;
+        ResultSet resultSet = null;
+        Connection connection = null;
+
+        // Objects for building the return value.
+        SvtChannelMap channels = new SvtChannelMap();
+        
+        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 id, fpga, hybrid, channel FROM "
+                    + database + "." + SVT_CHANNELS;
+            
+            // Execute the query and get the results.
+            statement = connection.createStatement();
+            resultSet = statement.executeQuery(query);
+                
+            while(resultSet.next()) {    
+
+                int id = resultSet.getInt(1);
+                int fpga = resultSet.getInt(2);
+                int hybrid = resultSet.getInt(3);
+                int channel = resultSet.getInt(4);
+
+                SvtChannel data = new SvtChannel(id, fpga, hybrid, channel);
+                channels.put(data.getId(), data);
+            }            
+        } 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;
+    }
+
+    public Class<SvtChannelMap> getType() {
+        return SvtChannelMap.class;
+    }
+
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
ChannelConstants.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- ChannelConstants.java	23 Sep 2013 23:09:10 -0000	1.3
+++ ChannelConstants.java	2 Oct 2013 23:19:54 -0000	1.4
@@ -1,88 +1,58 @@
 package org.lcsim.hps.conditions.svt;
 
 /**
+ * This class represents the conditions for a single SVT channel.
  * 
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: ChannelConstants.java,v 1.3 2013/09/23 23:09:10 jeremy Exp $
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: ChannelConstants.java,v 1.4 2013/10/02 23:19:54 jeremy Exp $
  */
-public class ChannelConstants {
-
-    private int fpga = -1;
-    private int hybrid = -1;
-    private int channel = -1;
+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 boolean badChannel = false;
 
     /**
      * Default Ctor
      */
-    public ChannelConstants() {
+    ChannelConstants() {
     }
 
-    public ChannelConstants(int fpga, int hybrid, int channel, double pedestal,
-            double noise, double tp, double t0Shift, double[][] pulseShape) {
-        this.setFpga(fpga);
-        this.setHybrid(hybrid);
-        this.setChannel(channel);
+    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);
     }
-
-    // --- Setters ---//
-    // ---------------//
-
-    public void setFpga(int fpga) {
-        this.fpga = fpga;
-    }
-
-    public void setHybrid(int hybrid) {
-        this.hybrid = hybrid;
-    }
-
-    public void setChannel(int channel) {
-        this.channel = channel;
-    }
-
-    public void setNoise(double noise) {
+   
+    void setNoise(double noise) {
         this.noise = noise;
     }
 
-    public void setPedestal(double pedestal) {
+    void setPedestal(double pedestal) {
         this.pedestal = pedestal;
     }
 
-    public void setShapingTime(double tp) {
+    void setShapingTime(double tp) {
         this.tp = tp;
     }
 
-    public void setT0Shift(double t0Shift) {
+    void setT0Shift(double t0Shift) {
         this.t0Shift = t0Shift;
     }
 
-    public void setPulseShape(double[][] pulseShape) {
+    void setPulseShape(double[][] pulseShape) {
         this.pulseShape = pulseShape;
     }
-
-    // --- Getters ---//
-    // ---------------//
-
-    public int getFpga() {
-        return fpga;
-    }
-
-    public int getHybrid() {
-        return hybrid;
-    }
-
-    public int getChannel() {
-        return channel;
+    
+    void setBadChannel(boolean badChannel) {
+        this.badChannel = badChannel;
     }
 
     public double getNoise() {
@@ -105,14 +75,13 @@
         return pulseShape;
     }
 
-    @Override
     public String toString() {
-        StringBuffer buffer = new StringBuffer();
-        buffer.append("fpga: " + this.getFpga() + ", ");
-        buffer.append("hybrid: " + this.getHybrid() + ", ");
-        buffer.append("channel: " + this.getChannel() + ", ");
+        StringBuffer buffer = new StringBuffer();        
         buffer.append("pedestal: " + this.getPedestal() + ", ");
-        buffer.append("noise: " + this.getNoise() + '\n');
+        buffer.append("noise: " + this.getNoise() + ", ");
+        buffer.append("t0: " + this.getT0Shift() + ", ");
+        buffer.append("tp: " + this.getShapingTime());
+        // TODO: add print pulse shape here
         return buffer.toString();
     }
 }

hps-java/src/main/java/org/lcsim/hps/conditions/svt
ChannelConstantsCollection.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- ChannelConstantsCollection.java	24 Sep 2013 02:51:35 -0000	1.2
+++ ChannelConstantsCollection.java	2 Oct 2013 23:19:54 -0000	1.3
@@ -7,7 +7,7 @@
  * This is a set of ChannelConstant objects mapped to their IDs (from the database).
  * @author Jeremy McCormick <[log in to unmask]>
  */
-public class ChannelConstantsCollection extends LinkedHashMap<Integer,ChannelConstants> {
+class ChannelConstantsCollection extends LinkedHashMap<Integer,ChannelConstants> {
     
     ChannelConstants getChannelConstants(Integer channelId) {
         return this.get(channelId);

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtCalibrationConverter.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- SvtCalibrationConverter.java	1 Oct 2013 01:22:33 -0000	1.11
+++ SvtCalibrationConverter.java	2 Oct 2013 23:19:54 -0000	1.12
@@ -6,7 +6,6 @@
 import java.sql.Statement;
 
 import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.hps.conditions.ConditionsConstants;
 import org.lcsim.hps.conditions.ConditionsRecord;
 import org.lcsim.hps.conditions.ConnectionManager;
 import org.lcsim.hps.conditions.DatabaseConditionsConverter;
@@ -15,9 +14,9 @@
  * Read SVT calibration data from the conditions database.
  * @author Omar Moreno <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SvtCalibrationConverter.java,v 1.11 2013/10/01 01:22:33 jeremy Exp $
+ * @version $Id: SvtCalibrationConverter.java,v 1.12 2013/10/02 23:19:54 jeremy Exp $
  */
-public class SvtCalibrationConverter extends DatabaseConditionsConverter<ChannelConstantsCollection> {
+public class SvtCalibrationConverter extends DatabaseConditionsConverter<SvtCalibrationCollection> {
     
     /**
      * Class constructor.
@@ -31,7 +30,7 @@
      * @param name The name of the conditions set.
      * @return The channel constants data.
      */
-    public ChannelConstantsCollection getData(ConditionsManager manager, String name) {
+    public SvtCalibrationCollection 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);
@@ -47,8 +46,7 @@
         Connection connection = null;
 
         // Objects for building the return value.
-        ChannelConstants constants = null;
-        ChannelConstantsCollection collection = new ChannelConstantsCollection();
+        SvtCalibrationCollection collection = new SvtCalibrationCollection();
         
         try {
                                                  
@@ -59,13 +57,11 @@
             String database = ConnectionManager.getConnectionParameters().getDatabase();
                                 
             // Construct the query to find matching calibration records using the ID field.
-            String query = "SELECT svt_channel_id, fpga, hybrid, channel, noise, pedestal FROM "
-                    + database + "." + tableName + ", "
-                    + database + "." + ConditionsConstants.SVT_CHANNELS
+            String query = "SELECT svt_channel_id, noise, pedestal FROM "
+                    + database + "." + tableName 
                     + " WHERE "
                     + fieldName + " = " + fieldValue
-                    + " AND svt_channels.id = " + tableName + ".svt_channel_id "
-                    + "ORDER BY svt_channels.id ASC";
+                    + " ORDER BY svt_channel_id ASC";
             
             // Execute the query and get the results.
             statement = connection.createStatement();
@@ -73,18 +69,13 @@
                 
             // Loop over the calibration records.
             while(resultSet.next()) {    
-
+                              
                 // Get the calibration data for a single channel.
                 int channelId = resultSet.getInt(1);
-                int fpga = resultSet.getInt(2);
-                int hybrid = resultSet.getInt(3);
-                int channel = resultSet.getInt(4);
-                double noise = resultSet.getDouble(5);
-                double pedestal = resultSet.getDouble(6);
+                double noise = resultSet.getDouble(2);
+                double pedestal = resultSet.getDouble(3);
 
-                // Add channel constants to the return collection.
-                constants = new ChannelConstants(fpga, hybrid, channel, pedestal, noise, Double.NaN, Double.NaN, null);            
-                collection.put(channelId, constants);
+                collection.add(new SvtCalibration(channelId, noise, pedestal));
             }            
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);
@@ -112,7 +103,7 @@
      * Get the type handled by this converter.     
      * @return The type handled by this converter, which is <code>ConditionsRecordCollection</code>.
      */
-    public Class<ChannelConstantsCollection> getType() {
-        return ChannelConstantsCollection.class;
+    public Class<SvtCalibrationCollection> getType() {
+        return SvtCalibrationCollection.class;
     }        
 }
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtConditions.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- SvtConditions.java	25 Sep 2013 22:36:53 -0000	1.6
+++ SvtConditions.java	2 Oct 2013 23:19:54 -0000	1.7
@@ -3,116 +3,97 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.lcsim.detector.tracker.silicon.SiSensor;
-
 /**
  * This class models all available SVT conditions data, including 
  * noise, pedestal, shaping time, and time shift by channel.
  * 
  * @author Omar Moreno <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SvtConditions.java,v 1.6 2013/09/25 22:36:53 jeremy Exp $
+ * @version $Id: SvtConditions.java,v 1.7 2013/10/02 23:19:54 jeremy Exp $
  */
 public class SvtConditions {
-
-    /**
-     * Data maps for SVT conditions. 
-     */
-    private Map<SiSensor, double[]> noiseMap = new HashMap<SiSensor, double[]>();
-    private Map<SiSensor, double[]> pedestalMap = new HashMap<SiSensor, double[]>();
-    private Map<SiSensor, double[]> tpMap = new HashMap<SiSensor, double[]>();
-    private Map<SiSensor, Double> t0ShiftMap = new HashMap<SiSensor, Double>();
-
+    
+    private Map<SvtChannel, ChannelConstants> channelData = new HashMap<SvtChannel, ChannelConstants>();
+    private SvtChannelMap channelMap = null;
+    
     /**
      * Class constructor.
      */
-    protected SvtConditions() {
+    SvtConditions() {
     }     
     
-    /**
-     * Set the noise value on a sensor's channel.
-     * @param sensor The SiSensor object.
-     * @param channel The channel number.
-     * @param noise The noise value.
-     */
-    void setNoise(SiSensor sensor, int channel, Double noise) {
-        if (noiseMap.get(sensor) == null)
-            noiseMap.put(sensor, new double[640]);   
-        noiseMap.get(sensor)[channel] = noise;
+    void setChannelMap(SvtChannelMap channelMap) {
+        this.channelMap = channelMap;
     }
     
-    /**
-     * Set the pedestal value on a sensor's channel.
-     * @param sensor The SiSensor object.
-     * @param channel The channel number.
-     * @param pedestal The pedestal value.
-     */
-    void setPedestal(SiSensor sensor, int channel, double pedestal) {
-        if (pedestalMap.get(sensor) == null)
-            pedestalMap.put(sensor, new double[640]);
-        pedestalMap.get(sensor)[channel] = pedestal;
+    ChannelConstants getChannelConstants(SvtChannel channel) {
+        return channelData.get(channel);
     }
     
-    /**
-     * Set the shaping time value on a sensor's channel.
-     * @param sensor The SiSensor object.
-     * @param channel The channel number.
-     * @param shapingTime The shaping time.
-     */
-    void setShapingTime(SiSensor sensor, int channel, double shapingTime) {
-        if (tpMap.get(sensor) == null)
-            tpMap.put(sensor, new double[640]);
-        tpMap.put(sensor, new double[640]);
+    void setNoise(SvtChannel channel, double noise) {
+        if (channelData.get(channel) == null)
+            channelData.put(channel, new ChannelConstants());
+        channelData.get(channel).setNoise(noise);
     }
-        
-    /**
-     * 
-     * Get the noise for a given channel on a sensor.
-     * 
-     * @param sensor
-     * @param channel
-     * @return noise
-     */
-    public Double getNoise(SiSensor sensor, int channel) {
-        double[] noise = noiseMap.get(sensor);
-        if (noise == null || channel < 0 || channel > 640) {
-            return null;
-        } else {
-            return noise[channel];
-        }
+    
+    void setPedestal(SvtChannel channel, double pedestal) {
+        if (channelData.get(channel) == null)
+            channelData.put(channel, new ChannelConstants());
+        channelData.get(channel).setPedestal(pedestal);
     }
-
-    /**
-     * 
-     * Get the pedestal for a given channel on a sensor.
-     * 
-     * @param sensor
-     * @param channel
-     * @return pedestal
-     */
-    public Double getPedestal(SiSensor sensor, int channel) {
-        double[] pedestal = pedestalMap.get(sensor);
-        if (pedestal == null || channel < 0 || channel > 640) {
-            return null;
-        } else {
-            return pedestal[channel];
-        }
+    
+    void setShapingTime(SvtChannel channel, double tp) {
+        if (channelData.get(channel) == null)
+            channelData.put(channel, new ChannelConstants());
+        channelData.get(channel).setShapingTime(tp);
     }
-
-    /**
-     * 
-     * Get the shaping time for a given channel on a sensor
-     * 
-     * @param sensor
-     * @param channel
-     * @return shaping time
-     */
-    public Double getShapingTime(SiSensor sensor, int channel) {
-        double[] tp = tpMap.get(sensor);
-        if (tp == null || channel < 0 || channel > 640) {
-            return null;
-        } else {
-            return tp[channel];
+    
+    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)
+            channelData.put(channel, new ChannelConstants());
+        channelData.get(channel).setBadChannel(true);
+    }
+    
+    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();
+    }
+        
+    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');
         }
-    }    
+        return buff.toString();
+    }
 }

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtConditionsLoader.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- SvtConditionsLoader.java	2 Oct 2013 17:57:59 -0000	1.5
+++ SvtConditionsLoader.java	2 Oct 2013 23:19:54 -0000	1.6
@@ -1,13 +1,10 @@
 package org.lcsim.hps.conditions.svt;
 
 import static org.lcsim.hps.conditions.ConditionsConstants.SVT_CALIBRATIONS;
-
-import java.util.Map.Entry;
+import static org.lcsim.hps.conditions.ConditionsConstants.SVT_BAD_CHANNELS;
 
 import org.lcsim.conditions.CachedConditions;
 import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.hps.util.Pair;
 
 /**
  * This class creates an {@link SvtConditions} object from the conditions database.
@@ -27,36 +24,35 @@
         
         // Reset the conditions object.
         conditions = new SvtConditions();
+        
+        // Get the SVT channel map.
+        SvtChannelMap channels = manager.getCachedConditions(SvtChannelMap.class, null).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<ChannelConstantsCollection> c = 
-                manager.getCachedConditions(ChannelConstantsCollection.class, SVT_CALIBRATIONS);
-        ChannelConstantsCollection channelData = c.getCachedData();
-        
-        // Get SvtUtils reference.
-        SvtUtils util = SvtUtils.getInstance();
-        
-        // Loop over all the channel data retrieved from the database.
-        for (Entry<Integer,ChannelConstants> entry : channelData.entrySet()) {
-            
-            // Get the constants for a single channel.
-            ChannelConstants channel = entry.getValue();
-            
-            // Find the associated sensor for the FPGA and hybrid numbers.
-            Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(channel.getFpga(), channel.getHybrid());
-            SiSensor sensor = util.getSensor(daqPair); 
-
-            // Sensor must exist!
-            if (sensor == null) {
-                throw new RuntimeException("SiSensor not found for fpga <" + channel.getFpga() + "> and hybrid <" + channel.getHybrid() + "> !");
-            }
-            
-            // Set the noise value for the channel.
-            conditions.setNoise(sensor, channel.getChannel(), channel.getNoise());
-            
-            // Set the pedestal value for the channel.
-            conditions.setPedestal(sensor, channel.getChannel(), channel.getPedestal());
-        }                         
+        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());
+        }  
+        
+        // Get the bad channel list.
+        SvtBadChannelCollection badChannels = manager.getCachedConditions(SvtBadChannelCollection.class, SVT_BAD_CHANNELS).getCachedData();
+        
+        // Add bad channels.
+        for (Integer badChannel : badChannels) {
+            conditions.setBadChannel(channels.get(badChannel));
+        }
     }
     
     /**

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtUtils.java removed after 1.1
diff -N SvtUtils.java
--- SvtUtils.java	2 Oct 2013 17:57:59 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,628 +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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.identifier.IIdentifier;
-import org.lcsim.detector.identifier.IIdentifierHelper;
-import org.lcsim.detector.tracker.silicon.ChargeCarrier;
-import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper;
-import org.lcsim.geometry.Detector;
-import org.lcsim.hps.conditions.ConditionsConstants;
-import org.lcsim.hps.conditions.ConnectionManager;
-import org.lcsim.hps.recon.tracking.StereoPair;
-import org.lcsim.hps.util.Pair;
-
-
-/**
- * A class providing various utilities related to the HPS SVT. 
- *
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtUtils.java,v 1.1 2013/10/02 17:57:59 jeremy Exp $
- */
-public class SvtUtils {
-
-    private static SvtUtils INSTANCE = null;
-    // Set of sensors
-    private Set<SiSensor> sensors = new HashSet<SiSensor>();
-    // Set of stereo pairs
-    private Set<StereoPair> stereoPairs = new HashSet<StereoPair>(); 
-    // Map from Sensor to Hybrid/FPGA pair
-    private Map<SiSensor /* sensor */, Pair<Integer /* FPGA */, Integer /* Hybrid */>> sensorToDaqPair = new HashMap<SiSensor, Pair<Integer, Integer>>();
-    // Map from Hybrid/FPGA pair
-    private Map<Pair<Integer /* FPGA */, Integer /* Hybrid */>, SiSensor /* Sensor*/> daqPairToSensor = new HashMap<Pair<Integer, Integer>, SiSensor>();
-    // Map from SVT top layer to Hybrid/FPGA pair
-    private Map<Integer /* Layer */, List<Pair<Integer /* FPGA */, Integer /* Hybrid */>>> topLayerDaqMap = new HashMap<Integer, List<Pair<Integer, Integer>>>();
-    // Map from SVT bottom layer to Hybrid/FPGA pair
-    private Map<Integer /* Layer # */, List<Pair<Integer /* FPGA */, Integer /* Hybrid */>>> bottomLayerDaqMap = new HashMap<Integer, List<Pair<Integer, Integer>>>();
-    // Map sensor to an SVT top layer
-    private Map<SiSensor /* Sensor */, Integer /* Layer */> sensorToTopLayer = new HashMap<SiSensor, Integer>();
-    // Map sensor to an SVT bottom layer
-    private Map<SiSensor /* Sensor */, Integer /* Layer */> sensorToBottomLayer = new HashMap<SiSensor, Integer>();
-    // Map sensor to descriptor
-    private Map<SiSensor /* Sensor */, String /* Description */> sensorToDescriptor = new HashMap<SiSensor, String>();
-    // Map layer to top SVT sensor 
-    private Map<Integer /* Layer */, List<SiSensor> /* Sensor */> topLayerToSensor = new HashMap<Integer, List<SiSensor>>();
-    // Map layer to bottom SVT sensor
-    private Map<Integer /* Layer */, List<SiSensor> /* Sensor */> bottomLayerToSensor = new HashMap<Integer, List<SiSensor>>();
-    private SiSensor[][] sensorArray;
-    private IIdentifierHelper helper;
-    String subdetectorName = "Tracker";
-    ConditionsManager manager = ConditionsManager.defaultInstance();
-    int maxModuleNumber = 0;
-    int maxPlaneNumber = 0;
-    private Set<Integer> fpgaNumbers = new HashSet<Integer>();
-    private boolean isSetup = false;
-    boolean debug = true;
-
-    /*
-     * Private ctor to keep user from instantiating 
-     */
-    private SvtUtils() {
-    }
-
-    /**
-     * 
-     */
-    public static SvtUtils getInstance() {
-
-        // Use lazy instantiation
-        if (INSTANCE == null) {
-        	System.out.println("making new SvtUtils instance");
-            INSTANCE = new SvtUtils();
-        }
-        return INSTANCE;
-    }
-
-    /**
-     * @return true if all maps have been loaded, false otherwise
-     */
-    public boolean isSetup() {
-        return isSetup;
-    }
-
-    /**
-     * Get the plane number to which the sensor belongs to. This is does not 
-     * return the SVT layer number.
-     * 
-     * @param sensor
-     * @return The layer number
-     */
-    // TODO: Change the name to clarify that what is being returned is the plane number
-    public int getLayerNumber(SiSensor sensor) {
-        if (sensorToTopLayer.containsKey(sensor)) {
-            return sensorToTopLayer.get(sensor);
-        } else if (sensorToBottomLayer.containsKey(sensor)) {
-            return sensorToBottomLayer.get(sensor);
-        } else {
-            throw new RuntimeException("The sensor " + sensor.getName() 
-            								+ " does not have an associated plane number");
-        }
-    }
-
-    /**
-     * Checks if a sensor is part of the top SVT volume.
-     *
-     * @return true if it is, false if it belongs to the bottom volume
-     */
-    public boolean isTopLayer(SiSensor sensor) {
-        if (sensorToTopLayer.containsKey(sensor)) {
-            return true;
-        } else if (sensorToBottomLayer.containsKey(sensor)) {
-            return false;
-        } else {
-            throw new RuntimeException("There is no layer associated with sensor " + sensor.getName());
-        }
-    }
-
-    /**
-     * Checks if the orientation of the sensor is axial.
-     * 
-     *  @return true if it is, false if it is a stereo sensor
-     */
-    public boolean isAxial(SiSensor sensor) {
-        if (this.isTopLayer(sensor) && this.getLayerNumber(sensor) % 2 == 1) {
-            return true;
-        } else if (!this.isTopLayer(sensor) && this.getLayerNumber(sensor) % 2 == 0) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Get a sensor by its plane and module id.
-     * 
-     *  @param moduleNumber : module id
-     *  @param planeNumber : layer (plane) id
-     *  @return sensor 
-     */
-    public SiSensor getSensor(int moduleNumber, int planeNumber) {
-        if (moduleNumber < 0 || moduleNumber >= maxModuleNumber) {
-            throw new RuntimeException("Module number " + moduleNumber + " is out of range!");
-        } else if (planeNumber <= 0 || planeNumber > maxPlaneNumber) {
-            throw new RuntimeException("Plane number " + planeNumber + " is out of range!");
-        }
-        return sensorArray[moduleNumber][planeNumber];
-    }
-
-    /**
-     * Get a sensor by its FPGA and hybrid number.
-     * 
-     *  @param daqPair : a Pair of the form Pair<FPGA number, hybrid number>
-     *  @return sensor
-     */
-    public SiSensor getSensor(Pair<Integer, Integer> daqPair) {
-        return daqPairToSensor.get(daqPair);
-    }
-
-    /**
-     * Get a sensor from the top SVT volume by its plane number and sensor 
-     * position within a plane.
-     * 
-     *  @param planeNumber
-     *  @param sensorNumber : position within a plane
-     *  @return sensor or null if the sensor doesn't exist in that position
-     */
-    public SiSensor getTopSensor(int planeNumber, int sensorNumber) {
-    	if(topLayerToSensor.get(planeNumber).size() <= sensorNumber) return null;
-        return topLayerToSensor.get(planeNumber).get(sensorNumber);
-    }
-
-    /**
-     * Get a sensor from the bottom SVT volume by its plane number and sensor 
-     * position within a plane.
-     * 
-     *  @param planeNumber
-     *  @param sensorNumber : position within a plane
-     *  @return sensor or null if the sensor doesn't exist in that position
-     */
-    public SiSensor getBottomSensor(int layer, int sensorNumber) {
-    	if(bottomLayerToSensor.get(layer).size() <= sensorNumber) return null;
-        return bottomLayerToSensor.get(layer).get(sensorNumber);
-    }
-
-    /**
-     * Get the Set of all sensors which compose the SVT.
-     * 
-     *  @return set of sensors
-     */
-    public Set<SiSensor> getSensors() {
-        return sensors;
-    }
-
-    /**
-     * Get the Set of all FPGA numbers. 
-     * 
-     * @return set of FPGA numbers
-     */
-    public Set<Integer> getFpgaNumbers() {
-        return fpgaNumbers;
-    }
-
-    /**
-     * Get the FPGA number associated with a sensor.
-     * 
-     * @return FPGA number
-     */
-    public int getFPGA(SiSensor sensor) {
-        return sensorToDaqPair.get(sensor).getFirstElement();
-    }
-
-    /**
-     * Get the hybrid number associated with a sensor.
-     * 
-     * @return hybrid number
-     */
-    public int getHybrid(SiSensor sensor) {
-        return sensorToDaqPair.get(sensor).getSecondElement();
-    }
-
-    public int getFPGACount() {
-        return 0;
-    }
-
-    /**
-     * Get the FPGA and hybrid number associated with a sensor as a pair of
-     * values.
-     * 
-     * @param sensor
-     * @return pair of the form Pair<FPGA, hybrid>
-     */
-    public Pair<Integer, Integer> getDaqPair(SiSensor sensor) {
-        return sensorToDaqPair.get(sensor);
-    }
-
-    /**
-     * Get the IIdentifierHelper associated with the SVT.
-     * 
-     * @return helper
-     */
-    public IIdentifierHelper getHelper() {
-        return helper;
-    }
-
-    /**
-     * Get a string describing a sensor.
-     * 
-     * @param sensor
-     * @return String describing a sensor
-     */
-    public String getDescription(SiSensor sensor) {
-        return this.sensorToDescriptor.get(sensor);
-    }
-
-    /**
-     * Make the cell ID for any channel on a sensor.
-     * 
-     * @param sensor
-     * @param channel : Physical channel number
-     * @return cell ID
-     */
-    public static long makeCellID(SiSensor sensor, int channel) {
-        int sideNumber;
-        if (sensor.hasElectrodesOnSide(ChargeCarrier.HOLE)) {
-            sideNumber = ChargeCarrier.HOLE.charge();
-        } else {
-            sideNumber = ChargeCarrier.ELECTRON.charge();
-        }
-        return sensor.makeStripId(channel, sideNumber).getValue();
-    }
-    
-    /**
-     * Get the set of all stereo pairs which compose the SVT.
-     * 
-     *  @return Set of stereo pairs
-     */
-    Set<StereoPair> getStereoPairs(){
-    	return stereoPairs; 
-    }
-
-    /**
-     * Creates and fill the various utility maps.
-     * 
-     * @param detector : The SVT detector being used
-     */
-    public void setup(Detector detector) {
-
-        this.printDebug("Method: setupMaps: \n\tDetector: " + detector.getDetectorName());
-
-        // Load the DAQ Map from the conditions database
-        //this.
-        loadSvtDaqMap();
-        
-        // Instantiate 'sensorArray' which allows for retrieval of a SiSensor
-        // by module and layer id
-        sensorArray = new SiSensor[maxModuleNumber + 1][maxPlaneNumber];
-
-        // Get all of the sensors composing the SVT and add them to the set of all sensors
-        IDetectorElement detectorElement = detector.getDetectorElement().findDetectorElement(subdetectorName);
-        helper = detectorElement.getIdentifierHelper();
-        sensors.addAll(detectorElement.findDescendants(SiSensor.class));
-        this.printDebug("\tTotal number of sensors: " + sensors.size());
-
-        IIdentifier sensorIdent;
-        SiTrackerIdentifierHelper sensorHelper;
-        String description;
-        // Loop through all of the sensors and fill the maps
-        for (SiSensor sensor : sensors) {
-
-            // Get the sensor identifier
-            sensorIdent = sensor.getIdentifier();
-
-            // Get the sensor identifier helper in order to decode the id fields
-            sensorHelper = (SiTrackerIdentifierHelper) sensor.getIdentifierHelper();
-
-            // Get the sensor layer and module id
-            int layerNumber = sensorHelper.getLayerValue(sensorIdent);
-            int moduleNumber = sensorHelper.getModuleValue(sensorIdent);
-            sensorArray[moduleNumber][layerNumber - 1] = sensor;
-            int listPosition = 0;
-            switch (moduleNumber % 2) {
-                // Top Layer
-            	case 0:
-                	
-                    listPosition = moduleNumber / 2;
-                    sensorToTopLayer.put(sensor, layerNumber);
-                    sensorToDaqPair.put( sensor, topLayerDaqMap.get(layerNumber).get(listPosition));
-                    topLayerToSensor.get(layerNumber).set(listPosition, sensor);
-                    daqPairToSensor.put(topLayerDaqMap.get(layerNumber).get(listPosition), sensor);
-                    description = "Top Layer " + layerNumber + " - Sensor " + listPosition;
-                    this.printDebug("\tDescription: " + description);
-                    sensorToDescriptor.put(sensor, description);
-                    break;
-                // Bottom Layer
-                case 1:
-                
-                	listPosition = (moduleNumber - 1) / 2;
-                    sensorToBottomLayer.put(sensor, layerNumber);
-                    sensorToDaqPair.put(sensor, bottomLayerDaqMap.get(layerNumber).get(listPosition));
-                    bottomLayerToSensor.get(layerNumber).set(listPosition, sensor);
-                    daqPairToSensor.put(bottomLayerDaqMap.get(layerNumber).get(listPosition), sensor);
-                    description = "Bottom Layer " + layerNumber + " - Sensor " + listPosition;
-                    this.printDebug("\tDescription: " + description);
-                    sensorToDescriptor.put(sensor, description);
-                    break;
-                default:
-                    throw new RuntimeException("Invalid module number: " + moduleNumber);
-            }
-        }
-        
-        // Create stereo pairs
-        this.createStereoPairs();
-        
-        isSetup = true;
-    }
-    
-    // FIXME: This logic should go inside a converter as with other conditions classes from db data.
-    private void loadSvtDaqMap(){ 
-    	
-    	// 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 layer, module, fpga, hybrid FROM "  
-            		+ database  + "." + ConditionsConstants.SVT_DAQ_MAP;
-                                   
-            // Execute the query and get the results.
-            statement = connection.createStatement();
-            resultSet = statement.executeQuery(query);
-            
-            int listPosition = 0;
-            
-            System.out.println("adding SVT DAQ map info:");
-          
-            // Loop over the records.
-            while(resultSet.next()) {
-            	           	
-            	// Parse the line
-                int layer = resultSet.getInt(1);
-                int module = resultSet.getInt(2);
-                int fpga = resultSet.getInt(3);
-                int hybrid = resultSet.getInt(4);
-                
-                System.out.println("layer: " + layer + ", module: " + module + ", fpga: " + fpga + ", hybrid: " + hybrid);
-                
-                // Find the maximum layer number and module number.  This
-                // is used when instantiating 'sensorArray' and when creating
-                // stereo pairs.
-                maxModuleNumber = Math.max(maxModuleNumber, module);
-                maxPlaneNumber = Math.max(maxPlaneNumber, layer);
-               
-                // A pair is used to relate an FPGA value to a hybrid number
-                Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(fpga, hybrid);
-                fpgaNumbers.add(fpga);
-                
-                // Load the maps based on module number.
-                //
-                // Module 0 & 2 correspond to sensors which lie in the top SVT volume
-                // Module 1 & 3 correspond to sensors which lie in the bottom SVT volume
-                //
-                // A module number > 1 indicate that the sensor is part of a double layer.
-                // For the test run detector, all module numbers are either 0 or 1.
-                switch (module % 2) {
-                    case 0:
-                        listPosition = module / 2;
-                        // If the top layer DAQ map doesn't contain the layer, add it
-                        if (!topLayerDaqMap.containsKey(layer)) {
-                            topLayerDaqMap.put(layer, new ArrayList<Pair<Integer, Integer>>());
-                        }
-                        this.printDebug("\tAdding FPGA: " + daqPair.getFirstElement() + ", Hybrid: " + daqPair.getSecondElement() + " to position: " + listPosition);
-                        // Add the DAQ pair to the corresponding layer
-                        topLayerDaqMap.get(layer).add(listPosition, daqPair);
-                        
-                        // If the top layer sensor map doesn't contain the layer, add it
-                        if (!topLayerToSensor.containsKey(layer)) {
-                            topLayerToSensor.put(layer, new ArrayList<SiSensor>());
-                        }
-                        // Create room within the sensor map for the sensor
-                        topLayerToSensor.get(layer).add(null);
-                        break;
-                    case 1:
-                        listPosition = (module - 1) / 2;
-                        if (!bottomLayerDaqMap.containsKey(layer)) {
-                            bottomLayerDaqMap.put(layer, new ArrayList<Pair<Integer, Integer>>());
-                        }
-                        this.printDebug("\tAdding FPGA: " + daqPair.getFirstElement() + ", Hybrid: " + daqPair.getSecondElement() + " to position: " + listPosition);
-                        bottomLayerDaqMap.get(layer).add(listPosition, daqPair);
-                        if (!bottomLayerToSensor.containsKey(layer)) {
-                            bottomLayerToSensor.put(layer, new ArrayList<SiSensor>());
-                        }
-                        bottomLayerToSensor.get(layer).add(null);
-                        break;
-                    default:
-                        throw new RuntimeException("Invalid module number: " + module);
-                }
-            }          
-        } catch (SQLException x) {
-            throw new RuntimeException("Database error.", x);
-        } finally {
-            // Cleanup the SQL statement.
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (Exception xx) {
-                	xx.printStackTrace();
-                }
-            }            
-            // Cleanup the connection.
-            if (connection != null) {
-                try {
-                    connection.close();
-                } catch (Exception x) {
-                	x.printStackTrace();
-                }
-            }
-        }        
-    }
-
-    /**
-     * Load the SVT DAQ Map from the conditions database
-     * 
-     */
-    /*
-    private void loadSvtDaqMap(){ 
-    	
-    	// Path to file in conditions database
-        String filePath = "daqmap/svt_default.daqmap";
-        BufferedReader daqMapReader = null; 
-        String currentLine = null;
-        try {
-            daqMapReader = new BufferedReader(manager.getRawConditions(filePath).getReader());
-          
-            // Continue to read lines for the DAQ map until the end of file is 
-            // reached. The DAQ map is has the following format
-            //
-            //  layer   module   fpga   hybrid
-            // ---------------------------------
-            while ((currentLine = daqMapReader.readLine()) != null) {
-                
-            	// If the line is a comment,skip it
-                if (currentLine.indexOf("#") != -1) continue;
-               
-                // Split the line into tokens by whitespace
-                StringTokenizer stringTok = new StringTokenizer(currentLine);
-                int listPosition = 0;
-                while (stringTok.hasMoreTokens()) {
-                	
-                	// Parse the line
-                    int layer = Integer.valueOf(stringTok.nextToken());
-                    int module = Integer.valueOf(stringTok.nextToken());
-                    int fpga = Integer.valueOf(stringTok.nextToken());
-                    int hybrid = Integer.valueOf(stringTok.nextToken());
-                    
-                    // Find the maximum layer number and module number.  This
-                    // is used when instantiating 'sensorArray' and when creating
-                    // stereo pairs.
-                    maxModuleNumber = Math.max(maxModuleNumber, module);
-                    maxPlaneNumber = Math.max(maxPlaneNumber, layer);
-                   
-                    // A pair is used to relate an FPGA value to a hybrid number
-                    Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(fpga, hybrid);
-                    fpgaNumbers.add(fpga);
-                    
-                    // Load the maps based on module number.
-                    //
-                    // Module 0 & 2 correspond to sensors which lie in the top SVT volume
-                    // Module 1 & 3 correspond to sensors which lie in the bottom SVT volume
-                    //
-                    // A module number > 1 indicate that the sensor is part of a double layer.
-                    // For the test run detector, all module numbers are either 0 or 1.
-                    switch (module % 2) {
-                        case 0:
-                            listPosition = module / 2;
-                            // If the top layer DAQ map doesn't contain the layer, add it
-                            if (!topLayerDaqMap.containsKey(layer)) {
-                                topLayerDaqMap.put(layer, new ArrayList<Pair<Integer, Integer>>());
-                            }
-                            this.printDebug("\tAdding FPGA: " + daqPair.getFirstElement() + ", Hybrid: " + daqPair.getSecondElement() + " to position: " + listPosition);
-                            // Add the DAQ pair to the corresponding layer
-                            topLayerDaqMap.get(layer).add(listPosition, daqPair);
-                            
-                            // If the top layer sensor map doesn't contain the layer, add it
-                            if (!topLayerToSensor.containsKey(layer)) {
-                                topLayerToSensor.put(layer, new ArrayList<SiSensor>());
-                            }
-                            // Create room within the sensor map for the sensor
-                            topLayerToSensor.get(layer).add(null);
-                            break;
-                        case 1:
-                            listPosition = (module - 1) / 2;
-                            if (!bottomLayerDaqMap.containsKey(layer)) {
-                                bottomLayerDaqMap.put(layer, new ArrayList<Pair<Integer, Integer>>());
-                            }
-                            this.printDebug("\tAdding FPGA: " + daqPair.getFirstElement() + ", Hybrid: " + daqPair.getSecondElement() + " to position: " + listPosition);
-                            bottomLayerDaqMap.get(layer).add(listPosition, daqPair);
-                            if (!bottomLayerToSensor.containsKey(layer)) {
-                                bottomLayerToSensor.put(layer, new ArrayList<SiSensor>());
-                            }
-                            bottomLayerToSensor.get(layer).add(null);
-                            break;
-                        default:
-                            throw new RuntimeException("Invalid module number: " + module);
-                    }
-                }
-            }
-            
-        } catch (IOException exception) {
-            throw new RuntimeException("Unable to load DAQ Map from " + filePath, exception);
-        }
-    }
-    */
-    
-    /**
-     * 
-     */
-    private void createStereoPairs(){
-    	
-    	// Loop through all the sensors in both top and bottom layers and
-    	// create stereo pairs. 
-    	SiSensor firstSensor = null;
-    	SiSensor secondSensor = null;
-    	int trackerLayer = 0; 
-    	
-    	// 
-    	for(int layerNumber = 1; layerNumber <= maxPlaneNumber; layerNumber+=2 ){
-    		for(int sensorNumber = 0; sensorNumber < (maxModuleNumber+1)/2; sensorNumber++){
-    			
-    			firstSensor = this.getTopSensor(layerNumber, sensorNumber);
-    			secondSensor = this.getTopSensor(layerNumber+1, sensorNumber);
-    			
-    			if(firstSensor == null || secondSensor == null) continue;
-    			
-    			trackerLayer = (layerNumber + 1)/2; 
-    			if(this.isAxial(firstSensor)){
-    				stereoPairs.add(new StereoPair(trackerLayer, StereoPair.detectorVolume.Top,  firstSensor, secondSensor));
-    			} else {
-    				stereoPairs.add(new StereoPair(trackerLayer, StereoPair.detectorVolume.Top, secondSensor, firstSensor));
-    			}
-    			
-    			firstSensor = this.getBottomSensor(layerNumber, sensorNumber);
-    			secondSensor = this.getBottomSensor(layerNumber+1, sensorNumber);
-    			
-    			if(firstSensor == null || secondSensor == null) continue;
-    			
-    			if(this.isAxial(firstSensor)){
-    				stereoPairs.add(new StereoPair(trackerLayer, StereoPair.detectorVolume.Bottom, firstSensor, secondSensor));
-    			} else {
-    				stereoPairs.add(new StereoPair(trackerLayer, StereoPair.detectorVolume.Bottom, secondSensor, firstSensor));
-    			}
-    		}
-    	}
-    	
-    	this.printDebug("Total number of stereo pairs created: " + stereoPairs.size());
-    	for(StereoPair stereoPair : stereoPairs){
-    		this.printDebug(stereoPair.toString());
-    	}
-    }
-
-    /**
-     * Print a debug message 
-     * 
-     * @param debugMessage : message to be printed
-     */
-    private void printDebug(String debugMessage) {
-        if (debug) {
-            System.out.println(this.getClass().getSimpleName() + ": " + debugMessage);
-        }
-    }
-}

hps-java/src/test/java/org/lcsim/hps/conditions
DatabaseConditionsReaderTest.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- DatabaseConditionsReaderTest.java	24 Sep 2013 02:40:21 -0000	1.6
+++ DatabaseConditionsReaderTest.java	2 Oct 2013 23:19:55 -0000	1.7
@@ -8,7 +8,7 @@
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
 import org.lcsim.conditions.ConditionsSet;
-import org.lcsim.hps.conditions.svt.ChannelConstantsCollection;
+//import org.lcsim.hps.conditions.svt.ChannelConstantsCollection;
 
 /**
  * This class tests the DatabaseConditionsReader on dummy data.
@@ -21,7 +21,7 @@
     private final String detectorName = "HPS-conditions-test";
     
     /** Run number of conditions set. */
-    private final int runNumber = 0;
+    private final int runNumber = 777;
     
     /** Name of conditions set. */
     private final String conditionsSetName = "svt_calibrations";
@@ -54,9 +54,9 @@
 	    ps.println(r.toString());
 	}
 	
-        CachedConditions<ChannelConstantsCollection> c = manager.getCachedConditions(ChannelConstantsCollection.class, conditionsSetName);
-        ChannelConstantsCollection calibration = c.getCachedData();
-        assertTrue("Calibration object is null.", calibration != null);
+        //CachedConditions<ChannelConstantsCollection> c = manager.getCachedConditions(ChannelConstantsCollection.class, conditionsSetName);
+        //ChannelConstantsCollection calibration = c.getCachedData();
+        //assertTrue("Calibration object is null.", calibration != null);
         //System.out.println("Got calibration conditions ... ");
         //System.out.println(calibration);
         //System.out.println("Success!");

hps-java/src/test/java/org/lcsim/hps/conditions/ecal
EcalConditionsLoaderTest.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- EcalConditionsLoaderTest.java	2 Oct 2013 17:57:59 -0000	1.2
+++ EcalConditionsLoaderTest.java	2 Oct 2013 23:19:55 -0000	1.3
@@ -4,8 +4,6 @@
 
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
-import org.lcsim.geometry.Detector;
-import org.lcsim.hps.conditions.svt.SvtUtils;
 import org.lcsim.util.loop.LCSimConditionsManagerImplementation;
 
 public class EcalConditionsLoaderTest extends TestCase {
@@ -26,12 +24,7 @@
         } 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.
         EcalConditionsLoader loader = new EcalConditionsLoader();
         loader.load();

hps-java/src/test/java/org/lcsim/hps/conditions/svt
SvtConditionsLoaderTest.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SvtConditionsLoaderTest.java	23 Sep 2013 23:09:10 -0000	1.1
+++ SvtConditionsLoaderTest.java	2 Oct 2013 23:19:55 -0000	1.2
@@ -8,7 +8,6 @@
 import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
 import org.lcsim.detector.tracker.silicon.SiSensor;
 import org.lcsim.geometry.Detector;
-import org.lcsim.hps.recon.tracking.SvtUtils;
 import org.lcsim.util.loop.LCSimConditionsManagerImplementation;
 
 /**
@@ -22,7 +21,7 @@
     private static final String detectorName = "HPS-conditions-test";
     
     /** The run number of the conditions set in the database. */
-    private static final int runNumber = 0;
+    private static final int runNumber = 777;
     
     /** Maximum channel number in a sensor. */
     private static final int MAX_CHANNEL = 639;
@@ -45,16 +44,18 @@
         }
         
         // Now we need to setup the Detector for the conditions loader.
-        Detector detector =
-                manager.getCachedConditions(Detector.class, "compact.xml").getCachedData();
-        SvtUtils.getInstance().setup(detector);
+        //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);
+        assertNotNull(conditions);        
+        System.out.println(conditions);
         
+        /*
         // Get all the sensors on the detector.        
         List<SiSensor> sensors = detector.getDetectorElement().findDescendants(SiSensor.class);
         int totalChannelsFound = 0;
@@ -81,5 +82,6 @@
         }
         System.out.println("got conditions for " + totalChannelsFound + " channels");
         assertEquals("Wrong number of total channels.", TOTAL_CHANNELS, totalChannelsFound);
+        */
     }
 }
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