Commit in java/trunk/conditions on MAIN
pom.xml+1-1976 -> 977
src/main/java/org/hps/conditions/ConditionsDriver.java+4-4976 -> 977
src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java-87976 removed
src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java-100976 removed
src/test/java/org/hps/conditions/ecal/EcalConditionsLoaderTest.java-105976 removed
src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java-90976 removed
+5-387
4 removed + 2 modified, total 6 files
Rename some classes to make Omar very happy.

java/trunk/conditions
pom.xml 976 -> 977
--- java/trunk/conditions/pom.xml	2014-09-10 01:40:30 UTC (rev 976)
+++ java/trunk/conditions/pom.xml	2014-09-10 01:51:44 UTC (rev 977)
@@ -24,7 +24,7 @@
                     <excludes>
                         <exclude>org/hps/conditions/svt/SvtBadChannelTest.java</exclude>
                         <exclude>org/hps/conditions/svt/SvtGainInsertTest.java</exclude>
-                        <exclude>org/hps/conditions/svt/SvtConditionsLoaderTest.java</exclude> 
+                        <exclude>org/hps/conditions/svt/SvtDetectorSetupTest.java</exclude> 
                         <exclude>org/hps/conditions/svt/SvtConditionsConverterTest.java</exclude>
                         <exclude>org/hps/conditions/svt/SvtConfigurationTest.java</exclude>
                     </excludes>

java/trunk/conditions/src/main/java/org/hps/conditions
ConditionsDriver.java 976 -> 977
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java	2014-09-10 01:40:30 UTC (rev 976)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java	2014-09-10 01:51:44 UTC (rev 977)
@@ -4,9 +4,9 @@
 import static org.hps.conditions.TableConstants.SVT_CONDITIONS;
 
 import org.hps.conditions.ecal.EcalConditions;
-import org.hps.conditions.ecal.EcalConditionsLoader;
+import org.hps.conditions.ecal.EcalDetectorSetup;
 import org.hps.conditions.svt.SvtConditions;
-import org.hps.conditions.svt.SvtConditionsLoader;
+import org.hps.conditions.svt.SvtDetectorSetup;
 import org.lcsim.conditions.ConditionsReader;
 import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
@@ -114,7 +114,7 @@
      */
     private void loadSvtConditions(Detector detector) {
         SvtConditions conditions = manager.getCachedConditions(SvtConditions.class, SVT_CONDITIONS).getCachedData();
-        SvtConditionsLoader loader = new SvtConditionsLoader();
+        SvtDetectorSetup loader = new SvtDetectorSetup();
         loader.load(detector, conditions);
     }
 
@@ -124,7 +124,7 @@
      */
     private void loadEcalConditions(Detector detector) {
         EcalConditions conditions = manager.getCachedConditions(EcalConditions.class, ECAL_CONDITIONS).getCachedData();
-        EcalConditionsLoader loader = new EcalConditionsLoader();
+        EcalDetectorSetup loader = new EcalDetectorSetup();
         loader.load(detector.getSubdetector(ecalSubdetectorName), conditions);
     }
 

