Author: [log in to unmask] Date: Mon Apr 6 18:17:40 2015 New Revision: 2663 Log: Code cleanup of conditions module, mostly from Checkstyle warnings. HPSJAVA-482 Added: java/trunk/conditions/src/main/java/org/hps/conditions/svt/package-info.java Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractIdentifier.java java/trunk/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObject.java java/trunk/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObjectCollection.java java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObject.java java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectCollection.java java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectException.java java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectUtilities.java java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsSeries.java java/trunk/conditions/src/main/java/org/hps/conditions/api/FieldValueMap.java java/trunk/conditions/src/main/java/org/hps/conditions/api/package-info.java java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamConditions.java java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java java/trunk/conditions/src/main/java/org/hps/conditions/beam/ImportBeamConditionsEngRun.java java/trunk/conditions/src/main/java/org/hps/conditions/beam/package-info.java java/trunk/conditions/src/main/java/org/hps/conditions/cli/AbstractCommand.java java/trunk/conditions/src/main/java/org/hps/conditions/cli/AddCommand.java java/trunk/conditions/src/main/java/org/hps/conditions/cli/CommandLineTool.java java/trunk/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java java/trunk/conditions/src/main/java/org/hps/conditions/cli/package-info.java java/trunk/conditions/src/main/java/org/hps/conditions/database/AbstractConditionsObjectConverter.java java/trunk/conditions/src/main/java/org/hps/conditions/database/ConditionsRecordConverter.java java/trunk/conditions/src/main/java/org/hps/conditions/database/ConditionsSeriesConverter.java java/trunk/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java java/trunk/conditions/src/main/java/org/hps/conditions/database/Converter.java java/trunk/conditions/src/main/java/org/hps/conditions/database/ConverterRegistry.java java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseUtilities.java java/trunk/conditions/src/main/java/org/hps/conditions/database/Field.java java/trunk/conditions/src/main/java/org/hps/conditions/database/QueryBuilder.java java/trunk/conditions/src/main/java/org/hps/conditions/database/Table.java java/trunk/conditions/src/main/java/org/hps/conditions/database/TableMetaData.java java/trunk/conditions/src/main/java/org/hps/conditions/database/TableRegistry.java java/trunk/conditions/src/main/java/org/hps/conditions/database/package-info.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalBadChannel.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCalibration.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCrystalChannelMap.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalGain.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalLed.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalLedCalibration.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalTimeShift.java java/trunk/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java java/trunk/conditions/src/main/java/org/hps/conditions/package-info.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditions.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditionsConverter.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtT0Shift.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/CalibrationHandler.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/ChannelConstants.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/SvtBadChannel.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsReader.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConfiguration.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtShapeFitParameters.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtT0Shift.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtChannel.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditions.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtT0Shift.java java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsDriverTest.java java/trunk/conditions/src/test/java/org/hps/conditions/EngRunConditionsTest.java java/trunk/conditions/src/test/java/org/hps/conditions/RunNumberTest.java java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamConditionsTest.java java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamCurrentTest.java java/trunk/conditions/src/test/java/org/hps/conditions/database/ConverterRegistryTest.java java/trunk/conditions/src/test/java/org/hps/conditions/database/TableRegistryTest.java java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalHardwareConditionsTest.java java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalLedTest.java java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtBadChannelTest.java java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConfigurationTest.java java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtDaqMappingTest.java java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtDetectorSetupTest.java java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtBadChannelsTest.java java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtConditionsConverterTest.java java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDetectorSetupTest.java Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java Mon Apr 6 18:17:40 2015 @@ -13,6 +13,7 @@ * be included in a steering file. * <p> * This is an example of using the Driver in an XML steering file: + * * <pre> * {@code * <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver"> @@ -61,7 +62,8 @@ /** * Set the name of the detector to use. - * @param detectorName The name of the detector. + * + * @param detectorName the name of the detector */ public final void setDetectorName(final String detectorName) { this.detectorName = detectorName; @@ -72,7 +74,8 @@ * frozen, the conditions system will ignore subsequent calls to * {@link org.lcsim.conditions.ConditionsManager#setDetector(String, int)} and instead use the user supplied * detector and run for the whole job. - * @param freeze True to freeze the conditions system after it is setup. + * + * @param freeze <code>true</code> to freeze the conditions system after it is setup */ public final void setFreeze(final boolean freeze) { this.freeze = freeze; @@ -81,10 +84,10 @@ /** * Set a custom run number to setup the conditions system. In the case where the actual event stream has run numbers * that differ from this one, most likely the Driver should be configured to be frozen after setup using - * {@link #setFreeze(boolean)}. - * - * The method {@link #setDetectorName(String)} needs to be called before this one or an exception will be thrown. - * @param runNumber The user supplied run number for the job. + * {@link #setFreeze(boolean)}. The method {@link #setDetectorName(String)} needs to be called before this one or an + * exception will be thrown. + * + * @param runNumber the user supplied run number for the job */ public final void setRunNumber(final int runNumber) { this.runNumber = runNumber; @@ -92,7 +95,8 @@ /** * Set a tag used to filter ConditionsRecords. - * @param tag The tag value e.g. "eng_run" etc. + * + * @param tag the tag value e.g. "pass0" */ public final void setTag(final String tag) { this.tag = tag; @@ -100,7 +104,8 @@ /** * Set an XML configuration resource. - * @param xmlConfigResource The XML configuration resource. + * + * @param xmlConfigResource the XML configuration resource */ public final void setXmlConfigResource(final String xmlConfigResource) { this.xmlConfigResource = xmlConfigResource; @@ -108,7 +113,8 @@ /** * Setup the conditions system based on the Driver parameters. - * @throws RuntimeException If there is a problem setting up the conditions system. + * + * @throws RuntimeException if there is a problem setting up the conditions system */ public final void initialize() { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractIdentifier.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractIdentifier.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractIdentifier.java Mon Apr 6 18:17:40 2015 @@ -11,14 +11,14 @@ /** * Encode the ID into a long. * - * @return The ID encoded into a long. + * @return the ID encoded into a <code>long</code> */ public abstract long encode(); /** * Check if the ID is valid. * - * @return True if valid. + * @return <code>true</code> if valid */ public abstract boolean isValid(); } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObject.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObject.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObject.java Mon Apr 6 18:17:40 2015 @@ -31,7 +31,7 @@ * <p> * Implements {@link ConditionsObject#getRowId()}. * - * @return The row ID. + * @return the row ID */ @Override public final int getRowId() { @@ -43,7 +43,7 @@ * <p> * Implements {@link ConditionsObject#isNew()}. * - * @return True if object is new. + * @return <code>true</code> if object is new */ @Override public final boolean isNew() { @@ -55,8 +55,8 @@ * <p> * Implements {@link ConditionsObject#setFieldValue(String, Object)}. * - * @param key The name of the field. - * @param value The value of the field. + * @param key the name of the field + * @param value the value of the field */ @Override public final void setFieldValue(final String key, final Object value) { @@ -68,7 +68,7 @@ * <p> * Implements {@link ConditionsObject#setFieldValues(FieldValueMap)}. * - * @param fieldValues The list of key-value pairs. + * @param fieldValues the list of key-value pairs */ @Override public final void setFieldValues(final FieldValueMap fieldValues) { @@ -80,10 +80,10 @@ * <p> * Implements {@link ConditionsObject#getFieldValue(Class, String)}. * - * @param klass The inferred return type. - * @param field The name of the field. - * @param <T> The generic type for inferrence of return type. - * @return The value of the field. + * @param klass the inferred return type + * @param field the name of the field + * @param <T> the type for inference of return type + * @return the value of the field */ @Override public final <T> T getFieldValue(final Class<T> klass, final String field) { @@ -95,7 +95,7 @@ * <p> * Implements {@link ConditionsObject#getFieldValues()}. * - * @return The field-value map. + * @return the field-value map */ @Override public final FieldValueMap getFieldValues() { @@ -105,9 +105,9 @@ /** * Get a field value. * - * @param field The field name. - * @param <T> The type inferred from the assigned variable. - * @return The field value. + * @param field the field name + * @param <T> the type inferred from the assigned variable + * @return the field value */ @SuppressWarnings("unchecked") public final <T> T getFieldValue(final String field) { @@ -117,8 +117,8 @@ /** * Set the database row ID of the object. * - * @param rowId The database row ID. - * @throws ConditionsObjectException If the object already has a row ID. + * @param rowId the database row ID + * @throws ConditionsObjectException if the object already has a row ID */ public final void setRowID(final int rowId) throws ConditionsObjectException { if (!isNew()) { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObjectCollection.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObjectCollection.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObjectCollection.java Mon Apr 6 18:17:40 2015 @@ -48,8 +48,8 @@ * This constructor uses the given conditions record and table meta data objects and will assign the collection ID * from the conditions record. * - * @param tableMetaData The table meta data. - * @param conditionsRecord The conditions record. + * @param tableMetaData the table meta data + * @param conditionsRecord the conditions record */ public BaseConditionsObjectCollection(final ConditionsRecord conditionsRecord, final TableMetaData tableMetaData) { this.conditionsRecord = conditionsRecord; @@ -60,9 +60,9 @@ /** * This constructor is used to explicitly assign all class variable values. * - * @param conditionsRecord The conditions record. - * @param tableMetaData The table meta data. - * @param collectionID The new collection ID. + * @param conditionsRecord the conditions record + * @param tableMetaData the table meta data + * @param collectionID the new collection ID */ public BaseConditionsObjectCollection(final ConditionsRecord conditionsRecord, final TableMetaData tableMetaData, final int collectionID) { @@ -75,7 +75,7 @@ * Set the associated table meta data for this collection. Once set it cannot be reassigned, which will cause an * exception to be thrown. * - * @param tableMetaData The table meta data for this collection. + * @param tableMetaData the table meta data for this collection */ public final void setTableMetaData(final TableMetaData tableMetaData) { if (this.tableMetaData != null) { @@ -88,7 +88,7 @@ * Set the associated conditions record this collection. Once set it cannot be reassigned, which will cause an * exception to be thrown. * - * @param conditionsRecord The conditions record for the collection. + * @param conditionsRecord the conditions record for the collection */ public final void setConditionsRecord(final ConditionsRecord conditionsRecord) { if (this.conditionsRecord != null) { @@ -102,9 +102,10 @@ * <p> * Implements {@link ConditionsObjectCollection#add(Object)}. * - * @param object The object do add to the collection. - * @return True if the add operation succeeded. - */ + * @param object the object do add to the collection + * @return <code>true</code> if the add operation succeeded + */ + @Override public boolean add(final ObjectType object) { if (contains(object)) { throw new IllegalArgumentException("Cannot add duplicate object " + object + " to collection."); @@ -117,7 +118,7 @@ * <p> * Implements {@link ConditionsObjectCollection#getTableMetaData()}. * - * @return The table meta data for the collection. + * @return the table meta data for the collection. */ @Override public final TableMetaData getTableMetaData() { @@ -129,7 +130,7 @@ * <p> * Implements {@link ConditionsObjectCollection#getCollectionId()}. * - * @return The collection ID. + * @return the collection ID */ @Override public final int getCollectionId() { @@ -145,7 +146,7 @@ * <p> * Implements {@link ConditionsObjectCollection#getConditionsRecord()}. * - * @return The conditions record for the collection. + * @return the conditions record for the collection */ @Override public final ConditionsRecord getConditionsRecord() { @@ -157,8 +158,8 @@ * <p> * Implements {@link ConditionsObjectCollection#setCollectionId(int)}. * - * @param collectionId The new collection ID. - * @throws ConditionsObjectException If the ID was already assigned. + * @param collectionId the new collection ID + * @throws ConditionsObjectException if the ID was already assigned */ @Override public final void setCollectionId(final int collectionId) throws ConditionsObjectException { @@ -174,8 +175,8 @@ * <p> * Implements {@link ConditionsObjectCollection#insert()}. * - * @throws ConditionsObjectException If there was a problem inserting the object. - * @throws SQLException If there was a SQL syntax error while executing the operation. + * @throws ConditionsObjectException if there was a problem inserting the object + * @throws SQLException if there was a SQL syntax error while executing the operation */ @Override public final void insert() throws ConditionsObjectException, SQLException { @@ -187,7 +188,7 @@ * <p> * Implements {@link ConditionsObjectCollection#select()}. * - * @return The number of records selected. + * @return the number of records selected */ @Override public final int select() { @@ -199,7 +200,7 @@ * <p> * Implements {@link ConditionsObjectCollection#delete()}. * - * @return The number of objects deleted. + * @return the number of objects deleted */ @Override public int delete() { @@ -211,7 +212,7 @@ * <p> * Implements {@link ConditionsObjectCollection#update()}. * - * @return The number of records updated. + * @return the number of records updated */ @Override public final int update() { @@ -220,7 +221,7 @@ /** * Convert this object to a string. - * @return The object converted to a string. + * @return the object converted to a string */ public String toString() { final StringBuffer buffer = new StringBuffer(); @@ -234,9 +235,9 @@ /** * Get an object by index. * - * @param index The index in the set. - * @return The object at the index. - * @throws IndexOutOfBoundsException If the index value is invalid. + * @param index the index in the set + * @return the object at the index + * @throws IndexOutOfBoundsException if the index is out of bounds */ public final ObjectType get(final int index) { if (index + 1 > this.size() || index < 0) { @@ -255,7 +256,7 @@ /** * Sort the collection in place. * - * @param comparator The comparator to use for sorting. + * @param comparator the comparator to use for sorting */ public void sort(final Comparator<ObjectType> comparator) { final List<ObjectType> objects = new ArrayList<ObjectType>(this); @@ -267,8 +268,8 @@ /** * Get a sorted list of the objects, leaving original collection in place. * - * @param comparator The comparator to use for the sort. - * @return A sorted list of the objects. + * @param comparator the comparator to use for the sort + * @return a sorted list of the objects */ @SuppressWarnings("unchecked") public BaseConditionsObjectCollection<ObjectType> sorted(final Comparator<ObjectType> comparator) { @@ -295,8 +296,8 @@ } /** - * Create and return a sorted collection, leaving the original collection unsorted. - * @return The sorted collection. + * Sort and return a copy of the collection. + * @return the sorted collection */ @SuppressWarnings("unchecked") @Override Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObject.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObject.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObject.java Mon Apr 6 18:17:40 2015 @@ -12,55 +12,55 @@ /** * Get the row ID of this object, which will be -1 for records not in the database. * - * @return The database row ID. + * @return the database row ID */ int getRowId(); /** * Set the value of a field. * - * @param field The name of the field. - * @param value The field value. + * @param field the name of the field + * @param value the field value */ void setFieldValue(String field, Object value); /** * Set all of the field values on this object. * - * @param fieldValues The map containing pairs of field names and values. + * @param fieldValues the map containing pairs of field names and values */ void setFieldValues(FieldValueMap fieldValues); /** - * Get the map of field values. + * Get the map of field values for the object. * - * @return The <code>FieldValueMap</code>. + * @return the <code>FieldValueMap</code> containing keys and values for the conditions object */ FieldValueMap getFieldValues(); /** * Get a field value, cast to the given class. * - * @param field The field value. - * @param type The class of the field. - * @param <T> The inferred type of the field. - * @return The field value casted to type T. + * @param field the field value + * @param type the class of the field + * @param <T> the inferred type of the field + * @return the field value cast to type T */ <T> T getFieldValue(Class<T> type, String field); /** * Get a field value with implicit return type. * - * @param field The field's name. - * @param <T> The inferred type of the field. - * @return The field value cast to type. + * @param field the field's name + * @param <T> the inferred type of the field + * @return the field value cast to type */ <T> T getFieldValue(String field); /** - * Set the row ID of this object. This cannot be reset once set to a valid ID (e.g. not -1). + * Set the row ID of this object. This cannot be reset once set to a value > 0. * - * @param rowId The object's row ID. + * @param rowId the object's row ID * @throws ConditionsObjectException if already set */ void setRowID(int rowId) throws ConditionsObjectException; @@ -69,7 +69,7 @@ * Return true if this object is new, e.g. it does not have a valid row ID. This means that it does not have a * database record in its table. * - * @return True if record is new. + * @return <code>true</code> if record is new */ boolean isNew(); @@ -81,9 +81,9 @@ /** * Compare objects according to standard Java conventions. * - * @param o1 The first object. - * @param o2 The second object. - * @return The result of comparison operation. + * @param o1 the first object + * @param o2 the second object + * @return the result of comparison operation */ public int compare(final ConditionsObject o1, final ConditionsObject o2) { if (o1.getRowId() < o2.getRowId()) { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectCollection.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectCollection.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectCollection.java Mon Apr 6 18:17:40 2015 @@ -17,82 +17,82 @@ /** * Get the table meta data. * - * @return The table meta data. + * @return the table meta data */ TableMetaData getTableMetaData(); /** * Get the collection ID. * - * @return The collection ID. + * @return the collection ID */ int getCollectionId(); /** * Get the conditions record. * - * @return The conditions record. + * @return the conditions record */ ConditionsRecord getConditionsRecord(); /** * Set the collection ID. Once set it cannot be assigned again, which will cause an exception. * - * @param collectionId The collection ID. - * @throws ConditionsObjectException If reassignment is attempted. + * @param collectionId the collection ID + * @throws ConditionsObjectException if reassignment of the ID is attempted */ void setCollectionId(int collectionId) throws ConditionsObjectException; /** * Insert all objects from the collection into the database. * - * @throws ConditionsObjectException If there is a conditions object error. - * @throws SQLException If there is a SQL syntax or execution error. + * @throws ConditionsObjectException if there is a conditions object error + * @throws SQLException if there is a SQL syntax or execution error */ void insert() throws ConditionsObjectException, SQLException; /** * Select objects into this collection by collection ID. * - * @return The number of rows selected. + * @return the number of rows selected */ int select(); /** * Delete objects in this from the database. * - * @return The number of rows deleted. + * @return the number of rows deleted */ int delete(); /** * Update rows in the database from these objects. * - * @return The number of rows updated. + * @return the number of rows updated */ int update(); /** * Get an object by its index. * - * @param index The index in the set. - * @return The object at the index. - * @throws IndexOutOfBoundsException If the index value is invalid. + * @param index the index in the set + * @return the object at the index + * @throws IndexOutOfBoundsException if the index value is out of bounds */ ObjectType get(int index); /** * Sort the collection in place. * - * @param comparator The comparator to use for sorting. + * @param comparator the comparator to use for sorting */ void sort(Comparator<ObjectType> comparator); /** * Get a sorted list of the objects, leaving original collection in place. * - * @param comparator The comparator to use for the sort. - * @return A sorted list of the objects. + * @param comparator the comparator to use for the sort + * @return a sorted list of the objects */ BaseConditionsObjectCollection<ObjectType> sorted(Comparator<ObjectType> comparator); @@ -102,9 +102,9 @@ void sort(); /** - * Get a new sorted collection. + * Get a new, sorted collection. * - * @return The new sorted collection. + * @return the new sorted collection */ BaseConditionsObjectCollection<ObjectType> sorted(); } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectException.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectException.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectException.java Mon Apr 6 18:17:40 2015 @@ -16,7 +16,7 @@ /** * Error with a message. * - * @param message The error message. + * @param message the error message */ public ConditionsObjectException(final String message) { super(message); @@ -25,8 +25,8 @@ /** * Error with an associated throwable. * - * @param message The error message. - * @param cause The error's cause. + * @param message the error message + * @param cause the error's cause */ public ConditionsObjectException(final String message, final Throwable cause) { super(message, cause); @@ -35,8 +35,8 @@ /** * Error with a message and object. * - * @param message The error message. - * @param object The associated conditions object. + * @param message the error message + * @param object the associated conditions object */ public ConditionsObjectException(final String message, final ConditionsObject object) { super(message); @@ -45,7 +45,7 @@ /** * Get the associated conditions object to the error. - * @return The object associated with the error. + * @return the object associated with the error */ public ConditionsObject getConditionsObject() { return object; Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectUtilities.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectUtilities.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectUtilities.java Mon Apr 6 18:17:40 2015 @@ -27,8 +27,8 @@ /** * Get the list of table names for the class. * - * @param type The class. - * @return The list of table names. + * @param type the class + * @return the list of table names */ public static String[] getTableNames(final Class<? extends ConditionsObject> type) { final Table tableAnnotation = type.getAnnotation(Table.class); @@ -42,8 +42,8 @@ /** * Get the list of database field names for the class. * - * @param type The class. - * @return The list of field names. + * @param type the class + * @return the list of field names */ public static Set<String> getFieldNames(final Class<? extends ConditionsObject> type) { final Set<String> fieldNames = new HashSet<String>(); @@ -71,8 +71,8 @@ /** * Get the class for the collection of the ConditionsObject type. * - * @param type The class of the ConditionsObject. - * @return The class of the collection. + * @param type the class of the ConditionsObject + * @return the class of the collection */ @SuppressWarnings("unchecked") public static Class<? extends BaseConditionsObjectCollection<? extends ConditionsObject>> getCollectionType( Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java Mon Apr 6 18:17:40 2015 @@ -35,8 +35,8 @@ /** * Sort using a comparator and leave the original collection unchanged. * - * @param comparator The comparison to use for sorting. - * @return The sorted collection. + * @param comparator the comparison to use for sorting + * @return the sorted collection */ public final ConditionsRecordCollection sorted(final Comparator<ConditionsRecord> comparator) { final List<ConditionsRecord> list = new ArrayList<ConditionsRecord>(this); @@ -49,7 +49,7 @@ /** * Sort and return collection by updated date. * - * @return The sorted collection. + * @return the sorted collection */ public final ConditionsRecordCollection sortedByUpdated() { return sorted(new UpdatedComparator()); @@ -58,7 +58,7 @@ /** * Sort and return collection by creation date. * - * @return The sorted collection. + * @return the sorted collection */ public final ConditionsRecordCollection sortedByCreated() { return sorted(new CreatedComparator()); @@ -67,7 +67,7 @@ /** * Sort and return by run start number. * - * @return The sorted collection. + * @return the sorted collection */ public final ConditionsRecordCollection sortedByRunStart() { return sorted(new RunStartComparator()); @@ -76,7 +76,7 @@ /** * Sort and return by key (table name). * - * @return The sorted collection. + * @return the sorted collection */ public final ConditionsRecordCollection sortedByKey() { return sorted(new KeyComparator()); @@ -85,7 +85,7 @@ /** * Sort the collection in place. * - * @param comparator The comparison to use for sorting. + * @param comparator the comparison to use for sorting */ public final void sort(final Comparator<ConditionsRecord> comparator) { final List<ConditionsRecord> list = new ArrayList<ConditionsRecord>(this); @@ -125,7 +125,7 @@ /** * Get the unique conditions keys from the records in this collection. * - * @return The set of unique conditions keys. + * @return the set of unique conditions keys */ public final Set<String> getConditionsKeys() { final Set<String> conditionsKeys = new HashSet<String>(); @@ -223,13 +223,13 @@ /** * Create a conditions record with fully qualified constructor. * - * @param collectionId The ID of the associated conditions collection. - * @param runStart The starting run number. - * @param runEnd The ending run number. - * @param name The name of the conditions set (usually same as table name). - * @param tableName The name of the conditions data table. - * @param notes Text notes about this record. - * @param tag The conditions tag for grouping this record with others. + * @param collectionId the ID of the associated conditions collection + * @param runStart the starting run number + * @param runEnd the ending run number + * @param name the name of the conditions set (usually same as table name) + * @param tableName the name of the conditions data table + * @param notes text notes about this record + * @param tag the conditions tag for grouping this record with others */ public ConditionsRecord(final int collectionId, final int runStart, final int runEnd, final String name, final String tableName, final String notes, final String tag) { @@ -252,7 +252,7 @@ /** * Insert the conditions record into the database. - * @throws ConditionsObjectException If there are errors inserting the record. + * @throws ConditionsObjectException if there are errors inserting the record */ public void insert() throws ConditionsObjectException { if (getFieldValues().size() == 0) { @@ -275,7 +275,7 @@ /** * Get the starting run number. * - * @return The starting run number. + * @return the starting run number */ @Field(names = { "run_start" }) public int getRunStart() { @@ -285,7 +285,7 @@ /** * Get the ending run number. * - * @return The ending run number. + * @return the ending run number */ @Field(names = { "run_end" }) public int getRunEnd() { @@ -295,7 +295,7 @@ /** * Get the date this record was last updated. * - * @return The date this record was updated. + * @return the date this record was updated */ @Field(names = { "updated" }) public Date getUpdated() { @@ -305,7 +305,7 @@ /** * Get the date this record was created. * - * @return The date this record was created. + * @return the date this record was created */ @Field(names = { "created" }) public Date getCreated() { @@ -315,7 +315,7 @@ /** * Get the name of the user who created this record. * - * @return The name of the person who created the record. + * @return the name of the person who created the record */ @Field(names = { "created_by" }) public String getCreatedBy() { @@ -325,7 +325,7 @@ /** * Get the notes. * - * @return The notes about this condition. + * @return the notes about this condition */ @Field(names = { "notes" }) public String getNotes() { @@ -333,10 +333,10 @@ } /** - * Get the name of these conditions, which should be unique by run number. This is called the "key" in the table - * meta data to distinguish it from "table name". - * - * @return The name of the conditions. + * Get the name of these conditions. This is called the "key" in the table + * meta data to distinguish it from "table name" but it is usually the same value. + * + * @return the name of the conditions */ @Field(names = { "name" }) public String getName() { @@ -346,7 +346,7 @@ /** * Get the name of the table containing the actual raw conditions data. * - * @return The name of the table with the conditions data. + * @return the name of the table with the conditions data */ @Field(names = { "table_name" }) public String getTableName() { @@ -356,7 +356,7 @@ /** * Get the collection ID, overriding this method from the parent class. * - * @return The collection ID. + * @return the collection ID */ @Field(names = { "collection_id" }) public int getCollectionId() { @@ -376,7 +376,7 @@ /** * Convert this record to a human readable string, one field per line. * - * @return This object represented as a string. + * @return this object represented as a string */ public String toString() { final StringBuffer sb = new StringBuffer(); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsSeries.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsSeries.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/ConditionsSeries.java Mon Apr 6 18:17:40 2015 @@ -6,11 +6,12 @@ * This class represents a series of collections containing <tt>ConditionsObjects</tt>. It is used to conditions * collections when there are multiple ones with the same key that are valid for the current run. * - * @param <ObjectType> The type of the conditions object. - * @param <CollectionType> The type of the conditions collection. + * @param <ObjectType> the type of the conditions object + * @param <CollectionType> the type of the conditions collection * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @SuppressWarnings({ "serial" }) -public class ConditionsSeries<ObjectType extends ConditionsObject, CollectionType extends ConditionsObjectCollection<ObjectType>> - extends ArrayList<ConditionsObjectCollection<ObjectType>> { +public class + ConditionsSeries<ObjectType extends ConditionsObject, CollectionType extends ConditionsObjectCollection<ObjectType>> + extends ArrayList<ConditionsObjectCollection<ObjectType>> { } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/FieldValueMap.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/FieldValueMap.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/FieldValueMap.java Mon Apr 6 18:17:40 2015 @@ -5,6 +5,8 @@ /** * Simple class extending <code>java.lang.Map</code> that maps field names * to values for conditions objects. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @SuppressWarnings("serial") public final class FieldValueMap extends LinkedHashMap<String, Object> { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/package-info.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/api/package-info.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/api/package-info.java Mon Apr 6 18:17:40 2015 @@ -3,8 +3,7 @@ * implementations, of the database conditions API for HPS. These classes * include simple ORM between conditions objects and the database. * - * @author Jeremy McCormick <[log in to unmask]> - * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> * @see ConditionsObject * @see ConditionsObjectCollection * @see ConditionsSeries Modified: java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamConditions.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamConditions.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamConditions.java Mon Apr 6 18:17:40 2015 @@ -37,7 +37,7 @@ * Get the average beam current (nA). * A value of 0 indicates there was no beam. * A null value means it was not recorded. - * @return The beam current (nA). + * @return the beam current (nA) */ @Field(names = {"current"}) public Double getCurrent() { @@ -46,7 +46,7 @@ /** * Get the average beam position in X (mm). - * @return The beam position (mm). + * @return the beam position (mm) */ @Field(names = {"position_x"}) public Double getPositionX() { @@ -55,7 +55,7 @@ /** * Get the average beam position in Y (mm). - * @return The beam position (mm). + * @return the beam position (mm) */ @Field(names = {"position_y"}) public Double getPositionY() { @@ -66,7 +66,7 @@ * Get the beam energy (GeV). * A value of 0 indicates there was no beam. * A null value means it was not recorded. - * @return The beam energy. + * @return the beam energy */ @Field(names = {"energy"}) public Double getEnergy() { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java Mon Apr 6 18:17:40 2015 @@ -25,7 +25,7 @@ /** * Get the integrated beam current. - * @return The integrated beam current. + * @return the integrated beam current */ @Field(names = {"beam_current"}) public double getIntegratedBeamCurrent() { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/beam/ImportBeamConditionsEngRun.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/beam/ImportBeamConditionsEngRun.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/beam/ImportBeamConditionsEngRun.java Mon Apr 6 18:17:40 2015 @@ -22,7 +22,7 @@ * <p> * The beam energy is hard-coded to 1.92 GeV for now, pending updates with better information. * - * @author Jeremy McCormick <[log in to unmask]> + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ public final class ImportBeamConditionsEngRun { @@ -44,8 +44,8 @@ /** * Import the Eng Run beam conditions from a text file. - * @param args The argument list. - * @throws Exception If there is an error importing the text file. + * @param args the argument list + * @throws Exception if there is an error importing the text file */ public static void main(final String[] args) throws Exception { @@ -101,8 +101,8 @@ final int run = entry.getKey(); final BeamConditions beam = entry.getValue(); final int collectionId = manager.getNextCollectionID("beam"); - final ConditionsRecord record = - new ConditionsRecord(collectionId, run, run, "beam", "beam", "imported from HPS_Runs.pdf", "eng_run"); + final ConditionsRecord record = new ConditionsRecord( + collectionId, run, run, "beam", "beam", "imported from HPS_Runs.pdf", "eng_run"); System.out.println(record); System.out.println(beam); final BeamConditionsCollection collection = new BeamConditionsCollection(); @@ -115,9 +115,9 @@ /** * Set the value of the beam current. - * @param beam The beam conditions object. - * @param fieldName The name of the field. - * @param rawValue The raw value from the text file. + * @param beam the beam conditions object + * @param fieldName the name of the field + * @param rawValue the raw value from the text file */ static void setValue(final BeamConditions beam, final String fieldName, final String rawValue) { final double value = Double.parseDouble(rawValue); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/beam/package-info.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/beam/package-info.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/beam/package-info.java Mon Apr 6 18:17:40 2015 @@ -1,6 +1,6 @@ /** * Provides access to beam parameters through the conditions system. * - * @author Jeremy McCormick <[log in to unmask]> + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ package org.hps.conditions.beam; Modified: java/trunk/conditions/src/main/java/org/hps/conditions/cli/AbstractCommand.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/cli/AbstractCommand.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/cli/AbstractCommand.java Mon Apr 6 18:17:40 2015 @@ -42,9 +42,9 @@ /** * Class constructor. - * @param name The string that invokes this command. - * @param description The description of this command. - * @param options The command's options (Apache CLI). + * @param name the string that invokes this command + * @param description the description of this command + * @param options the command's options (Apache CLI) */ AbstractCommand(final String name, final String description, final Options options) { this.name = name; @@ -54,7 +54,7 @@ /** * Get the name of this command. - * @return A String of the name of this command. + * @return the name of this command */ final String getName() { return this.name; @@ -62,15 +62,15 @@ /** * Get the description of this command. - * @return A String of the description of this command. + * @return the description of this command */ protected final String getDescription() { return this.description; } /** - * Options for this command. - * @return Options object for this command. + * Get the <code>Options</code> for this command (Apache CLI). + * @return the <code>Options</code> object for this command */ protected final Options getOptions() { return options; @@ -86,7 +86,7 @@ /** * Set whether verbose output is enabled. - * @param verbose True to enable verbose output. + * @param verbose <code>true</code> to enable verbose output */ final void setVerbose(final boolean verbose) { this.verbose = verbose; @@ -94,7 +94,7 @@ /** * Get verbose flag. - * @return The verbose flag. + * @return the verbose flag */ protected boolean getVerbose() { return verbose; @@ -102,8 +102,8 @@ /** * Parse the sub-command's options. - * @param arguments The sub-command's arguments. - * @return The parsed command line. + * @param arguments the sub-command's arguments + * @return the parsed command line */ protected final CommandLine parse(final String[] arguments) { CommandLine commandLine = null; Modified: java/trunk/conditions/src/main/java/org/hps/conditions/cli/AddCommand.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/cli/AddCommand.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/cli/AddCommand.java Mon Apr 6 18:17:40 2015 @@ -52,7 +52,7 @@ /** * Execute the command with the given arguments. * - * @param arguments The command line arguments. + * @param arguments the command line arguments */ final void execute(final String[] arguments) { @@ -134,15 +134,15 @@ /** * Create a conditions record. * - * @param runStart The run start. - * @param runEnd The run end. - * @param tableName The table name. - * @param name The key name. - * @param collectionId The collection ID. - * @param createdBy The user name. - * @param tag The conditions tag. - * @param notes The text notes. - * @return The new conditions record. + * @param runStart the run start + * @param runEnd the run end + * @param tableName the table name + * @param name the key name + * @param collectionId the collection ID + * @param createdBy the user name + * @param tag the conditions tag + * @param notes the text notes about the collection + * @return the new conditions record */ // FIXME: Too many method parameters (max 7 is recommended). private ConditionsRecord createConditionsRecord(final int runStart, final int runEnd, final String tableName, Modified: java/trunk/conditions/src/main/java/org/hps/conditions/cli/CommandLineTool.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/cli/CommandLineTool.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/cli/CommandLineTool.java Mon Apr 6 18:17:40 2015 @@ -32,7 +32,7 @@ /** * Setup logging. */ - private static final Logger LOGGER = + private static final Logger LOGGER = LogUtil.create(CommandLineTool.class.getSimpleName(), new DefaultLogFormatter(), Level.WARNING); /** @@ -72,7 +72,7 @@ /** * Run the command line tool, parsing the command line and sending arguments to sub-command handlers. * - * @param arguments The command line arguments passed directly from {@link #main(String[])}. + * @param arguments the command line arguments passed directly from {@link #main(String[])} */ private void run(final String[] arguments) { try { @@ -131,7 +131,7 @@ /** * Setup the conditions system based on command line arguments. * - * @param commandLine The parsed command line arguments. + * @param commandLine the parsed command line arguments */ private void setupConditionsManager(final CommandLine commandLine) { @@ -209,7 +209,7 @@ /** * Exit with the given status. * - * @param status The exit status. + * @param status the exit status */ private void exit(final int status) { System.exit(status); @@ -217,7 +217,7 @@ /** * Register a sub-command handler. - * @param command The sub-command handler. + * @param command the sub-command handler */ private void registerCommand(final AbstractCommand command) { if (commands.containsKey(command.getName())) { @@ -228,7 +228,7 @@ /** * Create a basic instance of this class. - * @return The instance of this class. + * @return the instance of this class */ private static CommandLineTool create() { final CommandLineTool cli = new CommandLineTool(); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java Mon Apr 6 18:17:40 2015 @@ -51,7 +51,7 @@ /** * Execute the 'load' command with the given arguments. * - * @param arguments The command arguments. + * @param arguments the command arguments */ @Override public void execute(final String[] arguments) { @@ -107,9 +107,9 @@ /** * Parse an input text file and add column names and row data to the input lists. - * @param fileName The name of the text file. - * @param columnNames The list of columns (modified by this method). - * @param rows The list of rows (modified by this method). + * @param fileName the name of the text file + * @param columnNames the list of columns (modified by this method) + * @param rows the list of rows (modified by this method) */ private final void parseFile(final String fileName, final List<String> columnNames, final List<List<String>> rows) { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java Mon Apr 6 18:17:40 2015 @@ -75,7 +75,7 @@ /** * Print out the conditions sets selected by the user's command line arguments. * - * @param arguments The command line arguments. + * @param arguments the command line arguments */ final void execute(final String[] arguments) { @@ -163,7 +163,7 @@ /** * Print out the conditions records either to the console or a file (if that option is enabled). * - * @param conditionsKeys The list of conditions keys (usually same as table names). + * @param conditionsKeys the list of conditions keys (usually same as table names) */ private void printConditionsRecords(final Set<String> conditionsKeys) { @@ -202,7 +202,7 @@ /** * Print the list of collections. - * @param collectionList The list of collections. + * @param collectionList the list of collections */ private void printCollections(final List<ConditionsObjectCollection<?>> collectionList) { // Loop over all the collections and print them. @@ -219,7 +219,7 @@ /** * Print a single collection. - * @param collection The collection. + * @param collection the collection to print */ private void printCollection(final ConditionsObjectCollection<?> collection) { final StringBuffer buffer = new StringBuffer(); @@ -238,7 +238,7 @@ /** * Print the header for a collection. - * @param collection The collection. + * @param collection the collection */ private void printCollectionHeader(final ConditionsObjectCollection<?> collection) { System.out.println("--------------------------------------"); @@ -249,8 +249,8 @@ } /** - * Print the column names. - * @param tableMetaData The table meta data. + * Print the column names for a table. + * @param tableMetaData the table meta data */ private void printColumnNames(final TableMetaData tableMetaData) { if (printIDs) { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/cli/package-info.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/cli/package-info.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/cli/package-info.java Mon Apr 6 18:17:40 2015 @@ -1,6 +1,6 @@ /** * Command line interface to the conditions system. * - * @author Jeremy McCormick <[log in to unmask]> + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ package org.hps.conditions.cli; Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/AbstractConditionsObjectConverter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/AbstractConditionsObjectConverter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/AbstractConditionsObjectConverter.java Mon Apr 6 18:17:40 2015 @@ -39,8 +39,8 @@ /** * Set the action that the converter will use to disambiguate when multiple conditions sets are found. - * - * @param multipleCollections The multiple collections action. + * + * @param multipleCollections the multiple collections action */ final void setMultipleCollectionsAction(MultipleCollectionsAction multipleCollections) { this.multipleCollections = multipleCollections; @@ -48,8 +48,8 @@ /** * Get the multiple collections action. - * - * @return The multiple collections action. + * + * @return the multiple collections action */ public final MultipleCollectionsAction getMultipleCollectionsAction() { return this.multipleCollections; @@ -57,8 +57,8 @@ /** * Get the specific type converted by this class. - * - * @return The class that this converter handles. + * + * @return the class that this converter handles */ public abstract Class<T> getType(); @@ -66,9 +66,9 @@ * Get the conditions data based on the name, e.g. "ecal_channels". The table information is found using the type * handled by the Converter. * - * @param conditionsManager The current conditions manager. - * @param name The name of the conditions set (maps to table name). - * @return The conditions data. + * @param conditionsManager the current conditions manager + * @param name the name of the conditions set (maps to table name) + * @return the conditions data */ @SuppressWarnings({ "unchecked", "rawtypes" }) public T getData(final ConditionsManager conditionsManager, final String name) { @@ -172,10 +172,10 @@ /** * Create a conditions object. * - * @param resultSet The database record. - * @param tableMetaData The table data for the object. - * @return The conditions object. - * @throws SQLException If there is a problem using the database. + * @param resultSet the database record + * @param tableMetaData the table data for the object + * @return the conditions object + * @throws SQLException if there is a problem using the database */ static final ConditionsObject createConditionsObject(final ResultSet resultSet, final TableMetaData tableMetaData) throws SQLException { @@ -203,11 +203,11 @@ /** * Create a conditions object collection. - * - * @param conditionsRecord The conditions record. - * @param tableMetaData The table data. - * @return The conditions object collection. - * @throws ConditionsObjectException If there is a problem creating the collection. + * + * @param conditionsRecord the conditions record + * @param tableMetaData the table data + * @return the conditions object collection + * @throws ConditionsObjectException if there is a problem creating the collection */ static final BaseConditionsObjectCollection<?> createCollection(final ConditionsRecord conditionsRecord, final TableMetaData tableMetaData) throws ConditionsObjectException { @@ -226,8 +226,8 @@ } /** - * Convert to string. - * @return The string. + * Convert object to string. + * @return the object converted to string */ public String toString() { return "ConditionsObjectConverter: type = " + this.getType() + ", multipleCollectionsAction = " Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/ConditionsRecordConverter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/ConditionsRecordConverter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/ConditionsRecordConverter.java Mon Apr 6 18:17:40 2015 @@ -10,14 +10,14 @@ /** * Read {@link org.hps.conditions.api.ConditionsRecord} objects from the conditions database. - * + * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ public final class ConditionsRecordConverter extends AbstractConditionsObjectConverter<ConditionsRecordCollection> { /** * Get the ConditionsRecords for a run based on current configuration of the conditions system. - * + * * @param manager The current conditions manager. * @param name The name of the conditions set. * @return The matching ConditionsRecords. Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/ConditionsSeriesConverter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/ConditionsSeriesConverter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/ConditionsSeriesConverter.java Mon Apr 6 18:17:40 2015 @@ -41,8 +41,8 @@ /** * Class constructor. - * @param objectType The type of the object. - * @param collectionType The type of the collection. + * @param objectType the type of the object + * @param collectionType the type of the collection */ ConditionsSeriesConverter(final Class<ObjectType> objectType, final Class<CollectionType> collectionType) { this.collectionType = collectionType; @@ -51,8 +51,8 @@ /** * Create a new conditions series. - * @param tableName The name of the data table. - * @return The conditions series. + * @param tableName the name of the data table + * @return the conditions series */ @SuppressWarnings({ "unchecked" }) final ConditionsSeries<ObjectType, CollectionType> createSeries(final String tableName) { @@ -77,7 +77,7 @@ } // Create a new conditions series. - final ConditionsSeries<ObjectType, CollectionType> series = + final ConditionsSeries<ObjectType, CollectionType> series = new ConditionsSeries<ObjectType, CollectionType>(); // Get the ConditionsRecord with the meta-data, which will use the current run number from the manager. @@ -107,7 +107,7 @@ // Loop over rows. while (resultSet.next()) { // Create new ConditionsObject. - final ConditionsObject newObject = + final ConditionsObject newObject = ConditionsRecordConverter.createConditionsObject(resultSet, tableMetaData); // Add new object to collection. Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java Mon Apr 6 18:17:40 2015 @@ -56,11 +56,11 @@ /** * Fully qualified constructor. * - * @param user The user name. - * @param password The password. - * @param hostname The hostname. - * @param port The port number. - * @param database The database name. + * @param user the user name + * @param password the password + * @param hostname the hostname + * @param port the port number + * @param database the database name */ public ConnectionParameters(final String user, final String password, final String database, final String hostname, final int port) { @@ -74,7 +74,7 @@ /** * Get Properties object for this connection. * - * @return The Properties for this connection. + * @return the Properties for this connection */ public Properties getConnectionProperties() { final Properties p = new Properties(); @@ -86,16 +86,16 @@ /** * Get the hostname. * - * @return The hostname. - */ - final String getHostname() { + * @return the hostname + */ + String getHostname() { return hostname; } /** * Get the port number. * - * @return The port number. + * @return the port number */ int getPort() { return port; @@ -104,7 +104,7 @@ /** * Get the name of the database. * - * @return The name of the database. + * @return the name of the database */ String getDatabase() { return database; @@ -112,8 +112,8 @@ /** * Get the user name. - * - * @return The user name. + * + * @return the user name */ String getUser() { return user; @@ -121,8 +121,8 @@ /** * Get the password. - * - * @return The password. + * + * @return the password */ String getPassword() { return password; @@ -133,7 +133,7 @@ * <p> * This is public because the DQM database manager is using it. * - * @return The connection string. + * @return the connection string */ public String getConnectionString() { return "jdbc:mysql://" + hostname + ":" + port + "/"; @@ -143,7 +143,7 @@ * Create a database connection from these parameters. The caller becomes the "owner" and is responsible for closing * it when finished. * - * @return The Connection object. + * @return the new <code>Connection</code> object */ public Connection createConnection() { final Properties connectionProperties = getConnectionProperties(); @@ -160,10 +160,10 @@ /** * Configure the connection parameters from a properties file. * - * @param file The properties file. - * @return The connection parameters. - */ - public static final ConnectionParameters fromProperties(final File file) { + * @param file the properties file + * @return the connection parameters + */ + public static ConnectionParameters fromProperties(final File file) { FileInputStream fin = null; try { fin = new FileInputStream(file); @@ -176,8 +176,8 @@ /** * Configure the connection parameters from an embedded classpath resource which should be a properties file. * - * @param resource The resource path. - * @return The connection parameters. + * @param resource the resource path + * @return the connection parameters */ public static ConnectionParameters fromResource(final String resource) { return fromProperties(ConnectionParameters.class.getResourceAsStream(resource)); @@ -186,8 +186,8 @@ /** * Configure the connection parameters from an <code>InputStream</code> of properties. * - * @param in The InputStream of the properties. - * @return The connection parameters. + * @param in the InputStream of the properties + * @return the connection parameters * @throws RuntimeException if the InputStream is invalid */ private static ConnectionParameters fromProperties(final InputStream in) { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/Converter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/Converter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/Converter.java Mon Apr 6 18:17:40 2015 @@ -19,14 +19,14 @@ * Get the action to perform in the converter when multiple conditions are found for the current configuration of * run number, detector and tag in the manager. * - * @return The multiple collections action. + * @return the multiple collections action */ MultipleCollectionsAction multipleCollectionsAction() default MultipleCollectionsAction.ERROR; /** * Get a custom converter class for the type. (Optional) * - * @return The custom converter for the type. + * @return the custom converter for the type */ Class<?> converter() default AbstractConditionsObjectConverter.class; } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/ConverterRegistry.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/ConverterRegistry.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/ConverterRegistry.java Mon Apr 6 18:17:40 2015 @@ -33,7 +33,7 @@ /** * Automatically create converters for all {@link org.hps.conditions.api.ConditionsObject} classes. * - * @return The registry of converters. + * @return the global registry of converters */ @SuppressWarnings({ "unchecked", "rawtypes" }) static ConverterRegistry create() { @@ -88,10 +88,10 @@ /** * Convert the object to a string. - * @return The object converted to a string. + * @return the object converted to a string */ @SuppressWarnings("rawtypes") - public final String toString() { + public String toString() { final StringBuffer buff = new StringBuffer(); for (Entry<Class<? extends ConditionsObject>, AbstractConditionsObjectConverter> entry : entrySet()) { buff.append(entry.getValue().toString()); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java Mon Apr 6 18:17:40 2015 @@ -223,7 +223,7 @@ /** * Get the static instance of this class. * - * @return The static instance of the manager. + * @return the static instance of the manager */ public static synchronized DatabaseConditionsManager getInstance() { @@ -261,7 +261,7 @@ /** * Set the log level. * - * @param level The log level. + * @param level the new log level */ public void setLogLevel(final Level level) { logger.config("setting log level to " + level); @@ -273,7 +273,7 @@ /** * Open the database connection. * - * @return True if a connection was opened; false if using an existing connection. + * @return <code>true</code> if a connection was opened; <code>false</code> if using an existing connection. */ public synchronized boolean openConnection() { boolean openedConnection = false; @@ -326,9 +326,9 @@ /** * Close the database connection but only if there was a connection opened based on the flag. Otherwise, it should - * be left open. - * - * @param connectionOpened True to close the connection; false to leave it open. + * be left open. Used in conjunction with return value of {@link #openConnection()}. + * + * @param connectionOpened <code>true</code> to close the connection; <code>false</code> to leave it open */ public synchronized void closeConnection(final boolean connectionOpened) { if (connectionOpened) { @@ -339,11 +339,11 @@ /** * Get a conditions series with one or more collections. * - * @param collectionType The type of the collection. - * @param tableName The name of the data table. - * @param <ObjectType> The type of the conditions object. - * @param <CollectionType> The type of the conditions collection. - * @return The conditions series. + * @param collectionType the type of the collection + * @param tableName the name of the data table + * @param <ObjectType> the type of the conditions object + * @param <CollectionType> the type of the conditions collection + * @return the conditions series */ @SuppressWarnings("unchecked") public @@ -392,35 +392,35 @@ /** * Utility method to determine if a run number is from the 2012 Test Run. * - * @param runNumber The run number. - * @return True if run number is from the Test Run. + * @param runNumber the run number + * @return <code>true</code> if run number is from the Test Run */ public static boolean isTestRun(final int runNumber) { return runNumber > 0 && runNumber <= TEST_RUN_MAX_RUN; } /** - * True if Test Run configuration is selected. - * - * @return True if current run is from the Test Run. + * Return <code>true</code> if Test Run configuration is active + * + * @return <code>true</code> if Test Run configuration is active */ public boolean isTestRun() { return isTestRun; } /** - * Get the current LCSim compact <code>Detector</code> object. - * - * @return The detector object. + * Get the current LCSim compact <code>Detector</code> object with the geometry and detector model. + * + * @return the detector object */ public Detector getDetectorObject() { return getCachedConditions(Detector.class, "compact.xml").getCachedData(); } /** - * Configure this object from an XML file. - * - * @param file The XML file. + * Configure some properties of this object from an XML file + * + * @param file the XML file */ public void setXmlConfig(final File file) { logger.config("setting XML config from file " + file.getPath()); @@ -437,7 +437,7 @@ /** * Configure this object from an embedded XML resource. * - * @param resource The embedded XML resource. + * @param resource the embedded XML resource */ public void setXmlConfig(final String resource) { logger.config("setting XML config from resource " + resource); @@ -448,7 +448,7 @@ /** * Set the path to a properties file containing connection settings. * - * @param file The properties file + * @param file the properties file */ public void setConnectionProperties(final File file) { logger.config("setting connection properties file " + file.getPath()); @@ -462,7 +462,7 @@ /** * Set the connection parameters of the conditions database. * - * @param connectionParameters The connection parameters. + * @param connectionParameters the connection parameters */ public void setConnectionParameters(final ConnectionParameters connectionParameters) { this.connectionParameters = connectionParameters; @@ -471,7 +471,7 @@ /** * Set the connection parameters from an embedded resource location. * - * @param resource The classpath resource location. + * @param resource the classpath resource location */ public void setConnectionResource(final String resource) { logger.config("setting connection resource " + resource); @@ -481,8 +481,8 @@ /** * Get the next collection ID for a database conditions table. * - * @param tableName The name of the table. - * @return The next collection ID. + * @param tableName the name of the table + * @return the next collection ID */ public synchronized int getNextCollectionID(final String tableName) { final boolean openedConnection = openConnection(); @@ -501,11 +501,11 @@ } /** - * This method will return true if the given collection ID already exists in the table. - * - * @param tableName The name of the table. - * @param collectionID The collection ID value. - * @return True if collection exists. + * This method will return <code>true</code> if the given collection ID already exists in the table. + * + * @param tableName the name of the table + * @param collectionID the collection ID value + * @return <code>true</code> if collection exists */ public boolean collectionExists(final String tableName, final int collectionID) { final String sql = "SELECT * FROM " + tableName + " where collection_id = " + collectionID; @@ -527,8 +527,9 @@ /** * This method can be used to perform a database SELECT query. * - * @param query The SQL query string. - * @return The ResultSet from the query or null. + * @param query the SQL query string + * @return the <code>ResultSet</code> from the query + * @throws RuntimeException if there is a query error */ ResultSet selectQuery(final String query) { logger.fine("executing SQL select query ..." + '\n' + query); @@ -546,8 +547,8 @@ /** * Perform a SQL query with an update command like INSERT, DELETE or UPDATE. * - * @param query The SQL query string. - * @return The keys of the rows affected. + * @param query the SQL query string + * @return the keys of the rows affected */ public List<Integer> updateQuery(final String query) { final boolean openedConnection = openConnection(); @@ -575,8 +576,8 @@ * Find a collection of conditions validity records by key name. The key name is distinct from the table name, but * they are usually set to the same value. * - * @param name The conditions key name. - * @return The set of matching conditions records. + * @param name the conditions key name + * @return the set of matching conditions records */ public ConditionsRecordCollection findConditionsRecords(final String name) { final ConditionsRecordCollection runConditionsRecords = getCachedConditions(ConditionsRecordCollection.class, @@ -601,17 +602,17 @@ /** * True if there is a conditions record with the given name. * - * @param name The conditions name. - * @return True if a conditions record exists with the given name. + * @param name the conditions record name (usually will match to table name) + * @return <code>true</code> if a conditions record exists with the given name */ public boolean hasConditionsRecord(final String name) { return !findConditionsRecords(name).isEmpty(); } /** - * Get a list of all the ConditionsRecord objects. - * - * @return The list of all the ConditionsRecord objects. + * Get a list of all the {@link ConditionsRecord} objects. + * + * @return the list of all the {@link ConditionsRecord} objects */ // FIXME: This should use a cache that is created during initialization, rather than look these up every time. public ConditionsRecordCollection getConditionsRecords() { @@ -637,7 +638,7 @@ /** * Get the combined ECAL conditions for this run. * - * @return The combined ECAL conditions. + * @return the combined ECAL conditions */ public EcalConditions getEcalConditions() { return this.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData(); @@ -646,7 +647,7 @@ /** * Get the combined SVT conditions for this run. * - * @return The combined SVT conditions. + * @return the combined SVT conditions */ public SvtConditions getSvtConditions() { return this.getCachedConditions(SvtConditions.class, "svt_conditions").getCachedData(); @@ -674,18 +675,18 @@ } /** - * True if conditions system is frozen. - * - * @return True if conditions system is frozen. + * True if conditions system is frozen + * + * @return <code>true</code> if conditions system is currently frozen */ public boolean isFrozen() { return isFrozen; } /** - * Set a tag used to filter ConditionsRecords. - * - * @param tag The tag value used to filter ConditionsRecords. + * Set a tag used to filter the accessible conditions records + * + * @param tag the tag value used to filter returned conditions records */ public void setTag(final String tag) { this.tag = tag; @@ -695,10 +696,10 @@ /** * Insert a collection of ConditionsObjects into the database. * - * @param collection The collection to insert. - * @param <ObjectType> The type of the conditions object. - * @throws SQLException If there is a database error. - * @throws ConditionsObjectException If there is a problem with the ConditionsObjects. + * @param collection the collection to insert + * @param <ObjectType> the type of the conditions object + * @throws SQLException if there is a database or SQL error + * @throws ConditionsObjectException if there is a problem inserting the object */ public <ObjectType extends ConditionsObject> void insertCollection( final ConditionsObjectCollection<ObjectType> collection) @@ -717,7 +718,7 @@ if (metaDataList == null) { // This is a fatal error because no meta data is available for the type. throw new ConditionsObjectException("Failed to find meta data for type: " + collection.getClass()); - } + } } if (collection.getCollectionId() == -1) { try { @@ -775,7 +776,7 @@ /** * Check if connected to the database. * - * @return true if connected + * @return <code>true</code> if connected */ public boolean isConnected() { return isConnected; @@ -784,7 +785,7 @@ /** * Get the Logger for this class, which can be used by related sub-classes if they do not have their own logger. * - * @return The Logger for this class. + * @return the Logger for this class */ public static Logger getLogger() { return logger; @@ -793,8 +794,8 @@ /** * Find table information from the name. * - * @param name The name of the table. - * @return The table information or null if does not exist. + * @param name the name of the table + * @return the table information or <code>null</code> if does not exist */ public TableMetaData findTableMetaData(final String name) { return tableRegistry.findByTableName(name); @@ -803,8 +804,8 @@ /** * Find table information from the collection type. * - * @param type The collection type. - * @return The table information or null if does not exist. + * @param type the collection type + * @return the table information or <code>null</code> if does not exist */ public List<TableMetaData> findTableMetaData(final Class<?> type) { return tableRegistry.findByCollectionType(type); @@ -813,7 +814,7 @@ /** * Get the name of the ECAL in the detector geometry. * - * @return The name of the ECAL. + * @return the name of the ECAL */ public String getEcalName() { return ecalName; @@ -822,7 +823,7 @@ /** * Get the subdetector object of the ECAL. * - * @return The ECAL subdetector. + * @return the ECAL subdetector */ public Subdetector getEcalSubdetector() { return this.getDetectorObject().getSubdetector(ecalName); @@ -831,16 +832,16 @@ /** * True if conditions manager is properly initialized. * - * @return True if the manager is initialized. + * @return <code>true</code> if the manager is initialized */ public boolean isInitialized() { return isInitialized; } /** - * Get the set of unique conditions tags from the conditions table. - * - * @return The list of unique conditions tags. + * Get the set of available conditions tags from the conditions table + * + * @return the set of available conditions tags */ public Set<String> getTags() { logger.fine("getting list of available conditions tags"); @@ -872,11 +873,12 @@ /** * Perform all necessary initialization, including setup of the XML configuration and loading of conditions - * onto the Detector. - * - * @param detectorName The name of the detector model. - * @param runNumber The run number. - * @throws ConditionsNotFoundException If there is a conditions system error. + * onto the Detector. This is called from the {@link #setDetector(String, int)} method to setup the manager + * for a new run or detector. + * + * @param detectorName the name of the detector model + * @param runNumber the run number + * @throws ConditionsNotFoundException if there is a conditions system error */ private void initialize(final String detectorName, final int runNumber) throws ConditionsNotFoundException { @@ -972,7 +974,7 @@ /** * Set the name of the ECAL sub-detector. * - * @param ecalName The name of the ECAL. + * @param ecalName the name of the ECAL subdetector */ private void setEcalName(final String ecalName) { if (ecalName == null) { @@ -983,9 +985,9 @@ } /** - * Set the name of the SVT sub-detector. - * - * @param svtName The name of the SVT. + * Set the name of the SVT subdetector. + * + * @param svtName the name of the SVT subdetector */ private void setSvtName(final String svtName) { if (svtName == null) { @@ -996,10 +998,10 @@ } /** - * True if the conditions record matches the current tag. - * - * @param record The conditions record. - * @return True if conditions record matches the currently used tag. + * Return <code>true</code> if the conditions record matches the current tag + * + * @param record the conditions record + * @return <code>true</code> if conditions record matches the currently used tag */ private boolean matchesTag(final ConditionsRecord record) { if (this.tag == null) { @@ -1020,10 +1022,10 @@ private void cacheConditionsSets() { for (TableMetaData meta : tableRegistry.values()) { try { - logger.fine("caching conditions " + meta.key + " with type " + meta.collectionClass.getCanonicalName()); - getCachedConditions(meta.collectionClass, meta.key); + logger.fine("caching conditions " + meta.getKey() + " with type " + meta.getCollectionClass().getCanonicalName()); + getCachedConditions(meta.getCollectionClass(), meta.getKey()); } catch (Exception e) { - logger.warning("could not cache conditions " + meta.key); + logger.warning("could not cache conditions " + meta.getKey()); } } } @@ -1075,7 +1077,7 @@ /** * Load configuration information from an XML document. * - * @param document The XML document. + * @param document the XML document */ private void loadConfiguration(final Document document) { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseUtilities.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseUtilities.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseUtilities.java Mon Apr 6 18:17:40 2015 @@ -20,7 +20,7 @@ /** * Cleanup a JDBC <code>ResultSet</code> by closing it and its <code>Statement</code> * - * @param resultSet The database ResultSet. + * @param resultSet the database <code>ResultSet</code> */ static void cleanup(final ResultSet resultSet) { Statement statement = null; Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/Field.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/Field.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/Field.java Mon Apr 6 18:17:40 2015 @@ -16,7 +16,7 @@ /** * The names of the table columns associated with this method. * - * @return The names of the table column associated with this method. + * @return the names of the table columns associated with this method */ String[] names() default ""; } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/QueryBuilder.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/QueryBuilder.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/QueryBuilder.java Mon Apr 6 18:17:40 2015 @@ -22,15 +22,15 @@ /** * Build a SQL select query string. - * @param tableName The name of the table. - * @param collectionId The collection ID. - * @param fields The list of fields. - * @param orderBy The field to order by. - * @return The SQL query string. + * @param tableName the name of the table + * @param collectionId the collection ID + * @param fields the list of fields + * @param orderBy the field to order by + * @return the SQL query string */ static String buildSelect(final String tableName, final int collectionId, final String[] fields, final String orderBy) { - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); buff.append("SELECT "); if (fields == null) { buff.append("* "); @@ -85,9 +85,9 @@ /** * Build a prepared insert statement for a conditions object. - * @param tableName The name of the table. - * @param object The conditions object. - * @return The prepared insert statement. + * @param tableName the name of the table + * @param object the conditions object + * @return the prepared insert statement */ static String buildPreparedInsert(final String tableName, final ConditionsObject object) { if (object.getFieldValues().size() == 0) { @@ -111,13 +111,13 @@ /** * Date formatting for insert statement. */ - final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss"); + private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss"); /** * Build an insert statement. - * @param tableName The table name. - * @param fieldValues The field values. - * @return The insert statement. + * @param tableName the table name + * @param fieldValues the field values + * @return the insert statement */ public static String buildInsert(final String tableName, final FieldValueMap fieldValues) { if (fieldValues.size() == 0) { @@ -145,11 +145,11 @@ /** * Build a SQL insert statement. - * @param tableName The table name. - * @param collectionID The collection ID. - * @param columnNames The column names. - * @param rows The row data. - * @return The SQL insert statement. + * @param tableName the table name + * @param collectionID the collection ID + * @param columnNames the column names + * @param rows the row data + * @return the SQL insert statement */ public static String buildInsert(final String tableName, final int collectionID, final List<String> columnNames, final List<List<String>> rows) { @@ -182,8 +182,8 @@ /** * Format the date for insert statement. - * @param date The input date. - * @return The formatted date string. + * @param date the input date + * @return the formatted date string */ static String formatDate(final Date date) { return DATE_FORMAT.format(date); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/Table.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/Table.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/Table.java Mon Apr 6 18:17:40 2015 @@ -17,7 +17,7 @@ /** * Get the names of the tables. - * @return The names of the tables. + * @return the names of the tables */ String[] names() default ""; } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/TableMetaData.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/TableMetaData.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/TableMetaData.java Mon Apr 6 18:17:40 2015 @@ -29,47 +29,47 @@ /** * The table name. */ - protected String tableName; - + private String tableName; + /** * The conditions key named (unused???). */ - protected String key; - + private String key; + /** * The object class. */ - protected Class<? extends ConditionsObject> objectClass; - + private Class<? extends ConditionsObject> objectClass; + /** * The collection class. */ - protected Class<? extends BaseConditionsObjectCollection<?>> collectionClass; - + private Class<? extends BaseConditionsObjectCollection<?>> collectionClass; + /** * The set of field names. */ - protected Set<String> fieldNames = new LinkedHashSet<String>(); - + private Set<String> fieldNames = new LinkedHashSet<String>(); + /** * The map of field names to their types. */ - protected Map<String, Class<?>> fieldTypes; + private Map<String, Class<?>> fieldTypes; /** - * Fully qualified constructor. - * @param key The conditions key. - * @param tableName The table name. - * @param objectClass The object class. - * @param collectionClass The collection class. - * @param fieldNames The field names. - * @param fieldTypes The field types. + * Fully qualified constructor. + * @param key the conditions key + * @param tableName the table name + * @param objectClass the object class + * @param collectionClass the collection class + * @param fieldNames the field names + * @param fieldTypes the field types */ public TableMetaData( - final String key, - final String tableName, - final Class<? extends ConditionsObject> objectClass, - final Class<? extends BaseConditionsObjectCollection<?>> collectionClass, + final String key, + final String tableName, + final Class<? extends ConditionsObject> objectClass, + final Class<? extends BaseConditionsObjectCollection<?>> collectionClass, final Set<String> fieldNames, final Map<String, Class<?>> fieldTypes) { if (key == null) { @@ -100,7 +100,7 @@ /** * Get the type of object this table maps onto. - * @return The type of object. + * @return the type of object */ public Class<? extends ConditionsObject> getObjectClass() { return objectClass; @@ -108,7 +108,7 @@ /** * Get the type of collection this table maps onto. - * @return The collection class. + * @return the collection class */ public Class<? extends BaseConditionsObjectCollection<?>> getCollectionClass() { return collectionClass; @@ -116,7 +116,7 @@ /** * Get the names of the fields. Types are implied from the database tables. - * @return The names of the fields. + * @return the names of the fields */ public String[] getFieldNames() { return fieldNames.toArray(new String[] {}); @@ -124,7 +124,7 @@ /** * Get the type of the field called <code>fieldName</code>. - * @return The type of the field. + * @return the type of the field */ public Class<?> getFieldType(final String fieldName) { return fieldTypes.get(fieldName); @@ -132,7 +132,7 @@ /** * Get the name of the table. - * @return The name of the table. + * @return the name of the table */ public String getTableName() { return tableName; @@ -141,7 +141,7 @@ /** * Get the key of this conditions type. May be different from table name but * is usually the same. - * @return The key name of the conditions type. + * @return the key name of the conditions type */ public String getKey() { return key; @@ -149,11 +149,12 @@ /** * Find table meta data by object type. - * @param tableMetaDataList The list of table meta data e.g. from the registry. - * @param objectType The type of the object. - * @return The list of table meta data that have that object type. + * @param tableMetaDataList the list of table meta data e.g. from the registry + * @param objectType the type of the object + * @return the list of table meta data that have that object type */ - public static List<TableMetaData> findByObjectType(List<TableMetaData> tableMetaDataList, Class<? extends ConditionsObject> objectType) { + public static List<TableMetaData> findByObjectType(final List<TableMetaData> tableMetaDataList, + final Class<? extends ConditionsObject> objectType) { List<TableMetaData> list = new ArrayList<TableMetaData>(); for (TableMetaData tableMetaData : tableMetaDataList) { if (tableMetaData.getObjectClass().equals(objectType)) { @@ -169,7 +170,7 @@ * @return This object converted to a string. */ public String toString() { - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); buff.append("tableMetaData: tableName = " + this.getTableName()); buff.append(", objectClass = " + this.getObjectClass().getCanonicalName()); buff.append(", collectionClass = " + this.getCollectionClass().getCanonicalName()); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/TableRegistry.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/TableRegistry.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/TableRegistry.java Mon Apr 6 18:17:40 2015 @@ -16,16 +16,17 @@ * This is a registry providing a map between tables and their meta-data. * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ +@SuppressWarnings("serial") public final class TableRegistry extends HashMap<String, TableMetaData> { /** - * Maps types to table meta data. + * Maps types to table meta data. */ static class ObjectTypeMap extends HashMap<Class<? extends ConditionsObject>, List<TableMetaData>> { /** * Add a connection between an object type and table meta data. - * @param type The object type. - * @param metaData The table meta data. + * @param type the object type + * @param metaData the table meta data */ void add(Class<? extends ConditionsObject> type, TableMetaData metaData) { if (this.get(type) == null) { @@ -37,14 +38,16 @@ /** * Maps collection types to table meta data. - */ - static class CollectionTypeMap extends HashMap<Class<? extends BaseConditionsObjectCollection<?>>, List<TableMetaData>> { + */ + static class CollectionTypeMap extends + HashMap<Class<? extends BaseConditionsObjectCollection<?>>, List<TableMetaData>> { + /** - * Add a connection between a collection type and table meta data. - * @param type The collection type. - * @param metaData The table meta data. + * Add a mapping between a collection type and table meta data. + * @param type the collection type + * @param metaData the table meta data */ - void add(Class<? extends BaseConditionsObjectCollection<?>> type, TableMetaData metaData) { + void add(final Class<? extends BaseConditionsObjectCollection<?>> type, final TableMetaData metaData) { if (this.get(type) == null) { this.put(type, new ArrayList<TableMetaData>()); } @@ -56,7 +59,7 @@ * Map between object types and meta data. */ private ObjectTypeMap objectTypeMap = new ObjectTypeMap(); - + /** * Map between collection types and meta data. */ @@ -72,7 +75,7 @@ /** * Create a new table meta data registry. - * @return The meta data registry. + * @return the meta data registry */ static TableRegistry create() { TableRegistry registry = new TableRegistry(); @@ -106,41 +109,41 @@ registry.put(name, data); registry.objectTypeMap.add(objectType, data); registry.collectionTypeMap.add(collectionType, data); - } + } } return registry; } /** * Find meta data by object type. - * @param objectType The object type. - * @return The meta data or null if none exists. + * @param objectType the object type + * @return the meta data or <code>null</code> if none exists. */ - List<TableMetaData> findByObjectType(Class<? extends ConditionsObject> objectType) { + List<TableMetaData> findByObjectType(final Class<? extends ConditionsObject> objectType) { return objectTypeMap.get(objectType); } /** * Find meta data by collection type. - * @param collectionType The collection type. - * @return The meta data or null if none exists. + * @param collectionType the collection type + * @return the meta data or <code>null</code> if none exists. */ - List<TableMetaData> findByCollectionType(Class<?> collectionType) { + List<TableMetaData> findByCollectionType(final Class<?> collectionType) { return collectionTypeMap.get(collectionType); } /** * Find meta data by table name. - * @param name The table name. - * @return The meta data or null if none exists. + * @param name the table name + * @return the meta data or <code>null</code> if none exists */ - TableMetaData findByTableName(String name) { + TableMetaData findByTableName(final String name) { return this.get(name); } /** * Convert this object to a string. - * @return This object converted to a string. + * @return this object converted to a string */ public String toString() { StringBuffer buff = new StringBuffer(); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/package-info.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/database/package-info.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/database/package-info.java Mon Apr 6 18:17:40 2015 @@ -2,7 +2,7 @@ * This package contains classes for converting database information * into conditions classes as well as updating the records from the * objects. - * + * * @see DatabaseConditionsManager * @see TableMetaData * @see AbstractConditionsObjectConverter Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalBadChannel.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalBadChannel.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalBadChannel.java Mon Apr 6 18:17:40 2015 @@ -25,7 +25,7 @@ /** * Sort and return the collection without modifying in place. - * @return The sorted collection. + * @return the sorted collection */ public BaseConditionsObjectCollection<EcalBadChannel> sorted() { return sorted(new ChannelIdComparator()); @@ -37,9 +37,9 @@ class ChannelIdComparator implements Comparator<EcalBadChannel> { /** * Compare two ECAL bad channel objects. - * @param o1 The first object. - * @param o2 The second object. - * @return -1, 0, 1 if first channel ID is less than, equal to, or greater than the second. + * @param o1 the first object + * @param o2 the second object + * @return -1, 0, 1 if first channel ID is less than, equal to, or greater than the second */ public int compare(EcalBadChannel o1, EcalBadChannel o2) { if (o1.getChannelId() < o2.getChannelId()) { @@ -55,7 +55,7 @@ /** * Get the ECAL channel ID. - * @return The ECAL channel ID. + * @return the ECAL channel ID */ @Field(names = {"ecal_channel_id"}) public int getChannelId() { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCalibration.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCalibration.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCalibration.java Mon Apr 6 18:17:40 2015 @@ -30,7 +30,7 @@ /** * Sort and return the collection but do no modify in place. - * @return The sorted collection. + * @return the sorted collection */ public BaseConditionsObjectCollection<EcalCalibration> sorted() { return sorted(new ChannelIdComparator()); @@ -42,9 +42,9 @@ class ChannelIdComparator implements Comparator<EcalCalibration> { /** * Compare two ECAL calibration objects. - * @param o1 The first object. - * @param o2 The second object. - * @return -1, 0, 1 if first channel ID is less than, equal to, or greater than the second. + * @param o1 the first object + * @param o2 the second object + * @return -1, 0, 1 if first channel ID is less than, equal to, or greater than the second */ public int compare(final EcalCalibration o1, final EcalCalibration o2) { if (o1.getChannelId() < o2.getChannelId()) { @@ -66,9 +66,9 @@ /** * Full qualified constructor. - * @param channelId The channel ID. - * @param pedestal The pedestal measurement (ADC counts). - * @param noise The noise measured as RMS. + * @param channelId the channel ID + * @param pedestal the pedestal measurement (ADC counts) + * @param noise the noise measured as RMS */ public EcalCalibration(final int channelId, final double pedestal, final double noise) { this.setFieldValue("ecal_channel_id", channelId); @@ -78,7 +78,7 @@ /** * Get the ECAL channel ID. - * @return The ECAL channel ID. + * @return the ECAL channel ID */ @Field(names = {"ecal_channel_id"}) public int getChannelId() { @@ -88,7 +88,7 @@ /** * Get the pedestal value in units of ADC counts, which is the mean of the * digitized preamplifier output. - * @return The gain value. + * @return the gain value */ @Field(names = {"pedestal"}) public double getPedestal() { @@ -98,7 +98,7 @@ /** * Get the noise value in units of ADC counts, which is the standard * deviation of the digitized preamplifier output. - * @return The noise value. + * @return the noise value */ @Field(names = {"noise"}) public double getNoise() { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java Mon Apr 6 18:17:40 2015 @@ -20,12 +20,12 @@ import org.lcsim.geometry.Subdetector; /** - * This class encapsulates all the information about a single ECal channel, - * corresponding to one physical crystal in the detector. + * This class encapsulates all the information about a single ECal channel, corresponding to one physical crystal in the + * detector. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -@Table(names = {"ecal_channels", "test_run_ecal_channels"}) +@Table(names = { "ecal_channels", "test_run_ecal_channels" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED, converter = EcalChannel.EcalChannelConverter.class) public final class EcalChannel extends BaseConditionsObject { @@ -36,12 +36,13 @@ /** * Create an {@link EcalChannel} collection. - * @param conditionsManager The conditions manager. - * @param name The name of the conditions data table. - * @return The collection of ECAL channel objects. - */ - @Override - public EcalChannelCollection getData(ConditionsManager conditionsManager, String name) { + * + * @param conditionsManager the conditions manager + * @param name the name of the conditions data table + * @return the collection of ECAL channel objects + */ + @Override + public EcalChannelCollection getData(final ConditionsManager conditionsManager, final String name) { final EcalChannelCollection collection = super.getData(conditionsManager, name); final Subdetector ecal = DatabaseConditionsManager.getInstance().getEcalSubdetector(); collection.buildGeometryMap(ecal.getDetectorElement().getIdentifierHelper(), ecal.getSystemID()); @@ -50,17 +51,18 @@ /** * Get the type this converter handles. - * @return The type this converter handles. + * + * @return the type this converter handles */ @Override public Class<EcalChannelCollection> getType() { return EcalChannelCollection.class; } } - - /** - * The <code>DaqId</code> is the combination of crate, slot and channel that - * specify the channel's DAQ configuration. + + /** + * The <code>DaqId</code> is the combination of crate, slot and channel that specify the channel's DAQ + * configuration. */ public static final class DaqId extends AbstractIdentifier { @@ -68,12 +70,12 @@ * The DAQ crate number. */ private int crate = -1; - - /** - * The DAQ slot number. + + /** + * The DAQ slot number. */ private int slot = -1; - + /** * The DAQ channel number. */ @@ -81,6 +83,7 @@ /** * Create a DAQ ID from an array of values. + * * @param values The list of values (crate, slot, channel). */ public DaqId(final int values[]) { @@ -91,16 +94,18 @@ /** * Encode this ID into a long value. + * * @return The encoded long value. */ @Override public long encode() { - // from Sho's code + // from ECAL readout sim code return (((long) crate) << 32) | ((long) slot << 16) | (long) channel; } /** * Check if the values look valid. + * * @return True if ID's values are valid. */ @Override @@ -110,8 +115,8 @@ } /** - * The <code>GeometryId</code> contains the x and y indices of the crystal - * in the LCSIM-based geometry representation. + * The <code>GeometryId</code> contains the x and y indices of the crystal in the LCSIM-based geometry + * representation. */ public static final class GeometryId extends AbstractIdentifier { @@ -119,12 +124,12 @@ * The subdetector system ID. */ private int system = -1; - + /** * The crystal's X index. */ private int x = Integer.MAX_VALUE; - + /** * The crystal's Y index. */ @@ -137,8 +142,9 @@ /** * Create a geometry ID. - * @param helper The ID helper. - * @param values The list of values (system, x, y). + * + * @param helper the ID helper + * @param values the list of values (order is system, x, y) */ public GeometryId(final IIdentifierHelper helper, final int[] values) { this.helper = helper; @@ -149,11 +155,13 @@ /** * Encode this ID as a long using the ID helper. + * * @return The encoded long value. */ @Override public long encode() { - IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); + final IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary() + .getNumberOfFields()); expId.setValue(helper.getFieldIndex("system"), system); expId.setValue(helper.getFieldIndex("ix"), x); expId.setValue(helper.getFieldIndex("iy"), y); @@ -161,8 +169,9 @@ } /** - * True if ID's values look valid. - * @return True if ID is valid. + * Return <code>true</code> if ID is valid + * + * @return <code>true</code> if ID is valid */ @Override public boolean isValid() { @@ -171,12 +180,10 @@ } /** - * The <code>ChannelId</code> is a unique number identifying the channel - * within its conditions collection. The channels in the database are given - * sequential channel IDs from 1 to N in semi-arbitrary order. The channel - * ID is generally the number used to connect other conditions objects such - * as {@link EcalGain} or {@link EcalCalibration} to the appropriate crystal - * in the calorimeter. + * The <code>ChannelId</code> is a unique number identifying the channel within its conditions collection. The + * channels in the database are given sequential channel IDs from 1 to N in semi-arbitrary order. The channel ID is + * generally the number used to connect other conditions objects such as {@link EcalGain} or {@link EcalCalibration} + * to the appropriate crystal in the calorimeter. */ public static final class ChannelId extends AbstractIdentifier { @@ -187,7 +194,8 @@ /** * Create a channel ID. - * @param values The values (size 0 with single int value). + * + * @param values the values (size 0 with single int value) */ public ChannelId(int[] values) { id = values[0]; @@ -195,7 +203,8 @@ /** * Encode as long value (just returns the int value). - * @return The ID's value. + * + * @return the ID's value encoded as a <code>long</code> */ @Override public long encode() { @@ -203,8 +212,9 @@ } /** - * True if ID looks valid. - * @return True if ID looks valid. + * Return <code>true</code> if ID is valid + * + * @return <code>true</code> if ID is valid */ @Override public boolean isValid() { @@ -213,25 +223,28 @@ } /** - * Create a {@link DaqId} for this ECAL channel. - * @return The DAQ Id for this ECAL channel. + * Create a {@link #DaqId} for this ECAL channel. + * + * @return the {@link #DaqId} for this ECAL channel */ DaqId createDaqId() { return new DaqId(new int[] { getCrate(), getSlot(), getChannel() }); } /** - * Create a {@link GeometryId} for this ECAL channel. - * @param helper The ID helper. - * @param system The subdetector system ID. - * @return The geometry ID. - */ - GeometryId createGeometryId(IIdentifierHelper helper, int system) { + * Create a {@link #GeometryId} for this ECAL channel. + * + * @param helper the ID helper + * @param system the subdetector system ID + * @return the geometry ID + */ + GeometryId createGeometryId(final IIdentifierHelper helper, final int system) { return new GeometryId(helper, new int[] { system, getX(), getY() }); } /** * Create a channel ID for this ECAL channel. + * * @return The channel ID. */ ChannelId createChannelId() { @@ -244,30 +257,29 @@ public static class EcalChannelCollection extends BaseConditionsObjectCollection<EcalChannel> { /** - * Map of {@link DaqId} to channel object. + * Map of {@link #DaqId} to channel object. */ private Map<Long, EcalChannel> daqMap = new HashMap<Long, EcalChannel>(); - - /** - * Map of {@link GeometryId} to channel object. + + /** + * Map of {@link #GeometryId} to channel object. */ private Map<Long, EcalChannel> geometryMap = new HashMap<Long, EcalChannel>(); - - /** - * Map of {@link ChannelId} to channel object. - */ - Map<Long, EcalChannel> channelMap = new HashMap<Long, EcalChannel>(); - - /** - * Add an <code>EcalChannel</code> to the collection and cache its ID - * information. The GeometryId must be created later as it requires - * access to the Detector API. - * - * @param channel The ECAL channel object. - * @return True if object was added successfully. - */ - @Override - public boolean add(final EcalChannel channel) { + + /** + * Map of {@link #ChannelId} to channel object. + */ + private Map<Long, EcalChannel> channelMap = new HashMap<Long, EcalChannel>(); + + /** + * Add an <code>EcalChannel</code> to the collection and cache its ID information. The GeometryId must be + * created later as it requires access to the Detector API. + * + * @param channel the ECAL channel object + * @return <code>true</code> if object was added successfully + */ + @Override + public boolean add(final EcalChannel channel) { super.add(channel); final DaqId daqId = channel.createDaqId(); if (daqId.isValid()) { @@ -281,9 +293,10 @@ } /** - * Build the map of {@link GeometryId} objects. - * @param helper The identifier helper of the subdetector. - * @param system The system ID of the subdetector. + * Build the map of {@link #GeometryId} objects. + * + * @param helper the ID helper of the subdetector + * @param system the system ID of the subdetector */ void buildGeometryMap(final IIdentifierHelper helper, final int system) { for (EcalChannel channel : this) { @@ -294,8 +307,9 @@ /** * Find a channel by using DAQ information. - * @param daqId The DAQ ID object. - * @return The matching channel or null if does not exist. + * + * @param daqId the DAQ ID object + * @return the matching channel or <code>null</code> if does not exist. */ public EcalChannel findChannel(final DaqId daqId) { return daqMap.get(daqId.encode()); @@ -303,8 +317,9 @@ /** * Find a channel by using its physical ID information. - * @param geometryId The geometric ID object. - * @return The matching channel or null if does not exist. + * + * @param geometryId the geometric ID object + * @return the matching channel or <code>null</code> if does not exist */ public EcalChannel findChannel(final GeometryId geometryId) { return geometryMap.get(geometryId.encode()); @@ -312,8 +327,9 @@ /** * Find a channel by its channel ID. - * @param channelId The channel ID object. - * @return The matching channel or null if does not exist. + * + * @param channelId the channel ID object + * @return the matching channel or <code>null</code> if does not exist */ public EcalChannel findChannel(final ChannelId channelId) { return channelMap.get(channelId.encode()); @@ -321,8 +337,9 @@ /** * Find a channel by its encoded geometric ID. - * @param id The encoded geometric ID. - * @return The matching channel or null if does not exist. + * + * @param id the encoded geometric ID + * @return the matching channel or <code>null</code> if does not exist */ public EcalChannel findGeometric(final long id) { return geometryMap.get(id); @@ -330,8 +347,9 @@ /** * Find a channel by its encoded channel ID. - * @param id The encoded channel ID. - * @return The matching channel or null if does not exist. + * + * @param id the encoded channel ID + * @return the matching channel or <code>null</code> if does not exist */ public EcalChannel findChannel(final long id) { return channelMap.get(id); @@ -339,16 +357,18 @@ /** * Find a channel by its encoded DAQ ID. - * @param id The encoded DAQ ID. - * @return The matching channel or null if does not exist. + * + * @param id the encoded DAQ ID + * @return the matching channel or <code>null</code> if does not exist */ public EcalChannel findDaq(final long id) { return daqMap.get(id); - } + } /** * Sort collection and return but do not sort in place. - * @return The sorted copy of the collection. + * + * @return the sorted copy of the collection */ public BaseConditionsObjectCollection<EcalChannel> sorted() { return sorted(new ChannelIdComparator()); @@ -360,9 +380,10 @@ class ChannelIdComparator implements Comparator<EcalChannel> { /** * Compare two ECAL channel objects using their channel ID. - * @param c1 The first object. - * @param c2 The second object. - * @return -1, 0, or 1 if first channel is less than, equal to or greater than second. + * + * @param c1 the first object + * @param c2 the second object + * @return -1, 0, or 1 if first channel is less than, equal to or greater than second */ public int compare(EcalChannel c1, EcalChannel c2) { if (c1.getChannelId() < c2.getChannelId()) { @@ -378,63 +399,69 @@ /** * Get the crate number of the channel. - * @return The crate number. - * - */ - @Field(names = {"crate"}) + * + * @return the crate number + */ + @Field(names = { "crate" }) public int getCrate() { return getFieldValue("crate"); } /** * Get the slot number of the channel. - * @return The slot number. - */ - @Field(names = {"slot"}) + * + * @return the slot number + */ + @Field(names = { "slot" }) public int getSlot() { return getFieldValue("slot"); } /** * Get the channel number of the channel. - * @return The channel number. - */ - @Field(names = {"channel"}) + * + * @return the channel number + */ + @Field(names = { "channel" }) public int getChannel() { return getFieldValue("channel"); } /** * Get the x value of the channel. - * @return The x value. - */ - @Field(names = {"x"}) + * + * @return the x value + */ + @Field(names = { "x" }) public int getX() { return getFieldValue("x"); } /** * Get the y value of the channel. - * @return The y value. - */ - @Field(names = {"y"}) + * + * @return the y value + */ + @Field(names = { "y" }) public int getY() { return getFieldValue("y"); } /** * Get the ID of the channel. - * @return The ID of the channel. - */ - @Field(names = {"channel_id"}) + * + * @return the ID of the channel + */ + @Field(names = { "channel_id" }) public int getChannelId() { return getFieldValue("channel_id"); } /** * Implementation of equals. - * @param o The object to compare equality to. - * @return True if objects are equal. + * + * @param o the object to compare equality to + * @return <code>true</code> if objects are equal */ public boolean equals(final Object o) { if (o == null) { @@ -447,7 +474,7 @@ return true; } final EcalChannel c = (EcalChannel) o; - return c.getChannelId() == getChannelId() && c.getCrate() == getCrate() && c.getSlot() == getSlot() + return c.getChannelId() == getChannelId() && c.getCrate() == getCrate() && c.getSlot() == getSlot() && c.getChannel() == getChannel() && c.getX() == getX() && c.getY() == getY(); } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java Mon Apr 6 18:17:40 2015 @@ -1,17 +1,13 @@ package org.hps.conditions.ecal; /** - * This class represents ECAL conditions per channel. - * <p> - * It is an aggregation of various ECAL conditions objects - * that are associated to a single channel. + * This class represents the conditions of a single ECAL channel such as a calibration and gain. * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> * @see EcalGain * @see EcalCalibration * @see EcalTimeShift * @see EcalBadChannel - * - * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ public final class EcalChannelConstants { @@ -19,17 +15,17 @@ * The channel {@link EcalGain} conditions. */ private EcalGain gain = null; - + /** * The channel {@link EcalCalibration} conditions. */ private EcalCalibration calibration = null; - + /** * The channel {@link EcalTimeShift} conditions. */ private EcalTimeShift timeShift = null; - + /** * True if channel is bad and should not be used for reconstruction. */ @@ -43,7 +39,8 @@ /** * Set the gain. - * @param gain The gain object. + * + * @param gain the new gain object */ void setGain(final EcalGain gain) { this.gain = gain; @@ -51,7 +48,8 @@ /** * Set the calibration. - * @param calibration The calibration object. + * + * @param calibration the new calibration object */ void setCalibration(final EcalCalibration calibration) { this.calibration = calibration; @@ -59,7 +57,8 @@ /** * Set the time shift. - * @param timeShift the time shift + * + * @param timeShift the new time shift */ void setTimeShift(final EcalTimeShift timeShift) { this.timeShift = timeShift; @@ -67,6 +66,7 @@ /** * Set whether this is a bad channel. + * * @param badChannel set to true to flag channel as bad */ void setBadChannel(final boolean badChannel) { @@ -75,6 +75,7 @@ /** * Get the gain. + * * @return The gain. */ public EcalGain getGain() { @@ -83,6 +84,7 @@ /** * Get the calibration. + * * @return The calibration. */ public EcalCalibration getCalibration() { @@ -91,6 +93,7 @@ /** * Get the time shift. + * * @return The time shift. */ public EcalTimeShift getTimeShift() { @@ -99,6 +102,7 @@ /** * True if this is a bad channel. + * * @return True if channel is bad. */ public boolean isBadChannel() { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java Mon Apr 6 18:17:40 2015 @@ -44,7 +44,7 @@ /** * Class constructor. - * @param subdetector The ECAL subdetector object. + * @param subdetector the ECAL subdetector object */ EcalConditions(final Subdetector subdetector) { if (subdetector == null) { @@ -55,7 +55,7 @@ /** * Set the channel map. - * @param channelCollection The channel map. + * @param channelCollection the channel map */ void setChannelCollection(final EcalChannelCollection channelCollection) { this.channelCollection = channelCollection; @@ -66,7 +66,7 @@ /** * Get the map between database IDs and <code>EcalChannel</code> objects. - * @return The channel map. + * @return the channel map */ public EcalChannelCollection getChannelCollection() { return channelCollection; @@ -74,8 +74,8 @@ /** * Get the channel information for a geometric crystal. - * @param crystal The geometric crystal. - * @return The channel information or null if does not exist. + * @param crystal the geometric crystal + * @return the channel information or null if does not exist */ public EcalChannel getChannel(final EcalCrystal crystal) { return crystalMap.getEcalChannel(crystal); @@ -85,9 +85,9 @@ * Get the conditions constants for a specific channel. These will be * created if they do not exist for the given channel, BUT only channels in * the channel map are accepted as an argument. - * @param channel The ECAL channel. - * @return The conditions constants for the channel. - * @throws IllegalArgumentException if channel does not exist in the channel map. + * @param channel the ECAL channel + * @return the conditions constants for the channel + * @throws IllegalArgumentException if channel does not exist in the channel map */ public EcalChannelConstants getChannelConstants(final EcalChannel channel) { // This channel must come from the map. Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java Mon Apr 6 18:17:40 2015 @@ -18,21 +18,21 @@ * from the database, based on the current run number known by the conditions * manager. * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> * @see EcalConditions * @see EcalChannel * @see EcalGain * @see EcalCalibration * @see EcalBadChannel * @see EcalTimeShift - * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> - * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ public class EcalConditionsConverter implements ConditionsConverter<EcalConditions> { /** * Get the default {@link EcalChannel} collection. - * @param manager The conditions manager. - * @return The default ECAL channel object collection. + * @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(); @@ -40,8 +40,8 @@ /** * Get the default {@link EcalGain} collection. - * @param manager The conditions manager. - * @return The ECAL channel gain collection. + * @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(); @@ -49,8 +49,8 @@ /** * Get the default collections of {@link EcalBadChannel} objects. - * @param manager The conditions manager. - * @return The collections of ECAL bad channel objects. + * @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"); @@ -58,8 +58,8 @@ /** * Get the default {@link EcalCalibration} collection. - * @param manager The conditions manager. - * @return The collection of ECAL channel calibration objects. + * @param manager the conditions manager + * @return the collection of ECAL channel calibration objects */ protected EcalCalibrationCollection getEcalCalibrationCollection(DatabaseConditionsManager manager) { return manager.getCachedConditions(EcalCalibrationCollection.class, "ecal_calibrations").getCachedData(); @@ -67,8 +67,8 @@ /** * Get the default {@link EcalTimeShift} collection. - * @param manager The conditions manager. - * @return The collection of ECAL time shift objects. + * @param manager the conditions manager + * @return the collection of ECAL time shift objects */ protected EcalTimeShiftCollection getEcalTimeShiftCollection(DatabaseConditionsManager manager) { return manager.getCachedConditions(EcalTimeShiftCollection.class, "ecal_time_shifts").getCachedData(); @@ -76,8 +76,8 @@ /** * Create combined ECAL conditions object containing all data for the current run. - * @param manager The conditions manager. - * @param name The conditions set name (unused but must satisfy conditions API). + * @param manager the conditions manager + * @param name the conditions set name (unused but must satisfy conditions API) */ public final EcalConditions getData(ConditionsManager manager, String name) { @@ -143,7 +143,7 @@ /** * Get the type handled by this converter. - * @return The type handled by this converter. + * @return the type handled by this converter */ public final Class<EcalConditions> getType() { return EcalConditions.class; Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java Mon Apr 6 18:17:40 2015 @@ -21,7 +21,7 @@ /** * Constructor which uses external reference to conditions object. - * @param conditions The ECAL conditions object. + * @param conditions the ECAL conditions object */ public EcalConditionsUtil(final EcalConditions conditions) { this.conditions = conditions; @@ -36,33 +36,33 @@ } /** - * Find a channel object from a cell ID, e.g. from Monte Carlo data. - * @param helper The identifier helper of the hit. - * @param cellId The cell ID of the hit. - * @return The corresponding ECAL channel found from the physical ID information. + * Find a channel object from a cell ID, e.g. from a <code>CalorimeterHit</code>. + * @param helper the identifier helper of the hit + * @param cellId the cell ID of the hit + * @return the corresponding ECAL channel found from the physical (geometric) ID information */ public EcalChannel findChannel(final IIdentifierHelper helper, final long cellId) { - // Make an ID object from hit ID. + // Make an ID object from the hit ID. final IIdentifier id = new Identifier(cellId); - // Get physical field values. + // Get the geometric field values which are subdetector ID and crystal indices. final int system = helper.getValue(id, "system"); final int x = helper.getValue(id, "ix"); final int y = helper.getValue(id, "iy"); - // Create an ID to search for in channel collection. + // Create an ID to searching in the channel collection. final GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y }); - // Find the ECAL channel and return the crate number. + // Find and return the channel object. return conditions.getChannelCollection().findChannel(geometryId); } /** * Get the DAQ crate number from a cell ID. - * @param helper The identifier helper of the hit. - * @param cellId The cell ID of the hit. - * @return The crate number of the channel. + * @param helper the identifier helper of the hit + * @param cellId the cell ID of the hit + * @return the crate number of the channel */ public int getCrate(final IIdentifierHelper helper, final long cellId) { return findChannel(helper, cellId).getCrate(); @@ -70,9 +70,9 @@ /** * Get the DAQ slot number from a cell ID. - * @param helper The identifier helper of the hit. - * @param cellId The cell ID of the hit. - * @return The slot number of the channel. + * @param helper the identifier helper of the hit + * @param cellId the cell ID of the hit + * @return the slot number of the channel */ public int getSlot(final IIdentifierHelper helper, final long cellId) { return findChannel(helper, cellId).getSlot(); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCrystalChannelMap.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCrystalChannelMap.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCrystalChannelMap.java Mon Apr 6 18:17:40 2015 @@ -19,17 +19,17 @@ /** * Map of crystal to channel. */ - Map<EcalCrystal, EcalChannel> crystalMap = new HashMap<EcalCrystal, EcalChannel>(); - + private Map<EcalCrystal, EcalChannel> crystalMap = new HashMap<EcalCrystal, EcalChannel>(); + /** * Map of channel to crystal. */ - Map<EcalChannel, EcalCrystal> channelMap = new HashMap<EcalChannel, EcalCrystal>(); + private Map<EcalChannel, EcalCrystal> channelMap = new HashMap<EcalChannel, EcalCrystal>(); /** * Creates the map between crystals and channels. - * @param api The ECAL API. - * @param channels The list of channels. + * @param api the ECAL geometry API + * @param channels the list of channels */ EcalCrystalChannelMap(final HPSEcalAPI api, final EcalChannelCollection channels) { @@ -46,7 +46,7 @@ for (EcalChannel channel : channels) { final EcalCrystal crystal = api.getCrystal(channel.getX(), channel.getY()); if (crystal == null) { - throw new RuntimeException("ECAl crystal was not found for channel X Y: " + throw new RuntimeException("ECAl crystal was not found for channel X Y: " + channel.getX() + " " + channel.getY()); } channelMap.put(channel, crystal); @@ -55,19 +55,19 @@ /** * Get a channel from a crystal. - * @param crystal The geometry object. - * @return The channel information or null if does not exist. + * @param crystal the crystal's geometry object + * @return the channel information or <code>null</code> if does not exist */ EcalChannel getEcalChannel(final EcalCrystal crystal) { return crystalMap.get(crystal); - } + } /** - * Get a channel from a crystal. - * @param crystal The geometry object. - * @return The channel information or null if does not exist. + * Get a crystal from a channel. + * @param channel the ECAL channel object + * @return the crystal's geometry object or <code>null</code> if does not exist */ EcalCrystal getEcalCrystal(final EcalChannel channel) { return channelMap.get(channel); } -} +} Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalGain.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalGain.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalGain.java Mon Apr 6 18:17:40 2015 @@ -11,7 +11,7 @@ /** * A per channel ECAL gain value. - * + * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @Table(names = { "ecal_gains", "test_run_ecal_gains", "ecal_hardware_gains" }) @@ -58,7 +58,7 @@ /** * Get the gain value in units of MeV/ADC count. * - * @return The gain value. + * @return the gain value */ @Field(names = { "gain" }) public double getGain() { @@ -68,7 +68,7 @@ /** * Get the ECal channel ID. * - * @return The ECal channel ID. + * @return the ECal channel ID */ @Field(names = { "ecal_channel_id" }) public int getChannelId() { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalLed.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalLed.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalLed.java Mon Apr 6 18:17:40 2015 @@ -11,9 +11,8 @@ import org.hps.conditions.ecal.EcalGain.EcalGainCollection.ChannelIdComparator; /** - * A conditions class for representing the setup of the LED system in the ECAL - * for one channel. - * + * A conditions class for representing the setup of the LED system in the ECAL for one channel. + * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @Table(names = "ecal_leds") @@ -23,24 +22,30 @@ /** * Generic collection class for these objects. */ + @SuppressWarnings("serial") public static class EcalLedCollection extends BaseConditionsObjectCollection<EcalLed> { - + /** * Sort and return a copy of this collection. - * @return The sorted copy. + * + * @return the new sorted collection */ public BaseConditionsObjectCollection<EcalLed> sorted() { return sorted(new ChannelIdComparator()); } - + /** * Comparison implementation by channel ID. */ class ChannelIdComparator implements Comparator<EcalLed> { /** * Compare two objects by channel ID. + * + * @param o1 the first object + * @param o2 the second object + * @return -1, 0, or 1 if first channel ID is less than, equal to or greater than the first */ - public int compare(EcalLed o1, EcalLed o2) { + public int compare(final EcalLed o1, final EcalLed o2) { if (o1.getEcalChannelId() < o2.getEcalChannelId()) { return -1; } else if (o1.getEcalChannelId() > o2.getEcalChannelId()) { @@ -49,60 +54,66 @@ return 0; } } - + } } /** * Get the ECAL channel ID. - * @return The ECAL channel ID. + * + * @return the ECAL channel ID */ - @Field(names = {"ecal_channel_id"}) + @Field(names = { "ecal_channel_id" }) public int getEcalChannelId() { return getFieldValue("ecal_channel_id"); } /** * Get the crate number assigned to this crystal. - * @return The crate number. + * + * @return the crate number */ - @Field(names = {"crate"}) + @Field(names = { "crate" }) public int getCrateNumber() { return getFieldValue("crate"); } /** * Get the LED number assigned to this crystal. - * @return The LED number. + * + * @return the LED number */ - @Field(names = {"number"}) + @Field(names = { "number" }) public int getLedNumber() { return getFieldValue("number"); } /** * Get the time delay of this channel. - * @return The time delay. + * + * @return the time delay */ - @Field(names = {"time_delay"}) + @Field(names = { "time_delay" }) public double getTimeDelay() { return getFieldValue("time_delay"); } /** * Get the amplitude high setting. - * @return The amplitude high setting. + * + * @return the amplitude high setting */ - @Field(names = {"amplitude_high"}) + @Field(names = { "amplitude_high" }) public double getAmplitudeHigh() { return getFieldValue("amplitude_high"); } /** * Get the amplitude low setting. - * @return The amplitude low setting. + * + * @return the amplitude low setting */ - @Field(names = {"amplitude_low"}) + @Field(names = { "amplitude_low" }) public double getAmplitudeLow() { return getFieldValue("amplitude_low"); } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalLedCalibration.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalLedCalibration.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalLedCalibration.java Mon Apr 6 18:17:40 2015 @@ -9,7 +9,7 @@ /** * ECAL LED calibration information per channel. - * + * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @Table(names = "ecal_led_calibrations") @@ -31,38 +31,43 @@ /** * Fully qualified constructor. - * @param channelId The ECAL channel ID (not the LED channel ID). - * @param ledResponse The mean of the LED response. - * @param rms The RMS of the LED response. + * + * @param channelId the ECAL channel ID (not the LED channel ID) + * @param ledResponse the mean of the LED response + * @param rms the RMS of the LED response */ - public EcalLedCalibration(int channelId, double ledResponse, double rms) { + public EcalLedCalibration(final int channelId, final double ledResponse, final double rms) { this.setFieldValue("ecal_channel_id", channelId); this.setFieldValue("led_response", ledResponse); this.setFieldValue("rms", rms); } + /** * Get the ECAL channel ID. + * * @return The ECAL channel ID. */ - @Field(names = {"ecal_channel_id"}) + @Field(names = { "ecal_channel_id" }) public int getEcalChannelId() { return getFieldValue("ecal_channel_id"); } /** - * Get the average led response - * @return The average led response + * Get the average LED response. + * + * @return the average LED response */ - @Field(names = {"led_response"}) + @Field(names = { "led_response" }) public double getLedResponse() { return getFieldValue("led_response"); } /** * Get the RMS of the LED response. - * @return The RMS of the LED response. + * + * @return the RMS of the LED response */ - @Field(names = {"rms"}) + @Field(names = { "rms" }) public int getRms() { return getFieldValue("rms"); } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalTimeShift.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalTimeShift.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalTimeShift.java Mon Apr 6 18:17:40 2015 @@ -11,7 +11,7 @@ /** * This class represents a time shift calibration value for an ECAL channel. - * + * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @Table(names = {"ecal_time_shifts", "test_run_ecal_time_shifts"}) @@ -21,8 +21,9 @@ /** * A collection of {@link EcalTimeShift} objects. */ - public static class EcalTimeShiftCollection extends BaseConditionsObjectCollection<EcalTimeShift> { - + @SuppressWarnings("serial") + public static final class EcalTimeShiftCollection extends BaseConditionsObjectCollection<EcalTimeShift> { + /** * Sort and return a copy of the collection. * @return The sorted copy of the collection. @@ -37,9 +38,9 @@ class ChannelIdComparator implements Comparator<EcalTimeShift> { /** * Compare two objects by channel ID. - * @param o1 The first object. - * @param o2 The second object. - * @return -1, 0 or 1 if first channel ID is less than, equal to, or greater than second. + * @param o1 the first object + * @param o2 the second object + * @return -1, 0 or 1 if first channel ID is less than, equal to, or greater than second */ public int compare(EcalTimeShift o1, EcalTimeShift o2) { if (o1.getChannelId() < o2.getChannelId()) { @@ -55,7 +56,7 @@ /** * Get the channel ID. - * @return The ECAL channel ID. + * @return the ECAL channel ID */ @Field(names = {"ecal_channel_id"}) public int getChannelId() { @@ -63,8 +64,8 @@ } /** - * Get the time shift in nanoseconds. - * @return The time shift in nanoseconds. + * Get the time shift in nanoseconds + * @return the time shift in nanoseconds */ @Field(names = {"time_shift"}) public double getTimeShift() { Modified: java/trunk/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java Mon Apr 6 18:17:40 2015 @@ -12,7 +12,7 @@ * This class loads all Test Run ECAL conditions into an {@link EcalConditions} object * from the database. * <p> - * The default names are overridden to use tables that contain Test Run data, only. + * The default names are overridden to use tables that contain only Test Run data. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> @@ -21,14 +21,16 @@ /** * Get the {@link EcalChannel} collection for Test Run. - * @return The Test Run ECAL channel collection. + * @param manager the conditions manager + * @return the Test Run ECAL channel collection */ protected EcalChannelCollection getEcalChannelCollection(DatabaseConditionsManager manager) { return manager.getCachedConditions(EcalChannelCollection.class, "test_run_ecal_channels").getCachedData(); } /** * Get the {@link EcalGain} collection for Test Run. - * @return The Test Run ECAL gain collection. + * @param manager the conditions manager + * @return the Test Run ECAL gain collection */ protected EcalGainCollection getEcalGainCollection(DatabaseConditionsManager manager) { return manager.getCachedConditions(EcalGainCollection.class, "test_run_ecal_gains").getCachedData(); @@ -36,7 +38,8 @@ /** * Get the collections of {@link EcalBadChannel} objects for Test Run. - * @return The Test Run bad channel collections. + * @param manager the conditions manager + * @return the Test Run bad channel collections */ protected ConditionsSeries<EcalBadChannel, EcalBadChannelCollection> getEcalBadChannelSeries(DatabaseConditionsManager manager) { return manager.getConditionsSeries(EcalBadChannelCollection.class, "test_run_ecal_bad_channels"); @@ -44,7 +47,8 @@ /** * Get the {@link EcalCalibration} collection for Test Run. - * @return The Test Run ECAL calibration collection. + * @param manager the conditions manager + * @return the Test Run ECAL calibration collection */ protected EcalCalibrationCollection getEcalCalibrationCollection(DatabaseConditionsManager manager) { return manager.getCachedConditions(EcalCalibrationCollection.class, "test_run_ecal_calibrations").getCachedData(); @@ -52,7 +56,8 @@ /** * Get the {@link EcalTimeShift} collection for Test Run. - * @return The Test Run ECAL time shift collection. + * @param manager the conditions manager + * @return the Test Run ECAL time shift collection */ protected EcalTimeShiftCollection getEcalTimeShiftCollection(DatabaseConditionsManager manager) { return manager.getCachedConditions(EcalTimeShiftCollection.class, "test_run_ecal_time_shifts").getCachedData(); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/package-info.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/package-info.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/package-info.java Mon Apr 6 18:17:40 2015 @@ -3,9 +3,8 @@ * using a framework built on the LCSim conditions system. The {@link DatabaseConditionsReader} has a set of * converters for reading data from tables using SQL queries and creating appropriate, typed objects for them. * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> * @see org.hps.conditions.api * @see org.hps.conditions.database - * - * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ package org.hps.conditions; Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtChannel.java Mon Apr 6 18:17:40 2015 @@ -11,63 +11,77 @@ /** * This abstract class provides basic setup information for an SVT sensor channel. - * - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -public class AbstractSvtChannel extends BaseConditionsObject { +public abstract class AbstractSvtChannel extends BaseConditionsObject { - // TODO: Put constants into their own class + /** + * Default number of samples to read out. + */ + // TODO: Put constants into their own class. public static final int MAX_NUMBER_OF_SAMPLES = 6; - public static abstract class AbstractSvtChannelCollection<T extends AbstractSvtChannel> extends BaseConditionsObjectCollection<T> { - - Map<Integer, T> channelMap = new HashMap<Integer, T>(); + /** + * Collection implementation for {@link AbstractSvtChannel}. + * + * @param <T> A type extending AbstractSvtChannel + */ + @SuppressWarnings("serial") + public abstract static class AbstractSvtChannelCollection<T extends AbstractSvtChannel> + extends BaseConditionsObjectCollection<T> { /** - * Add a channel of type extending {@link AbstractSvtChannel} to the - * channel map - * - * @param A channel of a type extending {@link AbstractSvtChannel} + * Map of channel number to object. */ - public boolean add(T channel) { + private Map<Integer, T> channelMap = new HashMap<Integer, T>(); + + /** + * Add a channel of type extending {@link AbstractSvtChannel} to the channel map. + * + * @param channel channel of a type extending {@link AbstractSvtChannel} + */ + @Override + public final boolean add(final T channel) { // If it doesn't exist, add the channel to the channel map if (channelMap.containsKey(channel.getChannelID())) { - throw new IllegalArgumentException("[ " + this.getClass().getSimpleName() + " ]: Channel ID already exists: " + channel.getChannelID()); + throw new IllegalArgumentException("[ " + this.getClass().getSimpleName() + + " ]: Channel ID already exists: " + channel.getChannelID()); } channelMap.put(channel.getChannelID(), channel); // Add to the collection - return super.add(channel); + return super.add(channel); } /** - * Find a channel of type extending {@link AbstractSvtChannel} using the - * channel ID - * - * @param channelID - * @return An SVT channel of type extending {@link AbstractSvtChannel} + * Find a channel of type extending {@link AbstractSvtChannel} using the channel ID. + * + * @param channelID the channel ID + * @return an SVT channel of type extending {@link AbstractSvtChannel} */ - public T findChannel(int channelID) { + public final T findChannel(final int channelID) { return channelMap.get(channelID); } /** - * Find the collection of channels of type extending - * {@link AbstractSvtChannel} that match a DAQ pair. - * - * @param pair The DAQ pair. - * @return The channels matching the DAQ pair or null if not found. + * Find the collection of channels of type extending {@link AbstractSvtChannel} that match a DAQ pair + * (FEB ID and FEB Hybrid ID). + * + * @param pair the DAQ pair + * @return the channels matching the DAQ pair or null if not found */ - public abstract Collection<T> find(Pair<Integer, Integer> pair); + public abstract Collection<T> find(final Pair<Integer, Integer> pair); /** * Convert this object to a human readable string. - * + * * @return This object converted to a string. */ - public String toString() { - StringBuffer buff = new StringBuffer(); + @Override + public final String toString() { + final StringBuffer buff = new StringBuffer(); for (T channel : this) { buff.append(channel.toString() + '\n'); } @@ -77,39 +91,39 @@ /** * Get the channel ID. - * - * @return The SVT channel ID. + * + * @return the SVT channel ID */ @Field(names = {"channel_id"}) - public int getChannelID() { + public final int getChannelID() { return getFieldValue("channel_id"); } /** * Get the channel number (0-639). This is different from the ID. - * - * @return The channel number. + * + * @return the channel number */ @Field(names = {"channel"}) - public int getChannel() { + public final int getChannel() { return getFieldValue("channel"); } - + /** * Set the channel ID. - * - * @param channelID : The SVT channel ID + * + * @param channelID the SVT channel ID */ - public void setChannelID(int channelID) { + public final void setChannelID(final int channelID) { this.setFieldValue("channel_id", channelID); } - + /** * Set the channel number (0-639). This is different from the ID. - * - * @param channel : The channel number + * + * @param channel the channel number */ - public void setChannel(int channel) { + public final void setChannel(final int channel) { this.setFieldValue("channel", channel); } -} +} Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditions.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditions.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditions.java Mon Apr 6 18:17:40 2015 @@ -8,22 +8,39 @@ import org.hps.conditions.svt.AbstractSvtT0Shift.AbstractSvtT0ShiftCollection; /** - * Abstract class providing some of the common functionality used to define an - * SVT conditions object + * Abstract class providing some of the common functionality used to define an SVT conditions object. * - * @author Omar Moreno <[log in to unmask]> - * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ public abstract class AbstractSvtConditions { - protected Map<AbstractSvtChannel, ChannelConstants> channelData = new HashMap<AbstractSvtChannel, ChannelConstants>(); + /** + * A map between the channel object and its conditions constants. + */ + private Map<AbstractSvtChannel, ChannelConstants> channelData = + new HashMap<AbstractSvtChannel, ChannelConstants>(); + + /** + * The time shift collection. + */ + // FIXME: Should be private with accessor methods. protected AbstractSvtT0Shift.AbstractSvtT0ShiftCollection<? extends AbstractSvtT0Shift> t0Shifts = null; + + /** + * The channel map. + */ + // FIXME: Should be private with accessor methods. protected AbstractSvtChannel.AbstractSvtChannelCollection<? extends AbstractSvtChannel> channelMap = null; + + /** + * The SVT DAQ mapping. + */ + // FIXME: Should be private with accessor methods. protected AbstractSvtDaqMapping.AbstractSvtDaqMappingCollection<? extends AbstractSvtDaqMapping> daqMap = null; /** * Get the DAQ map associated with these conditions. - * + * * @return The SVT DAQ map. */ public abstract AbstractSvtDaqMappingCollection<? extends AbstractSvtDaqMapping> getDaqMap(); @@ -32,61 +49,62 @@ * Get the conditions constants for a specific channel. These will be * created if they do not exist for the given channel, BUT only channels in * the current channel map are allowed as an argument. - * - * @param channel The SVT channel of interest - * @return The conditions constants for the given channel - * @throws IllegalArgumentException if . + * + * @param channel the SVT channel of interest + * @return the conditions constants for the given channel + * @throws IllegalArgumentException if channel was not found in map */ - public ChannelConstants getChannelConstants(AbstractSvtChannel channel) { + public final ChannelConstants getChannelConstants(final AbstractSvtChannel channel) { // This channel must come from the map. if (!channelMap.contains(channel)) { System.err.println("[ " + this.getClass().getSimpleName() + " ]: Channel not found in map => " + channel); throw new IllegalArgumentException("Channel was not found in map."); } // If channel has no data yet, then add it. - if (!channelData.containsKey(channel)) + if (!channelData.containsKey(channel)) { channelData.put(channel, new ChannelConstants()); + } return channelData.get(channel); } /** * Get the channel map for this set of conditions. - * - * @return The SVT channel map. + * + * @return the SVT channel map */ public abstract AbstractSvtChannelCollection<? extends AbstractSvtChannel> getChannelMap(); /** * Get the t0 shifts for this conditions set. - * - * @return The t0 shifts by sensor. + * + * @return the t0 shifts by sensor */ public abstract AbstractSvtT0ShiftCollection<? extends AbstractSvtT0Shift> getT0Shifts(); /** * Set the DAQ map for this conditions set. - * - * @param daqMap DAQ map for this conditions set. + * + * @param daqMap DAQ map for this conditions set */ - public void setDaqMap(AbstractSvtDaqMappingCollection<? extends AbstractSvtDaqMapping> daqMap) { + public final void setDaqMap(final AbstractSvtDaqMappingCollection<? extends AbstractSvtDaqMapping> daqMap) { this.daqMap = daqMap; } /** * Set the SVT channel map for this conditions set. - * - * @param channelMap The SVT channel map for this conditions set. + * + * @param channelMap the SVT channel map for this conditions set */ - public void setChannelMap(AbstractSvtChannelCollection<? extends AbstractSvtChannel> channelMap) { + public final void setChannelMap(final AbstractSvtChannelCollection<? extends AbstractSvtChannel> channelMap) { this.channelMap = channelMap; } /** * Set the sensor t0 shifts for this conditions set. - * - * @param t0Shifts for this conditions set. + * + * @param t0Shifts for this conditions set */ - public void setT0Shifts(AbstractSvtT0ShiftCollection<? extends AbstractSvtT0Shift> t0Shifts) { + public final void setT0Shifts(final AbstractSvtT0ShiftCollection<? extends AbstractSvtT0Shift> t0Shifts) { this.t0Shifts = t0Shifts; } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditionsConverter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditionsConverter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditionsConverter.java Mon Apr 6 18:17:40 2015 @@ -16,65 +16,105 @@ /** * Abstract class providing some of the common methods used in creating SVT * conditions objects from the database. - * - * @author Omar Moreno <[log in to unmask]> * - * @param <T extends AbstractSvtConditions> SVT conditions object type + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> + * @param <T> SVT conditions object type */ public abstract class AbstractSvtConditionsConverter<T extends AbstractSvtConditions> implements ConditionsConverter<T> { + /** + * The combined detector conditions object. + */ + // FIXME: Should be private with accessor methods. protected T conditions; + + /** + * Initialize logging. + */ static Logger logger = LogUtil.create(AbstractSvtConditionsConverter.class); - protected SvtShapeFitParametersCollection getSvtShapeFitParametersCollection(DatabaseConditionsManager manager) { + /** + * Get the default {@link SvtShapeFitParametersCollection} collection from the manager. + * @param manager the current conditions manager + * @return the default {@link SvtShapeFitParametersCollection} + */ + protected SvtShapeFitParametersCollection getSvtShapeFitParametersCollection(final DatabaseConditionsManager manager) { return manager.getCachedConditions(SvtShapeFitParametersCollection.class, "svt_shape_fit_parameters").getCachedData(); } - - protected SvtBadChannelCollection getSvtBadChannelCollection(DatabaseConditionsManager manager) { + + /** + * Get the default {@link SvtBadChannelCollection} collection from the manager. + * @param manager the current conditions manager + * @return the default {@link SvtBadChannelCollection} + */ + protected SvtBadChannelCollection getSvtBadChannelCollection(final DatabaseConditionsManager manager) { return manager.getCachedConditions(SvtBadChannelCollection.class, "svt_bad_channels").getCachedData(); } - - protected ConditionsSeries<SvtBadChannel, SvtBadChannelCollection> getSvtBadChannelSeries(DatabaseConditionsManager manager) { + + /** + * Get the default series of {@link SvtBadChannelCollection} collections from the manager. + * @param manager the current conditions manager + * @return the default series of {@link SvtBadChannelCollection} + */ + protected ConditionsSeries<SvtBadChannel, SvtBadChannelCollection> getSvtBadChannelSeries(final DatabaseConditionsManager manager) { return manager.getConditionsSeries(SvtBadChannelCollection.class, "svt_bad_channels"); } - - protected SvtCalibrationCollection getSvtCalibrationCollection(DatabaseConditionsManager manager) { + + /** + * Get the default {@link SvtCalibrationCollection} collection from the manager. + * @param manager the current conditions manager + * @return the default {@link SvtCalibrationCollection} + */ + protected SvtCalibrationCollection getSvtCalibrationCollection(final DatabaseConditionsManager manager) { return manager.getCachedConditions(SvtCalibrationCollection.class, "svt_calibrations").getCachedData(); } - - protected SvtGainCollection getSvtGainCollection(DatabaseConditionsManager manager) { + + /** + * Get the default {@link SvtGainCollection} collection from the manager. + * @param manager the current conditions manager + * @return the default {@link SvtGainCollection} + */ + protected SvtGainCollection getSvtGainCollection(final DatabaseConditionsManager manager) { return manager.getCachedConditions(SvtGainCollection.class, "svt_gains").getCachedData(); } - + /** * Create and return the SVT conditions object. - * @param manager The current conditions manager. - * @param name The conditions key, which is ignored for now. + * + * @param manager the current conditions manager + * @param name the conditions key, which is ignored for now + * @return the SVT conditions object */ - public T getData(ConditionsManager manager, String name) { + @Override + public T getData(final ConditionsManager manager, final String name) { - DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager; + final DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager; // Get the SVT calibrations (baseline, noise) from the conditions database - SvtCalibrationCollection calibrations = getSvtCalibrationCollection(dbConditionsManager); + final SvtCalibrationCollection calibrations = getSvtCalibrationCollection(dbConditionsManager); for (SvtCalibration calibration : calibrations) { - AbstractSvtChannel channel = conditions.getChannelMap().findChannel(calibration.getChannelID()); + final AbstractSvtChannel channel = conditions.getChannelMap().findChannel(calibration.getChannelID()); conditions.getChannelConstants(channel).setCalibration(calibration); } // Get the Channel pulse fit parameters from the conditions database - SvtShapeFitParametersCollection shapeFitParametersCollection = getSvtShapeFitParametersCollection(dbConditionsManager); + final SvtShapeFitParametersCollection shapeFitParametersCollection = + getSvtShapeFitParametersCollection(dbConditionsManager); for (SvtShapeFitParameters shapeFitParameters : shapeFitParametersCollection) { - AbstractSvtChannel channel = conditions.getChannelMap().findChannel(shapeFitParameters.getChannelID()); + final AbstractSvtChannel channel = conditions.getChannelMap().findChannel( + shapeFitParameters.getChannelID()); conditions.getChannelConstants(channel).setShapeFitParameters(shapeFitParameters); } - // Get the bad channels from the conditions database. If there aren't any bad channels, notify the user and move on. + // Get the bad channels from the conditions database. + // If there aren't any bad channels, notify the user and move on. try { - ConditionsSeries<SvtBadChannel, SvtBadChannelCollection> badChannelSeries = getSvtBadChannelSeries(dbConditionsManager); + final ConditionsSeries<SvtBadChannel, SvtBadChannelCollection> badChannelSeries = + getSvtBadChannelSeries(dbConditionsManager); for (ConditionsObjectCollection<SvtBadChannel> badChannelCollection : badChannelSeries) { for (SvtBadChannel badChannel : badChannelCollection) { - AbstractSvtChannel channel = conditions.getChannelMap().findChannel(badChannel.getChannelId()); + final AbstractSvtChannel channel = conditions.getChannelMap().findChannel( + badChannel.getChannelId()); conditions.getChannelConstants(channel).setBadChannel(true); } } @@ -83,13 +123,13 @@ } // Get the gains and offsets from the conditions database - SvtGainCollection channelGains = getSvtGainCollection(dbConditionsManager); + final SvtGainCollection channelGains = getSvtGainCollection(dbConditionsManager); for (SvtGain channelGain : channelGains) { - int channelId = channelGain.getChannelID(); - AbstractSvtChannel channel = conditions.getChannelMap().findChannel(channelId); + final int channelId = channelGain.getChannelID(); + final AbstractSvtChannel channel = conditions.getChannelMap().findChannel(channelId); conditions.getChannelConstants(channel).setGain(channelGain); } return conditions; } -} +} 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 Mon Apr 6 18:17:40 2015 @@ -7,110 +7,124 @@ import org.lcsim.detector.tracker.silicon.HpsSiSensor; /** - * This abstract class provides some of the basic functionality used to access - * SVT DAQ map variables. - * - * @author Omar Moreno <[log in to unmask]> + * This abstract class provides some of the basic functionality used to access SVT DAQ map variables. + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ public abstract class AbstractSvtDaqMapping extends BaseConditionsObject { - /** - * Flag values for top or bottom half. - */ - public static final String TOP_HALF = "T"; - public static final String BOTTOM_HALF = "B"; + /** + * 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> { /** - * Flag values for axial or stereo sensors - */ - public static final String AXIAL = "A"; - public static final String STEREO = "S"; - - public static abstract class AbstractSvtDaqMappingCollection<T extends AbstractSvtDaqMapping> extends BaseConditionsObjectCollection<T> { - - - /** - * Get a DAQ pair for the given {@link HpsSiSensor} - * - * @param sensor A sensor of type {@link HpsSiSensor} - * @return The DAQ pair associated with the sensor + * Get a DAQ pair for the given {@link HpsSiSensor}. + * + * @param sensor a sensor of type {@link HpsSiSensor} + * @return the DAQ pair associated with the sensor */ public abstract Pair<Integer, Integer> getDaqPair(HpsSiSensor sensor); /** * Get the orientation of a sensor. - * + * * @param daqPair for a given sensor - * @return If a daqPair is found, return an "A" if the sensor - * orientation is Axial, an "S" if the orientation is Stereo or - * null if the daqPair doesn't exist. + * @return if a daqPair is found, return an "A" if the sensor orientation is Axial, an "S" if the orientation is + * Stereo or null if the daqPair doesn't exist */ public abstract String getOrientation(Pair<Integer, Integer> daqPair); } /** - * Get the SVT half (TOP or BOTTOM) that the sensor belongs to. - * - * @return SVT half (TOP or BOTTOM) + * Get the SVT half (TOP or BOTTOM) that the sensor belongs to. + * + * @return SVT half (TOP or BOTTOM) */ - @Field(names = {"svt_half"}) - public String getSvtHalf() { + @Field(names = { "svt_half" }) + public final String getSvtHalf() { return getFieldValue("svt_half"); } /** - * Get the SVT sensor layer number (1-10 for test run and 1-12 for - * engineering run). - * - * @return SVT sensor layer number + * Get the SVT sensor layer number (1-10 for test run and 1-12 for engineering run). + * + * @return SVT sensor layer number */ - @Field(names = {"layer"}) - public int getLayerNumber() { + @Field(names = { "layer" }) + public final int getLayerNumber() { return getFieldValue("layer"); } - /** - * Get the orientation of an SVT sensor (AXIAL or STEREO). - * - * @param orientation : Orientation of an SVT sensor (AXIAL or STEREO) + * Get the orientation of an SVT sensor (AXIAL or STEREO). + * @see {@link #AXIAL} + * @see {@link #STEREO} + * @return the orientation of the SVT sensor */ - @Field(names = {"orientation"}) - public String getOrientation() { + @Field(names = { "orientation" }) + public final String getOrientation() { return getFieldValue("orientation"); } - + /** - * Set the SVT half (TOP or BOTTOM) that the sensor belongs to. - * - * @param svtHalf : SVT half (TOP or BOTTOM) + * Set the SVT half that the sensor belongs to. + * + * @param svtHalf the SVT half (TOP or BOTTOM) + * @see {@link #TOP_HALF} + * @see {@link #BOTTOM_HALF} */ - public void setSvtHalf(String svtHalf) { - if (!svtHalf.equals(AbstractSvtDaqMapping.TOP_HALF) && !svtHalf.equals(AbstractSvtDaqMapping.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); - + } - + /** - * Set the SVT sensor layer number (1-10 for test run and 1-12 for - * engineering run). - * - * @param layer : SVT sensor layer number + * Set the SVT sensor layer number (1-10 for test run and 1-12 for engineering run). + * + * @param layer : SVT sensor layer number */ - public void setLayerNumber(int layer) { + public final void setLayerNumber(final int layer) { this.setFieldValue("layer", layer); } - + /** - * Set the orientation of an SVT sensor (AXIAL or STEREO). - * - * @param orientation : Orientation of an SVT sensor (AXIAL or STEREO) + * Set the orientation of an SVT sensor (AXIAL or STEREO). + * + * @param orientation : Orientation of an SVT sensor (AXIAL or STEREO) */ - public void setOrientation(String orientation) { - if (!orientation.equals(AbstractSvtDaqMapping.AXIAL) && !orientation.equals(AbstractSvtDaqMapping.STEREO)) + public final void setOrientation(final String orientation) { + if (!orientation.equals(AbstractSvtDaqMapping.AXIAL) && !orientation.equals(AbstractSvtDaqMapping.STEREO)) { throw new RuntimeException("[ " + this.getClass().getSimpleName() + " ]: Invalid orientation of sensor."); + } this.setFieldValue("orientation", orientation); } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtT0Shift.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtT0Shift.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtT0Shift.java Mon Apr 6 18:17:40 2015 @@ -9,30 +9,35 @@ * Abstract class providing some of the basic functionality used to relate a t0 * shift value with either a FEB ID/FEB hybrid ID or an FPGA ID/hybrid ID. * - * @author Omar Moreno <[log in to unmask]> + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -public class AbstractSvtT0Shift extends BaseConditionsObject { +public abstract class AbstractSvtT0Shift extends BaseConditionsObject { - public static abstract class AbstractSvtT0ShiftCollection<T extends AbstractSvtT0Shift> extends BaseConditionsObjectCollection<T> { + /** + * The collection implementation for this class. + * + * @param <T> the type of the object in this collection which extends {@link AbstractSvtT0Shift} + */ + @SuppressWarnings("serial") + public static abstract class AbstractSvtT0ShiftCollection<T extends AbstractSvtT0Shift> + extends BaseConditionsObjectCollection<T> { /** * Get the t0 shift associated with a given DAQ pair - * - * @param DAQ pair for a given sensor - * @return The t0 shift associated with the DAQ pair. If a t0 shift for - * a given DAQ pair can't be found, it returns null. + * + * @param pair the DAQ pair for a given sensor + * @return the t0 shift associated with the DAQ pair or null if not found */ - public abstract T getT0Shift(Pair<Integer, Integer> pair); - + public abstract T getT0Shift(final Pair<Integer, Integer> pair); } /** * Get the t0 shift. - * - * @return The t0 shift. + * + * @return the t0 shift */ @Field(names = {"t0_shift"}) - public double getT0Shift() { + public final double getT0Shift() { return getFieldValue("t0_shift"); } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/CalibrationHandler.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/CalibrationHandler.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/CalibrationHandler.java Mon Apr 6 18:17:40 2015 @@ -3,60 +3,83 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.xml.sax.helpers.DefaultHandler; +import org.hps.conditions.database.DatabaseConditionsManager; +import org.hps.conditions.svt.SvtCalibration.SvtCalibrationCollection; +import org.hps.conditions.svt.SvtChannel.SvtChannelCollection; +import org.lcsim.util.log.DefaultLogFormatter; +import org.lcsim.util.log.LogUtil; import org.xml.sax.Attributes; import org.xml.sax.SAXException; - -import org.lcsim.util.log.DefaultLogFormatter; -import org.lcsim.util.log.LogUtil; - -import org.hps.conditions.svt.SvtChannel.SvtChannelCollection; -import org.hps.conditions.svt.SvtCalibration.SvtCalibrationCollection; -import org.hps.conditions.database.DatabaseConditionsManager; +import org.xml.sax.helpers.DefaultHandler; /** * Handler for calibration events. - * - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ class CalibrationHandler extends DefaultHandler { - - - // Initialize the logger - private static Logger logger = LogUtil.create(SvtConditionsLoader.class.getSimpleName(), + + /** + * Initialize the logger. + */ + private static Logger logger = LogUtil.create(SvtConditionsLoader.class.getSimpleName(), new DefaultLogFormatter(), Level.INFO); - // List of SVT channels + /** + * List of SVT channels. + */ private SvtChannelCollection svtChannels; - // List of SVT calibrations - private SvtCalibrationCollection calibrations - = new SvtCalibrationCollection(); + /** + * List of SVT calibrations. + */ + private SvtCalibrationCollection calibrations = new SvtCalibrationCollection(); - // An SVT calibration object encapsulating the baseline and noise values - // for an SVT channel + /** + * An SVT calibration object encapsulating the baseline and noise values for a channel. + */ private SvtCalibration calibration = null; - - String content; - // FEB ID (0-9) - int febID = 0; - // Hybrid ID (0-3) - int hybridID = 0; - // Hybrid (0-639) - int channel = 0; - // Baseline sample ID (0-5) - int baselineSampleID = 0; - // Noise sample ID (0-5) - int noiseSampleID = 0; - - // Flag denoting whether the calibrations of a given channel should be - // loaded into the conditions DB. If a channel is found to be missing - // baseline or noise values, is will be marked invalid. - boolean isValidChannel = false; - /** - * Default Constructor + * The string content from parsing an XML calibration. + */ + private String content; + + /** + * The FEB ID (0-9). + */ + private int febID = 0; + + /** + * The Hybrid ID (0-3). + */ + private int hybridID = 0; + + /** + * Channel number (0-639). + */ + private int channel = 0; + + /** + * Baseline sample ID (0-5). + */ + private int baselineSampleID = 0; + + /** + * Noise sample ID (0-5). + */ + // FIXME: This variable is unused. + private int noiseSampleID = 0; + + /** + * Flag denoting whether the calibrations of a given channel should be + * loaded into the conditions DB. If a channel is found to be missing + * baseline or noise values, is will be marked invalid. + */ + private boolean isValidChannel = false; + + /** + * Default constructor. */ public CalibrationHandler() { svtChannels = (SvtChannelCollection) DatabaseConditionsManager.getInstance() @@ -65,16 +88,16 @@ /** * 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 Any SAX exception, possibly wrapping another exception. + * + * @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(String uri, String localName, String qName, - Attributes attributes) throws SAXException { + public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) + throws SAXException { switch (qName) { case "Feb": @@ -95,58 +118,62 @@ case "noise": noiseSampleID = Integer.parseInt(attributes.getValue("id")); break; + default: + break; } } - + /** - * Method that is triggered when the end of a tag is encountered. + * 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 Any SAX exception, possibly wrapping another exception. + * @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(String uri, String localName, String qName) - throws SAXException { - - switch (qName) { + public void endElement(final String uri, final String localName, final String qName) + throws SAXException { + + switch (qName) { case "channel": - if (!isValidChannel) break; - calibrations.add(calibration); + if (isValidChannel) { + calibrations.add(calibration); + } break; case "baseline": calibration.setPedestal(baselineSampleID, Double.parseDouble(content)); isValidChannel = true; break; - case "noise": - calibration.setNoise(baselineSampleID, Double.parseDouble(content)); + case "noise": + calibration.setNoise(baselineSampleID, Double.parseDouble(content)); isValidChannel = true; + 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 Any SAX exception, possibly wrapping another exception. + * + * @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 (possibly wraps another exception type) */ @Override - public void characters(char[] ch, int start, int length) - throws SAXException { + public void characters(final char[] ch, final int start, final int length) + throws SAXException { content = String.copyValueOf(ch, start, length).trim(); } - + /** - * Get the collection of {@link SvtCalibration}s built from parsing the - * XML input file. - * - * @return The collection of {@link SvtCalibration}s + * Get the {@link SvtCalibrationCollection} created from parsing the XML input file. + * + * @return the {@link SvtCalibrationCollection} created from parsing the XML */ - public SvtCalibrationCollection getCalibrations() { + public SvtCalibrationCollection getCalibrations() { return calibrations; } -} +} Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/ChannelConstants.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/ChannelConstants.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/ChannelConstants.java Mon Apr 6 18:17:40 2015 @@ -1,17 +1,31 @@ package org.hps.conditions.svt; /** - * This class represents the conditions for a single SVT channel. - * - * @author Omar Moreno <[log in to unmask]> - * @author Jeremy McCormick <[log in to unmask]> + * This class represents the combined conditions for a single SVT channel. * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ public final class ChannelConstants { + /** + * The pedestal and noise for the channel. + */ private SvtCalibration calibration = null; + + /** + * The calculated gain for the channel. + */ private SvtGain gain = null; + + /** + * The shape fit parameters for the channel. + */ private SvtShapeFitParameters shapeFitParameters = null; + + /** + * Flag to indicate the channel is bad and should not be used for reconstruction. + */ private boolean badChannel = false; /** @@ -22,39 +36,44 @@ /** * Set the pulse parameters. - * @param pulseParameters The pulse parameters + * + * @param shapeFitParameters the pulse parameters */ - void setShapeFitParameters(SvtShapeFitParameters shapeFitParameters) { + void setShapeFitParameters(final SvtShapeFitParameters shapeFitParameters) { this.shapeFitParameters = shapeFitParameters; } /** * Set the gain. - * @param gain The gain object. + * + * @param gain the gain object */ - void setGain(SvtGain gain) { + void setGain(final SvtGain gain) { this.gain = gain; } /** * Set the calibration. - * @param calibration The calibration object. + * + * @param calibration the calibration object */ - void setCalibration(SvtCalibration calibration) { + void setCalibration(final SvtCalibration calibration) { this.calibration = calibration; } /** * Set the bad channel flag. - * @param badChannel The bad channel flag value. + * + * @param badChannel the bad channel flag value */ - void setBadChannel(boolean badChannel) { + void setBadChannel(final boolean badChannel) { this.badChannel = badChannel; } /** * Check if this is a bad channel. - * @return True if channel is bad; false if not. + * + * @return <code>true</code> if channel is bad */ public boolean isBadChannel() { return badChannel; @@ -62,7 +81,8 @@ /** * Get the shape fit parameters. - * @return The shape fit parameters. + * + * @return the shape fit parameters */ public SvtShapeFitParameters getShapeFitParameters() { return shapeFitParameters; @@ -70,7 +90,8 @@ /** * Get the gain. - * @return The gain. + * + * @return the gain object */ public SvtGain getGain() { return gain; @@ -78,7 +99,8 @@ /** * Get the calibration. - * @return The calibration. + * + * @return the calibration object */ public SvtCalibration getCalibration() { return calibration; @@ -86,10 +108,11 @@ /** * Convert this object to a string. + * * @return This object converted to a string. */ public String toString() { - StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = new StringBuffer(); buffer.append(getCalibration()); buffer.append(", "); buffer.append(getGain()); 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 Mon Apr 6 18:17:40 2015 @@ -1,150 +1,167 @@ package org.hps.conditions.svt; - -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; import org.hps.conditions.svt.SvtChannel.SvtChannelCollection; import org.hps.conditions.svt.SvtDaqMapping.SvtDaqMappingCollection; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; /** - * Handler for DAQ map events. - * - * @author Omar Moreno <[log in to unmask]> + * Handler for DAQ map events. + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -public class DaqMapHandler extends DefaultHandler { - - // Collection of DAQ map objects +public final class DaqMapHandler extends DefaultHandler { + + /** + * Max number of channels. + */ + // FIXME: Probably this constant could be used from some other class. + private static final int CHANNELS_MAX = 640; + + /** + * The collection of DAQ map objects. + */ private SvtDaqMappingCollection daqMap = new SvtDaqMappingCollection(); - - // Collection of SVT channel objects - private SvtChannelCollection svtChannels = new SvtChannelCollection(); - - // An SVT DAQ map object + + /** + * 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 - String content; - - // Current SVT channel ID. This gets incremented every time an SvtChannel - // gets added to the map. - int currentSvtChannelID = 0; - - - // FEB ID (0-9) - int febID = 0; - // Hybrid ID (0-3) - int hybridID = 0; - + /** - * Default Constructor + * Text node inside of an XML element. */ - public DaqMapHandler() { + private String content; + + /** + * Current SVT channel ID. This gets incremented every time an SvtChannel gets added to the map. + */ + private int currentSvtChannelID = 0; + + /** + * FEB ID (0-9). + */ + private int febID = 0; + + /** + * Hybrid ID (0-3). + */ + private int hybridID = 0; + + /** + * 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 Any SAX exception, possibly wrapping another exception. + * 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(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - + 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); + daqMapping = new SvtDaqMapping(febID, hybridID); + break; + default: break; } } - + /** - * Method that is triggered when the end of a tag is encountered. + * 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 Any SAX exception, possibly wrapping another exception. + * @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(String uri, String localName, String qName) - throws SAXException { - + 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; + break; case "Half": daqMapping.setSvtHalf(content); break; - case "Layer": + case "Layer": daqMapping.setLayerNumber(Integer.parseInt(content)); break; - case "Side": + 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 Any SAX exception, possibly wrapping another exception. - */ - @Override - public void characters(char[] ch, int start, int length) - throws SAXException { - content = String.copyValueOf(ch, start, length).trim(); - } - - /** - * Add a set of {@link SvtChannel}s to the {@link SvtChannelCollection} - * for each of the hybrids. A total of 639 channels are added per hybrid. - * - * @param febID : The Front End Board (FEB) ID - * @param febHybridID : The FEB hybrid ID - * - */ - public void addSvtChannels(int febID, int febHybridID) { - for (int channel = 0; channel < 640; channel++) { - this.svtChannels.add(new SvtChannel( - this.currentSvtChannelID, this.febID, this.hybridID, channel)); - this.currentSvtChannelID++; - } - } - + /** - * Get the {@link SvtDaqMappingCollection} built from parsing the XML - * input file. - * - * @return The collection of {@link SvtDaqMappingCollection}s + * 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 */ - public SvtDaqMappingCollection getDaqMap() { + @Override + public void characters(final char[] ch, final int start, final int length) throws SAXException { + content = String.copyValueOf(ch, start, length).trim(); + } + + /** + * Add a set of {@link SvtChannel} objects to the {@link SvtChannelCollection} for each of the hybrids. A total of + * 639 channels are added per hybrid. + * + * @param febID the Front End Board (FEB) ID + * @param febHybridID the FEB hybrid ID + */ + public void addSvtChannels(final int febID, final int febHybridID) { + for (int channel = 0; channel < CHANNELS_MAX; channel++) { + this.svtChannels.add(new SvtChannel(this.currentSvtChannelID, this.febID, this.hybridID, channel)); + this.currentSvtChannelID++; + } + } + + /** + * Get the {@link SvtDaqMappingCollection} built from parsing the XML input file. + * + * @return the {@link SvtDaqMappingCollection} from parsing the XML + */ + public SvtDaqMappingCollection getDaqMap() { return daqMap; } - + /** - * Get the {@link SvtChannelCollection} build from parsing the XML input - * file. - * + * Get the {@link SvtChannelCollection} build from parsing the XML input file. + * + * @return the {@link SvtChannelCollection} from parsing the XML */ - public SvtChannelCollection getSvtChannels() { - return svtChannels; + public SvtChannelCollection getSvtChannels() { + return svtChannels; } } 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 Mon Apr 6 18:17:40 2015 @@ -8,94 +8,165 @@ import org.hps.conditions.database.Table; /** - * <p> - * Encapsulates an SVT alignment constant, which is an encoded key plus a double - * value. + * 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> - * A == half == [1,2]<br> - * B == alignment type == [1,2]<br> - * C == unit axis == [1,2,3]<br> - * DE == module number == [1,10] - * - * @author Jeremy McCormick <[log in to unmask]> + * <pre> + * A == half == [1,2] + * B == alignment type == [1,2] + * C == unit axis == [1,2,3] + * 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. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @Table(names = "svt_alignments") @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_UPDATED) public final class SvtAlignmentConstant extends BaseConditionsObject { + /** + * Collection implementation for {@link SvtAlignmentConstant}. + */ + @SuppressWarnings("serial") public static class SvtAlignmentConstantCollection extends BaseConditionsObjectCollection<SvtAlignmentConstant> { } - /** Top or bottom half. */ + /** + * Top or bottom half. + */ public enum Half { - TOP(1), BOTTOM(2); - int value; - - Half(int value) { + /** 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. */ + /** + * The alignment constant type which is rotation or translation. + */ public enum AlignmentType { - ROTATION(1), TRANSLATION(2); - int value; - - AlignmentType(int value) { + /** Rotation alignment type. */ + ROTATION(1), + /** Translation alignment type. */ + TRANSLATION(2); + + /** + * The value of the alignment type constants. + */ + private int value; + + /** + * Constructor that has value of constant. + * @param value the value of the constant + */ + private AlignmentType(final int value) { this.value = value; } + /** + * Get the value of the constant. + * @return the value of the constant + */ int getValue() { return value; } }; - /** The unit axis. */ + /** + * The unit axis which for translations maps to XYZ. (Convention for rotation???) + */ public enum UnitAxis { - U(1), V(2), W(3); - int value; - - UnitAxis(int value) { + /** U unit axis. */ + U(1), + /** V unit axis. */ + V(2), + /** W unit axis. */ + W(3); + + /** + * Value for the constant. + */ + private int value; + + /** + * Create from value. + * + * @param value the value + */ + private UnitAxis(final int value) { this.value = value; } + /** + * Get the value + * + * @return the value + */ int getValue() { return value; } }; - /** Maximum value of module number. */ + /** + * Maximum value of the module number. + */ private static final int MAX_MODULE_NUMBER = 10; /** - * Get the alignment constant's full key with the encoded information. + * Get the alignment constant's encoded, raw value. + * * @return the alignment constant's key */ - @Field(names = {"parameter"}) + @Field(names = { "parameter" }) public String getParameter() { return getFieldValue("parameter"); } /** - * Get the the alignment constant's value which is always a single double. + * 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"}) + @Field(names = { "value" }) public double getValue() { return getFieldValue("value"); } /** * Decode the Half value from the key. + * * @return the Half value from the key + * @see {@link SvtAlignmentConstant#Half} */ public Half getHalf() { - int half = Integer.parseInt(getParameter().substring(0, 1)); + final int half = Integer.parseInt(getParameter().substring(0, 1)); if (half == Half.TOP.getValue()) { return Half.TOP; } else if (half == Half.BOTTOM.getValue()) { @@ -107,10 +178,12 @@ /** * Decode the AlignmentType value from the key. + * * @return the AlignmentType value from the key + * @see {@link SvtAlignmentConstant#AlignmentType} */ public AlignmentType getAlignmentType() { - int alignmentType = Integer.parseInt(getParameter().substring(1, 2)); + final int alignmentType = Integer.parseInt(getParameter().substring(1, 2)); if (alignmentType == AlignmentType.TRANSLATION.getValue()) { return AlignmentType.TRANSLATION; } else if (alignmentType == AlignmentType.ROTATION.getValue()) { @@ -122,10 +195,12 @@ /** * Decode the UnitAxis from the key. + * * @return the UnitAxis v + * @see {@link SvtAlignmentConstant#UnitAxis} */ public UnitAxis getUnitAxis() { - int unitAxis = Integer.parseInt(getParameter().substring(2, 3)); + final int unitAxis = Integer.parseInt(getParameter().substring(2, 3)); if (unitAxis == UnitAxis.U.getValue()) { return UnitAxis.U; } else if (unitAxis == UnitAxis.V.getValue()) { @@ -139,18 +214,25 @@ /** * Decode the module number from the key. + * * @return the module number from the key */ public int getModuleNumber() { - int moduleNumber = Integer.parseInt(getParameter().substring(3, 5)); + 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; } + /** + * Convert this object to a string. + * + * @return this object converted to a string + */ + @Override public String toString() { - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); buff.append(super.toString()); buff.append("half: ").append(getHalf().getValue()).append('\n'); buff.append("alignment_type: ").append(getAlignmentType().getValue()).append('\n'); @@ -158,4 +240,4 @@ buff.append("module_number: ").append(getModuleNumber()).append('\n'); return buff.toString(); } -} +} Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java Mon Apr 6 18:17:40 2015 @@ -7,18 +7,37 @@ import org.hps.conditions.database.MultipleCollectionsAction; import org.hps.conditions.database.Table; -@Table(names = {/*"svt_bad_channels",*/ "test_run_svt_bad_channels"}) +/** + * Represents a channel that has been flagged as bad, which should not + * be used for physics reconstructions. This might be done if the + * channel is extremely noisy, etc. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + */ +@Table(names = {"svt_bad_channels", "test_run_svt_bad_channels"}) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public final class SvtBadChannel extends BaseConditionsObject { + /** + * The collection implementation for {@link SvtBadChannel}. + */ + @SuppressWarnings("serial") public static class SvtBadChannelCollection extends BaseConditionsObjectCollection<SvtBadChannel> { } + /** + * Get the channel ID. + * @return the channel ID + */ @Field(names = {"svt_channel_id"}) public int getChannelId() { return getFieldValue("svt_channel_id"); } + /** + * Get a note about the bad channel. + * @return a note about the bad channel + */ @Field(names = {"notes"}) public int getNote() { return getFieldValue("notes"); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java Mon Apr 6 18:17:40 2015 @@ -11,36 +11,40 @@ /** * This class encapsulates noise and pedestal measurement for an SVT channel. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ @Table(names = {"svt_calibrations", "test_run_svt_calibrations"}) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_UPDATED) public final class SvtCalibration extends BaseConditionsObject { + /** + * The collection implementation for {@link SvtCalibration}. + */ + @SuppressWarnings("serial") public static class SvtCalibrationCollection extends BaseConditionsObjectCollection<SvtCalibration> { } /** - * Default Constructor + * Default constructor. */ - public SvtCalibration() { + public SvtCalibration() { } - + /** - * Constructor - * - * @param channelID : The SVT channel ID + * Constructor with channel ID. + * + * @param channelID the SVT channel ID */ - public SvtCalibration(int channelID) { - this.setChannelID(channelID); + public SvtCalibration(final int channelID) { + this.setChannelID(channelID); } - + /** * Get the channel ID. - * - * @return The channel ID. + * + * @return The channel ID */ @Field(names = {"svt_channel_id"}) public int getChannelID() { @@ -48,12 +52,13 @@ } /** - * Get the noise value. - * - * @return The noise value. + * Get the noise value. + * + * @param sample the sample number (0-5) + * @return the noise value */ @Field(names = {"noise_0", "noise_1", "noise_2", "noise_3", "noise_4", "noise_5"}) - public double getNoise(int sample) { + public double getNoise(final int sample) { if (sample < 0 || sample > MAX_NUMBER_OF_SAMPLES) { throw new IllegalArgumentException("Sample number is not within range."); } @@ -61,12 +66,13 @@ } /** - * Get the pedestal value. - * - * @return The pedestal value. + * Get the pedestal value. + * + * @param sample the sample number (0-5) + * @return The pedestal value. */ @Field(names = {"pedestal_0", "pedestal_1", "pedestal_2", "pedestal_3", "pedestal_4", "pedestal_5"}) - public double getPedestal(int sample) { + public double getPedestal(final int sample) { if (sample < 0 || sample > MAX_NUMBER_OF_SAMPLES) { throw new IllegalArgumentException("Sample number is not within range."); } @@ -74,43 +80,44 @@ } /** - * Set the channel ID. - * - * @param channelID + * Set the channel ID. + * + * @param channelID the channel ID */ - public void setChannelID(int channelID) { + public void setChannelID(final int channelID) { this.setFieldValue("svt_channel_id", channelID); } - + /** - * Set the noise value for the given sample. - * - * @param sample - * @param noise + * Set the noise value for the given sample. + * + * @param sample the sample number + * @param noise the noise */ - public void setNoise(int sample, double noise) { - String noiseField = "noise_" + Integer.toString(sample); + public void setNoise(final int sample, final double noise) { + final String noiseField = "noise_" + Integer.toString(sample); this.setFieldValue(noiseField, noise); } - + /** - * Set the pedestal value for the given sample - * - * @param sample - * @param pedestal + * Set the pedestal value for the given sample. + * + * @param sample the sample number + * @param pedestal the pedestal value */ - public void setPedestal(int sample, double pedestal) { - String pedestalField = "pedestal_" + Integer.toString(sample); + public void setPedestal(final int sample, final double pedestal) { + final String pedestalField = "pedestal_" + Integer.toString(sample); this.setFieldValue(pedestalField, pedestal); } - + /** - * Convert this object to a human readable string. - * - * @return This object converted to a string. + * Convert this object to a human readable string. + * + * @return This object converted to a string. */ + // FIXME: This is a mess when it prints to console. public String toString() { - StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = new StringBuffer(); buffer.append("Channel ID: " + this.getChannelID()); for (int i = 0; i < 115; i++) { buffer.append("-"); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java Mon Apr 6 18:17:40 2015 @@ -12,32 +12,62 @@ /** * This class represents SVT channel setup information, including FEB ID, FEB Hybrid ID, and channel numbers. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ @Table(names = { "svt_channels" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public final class SvtChannel extends AbstractSvtChannel { /** - * - */ - public SvtChannel() { - } - - /** - * Constructor - * - * @param channelID : The SVT channel ID - * @param febID : The Front End Board (FEB) ID (0-9) - * @param febHybridID : The hybrid ID (0-3) - * @param channel : The channel number (0-639) - */ - public SvtChannel(int channelID, int febID, int febHybridID, int channel) { - if (!this.isValidFeb(febID) - || !this.isValidFebHybridID(febHybridID) - || !this.isValidPhysicalChannel(channel)) { + * Maximum channel number. + */ + private static final int MAX_CHANNEL = 639; + + /** + * Minimum channel number. + */ + private static final int MIN_CHANNEL = 0; + + /** + * Maximum FEB Hybrid ID. + */ + private static final int MAX_FEB_HYBRID_ID = 3; + + /** + * Minimum FEB hybrid ID. + */ + private static final int MIN_FEB_HYBRID_ID = 0; + + /** + * Maximum FEB ID. + */ + private static final int MAX_FEB_ID = 9; + + /** + * Minimum FEB ID. + */ + private static final int MIN_FEB_ID = 0; + + /** + * Default constructor. + */ + public SvtChannel() { + } + + /** + * Fully qualified constructor. + * + * @param channelID the SVT channel ID + * @param febID the Front End Board (FEB) ID (0-9) + * @param febHybridID the hybrid ID (0-3) + * @param channel the channel number (0-639) + */ + public SvtChannel(final int channelID, final int febID, final int febHybridID, final int channel) { + if (!this.isValidFeb(febID) + || !this.isValidFebHybridID(febHybridID) + || !this.isValidPhysicalChannel(channel)) { throw new RuntimeException("Invalid FEB ID, FEB hybrid ID or physical channel number is being used."); } this.setChannelID(channelID); @@ -45,19 +75,23 @@ this.setFebHybridID(febHybridID); this.setChannel(channel); } - + + /** + * Collection implementation for {@link SvtChannel}. + */ + @SuppressWarnings("serial") public static class SvtChannelCollection extends AbstractSvtChannel.AbstractSvtChannelCollection<SvtChannel> { /** - * Find channels that match a DAQ pair (FEB ID, FEB Hybrid ID). - * - * @param pair : The DAQ pair consiting of a FEB ID and FEB Hybrid ID. - * @return The channels matching the DAQ pair or null if ?not found. + * Find channels that match a DAQ pair (FEB ID, FEB Hybrid ID). + * + * @param pair the DAQ pair consisting of a FEB ID and FEB Hybrid ID + * @return the channels matching the DAQ pair or null if not found */ @Override - public Collection<SvtChannel> find(Pair<Integer, Integer> pair) { - List<SvtChannel> channels = new ArrayList<SvtChannel>(); - int febID = pair.getFirstElement(); - int febHybridID = pair.getSecondElement(); + public Collection<SvtChannel> find(final Pair<Integer, Integer> pair) { + final List<SvtChannel> channels = new ArrayList<SvtChannel>(); + final int febID = pair.getFirstElement(); + final int febHybridID = pair.getSecondElement(); for (SvtChannel channel : this) { if (channel.getFebID() == febID && channel.getFebHybridID() == febHybridID) { channels.add(channel); @@ -67,17 +101,18 @@ } /** - * Get the SVT channel ID associated with a given FEB ID/Hybrid ID/physical channel. + * Get the SVT channel ID associated with a given FEB ID/Hybrid ID/physical channel. * - * @param febID : The FEB ID - * @param febHybridID : The FEB hybrid ID - * @param channel : The physical channel number - * @return The SVT channel ID - * @throws {@link RuntimeException} if the channel ID can't be found + * @param febID : The FEB ID + * @param febHybridID : The FEB hybrid ID + * @param channel : The physical channel number + * @return The SVT channel ID + * @throws {@link RuntimeException} if the channel ID can't be found */ - public int findChannelID(int febID, int febHybridID, int channel) { - for (SvtChannel svtChannel : this) { - if (svtChannel.getFebID() == febID && svtChannel.getFebHybridID() == febHybridID && svtChannel.getChannel() == channel) { + public final int findChannelID(final int febID, final int febHybridID, final int channel) { + for (final SvtChannel svtChannel : this) { + if (svtChannel.getFebID() == febID && svtChannel.getFebHybridID() == febHybridID + && svtChannel.getChannel() == channel) { return svtChannel.getChannelID(); } } @@ -87,9 +122,9 @@ } /** - * Get the FEB ID associated with this SVT channel ID. - * - * @return The FEB ID. + * Get the FEB ID associated with this SVT channel ID. + * + * @return The FEB ID. */ @Field(names = { "feb_id" }) public int getFebID() { @@ -97,9 +132,9 @@ } /** - * Get the FEB hybrid ID associated with this SVT channel ID. - * - * @return The FEB hybrid ID. + * Get the FEB hybrid ID associated with this SVT channel ID. + * + * @return The FEB hybrid ID. */ @Field(names = { "feb_hybrid_id" }) public int getFebHybridID() { @@ -107,67 +142,70 @@ } /** - * Set the FEB ID associated with this SVT channel ID. - * - * @param febID : The FEB ID - */ - public void setFebID(int febID) { + * Set the FEB ID associated with this SVT channel ID. + * + * @param febID the FEB ID + */ + public void setFebID(final int febID) { this.setFieldValue("feb_id", febID); } + + /** + * Set the FEB hybrid ID associated with this SVT channel ID. + * + * @param febHybridID : The FEB hybrid ID + */ + public void setFebHybridID(final int febHybridID) { + this.setFieldValue("feb_hybrid_id", febHybridID); + } + + /** + * Checks if a FEB ID is valid. + * + * @param febID the Front End Board (FEB) ID + * @return <code>true</code> if the FEB ID lies within the range 0-9 + */ + public boolean isValidFeb(int febID) { + return (febID >= MIN_FEB_ID && febID <= MAX_FEB_ID) ? true : false; + } /** - * Set the FEB hybrid ID associated with this SVT channel ID. - * - * @param febHybridID : The FEB hybrid ID - */ - public void setFebHybridID(int febHybridID) { - this.setFieldValue("feb_hybrid_id", febHybridID); + * Checks if a Front End Board hybrid ID is valid. + * + * @param febHybridID the hybrid ID + * @return <code>true</code> if the hybrid ID lies within the range 0-3 + */ + public boolean isValidFebHybridID(int febHybridID) { + return (febHybridID >= MIN_FEB_HYBRID_ID && febHybridID <= MAX_FEB_HYBRID_ID) ? true : false; } /** - * Checks if a FEB ID is valid - * - * @param febID : The Front End Board (FEB) ID - * @return True if the FEB ID lies within the range 0-9, false otherwise - */ - public boolean isValidFeb(int febID) { - return (febID >= 0 && febID <= 9) ? true : false; - } - - /** - * Checks if a Front End Board hybrid ID is valid - * - * @param febHybridID : The hybrid ID - * @return True if the hybrid ID lies within the range 0-3, false otherwise - */ - public boolean isValidFebHybridID(int febHybridID) { - return (febHybridID >= 0 && febHybridID <= 3) ? true : false; - } - - /** - * Checks if a physical channel number is valid - * - * @param channel : The physical channel number - * @return True if the channel number lies within the range 0-639, false - * otherwise - */ - public boolean isValidPhysicalChannel(int channel) { - return (channel >= 0 && channel <= 639) ? true : false; - } - - /** - * Implementation of equals. - * - * @return True if the object equals this one; false if not. + * Checks if a physical channel number is valid. + * + * @param channel the physical channel number + * @return <code>true</code> if the channel number lies within the range 0-639 + */ + public boolean isValidPhysicalChannel(int channel) { + return (channel >= MIN_CHANNEL && channel <= MAX_CHANNEL) ? true : false; + } + + /** + * Implementation of equals. + * + * @return <code>true</code> if the object equals this one */ public boolean equals(Object o) { - if (o == null) + if (o == null) { return false; - if (!(o instanceof SvtChannel)) + } + if (!(o instanceof SvtChannel)) { return false; - if (o == this) + } + if (o == this) { return true; - SvtChannel channel = (SvtChannel) o; - return getChannelID() == channel.getChannelID() && getFebID() == channel.getFebID() && getFebHybridID() == channel.getFebHybridID() && getChannel() == channel.getChannel(); + } + final SvtChannel channel = (SvtChannel) o; + return getChannelID() == channel.getChannelID() && getFebID() == channel.getFebID() + && getFebHybridID() == channel.getFebHybridID() && getChannel() == channel.getChannel(); } } 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 Mon Apr 6 18:17:40 2015 @@ -9,19 +9,19 @@ 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. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * + * @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 SvtDaqMappingCollection} associated with these conditions. - * + * * @return The SVT DAQ map. */ @Override @@ -31,7 +31,7 @@ /** * Get the {@link SvtChannelCollection} for this set of conditions. - * + * * @return The SVT channel map. */ @Override @@ -41,7 +41,7 @@ /** * Get the {@link SvtT0ShiftCollection} associated with these conditions. - * + * * @return The {@link SvtT0ShiftCollection} */ @Override @@ -54,13 +54,12 @@ * 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. + * + * @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. public String toString() { - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); buff.append('\n'); buff.append("Printing SVTConditions ..."); @@ -120,13 +119,14 @@ for (SvtChannel channel : this.getChannelMap()) { // Get the conditions for the channel. - ChannelConstants constants = getChannelConstants(channel); - SvtGain gain = constants.getGain(); - SvtShapeFitParameters shapeFit = constants.getShapeFitParameters(); - SvtCalibration calibration = constants.getCalibration(); + final ChannelConstants constants = getChannelConstants(channel); + final SvtGain gain = constants.getGain(); + final SvtShapeFitParameters shapeFit = constants.getShapeFitParameters(); + final SvtCalibration calibration = constants.getCalibration(); // Channel data. - buff.append(String.format("%-6d %-5d %-8d %-8d ", channel.getChannelID(), channel.getFebID(), channel.getFebHybridID(), channel.getChannel())); + buff.append(String.format("%-6d %-5d %-8d %-8d ", channel.getChannelID(), channel.getFebID(), + channel.getFebHybridID(), channel.getChannel())); // Calibration. for (int sample = 0; sample < MAX_NUMBER_OF_SAMPLES; sample++) { @@ -142,7 +142,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/SvtConditionsConverter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java Mon Apr 6 18:17:40 2015 @@ -1,48 +1,54 @@ package org.hps.conditions.svt; -import org.lcsim.conditions.ConditionsManager; import org.hps.conditions.database.DatabaseConditionsManager; import org.hps.conditions.svt.SvtChannel.SvtChannelCollection; import org.hps.conditions.svt.SvtDaqMapping.SvtDaqMappingCollection; import org.hps.conditions.svt.SvtT0Shift.SvtT0ShiftCollection; +import org.lcsim.conditions.ConditionsManager; /** * This class creates an {@link SvtConditions} object from the database, based * on the current run number known by the conditions manager. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * + * @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 SvtConditionsConverter extends AbstractSvtConditionsConverter<SvtConditions> { + /** + * Default constructor. + */ public SvtConditionsConverter() { this.conditions = new SvtConditions(); } /** - * Create and return an {@link SvtConditions} object - * - * @param manager The current conditions manager. - * @param name The conditions key, which is ignored for now. + * Create and return an {@link SvtConditions} object. + * + * @param manager the current conditions manager + * @param name the conditions key, which is ignored for now */ @Override - public SvtConditions getData(ConditionsManager manager, String name) { + public SvtConditions getData(final ConditionsManager manager, final String name) { - DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager; + final DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager; // Get the channel map from the conditions database - SvtChannelCollection channels = dbConditionsManager.getCachedConditions(SvtChannelCollection.class, "svt_channels").getCachedData(); + final SvtChannelCollection channels = dbConditionsManager.getCachedConditions( + SvtChannelCollection.class, "svt_channels").getCachedData(); // Create the SVT conditions object to use to encapsulate SVT condition // collections conditions.setChannelMap(channels); // Get the DAQ map from the conditions database - SvtDaqMappingCollection daqMap = dbConditionsManager.getCachedConditions(SvtDaqMappingCollection.class, "svt_daq_map").getCachedData(); + final SvtDaqMappingCollection daqMap = dbConditionsManager.getCachedConditions( + SvtDaqMappingCollection.class, "svt_daq_map").getCachedData(); conditions.setDaqMap(daqMap); // Get the collection of T0 shifts from the conditions database - SvtT0ShiftCollection t0Shifts = dbConditionsManager.getCachedConditions(SvtT0ShiftCollection.class, "svt_t0_shifts").getCachedData(); + final SvtT0ShiftCollection t0Shifts = dbConditionsManager.getCachedConditions( + SvtT0ShiftCollection.class, "svt_t0_shifts").getCachedData(); conditions.setT0Shifts(t0Shifts); conditions = super.getData(manager, name); @@ -58,4 +64,4 @@ public Class<SvtConditions> getType() { return SvtConditions.class; } -} +} Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java Mon Apr 6 18:17:40 2015 @@ -10,165 +10,181 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; - -import org.lcsim.util.log.DefaultLogFormatter; -import org.lcsim.util.log.LogUtil; -import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException; - import org.hps.conditions.api.ConditionsRecord; import org.hps.conditions.database.DatabaseConditionsManager; import org.hps.conditions.database.TableMetaData; import org.hps.conditions.svt.SvtCalibration.SvtCalibrationCollection; import org.hps.conditions.svt.SvtChannel.SvtChannelCollection; -import org.hps.conditions.svt.SvtConditionsReader; import org.hps.conditions.svt.SvtDaqMapping.SvtDaqMappingCollection; +import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException; +import org.lcsim.util.log.DefaultLogFormatter; +import org.lcsim.util.log.LogUtil; /** - * Command line tool used to load SVT conditions into the conditions database. - * - * @author Omar Moreno <[log in to unmask]> + * Command line tool used to load SVT conditions into the conditions database. + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -public class SvtConditionsLoader { - - // Initialize the logger - private static Logger logger = LogUtil.create(SvtConditionsLoader.class.getName(), +public final class SvtConditionsLoader { + + /** + * Initialize the logger. + */ + private static Logger logger = LogUtil.create(SvtConditionsLoader.class.getName(), new DefaultLogFormatter(), Level.INFO); + + /** + * Default detector name. + */ + public static final String DETECTOR = "HPS-Proposal2014-v9-2pt2"; + + /** + * SVT DAQ map table name. + */ + public static final String DAQ_MAP_TABLE_NAME = "svt_daq_map"; + + /** + * Calibrations table name. + */ + public static final String CALIBRATIONS_TABLE_NAME = "svt_calibrations"; + + /** + * SVT channels table name. + */ + public static final String SVT_CHANNELS_TABLE_NAME = "svt_channels"; - //-----------------// - //--- Constants ---// - //-----------------// - - // Default detector - public static final String DETECTOR = "HPS-Proposal2014-v9-2pt2"; - - // Table names - public static final String DAQ_MAP_TABLE_NAME = "svt_daq_map"; - public static final String CALIBRATIONS_TABLE_NAME = "svt_calibrations"; - public static final String SVT_CHANNELS_TABLE_NAME = "svt_channels"; - - //-----------------// - //-----------------// - - public static void main(String[] args) { - + /** + * Do not allow instantiation. + */ + private SvtConditionsLoader() { + throw new UnsupportedOperationException("Do not instantiate this class."); + } + + /** + * Run this class from the command line. + * @param args The command line arguments. + */ + public static void main(final String[] args) { + // Set up the command line options - Options options = setupCommandLineOptions(); - + final Options options = setupCommandLineOptions(); + // Parse the command line arguments - CommandLineParser parser = new PosixParser(); - CommandLine commandLine = null; - try { + final CommandLineParser parser = new PosixParser(); + final CommandLine commandLine; + try { commandLine = parser.parse(options, args); - } catch (ParseException e){ + } catch (ParseException e) { throw new RuntimeException("Unable to parse command line arguments.", e); } - - // Get the run number. If a run number hasn't been set, warn the user - // and exit. - if (!commandLine.hasOption("r")) { + + // Get the run number. If a run number hasn't been set, warn the user and exit. + if (!commandLine.hasOption("r")) { System.out.println("\nPlease specify a run number to associate with the conditions set.\n"); return; } - int runNumber = Integer.valueOf(commandLine.getOptionValue("r")); + final int runNumber = Integer.valueOf(commandLine.getOptionValue("r")); logger.info("Run number set to " + runNumber); - + // Initialize the conditions system and load the conditions onto the // detector object try { - - // If a user has specified the connection properties, set them, - // otherwise use the default values - if (commandLine.hasOption("p")) { + + // If a user has specified the connection properties, set them, otherwise use the default values. + if (commandLine.hasOption("p")) { DatabaseConditionsManager.getInstance() .setConnectionProperties(new File(commandLine.getOptionValue("p"))); } DatabaseConditionsManager.getInstance() .setDetector(SvtConditionsLoader.DETECTOR, runNumber); - } catch(ConditionsNotFoundException e) { + } catch (ConditionsNotFoundException e) { throw new RuntimeException("Could not initialize the conditions system.", e); } - + // Instantiate the SVT conditions reader - SvtConditionsReader reader; - try { - reader = new SvtConditionsReader(); + final SvtConditionsReader reader; + try { + reader = new SvtConditionsReader(); } catch (Exception e) { - throw new RuntimeException("Couldn't open SvtConditionsReader.", e); - } - - // If a calibrations file has been specified, parse it and load them + throw new RuntimeException("Couldn't open SvtConditionsReader.", e); + } + + // If a calibrations file has been specified, parse it and load them // to the conditions database. - if (commandLine.hasOption("c")) { - File calibrationFile = new File(commandLine.getOptionValue("c")); + if (commandLine.hasOption("c")) { + final File calibrationFile = new File(commandLine.getOptionValue("c")); logger.info("Loading calibrations from file " + calibrationFile.getAbsolutePath()); - try { - - // Parse the calibration file and retrieve the calibrations - // collection. + try { + + // Parse the calibration file and retrieve the calibrations collection. reader.parseCalibrations(calibrationFile); - SvtCalibrationCollection calibrations = reader.getSvtCalibrationCollection(); - + final SvtCalibrationCollection calibrations = reader.getSvtCalibrationCollection(); + // Set the table meta data - TableMetaData tableMetaData = DatabaseConditionsManager.getInstance().findTableMetaData(SvtConditionsLoader.CALIBRATIONS_TABLE_NAME); + final TableMetaData tableMetaData = DatabaseConditionsManager.getInstance() + .findTableMetaData(SvtConditionsLoader.CALIBRATIONS_TABLE_NAME); calibrations.setTableMetaData(tableMetaData); - - // Set the collection ID - int collectionID = DatabaseConditionsManager.getInstance().getNextCollectionID(SvtConditionsLoader.CALIBRATIONS_TABLE_NAME); + + // Set the collection ID. + final int collectionID = DatabaseConditionsManager.getInstance() + .getNextCollectionID(SvtConditionsLoader.CALIBRATIONS_TABLE_NAME); calibrations.setCollectionId(collectionID); logger.info("Using collection ID " + collectionID); - + // Load the calibrations calibrations.insert(); - logger.info("A total of " + calibrations.size() + " SvtCalibrations were loaded successfully into the database."); - - // Create a conditions record associated with the set of - // conditions that were just loaded - ConditionsRecord conditionsRecord = new ConditionsRecord( - calibrations.getCollectionId(), - runNumber, - 99999, + logger.info("A total of " + calibrations.size() + + " SvtCalibrations were loaded successfully into the database."); + + // Create a conditions record associated with the set of conditions that were just loaded. + final ConditionsRecord conditionsRecord = new ConditionsRecord( + calibrations.getCollectionId(), + runNumber, + 99999, SvtConditionsLoader.CALIBRATIONS_TABLE_NAME, SvtConditionsLoader.CALIBRATIONS_TABLE_NAME, "Pedestals and noise. Loaded using SvtConditionsLoader.", "eng_run"); conditionsRecord.insert(); - - } catch (Exception e) { + + } catch (Exception e) { throw new RuntimeException("Couldn't parse calibration file.", e); } } - + // If a DAQ map file has been specified, parse it and load them to the // conditions database. - if (commandLine.hasOption("d")) { - File daqMapFile = new File(commandLine.getOptionValue("d")); + if (commandLine.hasOption("d")) { + final File daqMapFile = new File(commandLine.getOptionValue("d")); logger.info("Loading DAQ map from file " + daqMapFile.getAbsolutePath()); - try { - + try { + // Parse the DAQ map file reader.parseDaqMap(daqMapFile); - SvtDaqMappingCollection daqMapping = reader.getDaqMapCollection(); - + final SvtDaqMappingCollection daqMapping = reader.getDaqMapCollection(); + // Set the table meta data - TableMetaData tableMetaData = DatabaseConditionsManager.getInstance().findTableMetaData(SvtConditionsLoader.DAQ_MAP_TABLE_NAME); + TableMetaData tableMetaData = DatabaseConditionsManager.getInstance().findTableMetaData( + SvtConditionsLoader.DAQ_MAP_TABLE_NAME); daqMapping.setTableMetaData(tableMetaData); - + // Set the collection ID - int collectionID = DatabaseConditionsManager.getInstance().getNextCollectionID(SvtConditionsLoader.DAQ_MAP_TABLE_NAME); + int collectionID = DatabaseConditionsManager.getInstance().getNextCollectionID( + SvtConditionsLoader.DAQ_MAP_TABLE_NAME); daqMapping.setCollectionId(collectionID); logger.info("Using collection ID " + collectionID); - + // Load the DAQ map daqMapping.insert(); logger.info("DAQ map has been loaded successfully"); logger.fine(daqMapping.toString()); // Create a conditions record associated with the set of - // conditions that were just loaded - ConditionsRecord conditionsRecord = new ConditionsRecord( - daqMapping.getCollectionId(), - runNumber, - 99999, + // conditions that were just loaded. + ConditionsRecord conditionsRecord = new ConditionsRecord( + daqMapping.getCollectionId(), + runNumber, + 99999, SvtConditionsLoader.DAQ_MAP_TABLE_NAME, SvtConditionsLoader.DAQ_MAP_TABLE_NAME, "Engineering run DAQ map. Loaded using SvtConditionsLoader.", @@ -176,33 +192,35 @@ conditionsRecord.insert(); logger.info("Loading the collection of SvtChannel's"); - SvtChannelCollection svtChannels = reader.getSvtChannelCollection(); - + final SvtChannelCollection svtChannels = reader.getSvtChannelCollection(); + // Set the table meta data - tableMetaData = DatabaseConditionsManager.getInstance().findTableMetaData(SvtConditionsLoader.SVT_CHANNELS_TABLE_NAME); + tableMetaData = DatabaseConditionsManager.getInstance().findTableMetaData( + SvtConditionsLoader.SVT_CHANNELS_TABLE_NAME); svtChannels.setTableMetaData(tableMetaData); // Set the collection ID - collectionID = DatabaseConditionsManager.getInstance().getNextCollectionID(SvtConditionsLoader.SVT_CHANNELS_TABLE_NAME); + collectionID = DatabaseConditionsManager.getInstance().getNextCollectionID( + SvtConditionsLoader.SVT_CHANNELS_TABLE_NAME); svtChannels.setCollectionId(collectionID); logger.info("Using collection ID " + collectionID); - + svtChannels.insert(); - logger.info("A total of " + svtChannels.size() + " SvtChannels were successfully loaded into the database."); - - // Create a conditions record associated with the set of - // conditions that were just loaded - conditionsRecord = new ConditionsRecord( - svtChannels.getCollectionId(), - runNumber, - 99999, + logger.info("A total of " + svtChannels.size() + + " SvtChannels were successfully loaded into the database."); + + // Create a conditions record associated with the set of + // conditions that were just loaded. + conditionsRecord = new ConditionsRecord( + svtChannels.getCollectionId(), + runNumber, + 99999, SvtConditionsLoader.SVT_CHANNELS_TABLE_NAME, SvtConditionsLoader.SVT_CHANNELS_TABLE_NAME, "Engineering run SVT channel IDs. Loaded using SvtConditionsLoader.", "eng_run"); conditionsRecord.insert(); - - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException("Couldn't parse DAQ map file.", e); } } @@ -210,11 +228,11 @@ /** * Method used to setup all command line options. - * + * * @return a set of options */ - private static Options setupCommandLineOptions() { - Options options = new Options(); + private static Options setupCommandLineOptions() { + final Options options = new Options(); options.addOption(new Option("r", true, "Run number")); options.addOption(new Option("p", true, "Path to properties file")); options.addOption(new Option("c", true, "Calibration file")); 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 Mon Apr 6 18:17:40 2015 @@ -5,101 +5,106 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import org.hps.conditions.svt.CalibrationHandler; import org.hps.conditions.svt.SvtCalibration.SvtCalibrationCollection; import org.hps.conditions.svt.SvtChannel.SvtChannelCollection; import org.hps.conditions.svt.SvtDaqMapping.SvtDaqMappingCollection; /** - * Reader used to parse SVT conditions. - * - * @author Omar Moreno <[log in to unmask]> + * Reader used to parse SVT conditions. + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -public class SvtConditionsReader { +public final class SvtConditionsReader { - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - SAXParser parser; + /** + * SAX parser factory. + */ + private SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - // SAX handlers - DaqMapHandler daqMapHandler; - CalibrationHandler calibrationHandler; - /** - * Default Constructor - * + * SAX parser. + */ + private SAXParser parser; + + /** + * SAX handler for DAQ map elements. + */ + private DaqMapHandler daqMapHandler; + + /** + * SAX handler for calibration elements. + */ + private CalibrationHandler calibrationHandler; + + /** + * Default constructor. + * * @throws Exception if a SAX parser can't be created. */ - public SvtConditionsReader() throws Exception { - - // Create a new SAX parser + public SvtConditionsReader() throws Exception { + + // Create a new SAX parser. parser = parserFactory.newSAXParser(); - } - - /** - * Parse a calibration file and create {@link SvtCalibration} objects out - * of all channel conditions. - * - * @param calibrationFile : The input calibration file to parse - * - */ - public void parseCalibrations(File calibrationFile) throws Exception { - - // Instantiate the calibration handler - calibrationHandler = new CalibrationHandler(); - - // Parse the calibration file and create the collection of SvtCalibrations - parser.parse(calibrationFile, calibrationHandler); - } - - /** - * Parse a DAQ map file and create {@link SvtDaqMapping} objects - * - * @param daqMapFile : The input DAQ map file to parse - * - */ - public void parseDaqMap(File daqMapFile) throws Exception { - - // Instatntiate the DAQ map handler - daqMapHandler = new DaqMapHandler(); - - // Parse the DAQ map file and create the collection of SvtDaqMapping objects - parser.parse(daqMapFile, 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 + * Parse a calibration file and create {@link SvtCalibration} objects out of all channel conditions. * + * @param calibrationFile the input calibration file to parse + * @throws Exception if there is an error parsing the calibrations data */ - public SvtDaqMappingCollection getDaqMapCollection() { - return daqMapHandler.getDaqMap(); + public void parseCalibrations(final File calibrationFile) throws Exception { + + // Instantiate the calibration handler. + calibrationHandler = new CalibrationHandler(); + + // Parse the calibration file and create the collection of SvtCalibrations. + parser.parse(calibrationFile, calibrationHandler); } - + /** - * 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 - * + * Parse a DAQ map file and create {@link SvtDaqMapping} objects. + * + * @param daqMapFile the input DAQ map file to parse + * @throws Exception if there is a problem parsing the DAQ map XML data */ - public SvtChannelCollection getSvtChannelCollection() { + public void parseDaqMap(final File daqMapFile) throws Exception { + + // Instantiate the DAQ map handler. + daqMapHandler = new DaqMapHandler(); + + // Parse the DAQ map file and create the collection of SvtDaqMapping objects. + parser.parse(daqMapFile, 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 - * + * 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() { + public SvtCalibrationCollection getSvtCalibrationCollection() { return calibrationHandler.getCalibrations(); } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConfiguration.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConfiguration.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConfiguration.java Mon Apr 6 18:17:40 2015 @@ -18,50 +18,63 @@ import org.jdom.output.XMLOutputter; /** - * This is a simple class for getting an SVT XML configuration file. + * This class is the conditions object model for an SVT configuration saved into the database. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -@Table(names = {"svt_configurations"}) +@Table(names = { "svt_configurations" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_UPDATED) -public class SvtConfiguration extends BaseConditionsObject { +public final class SvtConfiguration extends BaseConditionsObject { + /** + * Collection implementation for {@link SvtConfiguration} objects. + */ + @SuppressWarnings("serial") public static class SvtConfigurationCollection extends BaseConditionsObjectCollection<SvtConfiguration> { } /** * Get the filename associated with this configuration. + * * @return The filename associated with the configuration. */ - @Field(names = {"filename"}) + @Field(names = { "filename" }) public String getFileName() { return getFieldValue("filename"); } - - @Field(names = {"content"}) + + /** + * Get the content of the XML file as a byte array. + * + * @return the content of the XML file as a byte array + */ + @Field(names = { "content" }) public byte[] getContent() { return getFieldValue("content"); } /** - * Convert the raw database field value for the configuration into an XML - * document. + * Convert the raw database content for the configuration into an XML document. + * * @return The Document created from the raw data. - * @throws IOException - * @throws JDOMException + * @throws IOException if there is an IO error + * @throws JDOMException is there is an XML parsing error */ public Document createDocument() throws IOException, JDOMException { - byte[] bytes = getFieldValue("content"); - InputStream inputStream = new ByteArrayInputStream(bytes); - SAXBuilder builder = new SAXBuilder(); + final byte[] bytes = getFieldValue("content"); + final InputStream inputStream = new ByteArrayInputStream(bytes); + final SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); return builder.build(inputStream); } /** * Save this configuration to a local file on disk. - * @param filename The name of the local file. + * + * @param filename the name of the local file */ - public void writeToFile(String filename) { - XMLOutputter out = new XMLOutputter(); + public void writeToFile(final String filename) { + final XMLOutputter out = new XMLOutputter(); out.setFormat(Format.getPrettyFormat()); try { out.output(createDocument(), new FileWriter(filename)); @@ -71,11 +84,10 @@ } /** - * Save this configuration to a local file on disk using its name from the - * database. + * Save this configuration to a local file on disk using its name from the database. */ public void writeToFile() { - XMLOutputter out = new XMLOutputter(); + final XMLOutputter out = new XMLOutputter(); out.setFormat(Format.getPrettyFormat()); try { out.output(createDocument(), new FileWriter(getFileName())); @@ -83,4 +95,4 @@ throw new RuntimeException(e); } } -} +} 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 Mon Apr 6 18:17:40 2015 @@ -1,60 +1,69 @@ package org.hps.conditions.svt; -import org.lcsim.detector.tracker.silicon.HpsSiSensor; import org.hps.conditions.database.Converter; import org.hps.conditions.database.Field; import org.hps.conditions.database.MultipleCollectionsAction; import org.hps.conditions.database.Table; import org.hps.util.Pair; +import org.lcsim.detector.tracker.silicon.HpsSiSensor; /** * This class encapsulates the SVT DAQ map. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -@Table(names = {"svt_daq_map"}) +@Table(names = { "svt_daq_map" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public class SvtDaqMapping extends AbstractSvtDaqMapping { - + /** - * Constants describing the side of a sensor + * Electron side of a sensor. */ public static final String ELECTRON = "ELECTRON"; + + /** + * Positron side of a sensor. + */ public static final String POSITRON = "POSITRON"; /** - * Default Constructor + * Default Constructor. */ - public SvtDaqMapping() { + public SvtDaqMapping() { } - + /** - * Constructor + * Constructor that takes FEB ID and Hybrid ID. * - * @param febID : The Front End Board (FEB) ID (0-9) - * @param febHybridID : The FEB hybrid ID (0-3) + * @param febID the Front End Board (FEB) ID (0-9) + * @param febHybridID the FEB hybrid ID (0-3) */ - public SvtDaqMapping(int febID, int febHybridID) { + public SvtDaqMapping(final int febID, final int febHybridID) { this.setFebID(febID); this.setFebHybridID(febHybridID); } - + + /** + * 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 + * 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 */ - public Pair<Integer, Integer> getDaqPair(HpsSiSensor sensor) { + @Override + public Pair<Integer, Integer> getDaqPair(final HpsSiSensor sensor) { - String svtHalf = sensor.isTopLayer() ? TOP_HALF : BOTTOM_HALF; + 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())) { + if (svtHalf.equals(object.getSvtHalf()) && object.getLayerNumber() == sensor.getLayerNumber() + && object.getSide().equals(sensor.getSide())) { return new Pair<Integer, Integer>(object.getFebID(), object.getFebHybridID()); } @@ -63,20 +72,17 @@ } /** - * 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 (Pair<FEB ID, FEB Hybrid ID>) for a given sensor - * @return If a daqPair is found, return an "A" if the sensor - * orientation is Axial, an "S" if the orientation is Stereo or - * null if the daqPair doesn't exist. + * 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. */ - public String getOrientation(Pair<Integer, Integer> daqPair) { - + @Override + public String getOrientation(final Pair<Integer, Integer> daqPair) { for (SvtDaqMapping daqMapping : this) { - - if (daqPair.getFirstElement() == daqMapping.getFebID() && daqPair.getSecondElement() == daqMapping.getFebHybridID()) { + if (daqPair.getFirstElement() == daqMapping.getFebID() + && daqPair.getSecondElement() == daqMapping.getFebHybridID()) { return daqMapping.getOrientation(); } } @@ -85,10 +91,11 @@ /** * Convert this object to a string. - * @return This object converted to a string. + * + * @return this object converted to a string */ public String toString() { - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); buff.append("FEB ID: "); buff.append(" "); buff.append("FEB Hybrid ID: "); @@ -124,61 +131,66 @@ } /** - * Get the Front End Board (FEB) ID. + * Get the Front End Board (FEB) ID. * - * @return The FEB ID + * @return the FEB ID */ - @Field(names = {"feb_id"}) - public int getFebID() { + @Field(names = { "feb_id" }) + public final int getFebID() { return getFieldValue("feb_id"); } /** - * Get the Front End Board (FEB) hybrid ID. - * - * @param The FEB hybrid ID + * Get the Front End Board (FEB) hybrid ID. + * + * @return the FEB Hybrid ID */ - @Field(names = {"feb_hybrid_id"}) - public int getFebHybridID() { + @Field(names = { "feb_hybrid_id" }) + public final int getFebHybridID() { return getFieldValue("feb_hybrid_id"); } /** - * Get the side of the sensor (ELECTRON or POSITRON). - * - * @param sensor side (ELECTRON or POSITRON) + * Get the side of the sensor (ELECTRON or POSITRON). + * + * @see {@link #ELECTRON} + * @see {@link #POSITRON} + * @return sensor side (ELECTRON or POSITRON) */ - @Field(names = {"side"}) - public String getSide() { + @Field(names = { "side" }) + public final String getSide() { return getFieldValue("side"); } - + /** - * Set the Front End Board (FEB) ID. - * - * @param febID : FEB ID + * Set the Front End Board (FEB) ID. + * + * @param febID the FEB ID */ - public void setFebID(int febID) { + public final void setFebID(final int febID) { this.setFieldValue("feb_id", febID); } - + /** - * Set the Front End Board (FEB) hybrid ID. - * - * @param febHybridID : FEB hybrid ID + * Set the Front End Board (FEB) hybrid ID. + * + * @param febHybridID the FEB hybrid ID */ - public void setFebHybridID(int febHybridID) { + public final void setFebHybridID(final int febHybridID) { this.setFieldValue("feb_hybrid_id", febHybridID); } - + /** - * Set the side of the sensor (ELECTRON or POSITRON). - * - * @param side : sensor side (ELECTRON or POSITRON) + * Set the side of the sensor (ELECTRON or POSITRON). + * + * @param side the sensor side (ELECTRON or POSITRON) + * @see {@link #ELECTRON} + * @see {@link #POSITRON} */ - public void setSide(String side) { - if (!side.equals(SvtDaqMapping.ELECTRON) && !side.equals(SvtDaqMapping.POSITRON)) + public final void setSide(final String side) { + if (!side.equals(SvtDaqMapping.ELECTRON) && !side.equals(SvtDaqMapping.POSITRON)) { throw new RuntimeException("[ " + this.getClass().getSimpleName() + " ]: Invalid value for sensor side."); + } this.setFieldValue("side", side); } -} +} Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java Mon Apr 6 18:17:40 2015 @@ -22,47 +22,89 @@ /** - * This class puts {@link SvtConditions} data onto <code>HpsSiSensor</code> - * objects. + * This class puts {@link SvtConditions} data onto <code>HpsSiSensor</code> objects. * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * @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 SvtDetectorSetup implements ConditionsListener { - private static Logger logger = LogUtil.create(SvtDetectorSetup.class); - + /** + * The number of noise samples. + */ + private static final int NOISE_COUNT = 6; + + /** + * The number of pedestals. + */ + private static final int PEDESTAL_COUNT = 6; + + /** + * Initialize logger. + */ + private static Logger logger = LogUtil.create(SvtDetectorSetup.class); + + /** + * The name of the SVT subdetector in the detector model. + */ private String svtName = "Tracker"; + + /** + * Flag to enable/disable this class from within conditions manager. + */ private boolean enabled = true; - - public SvtDetectorSetup(String svtName) { + + /** + * Constructor that takes name of SVT. + * @param svtName the name of the SVT subdetector + */ + public SvtDetectorSetup(final String svtName) { this.svtName = svtName; } - - public void setSvtName(String svtName) { + + /** + * Set the name of the SVT in the detector model. + * @param svtName the name of the SVt in the detector model. + */ + public void setSvtName(final String svtName) { this.svtName = svtName; } - - public void setEnabled(boolean enabled) { + + /** + * Set whether this class is enabled to be activated on conditions changes. + * @param enabled <code>true</code> to enable + */ + public void setEnabled(final boolean enabled) { this.enabled = enabled; } - - public void setLogLevel(Level level) { + + /** + * Set the log level. + * @param level the log level + */ + public void setLogLevel(final Level level) { logger.setLevel(level); logger.getHandlers()[0].setLevel(level); } - + + /** + * Hook that activates this class when conditions change (new detector or run number). + * + * @param event the conditions event + */ @Override - public void conditionsChanged(ConditionsEvent event) { + public void conditionsChanged(final ConditionsEvent event) { if (enabled) { - DatabaseConditionsManager manager = (DatabaseConditionsManager) event.getConditionsManager(); - Subdetector subdetector = manager.getDetectorObject().getSubdetector(svtName); + final DatabaseConditionsManager manager = (DatabaseConditionsManager) event.getConditionsManager(); + final Subdetector subdetector = manager.getDetectorObject().getSubdetector(svtName); if (subdetector != null) { if (manager.isTestRun()) { - TestRunSvtConditions svtConditions = manager.getCachedConditions(TestRunSvtConditions.class, "test_run_svt_conditions").getCachedData(); + final TestRunSvtConditions svtConditions = manager.getCachedConditions( + TestRunSvtConditions.class, "test_run_svt_conditions").getCachedData(); loadTestRun(subdetector, svtConditions); } else { - SvtConditions svtConditions = manager.getCachedConditions(SvtConditions.class, "svt_conditions").getCachedData(); + final SvtConditions svtConditions = manager.getCachedConditions( + SvtConditions.class, "svt_conditions").getCachedData(); loadDefault(subdetector, svtConditions); } } else { @@ -73,24 +115,24 @@ logger.config("disabled"); } } - + /** * Load conditions data onto a detector object. - * - * @param The detector object. - * @param conditions The conditions object. - */ - void loadDefault(Subdetector subdetector, SvtConditions conditions) { + * + * @param subdetector the SVT subdetector object + * @param conditions the conditions object + */ + void loadDefault(final Subdetector subdetector, final SvtConditions conditions) { logger.info("loading SVT conditions onto subdetector " + subdetector.getName()); - + // Find sensor objects. - List<HpsSiSensor> sensors = subdetector.getDetectorElement().findDescendants(HpsSiSensor.class); + final List<HpsSiSensor> sensors = subdetector.getDetectorElement().findDescendants(HpsSiSensor.class); logger.info("setting up " + sensors.size() + " SVT sensors"); - SvtChannelCollection channelMap = conditions.getChannelMap(); + final SvtChannelCollection channelMap = conditions.getChannelMap(); logger.info("channel map has " + conditions.getChannelMap().size() + " entries"); - SvtDaqMappingCollection daqMap = conditions.getDaqMap(); - SvtT0ShiftCollection t0Shifts = conditions.getT0Shifts(); + final SvtDaqMappingCollection daqMap = conditions.getDaqMap(); + final SvtT0ShiftCollection t0Shifts = conditions.getT0Shifts(); // Loop over sensors. for (HpsSiSensor sensor : sensors) { @@ -99,7 +141,7 @@ sensor.reset(); // Get DAQ pair (FEB ID, FEB Hybrid ID) corresponding to this sensor - Pair<Integer, Integer> daqPair = daqMap.getDaqPair(sensor); + final Pair<Integer, Integer> daqPair = daqMap.getDaqPair(sensor); if (daqPair == null) { throw new RuntimeException("Failed to find DAQ pair for sensor: " + sensor.getName()); } @@ -111,7 +153,7 @@ sensor.setFebHybridID(daqPair.getSecondElement()); // Set the orientation of the sensor - String orientation = daqMap.getOrientation(daqPair); + final String orientation = daqMap.getOrientation(daqPair); if (orientation != null && orientation.contentEquals(SvtDaqMapping.AXIAL)) { sensor.setAxial(true); } else if (orientation != null && orientation.contains(SvtDaqMapping.STEREO)) { @@ -119,14 +161,14 @@ } // Find all the channels for this sensor. - Collection<SvtChannel> channels = channelMap.find(daqPair); + final Collection<SvtChannel> channels = channelMap.find(daqPair); // Loop over the channels of the sensor. for (SvtChannel channel : channels) { // Get conditions data for this channel. - ChannelConstants constants = conditions.getChannelConstants(channel); - int channelNumber = channel.getChannel(); + final ChannelConstants constants = conditions.getChannelConstants(channel); + final int channelNumber = channel.getChannel(); // // Set conditions data for this channel on the sensor object: @@ -139,8 +181,8 @@ // Set the pedestal and noise of each of the samples for the // channel - double[] pedestal = new double[6]; - double[] noise = new double[6]; + final double[] pedestal = new double[PEDESTAL_COUNT]; + final double[] noise = new double[NOISE_COUNT]; for (int sampleN = 0; sampleN < HpsSiSensor.NUMBER_OF_SAMPLES; sampleN++) { pedestal[sampleN] = constants.getCalibration().getPedestal(sampleN); noise[sampleN] = constants.getCalibration().getNoise(sampleN); @@ -157,22 +199,27 @@ } // Set the t0 shift for the sensor. - SvtT0Shift sensorT0Shift = t0Shifts.getT0Shift(daqPair); + final SvtT0Shift sensorT0Shift = t0Shifts.getT0Shift(daqPair); sensor.setT0Shift(sensorT0Shift.getT0Shift()); } } - void loadTestRun(Subdetector subdetector, TestRunSvtConditions conditions) { - - logger.info("loading Test Run SVT conditions onto subdetector " + subdetector.getName()); - + /** + * Load conditions from Test Run detector. + * @param subdetector the SVT subdetector object + * @param conditions the Test Run conditions + */ + void loadTestRun(final Subdetector subdetector, final TestRunSvtConditions conditions) { + + logger.info("loading Test Run SVT conditions onto subdetector " + subdetector.getName()); + // Find sensor objects. - List<HpsSiSensor> sensors = subdetector.getDetectorElement().findDescendants(HpsSiSensor.class); + final List<HpsSiSensor> sensors = subdetector.getDetectorElement().findDescendants(HpsSiSensor.class); logger.info("setting up " + sensors.size() + " SVT sensors"); - TestRunSvtChannelCollection channelMap = conditions.getChannelMap(); + final TestRunSvtChannelCollection channelMap = conditions.getChannelMap(); logger.info("channel map has " + channelMap.size() + " entries"); - TestRunSvtDaqMappingCollection daqMap = conditions.getDaqMap(); - TestRunSvtT0ShiftCollection t0Shifts = conditions.getT0Shifts(); + final TestRunSvtDaqMappingCollection daqMap = conditions.getDaqMap(); + final TestRunSvtT0ShiftCollection t0Shifts = conditions.getT0Shifts(); // Loop over sensors. for (HpsSiSensor sensor : sensors) { @@ -181,7 +228,7 @@ sensor.reset(); // Get DAQ pair (FPGA ID, Hybrid ID) corresponding to this sensor - Pair<Integer, Integer> daqPair = daqMap.getDaqPair(sensor); + final Pair<Integer, Integer> daqPair = daqMap.getDaqPair(sensor); if (daqPair == null) { throw new RuntimeException("Failed to find DAQ pair for sensor: " + sensor.getName()); } @@ -193,7 +240,7 @@ ((HpsTestRunSiSensor) sensor).setHybridID(daqPair.getSecondElement()); // Set the orientation of the sensor - String orientation = daqMap.getOrientation(daqPair); + final String orientation = daqMap.getOrientation(daqPair); if (orientation != null && orientation.contentEquals(TestRunSvtDaqMapping.AXIAL)) { sensor.setAxial(true); } else if (orientation != null && orientation.contains(TestRunSvtDaqMapping.STEREO)) { @@ -201,14 +248,14 @@ } // Find all the channels for this sensor. - Collection<TestRunSvtChannel> channels = channelMap.find(daqPair); + final Collection<TestRunSvtChannel> channels = channelMap.find(daqPair); // Loop over the channels of the sensor. for (TestRunSvtChannel channel : channels) { // Get conditions data for this channel. - ChannelConstants constants = conditions.getChannelConstants(channel); - int channelNumber = channel.getChannel(); + final ChannelConstants constants = conditions.getChannelConstants(channel); + final int channelNumber = channel.getChannel(); // // Set conditions data for this channel on the sensor object: @@ -221,8 +268,8 @@ // Set the pedestal and noise of each of the samples for the // channel - double[] pedestal = new double[6]; - double[] noise = new double[6]; + final double[] pedestal = new double[6]; + final double[] noise = new double[6]; for (int sampleN = 0; sampleN < HpsTestRunSiSensor.NUMBER_OF_SAMPLES; sampleN++) { pedestal[sampleN] = constants.getCalibration().getPedestal(sampleN); noise[sampleN] = constants.getCalibration().getNoise(sampleN); @@ -239,7 +286,7 @@ } // Set the t0 shift for the sensor. - TestRunSvtT0Shift sensorT0Shift = t0Shifts.getT0Shift(daqPair); + final TestRunSvtT0Shift sensorT0Shift = t0Shifts.getT0Shift(daqPair); sensor.setT0Shift(sensorT0Shift.getT0Shift()); } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java Mon Apr 6 18:17:40 2015 @@ -8,39 +8,47 @@ import org.hps.conditions.database.Table; /** - * This class represents gain measurements for a single SVT channel. - * @author Jeremy McCormick <[log in to unmask]> + * This class represents the signal gain measurement for a single SVT channel. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -@Table(names = {"svt_gains", "test_run_svt_gains"}) +@Table(names = { "svt_gains", "test_run_svt_gains" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public final class SvtGain extends BaseConditionsObject { + /** + * Collection implementation for {@link SvtGain} objects. + */ + @SuppressWarnings("serial") public static class SvtGainCollection extends BaseConditionsObjectCollection<SvtGain> { } /** * Get the channel ID. + * * @return The channel ID. */ - @Field(names = {"svt_channel_id"}) + @Field(names = { "svt_channel_id" }) public int getChannelID() { return getFieldValue(Integer.class, "svt_channel_id"); } /** * Get the gain. + * * @return The gain value. */ - @Field(names = {"gain"}) + @Field(names = { "gain" }) public double getGain() { return getFieldValue(Double.class, "gain"); } /** * Get the offset. + * * @return The offset value. */ - @Field(names = {"offset"}) + @Field(names = { "offset" }) public double getOffset() { return getFieldValue(Double.class, "offset"); } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtShapeFitParameters.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtShapeFitParameters.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtShapeFitParameters.java Mon Apr 6 18:17:40 2015 @@ -9,59 +9,69 @@ /** * This class encapsulates the shape fit parameters for an SVT channel. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -@Table(names = {"svt_shape_fit_parameters", "test_run_svt_shape_fit_parameters"}) +@Table(names = { "svt_shape_fit_parameters", "test_run_svt_shape_fit_parameters" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) +// TODO: This class needs better documentation as to what these parameters actually mean. public final class SvtShapeFitParameters extends BaseConditionsObject { + /** + * Collection implementation for {@link SvtShapeFitParameters} objects. + */ + @SuppressWarnings("serial") public static class SvtShapeFitParametersCollection extends BaseConditionsObjectCollection<SvtShapeFitParameters> { } /** * Get the SVT channel ID. + * * @return The SVT channel ID. */ - @Field(names = {"svt_channel_id"}) + @Field(names = { "svt_channel_id" }) public int getChannelID() { return getFieldValue(Integer.class, "svt_channel_id"); } /** * Get the amplitude. + * * @return The amplifude. */ - @Field(names = {"amplitude"}) + @Field(names = { "amplitude" }) public double getAmplitude() { return getFieldValue(Double.class, "amplitude"); } /** * Get t0. - * @return t0. + * + * @return t0 */ - @Field(names = {"t0"}) + @Field(names = { "t0" }) public double getT0() { return getFieldValue(Double.class, "t0"); } /** * Get tp. - * @return tp. + * + * @return tp */ - @Field(names = {"tp"}) + @Field(names = { "tp" }) public double getTp() { return getFieldValue(Double.class, "tp"); } /** * Convert this object to an array of doubles. + * * @return This object converted to an array of doubles. */ public double[] toArray() { - double[] values = new double[3]; + final double[] values = new double[3]; values[0] = getAmplitude(); values[1] = getT0(); values[2] = getTp(); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtT0Shift.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtT0Shift.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtT0Shift.java Mon Apr 6 18:17:40 2015 @@ -7,29 +7,32 @@ import org.hps.util.Pair; /** - * This class is a data holder for associating a t0 shift with a specific sensor - * by FEB ID and FEB hybrid ID. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * This class is a data holder for associating a t0 time shift with a specific sensor by DAQ pair + * (FEB ID and FEB hybrid ID). + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -@Table(names = {"svt_t0_shifts"}) +@Table(names = { "svt_t0_shifts" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public final class SvtT0Shift extends AbstractSvtT0Shift { + /** + * Concrete collection implementation for {@link SvtT0Shift}. + */ + @SuppressWarnings("serial") public static class SvtT0ShiftCollection extends AbstractSvtT0Shift.AbstractSvtT0ShiftCollection<SvtT0Shift> { /** - * Get the {@link SvtT0Shift} associated with a given DAQ pair - * + * Get the {@link SvtT0Shift} associated with a given DAQ pair. + * * @param DAQ pair for a given sensor - * @return The {@link SvtT0Shift} associated with the DAQ pair. If a t0 - * shift for a given DAQ pair can't be found, it returns null. + * @return the {@link SvtT0Shift} associated with the DAQ pair or null if does not exist */ @Override - public SvtT0Shift getT0Shift(Pair<Integer, Integer> pair) { - int febID = pair.getFirstElement(); - int febHybridID = pair.getSecondElement(); + public SvtT0Shift getT0Shift(final Pair<Integer, Integer> pair) { + final int febID = pair.getFirstElement(); + final int febHybridID = pair.getSecondElement(); for (SvtT0Shift t0Shift : this) { if (t0Shift.getFebID() == febID && t0Shift.getFebHybridID() == febHybridID) { return t0Shift; @@ -41,10 +44,10 @@ /** * Get the FEB ID. - * - * @return The FEB ID. + * + * @return the FEB ID */ - @Field(names = {"feb_id"}) + @Field(names = { "feb_id" }) public int getFebID() { return getFieldValue("feb_id"); } @@ -52,9 +55,9 @@ /** * Get the FEB hybrid ID. * - * @return The FEB hybrid ID. + * @return the FEB hybrid ID */ - @Field(names = {"feb_hybrid_id"}) + @Field(names = { "feb_hybrid_id" }) public int getFebHybridID() { return getFieldValue("feb_hybrid_id"); } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtChannel.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtChannel.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtChannel.java Mon Apr 6 18:17:40 2015 @@ -10,18 +10,34 @@ import org.hps.conditions.database.Table; import org.hps.util.Pair; +/** + * The implementation of {@link AbstractSvtChannel} for Test Run conditions. + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> + */ @Table(names = {"test_run_svt_channels"}) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public final class TestRunSvtChannel extends AbstractSvtChannel { - public static class TestRunSvtChannelCollection extends AbstractSvtChannel.AbstractSvtChannelCollection<TestRunSvtChannel> { + /** + * Concrete collection implementation for {@link TestRunSvtChannel} objects. + */ + @SuppressWarnings("serial") + public static class TestRunSvtChannelCollection + extends AbstractSvtChannel.AbstractSvtChannelCollection<TestRunSvtChannel> { + /** + * Find a collection of channels by their DAQ pair assignment. + * + * @param the DAQ pair (FEB ID and FEB Hybrid ID) + * @return the collection of channels + */ @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) { + public Collection<TestRunSvtChannel> find(final Pair<Integer, Integer> pair) { + final List<TestRunSvtChannel> channels = new ArrayList<TestRunSvtChannel>(); + final int fpga = pair.getFirstElement(); + final int hybrid = pair.getSecondElement(); + for (final TestRunSvtChannel channel : this) { if (channel.getFpgaID() == fpga && channel.getHybridID() == hybrid) { channels.add(channel); } @@ -32,8 +48,8 @@ /** * Get the FPGA ID. - * - * @return The FPGA ID + * + * @return the FPGA ID */ @Field(names = {"fpga"}) public int getFpgaID() { @@ -42,8 +58,8 @@ /** * Get the hybrid ID. - * - * @return The hybrid ID. + * + * @return the hybrid ID */ @Field(names = {"hybrid"}) public int getHybridID() { @@ -52,16 +68,21 @@ /** * Implementation of equals. - * @return True if the object equals this one; false if not. + * @param o the other object + * @return <code>true</code> if the object equals this one; false if not. */ - public boolean equals(Object o) { - if (o == null) + public boolean equals(final Object o) { + if (o == null) { return false; - if (!(o instanceof TestRunSvtChannel)) + } + if (!(o instanceof TestRunSvtChannel)) { return false; - if (o == this) + } + if (o == this) { return true; - TestRunSvtChannel channel = (TestRunSvtChannel) o; - return getChannelID() == channel.getChannelID() && getFpgaID() == channel.getFpgaID() && getHybridID() == channel.getHybridID() && getChannel() == channel.getChannel(); + } + final TestRunSvtChannel channel = (TestRunSvtChannel) o; + return getChannelID() == channel.getChannelID() && getFpgaID() == channel.getFpgaID() + && getHybridID() == channel.getHybridID() && getChannel() == channel.getChannel(); } } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditions.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditions.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditions.java Mon Apr 6 18:17:40 2015 @@ -13,16 +13,21 @@ * {@link TestRunSvtChannel} objects from the SVT channel map should be used to * lookup the conditions using the * {@link #getChannelConstants(TestRunSvtChannel)} method. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * + * @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 TestRunSvtConditions extends AbstractSvtConditions { /** + * Length of divider when printing. + */ + private static final int DIVIDER_LEN = 115; + + /** * Get the {@link TestRunSvtDaqMappingCollection} associated with these * conditions. - * + * * @return The SVT DAQ map. */ @Override @@ -32,7 +37,7 @@ /** * Get the {@link TestRunSvtChannelCollection} for this set of conditions. - * + * * @return The SVT channel map. */ @Override @@ -43,7 +48,7 @@ /** * Get the {@link TestRunSvtT0ShiftCollection} associated with these * conditions. - * + * * @return The {@link TestRunSvtT0ShiftCollection} */ @Override @@ -56,11 +61,10 @@ * 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. + * + * @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(); @@ -114,7 +118,7 @@ buff.append(" "); buff.append("Bad Channels"); buff.append('\n'); - for (int i = 0; i < 115; i++) { + for (int i = 0; i < DIVIDER_LEN; i++) { buff.append("-"); } buff.append('\n'); @@ -124,10 +128,10 @@ 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(); + final ChannelConstants constants = getChannelConstants(channel); + final SvtGain gain = constants.getGain(); + final SvtShapeFitParameters shapeFit = constants.getShapeFitParameters(); + final SvtCalibration calibration = constants.getCalibration(); // Channel data. buff.append(String.format("%-6d %-5d %-8d %-8d ", channel.getChannelID(), channel.getFpgaID(), channel.getHybridID(), channel.getChannel())); @@ -146,7 +150,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/TestRunSvtConditionsConverter.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java Mon Apr 6 18:17:40 2015 @@ -1,6 +1,5 @@ package org.hps.conditions.svt; -import org.lcsim.conditions.ConditionsManager; import org.hps.conditions.api.ConditionsSeries; import org.hps.conditions.database.DatabaseConditionsManager; import org.hps.conditions.svt.SvtBadChannel.SvtBadChannelCollection; @@ -10,53 +9,92 @@ import org.hps.conditions.svt.TestRunSvtChannel.TestRunSvtChannelCollection; import org.hps.conditions.svt.TestRunSvtDaqMapping.TestRunSvtDaqMappingCollection; import org.hps.conditions.svt.TestRunSvtT0Shift.TestRunSvtT0ShiftCollection; +import org.lcsim.conditions.ConditionsManager; +/** + * Converter for combined Test Run SVT conditions {@link TestRunSvtConditions} object. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + */ public final class TestRunSvtConditionsConverter extends AbstractSvtConditionsConverter<TestRunSvtConditions> { + /** + * Class constructor. + */ public TestRunSvtConditionsConverter() { this.conditions = new TestRunSvtConditions(); } - - protected SvtShapeFitParametersCollection getSvtShapeFitParametersCollection(DatabaseConditionsManager manager) { - return manager.getCachedConditions(SvtShapeFitParametersCollection.class, "test_run_svt_shape_fit_parameters").getCachedData(); + + /** + * Get the Test Run {@link SvtShapeFitParametersCollection}. + * + * @param manager the conditions manager + * @return the Test Run {@link SvtShapeFitParametersCollection} + */ + protected SvtShapeFitParametersCollection getSvtShapeFitParametersCollection( + final DatabaseConditionsManager manager) { + return manager.getCachedConditions(SvtShapeFitParametersCollection.class, + "test_run_svt_shape_fit_parameters").getCachedData(); } - - protected ConditionsSeries<SvtBadChannel, SvtBadChannelCollection> getSvtBadChannelSeries(DatabaseConditionsManager manager) { + + /** + * Get the Test Run series of {@link SvtBadChannelCollection} objects + * + * @param manager the conditions manager + * @return the Test Run bad channel collections + */ + protected ConditionsSeries<SvtBadChannel, SvtBadChannelCollection> getSvtBadChannelSeries( + final DatabaseConditionsManager manager) { return manager.getConditionsSeries(SvtBadChannelCollection.class, "test_run_svt_bad_channels"); } - - protected SvtCalibrationCollection getSvtCalibrationCollection(DatabaseConditionsManager manager) { + + /** + * Get the Test Run {@link SvtCalibrationCollection}. + * + * @param manager the conditions manager + * @return the Test Run {@link SvtCalibrationCollection} + */ + protected SvtCalibrationCollection getSvtCalibrationCollection(final DatabaseConditionsManager manager) { return manager.getCachedConditions(SvtCalibrationCollection.class, "test_run_svt_calibrations").getCachedData(); } - - protected SvtGainCollection getSvtGainCollection(DatabaseConditionsManager manager) { + + /** + * Get the Test Run {@link SvtGainCollection}. + * + * @param manager the conditions manager + * @return the Test Run {@link SvtGainCollection} + */ + protected SvtGainCollection getSvtGainCollection(final DatabaseConditionsManager manager) { return manager.getCachedConditions(SvtGainCollection.class, "test_run_svt_gains").getCachedData(); } /** - * Create and return an {@link TestRunSvtConditions} object - * + * 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) { + public TestRunSvtConditions getData(final ConditionsManager manager, final String name) { - DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager; + final DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager; // Get the channel map from the conditions database - TestRunSvtChannelCollection channels = dbConditionsManager.getCachedConditions(TestRunSvtChannelCollection.class, "test_run_svt_channels").getCachedData(); + final TestRunSvtChannelCollection channels = dbConditionsManager.getCachedConditions( + TestRunSvtChannelCollection.class, "test_run_svt_channels").getCachedData(); // 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 = dbConditionsManager.getCachedConditions(TestRunSvtDaqMappingCollection.class, "test_run_svt_daq_map").getCachedData(); + final TestRunSvtDaqMappingCollection daqMap = dbConditionsManager.getCachedConditions( + TestRunSvtDaqMappingCollection.class, "test_run_svt_daq_map").getCachedData(); conditions.setDaqMap(daqMap); // Get the collection of T0 shifts from the conditions database - TestRunSvtT0ShiftCollection t0Shifts = dbConditionsManager.getCachedConditions(TestRunSvtT0ShiftCollection.class, "test_run_svt_t0_shifts").getCachedData(); + final TestRunSvtT0ShiftCollection t0Shifts = dbConditionsManager.getCachedConditions( + TestRunSvtT0ShiftCollection.class, "test_run_svt_t0_shifts").getCachedData(); conditions.setT0Shifts(t0Shifts); conditions = super.getData(manager, name); Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtDaqMapping.java Mon Apr 6 18:17:40 2015 @@ -6,29 +6,31 @@ import org.hps.conditions.database.Table; import org.hps.util.Pair; import org.lcsim.detector.tracker.silicon.HpsSiSensor; -import org.lcsim.detector.tracker.silicon.HpsTestRunSiSensor; /** - * This class encapsulates the Test run SVT DAQ map. - * - * @author Omar Moreno <[log in to unmask]> + * This class encapsulates the Test Run SVT DAQ map. + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -@Table(names = {"test_run_svt_daq_map"}) +@Table(names = { "test_run_svt_daq_map" }) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public final class TestRunSvtDaqMapping extends AbstractSvtDaqMapping { + /** + * The collection implementation for {@link TestRunSvtDaqMapping} objects. + */ public static class TestRunSvtDaqMappingCollection extends AbstractSvtDaqMappingCollection<TestRunSvtDaqMapping> { /** - * Get a test run DAQ pair (FPGA and Hybrid ID) for the given - * {@linkplain HpsTestRunSiSensor} - * - * @param sensor A sensor of type {@link HpsTestRunSiSensor} - * @return The DAQ pair associated with the sensor + * Get a test run DAQ pair (FPGA and Hybrid ID) for the given {@linkplain HpsTestRunSiSensor}. + * + * @param sensor a sensor of type {@link HpsTestRunSiSensor} + * @return the DAQ pair associated with the sensor */ - public Pair<Integer, Integer> getDaqPair(HpsSiSensor sensor) { + @Override + public Pair<Integer, Integer> getDaqPair(final HpsSiSensor sensor) { - String svtHalf = sensor.isTopLayer() ? TOP_HALF : BOTTOM_HALF; + final String svtHalf = sensor.isTopLayer() ? TOP_HALF : BOTTOM_HALF; for (TestRunSvtDaqMapping daqMapping : this) { if (svtHalf.equals(daqMapping.getSvtHalf()) && daqMapping.getLayerNumber() == sensor.getLayerNumber()) { @@ -40,19 +42,17 @@ } /** - * Get the orientation of a sensor using the FPGA and Hybrid ID. If the - * FPGA and Hybrid ID combination is not found, return null. + * Get the orientation of a sensor using the FPGA and Hybrid ID. If the FPGA and Hybrid ID combination is not + * found, return null. * * @param daqPair (Pair<FPGA ID, Hybrid ID>) for a given sensor - * @return If a daqPair is found, return an "A" if the sensor - * orientation is Axial, an "S" if the orientation is Stereo or - * null if the daqPair doesn't exist. + * @return "A" if sensor orientation is Axial; "S" if Stereo; null if daqPair doesn't exist */ - public String getOrientation(Pair<Integer, Integer> daqPair) { - - for (TestRunSvtDaqMapping daqMapping : this) { - - if (daqPair.getFirstElement() == ((TestRunSvtDaqMapping) daqMapping).getFpgaID() && daqPair.getSecondElement() == ((TestRunSvtDaqMapping) daqMapping).getHybridID()) { + @Override + public String getOrientation(final Pair<Integer, Integer> daqPair) { + for (final TestRunSvtDaqMapping daqMapping : this) { + if (daqPair.getFirstElement() == ((TestRunSvtDaqMapping) daqMapping).getFpgaID() + && daqPair.getSecondElement() == ((TestRunSvtDaqMapping) daqMapping).getHybridID()) { return daqMapping.getOrientation(); } } @@ -61,10 +61,11 @@ /** * Convert {@link TestRunSvtDaqMapping} to a string. + * * @return This object converted to a string. */ public String toString() { - StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = new StringBuffer(); buffer.append("FPGA ID: "); buffer.append(" "); buffer.append("Hybrid ID: "); @@ -79,7 +80,7 @@ buffer.append("----------------------"); buffer.append('\n'); for (TestRunSvtDaqMapping daqMapping : this) { - TestRunSvtDaqMapping testRunDaqMapping = (TestRunSvtDaqMapping) daqMapping; + final TestRunSvtDaqMapping testRunDaqMapping = (TestRunSvtDaqMapping) daqMapping; buffer.append(testRunDaqMapping.getFpgaID()); buffer.append(" "); buffer.append(testRunDaqMapping.getHybridID()); @@ -96,12 +97,22 @@ } } - @Field(names = {"fpga"}) + /** + * Get the FPGA ID. + * + * @return the FPGA ID + */ + @Field(names = { "fpga" }) public int getFpgaID() { return getFieldValue("fpga"); } - @Field(names = {"hybrid"}) + /** + * Get the Hybrid ID. + * + * @return the Hybrid ID + */ + @Field(names = { "hybrid" }) public int getHybridID() { return getFieldValue("hybrid"); } Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtT0Shift.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtT0Shift.java (original) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtT0Shift.java Mon Apr 6 18:17:40 2015 @@ -9,29 +9,31 @@ /** * This class is a container that allows associating a t0 shift with a specific * sensor by FPGA ID and hybrid ID. - * - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ @Table(names = {"test_run_svt_t0_shifts"}) @Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED) public final class TestRunSvtT0Shift extends AbstractSvtT0Shift { - public static class TestRunSvtT0ShiftCollection extends AbstractSvtT0Shift.AbstractSvtT0ShiftCollection<TestRunSvtT0Shift> { + /** + * Collection implementation for {@link TestRunSvtT0Shift} objects. + */ + @SuppressWarnings("serial") + public static class TestRunSvtT0ShiftCollection + extends AbstractSvtT0Shift.AbstractSvtT0ShiftCollection<TestRunSvtT0Shift> { /** * Get the {@link TestRunSvtT0Shift} associated with a given DAQ pair - * + * * @param DAQ pair for a given sensor - * @return The {@link TestRunSvtT0Shift} associated with the DAQ pair. - * If a t0 shift for a given DAQ pair can't be found, it returns - * null. + * @return the {@link TestRunSvtT0Shift} associated with the DAQ pair or null if does not exist */ @Override - public TestRunSvtT0Shift getT0Shift(Pair<Integer, Integer> pair) { - - int fpgaID = pair.getFirstElement(); - int hybridID = pair.getSecondElement(); - for (TestRunSvtT0Shift t0Shift : this) { + public TestRunSvtT0Shift getT0Shift(final Pair<Integer, Integer> pair) { + final int fpgaID = pair.getFirstElement(); + final int hybridID = pair.getSecondElement(); + for (final TestRunSvtT0Shift t0Shift : this) { if (t0Shift.getFpgaID() == fpgaID && t0Shift.getHybridID() == hybridID) { return t0Shift; } @@ -42,8 +44,8 @@ /** * Get the FPGA ID. - * - * @return The FPGA ID. + * + * @return the FPGA ID */ @Field(names = {"fpga"}) public int getFpgaID() { @@ -52,8 +54,8 @@ /** * Get the hybrid ID. - * - * @return The hybrid ID. + * + * @return the hybrid ID */ @Field(names = {"hybrid"}) public int getHybridID() { Added: java/trunk/conditions/src/main/java/org/hps/conditions/svt/package-info.java ============================================================================= --- java/trunk/conditions/src/main/java/org/hps/conditions/svt/package-info.java (added) +++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/package-info.java Mon Apr 6 18:17:40 2015 @@ -0,0 +1,16 @@ +/** + * Implementation of detector conditions API for the HPS SVT. + * + * @see org.hps.conditions.api + * @see org.hps.conditions.api.ConditionsObject + * @see org.hps.conditions.api.ConditionsObjectCollection + * @see SvtChannel + * @see SvtConditions + * @see SvtGain + * @see SvtCalibration + * @see SvtT0Shift + * @see SvtBadChannel + * @author <a href="[log in to unmask]">Omar Moreno</a> + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + */ +package org.hps.conditions.svt; Modified: java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsDriverTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsDriverTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/ConditionsDriverTest.java Mon Apr 6 18:17:40 2015 @@ -14,36 +14,53 @@ /** * This is a basic test of using ConditionsDriver that doesn't actually check anything at the moment. - * @author Jeremy McCormick <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class ConditionsDriverTest extends TestCase { - +public final class ConditionsDriverTest extends TestCase { + + /** + * The run number to use for the test. + */ + private static final int RUN_NUMBER = 1351; + + /** + * Test the {@link ConditionsDriver} on Test Run data. + * @throws Exception if there is a test error or conditions error + */ public void testConditionsDriverTestRun() throws Exception { - + DatabaseConditionsManager.getInstance(); - - FileCache cache = new FileCache(); - File inputFile = cache.getCachedFile(new URL("http://www.lcsim.org/test/hps-java/ConditionsTest.slcio")); - - ConditionsDriver conditionsDriver = new ConditionsDriver(); + + final FileCache cache = new FileCache(); + final File inputFile = cache.getCachedFile(new URL("http://www.lcsim.org/test/hps-java/ConditionsTest.slcio")); + + final ConditionsDriver conditionsDriver = new ConditionsDriver(); conditionsDriver.setDetectorName("HPS-TestRun-v5"); conditionsDriver.setTag("test_run"); - conditionsDriver.setRunNumber(1351); + conditionsDriver.setRunNumber(RUN_NUMBER); conditionsDriver.setFreeze(true); - - LCSimLoop loop = new LCSimLoop(); + + final LCSimLoop loop = new LCSimLoop(); loop.setLCIORecordSource(inputFile); conditionsDriver.initialize(); loop.add(new EventMarkerDriver()); loop.add(new CheckDriver()); loop.loop(-1); } - + + /** + * This {@link org.lcsim.util.Driver} prints out when the conditions change. + */ static class CheckDriver extends Driver { - public void detectorChanged(Detector detector) { - System.out.println("detectorChanged - detector " + detector.getDetectorName() + /** + * Hook for conditions system change. + * @param detector the detector object + */ + public void detectorChanged(final Detector detector) { + System.out.println("detectorChanged - detector " + detector.getDetectorName() + " and run #" + DatabaseConditionsManager.getInstance().getRun()); - } + } } } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/EngRunConditionsTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/EngRunConditionsTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/EngRunConditionsTest.java Mon Apr 6 18:17:40 2015 @@ -27,105 +27,183 @@ import org.lcsim.util.loop.LCSimLoop; /** - * <p> * This tests the basic correctness of conditions for an LCIO file generated from Engineering Run data. * <p> * Currently only ECAL conditions are handled here but SVT should be added once that information is in the * production database and there are runs available with Tracker data. * <p> - * This test will need to be updated if the default conditions sets are changed for the EngRun. - * - * @author Jeremy McCormick <[log in to unmask]> + * This test will need to be updated if the default conditions sets are changed for the Eng Run. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class EngRunConditionsTest extends TestCase { - - static String url = "http://www.lcsim.org/test/hps-java/hps_003393.0_recon_20141225-0-100.slcio"; - - static int runNumber = 3393; - static int nChannels = 442; - static int runStart = 2000; - static int runEnd = 9999; - +public final class EngRunConditionsTest extends TestCase { + + /** + * Number of events to process. + */ + private static final int EVENT_COUNT = 100; + + /** + * Data file URL. + */ + private static final String URL = "http://www.lcsim.org/test/hps-java/hps_003393.0_recon_20141225-0-100.slcio"; + + /** + * The run number to use for the test. + */ + private static final int RUN_NUMBER = 3393; + + /** + * Number of ECAL channels. + */ + private static final int CHANNEL_COUNT = 442; + + /** + * Run start. + */ + private static final int RUN_START = 2000; + + /** + * Run end. + */ + private static final int RUN_END = 9999; + + /** + * Test Eng Run conditions. + * @throws Exception if there is an error (record processing problem) + */ public void test() throws Exception { - - DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); + + final DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); DatabaseConditionsManager.getLogger().setLevel(Level.ALL); manager.setTag("pass0"); manager.setXmlConfig("/org/hps/conditions/config/conditions_database_engrun.xml"); - - FileCache cache = new FileCache(); - File inputFile = cache.getCachedFile(new URL(url)); - - LCSimLoop loop = new LCSimLoop(); + + final FileCache cache = new FileCache(); + final File inputFile = cache.getCachedFile(new URL(URL)); + + final LCSimLoop loop = new LCSimLoop(); loop.add(new EventMarkerDriver()); loop.add(new ConditionsCheckDriver()); loop.setLCIORecordSource(inputFile); - loop.loop(100); + loop.loop(EVENT_COUNT); } - - static void checkRunNumbers(BaseConditionsObjectCollection<?> collection) { - assertTrue("Run start out of range.", collection.getConditionsRecord().getRunStart() >= runStart); - assertTrue("Run end out of range.", collection.getConditionsRecord().getRunEnd() <= runEnd); + + /** + * Check the run numbers of the conditions records. + * @param collection the conditions collection + */ + static void checkRunNumbers(final BaseConditionsObjectCollection<?> collection) { + assertTrue("Run start out of range.", collection.getConditionsRecord().getRunStart() >= RUN_START); + assertTrue("Run end out of range.", collection.getConditionsRecord().getRunEnd() <= RUN_END); } - + + /** + * This {@link org.lcsim.util.Driver} performs basic conditions data checks. + */ static class ConditionsCheckDriver extends Driver { - - boolean detectorChangedCalled = false; - - EcalConditions ecalConditions; - - public void detectorChanged(Detector detector) { - - assertEquals("Wrong run number.", runNumber, DatabaseConditionsManager.getInstance().getRun()); - - DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); - - EcalChannelCollection channels = conditionsManager.getCachedConditions(EcalChannelCollection.class, "ecal_channels").getCachedData(); - assertEquals("Wrong number of channels.", nChannels, channels.size()); + + /** + * Answer for gain value check of single channel. + */ + private static final double GAIN_ANSWER = 0.17; + + /** + * Answer for noise value check of single channel. + */ + private static final double NOISE_ANSWER = 2.74; + + /** + * Answer for pedestal value check of single channel. + */ + private static final double PEDESTAL_ANSWER = 105.78; + + /** + * Collection ID of calibrations. + */ + private static final int CALIBRATIONS_COLLECTION_ID = 4; + + /** + * Collection ID of gains. + */ + private static final int GAINS_COLLECTION_ID = 4; + + /** + * Flag if {@link #detectorChanged(Detector)} is activated. + */ + private boolean detectorChangedCalled = false; + + /** + * Combined ECAL conditions object. + */ + private EcalConditions ecalConditions; + + /** + * Hook when conditions are updated. Performs various checks for test. + * @param detector the detector object + */ + public void detectorChanged(final Detector detector) { + + assertEquals("Wrong run number.", RUN_NUMBER, DatabaseConditionsManager.getInstance().getRun()); + + final DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); + + final EcalChannelCollection channels = conditionsManager.getCachedConditions( + EcalChannelCollection.class, "ecal_channels").getCachedData(); + assertEquals("Wrong number of channels.", CHANNEL_COUNT, channels.size()); assertEquals("Wrong channel collection ID.", 2, channels.getConditionsRecord().getCollectionId()); checkRunNumbers(channels); - - EcalGainCollection gains = conditionsManager.getCachedConditions(EcalGainCollection.class, "ecal_gains").getCachedData(); - assertEquals("Wrong number of gains.", nChannels, gains.size()); - assertEquals("Wrong gains collection ID.", 4, gains.getConditionsRecord().getCollectionId()); + + final EcalGainCollection gains = conditionsManager.getCachedConditions( + EcalGainCollection.class, "ecal_gains").getCachedData(); + assertEquals("Wrong number of gains.", CHANNEL_COUNT, gains.size()); + assertEquals("Wrong gains collection ID.", GAINS_COLLECTION_ID, + gains.getConditionsRecord().getCollectionId()); checkRunNumbers(gains); - - EcalCalibrationCollection calibrations = conditionsManager.getCachedConditions(EcalCalibrationCollection.class, "ecal_calibrations").getCachedData(); - assertEquals("Wrong number of calibrations.", nChannels, calibrations.size()); - assertEquals("Wrong calibrations collection ID.", 4, calibrations.getConditionsRecord().getCollectionId()); + + final EcalCalibrationCollection calibrations = conditionsManager.getCachedConditions( + EcalCalibrationCollection.class, "ecal_calibrations").getCachedData(); + assertEquals("Wrong number of calibrations.", CHANNEL_COUNT, calibrations.size()); + assertEquals("Wrong calibrations collection ID.", CALIBRATIONS_COLLECTION_ID, + calibrations.getConditionsRecord().getCollectionId()); checkRunNumbers(calibrations); - + //EcalLedCollection leds = conditionsManager.getCollection(EcalLedCollection.class); //assertEquals("Wrong number of LEDs.", nChannels, leds.size()); //assertEquals("Wrong LEDs collection ID.", 2, leds.getConditionsRecord().getCollectionId()); //checkRunNumbers(leds); - + //EcalTimeShiftCollection timeShifts = conditionsManager.getCollection(EcalTimeShiftCollection.class); //assertEquals("Wrong number of timeShifts.", nChannels, timeShifts.size()); //assertEquals("Wrong LEDs collection ID.", 2, timeShifts.getConditionsRecord().getCollectionId()); //checkRunNumbers(timeShifts); - - ecalConditions = conditionsManager.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData(); - Set<EcalChannelConstants> channelConstants = new LinkedHashSet<EcalChannelConstants>(); + + ecalConditions = conditionsManager.getCachedConditions( + EcalConditions.class, "ecal_conditions").getCachedData(); + final Set<EcalChannelConstants> channelConstants = new LinkedHashSet<EcalChannelConstants>(); for (EcalChannel channel : ecalConditions.getChannelCollection().sorted()) { channelConstants.add(ecalConditions.getChannelConstants(channel)); } - assertEquals("Wrong number of channel constants.", nChannels, channelConstants.size()); - - EcalChannelConstants channelInfo = channelConstants.iterator().next(); - assertEquals("Wrong pedestal value.", 105.78, channelInfo.getCalibration().getPedestal()); - assertEquals("Wrong noise value.", 2.74, channelInfo.getCalibration().getNoise()); - assertEquals("Wrong gain value.", 0.17, channelInfo.getGain().getGain()); - + assertEquals("Wrong number of channel constants.", CHANNEL_COUNT, channelConstants.size()); + + final EcalChannelConstants channelInfo = channelConstants.iterator().next(); + assertEquals("Wrong pedestal value.", PEDESTAL_ANSWER, channelInfo.getCalibration().getPedestal()); + assertEquals("Wrong noise value.", NOISE_ANSWER, channelInfo.getCalibration().getNoise()); + assertEquals("Wrong gain value.", GAIN_ANSWER, channelInfo.getGain().getGain()); + detectorChangedCalled = true; } - - public void process(EventHeader event) { - assertEquals("Wrong run number.", runNumber, event.getRunNumber()); + + /** + * Event processing. Performs a few conditions system and geometry checks. + * @param event the LCSim event + */ + public void process(final EventHeader event) { + assertEquals("Wrong run number.", RUN_NUMBER, event.getRunNumber()); if (event.hasCollection(CalorimeterHit.class, "EcalCalHits")) { - List<CalorimeterHit> calHits = event.get(CalorimeterHit.class, "EcalCalHits"); - for (CalorimeterHit hit : calHits) { - EcalCrystal crystal = (EcalCrystal) hit.getDetectorElement(); + final List<CalorimeterHit> calHits = event.get(CalorimeterHit.class, "EcalCalHits"); + for (final CalorimeterHit hit : calHits) { + final EcalCrystal crystal = (EcalCrystal) hit.getDetectorElement(); if (crystal == null) { throw new RuntimeException("EcalCrystal is null."); } @@ -135,18 +213,23 @@ if (hit.getIdentifier() == null) { throw new RuntimeException("The hit ID is null."); } - assertEquals("The crystal and hit ID are different.", crystal.getIdentifier(), hit.getIdentifier()); - - EcalChannel channel = ecalConditions.getChannelCollection().findGeometric(hit.getIdentifier().getValue()); - EcalChannelConstants constants = ecalConditions.getChannelConstants(channel); - + assertEquals("The crystal and hit ID are different.", + crystal.getIdentifier(), hit.getIdentifier()); + + final EcalChannel channel = ecalConditions.getChannelCollection().findGeometric( + hit.getIdentifier().getValue()); + final EcalChannelConstants constants = ecalConditions.getChannelConstants(channel); + assertTrue("The crystal gain is invalid.", constants.getGain().getGain() > 0.); assertTrue("The crystal pedestal is invalid.", constants.getCalibration().getPedestal() > 0.); assertTrue("The crystal noise is invalid.", constants.getCalibration().getNoise() > 0.); } } } - + + /** + * End of data hook. Checks that {@link #detectorChanged(Detector)} was called. + */ public void endOfData() { if (!detectorChangedCalled) { throw new RuntimeException("The detectorChanged method was never called."); Modified: java/trunk/conditions/src/test/java/org/hps/conditions/RunNumberTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/RunNumberTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/RunNumberTest.java Mon Apr 6 18:17:40 2015 @@ -18,37 +18,40 @@ import org.lcsim.util.loop.LCSimLoop; /** - * This class checks that event processing works correctly for files that - * have multiple runs in them. - * - * @author Jeremy McCormick <[log in to unmask]> + * This class checks that event processing works correctly for files that have multiple runs in them. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class RunNumberTest extends TestCase { +public final class RunNumberTest extends TestCase { - // This test file has a few events from each of the "good runs" of the 2012 Test Run. - private static final String fileLocation = "http://www.lcsim.org/test/hps-java/ConditionsTest.slcio"; + /** + * Test file with a few events from each of the "good runs" of the 2012 Test Run. + */ + private static final String URL = "http://www.lcsim.org/test/hps-java/ConditionsTest.slcio"; - // Number of runs that should be processed in the job. - static final int NRUNS = 9; + /** + * Number of runs that should be processed in the job. + */ + private static final int RUN_COUNT = 9; /** * Run the test. - * @throws Exception + * @throws Exception if there is a test error */ public void test() throws Exception { // Cache a data file from the www. - FileCache cache = new FileCache(); - File testFile = cache.getCachedFile(new URL(fileLocation)); + final FileCache cache = new FileCache(); + final File testFile = cache.getCachedFile(new URL(URL)); // Create the record loop. - DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); + final DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); manager.setLogLevel(Level.WARNING); - LCSimLoop loop = new LCSimLoop(); + final LCSimLoop loop = new LCSimLoop(); // Configure the loop. loop.setLCIORecordSource(testFile); - RunNumberDriver runNumberDriver = new RunNumberDriver(); + final RunNumberDriver runNumberDriver = new RunNumberDriver(); loop.add(runNumberDriver); // Run over all events. @@ -71,16 +74,18 @@ } // Check that correct number of runs was processed. - assertEquals("Number of runs processed was incorrect.", NRUNS, runNumberDriver.nRuns); + assertEquals("Number of runs processed was incorrect.", RUN_COUNT, runNumberDriver.nRuns); // Check that the number of unique runs was correct. - assertEquals("Number of unique runs was incorrect.", NRUNS, runNumberDriver.uniqueRuns.size()); + assertEquals("Number of unique runs was incorrect.", RUN_COUNT, runNumberDriver.uniqueRuns.size()); // Check that detectorChanged was called the correct number of times. - assertEquals("The detectorChanged method was called an incorrect number of times.", NRUNS, runNumberDriver.nDetectorChanged); - + assertEquals("The detectorChanged method was called an incorrect number of times.", + RUN_COUNT, runNumberDriver.nDetectorChanged); + // Check that there was a unique Detector created for each run. - assertEquals("The number of Detector objects created was not correct.", NRUNS, runNumberDriver.uniqueDetectorObjects.size()); + assertEquals("The number of Detector objects created was not correct.", + RUN_COUNT, runNumberDriver.uniqueDetectorObjects.size()); } /** @@ -88,16 +93,41 @@ */ static class RunNumberDriver extends Driver { - int nRuns = 0; - int nDetectorChanged = 0; - List<Integer> runsProcessed = new ArrayList<Integer>(); - Set<Integer> uniqueRuns = new LinkedHashSet<Integer>(); - Set<Detector> uniqueDetectorObjects = new HashSet<Detector>(); - static DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); - - public void detectorChanged(Detector detector) { - //System.out.println("detectorChanged - detector " + detector.getDetectorName() + " and run #" + conditionsManager.getRun()); - int run = conditionsManager.getRun(); + /** + * Number of runs processed. + */ + private int nRuns = 0; + + /** + * Number of times {@link #detectorChanged(Detector)} was called. + */ + private int nDetectorChanged = 0; + + /** + * List of run numbers processed. + */ + private List<Integer> runsProcessed = new ArrayList<Integer>(); + + /** + * Set of unique run numbers processed. + */ + private Set<Integer> uniqueRuns = new LinkedHashSet<Integer>(); + + /** + * Set of unique detector objects. + */ + private Set<Detector> uniqueDetectorObjects = new HashSet<Detector>(); + + /** + * Reference to conditions manager. + */ + private static DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); + + /** + * Hook for conditions changed used to test multiple run processing. + */ + public void detectorChanged(final Detector detector) { + final int run = conditionsManager.getRun(); uniqueRuns.add(run); runsProcessed.add(run); ++nRuns; Modified: java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamConditionsTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamConditionsTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamConditionsTest.java Mon Apr 6 18:17:40 2015 @@ -20,32 +20,37 @@ /** * Load beam conditions for every run from the ECAL commissioning. - * - * @author Jeremy McCormick <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class BeamConditionsTest extends TestCase { +public final class BeamConditionsTest extends TestCase { - // This is every run from the ECAL commissioning! - static int runs[] = new int[] { - 2713, 2723, 2726, 2728, 2730, 2741, 2750, 2753, 2790, 2795, 2811, - 2823, 2825, 2826, 2837, 2847, 2888, 2889, 2891, 2915, 2916, 3128, - 3129, 3151, 3374, 3464, 2814, 2815, 3183, 3206, 3207, 3215, 3219, - 3220, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, - 3231, 3232, 3234, 3235, 3236, 3237, 3238, 3240, 3241, 3242, 3244, - 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3254, 3255, 3256, 3257, - 3258, 3259, 3260, 3261, 3263, 3264, 3265, 3266, 3267, 3268, 3269, - 3274, 3275, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3293, 3294, - 3295, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319, 3320, 3321, - 3322, 3323, 3324, 3325, 3326, 3327, 3330, 3335, 3336, 3337, 3338, - 3339, 3340, 3341, 3343, 3344, 3345, 3346, 3347, 3348, 3393, 3394, - 3395, 3396, 3398, 3399, 3401, 3402, 3417, 3418, 3419, 3420, 3421, - 3422, 3423, 3424, 3426, 3427, 3428, 3429, 3430, 3431, 3434, 3435, - 3436, 3437, 3438, 3441, 3444, 3445, 3446, 3447, 3448, 3449, 3450, - 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3461, 3462, + /** + * List of runs from the ECAL Eng Run. + */ + static int runs[] = new int[] { + 2713, 2723, 2726, 2728, 2730, 2741, 2750, 2753, 2790, 2795, 2811, + 2823, 2825, 2826, 2837, 2847, 2888, 2889, 2891, 2915, 2916, 3128, + 3129, 3151, 3374, 3464, 2814, 2815, 3183, 3206, 3207, 3215, 3219, + 3220, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, + 3231, 3232, 3234, 3235, 3236, 3237, 3238, 3240, 3241, 3242, 3244, + 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3254, 3255, 3256, 3257, + 3258, 3259, 3260, 3261, 3263, 3264, 3265, 3266, 3267, 3268, 3269, + 3274, 3275, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3293, 3294, + 3295, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319, 3320, 3321, + 3322, 3323, 3324, 3325, 3326, 3327, 3330, 3335, 3336, 3337, 3338, + 3339, 3340, 3341, 3343, 3344, 3345, 3346, 3347, 3348, 3393, 3394, + 3395, 3396, 3398, 3399, 3401, 3402, 3417, 3418, 3419, 3420, 3421, + 3422, 3423, 3424, 3426, 3427, 3428, 3429, 3430, 3431, 3434, 3435, + 3436, 3437, 3438, 3441, 3444, 3445, 3446, 3447, 3448, 3449, 3450, + 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3461, 3462, 3463, 3216, 2926, 2935, 2934, 2937 }; + /** + * Test the beam conditions. + */ public void testBeamConditions() { - DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); + final DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); manager.setLogLevel(Level.SEVERE); System.out.println("run id current position_x position_y energy"); Map<Integer, BeamConditions> beamConditions = new LinkedHashMap<Integer, BeamConditions>(); @@ -55,9 +60,9 @@ } catch (ConditionsNotFoundException e) { throw new RuntimeException(e); } - BeamConditionsCollection beamCollection = + final BeamConditionsCollection beamCollection = manager.getCachedConditions(BeamConditionsCollection.class, "beam").getCachedData(); - BeamConditions beam = beamCollection.get(0); + final BeamConditions beam = beamCollection.get(0); System.out.print(run + " "); System.out.print(beam.getRowId() + " "); System.out.print(beam.getCurrent() + " "); @@ -69,49 +74,54 @@ } writeBeamTuple(beamConditions); } - - static private void writeBeamTuple(Map<Integer, BeamConditions> beamConditions) { - - File dir = new TestOutputFile(BeamConditionsTest.class.getSimpleName()); + + /** + * Write out an AIDA tuple with the beam conditions. + * @param beamConditions the beam conditions + */ + private static void writeBeamTuple(final Map<Integer, BeamConditions> beamConditions) { + final File dir = new TestOutputFile(BeamConditionsTest.class.getSimpleName()); dir.mkdir(); - - IAnalysisFactory analysisFactory = IAnalysisFactory.create(); - ITree tree = null; + final IAnalysisFactory analysisFactory = IAnalysisFactory.create(); + final ITree tree; try { - tree = analysisFactory.createTreeFactory().create(dir.getPath() + File.separator + "BeamTuple.aida", "xml", false, true); + tree = analysisFactory.createTreeFactory().create(dir.getPath() + + File.separator + "BeamTuple.aida", "xml", false, true); } catch (IllegalArgumentException | IOException e) { throw new RuntimeException(e); } - ITuple tuple = analysisFactory.createTupleFactory(tree).create("/Beam Tuple", "Beam Tuple", "int run, double current, position_x, position_y, energy"); + final ITuple tuple = analysisFactory.createTupleFactory(tree).create("/Beam Tuple", + "Beam Tuple", "int run, double current, position_x, position_y, energy"); tuple.start(); for (Entry<Integer, BeamConditions> entry : beamConditions.entrySet()) { tuple.addRow(); - Double current = entry.getValue().getCurrent(); - if (current == null) + if (current == null) { current = 0.; + } Double positionX = entry.getValue().getPositionX(); - if (positionX == null) + if (positionX == null) { positionX = 0.; + } Double positionY = entry.getValue().getPositionY(); - if (positionY == null) + if (positionY == null) { positionY = 0.; + } Double energy = entry.getValue().getEnergy(); - if (energy == null) + if (energy == null) { energy = 0.; - - tuple.fill(0, (int)entry.getKey()); - tuple.fill(1, (double)current); - tuple.fill(2, (double)positionX); - tuple.fill(3, (double)positionY); - tuple.fill(4, (double)energy); + } + tuple.fill(0, (int) entry.getKey()); + tuple.fill(1, (double) current); + tuple.fill(2, (double) positionX); + tuple.fill(3, (double) positionY); + tuple.fill(4, (double) energy); tuple.next(); } - try { tree.commit(); } catch (IOException e) { throw new RuntimeException(e); } - } + } } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamCurrentTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamCurrentTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/beam/BeamCurrentTest.java Mon Apr 6 18:17:40 2015 @@ -16,43 +16,47 @@ /** * This test checks the Test Run beam current values by run. - * @author Jeremy McCormick <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class BeamCurrentTest extends TestCase { +public final class BeamCurrentTest extends TestCase { - /** This test file has a few events from the "good runs" of the Test Run. */ - private static final String fileLocation = "http://www.lcsim.org/test/hps-java/ConditionsTest.slcio"; + /** + * This test file has a few events from the "good runs" of the Test Run. + */ + private static final String URL = "http://www.lcsim.org/test/hps-java/ConditionsTest.slcio"; /** Answer key for beam current by run. */ - static Map<Integer, Double> beamCurrentAnswerKey = new HashMap<Integer, Double>(); + private static final Map<Integer, Double> ANSWER_KEY = new HashMap<Integer, Double>(); /** Setup the beam current answer key by run. */ static { - beamCurrentAnswerKey.put(1349, 54879.7343788147); - beamCurrentAnswerKey.put(1351, 26928.0426635742); - beamCurrentAnswerKey.put(1353, 204325.132622242); - beamCurrentAnswerKey.put(1354, 148839.141475141); - beamCurrentAnswerKey.put(1358, 92523.9428218845); - beamCurrentAnswerKey.put(1359, 91761.4541434497); - beamCurrentAnswerKey.put(1360, 209883.979889035); - beamCurrentAnswerKey.put(1362, 110298.553449392); - beamCurrentAnswerKey.put(1363, 8556.8459701538); + ANSWER_KEY.put(1349, 54879.7343788147); + ANSWER_KEY.put(1351, 26928.0426635742); + ANSWER_KEY.put(1353, 204325.132622242); + ANSWER_KEY.put(1354, 148839.141475141); + ANSWER_KEY.put(1358, 92523.9428218845); + ANSWER_KEY.put(1359, 91761.4541434497); + ANSWER_KEY.put(1360, 209883.979889035); + ANSWER_KEY.put(1362, 110298.553449392); + ANSWER_KEY.put(1363, 8556.8459701538); } /** * Run the test. - * @throws Exception + * + * @throws Exception if there is an event processing error */ public void test() throws Exception { DatabaseConditionsManager.getInstance(); - + // Cache file locally from URL. - FileCache cache = new FileCache(); - File testFile = cache.getCachedFile(new URL(fileLocation)); + final FileCache cache = new FileCache(); + final File testFile = cache.getCachedFile(new URL(URL)); // Create the LCSimLoop. - LCSimLoop loop = new LCSimLoop(); + final LCSimLoop loop = new LCSimLoop(); // Configure and run the loop. loop.setLCIORecordSource(testFile); @@ -62,24 +66,29 @@ /** * This Driver will check the beam current for a run against the answer key. - * @author Jeremy McCormick <[log in to unmask]> */ - class BeamCurrentChecker extends Driver { + static class BeamCurrentChecker extends Driver { - int currentRun = Integer.MIN_VALUE; + /** + * The current run number. + */ + private int currentRun = Integer.MIN_VALUE; /** * This method will check the beam current against the answer key for * the first event of a new run. + * @param the LCSim event */ - public void process(EventHeader event) { + protected void process(final EventHeader event) { if (currentRun != event.getRunNumber()) { currentRun = event.getRunNumber(); - BeamCurrentCollection collection = - DatabaseConditionsManager.getInstance().getCachedConditions(BeamCurrentCollection.class, "beam_current").getCachedData(); - BeamCurrent beamCurrent = collection.iterator().next(); - System.out.println("Run " + event.getRunNumber() + " has integrated beam current " + beamCurrent.getIntegratedBeamCurrent() + " nC."); - assertEquals("Wrong beam current for run.", beamCurrentAnswerKey.get(currentRun), beamCurrent.getIntegratedBeamCurrent()); + final BeamCurrentCollection collection = DatabaseConditionsManager.getInstance().getCachedConditions( + BeamCurrentCollection.class, "beam_current").getCachedData(); + final BeamCurrent beamCurrent = collection.iterator().next(); + System.out.println("Run " + event.getRunNumber() + " has integrated beam current " + + beamCurrent.getIntegratedBeamCurrent() + " nC."); + assertEquals("Wrong beam current for run.", ANSWER_KEY.get(currentRun), + beamCurrent.getIntegratedBeamCurrent()); } } } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/database/ConverterRegistryTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/database/ConverterRegistryTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/database/ConverterRegistryTest.java Mon Apr 6 18:17:40 2015 @@ -2,10 +2,19 @@ import junit.framework.TestCase; -public class ConverterRegistryTest extends TestCase { - - public void testConverterRegistry() { - ConverterRegistry converterRegistry = ConverterRegistry.create(); +/** + * This test loads the {@link ConverterRegistry}. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + */ +// FIXME: Doesn't test anything. +public final class ConverterRegistryTest extends TestCase { + + /** + * Load the global converter registry. + */ + public final void testConverterRegistry() { + final ConverterRegistry converterRegistry = ConverterRegistry.create(); System.out.println(converterRegistry.toString()); } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/database/TableRegistryTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/database/TableRegistryTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/database/TableRegistryTest.java Mon Apr 6 18:17:40 2015 @@ -2,10 +2,19 @@ import junit.framework.TestCase; -public class TableRegistryTest extends TestCase { +/** + * This test loads the {@link TableRegistry}. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + */ +// FIXME: Doesn't test anything. +public final class TableRegistryTest extends TestCase { + /** + * Load the global table registry. + */ public void testTableRegistry() { - TableRegistry registry = TableRegistry.create(); + final TableRegistry registry = TableRegistry.create(); System.out.println(registry.toString()); } } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalHardwareConditionsTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalHardwareConditionsTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalHardwareConditionsTest.java Mon Apr 6 18:17:40 2015 @@ -12,37 +12,55 @@ /** * This is a simple test that reads ECAL hardware calibrations and gains * from the conditions database. - * - * @author Jeremy McCormick <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class EcalHardwareConditionsTest extends TestCase { +public final class EcalHardwareConditionsTest extends TestCase { - static String CALIBRATIONS_TABLE = "ecal_hardware_calibrations"; - static String GAINS_TABLE = "ecal_hardware_gains"; - static int RECORD_COUNT = 442; - + /** + * Name of hardware calibrations table. + */ + private static final String CALIBRATIONS_TABLE = "ecal_hardware_calibrations"; + + /** + * Name of hardware gains table. + */ + private static final String GAINS_TABLE = "ecal_hardware_gains"; + + /** + * Number of conditions records (matches number of channels). + */ + private static final int RECORD_COUNT = 442; + + /** + * Load the ECAL hardware conditions. + * @throws Exception if there is a conditions error + */ public void testEcalHardwareConditions() throws Exception { - DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); + final DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); try { manager.setDetector("HPS-ECalCommissioning-v2", 0); } catch (ConditionsNotFoundException e) { throw new RuntimeException(e); } manager.setLogLevel(Level.ALL); - + // Read hardware calibrations. - EcalCalibrationCollection calibrations = manager.getCachedConditions(EcalCalibrationCollection.class, CALIBRATIONS_TABLE).getCachedData(); - assertEquals("Wrong name in conditions record.", CALIBRATIONS_TABLE, calibrations.getConditionsRecord().getTableName()); - assertEquals("Wrong table name in conditions record.", CALIBRATIONS_TABLE, calibrations.getConditionsRecord().getTableName()); + final EcalCalibrationCollection calibrations = manager.getCachedConditions(EcalCalibrationCollection.class, + CALIBRATIONS_TABLE).getCachedData(); + assertEquals("Wrong name in conditions record.", CALIBRATIONS_TABLE, + calibrations.getConditionsRecord().getTableName()); + assertEquals("Wrong table name in conditions record.", CALIBRATIONS_TABLE, + calibrations.getConditionsRecord().getTableName()); assertEquals("Wrong number of records.", RECORD_COUNT, calibrations.size()); System.out.println("successfully read " + calibrations.size() + " gain records from " + CALIBRATIONS_TABLE); - + // Read hardware gains. - EcalGainCollection gains = manager.getCachedConditions(EcalGainCollection.class, GAINS_TABLE).getCachedData(); + final EcalGainCollection gains = manager.getCachedConditions( + EcalGainCollection.class, GAINS_TABLE).getCachedData(); assertEquals("Wrong name in conditions record.", GAINS_TABLE, gains.getConditionsRecord().getTableName()); assertEquals("Wrong table name in conditions record.", GAINS_TABLE, gains.getConditionsRecord().getTableName()); assertEquals("Wrong number of records.", RECORD_COUNT, gains.size()); System.out.println("successfully read " + gains.size() + " gain records from " + GAINS_TABLE); } - } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalLedTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalLedTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/ecal/EcalLedTest.java Mon Apr 6 18:17:40 2015 @@ -9,34 +9,51 @@ import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException; /** - * A very basic test to make sure ECAL LED information is - * readable from the conditions dev database. - * @author Jeremy McCormick <[log in to unmask]> + * A test to make sure ECAL LED information is readable from the conditions dev database. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class EcalLedTest extends TestCase { - - DatabaseConditionsManager conditionsManager; +public final class EcalLedTest extends TestCase { + + /** + * Run number to use for test. + */ + private static final int RUN_NUMBER = 2000; + + /** + * The conditions manager. + */ + private static DatabaseConditionsManager conditionsManager; + + /** + * Setup the conditions manager. + */ + @Override public void setUp() { conditionsManager = DatabaseConditionsManager.getInstance(); try { - conditionsManager.setDetector("HPS-ECalCommissioning-v2", 2000); + conditionsManager.setDetector("HPS-ECalCommissioning-v2", RUN_NUMBER); } catch (ConditionsNotFoundException e) { throw new RuntimeException(e); } } - + + /** + * Load ECAL LED conditions. + */ public void testEcalLed() { - DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); - + // LED channel information. - EcalLedCollection leds = manager.getCachedConditions(EcalLedCollection.class, "ecal_leds").getCachedData(); - for (EcalLed led : leds) { - System.out.println(led); + final EcalLedCollection leds = conditionsManager.getCachedConditions( + EcalLedCollection.class, "ecal_leds").getCachedData(); + for (EcalLed led : leds) { + System.out.println(led); } - + // LED calibration data. - EcalLedCalibrationCollection calibrations = manager.getCachedConditions(EcalLedCalibrationCollection.class, "ecal_led_calibrations").getCachedData(); - for (EcalLedCalibration calibration : calibrations) { + final EcalLedCalibrationCollection calibrations = conditionsManager.getCachedConditions( + EcalLedCalibrationCollection.class, "ecal_led_calibrations").getCachedData(); + for (final EcalLedCalibration calibration : calibrations) { System.out.println(calibration); } } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtBadChannelTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtBadChannelTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtBadChannelTest.java Mon Apr 6 18:17:40 2015 @@ -18,45 +18,52 @@ import org.lcsim.util.loop.LCSimLoop; /** - * This class tests that the correct bad channel conditions are found for the - * test run. - * @author Jeremy McCormick <[log in to unmask]> + * This class tests that the correct bad channel conditions are found for the test run. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class SvtBadChannelTest extends TestCase { +public final class SvtBadChannelTest extends TestCase { - // This test file has a few events from each of the "good runs" of the 2012 - // Test Run. + /** + * This test file has a few events from each of the "good runs" of the 2012 Test Run. + */ private static final String TEST_FILE_URL = "http://www.lcsim.org/test/hps/conditions_test.slcio"; - // This is the number of bad channels in the QA set across all runs. - static int BAD_CHANNELS_QA_ANSWER = 50; + /** + * This is the number of bad channels in the conditions set that covers all run numbers. + */ + private static final int BAD_CHANNELS_QA_ANSWER = 50; - // Answer key for number of bad channels by run. - static Map<Integer, Integer> badChannelAnswerKey = new HashMap<Integer, Integer>(); + /** + * Answer key for number of bad channels per run. + */ + private static final Map<Integer, Integer> ANSWER_KEY = new HashMap<Integer, Integer>(); - // Setup the bad channel answer key by run. + /** + * Setup the answer key. + */ static { - badChannelAnswerKey.put(1351, 441); - badChannelAnswerKey.put(1353, 473); - badChannelAnswerKey.put(1354, 474); - badChannelAnswerKey.put(1358, 344); - badChannelAnswerKey.put(1359, 468); - badChannelAnswerKey.put(1360, 468); + ANSWER_KEY.put(1351, 441); + ANSWER_KEY.put(1353, 473); + ANSWER_KEY.put(1354, 474); + ANSWER_KEY.put(1358, 344); + ANSWER_KEY.put(1359, 468); + ANSWER_KEY.put(1360, 468); } /** * Run the test. - * @throws Exception + * @throws Exception if there is an event processing error */ public void test() throws Exception { // Cache a data file from the www. - FileCache cache = new FileCache(); - File testFile = cache.getCachedFile(new URL(TEST_FILE_URL)); + final FileCache cache = new FileCache(); + final File testFile = cache.getCachedFile(new URL(TEST_FILE_URL)); // Create the record loop. DatabaseConditionsManager.getInstance(); - LCSimLoop loop = new LCSimLoop(); + final LCSimLoop loop = new LCSimLoop(); // Configure the loop. loop.setLCIORecordSource(testFile); @@ -69,38 +76,44 @@ } /** - * This Driver will check the number of bad channels for a run against the - * answer key. - * @author Jeremy McCormick <[log in to unmask]> + * This Driver will check the number of bad channels for a run against the answer key. */ - class SvtBadChannelChecker extends Driver { + static class SvtBadChannelChecker extends Driver { - int _currentRun = -1; + /** + * The current run number. + */ + private int currentRun = -1; /** * This method will check the number of bad channels against the answer * key for the first event of a new run. + * @param the LCSim event */ - public void process(EventHeader event) { - int run = event.getRunNumber(); - if (run != _currentRun) { - _currentRun = run; - Detector detector = event.getDetector(); + public void process(final EventHeader event) { + final int run = event.getRunNumber(); + if (run != currentRun) { + currentRun = run; + final Detector detector = event.getDetector(); int badChannels = 0; - List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class); - for (HpsSiSensor sensor : sensors) { - int nchannels = sensor.getNumberOfChannels(); + final List<HpsSiSensor> sensors = detector.getDetectorElement() + .findDescendants(HpsSiSensor.class); + for (final HpsSiSensor sensor : sensors) { + final int nchannels = sensor.getNumberOfChannels(); for (int i = 0; i < nchannels; i++) { - if (sensor.isBadChannel(i)) + if (sensor.isBadChannel(i)) { ++badChannels; + } } } - System.out.println("Run " + _currentRun + " has " + badChannels + " SVT bad channels."); - if (badChannelAnswerKey.containsKey(_currentRun)) { - Integer badChannelsExpected = badChannelAnswerKey.get(run); - TestCase.assertEquals("Wrong number of bad channels found.", (int) badChannelsExpected, (int) badChannels); + System.out.println("Run " + currentRun + " has " + badChannels + " SVT bad channels."); + if (ANSWER_KEY.containsKey(currentRun)) { + final Integer badChannelsExpected = ANSWER_KEY.get(run); + TestCase.assertEquals("Wrong number of bad channels found.", + (int) badChannelsExpected, (int) badChannels); } else { - TestCase.assertEquals("Wrong number of bad channels found.", (int) BAD_CHANNELS_QA_ANSWER, (int) badChannels); + TestCase.assertEquals("Wrong number of bad channels found.", + (int) BAD_CHANNELS_QA_ANSWER, (int) badChannels); } } } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConfigurationTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConfigurationTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtConfigurationTest.java Mon Apr 6 18:17:40 2015 @@ -9,15 +9,21 @@ import org.jdom.Document; import org.jdom.JDOMException; -public class SvtConfigurationTest extends TestCase { +/** + * Load an SVT XML configuration from the database. + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + */ +public final class SvtConfigurationTest extends TestCase { - DatabaseConditionsManager manager; - + /** + * Load an SVT XML configuration from the database. + */ public void testSvtConfiguration() { - DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); - SvtConfigurationCollection collection = manager.getCachedConditions(SvtConfigurationCollection.class, "svt_configurations").getCachedData(); - - for (SvtConfiguration config : collection) { + final DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); + final SvtConfigurationCollection collection = manager.getCachedConditions(SvtConfigurationCollection.class, + "svt_configurations").getCachedData(); + for (final SvtConfiguration config : collection) { Document doc = null; try { doc = config.createDocument(); Modified: java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtDaqMappingTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtDaqMappingTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtDaqMappingTest.java Mon Apr 6 18:17:40 2015 @@ -3,55 +3,62 @@ import junit.framework.TestCase; import org.hps.conditions.database.DatabaseConditionsManager; -import org.hps.conditions.database.TableMetaData; import org.hps.conditions.svt.SvtDaqMapping.SvtDaqMappingCollection; /** * This test checks if the SVT DAQ map was loaded with reasonable values and is * being read correctly from the conditions database. - * - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -public class SvtDaqMappingTest extends TestCase { +public final class SvtDaqMappingTest extends TestCase { - // --- Constants ---// - // -----------------// + /** + * Total number of SVT sensors. + */ + public static final int TOTAL_NUMBER_OF_SENSORS = 36; - // Total number of SVT sensors - public static final int TOTAL_NUMBER_OF_SENSORS = 36; - // Min and max values of front end boad (FEB) hybrid ID's + /** + * Minimum FEB Hybrid ID. + */ public static final int MIN_FEB_HYBRID_ID = 0; + + /** + * Maximum FEB Hybrid ID. + */ public static final int MAX_FEB_HYBRID_ID = 3; - // -----------------// + /** + * Load the DAQ map from the database. + * @throws Exception if there is a test error + */ public void test() throws Exception { - - DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); + final DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); conditionsManager.setDetector("HPS-Proposal2014-v7-2pt2", 0); - - SvtDaqMappingCollection daqMappingCollection = conditionsManager.getCachedConditions(SvtDaqMappingCollection.class, "svt_daq_map").getCachedData(); - + final SvtDaqMappingCollection daqMappingCollection = conditionsManager.getCachedConditions( + SvtDaqMappingCollection.class, "svt_daq_map").getCachedData(); int totalSensors = 0; int febHybridID; //this.printDebug(""); for (SvtDaqMapping daqMapping : daqMappingCollection) { - //this.printDebug("Sensor: \n" + daqMapping.toString()); - // Check that the FEB Hybrid ID is within the allowable limits febHybridID = daqMapping.getFebHybridID(); - assertTrue("FEB Hybrid ID is out of range!.", febHybridID >= MIN_FEB_HYBRID_ID && febHybridID <= MAX_FEB_HYBRID_ID); - + assertTrue("FEB Hybrid ID is out of range!.", + febHybridID >= MIN_FEB_HYBRID_ID && febHybridID <= MAX_FEB_HYBRID_ID); totalSensors++; } - //this.printDebug("Total number of sensors found: " + totalSensors); assertTrue(totalSensors == TOTAL_NUMBER_OF_SENSORS); } - private void printDebug(String debugMessage) { + /** + * Print debug message. + * @param debugMessage the message + */ + private void printDebug(final String debugMessage) { System.out.println(this.getClass().getSimpleName() + ":: " + debugMessage); } } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtDetectorSetupTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtDetectorSetupTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtDetectorSetupTest.java Mon Apr 6 18:17:40 2015 @@ -5,8 +5,6 @@ import junit.framework.TestCase; import org.hps.conditions.database.DatabaseConditionsManager; -import org.hps.conditions.svt.SvtConditions; -import org.hps.conditions.svt.SvtDetectorSetup; import org.lcsim.detector.tracker.silicon.HpsSiSensor; import org.lcsim.geometry.Detector; @@ -14,49 +12,61 @@ * This test loads {@link SvtConditions} data onto the detector and then checks * that all channels of each sensor have non-zero data values for applicable * parameters. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -// TODO: Update this test with more meaningful test. -public class SvtDetectorSetupTest extends TestCase { +// TODO: Update this test with more meaningful assertions. +public final class SvtDetectorSetupTest extends TestCase { - // --- Constants ---// - // -----------------// - // TODO: Move all of these constants to their own class + /** + * Total number of SVT sensors. + */ + public static final int TOTAL_NUMBER_OF_SENSORS = 36; - // Total number of SVT sensors - public static final int TOTAL_NUMBER_OF_SENSORS = 36; - // Max FEB ID + /** + * Maximum FEB ID. + */ public static final int MAX_FEB_ID = 9; - // Max FEB Hybrid ID + + /** + * Maximum FEB Hybrid ID. + */ public static final int MAX_FEB_HYBRID_ID = 3; - // Max channel number + + /** + * Maximum channel number. + */ public static final int MAX_CHANNEL_NUMBER = 639; - // SVT Subdetector name + + /** + * Name of SVT subdetector. + */ public static final String SVT_SUBDETECTOR_NAME = "Tracker"; /** - * Load SVT conditions data onto the detector and perform basic checks - * afterwards. + * Load SVT conditions data onto the detector and then perform basic checks. + * @throws Exception if there is a test error */ public void test() throws Exception { - DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); + final DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); conditionsManager.setDetector("HPS-Proposal2014-v7-2pt2", 0); // Get the detector. - Detector detector = conditionsManager.getCachedConditions(Detector.class, "compact.xml").getCachedData(); + final Detector detector = conditionsManager.getCachedConditions(Detector.class, "compact.xml").getCachedData(); // Get all SVT conditions. - SvtConditions conditions = conditionsManager.getCachedConditions(SvtConditions.class, "svt_conditions").getCachedData(); + final SvtConditions conditions = conditionsManager.getCachedConditions( + SvtConditions.class, "svt_conditions").getCachedData(); // Load the SVT conditions onto detector. - SvtDetectorSetup loader = new SvtDetectorSetup("Tracker"); + final SvtDetectorSetup loader = new SvtDetectorSetup("Tracker"); loader.loadDefault(detector.getSubdetector(SVT_SUBDETECTOR_NAME), conditions); // Check sensor data. - List<HpsSiSensor> sensors = detector.getSubdetector(SVT_SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsSiSensor.class); + final List<HpsSiSensor> sensors = detector.getSubdetector(SVT_SUBDETECTOR_NAME).getDetectorElement() + .findDescendants(HpsSiSensor.class); // Check for correct number of sensors processed. this.printDebug("Total number of sensors found: " + sensors.size()); @@ -66,17 +76,18 @@ int totalSensors = 0; for (HpsSiSensor sensor : sensors) { - int nChannels = sensor.getNumberOfChannels(); + final int nChannels = sensor.getNumberOfChannels(); assertTrue("The number of channels this sensor has is invalid", nChannels <= MAX_CHANNEL_NUMBER); this.printDebug(sensor.toString()); // Check that the FEB ID as within the appropriate range - int febID = sensor.getFebID(); + final int febID = sensor.getFebID(); assertTrue("FEB ID is invalid. The FEB ID should be less than " + MAX_FEB_ID, febID <= MAX_FEB_ID); - int febHybridID = sensor.getFebHybridID(); - assertTrue("FEB Hybrid ID is invalid. The FEB Hybrid ID should be less than " + MAX_FEB_HYBRID_ID, febHybridID <= MAX_FEB_HYBRID_ID); + final int febHybridID = sensor.getFebHybridID(); + assertTrue("FEB Hybrid ID is invalid. The FEB Hybrid ID should be less than " + + MAX_FEB_HYBRID_ID, febHybridID <= MAX_FEB_HYBRID_ID); for (int channel = 0; channel < nChannels; channel++) { @@ -89,13 +100,17 @@ } assertTrue("Gain is zero.", sensor.getGain(channel) != 0); assertTrue("Shape fit parameters points to null.", sensor.getShapeFitParameters(channel) != null); - } + ++totalSensors; } System.out.println("Successfully loaded conditions data onto " + totalSensors + " SVT sensors!"); } + /** + * Print debug message. + * @param debugMessage the message + */ private void printDebug(String debugMessage) { System.out.println(this.getClass().getSimpleName() + ":: " + debugMessage); } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtBadChannelsTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtBadChannelsTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtBadChannelsTest.java Mon Apr 6 18:17:40 2015 @@ -14,13 +14,11 @@ * This test reads Test Run bad channel collections from the database * using a conditions series and checks that the correct number * of channels are flagged using several different runs. - * - * @author Jeremy McCormick <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -public class TestRunSvtBadChannelsTest extends TestCase { - - static String detectorName = "HPS-TestRun-v5"; - +public final class TestRunSvtBadChannelsTest extends TestCase { + /* mysql> select run_start, run_end, name from conditions where table_name like 'test_run_svt_bad_channels'; +-----------+---------+---------------------------+ @@ -34,8 +32,11 @@ | 1359 | 1359 | test_run_svt_bad_channels | | 1360 | 1360 | test_run_svt_bad_channels | +-----------+---------+---------------------------+ - */ - static int[] runNumbers = new int[] {0, 1351, 1353, 1354, 1358, 1359, 1360}; + */ + /** + * The run numbers to check. + */ + private static final int[] RUN_NUMBERS = new int[] {0, 1351, 1353, 1354, 1358, 1359, 1360}; /* mysql> select collection_id, count(*) from test_run_svt_bad_channels group by collection_id; @@ -50,47 +51,54 @@ | 6 | 424 | | 7 | 424 | +---------------+----------+ - */ - static int[] badChannelCount = {50, 392, 427, 457, 298, 424, 424}; - + */ + /** + * The bad channel count for each run. + */ + private static int[] BAD_CHANNEL_COUNTS = {50, 392, 427, 457, 298, 424, 424}; + + /** + * Test the bad channel numbers for various runs of the Test Run. + * @throws ConditionsNotFoundException if there is a conditions error + */ public void testSvtBadChannels() throws ConditionsNotFoundException { - - DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); + + final DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); conditionsManager.setXmlConfig("/org/hps/conditions/config/conditions_database_testrun_2012.xml"); conditionsManager.setLogLevel(Level.WARNING); - - for (int i = 0; i < runNumbers.length; i++) { - - int runNumber = runNumbers[i]; - + + for (int i = 0; i < RUN_NUMBERS.length; i++) { + + int runNumber = RUN_NUMBERS[i]; + System.out.println("-------------"); System.out.println("Run #" + runNumber); System.out.println("-------------"); System.out.println(); - - conditionsManager.setDetector(detectorName, runNumber); - - ConditionsSeries<SvtBadChannel, SvtBadChannelCollection> series = + + conditionsManager.setDetector("HPS-TestRun-v5", runNumber); + + final ConditionsSeries<SvtBadChannel, SvtBadChannelCollection> series = conditionsManager.getConditionsSeries(SvtBadChannelCollection.class, "test_run_svt_bad_channels"); - + int totalBadChannels = 0; for (ConditionsObjectCollection<SvtBadChannel> collection : series) { //System.out.println(collection.getConditionsRecord()); totalBadChannels += collection.size(); - } + } System.out.println("found " + totalBadChannels + " total bad chanenls"); - + // The run 0 channels are for all runs. - int expectedBadChannels = badChannelCount[0]; + int expectedBadChannels = BAD_CHANNEL_COUNTS[0]; if (runNumber != 0) { // Add bad channels from individual runs. - expectedBadChannels += badChannelCount[i]; + expectedBadChannels += BAD_CHANNEL_COUNTS[i]; } System.out.println("expected " + expectedBadChannels + " bad channels"); - + assertEquals("Wrong number of bad channels for run #" + runNumber, expectedBadChannels, totalBadChannels); - + System.out.println(); } } -} +} Modified: java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtConditionsConverterTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtConditionsConverterTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtConditionsConverterTest.java Mon Apr 6 18:17:40 2015 @@ -4,14 +4,29 @@ import org.hps.conditions.database.DatabaseConditionsManager; -public class TestRunSvtConditionsConverterTest extends TestCase { +/** + * Create combined SVT conditions for Test Run. + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> + */ +public final class TestRunSvtConditionsConverterTest extends TestCase { + /** + * The run number to use for the test. + */ + private static final int RUN_NUMBER = 1351; + + /** + * Create combined SVT Test Run conditions. + * @throws Exception if there is a conditions system error + */ public void test() throws Exception { - DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); + final DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); conditionsManager.setXmlConfig("/org/hps/conditions/config/conditions_database_testrun_2012.xml"); - conditionsManager.setDetector("HPS-TestRun-v5", 1351); + conditionsManager.setDetector("HPS-TestRun-v5", RUN_NUMBER); - TestRunSvtConditions svtConditions = conditionsManager.getCachedConditions(TestRunSvtConditions.class, "svt_conditions").getCachedData(); + final TestRunSvtConditions svtConditions = conditionsManager.getCachedConditions(TestRunSvtConditions.class, + "svt_conditions").getCachedData(); assertNotNull(svtConditions); System.out.println("[ " + this.getClass().getSimpleName() + "]: Printing test run SVT conditions."); System.out.println(svtConditions); Modified: java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDaqMappingTest.java Mon Apr 6 18:17:40 2015 @@ -3,41 +3,68 @@ import junit.framework.TestCase; import org.hps.conditions.database.DatabaseConditionsManager; -import org.hps.conditions.database.TableMetaData; import org.hps.conditions.svt.TestRunSvtDaqMapping.TestRunSvtDaqMappingCollection; /** * This test checks if the test run SVT DAQ map was loaded with reasonable * values and is being read correctly from the conditions database. - * - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -public class TestRunSvtDaqMappingTest extends TestCase { +public final class TestRunSvtDaqMappingTest extends TestCase { - TableMetaData metaData = null; + /** + * The run number to use for the test. + */ + private static final int RUN_NUMBER = 1351; - // --- Constants ---// - // -----------------// + /** + * Total number of SVT sensors. + */ + private static final int TOTAL_NUMBER_OF_SENSORS = 20; - // Total number of SVT sensors - public static final int TOTAL_NUMBER_OF_SENSORS = 20; - // Min and max values of the FPGA ID's - public static final int MIN_FPGA_ID = 0; - public static final int MAX_FPGA_ID = 6; - // Min and max values of Hybrid ID's - public static final int MIN_HYBRID_ID = 0; - public static final int MAX_HYBRID_ID = 2; - // Min and max layer number values - public static final int MIN_LAYER_NUMBER = 1; - public static final int MAX_LAYER_NUMBER = 10; + /** + * Minimum FPGA ID. + */ + private static final int MIN_FPGA_ID = 0; + /** + * Maximum FPGA ID. + */ + private static final int MAX_FPGA_ID = 6; + + /** + * Minimum Hybrid ID. + */ + private static final int MIN_HYBRID_ID = 0; + + /** + * Maximum Hybrid ID. + */ + private static final int MAX_HYBRID_ID = 2; + + /** + * Minimum layer number. + */ + private static final int MIN_LAYER_NUMBER = 1; + + /** + * Maximum layer number. + */ + private static final int MAX_LAYER_NUMBER = 10; + + /** + * Perform checks of SVT DAQ mapping for Test Run. + * @throws Exception if there is a test or conditions error + */ public void test() throws Exception { - DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); + final DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); conditionsManager.setXmlConfig("/org/hps/conditions/config/conditions_database_testrun_2012.xml"); - conditionsManager.setDetector("HPS-TestRun-v5", 1351); + conditionsManager.setDetector("HPS-TestRun-v5", RUN_NUMBER); - TestRunSvtDaqMappingCollection daqMappingCollection = conditionsManager.getCachedConditions(TestRunSvtDaqMappingCollection.class, "test_run_svt_daq_map").getCachedData(); + final TestRunSvtDaqMappingCollection daqMappingCollection = conditionsManager.getCachedConditions( + TestRunSvtDaqMappingCollection.class, "test_run_svt_daq_map").getCachedData(); int totalSensors = 0; this.printDebug(""); @@ -46,16 +73,18 @@ this.printDebug("Sensor: \n" + daqMapping.toString()); // Check that the FPGA ID is within the allowable limits - int fpgaID = daqMapping.getFpgaID(); + final int fpgaID = daqMapping.getFpgaID(); assertTrue("FPGA ID " + fpgaID + " is out of range!", fpgaID >= MIN_FPGA_ID && fpgaID <= MAX_FPGA_ID); // Check that the Hybrid ID is within the allowable limits - int hybridID = daqMapping.getHybridID(); - assertTrue("Hybrid ID " + hybridID + " is out of range!", hybridID >= MIN_HYBRID_ID && hybridID <= MAX_HYBRID_ID); + final int hybridID = daqMapping.getHybridID(); + assertTrue("Hybrid ID " + hybridID + " is out of range!", + hybridID >= MIN_HYBRID_ID && hybridID <= MAX_HYBRID_ID); // Check that the layer number is within the allowable limits - int layerNumber = daqMapping.getLayerNumber(); - assertTrue("The layer number " + layerNumber + " is out of range!", layerNumber >= MIN_LAYER_NUMBER && layerNumber <= MAX_LAYER_NUMBER); + final int layerNumber = daqMapping.getLayerNumber(); + assertTrue("The layer number " + layerNumber + " is out of range!", + layerNumber >= MIN_LAYER_NUMBER && layerNumber <= MAX_LAYER_NUMBER); totalSensors++; } @@ -64,7 +93,11 @@ assertTrue(totalSensors == TOTAL_NUMBER_OF_SENSORS); } - private void printDebug(String debugMessage) { + /** + * Print debug message. + * @param debugMessage the message + */ + private void printDebug(final String debugMessage) { System.out.println("[ " + this.getClass().getSimpleName() + " ]: " + debugMessage); } } Modified: java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDetectorSetupTest.java ============================================================================= --- java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDetectorSetupTest.java (original) +++ java/trunk/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtDetectorSetupTest.java Mon Apr 6 18:17:40 2015 @@ -12,41 +12,57 @@ * This test loads {@link TestRunSvtConditions} data onto the detector and then * checks that all channels of each sensor have non-zero data values for * applicable parameters. - * - * @author Omar Moreno <[log in to unmask]> + * + * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> */ -public class TestRunSvtDetectorSetupTest extends TestCase { - - // --- Constants ---// - // -----------------// - // TODO: Move all of these constants to their own class - - // Total number of SVT sensors - public static final int TOTAL_NUMBER_OF_SENSORS = 20; - // Max FEB ID - public static final int MAX_FPGA_ID = 6; - // Max FEB Hybrid ID - public static final int MAX_HYBRID_ID = 2; - // Max channel number - public static final int MAX_CHANNEL_NUMBER = 639; - // SVT Subdetector name - public static final String SVT_SUBDETECTOR_NAME = "Tracker"; +public final class TestRunSvtDetectorSetupTest extends TestCase { /** - * Load SVT conditions data onto the detector and perform basic checks - * afterwards. + * Run number to use for test. + */ + private static final int RUN_NUMBER = 1351; + + /** + * Total number of SVT sensors. + */ + private static final int TOTAL_NUMBER_OF_SENSORS = 20; + + /** + * Maximum FPGA ID. + */ + private static final int MAX_FPGA_ID = 6; + + /** + * Maximum Hybrid ID. + */ + private static final int MAX_HYBRID_ID = 2; + + /** + * Maximum channel number. + */ + private static final int MAX_CHANNEL_NUMBER = 639; + + /** + * Name of SVT subdetector. + */ + private static final String SVT_SUBDETECTOR_NAME = "Tracker"; + + /** + * Load SVT conditions data onto the detector and then perform basic checks of channel conditions data. + * @throws Exception if there is a test error */ public void test() throws Exception { - DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); + final DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance(); conditionsManager.setXmlConfig("/org/hps/conditions/config/conditions_database_testrun_2012.xml"); - conditionsManager.setDetector("HPS-TestRun-v5", 1351); + conditionsManager.setDetector("HPS-TestRun-v5", RUN_NUMBER); // Get the detector. - Detector detector = conditionsManager.getCachedConditions(Detector.class, "compact.xml").getCachedData(); + final Detector detector = conditionsManager.getCachedConditions(Detector.class, "compact.xml").getCachedData(); // Check sensor data. - List<HpsTestRunSiSensor> sensors = detector.getSubdetector(SVT_SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsTestRunSiSensor.class); + final List<HpsTestRunSiSensor> sensors = detector.getSubdetector(SVT_SUBDETECTOR_NAME).getDetectorElement() + .findDescendants(HpsTestRunSiSensor.class); // Check for correct number of sensors processed. this.printDebug("Total number of sensors found: " + sensors.size()); @@ -56,17 +72,18 @@ int totalSensors = 0; for (HpsTestRunSiSensor sensor : sensors) { - int nChannels = sensor.getNumberOfChannels(); + final int nChannels = sensor.getNumberOfChannels(); assertTrue("The number of channels this sensor has is invalid", nChannels <= MAX_CHANNEL_NUMBER); this.printDebug(sensor.toString()); // Check that the FEB ID as within the appropriate range - int fpgaID = sensor.getFpgaID(); + final int fpgaID = sensor.getFpgaID(); assertTrue("FPGA ID is invalid. The FPGA ID should be less than " + MAX_FPGA_ID, fpgaID <= MAX_FPGA_ID); - int hybridID = sensor.getHybridID(); - assertTrue("Hybrid ID is invalid. The Hybrid ID should be less than " + MAX_HYBRID_ID, hybridID <= MAX_HYBRID_ID); + final int hybridID = sensor.getHybridID(); + assertTrue("Hybrid ID is invalid. The Hybrid ID should be less than " + + MAX_HYBRID_ID, hybridID <= MAX_HYBRID_ID); for (int channel = 0; channel < nChannels; channel++) { @@ -81,10 +98,15 @@ assertTrue("Shape fit parameters points to null.", sensor.getShapeFitParameters(channel) != null); } + ++totalSensors; } System.out.println("Successfully loaded test run conditions data onto " + totalSensors + " SVT sensors!"); } + /** + * Print debug message. + * @param debugMessage the message + */ private void printDebug(String debugMessage) { System.out.println(this.getClass().getSimpleName() + ":: " + debugMessage); }