1 added + 33 modified, total 34 files
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/AbstractIdentifier.java (rev 0)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/AbstractIdentifier.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -0,0 +1,23 @@
+package org.hps.conditions;
+
+/**
+ * This class is a simplistic representation of a packaged identifier
+ * for use in the conditions system.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ *
+ */
+public abstract class AbstractIdentifier {
+
+ /**
+ * Encode the ID into a long.
+ * @return The ID encoded into a long.
+ */
+ public abstract long encode();
+
+ /**
+ * Check if the ID is valid.
+ * @return True if valid.
+ */
+ public abstract boolean isValid();
+}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -17,7 +17,7 @@
*
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class ConditionsDriver extends Driver {
+public final class ConditionsDriver extends Driver {
// Static instance of the manager.
static DatabaseConditionsManager manager;
@@ -29,7 +29,10 @@
// Default database connection parameters, which points to the SLAC development database.
static String _defaultConnectionResource =
"/org/hps/conditions/config/conditions_database_testrun_2012_connection.properties";
-
+
+ String ecalSubdetectorName = "Ecal";
+ String svtSubdetectorName = "Tracker";
+
/**
* Constructor which initializes the conditions manager with
* default connection parameters and configuration.
@@ -72,6 +75,14 @@
throw new RuntimeException(e);
}
}
+
+ public void setEcalSubdetectorName(String ecalSubdetectorName) {
+ this.ecalSubdetectorName = ecalSubdetectorName;
+ }
+
+ public void setSvtSubdetectorName(String svtSubdetectorName) {
+ this.svtSubdetectorName = svtSubdetectorName;
+ }
/**
* This method updates a new detector with SVT and ECal conditions data.
@@ -99,7 +110,7 @@
private void loadEcalConditions(Detector detector) {
EcalConditions conditions = manager.getCachedConditions(EcalConditions.class, ECAL_CONDITIONS).getCachedData();
EcalConditionsLoader loader = new EcalConditionsLoader();
- loader.load(detector, conditions);
+ loader.load(detector.getSubdetector(ecalSubdetectorName), conditions);
}
public void endOfData() {
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsRecord.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsRecord.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -10,7 +10,7 @@
*/
// TODO: Check behavior of select, delete, update and insert operations.
// TODO: Override default behavior of methods in super class that don't make sense.
-public class ConditionsRecord extends AbstractConditionsObject {
+public final class ConditionsRecord extends AbstractConditionsObject {
/**
* Collection type.
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsRecordConverter.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsRecordConverter.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -11,7 +11,7 @@
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: ConditionsRecordConverter.java,v 1.5 2013/10/15 23:24:47 jeremy Exp $
*/
-public class ConditionsRecordConverter extends ConditionsObjectConverter<ConditionsRecordCollection> {
+public final class ConditionsRecordConverter extends ConditionsObjectConverter<ConditionsRecordCollection> {
/**
* Get the ConditionsRecords for a run based on current configuration of the
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/DatabaseConditionsManager.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/DatabaseConditionsManager.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -44,7 +44,7 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
@SuppressWarnings("rawtypes")
-public class DatabaseConditionsManager extends ConditionsManagerImplementation {
+public final class DatabaseConditionsManager extends ConditionsManagerImplementation {
int runNumber = -1;
String detectorName;
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/QueryBuilder.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/QueryBuilder.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -5,7 +5,7 @@
*
* @author Jeremy McCormick <[log in to unmask]>
*/
-class QueryBuilder {
+final class QueryBuilder {
private QueryBuilder() {}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/TableMetaData.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/TableMetaData.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -17,7 +17,7 @@
* @author Jeremy McCormick <[log in to unmask]>
*
*/
-public class TableMetaData {
+public final class TableMetaData {
String tableName;
String key;
java/trunk/conditions/src/main/java/org/hps/conditions/beam
--- java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamConverterRegistry.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamConverterRegistry.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -3,7 +3,7 @@
import org.hps.conditions.ConditionsObjectConverter;
import org.hps.conditions.beam.BeamCurrent.BeamCurrentCollection;
-public class BeamConverterRegistry {
+public final class BeamConverterRegistry {
public static final class BeamCurrentConverter extends ConditionsObjectConverter<BeamCurrentCollection> {
public Class getType() {
return BeamCurrentCollection.class;
java/trunk/conditions/src/main/java/org/hps/conditions/beam
--- java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -7,7 +7,7 @@
* This class is a simple data holder for the integrated beam current condition.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class BeamCurrent extends AbstractConditionsObject {
+public final class BeamCurrent extends AbstractConditionsObject {
public static class BeamCurrentCollection extends ConditionsObjectCollection<BeamCurrent> {
}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalBadChannel.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalBadChannel.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -7,7 +7,7 @@
* This class represents an ECAL channel that is considered "bad" which means
* it should not be used in reconstruction.
*/
-public class EcalBadChannel extends AbstractConditionsObject {
+public final class EcalBadChannel extends AbstractConditionsObject {
public static class EcalBadChannelCollection extends ConditionsObjectCollection<EcalBadChannel> {
}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCalibration.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCalibration.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -12,7 +12,7 @@
*
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EcalCalibration extends AbstractConditionsObject {
+public final class EcalCalibration extends AbstractConditionsObject {
public static class EcalCalibrationCollection extends ConditionsObjectCollection<EcalCalibration> {
}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -1,98 +1,214 @@
package org.hps.conditions.ecal;
+import java.util.HashMap;
+import java.util.Map;
+
import org.hps.conditions.AbstractConditionsObject;
+import org.hps.conditions.AbstractIdentifier;
import org.hps.conditions.ConditionsObjectCollection;
+import org.hps.conditions.ConditionsObjectException;
+import org.lcsim.detector.identifier.ExpandedIdentifier;
+import org.lcsim.detector.identifier.IExpandedIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
/**
- * This class encapsulates all the setup information about a single ECal channel, e.g. one crystal.
- *
- * Any one of the three ID types specifies a unique channel. This class allows all these values to be
- * associated together by channel in the same place for ease of lookup.
+ * This class encapsulates all the information about a single ECal channel,
+ * corresponding to one physical crystal in the detector.
*
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EcalChannel extends AbstractConditionsObject {
+public final class EcalChannel extends AbstractConditionsObject {
/**
* The <code>DaqId</code> is the combination of crate, slot and channel that specify the channel's
* DAQ configuration.
*/
- public static final class DaqId {
- public int crate;
- public int slot;
- public int channel;
+ public static final class DaqId extends AbstractIdentifier {
+
+ private int crate = -1;
+ private int slot = -1;
+ private int channel = -1;
+
+ public DaqId(int values[]) {
+ crate = values[0];
+ slot = values[1];
+ channel = values[2];
+ }
+
+ @Override
+ public long encode() {
+ // from Sho's code
+ return (((long) crate) << 32) | ((long) slot << 16) | (long) channel;
+ }
+
+ @Override
+ public boolean isValid() {
+ return crate != -1 && slot != -1 && channel != -1;
+ }
}
/**
* The <code>GeometryId</code> contains the x and y indices of the crystal in the LCSIM-based geometry
* representation.
*/
- public static final class GeometryId {
- public int x;
- public int y;
+ public static final class GeometryId extends AbstractIdentifier {
+
+ private int system = -1;
+ private int x = Integer.MAX_VALUE;
+ private int y = Integer.MAX_VALUE;
+
+ private IIdentifierHelper helper;
+
+ public GeometryId(IIdentifierHelper helper, int[] values) {
+ this.helper = helper;
+ system = values[0];
+ x = values[1];
+ y = values[2];
+ }
+
+ @Override
+ public long encode() {
+ IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields());
+ expId.setValue(helper.getFieldIndex("system"), system);
+ expId.setValue(helper.getFieldIndex("ix"), x);
+ expId.setValue(helper.getFieldIndex("iy"), y);
+ return helper.pack(expId).getValue();
+ }
+
+ @Override
+ public boolean isValid() {
+ return system != -1 && x != Integer.MAX_VALUE && y != Integer.MAX_VALUE;
+ }
}
/**
- * The <code>channelId</code> is a unique number identifying the channel within its conditions collection.
+ * The <code>ChannelId</code> is a unique number identifying the channel within its conditions collection.
* The channels in the database are given sequential channel IDs from 1 to N in semi-arbitrary order.
* The channel ID is generally the number used to connect other conditions objects such as {@link EcalGain}
* or {@link EcalCalibration} to the appropriate crystal in the calorimeter.
*/
- public static final class ChannelId {
- public int id;
+ public static final class ChannelId extends AbstractIdentifier {
+
+ private int id = -1;
+
+ public ChannelId(int[] values) {
+ id = values[0];
+ }
+
+ @Override
+ public long encode() {
+ return id;
+ }
+
+ @Override
+ public boolean isValid() {
+ return id != -1;
+ }
}
+ DaqId createDaqId() {
+ return new DaqId(new int[] {getCrate(), getSlot(), getChannel()});
+ }
+
+ GeometryId createGeometryId(IIdentifierHelper helper, int system) {
+ return new GeometryId(helper, new int[] {system, getX(), getY()});
+ }
+
+ ChannelId createChannelId() {
+ return new ChannelId(new int[] {this.getChannelId()});
+ }
+
/**
- * A collection of {@link EcalChannel} objects that can be queried.
+ * A collection of {@link EcalChannel} objects.
*/
public static class EcalChannelCollection extends ConditionsObjectCollection<EcalChannel> {
-
+
+ // Identifier maps for fast lookup.
+ Map<Long, EcalChannel> daqMap = new HashMap<Long, EcalChannel>();
+ Map<Long, EcalChannel> geometryMap = new HashMap<Long, EcalChannel>();
+ Map<Long, EcalChannel> channelMap = new HashMap<Long, EcalChannel>();
+
+ /**
+ * Add an <code>EcalChannel</code> to the collection and cache its
+ * ID information. The GeometryId must be created later as it
+ * requires access to the Detector API.
+ */
+ @Override
+ public void add(EcalChannel channel) throws ConditionsObjectException {
+ super.add(channel);
+ DaqId daqId = channel.createDaqId();
+ if (daqId.isValid())
+ daqMap.put(daqId.encode(), channel);
+ ChannelId channelId = channel.createChannelId();
+ if (channelId.isValid())
+ channelMap.put(channelId.encode(), channel);
+ }
+
+ /**
+ * Build the map of geometry IDs.
+ * @param helper The identifier helper of the subdetector.
+ * @param system The system ID of the subdetector.
+ */
+ void buildGeometryMap(IIdentifierHelper helper, int system) {
+ for (EcalChannel channel : this.objects) {
+ GeometryId geometryId = channel.createGeometryId(helper, system);
+ geometryMap.put(geometryId.encode(), channel);
+ }
+ }
+
/**
* Find a channel by using DAQ information.
- * @param crate The crate number.
- * @param slot The slot number.
- * @param channelNumber The channel number.
+ * @param daqId The DAQ ID object.
* @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;
+ return daqMap.get(daqId.encode());
}
/**
* Find a channel by using its physical ID information.
- * @param x The x value.
- * @param y The y value.
+ * @param geometryId The geometric ID object.
* @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;
+ return geometryMap.get(geometryId.encode());
}
/**
* Find a channel by its channel ID.
- * @param channelId The channel ID to find.
+ * @param channelId The channel ID object.
* @return The matching channel or null if does not exist.
*/
public EcalChannel findChannel(ChannelId channelId) {
- for (EcalChannel channel : getObjects()) {
- if (channel.getChannelId() == channelId.id) {
- return channel;
- }
- }
- return null;
+ return channelMap.get(channelId.encode());
}
+
+ /**
+ * Find a channel by its encoded geometric ID.
+ * @param id The encoded geometric ID.
+ * @return The matching channel or null if does not exist.
+ */
+ public EcalChannel findGeometric(long id) {
+ return geometryMap.get(id);
+ }
+
+ /**
+ * Find a channel by its encoded channel ID.
+ * @param id The encoded channel ID.
+ * @return The matching channel or null if does not exist.
+ */
+ public EcalChannel findChannel(long id) {
+ return channelMap.get(id);
+ }
+
+ /**
+ * Find a channel by its encoded DAQ ID.
+ * @param id The encoded DAQ ID.
+ * @return The matching channel or null if does not exist.
+ */
+ public EcalChannel findDaq(long id) {
+ return daqMap.get(id);
+ }
}
/**
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -4,7 +4,7 @@
* This class represents ECAL conditions per channel.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EcalChannelConstants {
+public final class EcalChannelConstants {
EcalGain gain = null;
EcalCalibration calibration = null;
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -16,7 +16,7 @@
*
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EcalConditions {
+public final class EcalConditions {
/** Channel map. */
EcalChannelCollection channelMap = new EcalChannelCollection();
@@ -34,7 +34,7 @@
* Set the channel map.
* @param channels The channel map.
*/
- void setChannelMap(EcalChannelCollection channelMap) {
+ void setChannelCollection(EcalChannelCollection channelMap) {
this.channelMap = channelMap;
}
@@ -42,7 +42,7 @@
* Get the map between database IDs and <code>EcalChannel</code> objects.
* @return The channel map.
*/
- public EcalChannelCollection getChannelMap() {
+ public EcalChannelCollection getChannelCollection() {
return channelMap;
}
@@ -57,10 +57,11 @@
public EcalChannelConstants getChannelConstants(EcalChannel channel) {
// This channel must come from the map.
if (!channelMap.contains(channel)) {
- System.err.println("Channel not found in map => " + channel);
+ System.err.println("Channel not found in map: " + channel);
throw new IllegalArgumentException("Channel was not found in map.");
}
// If channel has no data yet, then add it.
+ // FIXME: I'm not sure this should happen at all!
if (!channelData.containsKey(channel))
channelData.put(channel, new EcalChannelConstants());
return channelData.get(channel);
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -20,7 +20,7 @@
* from the database, based on the current run number known by the conditions manager.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EcalConditionsConverter implements ConditionsConverter<EcalConditions> {
+public final class EcalConditionsConverter implements ConditionsConverter<EcalConditions> {
/**
* Create ECAL conditions object containing all data for the current run.
@@ -31,17 +31,18 @@
EcalConditions conditions = new EcalConditions();
// Get the channel information from the database.
- EcalChannelCollection channelMap = manager.getCachedConditions(EcalChannelCollection.class, ECAL_CHANNELS).getCachedData();
+ EcalChannelCollection channels = manager.getCachedConditions(EcalChannelCollection.class, ECAL_CHANNELS).getCachedData();
// Set the channel map.
- conditions.setChannelMap(channelMap);
+ conditions.setChannelCollection(channels);
+
+ System.out.println("channel collection size = " + channels.getObjects().size());
// Add gains.
EcalGainCollection gains = manager.getCachedConditions(EcalGainCollection.class, ECAL_GAINS).getCachedData();
for (EcalGain gain : gains.getObjects()) {
- ChannelId channelId = new ChannelId();
- channelId.id = gain.getChannelId();
- EcalChannel channel = channelMap.findChannel(channelId);
+ ChannelId channelId = new ChannelId(new int[] {gain.getChannelId()});
+ EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setGain(gain);
}
@@ -49,9 +50,8 @@
EcalBadChannelCollection badChannels = manager.getCachedConditions(
EcalBadChannelCollection.class, ECAL_BAD_CHANNELS).getCachedData();
for (EcalBadChannel badChannel : badChannels.getObjects()) {
- ChannelId channelId = new ChannelId();
- channelId.id = badChannel.getChannelId();
- EcalChannel channel = channelMap.findChannel(channelId);
+ ChannelId channelId = new ChannelId(new int[] {badChannel.getChannelId()});
+ EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setBadChannel(true);
}
@@ -59,9 +59,8 @@
EcalCalibrationCollection calibrations =
manager.getCachedConditions(EcalCalibrationCollection.class, ECAL_CALIBRATIONS).getCachedData();
for (EcalCalibration calibration : calibrations.getObjects()) {
- ChannelId channelId = new ChannelId();
- channelId.id = calibration.getChannelId();
- EcalChannel channel = channelMap.findChannel(channelId);
+ ChannelId channelId = new ChannelId(new int[] {calibration.getChannelId()});
+ EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setCalibration(calibration);
}
@@ -69,9 +68,8 @@
EcalTimeShiftCollection timeShifts =
manager.getCachedConditions(EcalTimeShiftCollection.class, ECAL_TIME_SHIFTS).getCachedData();
for (EcalTimeShift timeShift : timeShifts.getObjects()) {
- ChannelId channelId = new ChannelId();
- channelId.id = timeShift.getChannelId();
- EcalChannel channel = channelMap.findChannel(channelId);
+ ChannelId channelId = new ChannelId(new int[] {timeShift.getChannelId()});
+ EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setTimeShift(timeShift);
}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -5,39 +5,48 @@
import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
import org.hps.conditions.ecal.EcalChannel.GeometryId;
import org.lcsim.detector.converter.compact.EcalCrystal;
-import org.lcsim.geometry.Detector;
+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 class EcalConditionsLoader {
+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(Detector detector, EcalConditions conditions) {
+ public void load(Subdetector subdetector, EcalConditions conditions) {
// Find EcalCrystal objects.
- List<EcalCrystal> crystals = detector.getDetectorElement().findDescendants(EcalCrystal.class);
+ 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.getChannelMap();
+ 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 possibly existing conditions data.
+ // Reset in case of existing conditions data.
crystal.resetConditions();
// Find the corresponding entry in the channel map for this crystal.
- GeometryId geometryId = new GeometryId();
- geometryId.x = crystal.getX();
- geometryId.y = crystal.getY();
+ 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());
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -46,16 +46,15 @@
IIdentifier id = new Identifier(cellId);
// 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();
- geometryId.x = x;
- geometryId.y = y;
+ GeometryId geometryId = new GeometryId(helper, new int[] {system, x, y});
// Find the ECAL channel and return the crate number.
- return conditions.getChannelMap().findChannel(geometryId);
+ return conditions.getChannelCollection().findChannel(geometryId);
}
/**
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConverterRegistry.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConverterRegistry.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -11,7 +11,7 @@
* This is a set of data converters for ECAL conditions objects.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EcalConverterRegistry {
+public final class EcalConverterRegistry {
public static final class EcalBadChannelConverter extends ConditionsObjectConverter<EcalBadChannelCollection> {
public Class getType() {
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalGain.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalGain.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -8,7 +8,7 @@
*
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EcalGain extends AbstractConditionsObject {
+public final class EcalGain extends AbstractConditionsObject {
public static class EcalGainCollection extends ConditionsObjectCollection<EcalGain> {
}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalTimeShift.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalTimeShift.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -7,7 +7,7 @@
* This class represents a time shift calibration value for an ECAL channel.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EcalTimeShift extends AbstractConditionsObject {
+public final class EcalTimeShift extends AbstractConditionsObject {
/**
* A collection of {@link EcalTimeShift} objects.
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/ChannelConstants.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/ChannelConstants.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -7,7 +7,7 @@
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: ChannelConstants.java,v 1.5 2013/10/04 01:43:48 jeremy Exp $
*/
-public class ChannelConstants {
+public final class ChannelConstants {
private SvtCalibration calibration = null;
private SvtGain gain = null;
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -3,7 +3,7 @@
import org.hps.conditions.AbstractConditionsObject;
import org.hps.conditions.ConditionsObjectCollection;
-public class SvtBadChannel extends AbstractConditionsObject {
+public final class SvtBadChannel extends AbstractConditionsObject {
public static class SvtBadChannelCollection extends ConditionsObjectCollection<SvtBadChannel> {
}
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -7,7 +7,7 @@
* This class represents a noise and pedestal measurement for an SVT channel.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class SvtCalibration extends AbstractConditionsObject {
+public final class SvtCalibration extends AbstractConditionsObject {
public static class SvtCalibrationCollection extends ConditionsObjectCollection<SvtCalibration> {
}
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -15,7 +15,7 @@
* This class represents SVT channel setup information, including hybrid, FPGA, and channel numbers.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class SvtChannel extends AbstractConditionsObject {
+public final class SvtChannel extends AbstractConditionsObject {
public static class SvtChannelCollection extends ConditionsObjectCollection<SvtChannel> {
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -15,7 +15,7 @@
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: SvtConditions.java,v 1.11 2013/10/15 23:45:56 jeremy Exp $
*/
-public class SvtConditions {
+public final class SvtConditions {
/** SVT conditions data. */
private Map<SvtChannel, ChannelConstants> channelData = new HashMap<SvtChannel, ChannelConstants>();
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -22,7 +22,7 @@
* This class creates an {@link SvtConditions} object from the database,
* based on the current run number known by the conditions manager.
*/
-public class SvtConditionsConverter implements ConditionsConverter<SvtConditions> {
+public final class SvtConditionsConverter implements ConditionsConverter<SvtConditions> {
/**
* Create and return the SVT conditions object.
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -14,7 +14,7 @@
* This class loads {@link SvtConditions} data onto <code>HpsSiSensor</code> objects.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class SvtConditionsLoader {
+public final class SvtConditionsLoader {
/**
* Load conditions data onto a detector object.
@@ -22,6 +22,7 @@
* @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.
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConverterRegistry.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConverterRegistry.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -11,7 +11,7 @@
@SuppressWarnings({"unchecked", "rawtypes"})
-public class SvtConverterRegistry {
+public final class SvtConverterRegistry {
public static class SvtBadChannelConverter extends ConditionsObjectConverter<SvtBadChannelCollection> {
public Class getType() {
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -4,7 +4,7 @@
import org.hps.conditions.ConditionsObjectCollection;
import org.hps.util.Pair;
-public class SvtDaqMapping extends AbstractConditionsObject {
+public final class SvtDaqMapping extends AbstractConditionsObject {
public static class SvtDaqMappingCollection extends ConditionsObjectCollection<SvtDaqMapping> {
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -7,7 +7,7 @@
* This class represents gain measurements for a single SVT channel.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class SvtGain extends AbstractConditionsObject {
+public final class SvtGain extends AbstractConditionsObject {
public static class SvtGainCollection extends ConditionsObjectCollection<SvtGain> {
}
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtPulseParameters.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtPulseParameters.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -7,7 +7,7 @@
* This class represents the pulse parameters for an SVT channel.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class SvtPulseParameters extends AbstractConditionsObject {
+public final class SvtPulseParameters extends AbstractConditionsObject {
public static class SvtPulseParametersCollection extends ConditionsObjectCollection<SvtPulseParameters> {
}
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtTimeShift.java 2014-04-25 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtTimeShift.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -10,7 +10,7 @@
* by FPGA and hybrid numbers.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class SvtTimeShift extends AbstractConditionsObject {
+public final class SvtTimeShift extends AbstractConditionsObject {
public static class SvtTimeShiftCollection extends ConditionsObjectCollection<SvtTimeShift> {
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 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalConditionsLoaderTest.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -52,7 +52,7 @@
// Load conditions onto detector.
EcalConditionsLoader loader = new EcalConditionsLoader();
- loader.load(detector, conditions);
+ loader.load(detector.getSubdetector("Ecal"), conditions);
// Get crystals from detector.
List<EcalCrystal> crystals = detector.getDetectorElement().findDescendants(EcalCrystal.class);
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 02:28:23 UTC (rev 516)
+++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/PhysicalToGainTest.java 2014-04-25 20:22:15 UTC (rev 517)
@@ -63,7 +63,7 @@
.getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
// List of channels.
- channels = ecalConditions.getChannelMap();
+ channels = ecalConditions.getChannelCollection();
// ID helper.
helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
@@ -100,13 +100,12 @@
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();
- geometryId.x = x;
- geometryId.y = y;
+ GeometryId geometryId = new GeometryId(helper, new int[] {system, x, y});
// Find the ECAL channel.
return channels.findChannel(geometryId);
SVNspam 0.1