Author: [log in to unmask]
Date: Tue Jul 28 15:49:43 2015
New Revision: 3291
Log:
Add EcalPulseWidth to EcalConditions and EcalChannelConstants. HPSJAVA-560
Modified:
java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java
java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java
java/trunk/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java
Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java
=============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java (original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java Tue Jul 28 15:49:43 2015
@@ -12,17 +12,17 @@
public final class EcalChannelConstants {
/**
- * True if channel is bad and should not be used for reconstruction.
+ * <code>true</code> if channel is bad and should not be used for reconstruction.
*/
private boolean badChannel = false;
/**
- * The channel {@link EcalCalibration} conditions.
+ * The channel's {@link EcalCalibration} conditions (pedestal and noise).
*/
private EcalCalibration calibration = null;
/**
- * The channel {@link EcalGain} conditions.
+ * The channel {@link EcalGain} conditions (per channel gain value).
*/
private EcalGain gain = null;
@@ -30,6 +30,11 @@
* The channel {@link EcalTimeShift} conditions.
*/
private EcalTimeShift timeShift = null;
+
+ /**
+ * The channel's {@link EcalPulseWidth} conditions.
+ */
+ private EcalPulseWidth pulseWidth = null;
/**
* Class constructor, which is package protected.
@@ -38,36 +43,45 @@
}
/**
- * Get the calibration.
+ * Get the channel calibration.
*
- * @return The calibration.
+ * @return the channel calibration
*/
public EcalCalibration getCalibration() {
return this.calibration;
}
/**
- * Get the gain.
+ * Get the channel gain.
*
- * @return The gain.
+ * @return the channel gain
*/
public EcalGain getGain() {
return this.gain;
+ }
+
+ /**
+ * Get the pulse width or <code>null</code> if it does not exist.
+ *
+ * @return the pulse width
+ */
+ public EcalPulseWidth getPulseWidth() {
+ return this.pulseWidth;
}
/**
* Get the time shift.
*
- * @return The time shift.
+ * @return the time shift
*/
public EcalTimeShift getTimeShift() {
return this.timeShift;
}
/**
- * True if this is a bad channel.
+ * <code>true</code> if this is a bad channel.
*
- * @return True if channel is bad.
+ * @return <code>true</code> if channel is bad
*/
public boolean isBadChannel() {
return this.badChannel;
@@ -94,7 +108,7 @@
/**
* Set the gain.
*
- * @param gain the new gain object
+ * @param gain the channel gain
*/
void setGain(final EcalGain gain) {
this.gain = gain;
@@ -103,9 +117,18 @@
/**
* Set the time shift.
*
- * @param timeShift the new time shift
+ * @param timeShift the time shift
*/
void setTimeShift(final EcalTimeShift timeShift) {
this.timeShift = timeShift;
}
+
+ /**
+ * Set the pulse width.
+ *
+ * @param pulseWidth the pulse width
+ */
+ void setPulseWidth(final EcalPulseWidth pulseWidth) {
+ this.pulseWidth = pulseWidth;
+ }
}
Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java
=============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java (original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java Tue Jul 28 15:49:43 2015
@@ -8,6 +8,7 @@
import org.hps.conditions.ecal.EcalChannel.ChannelId;
import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
import org.hps.conditions.ecal.EcalGain.EcalGainCollection;
+import org.hps.conditions.ecal.EcalPulseWidth.EcalPulseWidthCollection;
import org.hps.conditions.ecal.EcalTimeShift.EcalTimeShiftCollection;
import org.lcsim.conditions.ConditionsConverter;
import org.lcsim.conditions.ConditionsManager;
@@ -27,7 +28,7 @@
* @see EcalTimeShift
*/
public class EcalConditionsConverter implements ConditionsConverter<EcalConditions> {
-
+
/**
* Create combined ECAL conditions object containing all data for the current run.
*
@@ -36,34 +37,29 @@
*/
@Override
public final EcalConditions getData(final ConditionsManager manager, final String name) {
+
+ // Get the ECal channel map from the conditions database.
+ final EcalChannelCollection channels = this.getEcalChannelCollection();
- final DatabaseConditionsManager databaseConditionsManager = (DatabaseConditionsManager) manager;
-
- // Get the ECal channel map from the conditions database
- final EcalChannelCollection channels = this.getEcalChannelCollection(databaseConditionsManager);
-
- // Create the ECal conditions object that will be used to encapsulate
- // ECal conditions collections
- final Detector detector = databaseConditionsManager.getDetectorObject();
- final EcalConditions conditions = new EcalConditions(detector.getSubdetector(databaseConditionsManager
+ // Create the ECal conditions object that will be used to encapsulate ECal conditions collections.
+ final Detector detector = getDatabaseConditionsManager().getDetectorObject();
+ final EcalConditions conditions = new EcalConditions(detector.getSubdetector(getDatabaseConditionsManager()
.getEcalName()));
// Set the channel map.
conditions.setChannelCollection(channels);
- // Get the ECal gains from the conditions database and add them to the
- // conditions set
- final EcalGainCollection gains = this.getEcalGainCollection(databaseConditionsManager);
+ // Get the ECal gains from the conditions database and add them to the conditions set
+ final EcalGainCollection gains = this.getEcalGainCollection();
for (final EcalGain gain : gains) {
final ChannelId channelId = new ChannelId(new int[] {gain.getChannelId()});
final EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setGain(gain);
}
+ // Get the bad channel collections and merge them together.
final ConditionsSeries<EcalBadChannel, EcalBadChannelCollection> badChannelSeries = this
- .getEcalBadChannelSeries(databaseConditionsManager);
- // FIXME: How to get EcalBadChannelCollection here instead for the collection type?
- // API of ConditionsSeries and ConditionsSeriesConverter needs to be changed!
+ .getEcalBadChannelSeries();
for (final ConditionsObjectCollection<EcalBadChannel> badChannels : badChannelSeries) {
for (final EcalBadChannel badChannel : badChannels) {
final ChannelId channelId = new ChannelId(new int[] {badChannel.getChannelId()});
@@ -72,26 +68,38 @@
}
}
- // Get the ECal calibrations from the conditions database and add them
- // to the conditions set.
- final EcalCalibrationCollection calibrations = this.getEcalCalibrationCollection(databaseConditionsManager);
+ // Get the ECal calibrations from the conditions database and add them to the conditions set.
+ final EcalCalibrationCollection calibrations = this.getEcalCalibrationCollection();
for (final EcalCalibration calibration : calibrations) {
final ChannelId channelId = new ChannelId(new int[] {calibration.getChannelId()});
final EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setCalibration(calibration);
}
- // Get the ECal time shifts from the conditions database and add them to
- // the conditions set.
- if (databaseConditionsManager.hasConditionsRecord("ecal_time_shifts")) {
- final EcalTimeShiftCollection timeShifts = this.getEcalTimeShiftCollection(databaseConditionsManager);
+ // Get the ECal time shifts from the conditions database and add them to the conditions set.
+ if (getDatabaseConditionsManager().hasConditionsRecord("ecal_time_shifts")) {
+ final EcalTimeShiftCollection timeShifts = this.getEcalTimeShiftCollection();
for (final EcalTimeShift timeShift : timeShifts) {
final ChannelId channelId = new ChannelId(new int[] {timeShift.getChannelId()});
final EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setTimeShift(timeShift);
}
} else {
- DatabaseConditionsManager.getLogger().warning("no ecal_time_shifts collection found");
+ // If time shifts do not exist it is not a fatal error.
+ DatabaseConditionsManager.getLogger().warning("no conditions found for EcalTimeShiftCollection");
+ }
+
+ // Set the channel pulse width if it exists in the database.
+ if (getDatabaseConditionsManager().hasConditionsRecord("ecal_pulse_widths")) {
+ final EcalPulseWidthCollection pulseWidths = this.getEcalPulseWidthCollection();
+ for (final EcalPulseWidth pulseWidth : pulseWidths) {
+ final ChannelId channelId = new ChannelId(new int[] {pulseWidth.getChannelId()});
+ final EcalChannel channel = channels.findChannel(channelId);
+ conditions.getChannelConstants(channel).setPulseWidth(pulseWidth);
+ }
+ } else {
+ // If pulse widths do not exist it is not a fatal error.
+ DatabaseConditionsManager.getLogger().warning("no conditions found for EcalPulseWidthCollection");
}
// Return the conditions object to caller.
@@ -104,9 +112,8 @@
* @param manager the conditions manager
* @return the collections of ECAL bad channel objects
*/
- protected ConditionsSeries<EcalBadChannel, EcalBadChannelCollection> getEcalBadChannelSeries(
- final DatabaseConditionsManager manager) {
- return manager.getConditionsSeries(EcalBadChannelCollection.class, "ecal_bad_channels");
+ protected ConditionsSeries<EcalBadChannel, EcalBadChannelCollection> getEcalBadChannelSeries() {
+ return getDatabaseConditionsManager().getConditionsSeries(EcalBadChannelCollection.class, "ecal_bad_channels");
}
/**
@@ -115,8 +122,8 @@
* @param manager the conditions manager
* @return the collection of ECAL channel calibration objects
*/
- protected EcalCalibrationCollection getEcalCalibrationCollection(final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalCalibrationCollection.class, "ecal_calibrations").getCachedData();
+ protected EcalCalibrationCollection getEcalCalibrationCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalCalibrationCollection.class, "ecal_calibrations").getCachedData();
}
/**
@@ -125,8 +132,8 @@
* @param manager the conditions manager
* @return the default ECAL channel object collection
*/
- protected EcalChannelCollection getEcalChannelCollection(final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalChannelCollection.class, "ecal_channels").getCachedData();
+ protected EcalChannelCollection getEcalChannelCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalChannelCollection.class, "ecal_channels").getCachedData();
}
/**
@@ -135,8 +142,8 @@
* @param manager the conditions manager
* @return the ECAL channel gain collection
*/
- protected EcalGainCollection getEcalGainCollection(final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalGainCollection.class, "ecal_gains").getCachedData();
+ protected EcalGainCollection getEcalGainCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalGainCollection.class, "ecal_gains").getCachedData();
}
/**
@@ -145,8 +152,18 @@
* @param manager the conditions manager
* @return the collection of ECAL time shift objects
*/
- protected EcalTimeShiftCollection getEcalTimeShiftCollection(final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalTimeShiftCollection.class, "ecal_time_shifts").getCachedData();
+ protected EcalTimeShiftCollection getEcalTimeShiftCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalTimeShiftCollection.class, "ecal_time_shifts").getCachedData();
+ }
+
+ /**
+ * Get the default {@link EcalPulseWith} collection.
+ *
+ * @param manager the conditions manager
+ * @return the collection of ECAL pulse widths
+ */
+ protected EcalPulseWidthCollection getEcalPulseWidthCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalPulseWidthCollection.class, "ecal_pulse_widths").getCachedData();
}
/**
@@ -158,4 +175,13 @@
public final Class<EcalConditions> getType() {
return EcalConditions.class;
}
+
+ /**
+ * Get the current instance of the conditions manager.
+ *
+ * @return the current instance of the conditions manager
+ */
+ protected final DatabaseConditionsManager getDatabaseConditionsManager() {
+ return DatabaseConditionsManager.getInstance();
+ }
}
Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java
=============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java (original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java Tue Jul 28 15:49:43 2015
@@ -1,7 +1,6 @@
package org.hps.conditions.ecal;
import org.hps.conditions.api.ConditionsSeries;
-import org.hps.conditions.database.DatabaseConditionsManager;
import org.hps.conditions.ecal.EcalBadChannel.EcalBadChannelCollection;
import org.hps.conditions.ecal.EcalCalibration.EcalCalibrationCollection;
import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
@@ -25,9 +24,8 @@
* @return the Test Run bad channel collections
*/
@Override
- protected ConditionsSeries<EcalBadChannel, EcalBadChannelCollection> getEcalBadChannelSeries(
- final DatabaseConditionsManager manager) {
- return manager.getConditionsSeries(EcalBadChannelCollection.class, "test_run_ecal_bad_channels");
+ protected ConditionsSeries<EcalBadChannel, EcalBadChannelCollection> getEcalBadChannelSeries() {
+ return getDatabaseConditionsManager().getConditionsSeries(EcalBadChannelCollection.class, "test_run_ecal_bad_channels");
}
/**
@@ -37,8 +35,8 @@
* @return the Test Run ECAL calibration collection
*/
@Override
- protected EcalCalibrationCollection getEcalCalibrationCollection(final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalCalibrationCollection.class, "test_run_ecal_calibrations")
+ protected EcalCalibrationCollection getEcalCalibrationCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalCalibrationCollection.class, "test_run_ecal_calibrations")
.getCachedData();
}
@@ -49,8 +47,8 @@
* @return the Test Run ECAL channel collection
*/
@Override
- protected EcalChannelCollection getEcalChannelCollection(final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalChannelCollection.class, "test_run_ecal_channels").getCachedData();
+ protected EcalChannelCollection getEcalChannelCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalChannelCollection.class, "test_run_ecal_channels").getCachedData();
}
/**
@@ -60,8 +58,8 @@
* @return the Test Run ECAL gain collection
*/
@Override
- protected EcalGainCollection getEcalGainCollection(final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalGainCollection.class, "test_run_ecal_gains").getCachedData();
+ protected EcalGainCollection getEcalGainCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalGainCollection.class, "test_run_ecal_gains").getCachedData();
}
/**
@@ -71,7 +69,7 @@
* @return the Test Run ECAL time shift collection
*/
@Override
- protected EcalTimeShiftCollection getEcalTimeShiftCollection(final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalTimeShiftCollection.class, "test_run_ecal_time_shifts").getCachedData();
+ protected EcalTimeShiftCollection getEcalTimeShiftCollection() {
+ return getDatabaseConditionsManager().getCachedConditions(EcalTimeShiftCollection.class, "test_run_ecal_time_shifts").getCachedData();
}
}
|