Print

Print


Commit in java/trunk/conditions/src/main/java/org/hps/conditions/svt on MAIN
SvtConditionsConverter.java+85-15968 -> 969
Get the table names specifying SVT conditions from the database configuration file.  If they aren't specified in the configuration, then use the defaults.

java/trunk/conditions/src/main/java/org/hps/conditions/svt
SvtConditionsConverter.java 968 -> 969
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java	2014-09-08 08:03:24 UTC (rev 968)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java	2014-09-08 19:45:30 UTC (rev 969)
@@ -8,6 +8,8 @@
 import static org.hps.conditions.TableConstants.SVT_PULSE_PARAMETERS;
 import static org.hps.conditions.TableConstants.SVT_TIME_SHIFTS;
 
+import org.hps.conditions.DatabaseConditionsManager;
+import org.hps.conditions.TableMetaData;
 import org.hps.conditions.svt.SvtBadChannel.SvtBadChannelCollection;
 import org.hps.conditions.svt.SvtCalibration.SvtCalibrationCollection;
 import org.hps.conditions.svt.SvtChannel.SvtChannelCollection;
@@ -21,58 +23,126 @@
 /**
  * This class creates an {@link SvtConditions} object from the database, based on the
  * current run number known by the conditions manager.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @author Omar Moreno <[log in to unmask]>
+ * $Id$
  */
 public final class SvtConditionsConverter implements ConditionsConverter<SvtConditions> {
 
+	private TableMetaData metaData = null; 
+	private String tableName = null; 
+	
     /**
      * Create and return the SVT conditions object.
      * @param manager The current conditions manager.
      * @param name The conditions key, which is ignored for now.
      */
     public SvtConditions getData(ConditionsManager manager, String name) {
-
-        // Get the SVT channel map.
-        SvtChannelCollection channels = manager.getCachedConditions(SvtChannelCollection.class, SVT_CHANNELS).getCachedData();
-
-        // Create the conditions object.
+    
+    	DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager;
+    	
+        // Get the table name containing the SVT channel map from the 
+    	// database configuration.  If it doesn't exist, use the default value.
+    	metaData = dbConditionsManager.findTableMetaData(SvtChannelCollection.class);
+    	if(metaData != null){
+    		tableName = metaData.getTableName();
+    	} else { 
+    		tableName = SVT_CHANNELS; 
+    	}
+    	// Get the SVT channel map from the conditions database
+    	SvtChannelCollection channels 
+    		= dbConditionsManager.getCachedConditions(SvtChannelCollection.class, tableName).getCachedData();
+        
+        // Create the SVT conditions object to use to encapsulate SVT condition collections
         SvtConditions conditions = new SvtConditions(channels);
 
-        // Create the DAQ map.
-        SvtDaqMappingCollection daqMap = manager.getCachedConditions(SvtDaqMappingCollection.class, SVT_DAQ_MAP).getCachedData();
+        // Get the table name containing the SVT DAQ map from the database
+        // configuration.  If it doesn't exist, use the default value.
+        metaData = dbConditionsManager.findTableMetaData(SvtDaqMappingCollection.class);
+    	if(metaData != null){
+    		tableName = metaData.getTableName();
+    	} else { 
+    		tableName = SVT_DAQ_MAP; 
+    	}
+        // Get the DAQ map from the conditions database
+        SvtDaqMappingCollection daqMap = manager.getCachedConditions(SvtDaqMappingCollection.class, tableName).getCachedData();
         conditions.setDaqMap(daqMap);
 
-        // Add calibrations by channel.
-        SvtCalibrationCollection calibrations = manager.getCachedConditions(SvtCalibrationCollection.class, SVT_CALIBRATIONS).getCachedData();
+        // Get the table name containing the SVT calibrations (baseline, noise)
+        // from the database configuration.  If it doesn't exist, use the 
+        // default value.
+        metaData = dbConditionsManager.findTableMetaData(SvtCalibrationCollection.class);
+    	if(metaData != null){
+    		tableName = metaData.getTableName();
+    	} else { 
+    		tableName = SVT_CALIBRATIONS; 
+    	}
+    	// Get the calibrations from the conditions database
+        SvtCalibrationCollection calibrations = manager.getCachedConditions(SvtCalibrationCollection.class, tableName).getCachedData();
         for (SvtCalibration calibration : calibrations.getObjects()) {
             SvtChannel channel = conditions.getChannelMap().findChannel(calibration.getChannelId());
             conditions.getChannelConstants(channel).setCalibration(calibration);
         }
 
+        // Get the table name containing the SVT pulse shape parameters from 
+        // the database configuration.  If it doesn't exist, use the default value.
+        metaData = dbConditionsManager.findTableMetaData(SvtPulseParametersCollection.class);
+    	if(metaData != null){
+    		tableName = metaData.getTableName();
+    	} else { 
+    		tableName = SVT_PULSE_PARAMETERS; 
+    	}
         // Add pulse parameters by channel.
-        SvtPulseParametersCollection pulseParametersCollection = manager.getCachedConditions(SvtPulseParametersCollection.class, SVT_PULSE_PARAMETERS).getCachedData();
+        SvtPulseParametersCollection pulseParametersCollection = manager.getCachedConditions(SvtPulseParametersCollection.class, tableName).getCachedData();
         for (SvtPulseParameters pulseParameters : pulseParametersCollection.getObjects()) {
             SvtChannel channel = conditions.getChannelMap().findChannel(pulseParameters.getChannelId());
             conditions.getChannelConstants(channel).setPulseParameters(pulseParameters);
         }
 
+        // Get the table name containing the SVT bad channel map from the 
+        // database configuration.  If it doesn't exist, use the default value.
+        metaData = dbConditionsManager.findTableMetaData(SvtBadChannelCollection.class);
+    	if(metaData != null){
+    		tableName = metaData.getTableName();
+    	} else { 
+    		tableName = SVT_BAD_CHANNELS; 
+    	}
         // Add bad channels.
-        SvtBadChannelCollection badChannels = manager.getCachedConditions(SvtBadChannelCollection.class, SVT_BAD_CHANNELS).getCachedData();
+        SvtBadChannelCollection badChannels = manager.getCachedConditions(SvtBadChannelCollection.class, tableName).getCachedData();
         for (SvtBadChannel badChannel : badChannels.getObjects()) {
             SvtChannel channel = conditions.getChannelMap().findChannel(badChannel.getChannelId());
             conditions.getChannelConstants(channel).setBadChannel(true);
         }
 
+        // Get the table name containing the SVT gains from the database
+        // configuration.  If it doesn't exist, use the default value.
+        metaData = dbConditionsManager.findTableMetaData(SvtGainCollection.class);
+    	if(metaData != null){
+    		tableName = metaData.getTableName();
+    	} else { 
+    		tableName = SVT_GAINS; 
+    	}
+        
         // Add gains by channel.
-        SvtGainCollection gains = manager.getCachedConditions(SvtGainCollection.class, SVT_GAINS).getCachedData();
+        SvtGainCollection gains = manager.getCachedConditions(SvtGainCollection.class, tableName).getCachedData();
         for (SvtGain object : gains.getObjects()) {
             int channelId = object.getChannelID();
             SvtChannel channel = conditions.getChannelMap().findChannel(channelId);
             conditions.getChannelConstants(channel).setGain(object);
         }
 
-        // Set the time shifts by sensor.
-        SvtTimeShiftCollection timeShifts = manager.getCachedConditions(SvtTimeShiftCollection.class, SVT_TIME_SHIFTS).getCachedData();
-        conditions.setTimeShifts(timeShifts);
+        // Get the table name containing the SVT t0 shifts. If it doesn't 
+        // exist, use the default value. 
+        metaData = dbConditionsManager.findTableMetaData(SvtTimeShiftCollection.class);
+    	if(metaData != null){
+    		tableName = metaData.getTableName();
+    	} else { 
+    		tableName = SVT_TIME_SHIFTS; 
+    	}	
+        // Set the t0 shifts by sensor.
+        SvtTimeShiftCollection t0Shifts = manager.getCachedConditions(SvtTimeShiftCollection.class, tableName).getCachedData();
+        conditions.setTimeShifts(t0Shifts);
 
         return conditions;
     }
SVNspam 0.1