Commit in hps-java/src on MAIN
main/java/org/lcsim/hps/conditions/ConditionsConstants.java+31.6 -> 1.7
                                  /ConditionsConverterRegister.java+9-41.1 -> 1.2
                                  /BadChannelConverter.java-771.4 removed
main/java/org/lcsim/hps/conditions/ecal/EcalBadChannelCollection.java+2-21.3 -> 1.4
main/java/org/lcsim/hps/conditions/svt/SvtTimeShift.java+49added 1.1
                                      /SvtTimeShiftCollection.java+24added 1.1
                                      /SvtTimeShiftConverter.java+77added 1.1
                                      /SvtBadChannelCollection.java+2-31.3 -> 1.4
                                      /SvtConditions.java+18-11.9 -> 1.10
                                      /SvtConditionsConverter.java+51.3 -> 1.4
                                      /SvtConditionsLoader.java+51.12 -> 1.13
                                      /SvtGainConverter.java+2-21.4 -> 1.5
test/java/org/lcsim/hps/conditions/svt/SvtConditionsLoaderTest.java+31.9 -> 1.10
+199-89
3 added + 1 removed + 9 modified, total 13 files
add time shift by sensor to conditions system; remove old bad channel converter

hps-java/src/main/java/org/lcsim/hps/conditions
ConditionsConstants.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- ConditionsConstants.java	4 Oct 2013 01:43:47 -0000	1.6
+++ ConditionsConstants.java	15 Oct 2013 23:14:47 -0000	1.7
@@ -36,4 +36,7 @@
     
     /** Conditions key for SVT gain data. */
     public static final String SVT_GAINS = "svt_gains";
+    
+    /** Conditions key fo SVT time shifts by sensor. */
+    public static final String SVT_TIME_SHIFTS = "svt_time_shifts";
 }

hps-java/src/main/java/org/lcsim/hps/conditions
ConditionsConverterRegister.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ConditionsConverterRegister.java	15 Oct 2013 01:35:03 -0000	1.1
+++ ConditionsConverterRegister.java	15 Oct 2013 23:14:47 -0000	1.2
@@ -1,6 +1,7 @@
 package org.lcsim.hps.conditions;
 
 import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.hps.conditions.ecal.EcalBadChannelConverter;
 import org.lcsim.hps.conditions.ecal.EcalCalibrationConverter;
 import org.lcsim.hps.conditions.ecal.EcalChannelMapConverter;
 import org.lcsim.hps.conditions.ecal.EcalConditionsConverter;
@@ -12,6 +13,7 @@
 import org.lcsim.hps.conditions.svt.SvtConditionsConverter;
 import org.lcsim.hps.conditions.svt.SvtDaqMapConverter;
 import org.lcsim.hps.conditions.svt.SvtGainConverter;
