11 modified files
java/trunk/conditions/src/test/java/org/hps/conditions
--- java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsDevTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsDevTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -7,10 +7,10 @@
import junit.framework.TestCase;
public class ConditionsDevTest extends TestCase {
-
+
public void testConditionsDev() {
- DatabaseConditionsManager manager = new DatabaseConditionsManager();
+ DatabaseConditionsManager manager = new DatabaseConditionsManager();
manager.configure("/org/hps/conditions/config/conditions_dev.xml");
manager.setConnectionResource("/org/hps/conditions/config/conditions_dev.properties");
manager.register();
@@ -19,10 +19,10 @@
} catch (ConditionsNotFoundException e) {
throw new RuntimeException(e);
}
-
+
List<TableMetaData> tableMetaData = manager.getTableMetaDataList();
for (TableMetaData metaData : tableMetaData) {
- System.out.println("getting conditions of type " + metaData.collectionClass.getCanonicalName() + " with key " + metaData.getKey() + " and table name " + metaData.getTableName());
+ System.out.println("getting conditions of type " + metaData.collectionClass.getCanonicalName() + " with key " + metaData.getKey() + " and table name " + metaData.getTableName());
manager.getConditionsData(metaData.collectionClass, metaData.getKey());
}
}
java/trunk/conditions/src/test/java/org/hps/conditions
--- java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsDriverTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsDriverTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -21,71 +21,71 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public class ConditionsDriverTest extends TestCase {
-
- // This test file has a few events from each of the "good runs" of the 2012 Test Run.
+
+ // This test file has a few events from each of the "good runs" of the 2012 Test Run.
private static final String TEST_FILE_URL = "http://www.lcsim.org/test/hps/conditions_test.slcio";
-
+
// Number of runs that should be processed in the job.
static final int NRUNS = 9;
-
+
/**
* Run the test.
- * @throws Exception
+ * @throws Exception
*/
public void test() throws Exception {
// Cache a data file from the www.
FileCache cache = new FileCache();
File testFile = cache.getCachedFile(new URL(TEST_FILE_URL));
-
- // Create the record loop.
+
+ // Create the record loop.
LCSimLoop loop = new LCSimLoop();
-
+
// Configure the loop.
loop.setLCIORecordSource(testFile);
- loop.add(new ConditionsDriver());
+ loop.add(new ConditionsDriver());
RunNumberDriver runNumberDriver = new RunNumberDriver();
loop.add(runNumberDriver);
-
+
// Turn off the log messages.
- //DatabaseConditionsManager.getInstance().setLogLevel(Level.OFF);
-
+ // DatabaseConditionsManager.getInstance().setLogLevel(Level.OFF);
+
// Run over all events.
loop.loop(-1, null);
-
+
System.out.println("Done processing events!");
-
+
// Print out unique runs.
System.out.println("Unique run numbers in this job ...");
for (int runNumber : runNumberDriver.getUniqueRuns()) {
System.out.println(runNumber);
}
-
+
System.out.println();
-
+
// Print out runs processed.
System.out.println("Processed runs in order ...");
for (int runNumber : runNumberDriver.getRunsProcessed()) {
System.out.println(runNumber);
}
-
+
// Check that correct number of runs was processed.
assertEquals("Number of runs processed was incorrect.", NRUNS, runNumberDriver.getNumberOfRuns());
-
+
// Check that the number of unique runs was correct.
- assertEquals("Number of unique runs was incorrect.", NRUNS, runNumberDriver.getUniqueRuns().size());
+ assertEquals("Number of unique runs was incorrect.", NRUNS, runNumberDriver.getUniqueRuns().size());
}
-
+
/**
* Simple Driver to store information about runs processed.
*/
static class RunNumberDriver extends Driver {
-
+
int _currentRun = -1;
int _nruns = 0;
List<Integer> _runsProcessed = new ArrayList<Integer>();
Set<Integer> _uniqueRuns = new LinkedHashSet<Integer>();
-
+
public void process(EventHeader event) {
int runNumber = event.getRunNumber();
if (runNumber != _currentRun) {
@@ -95,15 +95,15 @@
_nruns++;
}
}
-
+
int getNumberOfRuns() {
return _nruns;
}
-
+
List<Integer> getRunsProcessed() {
return _runsProcessed;
- }
-
+ }
+
Set<Integer> getUniqueRuns() {
return _uniqueRuns;
}
java/trunk/conditions/src/test/java/org/hps/conditions
--- java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsObjectTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsObjectTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -6,26 +6,26 @@
import org.hps.conditions.svt.SvtGain.SvtGainCollection;
/**
- * Test some basic operations of {@link org.hps.conditions.ConditionsObject}
- * using the {@link org.hps.conditions.svt.SvtGain} type.
+ * Test some basic operations of {@link org.hps.conditions.ConditionsObject} using the
+ * {@link org.hps.conditions.svt.SvtGain} type.
*
* @author Jeremy McCormick <[log in to unmask]>
- *
+ *
*/
// TODO: Add test of collection operations similar to the one for individual objects.
public class ConditionsObjectTest extends TestCase {
-
+
DatabaseConditionsManager _conditionsManager;
-
- public void setUp() {
+
+ public void setUp() {
_conditionsManager = new DefaultTestSetup().configure().setup();
}
-
- public void testBasicOperations() throws ConditionsObjectException {
-
+
+ public void testBasicOperations() throws ConditionsObjectException {
+
// Create a new collection, setting its table meta data and collection ID.
TableMetaData tableMetaData = _conditionsManager.findTableMetaData(TableConstants.SVT_GAINS);
- int collectionId = _conditionsManager.getNextCollectionId(tableMetaData.getTableName());
+ int collectionId = _conditionsManager.getNextCollectionId(tableMetaData.getTableName());
SvtGainCollection collection = new SvtGainCollection();
collection.setTableMetaData(tableMetaData);
try {
@@ -34,41 +34,39 @@
throw new RuntimeException(e);
}
collection.setIsReadOnly(false);
-
+
// Create a dummy conditions object and add to collection.
SvtGain gain = new SvtGain();
gain.setFieldValue("svt_channel_id", 1);
gain.setFieldValue("gain", 1.234);
gain.setFieldValue("offset", 5.678);
collection.add(gain);
-
+
// Insert into the database.
try {
gain.insert();
- System.out.println("inserted row " + gain.getRowId()
- + " into table " + gain.getTableMetaData().getTableName()
- + " with collection ID " + gain.getCollectionId());
+ System.out.println("inserted row " + gain.getRowId() + " into table " + gain.getTableMetaData().getTableName() + " with collection ID " + gain.getCollectionId());
} catch (ConditionsObjectException e) {
throw new RuntimeException(e);
}
-
+
// Select the gain that was just inserted.
SvtGain selectGain = new SvtGain();
selectGain.setRowId(gain.getRowId());
selectGain.setTableMetaData(tableMetaData);
selectGain.select();
// TODO: Check values here against the original object.
-
+
// Update the value in the database.
double newValue = 2.345;
gain.setFieldValue("gain", 2.345);
gain.update();
System.out.println("updated gain to new value " + newValue);
-
+
// Delete the object.
gain.delete();
assertEquals("The deleted object still has a valid row ID.", -1, gain.getRowId());
-
+
// Try an update which should fail.
try {
gain.update();
@@ -76,7 +74,7 @@
} catch (ConditionsObjectException e) {
System.out.println("caught expected error: " + e.getMessage());
}
-
+
// Try a delete which should fail.
try {
gain.delete();
java/trunk/conditions/src/test/java/org/hps/conditions
--- java/trunk/conditions/src/test/java/org/hps/conditions/DatabaseConditionsManagerTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/DatabaseConditionsManagerTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -3,21 +3,20 @@
import junit.framework.TestCase;
public class DatabaseConditionsManagerTest extends TestCase {
-
- DatabaseConditionsManager _conditionsManager;
-
+
+ DatabaseConditionsManager _conditionsManager;
+
public void setUp() {
_conditionsManager = new DefaultTestSetup().configure().setup();
}
-
+
@SuppressWarnings("rawtypes")
- public void testLoad() {
-
+ public void testLoad() {
+
// Load data from every table registered with the manager.
for (TableMetaData metaData : _conditionsManager.getTableMetaDataList()) {
System.out.println(">>>> loading conditions from table: " + metaData.getKey());
- ConditionsObjectCollection conditionsObjects =
- _conditionsManager.getConditionsData(metaData.getCollectionClass(), metaData.getKey());
+ ConditionsObjectCollection conditionsObjects = _conditionsManager.getConditionsData(metaData.getCollectionClass(), metaData.getKey());
System.out.println(" " + conditionsObjects.getObjects().size() + " " + conditionsObjects.get(0).getClass().getSimpleName() + " objects were created.");
}
}
java/trunk/conditions/src/test/java/org/hps/conditions/beam
--- java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamCurrentTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamCurrentTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -22,57 +22,57 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public class BeamCurrentTest extends TestCase {
-
+
/** This test file has a few events from the "good runs" of the Test Run. */
private static final String TEST_FILE_URL = "http://www.lcsim.org/test/hps/conditions_test.slcio";
-
+
/** Answer key for beam current by run. */
- static Map<Integer,Double> beamCurrentAnswerKey = new HashMap<Integer,Double>();
-
+ static Map<Integer, Double> beamCurrentAnswerKey = new HashMap<Integer, Double>();
+
/** Setup the beam current answer key by run. */
static {
- beamCurrentAnswerKey.put(1349, 54879.7343788147);
- beamCurrentAnswerKey.put(1351, 26928.0426635742);
- beamCurrentAnswerKey.put(1353, 204325.132622242);
- beamCurrentAnswerKey.put(1354, 148839.141475141);
- beamCurrentAnswerKey.put(1358, 92523.9428218845);
- beamCurrentAnswerKey.put(1359, 91761.4541434497);
- beamCurrentAnswerKey.put(1360, 209883.979889035);
- beamCurrentAnswerKey.put(1362, 110298.553449392);
- beamCurrentAnswerKey.put(1363, 8556.8459701538);
+ beamCurrentAnswerKey.put(1349, 54879.7343788147);
+ beamCurrentAnswerKey.put(1351, 26928.0426635742);
+ beamCurrentAnswerKey.put(1353, 204325.132622242);
+ beamCurrentAnswerKey.put(1354, 148839.141475141);
+ beamCurrentAnswerKey.put(1358, 92523.9428218845);
+ beamCurrentAnswerKey.put(1359, 91761.4541434497);
+ beamCurrentAnswerKey.put(1360, 209883.979889035);
+ beamCurrentAnswerKey.put(1362, 110298.553449392);
+ beamCurrentAnswerKey.put(1363, 8556.8459701538);
}
-
+
/**
* Run the test.
- * @throws Exception
+ * @throws Exception
*/
public void test() throws Exception {
// Cache file locally from URL.
FileCache cache = new FileCache();
File testFile = cache.getCachedFile(new URL(TEST_FILE_URL));
-
+
// Create the LCSimLoop.
LCSimLoop loop = new LCSimLoop();
-
+
// Configure and run the loop.
loop.setLCIORecordSource(testFile);
loop.add(new ConditionsDriver());
loop.add(new BeamCurrentChecker());
loop.loop(-1, null);
}
-
+
/**
* This Driver will check the beam current for a run against the answer key.
* @author Jeremy McCormick <[log in to unmask]>
*/
class BeamCurrentChecker extends Driver {
-
+
int currentRun = Integer.MIN_VALUE;
-
+
/**
- * This method will check the beam current against the answer key
- * for the first event of a new run.
+ * This method will check the beam current against the answer key for the first
+ * event of a new run.
*/
public void process(EventHeader event) {
if (currentRun != event.getRunNumber()) {
java/trunk/conditions/src/test/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsConverterTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsConverterTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -10,18 +10,18 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public class EcalConditionsConverterTest extends TestCase {
-
+
public void setUp() {
new DefaultTestSetup().configure().setup();
}
-
+
public void test() {
-
+
DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance();
-
+
// Test that the manager gets ECAL conditions.
- EcalConditions conditions = conditionsManager.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData();
+ EcalConditions conditions = conditionsManager.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData();
assertNotNull(conditions);
System.out.println(conditions);
- }
+ }
}
java/trunk/conditions/src/test/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsLoaderTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsLoaderTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -10,72 +10,72 @@
import org.lcsim.geometry.Detector;
/**
- * This test loads ECal conditions data onto the detector
- * and checks some of the results for basic validity.
+ * 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 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 DefaultTestSetup().configure().setup();
}
-
+
/**
* 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);
+ 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();
@@ -83,20 +83,20 @@
double gain = crystal.getGain();
boolean badChannel = crystal.isBadChannel();
- // Check basic validity of conditions. They should all be non-zero.
+ // 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);
java/trunk/conditions/src/test/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/test/java/org/hps/conditions/ecal/PhysicalToGainTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/PhysicalToGainTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -22,74 +22,72 @@
import org.lcsim.util.loop.LCSimLoop;
/**
- * This is a simple example of how to retrieve the gain and noise by physical ID (X,Y) in the ECAL.
+ * This is a simple example of how to retrieve the gain and noise by physical ID (X,Y) in
+ * the ECAL.
* @author Jeremy McCormick <[log in to unmask]>
*/
public class PhysicalToGainTest extends TestCase {
- // This test file has a few events from each of the "good runs" of the 2012 Test Run.
+ // This test file has a few events from each of the "good runs" of the 2012 Test Run.
private static final String TEST_FILE_URL = "http://www.lcsim.org/test/hps/conditions_test.slcio";
-
+
// Run the test.
public void test() throws Exception {
// Cache a data file from the www.
FileCache cache = new FileCache();
File testFile = cache.getCachedFile(new URL(TEST_FILE_URL));
-
- // Create the record loop.
+
+ // Create the record loop.
LCSimLoop loop = new LCSimLoop();
-
+
// Configure the loop.
loop.setLCIORecordSource(testFile);
loop.add(new ConditionsDriver());
loop.add(new PhysicalToGainDriver());
-
+
// Run a few events.
- loop.loop(1, null);
- }
-
+ loop.loop(1, null);
+ }
+
static class PhysicalToGainDriver extends Driver {
-
+
static final String collectionName = "EcalReadoutHits";
EcalConditions ecalConditions = null;
IIdentifierHelper helper = null;
- EcalChannelCollection channels = null;
-
+ EcalChannelCollection channels = null;
+
public void detectorChanged(Detector detector) {
-
+
// ECAL combined conditions object.
- ecalConditions = ConditionsManager.defaultInstance()
- .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
-
+ ecalConditions = ConditionsManager.defaultInstance().getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
// List of channels.
channels = ecalConditions.getChannelCollection();
-
+
// ID helper.
helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
}
-
+
public void process(EventHeader event) {
if (event.hasCollection(RawCalorimeterHit.class, collectionName)) {
-
+
// Get ECAL raw hits from event.
List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, collectionName);
- for (RawCalorimeterHit hit : hits) {
-
+ for (RawCalorimeterHit hit : hits) {
+
// Get the ECAL channel.
EcalChannel channel = findChannel(hit);
-
+
// Get the channel data.
EcalChannelConstants channelData = ecalConditions.getChannelConstants(channel);
-
+
// Get gain and noise.
double gain = channelData.getGain().getGain();
double noise = channelData.getCalibration().getNoise();
-
+
// Debug print the channel data.
- System.out.println("channel " + channel.getX() + "," + channel.getY()
- + " has gain " + channelData.getGain().getGain()
- + " and noise " + channelData.getCalibration().getNoise());
+ System.out.println("channel " + channel.getX() + "," + channel.getY() + " has gain " + channelData.getGain().getGain() + " and noise " + channelData.getCalibration().getNoise());
}
}
}
@@ -98,15 +96,15 @@
private EcalChannel findChannel(RawCalorimeterHit hit) {
// Make an ID object from raw hit ID.
IIdentifier id = new Identifier(hit.getCellID());
-
+
// Get physical field values.
int system = helper.getValue(id, "system");
int x = helper.getValue(id, "ix");
int y = helper.getValue(id, "iy");
-
+
// Create an ID to search for in channel collection.
- GeometryId geometryId = new GeometryId(helper, new int[] {system, x, y});
-
+ GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
+
// Find the ECAL channel.
return channels.findChannel(geometryId);
}
java/trunk/conditions/src/test/java/org/hps/conditions/svt
--- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtBadChannelTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtBadChannelTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -19,65 +19,66 @@
import org.lcsim.util.loop.LCSimLoop;
/**
- * This class tests that {@link org.lcsim.hps.conditions.ConditionsDriver} works correctly.
+ * This class tests that {@link org.lcsim.hps.conditions.ConditionsDriver} works
+ * correctly.
* @author Jeremy McCormick <[log in to unmask]>
*/
public class SvtBadChannelTest extends TestCase {
-
- // This test file has a few events from each of the "good runs" of the 2012 Test Run.
+
+ // This test file has a few events from each of the "good runs" of the 2012 Test Run.
private static final String TEST_FILE_URL = "http://www.lcsim.org/test/hps/conditions_test.slcio";
-
- // This is the number of bad channels in the QA set across all runs.
+
+ // This is the number of bad channels in the QA set across all runs.
static int BAD_CHANNELS_QA_ANSWER = 50;
-
+
// Answer key for number of bad channels by run.
- static Map<Integer,Integer> badChannelAnswerKey = new HashMap<Integer,Integer>();
-
+ static Map<Integer, Integer> badChannelAnswerKey = new HashMap<Integer, Integer>();
+
// Setup the bad channel answer key by run.
static {
- badChannelAnswerKey.put(1351, 441);
- badChannelAnswerKey.put(1353, 473);
- badChannelAnswerKey.put(1354, 474);
- badChannelAnswerKey.put(1358, 344);
- badChannelAnswerKey.put(1359, 468);
- badChannelAnswerKey.put(1360, 468);
+ badChannelAnswerKey.put(1351, 441);
+ badChannelAnswerKey.put(1353, 473);
+ badChannelAnswerKey.put(1354, 474);
+ badChannelAnswerKey.put(1358, 344);
+ badChannelAnswerKey.put(1359, 468);
+ badChannelAnswerKey.put(1360, 468);
}
-
+
/**
* Run the test.
- * @throws Exception
+ * @throws Exception
*/
public void test() throws Exception {
// Cache a data file from the www.
FileCache cache = new FileCache();
File testFile = cache.getCachedFile(new URL(TEST_FILE_URL));
-
- // Create the record loop.
+
+ // Create the record loop.
LCSimLoop loop = new LCSimLoop();
-
+
// Configure the loop.
loop.setLCIORecordSource(testFile);
- loop.add(new ConditionsDriver());
+ loop.add(new ConditionsDriver());
loop.add(new SvtBadChannelChecker());
-
+
DatabaseConditionsManager.getInstance().setLogLevel(Level.OFF);
-
+
// Run over all events.
- loop.loop(-1, null);
+ loop.loop(-1, null);
}
-
+
/**
* This Driver will check the number of bad channels for a run against the answer key.
* @author Jeremy McCormick <[log in to unmask]>
*/
class SvtBadChannelChecker extends Driver {
-
+
int _currentRun = -1;
-
+
/**
- * This method will check the number of bad channels against the answer key
- * for the first event of a new run.
+ * This method will check the number of bad channels against the answer key for
+ * the first event of a new run.
*/
public void process(EventHeader event) {
int run = event.getRunNumber();
@@ -88,7 +89,7 @@
List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class);
for (HpsSiSensor sensor : sensors) {
int nchannels = sensor.getNumberOfChannels();
- for (int i=0; i<nchannels; i++) {
+ for (int i = 0; i < nchannels; i++) {
if (sensor.isBadChannel(i))
++badChannels;
}
@@ -96,11 +97,11 @@
System.out.println("Run " + _currentRun + " has " + badChannels + " SVT bad channels.");
if (badChannelAnswerKey.containsKey(_currentRun)) {
Integer badChannelsExpected = badChannelAnswerKey.get(run);
- TestCase.assertEquals("Wrong number of bad channels found.", (int)badChannelsExpected, (int)badChannels);
+ TestCase.assertEquals("Wrong number of bad channels found.", (int) badChannelsExpected, (int) badChannels);
} else {
- TestCase.assertEquals("Wrong number of bad channels found.", (int)BAD_CHANNELS_QA_ANSWER, (int)badChannels);
+ TestCase.assertEquals("Wrong number of bad channels found.", (int) BAD_CHANNELS_QA_ANSWER, (int) badChannels);
}
}
- }
- }
+ }
+ }
}
java/trunk/conditions/src/test/java/org/hps/conditions/svt
--- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsConverterTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsConverterTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -6,25 +6,24 @@
import org.hps.conditions.DefaultTestSetup;
/**
- * This test loads and prints {@link SvtConditions}, which internally uses the
- * {@link SvtConditionsConverter}. It does not perform any assertions.
+ * This test loads and prints {@link SvtConditions}, which internally uses the
+ * {@link SvtConditionsConverter}. It does not perform any assertions.
*
* @author Jeremy McCormick <[log in to unmask]>
*/
public class SvtConditionsConverterTest extends TestCase {
-
-
+
public void setUp() {
new DefaultTestSetup().configure().setup();
}
-
+
/**
* Load and print all SVT conditions for a certain run number.
*/
public void test() {
-
+
DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance();
-
+
// Get conditions and print them out.
SvtConditions svt = conditionsManager.getCachedConditions(SvtConditions.class, "svt_conditions").getCachedData();
assertNotNull(svt);
java/trunk/conditions/src/test/java/org/hps/conditions/svt
--- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java 2014-04-25 20:30:32 UTC (rev 518)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java 2014-04-25 20:32:19 UTC (rev 519)
@@ -10,46 +10,46 @@
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.
+ * 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]>
*/
public class SvtConditionsLoaderTest extends TestCase {
-
+
/**
- * 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.
+ * 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() {
-
+
// Get the detector.
Detector detector = conditionsManager.getCachedConditions(Detector.class, "compact.xml").getCachedData();
-
+
// Get conditions.
SvtConditions conditions = conditionsManager.getCachedConditions(SvtConditions.class, "svt_conditions").getCachedData();
// Load 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();
@@ -59,24 +59,24 @@
// Loop over sensors.
for (HpsSiSensor sensor : sensors) {
// Loop over channels.
- for (int channel=0; channel<nchannels; channel++) {
-
+ for (int channel = 0; channel < nchannels; channel++) {
+
// Check that hardware information seems reasonable.
int hybrid = sensor.getHybridNumber();
assertTrue("Invalid hybrid value.", hybrid >= 0 && hybrid <= 2);
int fpga = sensor.getFpgaNumber();
assertTrue("Invalid FPGA value.", fpga >= 0 && fpga <= 6);
-
+
// 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);
+ 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) {
+ if (pulse[0] != 0) {
// Check pulse parameters:
assertTrue("amplitude is zero.", pulse[0] != 0);
assertTrue("t0 is zero.", pulse[1] != 0);
@@ -85,7 +85,7 @@
} else {
pulseNotSet += 1;
}
-
+
// Add to bad channel count.
if (sensor.isBadChannel(channel)) {
++badChannels;
@@ -93,22 +93,24 @@
++nsensors;
}
- // Check that time shift is set for the sensor. When unset, it's value will be NaN.
+ // 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.
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.
+
+ // 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!");
}
}
SVNspam 0.1