Author: [log in to unmask]
Date: Thu Aug 20 17:29:01 2015
New Revision: 3392
Log:
Merge trunk changes into branch.
Added:
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasMyaDataReader.java
- copied unchanged from r3391, java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasMyaDataReader.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtMotorMyaDataReader.java
- copied unchanged from r3391, java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtMotorMyaDataReader.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtMotorPosition.java
- copied unchanged from r3391, java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtMotorPosition.java
Modified:
java/branches/conditions-HPSJAVA-517/ (props changed)
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/api/ConditionsObjectUtilities.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/database/ConnectionParameters.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/run/RunSpreadsheet.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasConstant.java
java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasMyaDumpReader.java
Modified: java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/api/ConditionsObjectUtilities.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/api/ConditionsObjectUtilities.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/api/ConditionsObjectUtilities.java Thu Aug 20 17:29:01 2015
@@ -83,6 +83,7 @@
final TableMetaData tableInfo = TableRegistry.getTableRegistry().findByTableName(tableName);
final ConditionsObjectCollection<?> collection = tableInfo.newCollection();
collection.setConnection(MANAGER.getConnection());
+ collection.setTableMetaData(tableInfo);
return collection;
}
@@ -97,6 +98,7 @@
final TableMetaData tableInfo = TableRegistry.getTableRegistry().findByTableName(tableName);
final ConditionsObject object = tableInfo.newObject();
object.setConnection(MANAGER.getConnection());
+ object.setTableMetaData(tableInfo);
return object;
}
Modified: java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/database/ConnectionParameters.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/database/ConnectionParameters.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/database/ConnectionParameters.java Thu Aug 20 17:29:01 2015
@@ -177,6 +177,7 @@
*/
public String getConnectionString() {
return "jdbc:mysql://" + this.hostname + ":" + this.port + "/";
+ //String connectionString = "jdbc:mysql://localhost/" + database + "?user=" + user + "&password=" + password + "&useUnicode=true&characterEncoding=UTF-8";
}
/**
@@ -223,4 +224,14 @@
String getUser() {
return this.user;
}
+
+ /**
+ * Convert to human readable string.
+ *
+ * @return this object converted to a string
+ */
+ public String toString() {
+ return "ConnectionParameters { database: " + database + ", hostname: " + hostname + ", password: " + password
+ + ", port: " + port + ", user: " + user + " }";
+ }
}
Modified: java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java Thu Aug 20 17:29:01 2015
@@ -110,11 +110,9 @@
*/
public static synchronized DatabaseConditionsManager getInstance() {
- logger.finest("getting conditions manager instance");
-
// Is there no manager installed yet?
if (!ConditionsManager.isSetup() || !(ConditionsManager.defaultInstance() instanceof DatabaseConditionsManager)) {
- logger.finest("creating new DatabaseConditionsManager");
+ logger.finest("creating new DatabaseConditionsManager instance");
// Create a new instance if necessary, which will install it globally as the default.
new DatabaseConditionsManager();
}
@@ -122,12 +120,10 @@
// Get the instance back from the default conditions system and check that the type is correct now.
final ConditionsManager manager = ConditionsManager.defaultInstance();
if (!(manager instanceof DatabaseConditionsManager)) {
- logger.severe("default conditions manager has wrong type");
+ logger.severe("default conditions manager has wrong type: " + manager.getClass());
throw new RuntimeException("Default conditions manager has the wrong type: "
+ ConditionsManager.defaultInstance().getClass().getName());
}
-
- logger.finest("returning conditions manager instance");
return (DatabaseConditionsManager) manager;
}
Modified: java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java Thu Aug 20 17:29:01 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/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java Thu Aug 20 17:29:01 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/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java Thu Aug 20 17:29:01 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();
}
}
Modified: java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/run/RunSpreadsheet.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/run/RunSpreadsheet.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/run/RunSpreadsheet.java Thu Aug 20 17:29:01 2015
@@ -187,14 +187,21 @@
run = parseRunNumber(this.record);
try {
startDate = RunSpreadsheet.parseStartDate(this.record);
- } catch (ParseException e) {
+ } catch (ParseException e) {
}
try {
endDate = RunSpreadsheet.parseEndDate(this.record);
- } catch (ParseException e) {
- }
- }
-
+ } catch (ParseException e) {
+ }
+ }
+
+ public RunData(Date startDate, Date endDate, int run) {
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.run = run;
+ record = null;
+ }
+
public int getRun() {
return run;
}
@@ -213,6 +220,10 @@
public CSVRecord getRecord() {
return record;
+ }
+
+ public boolean isJunk() {
+ return "JUNK".compareToIgnoreCase(record.get("to_tape")) == 0;
}
}
Modified: java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java Thu Aug 20 17:29:01 2015
@@ -1,22 +1,24 @@
-/**
- *
- */
package org.hps.conditions.svt;
import hep.aida.*;
-
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
import java.sql.SQLException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map.Entry;
+import java.util.Map;
import java.util.Set;
+import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
-
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
@@ -24,7 +26,6 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
-import org.hps.conditions.api.ConditionsObjectException;
import org.hps.conditions.api.ConditionsRecord;
import org.hps.conditions.database.DatabaseConditionsManager;
import org.hps.conditions.run.RunRange;
@@ -32,10 +33,11 @@
import org.hps.conditions.run.RunSpreadsheet.RunData;
import org.hps.conditions.run.RunSpreadsheet.RunMap;
import org.hps.conditions.svt.SvtBiasConstant.SvtBiasConstantCollection;
-import org.hps.conditions.svt.SvtBiasMyaDumpReader.SvtBiasMyaRange;
-import org.hps.conditions.svt.SvtBiasMyaDumpReader.SvtBiasMyaRanges;
-import org.hps.conditions.svt.SvtBiasMyaDumpReader.SvtBiasRunRange;
-import org.hps.conditions.svt.SvtTimingConstants.SvtTimingConstantsCollection;
+import org.hps.conditions.svt.SvtBiasMyaDataReader.SvtBiasMyaRange;
+import org.hps.conditions.svt.SvtBiasMyaDataReader.SvtBiasRunRange;
+import org.hps.conditions.svt.SvtMotorMyaDataReader.SvtPositionMyaRange;
+import org.hps.conditions.svt.SvtMotorMyaDataReader.SvtPositionRunRange;
+import org.hps.conditions.svt.SvtMotorPosition.SvtMotorPositionCollection;
import org.hps.util.BasicLogFormatter;
import org.lcsim.util.aida.AIDA;
import org.lcsim.util.log.LogUtil;
@@ -47,13 +49,13 @@
public class SvtBiasConditionsLoader {
private static final Set<String> FIELDS = new HashSet<String>();
- private static Logger logger = LogUtil.create(SvtBiasConditionsLoader.class, new BasicLogFormatter(),Level.INFO);
-
+ private static Logger logger = LogUtil.create(SvtBiasConditionsLoader.class, new BasicLogFormatter(), Level.INFO);
/**
* Setup conditions.
*/
private static final DatabaseConditionsManager MANAGER = DatabaseConditionsManager.getInstance();
+
static {
FIELDS.add("run");
FIELDS.add("date");
@@ -64,62 +66,63 @@
/**
* Setup control plots.
*/
- private static AIDA aida = AIDA.defaultInstance();
+ private static final AIDA aida = AIDA.defaultInstance();
static IDataPointSet dpsRuns = null;
static IDataPointSet dpsBiasRuns = null;
-
+ static IDataPointSet dpsPositionRuns = null;
+
private static void setupPlots(boolean show) {
IDataPointSetFactory dpsf = aida.analysisFactory().createDataPointSetFactory(aida.tree());
- dpsRuns = dpsf.create("dpsRuns","Run intervals", 2);
- dpsBiasRuns = dpsf.create("dpsBiasRuns","Bias ON intervals associated with runs", 2);
+ dpsRuns = dpsf.create("dpsRuns", "Run intervals", 2);
+ dpsBiasRuns = dpsf.create("dpsBiasRuns", "Bias ON intervals associated with runs", 2);
+ dpsPositionRuns = dpsf.create("dpsPositionRuns", "Position stable intervals associated with runs", 2);
IPlotter plotter = aida.analysisFactory().createPlotterFactory().create("Bias run ranges");
IPlotterStyle plotterStyle = aida.analysisFactory().createPlotterFactory().createPlotterStyle();
plotterStyle.xAxisStyle().setParameter("type", "date");
- plotter.createRegions(1, 3);
- plotter.region(0).plot(dpsRuns,plotterStyle);
- plotter.region(1).plot(dpsBiasRuns,plotterStyle);
- plotter.region(2).plot(dpsRuns,plotterStyle);
- plotter.region(2).plot(dpsBiasRuns,plotterStyle,"mode=overlay");
- if(show) plotter.show();
-
- }
-
+ plotter.createRegions(1, 4);
+ plotter.region(0).plot(dpsRuns, plotterStyle);
+ plotter.region(1).plot(dpsBiasRuns, plotterStyle);
+ plotter.region(2).plot(dpsPositionRuns, plotterStyle);
+ plotter.region(3).plot(dpsRuns, plotterStyle);
+ plotter.region(3).plot(dpsBiasRuns, plotterStyle, "mode=overlay");
+ plotter.region(3).plot(dpsPositionRuns, plotterStyle, "mode=overlay");
+ if (show) {
+ plotter.show();
+ }
+
+ }
+
private static IDataPoint addPoint(IDataPointSet dps, long mstime, double val) {
IDataPoint dp = dps.addPoint();
- dp.coordinate(0).setValue(mstime/1000.);
+ dp.coordinate(0).setValue(mstime / 1000.);
dp.coordinate(1).setValue(val);
return dp;
}
-
-
+
/**
- * Default constructor
+ * Default constructor
*/
public SvtBiasConditionsLoader() {
}
-
-
-
/**
* Check validity of @link RunData
+ *
* @param data the @link RunData to check
* @return <code>true</code> if valid, <code>false</code> otherwise.
*/
private static boolean isValid(RunData data) {
- if(data.getStartDate() == null || data.getEndDate() == null || data.getStartDate().before(new Date(99,1,1))) {
+ if (data.getStartDate() == null || data.getEndDate() == null || data.getStartDate().before((new GregorianCalendar(1999, 1, 1)).getTime())) {
logger.fine("This run data is not valid: " + data.toString());
return false;
- }
+ }
if (data.getStartDate().after(data.getEndDate())) {
throw new RuntimeException("start date is after end date?!" + data.toString());
}
return true;
}
-
+
//private static Options options = null;
-
-
public static RunMap getRunMapFromSpreadSheet(String path) {
// Load in CSV records from the exported run spreadsheet.
logger.info(path);
@@ -128,65 +131,51 @@
// Find the run ranges that have the same fields values.
final List<RunRange> ranges = RunRange.findRunRanges(runSheet, FIELDS);
logger.info("Found " + ranges.size() + " ranges.");
- for(RunRange range : ranges) logger.fine(range.toString());
+ for (RunRange range : ranges) {
+ logger.fine(range.toString());
+ }
// find the run records (has converted dates and stuff) for these ranges
- RunMap runmap = runSheet.getRunMap(ranges);
+ RunMap runmap = runSheet.getRunMap(ranges);
logger.info("Found " + runmap.size() + " runs in the run map.");
return runmap;
}
-
- public static List<SvtBiasRunRange> getBiasRunRanges(RunMap runmap,
- SvtBiasMyaDumpReader biasMyaReader) {
- List<SvtBiasRunRange> biasRunRanges = new ArrayList<SvtBiasRunRange>();
- // loop over runs from CSV
- RunData prev = null;
- for(Entry<Integer,RunData> entry : runmap.entrySet()) {
- int run = entry.getKey();
- RunData data = entry.getValue();
- logger.fine("Processing " + run + " " + data.toString());
-
- //check that data is ok
+
+ public static List<RunData> getRunListFromSpreadSheet(String path) {
+ // Load in CSV records from the exported run spreadsheet.
+ List<RunData> runList = new ArrayList<RunData>();
+
+ // find the run records (has converted dates and stuff) for these ranges
+ RunMap runmap = getRunMapFromSpreadSheet(path);
+
+ List<Integer> runNums = new ArrayList<Integer>(runmap.keySet());
+ Collections.sort(runNums);
+ for (Integer runNum : runNums) {
+ RunData data = runmap.get(runNum);
if (isValid(data)) {
- if(prev!=null) {
- if(isValid(prev)) {
- if(prev.getEndDate().after(data.getStartDate())) {
- throw new RuntimeException("prev end date after run started?: " + prev.toString() + " " + data.toString());
- } else if(prev.getStartDate().after(data.getEndDate())) {
- throw new RuntimeException("prev start date before run ended?: " + prev.toString() + " " + data.toString());
- }
- }
- }
-
- // find the bias ranges applicable to this run
- SvtBiasMyaRanges overlaps = biasMyaReader.findOverlappingRanges(data.getStartDate(), data.getEndDate());
- logger.fine("Found " + overlaps.size() + " overlapping bias ranges");
- logger.fine(overlaps.toString());
-
- biasRunRanges.add(new SvtBiasRunRange(data,overlaps));
- prev = data;
-
- }
- }
- return biasRunRanges;
- }
-
-
-
-
-
+ runList.add(data);
+ }
+ }
+ return runList;
+ }
+
/**
* Load SVT HV bias constants into the conditions database.
- *
- * @param args the command line arguments (requires a CVS run log file and a MYA dump file.)
+ *
+ * @param args the command line arguments (requires a CVS run log file and a
+ * MYA dump file.)
*/
public static void main(String[] args) {
Options options = new Options();
- options.addOption(new Option("c", true, "CVS run file"));
- options.addOption(new Option("m", true, "MYA dump file"));
+ options.addOption(new Option("c", true, "CSV run file"));
+ options.addOption(new Option("m", true, "MYA dump file for bias"));
+ options.addOption(new Option("p", true, "MYA dump file for motor positions"));
+ options.addOption(new Option("t", false, "use run table format (from crawler) for bias"));
+ options.addOption(new Option("d", false, "discard first line of MYA data (for myaData output)"));
options.addOption(new Option("g", false, "Actually load stuff into DB"));
+ options.addOption(new Option("b", true, "beam current file"));
options.addOption(new Option("s", false, "Show plots"));
-
+
final CommandLineParser parser = new PosixParser();
CommandLine cl = null;
try {
@@ -194,83 +183,99 @@
} catch (ParseException e) {
throw new RuntimeException("Cannot parse.", e);
}
-
- if(!cl.hasOption("c") || !cl.hasOption("m")) {
+
+ if (!cl.hasOption("c") || (!cl.hasOption("m") && !cl.hasOption("p"))) {
printUsage(options);
return;
}
-
-
-
+
// Setup plots
- setupPlots(cl.hasOption("s")?true:false);
-
-
+ setupPlots(cl.hasOption("s"));
+
// Load in CSV records from the exported run spreadsheet.
- RunMap runmap = getRunMapFromSpreadSheet(cl.getOptionValue("c"));
-
-
+ List<RunData> runList;
+ if (cl.hasOption("t")) {
+ runList = SvtBiasMyaDataReader.readRunTable(new File(cl.getOptionValue("c")));
+ } else {
+ runList = getRunListFromSpreadSheet(cl.getOptionValue("c"));
+ }
+
+ List<SvtBiasRunRange> biasRunRanges = null;
+ List<SvtPositionRunRange> positionRunRanges = null;
// Load MYA dump
- SvtBiasMyaDumpReader biasMyaReader = new SvtBiasMyaDumpReader(cl.getOptionValue("m"));
- logger.info("Got " + biasMyaReader.getRanges().size() + " bias ranges");
-
-
+ if (cl.hasOption("m")) {
+ List<SvtBiasMyaRange> biasRanges = SvtBiasMyaDataReader.readMyaData(new File(cl.getOptionValue("m")), 178.0, 2000, cl.hasOption("d"));
+ logger.info("Got " + biasRanges.size() + " bias ranges");
+ biasRunRanges = SvtBiasMyaDataReader.findOverlappingRanges(runList, biasRanges);
+ }
+
+ if (cl.hasOption("p")) {
+ List<SvtPositionMyaRange> positionRanges = SvtMotorMyaDataReader.readMyaData(new File(cl.getOptionValue("p")), 200, 10000);
+ logger.info("Got " + positionRanges.size() + " position ranges");
+ positionRunRanges = SvtMotorMyaDataReader.findOverlappingRanges(runList, positionRanges);
+ }
+
// Combine them to run ranges when bias was on
// each run may have multiple bias ranges
-
- List<SvtBiasRunRange> biasRunRanges = getBiasRunRanges(runmap,biasMyaReader);
-
-
-
// fill graphs
- if(cl.hasOption("s")) {
- for(SvtBiasRunRange r : biasRunRanges) {
- logger.info(r.toString());
- if(r.getRun().getRun()>5600) {//9999999999999.0) {
- //if(dpsRuns.size()/4.0<500) {//9999999999999.0) {
- addPoint(dpsRuns, r.getRun().getStartDate().getTime(),0.0);
- addPoint(dpsRuns, r.getRun().getStartDate().getTime(),1.0);
- addPoint(dpsRuns, r.getRun().getEndDate().getTime(),1.0);
- addPoint(dpsRuns, r.getRun().getEndDate().getTime(),0.0);
-
- for(SvtBiasMyaRange br : r.getRanges()) {
- addPoint(dpsBiasRuns, br.getStart().getDate().getTime(),0.0);
- addPoint(dpsBiasRuns, br.getStart().getDate().getTime(),0.5);
- addPoint(dpsBiasRuns, br.getEnd().getDate().getTime(),0.5);
- addPoint(dpsBiasRuns, br.getEnd().getDate().getTime(),0.0);
- }
-
-
- }
-
- }
- }
-
-
+ if (cl.hasOption("s")) {
+ if (cl.hasOption("m")) {
+ for (SvtBiasRunRange r : biasRunRanges) {
+ logger.info(r.toString());
+ if (r.getRun().getRun() > 5600) {//9999999999999.0) {
+ //if(dpsRuns.size()/4.0<500) {//9999999999999.0) {
+ addPoint(dpsRuns, r.getRun().getStartDate().getTime(), 0.0);
+ addPoint(dpsRuns, r.getRun().getStartDate().getTime(), 1.0);
+ addPoint(dpsRuns, r.getRun().getEndDate().getTime(), 1.0);
+ addPoint(dpsRuns, r.getRun().getEndDate().getTime(), 0.0);
+
+ for (SvtBiasMyaRange br : r.getRanges()) {
+ addPoint(dpsBiasRuns, br.getStartDate().getTime(), 0.0);
+ addPoint(dpsBiasRuns, br.getStartDate().getTime(), 0.3);
+ addPoint(dpsBiasRuns, br.getEndDate().getTime(), 0.3);
+ addPoint(dpsBiasRuns, br.getEndDate().getTime(), 0.0);
+ }
+ }
+ }
+ }
+ if (cl.hasOption("p")) {
+ for (SvtPositionRunRange r : positionRunRanges) {
+ logger.info(r.toString());
+ if (r.getRun().getRun() > 5600) {//9999999999999.0) {
+ //if(dpsRuns.size()/4.0<500) {//9999999999999.0) {
+ for (SvtPositionMyaRange br : r.getRanges()) {
+ addPoint(dpsPositionRuns, br.getStartDate().getTime(), 0.0);
+ addPoint(dpsPositionRuns, br.getStartDate().getTime(), 0.5 + 100 * Math.max(br.getTop(), br.getBottom()));
+ addPoint(dpsPositionRuns, br.getEndDate().getTime(), 0.5 + 100 * Math.max(br.getTop(), br.getBottom()));
+ addPoint(dpsPositionRuns, br.getEndDate().getTime(), 0.0);
+ }
+ }
+ }
+ }
+ }
+
+ if (cl.hasOption("b") && cl.hasOption("m") && cl.hasOption("p")) {
+ readBeamData(new File(cl.getOptionValue("b")), runList, positionRunRanges, biasRunRanges);
+ }
+
// load to DB
- if(cl.hasOption("g")) {
- loadToConditionsDB(biasRunRanges);
- }
- }
-
-
+ if (cl.hasOption("g")) {
+ if (cl.hasOption("m")) {
+ loadBiasesToConditionsDB(biasRunRanges);
+ }
+ if (cl.hasOption("p")) {
+ loadPositionsToConditionsDB(positionRunRanges);
+ }
+ }
+ }
private static void printUsage(Options options) {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("Need to adhere to these options", options);
-
- }
-
- private final static SvtBiasConstantCollection findCollection(final List<SvtBiasConstantCollection> list, Date date) {
- for( SvtBiasConstantCollection collection : list) {
- if(collection.find(date) != null) {
- return collection;
- }
- }
- return null;
- }
-
- private static final void loadToConditionsDB(List<SvtBiasRunRange> ranges) {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp("Need to adhere to these options", options);
+
+ }
+
+ private static void loadBiasesToConditionsDB(List<SvtBiasRunRange> ranges) {
logger.info("Load to DB...");
// Create a new collection for each run
@@ -293,6 +298,10 @@
// create a collection
SvtBiasConstantCollection collection = new SvtBiasConstantCollection();
+ // Set the table meta data
+ collection.setTableMetaData(MANAGER.findTableMetaData("svt_bias_constants"));
+ collection.setConnection(MANAGER.getConnection());
+
int collectionId = -1;
try {
collectionId = MANAGER.getCollectionId(collection, "run ranges for SVT HV bias ON");
@@ -305,28 +314,30 @@
final ConditionsRecord condition = new ConditionsRecord();
condition.setFieldValue("run_start", rundata.getRun());
condition.setFieldValue("run_end", rundata.getRun());
- condition.setFieldValue("name", "svt_bias");
+ condition.setFieldValue("name", "svt_bias_constants");
condition.setFieldValue("table_name", "svt_bias_constants");
condition.setFieldValue("notes", "constants from mya");
condition.setFieldValue("created", new Date());
condition.setFieldValue("created_by", System.getProperty("user.name"));
condition.setFieldValue("collection_id", collectionId);
+ condition.setTableMetaData(MANAGER.findTableMetaData("conditions"));
+ condition.setConnection(MANAGER.getConnection());
+ logger.info(condition.toString());
try {
for (SvtBiasMyaRange biasRange : range.getRanges()) {
// create a constant and add to the collection
final SvtBiasConstant constant = new SvtBiasConstant();
- constant.setFieldValue("start", biasRange.getStartDate());
- constant.setFieldValue("end", biasRange.getEndDate());
- constant.setFieldValue("value", biasRange.getStart().getValue());
+ constant.setFieldValue("start", biasRange.getStartDate().getTime());
+ constant.setFieldValue("end", biasRange.getEndDate().getTime());
+ constant.setFieldValue("value", biasRange.getValue());
collection.add(constant);
- logger.info(condition.toString());
}
-
+
// Insert collection data.
collection.insert();
-
+
// Insert conditions record.
condition.insert();
@@ -335,4 +346,170 @@
}
}
}
+
+ private static void loadPositionsToConditionsDB(List<SvtPositionRunRange> ranges) {
+ logger.info("Load to DB...");
+
+ // Create a new collection for each run
+ List<Integer> runsadded = new ArrayList<Integer>();
+
+ for (SvtPositionRunRange range : ranges) {
+ logger.info("Loading " + range.toString());
+ RunData rundata = range.getRun();
+ if (runsadded.contains(rundata.getRun())) {
+ logger.warning("Run " + Integer.toString(rundata.getRun()) + " was already added?");
+ throw new RuntimeException("Run " + Integer.toString(rundata.getRun()) + " was already added?");
+ }
+ runsadded.add(rundata.getRun());
+
+ if (range.getRanges().isEmpty()) {
+ logger.info("No position range for run " + range.getRun().getRun());
+ continue;
+ }
+
+ // create a collection
+ SvtMotorPositionCollection collection = new SvtMotorPositionCollection();
+
+ // Set the table meta data
+ collection.setTableMetaData(MANAGER.findTableMetaData("svt_motor_positions"));
+ collection.setConnection(MANAGER.getConnection());
+
+ int collectionId = -1;
+ try {
+ collectionId = MANAGER.getCollectionId(collection, "run ranges for SVT positions");
+ } catch (SQLException e1) {
+ throw new RuntimeException(e1);
+ }
+
+ collection.setCollectionId(collectionId);
+
+ final ConditionsRecord condition = new ConditionsRecord();
+ condition.setFieldValue("run_start", rundata.getRun());
+ condition.setFieldValue("run_end", rundata.getRun());
+ condition.setFieldValue("name", "svt_motor_positions");
+ condition.setFieldValue("table_name", "svt_motor_positions");
+ condition.setFieldValue("notes", "constants from mya");
+ condition.setFieldValue("created", new Date());
+ condition.setFieldValue("created_by", System.getProperty("user.name"));
+ condition.setFieldValue("collection_id", collectionId);
+ condition.setTableMetaData(MANAGER.findTableMetaData("conditions"));
+ condition.setConnection(MANAGER.getConnection());
+ logger.info(condition.toString());
+
+ try {
+
+ for (SvtPositionMyaRange positionRange : range.getRanges()) {
+ // create a constant and add to the collection
+ final SvtMotorPosition constant = new SvtMotorPosition();
+ constant.setFieldValue("start", positionRange.getStartDate().getTime());
+ constant.setFieldValue("end", positionRange.getEndDate().getTime());
+ constant.setFieldValue("top", positionRange.getTop());
+ constant.setFieldValue("bottom", positionRange.getBottom());
+ collection.add(constant);
+ }
+
+ // Insert collection data.
+ collection.insert();
+
+ // Insert conditions record.
+ condition.insert();
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private static void readBeamData(File file, List<RunData> runList, List<SvtPositionRunRange> positionRanges, List<SvtBiasRunRange> biasRanges) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("America/New_York"));
+
+ Map<Integer, SvtPositionRunRange> positionRangeMap = new HashMap<Integer, SvtPositionRunRange>();
+ for (SvtPositionRunRange range : positionRanges) {
+ positionRangeMap.put(range.getRun().getRun(), range);
+ }
+ Map<Integer, SvtBiasRunRange> biasRangeMap = new HashMap<Integer, SvtBiasRunRange>();
+ for (SvtBiasRunRange range : biasRanges) {
+ biasRangeMap.put(range.getRun().getRun(), range);
+ }
+
+ try {
+ BufferedReader br = new BufferedReader(new FileReader(file));
+ String line;
+ System.out.println("myaData header: " + br.readLine()); //discard the first line
+
+ for (RunData run : runList) {
+ double totalCharge = 0;
+ double totalChargeWithBias = 0;
+ double totalChargeWithBiasAtNominal = 0;
+ double totalChargeWithBiasAt1pt5 = 0;
+ Date lastDate = null;
+
+ while ((line = br.readLine()) != null) {
+ String arr[] = line.split(" +");
+
+ if (arr.length != 3) {
+ throw new java.text.ParseException("this line is not correct.", 0);
+ }
+ Date date = dateFormat.parse(arr[0] + " " + arr[1]);
+ if (date.after(run.getEndDate())) {
+ break;
+ }
+ if (date.before(run.getStartDate())) {
+ continue;
+ }
+
+ double current;
+ if (arr[2].equals("<undefined>")) {
+ current = 0;
+ } else {
+ current = Double.parseDouble(arr[2]);
+ }
+
+ if (date.after(run.getStartDate())) {
+ if (lastDate != null) {
+ double dt = (date.getTime() - lastDate.getTime()) / 1000.0;
+ double dq = dt * current; // nC
+
+ totalCharge += dq;
+ SvtBiasRunRange biasRunRange = biasRangeMap.get(run.getRun());
+ if (biasRunRange != null) {
+ for (SvtBiasMyaRange biasRange : biasRunRange.getRanges()) {
+ if (biasRange.includes(date)) {
+ totalChargeWithBias += dq;
+
+ SvtPositionRunRange positionRunRange = positionRangeMap.get(run.getRun());
+ if (positionRunRange != null) {
+ for (SvtPositionMyaRange positionRange : positionRunRange.getRanges()) {
+ if (positionRange.includes(date)) {
+ if (Math.abs(positionRange.getBottom()) < 0.0001 && Math.abs(positionRange.getTop()) < 0.0001) {
+ totalChargeWithBiasAtNominal += dq;
+ } else if (Math.abs(positionRange.getBottom() - 0.0033) < 0.0001 && Math.abs(positionRange.getTop() - 0.0031) < 0.0001) {
+ totalChargeWithBiasAt1pt5 += dq;
+ }
+ break;
+ }
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+ }
+ }
+ lastDate = date;
+ }
+
+ System.out.format("run\t%d\ttotalQ\t%.0f\ttotalQBias\t%.0f\tfracBias\t%f\ttotalQNom\t%.0f\tfracNom\t%f\ttotalQ1pt5\t%.0f\tfrac1pt5\t%f\n", run.getRun(), totalCharge, totalChargeWithBias, totalChargeWithBias / totalCharge, totalChargeWithBiasAtNominal, totalChargeWithBiasAtNominal / totalCharge, totalChargeWithBiasAt1pt5, totalChargeWithBiasAt1pt5 / totalCharge);
+ }
+ br.close();
+
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } catch (java.text.ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
Modified: java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasConstant.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasConstant.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasConstant.java Thu Aug 20 17:29:01 2015
@@ -13,7 +13,7 @@
*
* Encapsulates an SVT bias constant, which is range in time where bias was ON.
*
- * @author Per Hansson Adrian <[log in to unmask]>
+ * @author Per Hansson Adrian, SLAC
*/
@Table(names = "svt_bias_constants")
@Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED)
@@ -34,7 +34,7 @@
*/
public SvtBiasConstant find(Date date) {
for (SvtBiasConstant constant : this) {
- if(date.after(constant.getStart()) && date.before(constant.getEnd())) {
+ if(date.getTime() >= constant.getStart() && date.getTime() <= constant.getEnd()) {
return constant;
}
}
@@ -44,22 +44,22 @@
/**
- * The start date.
+ * The start date as a Unix timestamp in milliseconds (GMT).
*
- * @return the start date
+ * @return the start date as a Unix timestamp
*/
@Field(names = {"start"})
- public Date getStart() {
+ public Long getStart() {
return getFieldValue("start");
}
/**
- * The end date.
+ * The end date as a Unix timestamp in milliseconds (GMT).
*
- * @return the end date
+ * @return the end date as a Unix timestamp
*/
@Field(names = {"end"})
- public Date getEnd() {
+ public Long getEnd() {
return getFieldValue("end");
}
Modified: java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasMyaDumpReader.java
=============================================================================
--- java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasMyaDumpReader.java (original)
+++ java/branches/conditions-HPSJAVA-517/src/main/java/org/hps/conditions/svt/SvtBiasMyaDumpReader.java Thu Aug 20 17:29:01 2015
@@ -34,13 +34,15 @@
}
- private static final SimpleDateFormat DATE_FORMAT = new RunSpreadsheet.AnotherSimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+// private static final SimpleDateFormat DATE_FORMAT = new RunSpreadsheet.AnotherSimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//private static final TimeZone timeZone = TimeZone.getTimeZone("EST");
public static final double BIASVALUEON = 178.0;
private List<SvtBiasMyaEntry> myaEntries = new ArrayList<SvtBiasMyaEntry>();
private SvtBiasMyaRanges biasRanges = new SvtBiasMyaRanges();
public SvtBiasMyaDumpReader() {
+ DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("America/New_York"));
}
public SvtBiasMyaRanges findOverlappingRanges(Date date_start, Date date_end) {
|