java/trunk/conditions/src/main/java/org/hps/conditions/ecal
EcalConditionsLoader.java removed after 976
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java	2014-09-10 01:40:30 UTC (rev 976)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java	2014-09-10 01:51:44 UTC (rev 977)
@@ -1,87 +0,0 @@
-package org.hps.conditions.ecal;
-
-import java.util.List;
-
-import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
-import org.hps.conditions.ecal.EcalChannel.GeometryId;
-import org.lcsim.detector.converter.compact.EcalCrystal;
-import org.lcsim.detector.identifier.IIdentifierHelper;
-import org.lcsim.geometry.Subdetector;
-
-/**
- * Load {@link EcalConditions} data onto <code>EcalCrystal</code> objects.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public final class EcalConditionsLoader {
-
-    /**
-     * Load ECal conditions data onto a full detector object.
-     * @param detector The detector object.
-     * @param conditions The conditions object.
-     */
-    public void load(Subdetector subdetector, EcalConditions conditions) {
-
-        // Find EcalCrystal objects.
-        List<EcalCrystal> crystals = subdetector.getDetectorElement().findDescendants(EcalCrystal.class);
-
-        // Get the ID helper.
-        IIdentifierHelper helper = subdetector.getDetectorElement().getIdentifierHelper();
-
-        // Get the system ID.
-        int system = subdetector.getSystemID();
-
-        // Get the full channel map created by the conditions system.
-        EcalChannelCollection channelMap = conditions.getChannelCollection();
-
-        // Build the map of geometry IDs.
-        channelMap.buildGeometryMap(helper, system);
-
-        // Loop over crystals.
-        for (EcalCrystal crystal : crystals) {
-
-            // System.out.println(crystal.getName() + " @ " + crystal.getX() + ", " +
-            // crystal.getY());
-
-            // Reset in case of existing conditions data.
-            crystal.resetConditions();
-
-            // Find the corresponding entry in the channel map for this crystal.
-            int[] geomValues = new int[] { system, crystal.getX(), crystal.getY() };
-            GeometryId geometryId = new GeometryId(helper, geomValues);
-            EcalChannel channel = channelMap.findChannel(geometryId);
-            if (channel == null) {
-                throw new RuntimeException("EcalChannel not found for crystal: " + crystal.getName());
-            }
-
-            // Set the crate.
-            crystal.setCrate(channel.getCrate());
-
-            // Set the slot.
-            crystal.setSlot(channel.getSlot());
-
-            // Set the channel number.
-            crystal.setChannel(channel.getChannel());
-
-            // Get the channel constants.
-            EcalChannelConstants constants = conditions.getChannelConstants(channel);
-            if (constants == null) {
-                throw new RuntimeException("EcalChannelConstants object not found for crystal: " + crystal.getName());
-            }
-
-            // Set bad channel.
-            crystal.setBadChannel(constants.isBadChannel());
-
-            // Set pedestal.
-            crystal.setPedestal(constants.getCalibration().getPedestal());
-
-            // Set noise.
-            crystal.setNoise(constants.getCalibration().getNoise());
-
-            // Set gain.
-            crystal.setGain(constants.getGain().getGain());
-
-            // Set time shift.
-            crystal.setTimeShift(constants.getTimeShift().getTimeShift());
-        }
-    }
-}
\ No newline at end of file

