LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  October 2014

HPS-SVN October 2014

Subject:

r1360 - /java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java

From:

[log in to unmask]

Reply-To:

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

Date:

Thu, 30 Oct 2014 23:55:24 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (154 lines)

Author: [log in to unmask]
Date: Thu Oct 30 16:55:21 2014
New Revision: 1360

Log:
Update to use the DatabaseConditionsManager getCollection method.

Modified:
    java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java

Modified: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java
 =============================================================================
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java	(original)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java	Thu Oct 30 16:55:21 2014
@@ -1,11 +1,4 @@
 package org.hps.conditions.ecal;
-
-import static org.hps.conditions.TableConstants.ECAL_BAD_CHANNELS;
-import static org.hps.conditions.TableConstants.ECAL_CALIBRATIONS;
-import static org.hps.conditions.TableConstants.ECAL_CHANNELS;
-import static org.hps.conditions.TableConstants.ECAL_GAINS;
-import static org.hps.conditions.TableConstants.ECAL_TIME_SHIFTS;
-
 
 import org.lcsim.conditions.ConditionsConverter;
 import org.lcsim.conditions.ConditionsManager;
@@ -17,18 +10,16 @@
 import org.hps.conditions.ecal.EcalGain.EcalGainCollection;
 import org.hps.conditions.ecal.EcalTimeShift.EcalTimeShiftCollection;
 import org.hps.conditions.DatabaseConditionsManager;
-import org.hps.conditions.TableMetaData;
 
 /**
- * This class loads all ecal conditions into an {@link EcalConditions} object from the
+ * This class loads all ECal conditions into an {@link EcalConditions} 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]>
  */
 public final class EcalConditionsConverter implements ConditionsConverter<EcalConditions> {
 
-	private TableMetaData metaData = null; 
-	private String tableName = null;
 	
     /**
      * Create ECAL conditions object containing all data for the current run.
@@ -37,92 +28,46 @@
 
     	DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager;
 
-        // Get the table name containing the Ecal channel map from the database
-        // configuration.  If it doesn't exist, use the default value.
-        metaData = dbConditionsManager.findTableMetaData(EcalChannelCollection.class);
-        if(metaData != null){
-        	tableName = metaData.getTableName();
-        } else { 
-        	tableName = ECAL_CHANNELS;  
-        }
-        // Get the Ecal channel map from the conditions database
-        EcalChannelCollection channels = manager.getCachedConditions(EcalChannelCollection.class, tableName).getCachedData();
+        // Get the ECal channel map from the conditions database
+        EcalChannelCollection channels = dbConditionsManager.getCollection(EcalChannelCollection.class);
 
-    	// Create the Ecal conditions object that will be used to encapsulate
-        // Ecal conditions collections
+    	// Create the ECal conditions object that will be used to encapsulate
+        // ECal conditions collections
         EcalConditions conditions = new EcalConditions();
         
         // Set the channel map.
         conditions.setChannelCollection(channels);
 
-        System.out.println("channel collection size = " + channels.getObjects().size());
-
-        // Get the table name containing the Ecal gains from the database
-        // configuration. If it doesn't exist, use the default value.
-        metaData = dbConditionsManager.findTableMetaData(EcalGainCollection.class);
-        if(metaData != null){
-        	tableName = metaData.getTableName();
-        } else { 
-        	tableName = ECAL_GAINS;  
-        }
-        // Add the gains
-        EcalGainCollection gains = manager.getCachedConditions(EcalGainCollection.class, tableName).getCachedData();
+        // Get the ECal gains from the conditions database and add them to the conditions set
+        EcalGainCollection gains = dbConditionsManager.getCollection(EcalGainCollection.class);
         for (EcalGain gain : gains.getObjects()) {
             ChannelId channelId = new ChannelId(new int[] {gain.getChannelId()});
             EcalChannel channel = channels.findChannel(channelId);
             conditions.getChannelConstants(channel).setGain(gain);
         }
 
-        // Get the table name containing the Ecal bad channel map from the 
-        // database configuration. If it doesn't exist, use the default value.
-        metaData = dbConditionsManager.findTableMetaData(EcalBadChannelCollection.class);
-        if(metaData != null){
-        	tableName = metaData.getTableName();
-        } else { 
-        	tableName = ECAL_BAD_CHANNELS;  
-        }
-        
-        // Add bad channels.
-        // FIXME: This should be changed to catch a conditions record not found
-        // exception instead of a runtime exception
+        // Get the ECal bad channels and add them to the conditions set 
         try { 
-        	EcalBadChannelCollection badChannels = manager.getCachedConditions(EcalBadChannelCollection.class, tableName).getCachedData();
+        	EcalBadChannelCollection badChannels = dbConditionsManager.getCollection(EcalBadChannelCollection.class);
         	for (EcalBadChannel badChannel : badChannels.getObjects()) {
         		ChannelId channelId = new ChannelId(new int[] {badChannel.getChannelId()});
         		EcalChannel channel = channels.findChannel(channelId);
         		conditions.getChannelConstants(channel).setBadChannel(true);
         	}
         } catch(RuntimeException e){
-        	e.printStackTrace();
+        	System.out.println("[ " + conditions.getClass().getSimpleName() + "]: A set of bad channels were not found!");
         }
 
-        
-        // Get the table name containing the Ecal calibrations (pedestal, noise)
-        // from the database configuration. If it doesn't exist, use the default value.
-        metaData = dbConditionsManager.findTableMetaData(EcalCalibrationCollection.class);
-        if(metaData != null){
-        	tableName = metaData.getTableName();
-        } else { 
-        	tableName = ECAL_CALIBRATIONS;  
-        }
-        // Add calibrations including pedestal and noise values.
-        EcalCalibrationCollection calibrations = manager.getCachedConditions(EcalCalibrationCollection.class, tableName).getCachedData();
+        // Get the ECal calibrations from the conditions database and add them to the conditions set.
+        EcalCalibrationCollection calibrations = dbConditionsManager.getCollection(EcalCalibrationCollection.class);
         for (EcalCalibration calibration : calibrations.getObjects()) {
             ChannelId channelId = new ChannelId(new int[] {calibration.getChannelId()});
             EcalChannel channel = channels.findChannel(channelId);
             conditions.getChannelConstants(channel).setCalibration(calibration);
         }
 
-        // Get the table name containing the Ecal calibrations (pedestal, noise)
-        // from the database configuration. If it doesn't exist, use the default value.
-        metaData = dbConditionsManager.findTableMetaData(EcalTimeShiftCollection.class);
-        if(metaData != null){
-        	tableName = metaData.getTableName();
-        } else { 
-        	tableName = ECAL_TIME_SHIFTS;  
-        }
-        // Add time shifts.
-        EcalTimeShiftCollection timeShifts = manager.getCachedConditions(EcalTimeShiftCollection.class, tableName).getCachedData();
+        // Get the ECal time shifts from the conditions database and add them to the conditions set.
+        EcalTimeShiftCollection timeShifts = dbConditionsManager.getCollection(EcalTimeShiftCollection.class);
         for (EcalTimeShift timeShift : timeShifts.getObjects()) {
             ChannelId channelId = new ChannelId(new int[] {timeShift.getChannelId()});
             EcalChannel channel = channels.findChannel(channelId);

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

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

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

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

Privacy Notice, Security Notice and Terms of Use