Commit in hps-java/src/main/java/org/lcsim/hps/conditions/svt on MAIN | |||
ChannelConstants.java | +109 | -112 | 1.1 -> 1.2 |
SvtCalibrationConverter.java | +46 | -41 | 1.5 -> 1.6 |
SvtConditions.java | +97 | -95 | 1.1 -> 1.2 |
+252 | -248 |
reformat; no other code changes
diff -u -r1.1 -r1.2 --- ChannelConstants.java 20 Sep 2013 08:52:42 -0000 1.1 +++ ChannelConstants.java 20 Sep 2013 21:55:09 -0000 1.2 @@ -1,121 +1,118 @@
package org.lcsim.hps.conditions.svt;
-
/** * * @author Omar Moreno <[log in to unmask]>
- * @version $Id: ChannelConstants.java,v 1.1 2013/09/20 08:52:42 omoreno Exp $
+ * @version $Id: ChannelConstants.java,v 1.2 2013/09/20 21:55:09 jeremy Exp $
*/ public class ChannelConstants {
- private int fpga = -1; - private int hybrid = -1; - private int channel = -1; - - private double pedestal = Double.NaN; - private double noise = Double.NaN; - private double tp = Double.NaN; - private double t0Shift = Double.NaN; - private double[][] pulseShape = null; - - - /** - * Default Ctor - */ - public ChannelConstants(){ - } - - public ChannelConstants(int fpga, int hybrid, int channel, - double pedestal, double noise, double tp, double t0Shift, double[][] pulseShape){ - this.setFpga(fpga); - this.setHybrid(hybrid); - this.setChannel(channel); - this.setPedestal(pedestal); - this.setNoise(noise); - this.setShapingTime(tp); - this.setT0Shift(t0Shift); - this.setPulseShape(pulseShape); - } - - - //--- Setters ---// - //---------------// - - public void setFpga(int fpga){ - this.fpga = fpga; - } - - public void setHybrid(int hybrid){ - this.hybrid = hybrid; - } - - public void setChannel(int channel){ - this.channel = channel; - } - - public void setNoise(double noise){ - this.noise = noise; - } - - public void setPedestal(double pedestal){ - this.pedestal = pedestal; - } - - public void setShapingTime(double tp){ - this.tp = tp; - } - - public void setT0Shift(double t0Shift){ - this.t0Shift = t0Shift; - } - - public void setPulseShape(double[][] pulseShape){ - this.pulseShape = pulseShape; - } - - //--- Getters ---// - //---------------// - - public int getFpga(){ - return fpga; - } - - public int getHybrid(){ - return hybrid; - } - - public int getChannel(){ - return channel; - } - - public double getNoise(){ - return noise; - } - - public double getPedestal(){ - return pedestal; - } - - public double getShapingTime(){ - return tp; - } - - public double getT0Shift(){ - return t0Shift; - } - - public double[][] getPulseShape(){ - return pulseShape; - } - - @Override - public String toString(){ - StringBuffer buffer = new StringBuffer(); - buffer.append("FPGA: " + this.getFpga() + "\n"); - buffer.append("Hybrid: " + this.getHybrid() + "\n"); - buffer.append("Channel: " + this.getChannel() + "\n"); - buffer.append("Pedestal: " + this.getPedestal() + "\n"); - buffer.append("Noise: " + this.getNoise() + "\n"); - return buffer.toString(); - }
+ private int fpga = -1; + private int hybrid = -1; + private int channel = -1; + + private double pedestal = Double.NaN; + private double noise = Double.NaN; + private double tp = Double.NaN; + private double t0Shift = Double.NaN; + private double[][] pulseShape = null; + + /** + * Default Ctor + */ + public ChannelConstants() { + } + + public ChannelConstants(int fpga, int hybrid, int channel, double pedestal, + double noise, double tp, double t0Shift, double[][] pulseShape) { + this.setFpga(fpga); + this.setHybrid(hybrid); + this.setChannel(channel); + this.setPedestal(pedestal); + this.setNoise(noise); + this.setShapingTime(tp); + this.setT0Shift(t0Shift); + this.setPulseShape(pulseShape); + } + + // --- Setters ---// + // ---------------// + + public void setFpga(int fpga) { + this.fpga = fpga; + } + + public void setHybrid(int hybrid) { + this.hybrid = hybrid; + } + + public void setChannel(int channel) { + this.channel = channel; + } + + public void setNoise(double noise) { + this.noise = noise; + } + + public void setPedestal(double pedestal) { + this.pedestal = pedestal; + } + + public void setShapingTime(double tp) { + this.tp = tp; + } + + public void setT0Shift(double t0Shift) { + this.t0Shift = t0Shift; + } + + public void setPulseShape(double[][] pulseShape) { + this.pulseShape = pulseShape; + } + + // --- Getters ---// + // ---------------// + + public int getFpga() { + return fpga; + } + + public int getHybrid() { + return hybrid; + } + + public int getChannel() { + return channel; + } + + public double getNoise() { + return noise; + } + + public double getPedestal() { + return pedestal; + } + + public double getShapingTime() { + return tp; + } + + public double getT0Shift() { + return t0Shift; + } + + public double[][] getPulseShape() { + return pulseShape; + } + + @Override + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append("FPGA: " + this.getFpga() + "\n"); + buffer.append("Hybrid: " + this.getHybrid() + "\n"); + buffer.append("Channel: " + this.getChannel() + "\n"); + buffer.append("Pedestal: " + this.getPedestal() + "\n"); + buffer.append("Noise: " + this.getNoise() + "\n"); + return buffer.toString(); + }
}
diff -u -r1.5 -r1.6 --- SvtCalibrationConverter.java 20 Sep 2013 08:52:42 -0000 1.5 +++ SvtCalibrationConverter.java 20 Sep 2013 21:55:09 -0000 1.6 @@ -5,64 +5,68 @@
import java.sql.SQLException; import java.sql.Statement;
-import org.lcsim.conditions.ConditionsConverter;
import org.lcsim.conditions.ConditionsManager; import org.lcsim.conditions.ConditionsSet; import org.lcsim.hps.conditions.ConnectionManager;
+import org.lcsim.hps.conditions.DatabaseConditionsConverter;
/** * Read from conditions database and create SVT calibration data. * * @author jeremym
- * @version $Id: SvtCalibrationConverter.java,v 1.5 2013/09/20 08:52:42 omoreno Exp $
+ * @version $Id: SvtCalibrationConverter.java,v 1.6 2013/09/20 21:55:09 jeremy Exp $
*/
-public class SvtCalibrationConverter implements ConditionsConverter<ChannelConstants> { -
+public class SvtCalibrationConverter extends DatabaseConditionsConverter<ChannelConstants> { +
Connection connection = null;
- Statement statement = null; - String database; - ResultSet resultSet = null; - ConditionsSet conditionsSet = null; -
+ Statement statement = null; + String database; + ResultSet resultSet = null; + ConditionsSet conditionsSet = null; +
private boolean hasNext = true;
- private boolean connectionEstablished = false; - - public SvtCalibrationConverter() { - // Connect to the database. - connection = ConnectionManager.createConnection(); - database = ConnectionManager.getConnectionParameters().getDatabase(); - }
+ private boolean connectionEstablished = false; + + public SvtCalibrationConverter() { + // Connect to the database. + connection = ConnectionManager.createConnection(); + database = ConnectionManager.getConnectionParameters().getDatabase(); + }
public ChannelConstants getData(ConditionsManager manager, String name) {
- ChannelConstants constants = null;
+ ChannelConstants constants = null;
try {
- if(!connectionEstablished){ - conditionsSet = manager.getConditions(name); - - String query = "SELECT fpga, hybrid, channel, noise, pedestal FROM " - + database + "." - + conditionsSet.getString("table") + " WHERE " - + conditionsSet.getString("column") + " = " - + conditionsSet.getString("id"); - - statement = connection.createStatement(); - resultSet = statement.executeQuery(query); - hasNext = resultSet.next(); - } -
+ if (!connectionEstablished) { + + conditionsSet = manager.getConditions(name); + + String query = "SELECT fpga, hybrid, channel, noise, pedestal FROM " + + database + + "." + + conditionsSet.getString("table") + + " WHERE " + + conditionsSet.getString("column") + + " = " + + conditionsSet.getString("id"); + + statement = connection.createStatement(); + resultSet = statement.executeQuery(query); + hasNext = resultSet.next(); + } +
int fpga = resultSet.getInt(1); int hybrid = resultSet.getInt(2); int channel = resultSet.getInt(3); double noise = resultSet.getDouble(4); double pedestal = resultSet.getDouble(5);
- - constants - = new ChannelConstants(fpga, hybrid, channel, pedestal, noise, - Double.NaN, Double.NaN, null); - resultSet.next(); -
+ + constants = new ChannelConstants(fpga, hybrid, channel, pedestal, + noise, Double.NaN, Double.NaN, null); + + resultSet.next(); +
} catch (SQLException x) { if (statement != null) { try {
@@ -83,13 +87,14 @@
/** * Get the type handled by this converter.
+ *
* @return The type handled by this converter. */ public Class<ChannelConstants> getType() { return ChannelConstants.class; }
- - public boolean hasNext() { - return hasNext; - }
+ + public boolean hasNext() { + return hasNext; + }
}
diff -u -r1.1 -r1.2 --- SvtConditions.java 20 Sep 2013 08:52:42 -0000 1.1 +++ SvtConditions.java 20 Sep 2013 21:55:09 -0000 1.2 @@ -1,7 +1,7 @@
package org.lcsim.hps.conditions.svt; import java.util.HashMap;
-import java.util.Map;
+import java.util.Map;
import java.util.List; import org.lcsim.conditions.ConditionsConverter;
@@ -14,100 +14,102 @@
/** * * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtConditions.java,v 1.1 2013/09/20 08:52:42 omoreno Exp $
+ * @version $Id: SvtConditions.java,v 1.2 2013/09/20 21:55:09 jeremy Exp $
*/ public class SvtConditions {
- - private static Map<SiSensor, double[]> noiseMap = new HashMap<SiSensor, double[]>(); - private static Map<SiSensor, double[]> pedestalMap = new HashMap<SiSensor, double[]>(); - private static Map<SiSensor, double[]> tpMap = new HashMap<SiSensor, double[]>(); - private static Map<SiSensor, Double> t0ShiftMap = new HashMap<SiSensor, Double>(); - - /** - * Ctor - */ - private SvtConditions(){ - } - - public static void loadSvtConditions(ConditionsConverter<ChannelConstants> converter){ - - ConditionsManager conditionsManager = ConditionsManager.defaultInstance(); - - SvtCalibrationConverter calibrationsConverter = new SvtCalibrationConverter(); - ChannelConstants channelConstants; - - - while(calibrationsConverter.hasNext()){ - - channelConstants = calibrationsConverter.getData(conditionsManager, "svt_calibrations"); - - int fpga = channelConstants.getFpga(); - int hybrid = channelConstants.getHybrid(); - int channel = channelConstants.getChannel(); - - Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(fpga, hybrid); - SiSensor sensor = SvtUtils.getInstance().getSensor(daqPair); - - if(noiseMap.get(sensor) == null) noiseMap.put(sensor, new double[640]); - if(pedestalMap.get(sensor) == null) pedestalMap.put(sensor, new double[640]); - if(tpMap.get(sensor) == null) tpMap.put(sensor, new double[640]); - - noiseMap.get(sensor)[channel] = channelConstants.getNoise(); - pedestalMap.get(sensor)[channel] = channelConstants.getPedestal(); - tpMap.get(sensor)[channel] = channelConstants.getShapingTime(); - - } - } - - - /** - * - * Get the noise for a given channel on a sensor. - * - * @param sensor - * @param channel - * @return noise - */ - public static Double getNoise(SiSensor sensor, int channel){ - double[] noise = noiseMap.get(sensor); - if(noise == null || channel < 0 || channel > 640){ - return null; - } else { - return noise[channel]; - } - } - - /** - * - * Get the pedestal for a given channel on a sensor. - * - * @param sensor - * @param channel - * @return pedestal - */ - public static Double getPedestal(SiSensor sensor, int channel){ - double[] pedestal = pedestalMap.get(sensor); - if(pedestal == null || channel < 0 || channel > 640){ - return null; - } else { - return pedestal[channel]; - } - } - - /** - * - * Get the shaping time for a given channel on a sensor - * - * @param sensor - * @param channel - * @return shaping time - */ - public static Double getShapingTime(SiSensor sensor, int channel){ - double[] tp = tpMap.get(sensor); - if(tp == null || channel < 0 || channel > 640){ - return null; - } else { - return tp[channel]; - } - }
+ + private static Map<SiSensor, double[]> noiseMap = new HashMap<SiSensor, double[]>(); + private static Map<SiSensor, double[]> pedestalMap = new HashMap<SiSensor, double[]>(); + private static Map<SiSensor, double[]> tpMap = new HashMap<SiSensor, double[]>(); + private static Map<SiSensor, Double> t0ShiftMap = new HashMap<SiSensor, Double>(); + + /** + * Ctor + */ + private SvtConditions() { + } + + public static void loadSvtConditions(ConditionsConverter<ChannelConstants> converter) { + + ConditionsManager conditionsManager = ConditionsManager.defaultInstance(); + + SvtCalibrationConverter calibrationsConverter = new SvtCalibrationConverter(); + ChannelConstants channelConstants; + + while (calibrationsConverter.hasNext()) { + + channelConstants = calibrationsConverter.getData(conditionsManager, "svt_calibrations"); + + int fpga = channelConstants.getFpga(); + int hybrid = channelConstants.getHybrid(); + int channel = channelConstants.getChannel(); + + Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(fpga, + hybrid); + SiSensor sensor = SvtUtils.getInstance().getSensor(daqPair); + + if (noiseMap.get(sensor) == null) + noiseMap.put(sensor, new double[640]); + if (pedestalMap.get(sensor) == null) + pedestalMap.put(sensor, new double[640]); + if (tpMap.get(sensor) == null) + tpMap.put(sensor, new double[640]); + + noiseMap.get(sensor)[channel] = channelConstants.getNoise(); + pedestalMap.get(sensor)[channel] = channelConstants.getPedestal(); + tpMap.get(sensor)[channel] = channelConstants.getShapingTime(); + + } + } + + /** + * + * Get the noise for a given channel on a sensor. + * + * @param sensor + * @param channel + * @return noise + */ + public static Double getNoise(SiSensor sensor, int channel) { + double[] noise = noiseMap.get(sensor); + if (noise == null || channel < 0 || channel > 640) { + return null; + } else { + return noise[channel]; + } + } + + /** + * + * Get the pedestal for a given channel on a sensor. + * + * @param sensor + * @param channel + * @return pedestal + */ + public static Double getPedestal(SiSensor sensor, int channel) { + double[] pedestal = pedestalMap.get(sensor); + if (pedestal == null || channel < 0 || channel > 640) { + return null; + } else { + return pedestal[channel]; + } + } + + /** + * + * Get the shaping time for a given channel on a sensor + * + * @param sensor + * @param channel + * @return shaping time + */ + public static Double getShapingTime(SiSensor sensor, int channel) { + double[] tp = tpMap.get(sensor); + if (tp == null || channel < 0 || channel > 640) { + return null; + } else { + return tp[channel]; + } + }
}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1