2 removed + 9 modified, total 11 files
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsConverterRegistery.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsConverterRegistery.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -3,7 +3,7 @@
import org.hps.conditions.beam.BeamCurrentConverter;
import org.hps.conditions.ecal.EcalBadChannelConverter;
import org.hps.conditions.ecal.EcalCalibrationConverter;
-import org.hps.conditions.ecal.EcalChannelMapConverter;
+import org.hps.conditions.ecal.EcalChannelConverter;
import org.hps.conditions.ecal.EcalConditionsConverter;
import org.hps.conditions.ecal.EcalGainConverter;
import org.hps.conditions.svt.SvtPulseParametersConverter;
@@ -38,10 +38,16 @@
// ConditionsRecords with validity meta data.
manager.registerConditionsConverter(new ConditionsRecordConverter(factory));
-
+
// SVT combined conditions.
manager.registerConditionsConverter(new SvtConditionsConverter(factory));
+
+ // SVT channel map.
+ manager.registerConditionsConverter(new SvtChannelConverter(factory));
+ // SVT DAQ map.
+ manager.registerConditionsConverter(new SvtDaqMapConverter(factory));
+
// SVT gains.
manager.registerConditionsConverter(new SvtGainConverter(factory));
@@ -51,16 +57,18 @@
// SVT calibrations.
manager.registerConditionsConverter(new SvtCalibrationConverter(factory));
- // SVT channel map.
- // TODO: Needs to support unique collection IDs.
- manager.registerConditionsConverter(new SvtChannelConverter(factory));
-
// SVT time shift by sensor.
manager.registerConditionsConverter(new SvtTimeShiftConverter(factory));
// SVT bad channels.
- manager.registerConditionsConverter(new SvtBadChannelConverter(factory));
+ manager.registerConditionsConverter(new SvtBadChannelConverter(factory));
+ // ECAL combined conditions.
+ manager.registerConditionsConverter(new EcalConditionsConverter(factory));
+
+ // ECAL channel map.
+ manager.registerConditionsConverter(new EcalChannelConverter(factory));
+
// ECAL bad channels.
manager.registerConditionsConverter(new EcalBadChannelConverter(factory));
@@ -69,21 +77,8 @@
// ECAL calibrations.
manager.registerConditionsConverter(new EcalCalibrationConverter(factory));
-
- // ECAL combined conditions.
- manager.registerConditionsConverter(new EcalConditionsConverter(factory));
-
+
// Beam current condition.
- manager.registerConditionsConverter(new BeamCurrentConverter(factory));
-
- // /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
- // TODO: Remaining to convert to new API...
- // /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
-
- // SVT DAQ map.
- manager.registerConditionsConverter(new SvtDaqMapConverter(factory));
-
- // ECAL channel map.
- manager.registerConditionsConverter(new EcalChannelMapConverter(factory));
+ manager.registerConditionsConverter(new BeamCurrentConverter(factory));
}
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsTableRegistry.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsTableRegistry.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -53,7 +53,7 @@
// SVT channels
fields = new HashSet<String>();
- fields.add("id"); // TODO: Change to svt_channel_id
+ fields.add("channel_id");
fields.add("fpga");
fields.add("hybrid");
fields.add("channel");
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -8,7 +8,7 @@
* from the DAQ hardware, and the physical x and y values of the geometric crystal volumes.
* Each of these three pieces of data specifies a unique channel, so the information is in
* some sense redundant. This class allows all these values to be associated by channel
- * in the same place. The object references are used as keys into a {@link EcalChannelMap}
+ * in the same place. The object references are used as keys into a {@link EcalChannelCollection}
* in the {@link EcalConditions} object for getting channel data.
*
* @author Jeremy McCormick <[log in to unmask]>
@@ -59,9 +59,8 @@
* Get the ID.
* @return The ID of the channel.
*/
- public int getId() {
- // FIXME: Needs to be changed to channel ID reference.
- return this.getRowId();
+ public int getChannelId() {
+ return getFieldValue("channel_id");
}
/**
@@ -79,7 +78,7 @@
return true;
}
EcalChannel c = (EcalChannel)o;
- return c.getId() == getId()
+ return c.getChannelId() == getChannelId()
&& c.getCrate() == getCrate()
&& c.getSlot() == getSlot()
&& c.getChannel() == getChannel()
@@ -88,11 +87,11 @@
}
/**
- * Implement of string conversion.
+ * Implementation of string conversion.
* @return The string representation of this channel data.
*/
public String toString() {
- return "id: " + getId()
+ return "id: " + getChannelId()
+ ", crate: " + getCrate()
+ ", slot: " + getSlot()
+ ", channel: " + getChannel()
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -3,7 +3,7 @@
/**
* This class represents ECAL conditions per channel. Individual channel
* settings can be retrieved using the {@link EcalConditions} object
- * and its {@link EcalChannelMap}.
+ * and its {@link EcalChannelCollection}.
* @author Jeremy McCormick <[log in to unmask]>
*/
public class EcalChannelConstants {
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelMap.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelMap.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -1,74 +0,0 @@
-package org.hps.conditions.ecal;
-
-import org.hps.conditions.ConditionsObjectCollection;
-
-/**
- * This class maps ID values from the database to detailed ECal channel information.
- * There should really only be one of these data structures per job, as the EcalChannel
- * objects are used as unique identifiers in the {@link EcalConditions} class.
- */
-public class EcalChannelMap extends ConditionsObjectCollection<EcalChannel> {
-
- public static final class DaqId {
- public int crate;
- public int slot;
- public int channel;
- }
-
- public static final class GeometryId {
- public int x;
- public int y;
- }
-
- public static final class ChannelId {
- public int id;
- }
-
- /**
- * Class constructor.
- */
- EcalChannelMap() {
- }
-
- /**
- * Find a channel by using DAQ information.
- * @param crate The crate number.
- * @param slot The slot number.
- * @param channelNumber The channel number.
- * @return The matching channel or null if does not exist.
- */
- public EcalChannel findChannel(DaqId daqId) {
- for (EcalChannel channel : getObjects()) {
- if (channel.getCrate() == daqId.crate
- && channel.getSlot() == daqId.slot
- && channel.getChannel() == daqId.channel) {
- return channel;
- }
- }
- return null;
- }
-
- /**
- * Find a channel by using its physical ID information.
- * @param x The x value.
- * @param y The y value.
- * @return The matching channel or null if does not exist.
- */
- public EcalChannel findChannel(GeometryId geometryId) {
- for (EcalChannel channel : getObjects()) {
- if (channel.getX() == geometryId.x && channel.getY() == geometryId.y) {
- return channel;
- }
- }
- return null;
- }
-
- public EcalChannel findChannel(ChannelId channelId) {
- for (EcalChannel channel : getObjects()) {
- if (channel.getId() == channelId.id) {
- return channel;
- }
- }
- return null;
- }
-}
\ No newline at end of file
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelMapConverter.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelMapConverter.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -1,83 +0,0 @@
-package org.hps.conditions.ecal;
-
-import static org.hps.conditions.ConditionsTableConstants.ECAL_CHANNELS;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.hps.conditions.AbstractConditionsObject.FieldValueMap;
-import org.hps.conditions.ConditionsObjectException;
-import org.hps.conditions.ConditionsObjectFactory;
-import org.hps.conditions.ConnectionManager;
-import org.hps.conditions.DatabaseConditionsConverter;
-import org.lcsim.conditions.ConditionsManager;
-
-/**
- * This class creates the {@link EcalChannelMap} from the conditions table
- * containing the channel data.
- *
- * @author Jeremy McCormick <[log in to unmask]>
- */
-// TODO: Needs to support different collectionIDs.
-public class EcalChannelMapConverter extends DatabaseConditionsConverter<EcalChannelMap> {
-
- public EcalChannelMapConverter(ConditionsObjectFactory objectFactory) {
- super(objectFactory);
- }
-
- /**
- * Load the data from the conditions database.
- * @param manager The conditions manager.
- * @param name The name of the conditions set.
- */
- public EcalChannelMap getData(ConditionsManager manager, String name) {
-
- // References to database objects.
- ResultSet resultSet = null;
- ConnectionManager connectionManager = getConnectionManager();
-
- // Collection to be returned to caller.
- EcalChannelMap collection = new EcalChannelMap();
-
- // Assign default key name if none was given.
- String tableName = name;
- if (tableName == null)
- tableName = ECAL_CHANNELS;
-
- // Query to retrieve channel data.
- String query = "SELECT id, x, y, crate, slot, channel FROM " + name;
-
- // Execute the query and get the results.
- resultSet = connectionManager.query(query);
-
- try {
- // Loop over the records.
- while (resultSet.next()) {
-
- int rowId = resultSet.getInt(1);
- FieldValueMap fieldValues = new FieldValueMap();
- fieldValues.put("x", resultSet.getInt(2));
- fieldValues.put("y", resultSet.getInt(3));
- fieldValues.put("crate", resultSet.getInt(4));
- fieldValues.put("slot", resultSet.getInt(5));
- fieldValues.put("channel", resultSet.getInt(6));
- EcalChannel newObject = _objectFactory.createObject(EcalChannel.class, tableName, rowId, fieldValues, true);
- collection.add(newObject);
- }
- } catch (SQLException x) {
- throw new RuntimeException("Database error.", x);
- } catch (ConditionsObjectException x) {
- throw new RuntimeException("Error converting to " + getType().getSimpleName() + " type.", x);
- }
-
- return collection;
- }
-
- /**
- * Get the type that this converter handles.
- * @return The type handled by this converter.
- */
- public Class<EcalChannelMap> getType() {
- return EcalChannelMap.class;
- }
-}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -12,7 +12,7 @@
public class EcalConditions {
/** Channel map. */
- EcalChannelMap channelMap = new EcalChannelMap();
+ EcalChannelCollection channelMap = new EcalChannelCollection();
/** Map between channels and conditions data. */
Map<EcalChannel,EcalChannelConstants> channelData = new HashMap<EcalChannel,EcalChannelConstants>();
@@ -27,7 +27,7 @@
* Set the channel map.
* @param channels The channel map.
*/
- void setChannelMap(EcalChannelMap channelMap) {
+ void setChannelMap(EcalChannelCollection channelMap) {
this.channelMap = channelMap;
}
@@ -35,7 +35,7 @@
* Get the map between database IDs and <code>EcalChannel</code> objects.
* @return The channel map.
*/
- public EcalChannelMap getChannelMap() {
+ public EcalChannelCollection getChannelMap() {
return channelMap;
}
@@ -109,7 +109,7 @@
// Channel data.
buff.append(String.format("%-5d %-6d %-6d %-8d %-6d %-6d",
- channel.getId(), channel.getCrate(), channel.getSlot(), channel.getChannel(),
+ channel.getChannelId(), channel.getCrate(), channel.getSlot(), channel.getChannel(),
channel.getX(), channel.getY()));
// Constants.
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -7,7 +7,7 @@
import org.hps.conditions.ConditionsObjectFactory;
import org.hps.conditions.DatabaseConditionsConverter;
-import org.hps.conditions.ecal.EcalChannelMap.ChannelId;
+import org.hps.conditions.ecal.EcalChannelCollection.ChannelId;
import org.lcsim.conditions.ConditionsManager;
/**
@@ -30,7 +30,7 @@
EcalConditions conditions = new EcalConditions();
// Get the channel information from the database.
- EcalChannelMap channelMap = manager.getCachedConditions(EcalChannelMap.class, ECAL_CHANNELS).getCachedData();
+ EcalChannelCollection channelMap = manager.getCachedConditions(EcalChannelCollection.class, ECAL_CHANNELS).getCachedData();
// Set the channel map.
conditions.setChannelMap(channelMap);
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -2,7 +2,7 @@
import java.util.List;
-import org.hps.conditions.ecal.EcalChannelMap.GeometryId;
+import org.hps.conditions.ecal.EcalChannelCollection.GeometryId;
import org.lcsim.detector.converter.compact.EcalCrystal;
import org.lcsim.geometry.Detector;
@@ -23,7 +23,7 @@
List<EcalCrystal> crystals = detector.getDetectorElement().findDescendants(EcalCrystal.class);
// Get the full channel map created by the conditions system.
- EcalChannelMap channelMap = conditions.getChannelMap();
+ EcalChannelCollection channelMap = conditions.getChannelMap();
// Loop over crystals.
for (EcalCrystal crystal : crystals) {
java/trunk/conditions/src/test/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsLoaderTest.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsLoaderTest.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -38,6 +38,9 @@
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;
/**
* Load SVT conditions data onto the detector and perform basic checks afterwards.
@@ -73,6 +76,7 @@
int badChannelCount = 0;
// Loop over crystals.
+ int ncrystals = 0;
for (EcalCrystal crystal : crystals) {
// Get DAQ information.
@@ -100,11 +104,16 @@
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!");
+
// Cleanup the database connection.
ConnectionManager.getConnectionManager().disconnect();
}
java/trunk/conditions/src/test/java/org/hps/conditions/svt
--- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java 2014-03-18 23:41:30 UTC (rev 317)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConditionsLoaderTest.java 2014-03-19 00:08:37 UTC (rev 318)
@@ -34,6 +34,9 @@
/** 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;
/**
* Load SVT conditions data onto the detector and perform basic checks afterwards.
@@ -106,6 +109,9 @@
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);
@@ -114,7 +120,7 @@
// 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!");
// Cleanup the database connection.
SVNspam 0.1