java/trunk/conditions/src/main/java/org/hps/conditions/svt
SvtConditionsLoader.java removed after 976
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java	2014-09-10 01:40:30 UTC (rev 976)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java	2014-09-10 01:51:44 UTC (rev 977)
@@ -1,100 +0,0 @@
-package org.hps.conditions.svt;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.hps.conditions.svt.SvtChannel.SvtChannelCollection;
-import org.hps.conditions.svt.SvtDaqMapping.SvtDaqMappingCollection;
-import org.hps.conditions.svt.SvtTimeShift.SvtTimeShiftCollection;
-import org.lcsim.detector.tracker.silicon.HpsSiSensor;
-import org.lcsim.geometry.Detector;
-import org.hps.util.Pair;
-
-/**
- * This class loads {@link SvtConditions} data onto <code>HpsSiSensor</code> objects.
- * @author Jeremy McCormick <[log in to unmask]>
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id$
- */
-public final class SvtConditionsLoader {
-
-    /**
-     * Load conditions data onto a detector object. This method is analogous to
-     * {@link org.lcsim.hps.recon.tracking.SvtUtils#setup(Detector)}.
-     * @param detector The detector object.
-     * @param conditions The conditions object.
-     */
-    // FIXME: Change this to use a Subdetector instead of the Detector.
-    public void load(Detector detector, SvtConditions conditions) {
-
-        // Find sensor objects.
-        List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class);
-        SvtChannelCollection channelMap = conditions.getChannelMap();
-        SvtDaqMappingCollection daqMap = conditions.getDaqMap();
-        SvtTimeShiftCollection timeShifts = conditions.getTimeShifts();
-
-        // Loop over sensors.
-        for (HpsSiSensor sensor : sensors) {
-
-            // Reset possible existing conditions data on sensor.
-            sensor.reset();
-
-            // Get the layer number.  The layer number will range from 1-12;
-            int layerNumber = sensor.getLayerNumber();
-            
-            // Get the module ID number.  The sensors in the first three layers
-            // of the SVT are assigned a module ID = 0 if they are in the top 
-            // volume and 1 if they are on the bottom.  For layers 4-6, the 
-            // assigned module ID is 0 and 2 for top and 1 and 3 for bottom
-            // depending on whether the sensor is on the hole or slot side of
-            // the half-module.
-            int moduleNumber = sensor.getModuleNumber();
-
-            // Get DAQ pair (FEB ID, FEB Hybrid ID) corresponding to this sensor
-            Pair<Integer, Integer> daqPair = null;
-            String SvtHalf = SvtDaqMappingCollection.TOP_HALF;
-            if (sensor.isBottomLayer()) {
-                SvtHalf = SvtDaqMappingCollection.BOTTOM_HALF;
-            }
-            daqPair = daqMap.getDaqPair(SvtHalf, layerNumber, moduleNumber);
-            if (daqPair == null) {
-                throw new RuntimeException("Failed to find DAQ pair for sensor: " + sensor.getName());
-            }
-
-            // Set the FEB ID of the sensor
-            sensor.setFebID(daqPair.getFirstElement());
-           
-            // Set the FEB Hybrid ID of the sensor
-            sensor.setFebHybridID(daqPair.getSecondElement());
-
-            // Find all the channels for this sensor.
-            Collection<SvtChannel> channels = channelMap.find(daqPair);
-
-            // Loop over the channels of the sensor.
-            for (SvtChannel channel : channels) {
-                // Get conditions data for this channel.
-                ChannelConstants constants = conditions.getChannelConstants(channel);
-                int channelNumber = channel.getChannel();
-
-                //
-                // Set conditions data for this channel on the sensor object:
-                //
-                if (constants.isBadChannel()) {
-                    sensor.setBadChannel(channelNumber);
-                }
-
-                /*
-                sensor.setGain(channelNumber, constants.getGain().getGain());
-                sensor.setTimeOffset(channelNumber, constants.getGain().getOffset());
-                sensor.setNoise(channelNumber, constants.getCalibration().getNoise());
-                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());
-        }
-    }
-}

java/trunk/conditions/src/test/java/org/hps/conditions/ecal
EcalConditionsLoaderTest.java removed after 976
--- java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsLoaderTest.java	2014-09-10 01:40:30 UTC (rev 976)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsLoaderTest.java	2014-09-10 01:51:44 UTC (rev 977)
@@ -1,105 +0,0 @@
-package org.hps.conditions.ecal;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.hps.conditions.DatabaseConditionsManager;
-import org.hps.conditions.config.TestRunReadOnlyConfiguration;
-import org.lcsim.detector.converter.compact.EcalCrystal;
-import org.lcsim.geometry.Detector;
-
-/**
- * This test loads ECal conditions data onto the detector and checks some of the results
- * for basic validity.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class EcalConditionsLoaderTest extends TestCase {
-
-    /** Expected number of crystals. */
-    private static final int CRYSTAL_COUNT_ANSWER = 442;
-
-    /** Expected number of bad channels. */
-    private static final int BAD_CHANNELS_ANSWER = 44;
-
-    /** Valid minimum and maximum values for DAQ setup parameters. */
-    private static final int MIN_CRATE_ANSWER = 1;
-    private static final int MAX_CRATE_ANSWER = 2;
-    private static final int MIN_SLOT_ANSWER = 3;
-    private static final int MAX_SLOT_ANSWER = 19;
-    private static final int MIN_CHANNEL_ANSWER = 0;
-    private static final int MAX_CHANNEL_ANSWER = 19;
-
-    // The total number of crystals that should be processed.
-    private static final int CRYSTAL_COUNT = 442;
-
-    public void setUp() {
-        new TestRunReadOnlyConfiguration(true);
-    }
-
-    /**
-     * Load SVT conditions data onto the detector and perform basic checks afterwards.
-     */
-    public void testLoad() {
-
-        DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance();
-
-        // Get the detector.
-        Detector detector = conditionsManager.getCachedConditions(Detector.class, "compact.xml").getCachedData();
-
-        // Get conditions.
-        EcalConditions conditions = conditionsManager.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData();
-
-        // Load conditions onto detector.
-        EcalConditionsLoader loader = new EcalConditionsLoader();
-        loader.load(detector.getSubdetector("Ecal"), conditions);
-
-        // Get crystals from detector.
-        List<EcalCrystal> crystals = detector.getDetectorElement().findDescendants(EcalCrystal.class);
-
-        // Check number of crystals.
-        assertEquals("Wrong number of crystals.", CRYSTAL_COUNT_ANSWER, crystals.size());
-
-        // Counter for bad channels.
-        int badChannelCount = 0;
-
-        // Loop over crystals.
-        int ncrystals = 0;
-        for (EcalCrystal crystal : crystals) {
-
-            // Get DAQ information.
-            int crate = crystal.getCrate();
-            int slot = crystal.getSlot();
-            int channel = crystal.getChannel();
-
-            // Check basic validity of DAQ setup information.
-            assertTrue("Crate number is out of range.", crate >= MIN_CRATE_ANSWER && crate <= MAX_CRATE_ANSWER);
-            assertTrue("Slot number is out of range.", slot >= MIN_SLOT_ANSWER && slot <= MAX_SLOT_ANSWER);
-            assertTrue("Channel number is out of range.", MIN_CHANNEL_ANSWER >= 0 && channel <= MAX_CHANNEL_ANSWER);
-
-            // Get time dependent conditions.
-            double pedestal = crystal.getPedestal();
-            double noise = crystal.getNoise();
-            double gain = crystal.getGain();
-            boolean badChannel = crystal.isBadChannel();
-
-            // Check basic validity of conditions. They should all be non-zero.
-            assertTrue("Pedestal value is zero.", pedestal != 0);
-            assertTrue("Noise value is zero.", noise != 0);
-            assertTrue("Gain value is zero.", gain != 0);
-
-            // Increment bad channel count.
-            if (badChannel)
-                ++badChannelCount;
-
-            ++ncrystals;
-        }
-
-        assertEquals("The number of crystals was wrong.", CRYSTAL_COUNT, ncrystals);
-
-        // Check total number of bad channels.
-        assertEquals("Wrong number of bad channels.", BAD_CHANNELS_ANSWER, badChannelCount);
-
-        System.out.println("Successfully loaded conditions onto " + ncrystals + " ECal crystals!");
-    }
-}

java/trunk/conditions/src/test/java/org/hps/conditions/svt
SvtConditionsLoaderTest.java removed after 976
--- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java	2014-09-10 01:40:30 UTC (rev 976)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java	2014-09-10 01:51:44 UTC (rev 977)
@@ -1,90 +0,0 @@
-package org.hps.conditions.svt;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.hps.conditions.DatabaseConditionsManager;
-import org.hps.conditions.config.DevReadOnlyConfiguration;
-import org.lcsim.detector.tracker.silicon.HpsSiSensor;
-import org.lcsim.geometry.Detector;
-
-/**
- * This test loads {@link SvtConditions} data onto the detector and then checks that all
- * channels of each sensor have non-zero data values for applicable parameters.
- * 
- * @author Jeremy McCormick <[log in to unmask]>
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id$
- */
-// TODO: Need to fix this tests so that it actually makes sense for the conditions we have.
-public class SvtConditionsLoaderTest extends TestCase {
-	
-	
-	//--- Constants ---//
-	//-----------------//
-	
-	// Total number of SVT sensors
-	public static final int TOTAL_NUMBER_OF_SENSORS = 36;	
-	   
-	public void setUp(){
-	    new DevReadOnlyConfiguration().setup().load("HPS-Proposal2014-v7-2pt2", 0);
-	}
-
-    /**
-     * Load SVT conditions data onto the detector and perform basic checks afterwards.
-     */
-    public void test() {
-    	
-		DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance();
-    	
-        // Get the detector.
-        Detector detector = conditionsManager.getCachedConditions(Detector.class, "compact.xml").getCachedData();
-
-        // Get all SVT conditions.
-        SvtConditions conditions = conditionsManager.getCachedConditions(SvtConditions.class, "svt_conditions").getCachedData();
-
-        // Load the SVT conditions onto detector.
-        SvtConditionsLoader loader = new SvtConditionsLoader();
-        loader.load(detector, conditions);
-
-        // Check sensor data.
-        List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class);
-        
-        int nChannels = sensors.get(0).getNumberOfChannels();
-        this.printDebug("Total number of channels per sensor: " + nChannels);
-        
-        // Loop over sensors.
-        int totalSensors = 0; 
-        for (HpsSiSensor sensor : sensors) {
-
-        	totalSensors++; 
-        	
-        	// Check that hardware information seems reasonable.
-            int febHybridID = sensor.getFebHybridID();
-            int febID = sensor.getFebID();
-
-            for (int channel = 0; channel < nChannels; channel++) {
-        
-                // Check that conditions values are not zero:
-                /*assertTrue("Gain is zero.", sensor.getGain(channel) != 0);
-                assertTrue("Noise is zero.", sensor.getNoise(channel) != 0);
-                assertTrue("Pedestal is zero.", sensor.getPedestal(channel) != 0);
-                assertTrue("Time offset is zero.", sensor.getTimeOffset(channel) != 0);
-                assertTrue("PulseParameters points to null.", sensor.getPulseParameters(channel) != null);
-                double[] pulse = sensor.getPulseParameters(channel);
-                */
-            }
-        }
-        
-        // Check for correct number of sensors processed.
-		this.printDebug("Total number of sensors found: " + totalSensors);
-		assertTrue(totalSensors == TOTAL_NUMBER_OF_SENSORS);
-        
-        System.out.println("Successfully loaded conditions data onto " + totalSensors + " SVT sensors!"); 
-    }
-
-    private void printDebug(String debugMessage){
-		System.out.println(this.getClass().getSimpleName() + ":: " + debugMessage);
-	}
-}
SVNspam 0.1