Author: [log in to unmask] Date: Thu Apr 9 19:20:38 2015 New Revision: 2670 Log: Some javadoc fix up. Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/DaqMapHandler.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsReader.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java Thu Apr 9 19:20:38 2015 @@ -14,33 +14,13 @@ public abstract class AbstractSvtDaqMapping extends BaseConditionsObject { /** - * Flag value for top half. - */ - public static final String TOP_HALF = "T"; - - /** - * Flag value for bottom half. - */ - public static final String BOTTOM_HALF = "B"; - - /** - * Flag value for axial sensor. - */ - public static final String AXIAL = "A"; - - /** - * Flag value for stereo sensor. - */ - public static final String STEREO = "S"; - - /** * The collection implementation for {@link AbstractSvtDaqMapping}. * * @param <T> the type of the object in the collection which must extend {@link AbstractSvtDaqMapping} */ @SuppressWarnings("serial") public static abstract class AbstractSvtDaqMappingCollection<T extends AbstractSvtDaqMapping> extends - BaseConditionsObjectCollection<T> { + BaseConditionsObjectCollection<T> { /** * Get a DAQ pair for the given {@link HpsSiSensor}. @@ -62,14 +42,24 @@ } /** - * Get the SVT half (TOP or BOTTOM) that the sensor belongs to. - * - * @return SVT half (TOP or BOTTOM) + * Flag value for axial sensor. */ - @Field(names = { "svt_half" }) - public final String getSvtHalf() { - return getFieldValue("svt_half"); - } + public static final String AXIAL = "A"; + + /** + * Flag value for bottom half. + */ + public static final String BOTTOM_HALF = "B"; + + /** + * Flag value for stereo sensor. + */ + public static final String STEREO = "S"; + + /** + * Flag value for top half. + */ + public static final String TOP_HALF = "T"; /** * Get the SVT sensor layer number (1-10 for test run and 1-12 for engineering run). @@ -83,8 +73,9 @@ /** * Get the orientation of an SVT sensor (AXIAL or STEREO). - * @see {@link #AXIAL} - * @see {@link #STEREO} + * + * @see AXIAL + * @see STEREO * @return the orientation of the SVT sensor */ @Field(names = { "orientation" }) @@ -93,18 +84,13 @@ } /** - * Set the SVT half that the sensor belongs to. + * Get the SVT half (TOP or BOTTOM) that the sensor belongs to. * - * @param svtHalf the SVT half (TOP or BOTTOM) - * @see {@link #TOP_HALF} - * @see {@link #BOTTOM_HALF} + * @return SVT half (TOP or BOTTOM) */ - public final void setSvtHalf(final String svtHalf) { - if (!svtHalf.equals(AbstractSvtDaqMapping.TOP_HALF) && !svtHalf.equals(AbstractSvtDaqMapping.BOTTOM_HALF)) { - throw new RuntimeException("[ " + this.getClass().getSimpleName() + " ]: Invalid value of SVT half."); - } - this.setFieldValue("svt_half", svtHalf); - + @Field(names = { "svt_half" }) + public final String getSvtHalf() { + return getFieldValue("svt_half"); } /** @@ -127,4 +113,19 @@ } this.setFieldValue("orientation", orientation); } + + /** + * Set the SVT half that the sensor belongs to. + * + * @param svtHalf the SVT half (TOP or BOTTOM) + * @see TOP_HALF + * @see BOTTOM_HALF + */ + public final void setSvtHalf(final String svtHalf) { + if (!svtHalf.equals(AbstractSvtDaqMapping.TOP_HALF) && !svtHalf.equals(AbstractSvtDaqMapping.BOTTOM_HALF)) { + throw new RuntimeException("[ " + this.getClass().getSimpleName() + " ]: Invalid value of SVT half."); + } + this.setFieldValue("svt_half", svtHalf); + + } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/DaqMapHandler.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/DaqMapHandler.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/DaqMapHandler.java Thu Apr 9 19:20:38 2015 @@ -20,21 +20,6 @@ private static final int CHANNELS_MAX = 640; /** - * The collection of DAQ map objects. - */ - private SvtDaqMappingCollection daqMap = new SvtDaqMappingCollection(); - - /** - * The Collection of SVT channel objects. - */ - private SvtChannelCollection svtChannels = new SvtChannelCollection(); - - /** - * An SVT DAQ map object. - */ - private SvtDaqMapping daqMapping = null; - - /** * Text node inside of an XML element. */ private String content; @@ -43,6 +28,16 @@ * Current SVT channel ID. This gets incremented every time an SvtChannel gets added to the map. */ private int currentSvtChannelID = 0; + + /** + * The collection of DAQ map objects. + */ + private final SvtDaqMappingCollection daqMap = new SvtDaqMappingCollection(); + + /** + * An SVT DAQ map object. + */ + private SvtDaqMapping daqMapping = null; /** * FEB ID (0-9). @@ -55,81 +50,14 @@ private int hybridID = 0; /** + * The Collection of SVT channel objects. + */ + private final SvtChannelCollection svtChannels = new SvtChannelCollection(); + + /** * Default constructor. */ public DaqMapHandler() { - } - - /** - * Method that is triggered when the start tag is encountered. - * - * @param uri the Namespace URI - * @param locaName the local name (without prefix) - * @param qName the qualified name (with prefix) - * @param attributes the attributes attached to the element - * @throws SAXException if there is an error processing the element - */ - @Override - public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) - throws SAXException { - - switch (qName) { - case "Feb": - febID = Integer.parseInt(attributes.getValue("id")); - break; - case "Hybrid": - hybridID = Integer.parseInt(attributes.getValue("id")); - daqMapping = new SvtDaqMapping(febID, hybridID); - break; - default: - break; - } - } - - /** - * Method that is triggered when the end of a tag is encountered. - * - * @param uri the Namespace URI. - * @param locaName the local name (without prefix) - * @param qName the qualified name (with prefix) - * @throws SAXException if there is an error processing the element - */ - @Override - public void endElement(final String uri, final String localName, final String qName) throws SAXException { - - switch (qName) { - case "Hybrid": - daqMap.add(daqMapping); - this.addSvtChannels(febID, hybridID); - break; - case "Half": - daqMapping.setSvtHalf(content); - break; - case "Layer": - daqMapping.setLayerNumber(Integer.parseInt(content)); - break; - case "Side": - daqMapping.setSide(content); - break; - case "Orientation": - daqMapping.setOrientation(content); - break; - default: - break; - } - } - - /** - * Method called to extract character data inside of an element. - * - * @param ch the characters - * @param start the start position in the character array - * @param length the number of characters to use from the character array - * @throws SAXException if there is an error processing the element - */ - @Override - public void characters(final char[] ch, final int start, final int length) throws SAXException { - content = String.copyValueOf(ch, start, length).trim(); } /** @@ -147,12 +75,58 @@ } /** + * Method called to extract character data inside of an element. + * + * @param ch the characters + * @param start the start position in the character array + * @param length the number of characters to use from the character array + * @throws SAXException if there is an error processing the element + */ + @Override + public void characters(final char[] ch, final int start, final int length) throws SAXException { + this.content = String.copyValueOf(ch, start, length).trim(); + } + + /** + * Method that is triggered when the end of a tag is encountered. + * + * @param uri the Namespace URI. + * @param locaName the local name (without prefix) + * @param qName the qualified name (with prefix) + * @throws SAXException if there is an error processing the element + */ + @Override + public void endElement(final String uri, final String localName, final String qName) throws SAXException { + + switch (qName) { + case "Hybrid": + this.daqMap.add(this.daqMapping); + this.addSvtChannels(this.febID, this.hybridID); + break; + case "Half": + this.daqMapping.setSvtHalf(this.content); + break; + case "Layer": + this.daqMapping.setLayerNumber(Integer.parseInt(this.content)); + break; + case "Side": + this.daqMapping.setSide(this.content); + break; + case "Orientation": + this.daqMapping.setOrientation(this.content); + break; + default: + break; + } + } + + /** * Get the {@link SvtDaqMappingCollection} built from parsing the XML input file. * * @return the {@link SvtDaqMappingCollection} from parsing the XML */ public SvtDaqMappingCollection getDaqMap() { - return daqMap; + return this.daqMap; } /** @@ -161,7 +135,33 @@ * @return the {@link SvtChannelCollection} from parsing the XML */ public SvtChannelCollection getSvtChannels() { - return svtChannels; + return this.svtChannels; + } + + /** + * Method that is triggered when the start tag is encountered. + * + * @param uri the Namespace URI + * @param localName the local name (without prefix) + * @param qName the qualified name (with prefix) + * @param attributes the attributes attached to the element + * @throws SAXException if there is an error processing the element + */ + @Override + public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) + throws SAXException { + + switch (qName) { + case "Feb": + this.febID = Integer.parseInt(attributes.getValue("id")); + break; + case "Hybrid": + this.hybridID = Integer.parseInt(attributes.getValue("id")); + this.daqMapping = new SvtDaqMapping(this.febID, this.hybridID); + break; + default: + break; + } } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java Thu Apr 9 19:20:38 2015 @@ -8,10 +8,11 @@ import org.hps.conditions.database.Table; /** - * Encapsulates an SVT alignment constant, which is an encoded, string key with a double value - * representing the translation or rotation of a detector component. + * Encapsulates an SVT alignment constant, which is an encoded, string key with a double value representing the + * translation or rotation of a detector component. * <p> * The format of the keys is ABCDE where:<br> + * * <pre> * A == half == [1,2] * B == alignment type == [1,2] @@ -19,8 +20,7 @@ * DE == module number == [01-10] * </pre> * <p> - * The key naming conventions are from the - * <a href="http://www.desy.de/~blobel/mptalks.html">Millipede</a> package. + * The key naming conventions are from the <a href="http://www.desy.de/~blobel/mptalks.html">Millipede</a> package. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @@ -29,46 +29,6 @@ public final class SvtAlignmentConstant extends BaseConditionsObject { /** - * Collection implementation for {@link SvtAlignmentConstant}. - */ - @SuppressWarnings("serial") - public static class SvtAlignmentConstantCollection extends BaseConditionsObjectCollection<SvtAlignmentConstant> { - } - - /** - * Top or bottom half. - */ - public enum Half { - /** Top half. */ - TOP(1), - /** Bottom half. */ - BOTTOM(2); - - /** - * The integer value designating top or bottom half. - */ - private int value; - - /** - * Create from top or bottom value. - * - * @param value the value for half - */ - private Half(final int value) { - this.value = value; - } - - /** - * Get the value. - * - * @return the value - */ - int getValue() { - return value; - } - }; - - /** * The alignment constant type which is rotation or translation. */ public enum AlignmentType { @@ -80,10 +40,11 @@ /** * The value of the alignment type constants. */ - private int value; + private final int value; /** * Constructor that has value of constant. + * * @param value the value of the constant */ private AlignmentType(final int value) { @@ -91,12 +52,53 @@ } /** - * Get the value of the constant. + * Get the value for the alignment constant type. + * * @return the value of the constant */ int getValue() { - return value; - } + return this.value; + } + } + + /** + * Top or bottom half. + */ + public enum Half { + /** Bottom half. */ + BOTTOM(2), + /** Top half. */ + TOP(1); + + /** + * The integer value designating top or bottom half. + */ + private final int value; + + /** + * Create from top or bottom value. + * + * @param value the value for half + */ + private Half(final int value) { + this.value = value; + } + + /** + * Get the value for the half. + * + * @return the value + */ + int getValue() { + return this.value; + } + }; + + /** + * Collection implementation for {@link SvtAlignmentConstant}. + */ + @SuppressWarnings("serial") + public static class SvtAlignmentConstantCollection extends BaseConditionsObjectCollection<SvtAlignmentConstant> { }; /** @@ -113,7 +115,7 @@ /** * Value for the constant. */ - private int value; + private final int value; /** * Create from value. @@ -125,12 +127,12 @@ } /** - * Get the value + * Get the value for the unit axis. * * @return the value */ int getValue() { - return value; + return this.value; } }; @@ -140,30 +142,27 @@ private static final int MAX_MODULE_NUMBER = 10; /** - * Get the alignment constant's encoded, raw value. - * - * @return the alignment constant's key - */ - @Field(names = { "parameter" }) - public String getParameter() { - return getFieldValue("parameter"); - } - - /** - * Get the the alignment constant's value, which is always a single double. - * - * @return the alignment constant's value as a double - */ - @Field(names = { "value" }) - public double getValue() { - return getFieldValue("value"); + * Decode the AlignmentType value from the key. + * + * @return the AlignmentType value from the key + * @see AlignmentType + */ + public AlignmentType getAlignmentType() { + final int alignmentType = Integer.parseInt(getParameter().substring(1, 2)); + if (alignmentType == AlignmentType.TRANSLATION.getValue()) { + return AlignmentType.TRANSLATION; + } else if (alignmentType == AlignmentType.ROTATION.getValue()) { + return AlignmentType.ROTATION; + } else { + throw new IllegalArgumentException("Could not parse valid AlignmentType from " + getParameter()); + } } /** * Decode the Half value from the key. - * + * * @return the Half value from the key - * @see {@link SvtAlignmentConstant#Half} + * @see Half */ public Half getHalf() { final int half = Integer.parseInt(getParameter().substring(0, 1)); @@ -177,27 +176,33 @@ } /** - * Decode the AlignmentType value from the key. - * - * @return the AlignmentType value from the key - * @see {@link SvtAlignmentConstant#AlignmentType} - */ - public AlignmentType getAlignmentType() { - final int alignmentType = Integer.parseInt(getParameter().substring(1, 2)); - if (alignmentType == AlignmentType.TRANSLATION.getValue()) { - return AlignmentType.TRANSLATION; - } else if (alignmentType == AlignmentType.ROTATION.getValue()) { - return AlignmentType.ROTATION; - } else { - throw new IllegalArgumentException("Could not parse valid AlignmentType from " + getParameter()); - } + * Decode the module number from the key. + * + * @return the module number from the key + */ + public int getModuleNumber() { + final int moduleNumber = Integer.parseInt(getParameter().substring(3, 5)); + if (moduleNumber > MAX_MODULE_NUMBER || moduleNumber == 0) { + throw new IllegalArgumentException("The decoded module number " + moduleNumber + " is invalid."); + } + return moduleNumber; + } + + /** + * Get the alignment constant's encoded, raw value. + * + * @return the alignment constant's key + */ + @Field(names = { "parameter" }) + public String getParameter() { + return getFieldValue("parameter"); } /** * Decode the UnitAxis from the key. * * @return the UnitAxis v - * @see {@link SvtAlignmentConstant#UnitAxis} + * @see UnitAxis */ public UnitAxis getUnitAxis() { final int unitAxis = Integer.parseInt(getParameter().substring(2, 3)); @@ -213,16 +218,13 @@ } /** - * Decode the module number from the key. - * - * @return the module number from the key - */ - public int getModuleNumber() { - final int moduleNumber = Integer.parseInt(getParameter().substring(3, 5)); - if (moduleNumber > MAX_MODULE_NUMBER || moduleNumber == 0) { - throw new IllegalArgumentException("The decoded module number " + moduleNumber + " is invalid."); - } - return moduleNumber; + * Get the the alignment constant's value, which is always a single double. + * + * @return the alignment constant's value as a double + */ + @Field(names = { "value" }) + public double getValue() { + return getFieldValue("value"); } /** Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java Thu Apr 9 19:20:38 2015 @@ -1,23 +1,31 @@ package org.hps.conditions.svt; + +import static org.hps.conditions.svt.AbstractSvtChannel.MAX_NUMBER_OF_SAMPLES; import org.hps.conditions.svt.SvtChannel.SvtChannelCollection; import org.hps.conditions.svt.SvtDaqMapping.SvtDaqMappingCollection; - import org.hps.conditions.svt.SvtT0Shift.SvtT0ShiftCollection; // 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 SVT channel map should be used to lookup - * the conditions using the {@link #getChannelConstants(SvtChannel)} method. + * This class contains all test run SVT conditions data by readout channel. {@link SvtChannel} objects from the SVT + * channel map can be used to lookup the conditions for individual channels. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ public final class SvtConditions extends AbstractSvtConditions { + + /** + * Get the {@link SvtChannelCollection} for this set of conditions. + * + * @return The SVT channel map. + */ + @Override + public SvtChannelCollection getChannelMap() { + return (SvtChannelCollection) this.channelMap; + } /** * Get the {@link SvtDaqMappingCollection} associated with these conditions. @@ -26,17 +34,7 @@ */ @Override public SvtDaqMappingCollection getDaqMap() { - return (SvtDaqMappingCollection) daqMap; - } - - /** - * Get the {@link SvtChannelCollection} for this set of conditions. - * - * @return The SVT channel map. - */ - @Override - public SvtChannelCollection getChannelMap() { - return (SvtChannelCollection) channelMap; + return (SvtDaqMappingCollection) this.daqMap; } /** @@ -46,18 +44,18 @@ */ @Override public SvtT0ShiftCollection getT0Shifts() { - return (SvtT0ShiftCollection) t0Shifts; + return (SvtT0ShiftCollection) this.t0Shifts; } /** - * 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 + * 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 */ // FIXME: Make this look more human readable. At the moment, reading this requires a huge terminal window. + @Override public String toString() { final StringBuffer buff = new StringBuffer(); @@ -116,7 +114,7 @@ } buff.append('\n'); // Loop over channels. - for (SvtChannel channel : this.getChannelMap()) { + for (final SvtChannel channel : this.getChannelMap()) { // Get the conditions for the channel. final ChannelConstants constants = getChannelConstants(channel); @@ -142,8 +140,8 @@ 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())); + buff.append(String.format("%-10.4f %-8.4f %-8.4f", shapeFit.getAmplitude(), shapeFit.getT0(), + shapeFit.getTp())); // Bad channel. buff.append(constants.isBadChannel()); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsReader.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsReader.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsReader.java Thu Apr 9 19:20:38 2015 @@ -17,14 +17,9 @@ public final class SvtConditionsReader { /** - * SAX parser factory. + * SAX handler for calibration elements. */ - private SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - - /** - * SAX parser. - */ - private SAXParser parser; + private CalibrationHandler calibrationHandler; /** * SAX handler for DAQ map elements. @@ -32,9 +27,14 @@ private DaqMapHandler daqMapHandler; /** - * SAX handler for calibration elements. + * SAX parser. */ - private CalibrationHandler calibrationHandler; + private final SAXParser parser; + + /** + * SAX parser factory. + */ + private final SAXParserFactory parserFactory = SAXParserFactory.newInstance(); /** * Default constructor. @@ -44,7 +44,37 @@ public SvtConditionsReader() throws Exception { // Create a new SAX parser. - parser = parserFactory.newSAXParser(); + this.parser = this.parserFactory.newSAXParser(); + } + + /** + * Get the collection of {@link SvtDaqMapping} objects created when parsing the DAQ map. If a DAQ map hasn't been + * parsed yet, an empty collection will be returned. + * + * @return A collection of {@link SvtDaqMapping} objects + */ + public SvtDaqMappingCollection getDaqMapCollection() { + return this.daqMapHandler.getDaqMap(); + } + + /** + * Get the collection of {@link SvtCalibration} objects built from parsing a calibrations file. If a calibrations + * file hasn't been parsed yet, an empty collection will be returned. + * + * @return A collection of {@link SvtCalibration} objects + */ + public SvtCalibrationCollection getSvtCalibrationCollection() { + return this.calibrationHandler.getCalibrations(); + } + + /** + * Get the collection of {@link SvtChannel} objects built from parsing the DAQ map. If a DAQ maps hasn't been parsed + * yet, an empty collection will be returned. + * + * @return A collection of {@link SvtChannel} objects + */ + public SvtChannelCollection getSvtChannelCollection() { + return this.daqMapHandler.getSvtChannels(); } /** @@ -56,10 +86,10 @@ public void parseCalibrations(final File calibrationFile) throws Exception { // Instantiate the calibration handler. - calibrationHandler = new CalibrationHandler(); + this.calibrationHandler = new CalibrationHandler(); // Parse the calibration file and create the collection of SvtCalibrations. - parser.parse(calibrationFile, calibrationHandler); + this.parser.parse(calibrationFile, this.calibrationHandler); } /** @@ -71,40 +101,10 @@ public void parseDaqMap(final File daqMapFile) throws Exception { // Instantiate the DAQ map handler. - daqMapHandler = new DaqMapHandler(); + this.daqMapHandler = new DaqMapHandler(); // Parse the DAQ map file and create the collection of SvtDaqMapping objects. - parser.parse(daqMapFile, daqMapHandler); + this.parser.parse(daqMapFile, this.daqMapHandler); } - - /** - * Get the collection of {@link SvtDaqMapping} objects created when parsing the DAQ map. If a DAQ map hasn't been - * parsed yet, an empty collection will be returned. - * - * @return A collection of {@link SvtDaqMappig} objects - */ - public SvtDaqMappingCollection getDaqMapCollection() { - return daqMapHandler.getDaqMap(); - } - - /** - * Get the collection of {@link SvtChannel} objects built from parsing the DAQ map. If a DAQ maps hasn't been parsed - * yet, an empty collection will be returned. - * - * @return A collection of {@link SvtChannel} objects - */ - public SvtChannelCollection getSvtChannelCollection() { - return daqMapHandler.getSvtChannels(); - } - - /** - * Get the collection of {@link SvtCalibration} objects built from parsing a calibrations file. If a calibrations - * file hasn't been parsed yet, an empty collection will be returned. - * - * @return A collection of {@link SvtCalibration} objects - */ - public SvtCalibrationCollection getSvtCalibrationCollection() { - return calibrationHandler.getCalibrations(); - } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java Thu Apr 9 19:20:38 2015 @@ -16,6 +16,93 @@ @Table(names = { "svt_daq_map" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public class SvtDaqMapping extends AbstractSvtDaqMapping { + + /** + * Collection implementation for {@link SvtDaqMapping} objects. + */ + @SuppressWarnings("serial") + public static class SvtDaqMappingCollection extends AbstractSvtDaqMappingCollection<SvtDaqMapping> { + + /** + * Get a DAQ pair (FEB ID, FEB Hybrid ID) for the given {@link HpsSiSensor}. + * + * @param sensor a sensor of type {@link HpsSiSensor} + * @return the DAQ pair associated with the sensor + */ + @Override + public Pair<Integer, Integer> getDaqPair(final HpsSiSensor sensor) { + + final String svtHalf = sensor.isTopLayer() ? TOP_HALF : BOTTOM_HALF; + for (final SvtDaqMapping object : this) { + + if (svtHalf.equals(object.getSvtHalf()) && object.getLayerNumber() == sensor.getLayerNumber() + && object.getSide().equals(sensor.getSide())) { + + return new Pair<Integer, Integer>(object.getFebID(), object.getFebHybridID()); + } + } + return null; + } + + /** + * Get the orientation of a sensor using the FEB ID and FEB Hybrid ID. If the FEB ID and FEB Hybrid ID + * combination is not found, return null. + * + * @param daqPair the DAQ pair for a given sensor + * @return "A" if sensor orientation is Axial; "S" if Stereo; null if daqPair doesn't exist. + */ + @Override + public String getOrientation(final Pair<Integer, Integer> daqPair) { + for (final SvtDaqMapping daqMapping : this) { + if (daqPair.getFirstElement() == daqMapping.getFebID() + && daqPair.getSecondElement() == daqMapping.getFebHybridID()) { + return daqMapping.getOrientation(); + } + } + return null; + } + + /** + * Convert this object to a string. + * + * @return this object converted to a string + */ + @Override + public String toString() { + final StringBuffer buff = new StringBuffer(); + buff.append("FEB ID: "); + buff.append(" "); + buff.append("FEB Hybrid ID: "); + buff.append(" "); + buff.append("Hybrid ID: "); + buff.append(" "); + buff.append("SVT half: "); + buff.append(" "); + buff.append("Layer"); + buff.append(" "); + buff.append("Orientation: "); + buff.append(" "); + buff.append('\n'); + buff.append("----------------------"); + buff.append('\n'); + for (final SvtDaqMapping object : this) { + buff.append(object.getFebID()); + buff.append(" "); + buff.append(object.getFebHybridID()); + buff.append(" "); + buff.append(object.getSvtHalf()); + buff.append(" "); + buff.append(String.format("%-2d", object.getLayerNumber())); + buff.append(" "); + buff.append(object.getSide()); + buff.append(" "); + buff.append(object.getOrientation()); + buff.append(" "); + buff.append('\n'); + } + return buff.toString(); + } + } /** * Electron side of a sensor. @@ -45,89 +132,13 @@ } /** - * Collection implementation for {@link SvtDaqMapping} objects. + * Get the Front End Board (FEB) hybrid ID. + * + * @return the FEB Hybrid ID */ - @SuppressWarnings("serial") - public static class SvtDaqMappingCollection extends AbstractSvtDaqMappingCollection<SvtDaqMapping> { - - /** - * Get a DAQ pair (FEB ID, FEB Hybrid ID) for the given {@link HpsSiSensor}. - * - * @param sensor a sensor of type {@link HpsSiSensor} - * @return the DAQ pair associated with the sensor - */ - @Override - public Pair<Integer, Integer> getDaqPair(final HpsSiSensor sensor) { - - final String svtHalf = sensor.isTopLayer() ? TOP_HALF : BOTTOM_HALF; - for (SvtDaqMapping object : this) { - - if (svtHalf.equals(object.getSvtHalf()) && object.getLayerNumber() == sensor.getLayerNumber() - && object.getSide().equals(sensor.getSide())) { - - return new Pair<Integer, Integer>(object.getFebID(), object.getFebHybridID()); - } - } - return null; - } - - /** - * Get the orientation of a sensor using the FEB ID and FEB Hybrid ID. If the FEB ID and FEB Hybrid ID - * combination is not found, return null. - * - * @param daqPair the DAQ pair for a given sensor - * @return "A" if sensor orientation is Axial; "S" if Stereo; null if daqPair doesn't exist. - */ - @Override - public String getOrientation(final Pair<Integer, Integer> daqPair) { - for (SvtDaqMapping daqMapping : this) { - if (daqPair.getFirstElement() == daqMapping.getFebID() - && daqPair.getSecondElement() == daqMapping.getFebHybridID()) { - return daqMapping.getOrientation(); - } - } - return null; - } - - /** - * Convert this object to a string. - * - * @return this object converted to a string - */ - public String toString() { - final StringBuffer buff = new StringBuffer(); - buff.append("FEB ID: "); - buff.append(" "); - buff.append("FEB Hybrid ID: "); - buff.append(" "); - buff.append("Hybrid ID: "); - buff.append(" "); - buff.append("SVT half: "); - buff.append(" "); - buff.append("Layer"); - buff.append(" "); - buff.append("Orientation: "); - buff.append(" "); - buff.append('\n'); - buff.append("----------------------"); - buff.append('\n'); - for (SvtDaqMapping object : this) { - buff.append(object.getFebID()); - buff.append(" "); - buff.append(object.getFebHybridID()); - buff.append(" "); - buff.append(object.getSvtHalf()); - buff.append(" "); - buff.append(String.format("%-2d", object.getLayerNumber())); - buff.append(" "); - buff.append(object.getSide()); - buff.append(" "); - buff.append(object.getOrientation()); - buff.append(" "); - buff.append('\n'); - } - return buff.toString(); - } + @Field(names = { "feb_hybrid_id" }) + public final int getFebHybridID() { + return getFieldValue("feb_hybrid_id"); } /** @@ -141,25 +152,24 @@ } /** - * Get the Front End Board (FEB) hybrid ID. - * - * @return the FEB Hybrid ID - */ - @Field(names = { "feb_hybrid_id" }) - public final int getFebHybridID() { - return getFieldValue("feb_hybrid_id"); - } - - /** * Get the side of the sensor (ELECTRON or POSITRON). * - * @see {@link #ELECTRON} - * @see {@link #POSITRON} + * @see ELECTRON + * @see POSITRON * @return sensor side (ELECTRON or POSITRON) */ @Field(names = { "side" }) public final String getSide() { return getFieldValue("side"); + } + + /** + * Set the Front End Board (FEB) hybrid ID. + * + * @param febHybridID the FEB hybrid ID + */ + public final void setFebHybridID(final int febHybridID) { + this.setFieldValue("feb_hybrid_id", febHybridID); } /** @@ -169,15 +179,6 @@ */ public final void setFebID(final int febID) { this.setFieldValue("feb_id", febID); - } - - /** - * Set the Front End Board (FEB) hybrid ID. - * - * @param febHybridID the FEB hybrid ID - */ - public final void setFebHybridID(final int febHybridID) { - this.setFieldValue("feb_hybrid_id", febHybridID); } /**