+import org.lcsim.hps.conditions.svt.SvtTimeShiftConverter;
 
 /**
  * This class registers the full set of conditions converters onto the manager.
@@ -42,13 +44,16 @@
         
         // SVT bad channels.
         manager.registerConditionsConverter(new SvtBadChannelConverter());       
-        
-        // SVT and ECAL bad channels.  Same converter can be used.
-        manager.registerConditionsConverter(new BadChannelConverter());
-        
+       
+        // SVT time shift by sensor.
+        manager.registerConditionsConverter(new SvtTimeShiftConverter());
+                
         // SVT combined conditions.
         manager.registerConditionsConverter(new SvtConditionsConverter());
         
+        // ECAL bad channels.
+        manager.registerConditionsConverter(new EcalBadChannelConverter());
+        
         // ECAL channel map.
         manager.registerConditionsConverter(new EcalChannelMapConverter());
         

hps-java/src/main/java/org/lcsim/hps/conditions
BadChannelConverter.java removed after 1.4
diff -N BadChannelConverter.java
--- BadChannelConverter.java	11 Oct 2013 00:05:36 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-package org.lcsim.hps.conditions;
-
-import static org.lcsim.hps.conditions.ConditionsConstants.ECAL_BAD_CHANNELS;
-import static org.lcsim.hps.conditions.ConditionsConstants.SVT_BAD_CHANNELS;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.lcsim.conditions.ConditionsManager;
-
-/**
- * This class creates a {@link ChannelCollection} representing bad readout channels.
- * @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(0);
-        
-        // 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();
-
-        // Get the name of the current database being used.
-        String database = this.getConnectionManager().getConnectionParameters().getDatabase();
-
-        // Select the correct field name depending on if SVT or ECAL is being queried.
-        // FIXME: Might be better to go back to having 2 separate converters!!!
-        String idFieldName = null;
-        if (name == SVT_BAD_CHANNELS) {
-            idFieldName = "svt_channel_id";
-        } else if (name == ECAL_BAD_CHANNELS) {
-            idFieldName = "ecal_channel_id";
-        } else {
-            throw new IllegalArgumentException("Unknown conditions key for this converter: " + name);
-        }
-        
-        // Query for getting back bad channel records.
-        String query = "SELECT " + idFieldName + " FROM " + tableName + " WHERE " + fieldName + " = " + fieldValue + " ORDER BY id ASC";
-        ResultSet resultSet = ConnectionManager.getConnectionManager().query(query);
-
-        // Loop over the records.
-        try {
-            while (resultSet.next()) {
-                int channelId = resultSet.getInt(1);
-                badChannels.add(channelId);
-            }
-        } catch (SQLException x) {
-            throw new RuntimeException(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/ecal
EcalBadChannelCollection.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- EcalBadChannelCollection.java	15 Oct 2013 00:55:35 -0000	1.3
+++ EcalBadChannelCollection.java	15 Oct 2013 23:14:47 -0000	1.4
@@ -1,6 +1,6 @@
 package org.lcsim.hps.conditions.ecal;
 
-import java.util.HashSet;
+import org.lcsim.hps.conditions.ChannelCollection;
 
-public class EcalBadChannelCollection extends HashSet<Integer> {
+public class EcalBadChannelCollection extends ChannelCollection {
 }

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtTimeShift.java added at 1.1
diff -N SvtTimeShift.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtTimeShift.java	15 Oct 2013 23:14:47 -0000	1.1
@@ -0,0 +1,49 @@
+package org.lcsim.hps.conditions.svt;
+
+/**
+ * This class is a data holder for associating a time shift with a specific sensor
+ * by FPGA and hybrid numbers.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class SvtTimeShift {
+    
+    int fpga;
+    int hybrid;
+    double timeShift;
+    
+    /**
+     * Fully qualified constructor.
+     * @param fpga The FPGA number.
+     * @param hybrid The hybrid number.
+     * @param timeShift The time shift.
+     */
+    SvtTimeShift(int fpga, int hybrid, double timeShift) {
+        this.fpga = fpga;
+        this.hybrid = hybrid;
+        this.timeShift = timeShift;
+    }
+    
+    /**
+     * Get the FPGA number.
+     * @return The FPGA number.
+     */
+    int getFpga() {
+        return fpga;
+    }
+    
+    /**
+     * Get the hybrid number.
+     * @return The hybrid number.
+     */
+    int getHybrid() {
+        return hybrid;
+    }
+    
+    /**
+     * Get the time shift.
+     * @return The time shift.
+     */
+    double getTimeShift() {
+        return timeShift;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtTimeShiftCollection.java added at 1.1
diff -N SvtTimeShiftCollection.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtTimeShiftCollection.java	15 Oct 2013 23:14:47 -0000	1.1
@@ -0,0 +1,24 @@
+package org.lcsim.hps.conditions.svt;
+
+import java.util.ArrayList;
+
+import org.lcsim.hps.util.Pair;
+
+/**
+ * A simple collection of {@link SvtTimeShift} objects.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class SvtTimeShiftCollection extends ArrayList<SvtTimeShift> {
+
+    SvtTimeShiftCollection find(Pair<Integer,Integer> pair) {
+        SvtTimeShiftCollection timeShifts = new SvtTimeShiftCollection();
+        int fpga = pair.getFirstElement();
+        int hybrid = pair.getSecondElement();
+        for (SvtTimeShift timeShift : this) {
+            if (timeShift.getFpga() == fpga && timeShift.getHybrid() == hybrid) {
+                timeShifts.add(timeShift);
+            }
+        }
+        return timeShifts;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtTimeShiftConverter.java added at 1.1
diff -N SvtTimeShiftConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtTimeShiftConverter.java	15 Oct 2013 23:14:47 -0000	1.1
@@ -0,0 +1,77 @@
+package org.lcsim.hps.conditions.svt;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+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 SvtGainCollection} from the conditions database.
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: SvtTimeShiftConverter.java,v 1.1 2013/10/15 23:14:47 jeremy Exp $
+ */
+public class SvtTimeShiftConverter extends DatabaseConditionsConverter<SvtTimeShiftCollection> {
+    
+    /**
+     * Class constructor.
+     */
+    public SvtTimeShiftConverter() {
+    }
+
+    /**
+     * 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 SvtTimeShiftCollection 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(0);
+               
+        // 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();
+                
+        // Collection that will be returned. 
+        SvtTimeShiftCollection collection = new SvtTimeShiftCollection();
+        
+        // Get the connection manager.
+        ConnectionManager connectionManager = ConnectionManager.getConnectionManager();
+                                                                                            
+        // Construct the query to find matching records.
+        String query = "SELECT fpga, hybrid, time_shift FROM "
+                + tableName + " WHERE " + fieldName + " = " + fieldValue;
+            
+        // Execute the query and get the results.
+        ResultSet resultSet = connectionManager.query(query);
+               
+        try {
+            // Loop over the records.            
+            while(resultSet.next()) {                                 
+                // Create the object with the sensor time shift.
+                int fpga = resultSet.getInt(1);
+                int hybrid = resultSet.getInt(2);
+                double timeShift = resultSet.getDouble(3);
+                collection.add(new SvtTimeShift(fpga, hybrid, timeShift));
+            }            
+        } catch (SQLException x) {
+            throw new RuntimeException("Database error.", x);
+        }
+        
+        // Return collection to caller.
+        return collection;
+    }
+
+    /**
+     * Get the type handled by this converter.     
+     * @return The type handled by this converte.
+     */
+    public Class<SvtTimeShiftCollection> getType() {
+        return SvtTimeShiftCollection.class;
+    }        
+}
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtBadChannelCollection.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SvtBadChannelCollection.java	15 Oct 2013 00:56:09 -0000	1.3
+++ SvtBadChannelCollection.java	15 Oct 2013 23:14:47 -0000	1.4
@@ -1,12 +1,11 @@
 package org.lcsim.hps.conditions.svt;
 
-import java.util.HashSet;
+import org.lcsim.hps.conditions.ChannelCollection;
 
 /**
  * This class represents a set of bad channels in the ECAL by their channel IDs
  * from the conditions database.
  * @author Jeremy McCormick <[log in to unmask]>
  */
-public class SvtBadChannelCollection extends HashSet<Integer> {
-
+public class SvtBadChannelCollection extends ChannelCollection {
 }

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtConditions.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- SvtConditions.java	11 Oct 2013 00:07:24 -0000	1.9
+++ SvtConditions.java	15 Oct 2013 23:14:47 -0000	1.10
@@ -11,13 +11,14 @@
  * 
  * @author Omar Moreno <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SvtConditions.java,v 1.9 2013/10/11 00:07:24 jeremy Exp $
+ * @version $Id: SvtConditions.java,v 1.10 2013/10/15 23:14:47 jeremy Exp $
  */
 public class SvtConditions {
     
     private Map<SvtChannel, ChannelConstants> channelData = new HashMap<SvtChannel, ChannelConstants>();
     private SvtChannelMap channelMap = null;
     private SvtDaqMap daqMap = null;
+    private SvtTimeShiftCollection timeShifts = null;
     
     /**
      * Class constructor, which takes a channel map.
@@ -64,12 +65,28 @@
     }
     
     /**
+     * Get the {@link SvtTimeShiftCollection}.
+     * @return The time shifts by sensor.
+     */
+    public SvtTimeShiftCollection getTimeShifts() {
+        return timeShifts;
+    }
+    
+    /**
      * Set the {@link SvtDaqMap} associated with these conditions.
      * @param daqMap The SVT DAQ map.
      */
     void setDaqMap(SvtDaqMap daqMap) {
         this.daqMap = daqMap;
     }
+    
+    /**
+     * Set the sensor time shifts.
+     * @param timeShifts The sensor time shifts collection.
+     */
+    void setTimeShifts(SvtTimeShiftCollection timeShifts) {
+        this.timeShifts = timeShifts;
+    }
             
     /**
      * Convert this object to a human readable string.  This method prints a formatted table 

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtConditionsConverter.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SvtConditionsConverter.java	15 Oct 2013 01:36:21 -0000	1.3
+++ SvtConditionsConverter.java	15 Oct 2013 23:14:47 -0000	1.4
@@ -6,6 +6,7 @@
 import static org.lcsim.hps.conditions.ConditionsConstants.SVT_DAQ_MAP;
 import static org.lcsim.hps.conditions.ConditionsConstants.SVT_GAINS;
 import static org.lcsim.hps.conditions.ConditionsConstants.SVT_PULSE_PARAMETERS;
+import static org.lcsim.hps.conditions.ConditionsConstants.SVT_TIME_SHIFTS;
 
 import java.util.Map.Entry;
 
@@ -63,6 +64,10 @@
             conditions.getChannelConstants(channel).setGain(entry.getValue());
         }
         
+        // Set the time shifts by sensor.
+        SvtTimeShiftCollection timeShifts = manager.getCachedConditions(SvtTimeShiftCollection.class, SVT_TIME_SHIFTS).getCachedData();
+        conditions.setTimeShifts(timeShifts);
+        
         return conditions;    
     }
 

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtConditionsLoader.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- SvtConditionsLoader.java	11 Oct 2013 01:42:34 -0000	1.12
+++ SvtConditionsLoader.java	15 Oct 2013 23:14:47 -0000	1.13
@@ -25,6 +25,7 @@
         List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class);
         SvtChannelMap channelMap = conditions.getChannelMap();
         SvtDaqMap daqMap = conditions.getDaqMap();
+        SvtTimeShiftCollection timeShifts = conditions.getTimeShifts();
         
         // Loop over sensors.
         for (HpsSiSensor sensor : sensors) {
@@ -66,6 +67,10 @@
                 sensor.setPedestal(channelNumber, constants.getCalibration().getPedestal());
                 sensor.setPulseParameters(channelNumber, constants.getPulseParameters().toArray());
             }
+            
+            // Set the time shift for the sensor.
+            SvtTimeShift sensorTimeShift = timeShifts.find(daqPair).get(0);
+            sensor.setTimeShift(sensorTimeShift.getTimeShift());
         }
     }
 }
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtGainConverter.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- SvtGainConverter.java	11 Oct 2013 00:07:24 -0000	1.4
+++ SvtGainConverter.java	15 Oct 2013 23:14:47 -0000	1.5
@@ -11,7 +11,7 @@
 /**
  * This class creates a {@link SvtGainCollection} from the conditions database.
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SvtGainConverter.java,v 1.4 2013/10/11 00:07:24 jeremy Exp $
+ * @version $Id: SvtGainConverter.java,v 1.5 2013/10/15 23:14:47 jeremy Exp $
  */
 public class SvtGainConverter extends DatabaseConditionsConverter<SvtGainCollection> {
     
@@ -70,7 +70,7 @@
 
     /**
      * Get the type handled by this converter.     
-     * @return The type handled by this converter, which is <code>ConditionsRecordCollection</code>.
+     * @return The type handled by this converter.
      */
     public Class<SvtGainCollection> getType() {
         return SvtGainCollection.class;

hps-java/src/test/java/org/lcsim/hps/conditions/svt
SvtConditionsLoaderTest.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- SvtConditionsLoaderTest.java	15 Oct 2013 01:35:59 -0000	1.9
+++ SvtConditionsLoaderTest.java	15 Oct 2013 23:14:47 -0000	1.10
@@ -98,6 +98,9 @@
                     ++badChannels;
                 }
             }
+
+            // Check that time shift is set for the sensor.  When unset, it's value will be NaN.
+            assertTrue("Time shift was not set.", sensor.getTimeShift() != Double.NaN);
         }
         
         // Check that there were at least some bad channels.
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