java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java 2014-09-09 01:45:29 UTC (rev 970)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java 2014-09-09 01:49:54 UTC (rev 971)
@@ -13,6 +13,8 @@
/**
* 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 {
@@ -37,8 +39,16 @@
// Reset possible existing conditions data on sensor.
sensor.reset();
- // Get the layer number.
+ // 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;
@@ -46,7 +56,7 @@
if (sensor.isBottomLayer()) {
SvtHalf = SvtDaqMappingCollection.BOTTOM_HALF;
}
- daqPair = daqMap.getDaqPair(SvtHalf, layerNumber);
+ daqPair = daqMap.getDaqPair(SvtHalf, layerNumber, moduleNumber);
if (daqPair == null) {
throw new RuntimeException("Failed to find DAQ pair for sensor: " + sensor.getName());
}
@@ -56,7 +66,6 @@
// 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);
@@ -73,6 +82,7 @@
if (constants.isBadChannel()) {
sensor.setBadChannel(channelNumber);
}
+
/*
sensor.setGain(channelNumber, constants.getGain().getGain());
sensor.setTimeOffset(channelNumber, constants.getGain().getOffset());
@@ -83,7 +93,7 @@
}
// Set the time shift for the sensor.
- SvtTimeShift sensorTimeShift = timeShifts.find(daqPair).get(0);
+ //SvtTimeShift sensorTimeShift = timeShifts.find(daqPair).get(0);
//sensor.setTimeShift(sensorTimeShift.getTimeShift());
}
}
java/trunk/conditions/src/test/java/org/hps/conditions/svt
--- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java 2014-09-09 01:45:29 UTC (rev 970)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java 2014-09-09 01:49:54 UTC (rev 971)
@@ -5,7 +5,7 @@
import junit.framework.TestCase;
import org.hps.conditions.DatabaseConditionsManager;
-import org.hps.conditions.config.DefaultTestSetup;
+import org.hps.conditions.config.DevDatabaseReadOnlyConfig;
import org.lcsim.detector.tracker.silicon.HpsSiSensor;
import org.lcsim.geometry.Detector;
@@ -14,58 +14,63 @@
* 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;
+
+ //-----------------//
+
+ DevDatabaseReadOnlyConfig dbConfig = new DevDatabaseReadOnlyConfig();
+
+ public void setUp(){
+ dbConfig.setup();
+ dbConfig.load("HPS-Proposal2014-v7-2pt2", 0);
+ }
/**
- * The number of bad channels that should be returned for the run. One of these is a
- * duplicate so the row count is actually 442 in the database.
- */
- private static final int BAD_CHANNELS_ANSWER = 441;
-
- /** The number of channels where pulse information is all zeroes. */
- private static final int PULSE_NOT_SET_ANSWER = 4;
-
- // Total number of sensors that should be processed.
- private static final int SENSOR_COUNT = 12800;
-
- DatabaseConditionsManager conditionsManager;
-
- public void setUp() {
- conditionsManager = new DefaultTestSetup().configure().setup();
- }
-
- /**
* 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 conditions.
+ // Get all SVT conditions.
SvtConditions conditions = conditionsManager.getCachedConditions(SvtConditions.class, "svt_conditions").getCachedData();
- // Load conditions onto detector.
+ // 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);
- final int nchannels = sensors.get(0).getNumberOfChannels();
- int badChannels = 0;
- int pulseNotSet = 0;
- int nsensors = 0;
+
+ 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) {
- // Loop over channels.
- for (int channel = 0; channel < nchannels; channel++) {
- // Check that hardware information seems reasonable.
- int febHybridID = sensor.getFebHybridID();
- int febID = sensor.getFebID();
+ 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);
@@ -74,44 +79,17 @@
assertTrue("PulseParameters points to null.", sensor.getPulseParameters(channel) != null);
double[] pulse = sensor.getPulseParameters(channel);
*/
-
- // There are four channels in the database where these are all zeroes.
- /*if (pulse[0] != 0) {
- // Check pulse parameters:
- assertTrue("amplitude is zero.", pulse[0] != 0);
- assertTrue("t0 is zero.", pulse[1] != 0);
- assertTrue("tp is zero.", pulse[2] != 0);
- assertTrue("chisq is zero.", pulse[3] != 0);
- } else {
- pulseNotSet += 1;
- }*/
-
- // Add to bad channel count.
- if (sensor.isBadChannel(channel)) {
- ++badChannels;
- }
- ++nsensors;
}
-
- // 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 for correct number of sensors processed.
+ this.printDebug("Total number of sensors found: " + totalSensors);
+ assertTrue(totalSensors == TOTAL_NUMBER_OF_SENSORS);
- /*assertEquals("The number of sensors was wrong.", SENSOR_COUNT, nsensors);
-
- // Check that there were at least some bad channels.
- assertTrue("Number of bad channels was zero.", badChannels != 0);
-
- // Now check the exact number of bad channels, which should be the QA set plus
- // those for run 1351.
- assertEquals("Wrong number of dead channels found.", BAD_CHANNELS_ANSWER, badChannels);
-
- // There should be exactly 4 channels where the pulse parameters are all zeroes.
- assertEquals("The number of channels for which pulse was not set is wrong.", PULSE_NOT_SET_ANSWER, pulseNotSet);
-
- System.out.println("Successfully loaded conditions data onto " + nsensors + " SVT sensors!"); */
+ System.out.println("Successfully loaded conditions data onto " + totalSensors + " SVT sensors!");
}
+
+ private void printDebug(String debugMessage){
+ System.out.println(this.getClass().getSimpleName() + ":: " + debugMessage);
+ }
}