Author: omoreno
Date: Mon Oct 27 11:57:19 2014
New Revision: 1318
Log:
Add a class to encapsulate all test run SVT conditions along with a test run SVT conditions converter. Also add a class describing a test run SVT sensor channel.
Added:
java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtChannel.java (with props)
java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditions.java (with props)
java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java (with props)
Added: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtChannel.java
=============================================================================
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtChannel.java (added)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtChannel.java Mon Oct 27 11:57:19 2014
@@ -0,0 +1,74 @@
+package org.hps.conditions.svt;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.hps.util.Pair;
+
+public final class TestRunSvtChannel extends AbstractSvtChannel {
+
+ public static class TestRunSvtChannelCollection
+ extends AbstractSvtChannel.AbstractSvtChannelCollection<TestRunSvtChannel> {
+
+ @Override
+ public Collection<TestRunSvtChannel> find(Pair<Integer, Integer> pair) {
+ List<TestRunSvtChannel> channels = new ArrayList<TestRunSvtChannel>();
+ int fpga = pair.getFirstElement();
+ int hybrid = pair.getSecondElement();
+ for(TestRunSvtChannel channel : this.getObjects()){
+ if(channel.getFpgaID() == fpga && channel.getHybridID() == hybrid){
+ channels.add(channel);
+ }
+ }
+ return channels;
+ }
+ }
+
+ /**
+ * Get the FPGA ID.
+ *
+ * @return The FPGA ID
+ */
+ public int getFpgaID(){
+ return getFieldValue("fpga");
+ }
+
+ /**
+ * Get the hybrid ID.
+ *
+ * @return The hybrid ID.
+ */
+ public int getHybridID(){
+ return getFieldValue("hybrid");
+ }
+
+ /**
+ * Convert this object to a human readable string.
+ * @return This object as a string.
+ */
+ public String toString() {
+ return "channel_id: " + getChannelID() +
+ ", fpga: " + getFpgaID() +
+ ", hybrid: " + getHybridID() +
+ ", channel: " + getChannel();
+ }
+
+ /**
+ * Implementation of equals.
+ * @return True if the object equals this one; false if not.
+ */
+ public boolean equals(Object o) {
+ if (o == null)
+ return false;
+ if (!(o instanceof TestRunSvtChannel))
+ return false;
+ if (o == this)
+ return true;
+ TestRunSvtChannel channel = (TestRunSvtChannel) o;
+ return getChannelID() == channel.getChannelID()
+ && getFpgaID() == channel.getFpgaID()
+ && getHybridID() == channel.getHybridID()
+ && getChannel() == channel.getChannel();
+ }
+}
Added: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditions.java
=============================================================================
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditions.java (added)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditions.java Mon Oct 27 11:57:19 2014
@@ -0,0 +1,168 @@
+package org.hps.conditions.svt;
+
+import org.hps.conditions.svt.TestRunSvtChannel.TestRunSvtChannelCollection;
+import org.hps.conditions.svt.TestRunSvtDaqMapping.TestRunSvtDaqMappingCollection;
+
+// TODO: Move all constants to their own class
+import static org.hps.conditions.svt.SvtChannel.MAX_NUMBER_OF_SAMPLES;
+
+/**
+ * This class contains all test run SVT conditions data by readout channel. {@link SvtChannel}
+ * objects from the {@linkSvtChannelMap} should be used to lookup the conditions using the
+ * {@link #getChannelConstants(SvtChannel)} method.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @author Omar Moreno <[log in to unmask]>
+ */
+public class TestRunSvtConditions extends AbstractSvtConditions {
+
+ protected TestRunSvtDaqMappingCollection daqMap = null;
+
+ /**
+ * Get the {@link TestRunSvtDaqMappingCollection} associated with these conditions.
+ *
+ * @return The SVT DAQ map.
+ */
+ @Override
+ public TestRunSvtDaqMappingCollection getDaqMap() {
+ return daqMap;
+ }
+
+ @Override
+ public TestRunSvtChannelCollection getChannelMap() {
+ return (TestRunSvtChannelCollection) channelMap;
+ }
+
+ /**
+ * Set the {@link TestRunSvtDaqMappingCollection} associated with these conditions.
+ *
+ * @param daqMap The SVT DAQ map.
+ * @return
+ */
+ public void setDaqMap(TestRunSvtDaqMappingCollection daqMap) {
+ this.daqMap = daqMap;
+ }
+
+ /**
+ * Set the channel map of type {@link TestRunSvtChannelCollection}.
+ *
+ * @param channelMap The SVT channel map.
+ */
+ public void setChannelMap(TestRunSvtChannelCollection channelMap){
+ this.channelMap = channelMap;
+ }
+
+ /**
+ * Convert this object to a human readable string. This method prints a formatted
+ * table of channel data independently of how its member objects implement their
+ * string conversion method. For now, it does not print the time shifts by sensor as
+ * all other information is by channel.
+ *
+ * @return This object converted to a string, without the DAQ map.
+ * TODO: Make this look more human readable. At the moment, reading this
+ * requires a huge terminal window.
+ */
+ public String toString() {
+ StringBuffer buff = new StringBuffer();
+
+ buff.append('\n');
+ buff.append("Printing SVTConditions ...");
+ buff.append('\n');
+ buff.append('\n');
+
+ // Table header:
+ buff.append("Channel ID");
+ buff.append(" ");
+ buff.append("FPGA ID");
+ buff.append(" ");
+ buff.append("Hybrid ID");
+ buff.append(" ");
+ buff.append("Channel");
+ buff.append(" ");
+ buff.append("Pedestal sample 0");
+ buff.append(" ");
+ buff.append("Pedestal sample 1");
+ buff.append(" ");
+ buff.append("Pedestal sample 2");
+ buff.append(" ");
+ buff.append("Pedestal sample 3");
+ buff.append(" ");
+ buff.append("Pedestal sample 4");
+ buff.append(" ");
+ buff.append("Pedestal sample 5");
+ buff.append(" ");
+ buff.append("Noise sample 0");
+ buff.append(" ");
+ buff.append("Noise sample 1");
+ buff.append(" ");
+ buff.append("Noise sample 2");
+ buff.append(" ");
+ buff.append("Noise sample 3");
+ buff.append(" ");
+ buff.append("Noise sample 4");
+ buff.append(" ");
+ buff.append("Noise sample 5");
+ buff.append(" ");
+ buff.append("Gain");
+ buff.append(" ");
+ buff.append("Offset");
+ buff.append(" ");
+ buff.append("Amplitude");
+ buff.append(" ");
+ buff.append("t0");
+ buff.append(" ");
+ buff.append("tp");
+ buff.append(" ");
+ buff.append("Bad Channels");
+ buff.append('\n');
+ for (int i = 0; i < 115; i++) {
+ buff.append("-");
+ }
+ buff.append('\n');
+ // Loop over channels.
+ for (TestRunSvtChannel channel : this.getChannelMap().getObjects()) {
+
+ System.out.println("Channel: " + channel.toString());
+
+ // Get the conditions for the channel.
+ ChannelConstants constants = getChannelConstants(channel);
+ SvtGain gain = constants.getGain();
+ SvtShapeFitParameters shapeFit = constants.getShapeFitParameters();
+ SvtCalibration calibration = constants.getCalibration();
+
+ // Channel data.
+ buff.append(String.format("%-6d %-5d %-8d %-8d ", channel.getChannelID(), channel.getFpgaID(), channel.getHybridID(), channel.getChannel()));
+
+ // Calibration.
+ for(int sample = 0; sample < MAX_NUMBER_OF_SAMPLES; sample++){
+ buff.append(calibration.getPedestal(sample));
+ buff.append(" ");
+ }
+ for(int sample = 0; sample < MAX_NUMBER_OF_SAMPLES; sample++){
+ buff.append(calibration.getNoise(sample));
+ buff.append(" ");
+ }
+
+ // Gain.
+ buff.append(String.format("%-6.4f %-9.4f ", gain.getGain(), gain.getOffset()));
+
+ // Pulse shape.
+ buff.append(String.format("%-10.4f %-8.4f %-8.4f", shapeFit.getAmplitude(), shapeFit.getT0(), shapeFit.getTp()));
+
+ // Bad channel.
+ buff.append(constants.isBadChannel());
+
+ buff.append('\n');
+ }
+
+ buff.append('\n');
+ buff.append("Printing SVT DAQ Map...");
+ buff.append('\n');
+ buff.append('\n');
+ buff.append(getDaqMap());
+
+ return buff.toString();
+ }
+
+
+}
Added: java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java
=============================================================================
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java (added)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java Mon Oct 27 11:57:19 2014
@@ -0,0 +1,52 @@
+package org.hps.conditions.svt;
+
+import org.lcsim.conditions.ConditionsManager;
+import org.hps.conditions.DatabaseConditionsManager;
+import org.hps.conditions.svt.TestRunSvtChannel.TestRunSvtChannelCollection;
+import org.hps.conditions.svt.TestRunSvtDaqMapping.TestRunSvtDaqMappingCollection;
+
+public final class TestRunSvtConditionsConverter extends AbstractSvtConditionsConverter<TestRunSvtConditions> {
+
+
+ public TestRunSvtConditionsConverter(){
+ this.conditions = new TestRunSvtConditions();
+ }
+
+ /**
+ * Create and return an {@link TestRunSvtConditions} object
+ *
+ * @param manager The current conditions manager.
+ * @param name The conditions key, which is ignored for now.
+ */
+ @Override
+ public TestRunSvtConditions getData(ConditionsManager manager, String name){
+
+ DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager;
+
+ // Get the channel map from the conditions database
+ TestRunSvtChannelCollection channels = this.getCollection(TestRunSvtChannelCollection.class, dbConditionsManager);
+
+ //System.out.println("Test run channels: " + channels.toString());
+
+ // Create the SVT conditions object to use to encapsulate SVT condition collections
+ conditions.setChannelMap(channels);
+
+ // Get the DAQ map from the conditions database
+ TestRunSvtDaqMappingCollection daqMap = this.getCollection(TestRunSvtDaqMappingCollection.class, dbConditionsManager);
+ conditions.setDaqMap(daqMap);
+
+ conditions = super.getData(manager, name);
+
+ return conditions;
+ }
+
+
+ /**
+ * Get the type handled by this converter.
+ * @return The type handled by this converter.
+ */
+ @Override
+ public Class<TestRunSvtConditions> getType() {
+ return TestRunSvtConditions.class;
+ }
+}
|