40 modified files
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/AbstractConditionsObject.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/AbstractConditionsObject.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -17,18 +17,18 @@
protected boolean isDirty = false;
protected boolean isReadOnly = false;
protected FieldValueMap fieldValues;
-
+
/**
* Constructor for sub-classing.
*/
- protected AbstractConditionsObject() {
+ protected AbstractConditionsObject() {
fieldValues = new FieldValueMap();
}
-
+
public TableMetaData getTableMetaData() {
return tableMetaData;
}
-
+
public int getRowId() {
return rowId;
}
@@ -36,7 +36,7 @@
public int getCollectionId() {
return collectionId;
}
-
+
public boolean isReadOnly() {
return isReadOnly;
}
@@ -48,7 +48,7 @@
public boolean isDirty() {
return isDirty;
}
-
+
public void delete() throws ConditionsObjectException {
if (isReadOnly()) {
throw new ConditionsObjectException("This object is set to read only.");
@@ -60,20 +60,17 @@
DatabaseConditionsManager.getInstance().updateQuery(query);
rowId = -1;
}
-
+
public void insert() throws ConditionsObjectException {
if (!isNew())
throw new ConditionsObjectException("Record already exists in database and cannot be inserted.");
if (isReadOnly())
throw new ConditionsObjectException("This object is set to read only mode.");
- if (fieldValues.size() == 0)
+ if (fieldValues.size() == 0)
throw new ConditionsObjectException("There are no field values to insert.");
if (!hasValidCollection())
throw new ConditionsObjectException("The object's collection ID is not valid.");
- String query = QueryBuilder.buildInsert(getTableMetaData().getTableName(),
- getCollectionId(),
- getTableMetaData().getFieldNames(),
- fieldValues.valuesToArray());
+ String query = QueryBuilder.buildInsert(getTableMetaData().getTableName(), getCollectionId(), getTableMetaData().getFieldNames(), fieldValues.valuesToArray());
List<Integer> keys = DatabaseConditionsManager.getInstance().updateQuery(query);
if (keys.size() == 0 || keys.size() > 1) {
throw new ConditionsObjectException("SQL insert returned wrong number of keys: " + keys.size());
@@ -84,26 +81,25 @@
public void select() throws ConditionsObjectException {
if (isNew()) {
throw new ConditionsObjectException("Record has not been inserted into the database yet.");
- }
- String query = QueryBuilder.buildSelect(
- getTableMetaData().getTableName(), collectionId, fieldValues.fieldsToArray(), "id ASC");
+ }
+ String query = QueryBuilder.buildSelect(getTableMetaData().getTableName(), collectionId, fieldValues.fieldsToArray(), "id ASC");
DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance();
- ResultSet resultSet = manager.selectQuery(query);
+ ResultSet resultSet = manager.selectQuery(query);
try {
ResultSetMetaData metadata = resultSet.getMetaData();
int ncolumns = metadata.getColumnCount();
- if (resultSet.next()) {
- for (int i=1; i<=ncolumns; i++) {
+ if (resultSet.next()) {
+ for (int i = 1; i <= ncolumns; i++) {
fieldValues.put(metadata.getColumnName(i), resultSet.getObject(i));
}
- }
+ }
} catch (SQLException e) {
throw new ConditionsObjectException(e.getMessage(), this);
}
DatabaseConditionsManager.close(resultSet);
resultSet = null;
}
-
+
public void update() throws ConditionsObjectException {
if (isReadOnly()) {
throw new ConditionsObjectException("This object is set to read only.", this);
@@ -114,38 +110,34 @@
if (fieldValues.size() == 0) {
throw new ConditionsObjectException("No field values to update.", this);
}
- String query = QueryBuilder.buildUpdate(
- tableMetaData.getTableName(),
- rowId,
- fieldValues.fieldsToArray(),
- fieldValues.valuesToArray());
+ String query = QueryBuilder.buildUpdate(tableMetaData.getTableName(), rowId, fieldValues.fieldsToArray(), fieldValues.valuesToArray());
DatabaseConditionsManager.getInstance().updateQuery(query);
setIsDirty(false);
}
-
+
public void setFieldValue(String key, Object value) {
fieldValues.put(key, value);
setIsDirty(true);
}
-
+
public void setFieldValues(FieldValueMap fieldValues) {
this.fieldValues = fieldValues;
if (!isNew()) {
setIsDirty(true);
- }
+ }
}
-
+
public <T> T getFieldValue(Class<T> klass, String field) {
- return klass.cast(fieldValues.get(field));
+ return klass.cast(fieldValues.get(field));
}
-
+
@SuppressWarnings("unchecked")
public <T> T getFieldValue(String field) {
- return (T)fieldValues.get(field);
+ return (T) fieldValues.get(field);
}
public void setTableMetaData(TableMetaData tableMetaData) throws ConditionsObjectException {
- if (this.tableMetaData != null)
+ if (this.tableMetaData != null)
throw new ConditionsObjectException("The table meta data cannot be reset on an object.", this);
this.tableMetaData = tableMetaData;
}
@@ -155,26 +147,26 @@
throw new ConditionsObjectException("The collection ID cannot be reassigned once set.", this);
this.collectionId = collectionId;
}
-
+
public void setIsDirty(boolean isDirty) {
this.isDirty = isDirty;
}
-
+
public void setIsReadOnly() {
isReadOnly = true;
}
-
+
public void setRowId(int rowId) throws ConditionsObjectException {
if (this.rowId != -1)
throw new ConditionsObjectException("The row ID cannot be reassigned on an existing object.");
this.rowId = rowId;
}
-
+
private boolean hasValidCollection() {
return collectionId != -1;
- }
-
- //protected void finalize() {
- // System.out.println("finalizing ConditionsObject " + System.identityHashCode(this));
- //}
+ }
+
+ // protected void finalize() {
+ // System.out.println("finalizing ConditionsObject " + System.identityHashCode(this));
+ // }
}
\ No newline at end of file
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/AbstractIdentifier.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/AbstractIdentifier.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -1,23 +1,23 @@
package org.hps.conditions;
/**
- * This class is a simplistic representation of a packaged identifier
- * for use in the conditions system.
+ * This class is a simplistic representation of a packaged identifier for use in the
+ * conditions system.
*
* @author Jeremy McCormick <[log in to unmask]>
- *
+ *
*/
public abstract class AbstractIdentifier {
-
- /**
- * Encode the ID into a long.
- * @return The ID encoded into a long.
- */
- public abstract long encode();
-
- /**
- * Check if the ID is valid.
- * @return True if valid.
- */
- public abstract boolean isValid();
+
+ /**
+ * Encode the ID into a long.
+ * @return The ID encoded into a long.
+ */
+ public abstract long encode();
+
+ /**
+ * Check if the ID is valid.
+ * @return True if valid.
+ */
+ public abstract boolean isValid();
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -18,24 +18,23 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class ConditionsDriver extends Driver {
-
+
// Static instance of the manager.
static DatabaseConditionsManager manager;
-
+
// Default conditions system XML config, which is for the Test Run 2012 database.
- String _defaultConfigResource =
- "/org/hps/conditions/config/conditions_database_testrun_2012.xml";
-
- // Default database connection parameters, which points to the SLAC development database.
- static String _defaultConnectionResource =
- "/org/hps/conditions/config/conditions_database_testrun_2012_connection.properties";
-
+ String _defaultConfigResource = "/org/hps/conditions/config/conditions_database_testrun_2012.xml";
+
+ // Default database connection parameters, which points to the SLAC development
+ // database.
+ static String _defaultConnectionResource = "/org/hps/conditions/config/conditions_database_testrun_2012_connection.properties";
+
String ecalSubdetectorName = "Ecal";
String svtSubdetectorName = "Tracker";
-
+
/**
- * Constructor which initializes the conditions manager with
- * default connection parameters and configuration.
+ * Constructor which initializes the conditions manager with default connection
+ * parameters and configuration.
*/
public ConditionsDriver() {
manager = new DatabaseConditionsManager();
@@ -43,7 +42,7 @@
manager.configure(_defaultConfigResource);
manager.register();
}
-
+
/**
* Set the configuration XML resource to be used by the manager.
* @param resource the configuration resource
@@ -51,7 +50,7 @@
public void setConfigResource(String resource) {
manager.configure(resource);
}
-
+
/**
* Set the connection properties file resource to be used by the manager.
* @param resource the connection resource
@@ -59,31 +58,31 @@
public void setConnectionResource(String resource) {
manager.setConnectionResource(resource);
}
-
+
/**
* Set the class of the conditions reader to use.
*/
- public void setConditionsReaderClass(String className) {
+ public void setConditionsReaderClass(String className) {
try {
Object object = Class.forName(className).newInstance();
- ConditionsReader reader = (ConditionsReader)object;
+ ConditionsReader reader = (ConditionsReader) object;
if (reader != null)
manager.setBaseConditionsReader(reader);
- else
+ else
throw new IllegalArgumentException("The class " + className + " is not a ConditionsReader.");
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
-
+
public void setEcalSubdetectorName(String ecalSubdetectorName) {
- this.ecalSubdetectorName = ecalSubdetectorName;
+ this.ecalSubdetectorName = ecalSubdetectorName;
}
-
+
public void setSvtSubdetectorName(String svtSubdetectorName) {
- this.svtSubdetectorName = svtSubdetectorName;
+ this.svtSubdetectorName = svtSubdetectorName;
}
-
+
/**
* This method updates a new detector with SVT and ECal conditions data.
*/
@@ -92,27 +91,27 @@
loadSvtConditions(detector);
loadEcalConditions(detector);
}
-
+
/**
* Load the SVT conditions onto the <code>Detector</code>.
* @param detector The detector to update.
*/
- private void loadSvtConditions(Detector detector) {
- SvtConditions conditions = manager.getCachedConditions(SvtConditions.class, SVT_CONDITIONS).getCachedData();
+ private void loadSvtConditions(Detector detector) {
+ SvtConditions conditions = manager.getCachedConditions(SvtConditions.class, SVT_CONDITIONS).getCachedData();
SvtConditionsLoader loader = new SvtConditionsLoader();
loader.load(detector, conditions);
- }
-
- /**
+ }
+
+ /**
* Load the ECal conditions onto the <code>Detector</code>.
* @param detector The detector to update.
- */
+ */
private void loadEcalConditions(Detector detector) {
EcalConditions conditions = manager.getCachedConditions(EcalConditions.class, ECAL_CONDITIONS).getCachedData();
EcalConditionsLoader loader = new EcalConditionsLoader();
loader.load(detector.getSubdetector(ecalSubdetectorName), conditions);
}
-
+
public void endOfData() {
manager.closeConnection();
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsObject.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsObject.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -3,137 +3,135 @@
import java.util.LinkedHashMap;
/**
- * This is an ORM interface for accessing conditions database information by row.
- * It can handle new or existing records. The ID values for new records are -1
- * which indicates they are not in the database yet.
+ * This is an ORM interface for accessing conditions database information by row. It can
+ * handle new or existing records. The ID values for new records are -1 which indicates
+ * they are not in the database yet.
* @author Jeremy McCormick <[log in to unmask]>
*/
public interface ConditionsObject {
-
+
/**
* Get the database table meta data associated to this object.
* @return The database table meta data associated to this object.
*/
TableMetaData getTableMetaData();
-
+
/**
* Get the row ID of this object.
* @return The database row ID.
*/
int getRowId();
-
+
/**
- * Get the collection ID of this object identifying its unique collection.
+ * Get the collection ID of this object identifying its unique collection.
* @return The collection ID.
*/
int getCollectionId();
-
+
/**
- * Update this row in the database using a SQL UPDATE statement.
+ * Update this row in the database using a SQL UPDATE statement.
*/
void update() throws ConditionsObjectException;
-
+
/**
* Delete this object's row in the database using a SQL DELETE statement.
*/
void delete() throws ConditionsObjectException;
-
+
/**
- * Insert this object into the database using a SQL INSERT statement.
+ * Insert this object into the database using a SQL INSERT statement.
*/
void insert() throws ConditionsObjectException;
-
+
/**
- * Select data into this object from the database using a SQL SELECT statement.
+ * Select data into this object from the database using a SQL SELECT statement.
*/
void select() throws ConditionsObjectException;
-
+
/**
* Return true if this object is read-only.
* @return True if object is read-only.
*/
boolean isReadOnly();
-
+
/**
* Return true if this object is new and hasn't been inserted into the database yet.
* @return True if object is new.
*/
boolean isNew();
-
+
/**
* Return true if this object's data has been modified without a database update.
* @return True if object is dirty.
*/
boolean isDirty();
-
+
/**
- * Generic set method for field values.
- * This will set the object to the 'dirty' state.
+ * Generic set method for field values. This will set the object to the 'dirty' state.
* @param fieldName The name of the field.
* @param fieldValue The field value.
*/
void setFieldValue(String field, Object value);
-
+
/**
* Set all of the field values on this object.
* @param fieldValues The FieldValueMap containing pairs of names and values.
*/
void setFieldValues(FieldValueMap fieldValues);
-
+
/**
* Get a field value, cast to the given class.
* @param field The field value.
* @return The field value casted to type T.
*/
public <T> T getFieldValue(Class<T> klass, String field);
-
+
/**
* Get a field value with implicit return type.
* @param field The field's name.
* @return The field value cast to type.
*/
public <T> T getFieldValue(String field);
-
+
/**
- * Set the ConditionsTableMetaData of this object.
- * This cannot be reset once set.
+ * Set the ConditionsTableMetaData of this object. This cannot be reset once set.
* @param tableMetaData The ConditionsTableMetaData.
* @throws ConditionsObjectException if already set
*/
void setTableMetaData(TableMetaData tableMetaData) throws ConditionsObjectException;
-
+
/**
- * Set the collection ID of this object.
- * This cannot be reset once set to a valid ID (e.g. not -1).
+ * Set the collection ID of this object. This cannot be reset once set to a valid ID
+ * (e.g. not -1).
* @param collectionId The collection ID.
* @throws ConditionsObjectException if already set
*/
void setCollectionId(int collectionId) throws ConditionsObjectException;
-
+
/**
- * 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 valid ID (e.g.
+ * not -1).
* @param rowId The object's row ID.
* @throws ConditionsObjectException if already set
*/
public void setRowId(int rowId) throws ConditionsObjectException;
-
+
/**
- * Set the object to read only mode. This cannot be changed back once it is set.
+ * Set the object to read only mode. This cannot be changed back once it is set.
*/
- void setIsReadOnly();
-
+ void setIsReadOnly();
+
/**
* Simple class extending <code>java.lang.Map</code> that maps field names to values.
*/
- public static final class FieldValueMap extends LinkedHashMap<String, Object> {
-
+ public static final class FieldValueMap extends LinkedHashMap<String, Object> {
+
Object[] valuesToArray() {
return values().toArray();
}
-
+
String[] fieldsToArray() {
return keySet().toArray(new String[] {});
}
- }
+ }
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsObjectCollection.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsObjectCollection.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -9,17 +9,17 @@
// TODO: Collections with a mix of different collection IDs on their objects should always be read only.
public class ConditionsObjectCollection<T extends ConditionsObject> {
- protected List<T> objects = new ArrayList<T>();
+ protected List<T> objects = new ArrayList<T>();
protected TableMetaData tableMetaData;
protected int collectionId = -1;
protected boolean isReadOnly;
protected boolean isDirty;
protected boolean isNew;
protected ConditionsRecord conditionsRecord;
-
+
protected ConditionsObjectCollection() {
}
-
+
public ConditionsObjectCollection(TableMetaData tableMetaData, int collectionId, boolean isReadOnly) {
this.tableMetaData = tableMetaData;
this.collectionId = collectionId;
@@ -28,21 +28,22 @@
this.isNew = true;
}
}
-
+
public T get(int index) {
return objects.get(index);
}
-
+
public List<T> getObjects() {
return Collections.unmodifiableList(objects);
}
-
+
public boolean contains(Object object) {
return getObjects().contains(object);
}
-
- // TODO: Should check here if object has an existing collection ID that is different
- // from this collection's, in which case this collection becomes "mixed" and it should be
+
+ // TODO: Should check here if object has an existing collection ID that is different
+ // from this collection's, in which case this collection becomes "mixed" and it should
+ // be
// flagged as read only.
public void add(T object) throws ConditionsObjectException {
if (objects.contains(object)) {
@@ -65,33 +66,35 @@
}
public TableMetaData getTableMetaData() {
- return tableMetaData;
+ return tableMetaData;
}
public int getCollectionId() {
return collectionId;
}
-
+
// TODO: Should this also insert new records that do not exist?
// TODO: This operation should lock the table.
public void update() throws ConditionsObjectException {
- for (ConditionsObject object : objects) {
+ for (ConditionsObject object : objects) {
object.update();
- }
+ }
setIsDirty(false);
}
- // TODO: This does not need to loop. It should just call delete on the collection ID value.
+ // TODO: This does not need to loop. It should just call delete on the collection ID
+ // value.
public void delete() throws ConditionsObjectException {
if (isReadOnly()) {
throw new ConditionsObjectException("Collection is read only.");
}
- for (ConditionsObject object : objects) {
+ for (ConditionsObject object : objects) {
object.delete();
- }
+ }
}
- // TODO: This should not loop. It should select all the objects with a matching collection ID
+ // TODO: This should not loop. It should select all the objects with a matching
+ // collection ID
// from the database.
public void select() throws ConditionsObjectException, SQLException {
for (ConditionsObject object : objects) {
@@ -106,9 +109,9 @@
throw new ConditionsObjectException("Collection already exists in the database.");
}
for (ConditionsObject object : objects) {
- //if (object.isNew()) {
+ // if (object.isNew()) {
object.insert();
- //}
+ // }
}
isNew = false;
}
@@ -120,30 +123,30 @@
public boolean isReadOnly() {
return isReadOnly;
}
-
+
void setIsDirty(boolean isDirty) {
this.isDirty = isDirty;
}
-
- // TODO: This can probably just check if collection ID is not valid e.g. equals -1.
+
+ // TODO: This can probably just check if collection ID is not valid e.g. equals -1.
public boolean isNew() {
return isNew;
}
-
+
public void setCollectionId(int collectionId) throws ConditionsObjectException {
if (this.collectionId != -1)
throw new ConditionsObjectException("The collection ID is already set.");
this.collectionId = collectionId;
}
-
+
public void setTableMetaData(TableMetaData tableMetaData) {
this.tableMetaData = tableMetaData;
}
-
+
public void setIsReadOnly(boolean isReadOnly) {
this.isReadOnly = isReadOnly;
- }
-
+ }
+
public void setConditionsRecord(ConditionsRecord conditionsRecord) throws ConditionsObjectException {
if (this.conditionsRecord != null)
throw new ConditionsObjectException("The ConditionsRecord is already set on this collection.");
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsObjectConverter.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsObjectConverter.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -11,64 +11,68 @@
/**
* <p>
- * Implementation of default conversion from database tables to a {@link ConditionsObject} class.
+ * Implementation of default conversion from database tables to a {@link ConditionsObject}
+ * class.
* </p>
* <p>
* This class actually returns collections and not individual objects.
- * </p>
+ * </p>
*
* @author Jeremy McCormick <[log in to unmask]>
-
- * @param <T> The type of the returned data which should be a class extending
- * {@link ConditionsObjectCollection}.
+ *
+ * @param <T> The type of the returned data which should be a class extending
+ * {@link ConditionsObjectCollection}.
*/
public abstract class ConditionsObjectConverter<T> implements ConditionsConverter<T> {
-
- public ConditionsObjectConverter() {
+
+ public ConditionsObjectConverter() {
}
-
+
/**
* Classes that extend this must define this method to specify what type the converter
* is able to handle.
* @return The Class that this converter handles.
*/
public abstract Class getType();
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
public T getData(ConditionsManager conditionsManager, String name) {
- //System.out.println("finding conditions for key " + name + " ...");
-
+ // System.out.println("finding conditions for key " + name + " ...");
+
// Get the DatabaseConditionsManager which is required for using this converter.
DatabaseConditionsManager databaseConditionsManager = getDatabaseConditionsManager(conditionsManager);
-
+
// Get the table meta data from the key given by the caller.
TableMetaData tableMetaData = databaseConditionsManager.findTableMetaData(name);
if (tableMetaData == null)
throw new RuntimeException("Table meta data for " + name + " was not found.");
-
+
// Create a collection to return.
ConditionsObjectCollection collection;
try {
- collection = tableMetaData.getCollectionClass().newInstance();
+ collection = tableMetaData.getCollectionClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
-
- // Get the ConditionsRecord with the meta-data, which will use the current run number from the manager.
+
+ // Get the ConditionsRecord with the meta-data, which will use the current run
+ // number from the manager.
ConditionsRecordCollection conditionsRecords = databaseConditionsManager.findConditionsRecords(name);
-
+
if (conditionsRecords.getObjects().size() == 0) {
// There were no records returned, which is a fatal error.
throw new RuntimeException("No conditions found with key: " + name);
- } else if (conditionsRecords.getObjects().size() > 1) {
+ } else if (conditionsRecords.getObjects().size() > 1) {
// There were multiple records returned.
if (!allowMultipleCollections())
- // If there are multiple records returned but this is not allowed by the converter,
+ // If there are multiple records returned but this is not allowed by the
+ // converter,
// then this is a fatal error.
throw new RuntimeException("Multiple conditions records returned but this is not allowed.");
} else {
- // There was a single conditions record so the collection information can be set meaningfully.
+ // There was a single conditions record so the collection information can be
+ // set meaningfully.
try {
collection.setCollectionId(conditionsRecords.get(0).getCollectionId());
collection.setTableMetaData(tableMetaData);
@@ -78,52 +82,51 @@
}
}
- // Loop over conditions records. This will usually just be one record.
+ // Loop over conditions records. This will usually just be one record.
for (ConditionsRecord conditionsRecord : conditionsRecords.getObjects()) {
-
+
// Get the table name.
String tableName = conditionsRecord.getTableName();
-
+
// Get the collection ID.
int collectionId = conditionsRecord.getCollectionId();
-
+
// Build a select query.
String query = QueryBuilder.buildSelect(tableName, collectionId, tableMetaData.getFieldNames(), "id ASC");
-
+
// Query the database.
ResultSet resultSet = databaseConditionsManager.selectQuery(query);
-
+
try {
// Loop over rows.
while (resultSet.next()) {
// Create new ConditionsObject.
ConditionsObject newObject = createConditionsObject(resultSet, tableMetaData);
-
- // Add new object to collection, which will also assign it a
- // collection ID if applicable.
+
+ // Add new object to collection, which will also assign it a
+ // collection ID if applicable.
collection.add(newObject);
}
} catch (SQLException | ConditionsObjectException e) {
throw new RuntimeException(e);
- }
+ }
}
-
+
// Return new collection.
- return (T)collection;
+ return (T) collection;
}
- protected ConditionsObject createConditionsObject(ResultSet resultSet,
- TableMetaData tableMetaData) throws SQLException {
+ protected ConditionsObject createConditionsObject(ResultSet resultSet, TableMetaData tableMetaData) throws SQLException {
ResultSetMetaData metaData = resultSet.getMetaData();
int rowId = resultSet.getInt(1);
int ncols = metaData.getColumnCount();
FieldValueMap fieldValues = new FieldValueMap();
- for (int i=2; i<=ncols; i++) {
+ for (int i = 2; i <= ncols; i++) {
fieldValues.put(metaData.getColumnName(i), resultSet.getObject(i));
- }
+ }
ConditionsObject newObject = null;
try {
- newObject = tableMetaData.getObjectClass().newInstance();
+ newObject = tableMetaData.getObjectClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
@@ -140,15 +143,15 @@
newObject.setFieldValues(fieldValues);
return newObject;
}
-
+
protected DatabaseConditionsManager getDatabaseConditionsManager(ConditionsManager conditionsManager) {
if (conditionsManager instanceof DatabaseConditionsManager) {
- return (DatabaseConditionsManager)conditionsManager;
+ return (DatabaseConditionsManager) conditionsManager;
} else {
throw new RuntimeException("This converter requires a ConditionsManager of type DatabaseConditionsManager.");
}
}
-
+
public boolean allowMultipleCollections() {
return false;
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsObjectException.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsObjectException.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -1,8 +1,8 @@
package org.hps.conditions;
/**
- * Generic Exception type throw by methods of {@link ConditionsObject}
- * or other associated classes such as converters and collections.
+ * Generic Exception type throw by methods of {@link ConditionsObject} or other associated
+ * classes such as converters and collections.
*/
@SuppressWarnings("serial")
public final class ConditionsObjectException extends Exception {
@@ -17,7 +17,7 @@
super(message);
this.object = object;
}
-
+
public ConditionsObject getConditionsObject() {
return object;
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsRecord.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsRecord.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -3,8 +3,8 @@
import java.util.Date;
/**
- * This class represents a single record from the primary conditions data table,
- * which defines the validity range for a specific collection of conditions objects.
+ * This class represents a single record from the primary conditions data table, which
+ * defines the validity range for a specific collection of conditions objects.
*
* @author Jeremy McCormick <[log in to unmask]>
*/
@@ -17,19 +17,21 @@
*/
public static class ConditionsRecordCollection extends ConditionsObjectCollection<ConditionsRecord> {
/**
- * Since ConditionsRecord collections are always "mixed", meaning the collection ID values
- * are usually all going to be different, the default behavior of the super class is overridden.
+ * Since ConditionsRecord collections are always "mixed", meaning the collection
+ * ID values are usually all going to be different, the default behavior of the
+ * super class is overridden.
*/
public void add(ConditionsRecord record) {
objects.add(record);
}
-
- // FIXME: Should probably override more methods here that don't make sense for this type!
+
+ // FIXME: Should probably override more methods here that don't make sense for
+ // this type!
}
-
- protected ConditionsRecord() {
+
+ protected ConditionsRecord() {
}
-
+
/**
* Get the starting run number.
* @return The starting run number.
@@ -37,7 +39,7 @@
public int getRunStart() {
return getFieldValue("run_start");
}
-
+
/**
* Get the ending run number.
* @return The ending run number.
@@ -45,7 +47,7 @@
public int getRunEnd() {
return getFieldValue("run_end");
}
-
+
/**
* Get the date this record was last updated.
* @return The date this record was updated.
@@ -53,7 +55,7 @@
public Date getUpdated() {
return getFieldValue("updated");
}
-
+
/**
* Get the date this record was created.
* @return The date this record was created.
@@ -61,7 +63,7 @@
public Date getCreated() {
return getFieldValue("created");
}
-
+
/**
* Get the starting valid time.
* @return The starting valid time.
@@ -69,13 +71,13 @@
public Date getValidFrom() {
return getFieldValue("valid_from");
}
-
+
/**
* Get the ending valid time.
* @return The ending valid time.
*/
public Date getValidTo() {
- return getFieldValue("valid_to");
+ return getFieldValue("valid_to");
}
/**
@@ -93,16 +95,16 @@
public String getNotes() {
return getFieldValue("notes");
}
-
+
/**
- * 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".
+ * 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.
*/
public String getName() {
return getFieldValue("name");
}
-
+
/**
* Get the version of the format these conditions are stored in.
* @return The conditions version.
@@ -110,15 +112,15 @@
public String getFormatVersion() {
return getFieldValue("format_version");
}
-
+
/**
* 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.
*/
public String getTableName() {
return getFieldValue("table_name");
}
-
+
/**
* Get the collection ID, overriding this method from the parent class.
* @return The collection ID.
@@ -126,7 +128,7 @@
public int getCollectionId() {
return getFieldValue("collection_id");
}
-
+
/**
* Convert this record to a human readable string, one field per line.
* @return This object represented as a string.
@@ -145,7 +147,7 @@
buff.append("validTo: " + getValidTo() + '\n');
buff.append("createdBy: " + getCreatedBy() + '\n');
buff.append("formatVersion: " + getFormatVersion() + '\n');
- buff.append("notes: " + getNotes() + '\n');
+ buff.append("notes: " + getNotes() + '\n');
return buff.toString();
- }
+ }
}
\ No newline at end of file
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsRecordConverter.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConditionsRecordConverter.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -7,70 +7,65 @@
import org.lcsim.conditions.ConditionsManager;
/**
- * Read ConditionsRecord objects from the conditions database.
+ * Read ConditionsRecord objects from the conditions database.
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: ConditionsRecordConverter.java,v 1.5 2013/10/15 23:24:47 jeremy Exp $
*/
public final class ConditionsRecordConverter extends ConditionsObjectConverter<ConditionsRecordCollection> {
-
+
/**
* Get the ConditionsRecords for a run based on current configuration of the
- * <code>DatabaseConditionsManager</code>.
+ * <code>DatabaseConditionsManager</code>.
* @param manager The current conditions manager.
* @param name The name of the conditions set.
* @return The matching ConditionsRecords.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public ConditionsRecordCollection getData(ConditionsManager manager, String name) {
-
+
DatabaseConditionsManager databaseConditionsManager = getDatabaseConditionsManager(manager);
TableMetaData tableMetaData = databaseConditionsManager.findTableMetaData(name);
-
+
if (tableMetaData == null)
throw new RuntimeException("Failed to find meta data with key " + name);
-
- String query = "SELECT * from "
- + tableMetaData.getTableName()
- + " WHERE "
- + "run_start <= "
- + manager.getRun()
- + " AND run_end >= "
- + manager.getRun();
-
+
+ String query = "SELECT * from " + tableMetaData.getTableName() + " WHERE " + "run_start <= " + manager.getRun() + " AND run_end >= " + manager.getRun();
+
ResultSet resultSet = databaseConditionsManager.selectQuery(query);
-
+
// Create a collection to return.
ConditionsObjectCollection collection;
try {
- collection = tableMetaData.getCollectionClass().newInstance();
+ collection = tableMetaData.getCollectionClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
-
+
try {
- while(resultSet.next()) {
+ while (resultSet.next()) {
ConditionsObject conditionsRecord = createConditionsObject(resultSet, tableMetaData);
try {
collection.add(conditionsRecord);
} catch (ConditionsObjectException e) {
throw new RuntimeException(e);
}
- }
+ }
} catch (SQLException x) {
throw new RuntimeException("Database error", x);
- }
-
+ }
+
return getType().cast(collection);
}
/**
* Get the type handled by this converter.
- * @return The type handled by this converter, which is <code>ConditionsRecordCollection</code>.
+ * @return The type handled by this converter, which is
+ * <code>ConditionsRecordCollection</code>.
*/
public Class<ConditionsRecordCollection> getType() {
return ConditionsRecordCollection.class;
- }
-
+ }
+
public boolean allowMultipleCollections() {
return true;
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/ConnectionParameters.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ConnectionParameters.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -11,14 +11,14 @@
import java.util.Properties;
/**
- * This class encapsulates the parameters for connecting to a database,
- * including hostname, port, user and password. It can also create and
- * return a Connection object based on these parameters.
+ * This class encapsulates the parameters for connecting to a database, including
+ * hostname, port, user and password. It can also create and return a Connection object
+ * based on these parameters.
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: ConnectionParameters.java,v 1.8 2013/10/04 01:54:16 jeremy Exp $
*/
public final class ConnectionParameters {
-
+
private String user;
private String password;
private int port;
@@ -67,7 +67,7 @@
int getPort() {
return port;
}
-
+
/**
* Get the name of the database.
* @return The name of the database.
@@ -75,14 +75,14 @@
String getDatabase() {
return database;
}
-
+
/**
* Get the user name.
*/
String getUser() {
return user;
}
-
+
/**
* Get the password.
*/
@@ -96,14 +96,14 @@
*/
String getConnectionString() {
return "jdbc:mysql://" + hostname + ":" + port + "/";
- }
-
+ }
+
/**
- * Create a database connection from these parameters.
- * The caller becomes the "owner" and is responsible for closing it when finished.
+ * Create a database connection from these parameters. The caller becomes the "owner"
+ * and is responsible for closing it when finished.
* @return The Connection object.
*/
- Connection createConnection() {
+ Connection createConnection() {
Properties connectionProperties = getConnectionProperties();
Connection connection = null;
try {
@@ -114,13 +114,13 @@
}
return connection;
}
-
+
/**
- * Configure the connection parameters from a properties file.
+ * Configure the connection parameters from a properties file.
* @param file The properties file.
* @return The connection parameters.
*/
- public static final ConnectionParameters fromProperties(File file) {
+ public static final ConnectionParameters fromProperties(File file) {
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
@@ -129,19 +129,19 @@
}
return fromProperties(fin);
}
-
+
/**
- * Configure the connection parameters from an embedded classpath resource
- * which should be a properties file.
+ * Configure the connection parameters from an embedded classpath resource which
+ * should be a properties file.
* @param String The resource path.
* @return The connection parameters.
*/
public static final ConnectionParameters fromResource(String resource) {
return fromProperties(ConnectionParameters.class.getResourceAsStream(resource));
}
-
+
/**
- * Configure the connection parameters from an <code>InputStream</code> of properties.
+ * Configure the connection parameters from an <code>InputStream</code> of properties.
* @param in The InputStream of the properties.
* @return The connection parameters.
* @throws RuntimeException if the InputStream is invalid
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/DatabaseConditionsManager.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/DatabaseConditionsManager.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -33,34 +33,35 @@
/**
* <p>
- * This class should be used as the top-level ConditionsManager for database access to conditions
- * data.
+ * This class should be used as the top-level ConditionsManager for database access to
+ * conditions data.
* </p>
* <p>
- * In general, this will be overriding the <code>LCSimConditionsManagerImplementation</code> which
- * is setup from within <code>LCSimLoop</code>.
+ * In general, this will be overriding the
+ * <code>LCSimConditionsManagerImplementation</code> which is setup from within
+ * <code>LCSimLoop</code>.
* </p>
*
* @author Jeremy McCormick <[log in to unmask]>
- */
+ */
@SuppressWarnings("rawtypes")
public final class DatabaseConditionsManager extends ConditionsManagerImplementation {
int runNumber = -1;
String detectorName;
- List<TableMetaData> tableMetaData;
+ List<TableMetaData> tableMetaData;
List<ConditionsConverter> converters;
File connectionPropertiesFile;
- ConditionsReader baseReader;
+ ConditionsReader baseReader;
static Logger logger = null;
ConnectionParameters connectionParameters;
Connection connection;
boolean wasConfigured = false;
boolean isConnected = false;
-
+
/**
- * Class constructor, which is only package accessible.
- * Users should call {@link #getInstance()} to access the manager.
+ * Class constructor, which is only package accessible. Users should call
+ * {@link #getInstance()} to access the manager.
*/
DatabaseConditionsManager() {
registerConditionsConverter(new DetectorConditionsConverter());
@@ -92,74 +93,74 @@
logger.addHandler(handler);
logger.config("logger initialized with level " + handler.getLevel());
}
-
+
/**
- * Register this conditions manager as the global default.
+ * Register this conditions manager as the global default.
*/
void register() {
ConditionsManager.setDefaultConditionsManager(this);
}
/**
- * Get the static instance of this class, which must have been
- * registered first from a call to {@link #register()}.
+ * Get the static instance of this class, which must have been registered first from a
+ * call to {@link #register()}.
* @return The static instance of the manager.
*/
public static DatabaseConditionsManager getInstance() {
-
+
// Perform default setup if necessary.
if (!ConditionsManager.isSetup()) {
DatabaseConditionsManager manager = new DatabaseConditionsManager();
manager.register();
}
-
- // Get the instance of the manager from the conditions system and
+
+ // Get the instance of the manager from the conditions system and
// that the type is valid.
ConditionsManager manager = ConditionsManager.defaultInstance();
if (!(manager instanceof DatabaseConditionsManager)) {
throw new RuntimeException("The default ConditionsManager has the wrong type.");
}
-
- return (DatabaseConditionsManager)manager;
+
+ return (DatabaseConditionsManager) manager;
}
-
+
/**
- * This method catches changes to the detector name and run number.
- * Somewhat unintuitively, this method is actually called every time
- * an lcsim event is created, so it has internal logic to figure out
- * if the conditions system actually needs to be updated.
+ * This method catches changes to the detector name and run number. Somewhat
+ * unintuitively, this method is actually called every time an lcsim event is created,
+ * so it has internal logic to figure out if the conditions system actually needs to
+ * be updated.
*/
@Override
- public void setDetector(String detectorName, int runNumber) throws ConditionsNotFoundException {
+ public void setDetector(String detectorName, int runNumber) throws ConditionsNotFoundException {
// Detector update.
if (getDetector() == null || !getDetector().equals(detectorName)) {
logger.config("setting new detector " + detectorName);
setup(detectorName);
}
-
+
// Run number update.
if (this.runNumber != runNumber) {
logger.config("setting new run number " + runNumber);
this.runNumber = runNumber;
}
-
+
// Let the super class do whatever it think it needs to do.
super.setDetector(detectorName, runNumber);
- }
-
+ }
+
/**
* Perform setup for a new detector description.
* @param detectorName the name of the detector
*/
void setup(String detectorName) {
if (baseReader instanceof BaseClasspathConditionsReader) {
- ((BaseClasspathConditionsReader)baseReader).setResourcePath(detectorName);
+ ((BaseClasspathConditionsReader) baseReader).setResourcePath(detectorName);
logger.config("set resource path " + detectorName + " on conditions reader");
}
if (!isConnected())
openConnection();
else
- logger.config("using existing connection " + connectionParameters.getConnectionString());
+ logger.config("using existing connection " + connectionParameters.getConnectionString());
}
/**
@@ -194,7 +195,7 @@
configure(new FileInputStream(file));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
- }
+ }
}
/**
@@ -206,9 +207,9 @@
InputStream in = getClass().getResourceAsStream(resource);
if (in == null)
throw new IllegalArgumentException("The resource does not exist.");
- configure(in);
+ configure(in);
}
-
+
/**
* Set the path to a properties file containing connection settings.
* @param file The properties file
@@ -217,26 +218,26 @@
logger.config("setting connection prop file " + file.getPath());
if (!file.exists())
throw new IllegalArgumentException("The connection properties file does not exist: " + connectionPropertiesFile.getPath());
- connectionParameters = ConnectionParameters.fromProperties(file);
+ connectionParameters = ConnectionParameters.fromProperties(file);
}
-
+
/**
* Set the connection parameters from an embedded resource.
* @param resource The classpath resource
*/
public void setConnectionResource(String resource) {
logger.config("setting connection resource " + resource);
- connectionParameters = ConnectionParameters.fromResource(resource);
+ connectionParameters = ConnectionParameters.fromResource(resource);
}
/**
- * Set externally the base ConditionsReader that will be used to find non-database conditions
- * such as the compact.xml file for the detector.
+ * Set externally the base ConditionsReader that will be used to find non-database
+ * conditions such as the compact.xml file for the detector.
* @param reader The base ConditionsReader.
*/
public void setBaseConditionsReader(ConditionsReader reader) {
logger.config("setting conditions reader to " + reader.getClass().getCanonicalName());
- baseReader = reader;
+ baseReader = reader;
}
/**
@@ -244,7 +245,8 @@
* @param tableName The name of the table.
* @return The next collection ID.
*/
- // FIXME: If there are no collections that exist, this method should simply return the value '1'
+ // FIXME: If there are no collections that exist, this method should simply return the
+ // value '1'
// or it could throw an exception.
public int getNextCollectionId(String tableName) {
TableMetaData tableData = findTableMetaData(tableName);
@@ -279,11 +281,11 @@
for (TableMetaData meta : tableMetaData) {
if (meta.getKey().equals(name)) {
return meta;
- }
+ }
}
return null;
}
-
+
/**
* Find meta data by collection class type.
* @param type The collection class.
@@ -297,9 +299,9 @@
}
return null;
}
-
+
/**
- * This method can be used to perform a database SELECT query.
+ * 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.
*/
@@ -312,23 +314,23 @@
result = statement.executeQuery(query);
} catch (SQLException x) {
throw new RuntimeException("Error in query: " + query, x);
- }
+ }
return result;
}
-
+
/**
* 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.
*/
- public List<Integer> updateQuery(String query) {
+ public List<Integer> updateQuery(String query) {
logger.fine(query);
List<Integer> keys = new ArrayList<Integer>();
Statement statement = null;
try {
statement = connection.createStatement();
- statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
- ResultSet resultSet = statement.getGeneratedKeys();
+ statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
+ ResultSet resultSet = statement.getGeneratedKeys();
while (resultSet.next()) {
int key = resultSet.getInt(1);
keys.add(key);
@@ -340,7 +342,7 @@
}
return keys;
}
-
+
/**
* Set the log level.
* @param level The log level.
@@ -350,11 +352,11 @@
logger.setLevel(level);
logger.getHandlers()[0].setLevel(level);
}
-
+
/**
- * 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 in the XML configuration.
+ * 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 in the XML
+ * configuration.
* @param name The conditions key name.
* @return The set of matching conditions records.
*/
@@ -369,13 +371,12 @@
}
if (foundConditionsRecords.getObjects().size() > 0) {
for (ConditionsRecord record : foundConditionsRecords.getObjects()) {
- logger.fine("found ConditionsRecord with key " + name + " ..."
- + '\n' + record.toString());
+ logger.fine("found ConditionsRecord with key " + name + " ..." + '\n' + record.toString());
}
}
return foundConditionsRecords;
- }
-
+ }
+
/**
* Return true if the connection parameters are valid, e.g. non-null.
* @return true if connection parameters are non-null
@@ -383,7 +384,7 @@
public boolean hasConnectionParameters() {
return connectionParameters != null;
}
-
+
/**
* Return if the manager was configured e.g. from an XML configuration file.
* @return true if manager was configured
@@ -391,7 +392,7 @@
public boolean wasConfigured() {
return wasConfigured;
}
-
+
/**
* Close a JDBC <code>Statement</code>.
* @param statement the Statement to close
@@ -408,12 +409,12 @@
}
}
}
-
+
/**
* Close a JDBC <code>ResultSet</code>, or rather the Statement connected to it.
* @param resultSet the ResultSet to close
*/
- static void close(ResultSet resultSet) {
+ static void close(ResultSet resultSet) {
if (resultSet != null) {
try {
Statement statement = resultSet.getStatement();
@@ -426,7 +427,7 @@
}
}
}
-
+
/**
* Check if connected to the database.
* @return true if connected
@@ -436,8 +437,8 @@
}
/**
- * Configure this class from an <code>InputStream</code> which should point
- * to an XML document.
+ * Configure this class from an <code>InputStream</code> which should point to an XML
+ * document.
* @param in the InputStream which should be in XML format
*/
private void configure(InputStream in) {
@@ -449,12 +450,12 @@
loadTableMetaData(config);
// Load the converter classes.
- loadConverters(config);
-
+ loadConverters(config);
+
// Set configured state to true.
wasConfigured = true;
}
-
+
/**
* Create an XML document from an <code>InputStream</code>.
* @param in The InputStream.
@@ -477,8 +478,9 @@
* @param config The XML document.
*/
private void loadConverters(Document config) {
-
- // Load the list of converters from the "converters" section of the config document.
+
+ // Load the list of converters from the "converters" section of the config
+ // document.
(this.new ConditionsConverterLoader()).load(config.getRootElement().getChild("converters"));
// Register the list of converters with this manager.
@@ -486,9 +488,9 @@
for (ConditionsConverter converter : converters) {
registerConditionsConverter(converter);
logger.config("registered converter " + converter.getClass().getSimpleName());
- }
+ }
}
-
+
/**
* Load table meta data configuration from an XML document.
* @param config The XML document.
@@ -497,7 +499,7 @@
// Load table meta data from the "tables" section of the config document.
(this.new TableMetaDataLoader()).load(config.getRootElement().getChild("tables"));
}
-
+
/**
* Open the database connection.
*/
@@ -508,7 +510,7 @@
logger.config("created connection " + connectionParameters.getConnectionString());
isConnected = true;
}
-
+
/**
* Close the database connection.
*/
@@ -529,13 +531,13 @@
connection = null;
connectionParameters = null;
}
-
+
@Override
public void finalize() {
if (isConnected())
closeConnection();
}
-
+
/**
* This class loads an XML configuration of conditions table meta data.
*
@@ -597,17 +599,17 @@
tableMetaData.add(tableData);
}
- }
+ }
}
/**
- * This class reads in an XML configuration specifying a list of converter classes, e.g. from
- * the config file for the {@link DatabaseConditionsManager}.
+ * This class reads in an XML configuration specifying a list of converter classes,
+ * e.g. from the config file for the {@link DatabaseConditionsManager}.
*
* @author Jeremy McCormick <[log in to unmask]>
*/
class ConditionsConverterLoader {
-
+
void load(Element element) {
converters = new ArrayList<ConditionsConverter>();
for (Iterator iterator = element.getChildren("converter").iterator(); iterator.hasNext();) {
@@ -629,5 +631,5 @@
}
}
}
-
+
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/DefaultTestSetup.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/DefaultTestSetup.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -4,24 +4,24 @@
/**
* <p>
- * This is a static utility class for setting up the conditions system for test cases
- * in this package and sub-packages.
+ * This is a static utility class for setting up the conditions system for test cases in
+ * this package and sub-packages.
* </p>
* <p>
* It uses the SLAC Test Run 2012 conditions database, with a relative reference to a file
- * containing connection parameters in the hps-conditions module. The XML configuration
- * is read from a classpath resource in the same module.
+ * containing connection parameters in the hps-conditions module. The XML configuration is
+ * read from a classpath resource in the same module.
* </p>
* <p>
- * The detector is set to <i>HPS-conditions-test</i>, which is a test detector without real data
- * associated to it. There are a few files used in the test cases that use this detector.
+ * The detector is set to <i>HPS-conditions-test</i>, which is a test detector without
+ * real data associated to it. There are a few files used in the test cases that use this
+ * detector.
* </p>
* <p>
* The run number is initially set to <i>1351</i> which is one of the "good runs".
* </p>
* <p>
- * Full setup can be performed with this method chain:
- * <code>
+ * Full setup can be performed with this method chain: <code>
* DatabaseConditionsManager manager = new DefaultTestSetup().configure().setup();
* </code>
* </p>
@@ -39,19 +39,20 @@
// Default conditions manager parameters.
static String connectionResource = "/org/hps/conditions/config/conditions_database_testrun_2012_connection.properties";
static String conditionsConfig = "/org/hps/conditions/config/conditions_database_testrun_2012.xml";
-
+
// Default test detector and run number for test cases not using real data.
static String detectorName = "HPS-conditions-test";
static int runNumber = 1351;
-
+
DatabaseConditionsManager conditionsManager;
boolean wasConfigured = false;
-
+
/**
- * Configure and register the {@link DatabaseConditionsManager} with default parameters.
+ * Configure and register the {@link DatabaseConditionsManager} with default
+ * parameters.
* @return an instance of this class for chaining (e.g. to call {@link #setup()}.
*/
- public DefaultTestSetup configure() {
+ public DefaultTestSetup configure() {
conditionsManager = new DatabaseConditionsManager();
conditionsManager.setConnectionResource(connectionResource);
conditionsManager.configure(conditionsConfig);
@@ -59,10 +60,10 @@
wasConfigured = true;
return this;
}
-
+
/**
- * Setup the detector and run number conditions for the conditions manager.
- * This is mostly useful for test cases not using an <code>LCSimLoop</code>.
+ * Setup the detector and run number conditions for the conditions manager. This is
+ * mostly useful for test cases not using an <code>LCSimLoop</code>.
* @return the conditions manager
*/
public DatabaseConditionsManager setup() {
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/QueryBuilder.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/QueryBuilder.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -6,9 +6,10 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
final class QueryBuilder {
-
- private QueryBuilder() {}
+ private QueryBuilder() {
+ }
+
static String buildSelect(String tableName, int collectionId, String[] fields, String order) {
StringBuffer buff = new StringBuffer();
buff.append("SELECT ");
@@ -20,7 +21,7 @@
for (String fieldName : fields) {
buff.append(fieldName + ", ");
}
- buff.delete(buff.length()-2, buff.length()-1);
+ buff.delete(buff.length() - 2, buff.length() - 1);
}
buff.append(" FROM " + tableName);
if (collectionId != -1)
@@ -30,20 +31,20 @@
}
return buff.toString();
}
-
+
static String buildUpdate(String tableName, int rowId, String[] fields, Object[] values) {
if (fields.length != values.length)
- throw new IllegalArgumentException("The field and value arrays are different lengths.");
- StringBuffer buff = new StringBuffer();
+ throw new IllegalArgumentException("The field and value arrays are different lengths.");
+ StringBuffer buff = new StringBuffer();
buff.append("UPDATE " + tableName + " SET ");
- for (int i=0; i<fields.length; i++) {
+ for (int i = 0; i < fields.length; i++) {
buff.append(fields[i] + " = '" + values[i] + "', ");
}
- buff.delete(buff.length()-2, buff.length()-1);
- buff.append(" WHERE id = " + rowId);
+ buff.delete(buff.length() - 2, buff.length() - 1);
+ buff.append(" WHERE id = " + rowId);
return buff.toString();
}
-
+
static String buildInsert(String tableName, int collectionId, String[] fields, Object[] values) {
if (fields.length != values.length)
throw new IllegalArgumentException("The field and value arrays are different lengths.");
@@ -55,16 +56,16 @@
buff.append(" ) VALUES ( " + collectionId);
for (Object value : values) {
buff.append(", " + value);
- }
+ }
buff.append(") ");
return buff.toString();
}
-
+
static String buildDelete(String tableName, int rowId) {
if (rowId <= 0)
throw new IllegalArgumentException("Invalid row ID: " + rowId);
String query = "DELETE FROM " + tableName + " WHERE id = " + rowId;
return query;
}
-
+
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/TableConstants.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/TableConstants.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -2,64 +2,66 @@
/**
* <p>
- * This is a static set of constants defining default table names and lookup key values for conditions data.
- * The actual table names for the conditions data are defined externally in an XML configuration file read by the
- * {@link DatabaseConditionsManager}.
+ * This is a static set of constants defining default table names and lookup key values
+ * for conditions data. The actual table names for the conditions data are defined
+ * externally in an XML configuration file read by the {@link DatabaseConditionsManager}.
* </p>
* <p>
- * It is possible that the key and table names are defined differently in the XML configuration, e.g. if the
- * name of the key is not exactly the same as the table name, but usually they are the same value.
- * </p>
+ * It is possible that the key and table names are defined differently in the XML
+ * configuration, e.g. if the name of the key is not exactly the same as the table name,
+ * but usually they are the same value.
+ * </p>
*/
public final class TableConstants {
-
- private TableConstants() {}
-
+
+ private TableConstants() {
+ }
+
/** Conditions key for ConditionsRecord. */
public static final String CONDITIONS_RECORD = "conditions_records";
/** Conditions key for combined ECal conditions. */
public static final String ECAL_CONDITIONS = "ecal_conditions";
-
+
/** Table with ECal channel data. */
public static final String ECAL_CHANNELS = "ecal_channels";
/** Conditions key for ECal gain data. */
public static final String ECAL_GAINS = "ecal_gains";
-
+
/** Conditions key for ECal bad channel set. */
public static final String ECAL_BAD_CHANNELS = "ecal_bad_channels";
-
+
/** Conditions key for ECal calibration information. */
public static final String ECAL_CALIBRATIONS = "ecal_calibrations";
-
+
/** ECAL time shifts. */
public static final String ECAL_TIME_SHIFTS = "ecal_time_shifts";
-
+
/** Conditions key for combined ECal conditions. */
public static final String SVT_CONDITIONS = "svt_conditions";
-
+
/** Table with SVT channel data. */
public static final String SVT_CHANNELS = "svt_channels";
-
+
/** Table with the SVT DAQ map. */
public static final String SVT_DAQ_MAP = "svt_daq_map";
-
- /** Conditions key for SVT calibration data. */
+
+ /** Conditions key for SVT calibration data. */
public static final String SVT_CALIBRATIONS = "svt_calibrations";
-
+
/** Conditions key for SVT bad channels. */
public static final String SVT_BAD_CHANNELS = "svt_bad_channels";
-
+
/** Conditions key for SVT pulse parameters. */
public static final String SVT_PULSE_PARAMETERS = "svt_pulse_parameters";
-
+
/** Conditions key for SVT gain data. */
public static final String SVT_GAINS = "svt_gains";
-
+
/** Conditions key for SVT time shifts by sensor. */
public static final String SVT_TIME_SHIFTS = "svt_time_shifts";
-
+
/** Conditions key for integrated beam current. */
public static final String BEAM_CURRENT = "beam_current";
}
java/trunk/conditions/src/main/java/org/hps/conditions
--- java/trunk/conditions/src/main/java/org/hps/conditions/TableMetaData.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/TableMetaData.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -5,43 +5,39 @@
/**
* <p>
- * This class provides meta data about a conditions table, including a
- * list of conditions data fields. The list of fields does not include
- * the collection ID or row ID, which are implicitly assumed to exist.
- * </p>
+ * This class provides meta data about a conditions table, including a list of conditions
+ * data fields. The list of fields does not include the collection ID or row ID, which are
+ * implicitly assumed to exist.
+ * </p>
* <p>
- * It also has references to the implementation classes which are used to
- * map the data onto {@link ConditionsObject} and {@link ConditionsObjectCollection}s.
+ * It also has references to the implementation classes which are used to map the data
+ * onto {@link ConditionsObject} and {@link ConditionsObjectCollection}s.
* </p>
*
* @author Jeremy McCormick <[log in to unmask]>
- *
+ *
*/
public final class TableMetaData {
-
+
String tableName;
String key;
Class<? extends ConditionsObject> objectClass;
Class<? extends ConditionsObjectCollection<?>> collectionClass;
Set<String> fieldNames = new LinkedHashSet<String>();
-
+
/**
* The fully qualified constructor.
* @param tableName The name of the table in the conditions database.
* @param objectClass The type of object for the data mapping.
* @param collectionClass The type of collection for the data mapping.
*/
- TableMetaData(
- String key,
- String tableName,
- Class<? extends ConditionsObject> objectClass,
- Class<? extends ConditionsObjectCollection<?>> collectionClass) {
+ TableMetaData(String key, String tableName, Class<? extends ConditionsObject> objectClass, Class<? extends ConditionsObjectCollection<?>> collectionClass) {
this.key = key;
this.tableName = tableName;
this.objectClass = objectClass;
this.collectionClass = collectionClass;
}
-
+
/**
* Get the type of object this table maps onto.
* @return The type of object.
@@ -49,7 +45,7 @@
Class<? extends ConditionsObject> getObjectClass() {
return objectClass;
}
-
+
/**
* Get the type of collection this table maps onto.
* @return
@@ -57,16 +53,15 @@
Class<? extends ConditionsObjectCollection<?>> getCollectionClass() {
return collectionClass;
}
-
+
/**
- * Get the names of the fields.
- * Types are implied from the database tables.
+ * Get the names of the fields. Types are implied from the database tables.
* @return The names of the fields.
*/
String[] getFieldNames() {
- return fieldNames.toArray(new String[]{});
+ return fieldNames.toArray(new String[] {});
}
-
+
/**
* Add a field.
* @param name The name of the field.
@@ -77,7 +72,7 @@
}
fieldNames.add(name);
}
-
+
/**
* Get the name of the table.
* @return The name of the table.
@@ -85,10 +80,10 @@
public String getTableName() {
return tableName;
}
-
+
/**
- * Get the key of this conditions type. May be different from table name
- * but is usually the same.
+ * 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.
*/
public String getKey() {
java/trunk/conditions/src/main/java/org/hps/conditions/beam
--- java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamConverterRegistry.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamConverterRegistry.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -3,7 +3,7 @@
import org.hps.conditions.ConditionsObjectConverter;
import org.hps.conditions.beam.BeamCurrent.BeamCurrentCollection;
-public final class BeamConverterRegistry {
+public final class BeamConverterRegistry {
public static final class BeamCurrentConverter extends ConditionsObjectConverter<BeamCurrentCollection> {
public Class getType() {
return BeamCurrentCollection.class;
java/trunk/conditions/src/main/java/org/hps/conditions/beam
--- java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -8,10 +8,10 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class BeamCurrent extends AbstractConditionsObject {
-
+
public static class BeamCurrentCollection extends ConditionsObjectCollection<BeamCurrent> {
}
-
+
/**
* Get the integrated beam current.
* @return The integrated beam current.
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalBadChannel.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalBadChannel.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -4,16 +4,16 @@
import org.hps.conditions.ConditionsObjectCollection;
/**
- * This class represents an ECAL channel that is considered "bad" which means
- * it should not be used in reconstruction.
+ * This class represents an ECAL channel that is considered "bad" which means it should
+ * not be used in reconstruction.
*/
public final class EcalBadChannel extends AbstractConditionsObject {
-
- public static class EcalBadChannelCollection extends ConditionsObjectCollection<EcalBadChannel> {
+
+ public static class EcalBadChannelCollection extends ConditionsObjectCollection<EcalBadChannel> {
}
-
+
int getChannelId() {
return getFieldValue("ecal_channel_id");
}
-
+
}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCalibration.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalCalibration.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -4,19 +4,19 @@
import org.hps.conditions.ConditionsObjectCollection;
/**
- * This class is a simplistic representation of ECal pedestal and noise
- * values from the conditions database.
+ * This class is a simplistic representation of ECal pedestal and noise values from the
+ * conditions database.
*
- * The pedestal and noise are in units of ADC counts. They are the mean and the
- * standard deviation of the digitized pre-amp output.
+ * The pedestal and noise are in units of ADC counts. They are the mean and the standard
+ * deviation of the digitized pre-amp output.
*
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalCalibration extends AbstractConditionsObject {
-
+
public static class EcalCalibrationCollection extends ConditionsObjectCollection<EcalCalibration> {
}
-
+
/**
* Get the channel ID.
* @return The channel ID.
@@ -24,19 +24,19 @@
public int getChannelId() {
return getFieldValue("ecal_channel_id");
}
-
+
/**
- * Get the pedestal value in units of ADC counts, which is the
- * mean of the digitized pre-amp output.
+ * Get the pedestal value in units of ADC counts, which is the mean of the digitized
+ * pre-amp output.
* @return The gain value.
*/
public double getPedestal() {
return getFieldValue("pedestal");
- }
-
+ }
+
/**
- * Get the noise value in units of ADC counts, which is the
- * standard deviation of the digitized pre-amp output.
+ * Get the noise value in units of ADC counts, which is the standard deviation of the
+ * digitized pre-amp output.
* @return The noise value.
*/
public double getNoise() {
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannel.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -12,205 +12,205 @@
import org.lcsim.detector.identifier.IIdentifierHelper;
/**
- * 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 Jeremy McCormick <[log in to unmask]>
*/
public final class EcalChannel extends AbstractConditionsObject {
-
+
/**
- * 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 {
- private int crate = -1;
- private int slot = -1;
- private int channel = -1;
-
+ private int crate = -1;
+ private int slot = -1;
+ private int channel = -1;
+
public DaqId(int values[]) {
- crate = values[0];
- slot = values[1];
- channel = values[2];
+ crate = values[0];
+ slot = values[1];
+ channel = values[2];
}
-
- @Override
+
+ @Override
public long encode() {
- // from Sho's code
- return (((long) crate) << 32) | ((long) slot << 16) | (long) channel;
+ // from Sho's code
+ return (((long) crate) << 32) | ((long) slot << 16) | (long) channel;
}
-
- @Override
+
+ @Override
public boolean isValid() {
- return crate != -1 && slot != -1 && channel != -1;
+ return crate != -1 && slot != -1 && channel != -1;
}
}
-
+
/**
- * 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 {
- private int system = -1;
- private int x = Integer.MAX_VALUE;
- private int y = Integer.MAX_VALUE;
-
+ private int system = -1;
+ private int x = Integer.MAX_VALUE;
+ private int y = Integer.MAX_VALUE;
+
private IIdentifierHelper helper;
-
+
public GeometryId(IIdentifierHelper helper, int[] values) {
- this.helper = helper;
- system = values[0];
- x = values[1];
- y = values[2];
+ this.helper = helper;
+ system = values[0];
+ x = values[1];
+ y = values[2];
}
-
- @Override
+
+ @Override
public long encode() {
- IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields());
+ 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);
return helper.pack(expId).getValue();
}
- @Override
- public boolean isValid() {
- return system != -1 && x != Integer.MAX_VALUE && y != Integer.MAX_VALUE;
- }
+ @Override
+ public boolean isValid() {
+ return system != -1 && x != Integer.MAX_VALUE && y != Integer.MAX_VALUE;
+ }
}
-
+
/**
- * 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 {
-
+
private int id = -1;
-
+
public ChannelId(int[] values) {
- id = values[0];
+ id = values[0];
}
-
- @Override
+
+ @Override
public long encode() {
- return id;
+ return id;
}
-
- @Override
+
+ @Override
public boolean isValid() {
- return id != -1;
+ return id != -1;
}
}
-
+
DaqId createDaqId() {
- return new DaqId(new int[] {getCrate(), getSlot(), getChannel()});
+ return new DaqId(new int[] { getCrate(), getSlot(), getChannel() });
}
-
+
GeometryId createGeometryId(IIdentifierHelper helper, int system) {
- return new GeometryId(helper, new int[] {system, getX(), getY()});
+ return new GeometryId(helper, new int[] { system, getX(), getY() });
}
-
+
ChannelId createChannelId() {
- return new ChannelId(new int[] {this.getChannelId()});
+ return new ChannelId(new int[] { this.getChannelId() });
}
-
+
/**
- * A collection of {@link EcalChannel} objects.
+ * A collection of {@link EcalChannel} objects.
*/
public static class EcalChannelCollection extends ConditionsObjectCollection<EcalChannel> {
-
- // Identifier maps for fast lookup.
- Map<Long, EcalChannel> daqMap = new HashMap<Long, EcalChannel>();
- Map<Long, EcalChannel> geometryMap = new HashMap<Long, EcalChannel>();
- 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.
- */
- @Override
- public void add(EcalChannel channel) throws ConditionsObjectException {
- super.add(channel);
- DaqId daqId = channel.createDaqId();
- if (daqId.isValid())
- daqMap.put(daqId.encode(), channel);
- ChannelId channelId = channel.createChannelId();
- if (channelId.isValid())
- channelMap.put(channelId.encode(), channel);
- }
-
- /**
- * Build the map of geometry IDs.
- * @param helper The identifier helper of the subdetector.
- * @param system The system ID of the subdetector.
- */
- void buildGeometryMap(IIdentifierHelper helper, int system) {
- for (EcalChannel channel : this.objects) {
- GeometryId geometryId = channel.createGeometryId(helper, system);
- geometryMap.put(geometryId.encode(), channel);
- }
- }
-
+
+ // Identifier maps for fast lookup.
+ Map<Long, EcalChannel> daqMap = new HashMap<Long, EcalChannel>();
+ Map<Long, EcalChannel> geometryMap = new HashMap<Long, EcalChannel>();
+ 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.
+ */
+ @Override
+ public void add(EcalChannel channel) throws ConditionsObjectException {
+ super.add(channel);
+ DaqId daqId = channel.createDaqId();
+ if (daqId.isValid())
+ daqMap.put(daqId.encode(), channel);
+ ChannelId channelId = channel.createChannelId();
+ if (channelId.isValid())
+ channelMap.put(channelId.encode(), channel);
+ }
+
+ /**
+ * Build the map of geometry IDs.
+ * @param helper The identifier helper of the subdetector.
+ * @param system The system ID of the subdetector.
+ */
+ void buildGeometryMap(IIdentifierHelper helper, int system) {
+ for (EcalChannel channel : this.objects) {
+ GeometryId geometryId = channel.createGeometryId(helper, system);
+ geometryMap.put(geometryId.encode(), channel);
+ }
+ }
+
+ /**
* Find a channel by using DAQ information.
* @param daqId The DAQ ID object.
* @return The matching channel or null if does not exist.
*/
public EcalChannel findChannel(DaqId daqId) {
- return daqMap.get(daqId.encode());
+ return daqMap.get(daqId.encode());
}
-
+
/**
* 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.
*/
public EcalChannel findChannel(GeometryId geometryId) {
- return geometryMap.get(geometryId.encode());
+ return geometryMap.get(geometryId.encode());
}
-
+
/**
* Find a channel by its channel ID.
* @param channelId The channel ID object.
* @return The matching channel or null if does not exist.
*/
public EcalChannel findChannel(ChannelId channelId) {
- return channelMap.get(channelId.encode());
+ return channelMap.get(channelId.encode());
}
-
+
/**
* Find a channel by its encoded geometric ID.
* @param id The encoded geometric ID.
* @return The matching channel or null if does not exist.
*/
public EcalChannel findGeometric(long id) {
- return geometryMap.get(id);
+ return geometryMap.get(id);
}
-
+
/**
* Find a channel by its encoded channel ID.
* @param id The encoded channel ID.
* @return The matching channel or null if does not exist.
*/
public EcalChannel findChannel(long id) {
- return channelMap.get(id);
+ return channelMap.get(id);
}
-
+
/**
* Find a channel by its encoded DAQ ID.
* @param id The encoded DAQ ID.
* @return The matching channel or null if does not exist.
*/
public EcalChannel findDaq(long id) {
- return daqMap.get(id);
+ return daqMap.get(id);
}
}
-
+
/**
* Get the crate number of the channel.
* @return The crate number.
@@ -218,7 +218,7 @@
public int getCrate() {
return getFieldValue("crate");
}
-
+
/**
* Get the slot number of the channel.
* @return The slot number.
@@ -226,7 +226,7 @@
public int getSlot() {
return getFieldValue("slot");
}
-
+
/**
* Get the channel number of the channel.
* @return The channel number.
@@ -234,7 +234,7 @@
public int getChannel() {
return getFieldValue("channel");
}
-
+
/**
* Get the x value of the channel.
* @return The x value.
@@ -242,7 +242,7 @@
public int getX() {
return getFieldValue("x");
}
-
+
/**
* Get the y value of the channel.
* @return The y value.
@@ -258,7 +258,7 @@
public int getChannelId() {
return getFieldValue("channel_id");
}
-
+
/**
* Implementation of equals.
* @return True if objects are equal.
@@ -273,25 +273,15 @@
if (o == this) {
return true;
}
- EcalChannel c = (EcalChannel)o;
- return c.getChannelId() == getChannelId()
- && c.getCrate() == getCrate()
- && c.getSlot() == getSlot()
- && c.getChannel() == getChannel()
- && c.getX() == getX()
- && c.getY() == getY();
+ EcalChannel c = (EcalChannel) o;
+ return c.getChannelId() == getChannelId() && c.getCrate() == getCrate() && c.getSlot() == getSlot() && c.getChannel() == getChannel() && c.getX() == getX() && c.getY() == getY();
}
-
+
/**
* Implementation of string conversion.
* @return The string representation of this channel data.
*/
public String toString() {
- return "id: " + getChannelId()
- + ", crate: " + getCrate()
- + ", slot: " + getSlot()
- + ", channel: " + getChannel()
- + ", x: " + getX()
- + ", y: " + getY();
+ return "id: " + getChannelId() + ", crate: " + getCrate() + ", slot: " + getSlot() + ", channel: " + getChannel() + ", x: " + getX() + ", y: " + getY();
}
}
\ No newline at end of file
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalChannelConstants.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -5,18 +5,18 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalChannelConstants {
-
+
EcalGain gain = null;
EcalCalibration calibration = null;
EcalTimeShift timeShift = null;
boolean badChannel = false;
-
+
/**
* Class constructor, which is package protected.
*/
- EcalChannelConstants() {
+ EcalChannelConstants() {
}
-
+
/**
* Set the gain.
* @param gain The gain object.
@@ -24,7 +24,7 @@
void setGain(EcalGain gain) {
this.gain = gain;
}
-
+
/**
* Set the calibration.
* @param calibration The calibration object.
@@ -32,7 +32,7 @@
void setCalibration(EcalCalibration calibration) {
this.calibration = calibration;
}
-
+
/**
* Set the time shift.
* @param timeShift the time shift
@@ -40,7 +40,7 @@
void setTimeShift(EcalTimeShift timeShift) {
this.timeShift = timeShift;
}
-
+
/**
* Set whether this is a bad channel.
* @param badChannel set to true to flag channel as bad
@@ -48,7 +48,7 @@
void setBadChannel(boolean badChannel) {
this.badChannel = badChannel;
}
-
+
/**
* Get the gain.
* @return The gain.
@@ -56,7 +56,7 @@
public EcalGain getGain() {
return gain;
}
-
+
/**
* Get the calibration.
* @return The calibration.
@@ -64,7 +64,7 @@
public EcalCalibration getCalibration() {
return calibration;
}
-
+
/**
* Get the time shift.
* @return the time shift
@@ -72,7 +72,7 @@
public EcalTimeShift getTimeShift() {
return timeShift;
}
-
+
/**
* Get whether this channel is bad or not.
* @return True if channel is bad; false if not.
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditions.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -6,30 +6,29 @@
import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
/**
- * This class provides access to all ECAL conditions from the database,
- * including gain, pedestal and bad channel settings, per crystal.
+ * This class provides access to all ECAL conditions from the database, including gain,
+ * pedestal and bad channel settings, per crystal.
*
- * Unlike most conditions data types, it does not extend
- * {@link org.hps.conditions.ConditionsObject}, because it is a composite
- * object containing data assembled from many other
- * {@link org.hps.conditions.ConditionsObjects}.
+ * Unlike most conditions data types, it does not extend
+ * {@link org.hps.conditions.ConditionsObject}, because it is a composite object
+ * containing data assembled from many other {@link org.hps.conditions.ConditionsObjects}.
*
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalConditions {
-
+
/** Channel map. */
EcalChannelCollection channelMap = new EcalChannelCollection();
-
+
/** Map between channels and conditions data. */
- Map<EcalChannel,EcalChannelConstants> channelData = new HashMap<EcalChannel,EcalChannelConstants>();
-
+ Map<EcalChannel, EcalChannelConstants> channelData = new HashMap<EcalChannel, EcalChannelConstants>();
+
/**
* Class constructor, which is package protected.
*/
- EcalConditions() {
+ EcalConditions() {
}
-
+
/**
* Set the channel map.
* @param channels The channel map.
@@ -37,7 +36,7 @@
void setChannelCollection(EcalChannelCollection channelMap) {
this.channelMap = channelMap;
}
-
+
/**
* Get the map between database IDs and <code>EcalChannel</code> objects.
* @return The channel map.
@@ -45,11 +44,11 @@
public EcalChannelCollection getChannelCollection() {
return channelMap;
}
-
+
/**
- * 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.
+ * 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 ECAL channel.
* @return The conditions constants for the channel.
* @throws IllegalArgumentException if channel does not exist in the channel map.
@@ -65,32 +64,32 @@
if (!channelData.containsKey(channel))
channelData.put(channel, new EcalChannelConstants());
return channelData.get(channel);
- }
-
+ }
+
/**
* Convert this object to a string.
* @return A string representation of this object.
*/
public String toString() {
StringBuffer buff = new StringBuffer();
-
+
buff.append('\n');
buff.append("Printing ECAL conditions ...");
buff.append('\n');
buff.append('\n');
-
+
// Table header:
buff.append("id");
buff.append(" ");
buff.append("crate");
buff.append(" ");
- buff.append("slot");
+ buff.append("slot");
buff.append(" ");
- buff.append("channel");
+ buff.append("channel");
buff.append(" ");
buff.append("x");
buff.append(" ");
- buff.append("y");
+ buff.append("y");
buff.append(" ");
buff.append("gain");
buff.append(" ");
@@ -102,35 +101,33 @@
buff.append(" ");
buff.append("bad");
buff.append('\n');
- for (int i=0; i<91; i++) {
+ for (int i = 0; i < 91; i++) {
buff.append("-");
- }
+ }
buff.append('\n');
-
+
// Loop over all channels.
for (EcalChannel channel : channelMap.getObjects()) {
-
+
EcalChannelConstants constants = getChannelConstants(channel);
-
+
double gain = constants.getGain().getGain();
double pedestal = constants.getCalibration().getPedestal();
double noise = constants.getCalibration().getNoise();
double timeShift = constants.getTimeShift().getTimeShift();
- boolean bad = constants.isBadChannel();
-
+ boolean bad = constants.isBadChannel();
+
// Channel data.
- buff.append(String.format("%-5d %-6d %-6d %-8d %-6d %-6d",
- channel.getChannelId(), channel.getCrate(), channel.getSlot(), channel.getChannel(),
- channel.getX(), channel.getY()));
-
+ buff.append(String.format("%-5d %-6d %-6d %-8d %-6d %-6d", channel.getChannelId(), channel.getCrate(), channel.getSlot(), channel.getChannel(), channel.getX(), channel.getY()));
+
// Constants.
buff.append(String.format("%-10.4f %-10.4f %-10.4f %-11.4f", gain, pedestal, noise, timeShift));
-
+
// Bad channel.
buff.append(bad);
-
+
buff.append('\n');
}
return buff.toString();
- }
+ }
}
\ No newline at end of file
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsConverter.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -16,63 +16,60 @@
import org.lcsim.conditions.ConditionsManager;
/**
- * This class loads all ecal conditions into an {@link EcalConditions} object
- * from the database, based on the current run number known by the conditions manager.
+ * This class loads all ecal conditions into an {@link EcalConditions} object from the
+ * database, based on the current run number known by the conditions manager.
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalConditionsConverter implements ConditionsConverter<EcalConditions> {
-
+
/**
* Create ECAL conditions object containing all data for the current run.
*/
public EcalConditions getData(ConditionsManager manager, String name) {
-
+
// Create new, empty conditions object to fill with data.
EcalConditions conditions = new EcalConditions();
-
- // Get the channel information from the database.
+
+ // Get the channel information from the database.
EcalChannelCollection channels = manager.getCachedConditions(EcalChannelCollection.class, ECAL_CHANNELS).getCachedData();
-
+
// Set the channel map.
conditions.setChannelCollection(channels);
-
+
System.out.println("channel collection size = " + channels.getObjects().size());
-
+
// Add gains.
- EcalGainCollection gains = manager.getCachedConditions(EcalGainCollection.class, ECAL_GAINS).getCachedData();
+ EcalGainCollection gains = manager.getCachedConditions(EcalGainCollection.class, ECAL_GAINS).getCachedData();
for (EcalGain gain : gains.getObjects()) {
ChannelId channelId = new ChannelId(new int[] {gain.getChannelId()});
EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setGain(gain);
}
-
+
// Add bad channels.
- EcalBadChannelCollection badChannels = manager.getCachedConditions(
- EcalBadChannelCollection.class, ECAL_BAD_CHANNELS).getCachedData();
+ EcalBadChannelCollection badChannels = manager.getCachedConditions(EcalBadChannelCollection.class, ECAL_BAD_CHANNELS).getCachedData();
for (EcalBadChannel badChannel : badChannels.getObjects()) {
ChannelId channelId = new ChannelId(new int[] {badChannel.getChannelId()});
EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setBadChannel(true);
}
-
+
// Add calibrations including pedestal and noise values.
- EcalCalibrationCollection calibrations =
- manager.getCachedConditions(EcalCalibrationCollection.class, ECAL_CALIBRATIONS).getCachedData();
+ EcalCalibrationCollection calibrations = manager.getCachedConditions(EcalCalibrationCollection.class, ECAL_CALIBRATIONS).getCachedData();
for (EcalCalibration calibration : calibrations.getObjects()) {
ChannelId channelId = new ChannelId(new int[] {calibration.getChannelId()});
EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setCalibration(calibration);
- }
-
+ }
+
// Add time shifts.
- EcalTimeShiftCollection timeShifts =
- manager.getCachedConditions(EcalTimeShiftCollection.class, ECAL_TIME_SHIFTS).getCachedData();
+ EcalTimeShiftCollection timeShifts = manager.getCachedConditions(EcalTimeShiftCollection.class, ECAL_TIME_SHIFTS).getCachedData();
for (EcalTimeShift timeShift : timeShifts.getObjects()) {
ChannelId channelId = new ChannelId(new int[] {timeShift.getChannelId()});
EcalChannel channel = channels.findChannel(channelId);
conditions.getChannelConstants(channel).setTimeShift(timeShift);
}
-
+
// Return the conditions object to caller.
return conditions;
}
@@ -84,6 +81,5 @@
public Class<EcalConditions> getType() {
return EcalConditions.class;
}
-
-
+
}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsLoader.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -13,72 +13,73 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalConditionsLoader {
-
+
/**
* Load ECal conditions data onto a full detector object.
* @param detector The detector object.
* @param conditions The conditions object.
*/
public void load(Subdetector subdetector, EcalConditions conditions) {
-
- // Find EcalCrystal objects.
+
+ // Find EcalCrystal objects.
List<EcalCrystal> crystals = subdetector.getDetectorElement().findDescendants(EcalCrystal.class);
-
+
// Get the ID helper.
IIdentifierHelper helper = subdetector.getDetectorElement().getIdentifierHelper();
-
+
// Get the system ID.
int system = subdetector.getSystemID();
-
+
// Get the full channel map created by the conditions system.
EcalChannelCollection channelMap = conditions.getChannelCollection();
-
+
// Build the map of geometry IDs.
channelMap.buildGeometryMap(helper, system);
-
+
// Loop over crystals.
for (EcalCrystal crystal : crystals) {
-
- //System.out.println(crystal.getName() + " @ " + crystal.getX() + ", " + crystal.getY());
-
+
+ // System.out.println(crystal.getName() + " @ " + crystal.getX() + ", " +
+ // crystal.getY());
+
// Reset in case of existing conditions data.
crystal.resetConditions();
-
+
// Find the corresponding entry in the channel map for this crystal.
- int[] geomValues = new int[] {system, crystal.getX(), crystal.getY()};
+ int[] geomValues = new int[] { system, crystal.getX(), crystal.getY() };
GeometryId geometryId = new GeometryId(helper, geomValues);
EcalChannel channel = channelMap.findChannel(geometryId);
if (channel == null) {
throw new RuntimeException("EcalChannel not found for crystal: " + crystal.getName());
}
-
+
// Set the crate.
crystal.setCrate(channel.getCrate());
-
+
// Set the slot.
crystal.setSlot(channel.getSlot());
-
+
// Set the channel number.
crystal.setChannel(channel.getChannel());
-
+
// Get the channel constants.
EcalChannelConstants constants = conditions.getChannelConstants(channel);
if (constants == null) {
throw new RuntimeException("EcalChannelConstants object not found for crystal: " + crystal.getName());
}
-
+
// Set bad channel.
crystal.setBadChannel(constants.isBadChannel());
-
+
// Set pedestal.
crystal.setPedestal(constants.getCalibration().getPedestal());
-
+
// Set noise.
crystal.setNoise(constants.getCalibration().getNoise());
-
+
// Set gain.
crystal.setGain(constants.getGain().getGain());
-
+
// Set time shift.
crystal.setTimeShift(constants.getTimeShift().getTimeShift());
}
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -8,15 +8,14 @@
import org.lcsim.detector.identifier.Identifier;
/**
- * This is a set of utility methods for the ECAL that use the database
- * conditions system.
+ * This is a set of utility methods for the ECAL that use the database conditions system.
*
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalConditionsUtil {
-
+
private EcalConditions conditions;
-
+
/**
* Constructor which uses external reference to conditions object.
* @param conditions The ECAL conditions object.
@@ -24,16 +23,15 @@
public EcalConditionsUtil(EcalConditions conditions) {
this.conditions = conditions;
}
-
+
/**
- * Constructor which will find the ECAL conditions from the static conditions
- * manager instance.
+ * Constructor which will find the ECAL conditions from the static conditions manager
+ * instance.
*/
public EcalConditionsUtil() {
- conditions = DatabaseConditionsManager.getInstance()
- .getConditionsData(EcalConditions.class, TableConstants.ECAL_CONDITIONS);
+ conditions = DatabaseConditionsManager.getInstance().getConditionsData(EcalConditions.class, TableConstants.ECAL_CONDITIONS);
}
-
+
/**
* Find a channel object from a cell ID, e.g. from Monte Carlo data.
* @param helper The identifier helper of the hit.
@@ -41,7 +39,7 @@
* @return The corresponding ECAL channel found from the physical ID information.
*/
EcalChannel findChannel(IIdentifierHelper helper, long cellId) {
-
+
// Make an ID object from hit ID.
IIdentifier id = new Identifier(cellId);
@@ -51,12 +49,12 @@
int y = helper.getValue(id, "iy");
// Create an ID to search for in channel collection.
- GeometryId geometryId = new GeometryId(helper, new int[] {system, x, y});
+ GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
// Find the ECAL channel and return the crate number.
return conditions.getChannelCollection().findChannel(geometryId);
}
-
+
/**
* Get the DAQ crate number from a cell ID.
* @param helper The identifier helper of the hit.
@@ -64,9 +62,9 @@
* @return The crate number of the channel.
*/
int getCrate(IIdentifierHelper helper, long cellId) {
- return findChannel(helper, cellId).getCrate();
+ return findChannel(helper, cellId).getCrate();
}
-
+
/**
* Get the DAQ slot number from a cell ID.
* @param helper The identifier helper of the hit.
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConverterRegistry.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalConverterRegistry.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -12,35 +12,35 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalConverterRegistry {
-
- public static final class EcalBadChannelConverter extends ConditionsObjectConverter<EcalBadChannelCollection> {
+
+ public static final class EcalBadChannelConverter extends ConditionsObjectConverter<EcalBadChannelCollection> {
public Class getType() {
return EcalBadChannelCollection.class;
- }
+ }
public boolean allowMultipleCollections() {
return true;
- }
+ }
}
-
- public static final class EcalCalibrationConverter extends ConditionsObjectConverter<EcalCalibrationCollection> {
+
+ public static final class EcalCalibrationConverter extends ConditionsObjectConverter<EcalCalibrationCollection> {
public Class getType() {
return EcalCalibrationCollection.class;
}
}
-
- public static final class EcalChannelConverter extends ConditionsObjectConverter<EcalChannelCollection> {
+
+ public static final class EcalChannelConverter extends ConditionsObjectConverter<EcalChannelCollection> {
public Class getType() {
return EcalChannelCollection.class;
- }
+ }
}
-
- public static final class EcalGainConverter extends ConditionsObjectConverter<EcalGainCollection> {
+
+ public static final class EcalGainConverter extends ConditionsObjectConverter<EcalGainCollection> {
public Class getType() {
return EcalGainCollection.class;
}
}
-
+
public static final class EcalTimeShiftConverter extends ConditionsObjectConverter<EcalTimeShift> {
public Class getType() {
return EcalTimeShiftCollection.class;
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalGain.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalGain.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -9,18 +9,18 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalGain extends AbstractConditionsObject {
-
+
public static class EcalGainCollection extends ConditionsObjectCollection<EcalGain> {
}
-
+
/**
* Get the gain value in units of MeV/ADC count.
* @return The gain value.
*/
public double getGain() {
return getFieldValue("gain");
- }
-
+ }
+
/**
* Get the ECal channel ID.
* @return The ECal channel ID.
java/trunk/conditions/src/main/java/org/hps/conditions/ecal
--- java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalTimeShift.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/ecal/EcalTimeShift.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -8,13 +8,13 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class EcalTimeShift extends AbstractConditionsObject {
-
+
/**
* A collection of {@link EcalTimeShift} objects.
*/
public static class EcalTimeShiftCollection extends ConditionsObjectCollection<EcalTimeShift> {
}
-
+
/**
* Get the channel ID.
* @return The ECAL channel ID.
@@ -22,7 +22,7 @@
public int getChannelId() {
return getFieldValue("ecal_channel_id");
}
-
+
/**
* Get the time shift in nanoseconds.
* @return The time shift in nanoseconds.
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/ChannelConstants.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/ChannelConstants.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -18,7 +18,7 @@
* Class constructor.
*/
ChannelConstants() {
- }
+ }
/**
* Set the pulse parameters.
@@ -27,7 +27,7 @@
void setPulseParameters(SvtPulseParameters pulseParameters) {
this.pulseParameters = pulseParameters;
}
-
+
/**
* Set the gain.
* @param gain The gain object.
@@ -35,15 +35,15 @@
void setGain(SvtGain gain) {
this.gain = gain;
}
-
+
/**
* Set the calibration.
* @param calibration The calibration object.
*/
void setCalibration(SvtCalibration calibration) {
this.calibration = calibration;
- }
-
+ }
+
/**
* Set the bad channel flag.
* @param badChannel The bad channel flag value.
@@ -51,7 +51,7 @@
void setBadChannel(boolean badChannel) {
this.badChannel = badChannel;
}
-
+
/**
* Check if this is a bad channel.
* @return True if channel is bad; false if not.
@@ -59,7 +59,7 @@
public boolean isBadChannel() {
return badChannel;
}
-
+
/**
* Get the pulse parameters.
* @return The pulse parameters.
@@ -67,7 +67,7 @@
public SvtPulseParameters getPulseParameters() {
return pulseParameters;
}
-
+
/**
* Get the gain.
* @return The gain.
@@ -75,7 +75,7 @@
public SvtGain getGain() {
return gain;
}
-
+
/**
* Get the calibration.
* @return The calibration.
@@ -89,7 +89,7 @@
* @return This object converted to a string.
*/
public String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = new StringBuffer();
buffer.append(getCalibration());
buffer.append(", ");
buffer.append(getGain());
@@ -98,4 +98,3 @@
return buffer.toString();
}
}
-
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -4,10 +4,10 @@
import org.hps.conditions.ConditionsObjectCollection;
public final class SvtBadChannel extends AbstractConditionsObject {
-
- public static class SvtBadChannelCollection extends ConditionsObjectCollection<SvtBadChannel> {
+
+ public static class SvtBadChannelCollection extends ConditionsObjectCollection<SvtBadChannel> {
}
-
+
public int getChannelId() {
return getFieldValue("svt_channel_id");
}
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -11,7 +11,7 @@
public static class SvtCalibrationCollection extends ConditionsObjectCollection<SvtCalibration> {
}
-
+
/**
* Get the channel ID.
* @return The channel ID.
@@ -19,7 +19,7 @@
public int getChannelId() {
return getFieldValue(Integer.class, "svt_channel_id");
}
-
+
/**
* Get the noise value.
* @return The noise value.
@@ -27,7 +27,7 @@
public double getNoise() {
return getFieldValue(Double.class, "noise");
}
-
+
/**
* Get the pedestal value.
* @return The pedestal value.
@@ -35,7 +35,7 @@
public double getPedestal() {
return getFieldValue(Double.class, "pedestal");
}
-
+
/**
* Convert this object to a human readable string.
* @return This object converted to a string.
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtChannel.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -12,22 +12,23 @@
import org.hps.util.Pair;
/**
- * This class represents SVT channel setup information, including hybrid, FPGA, and channel numbers.
+ * This class represents SVT channel setup information, including hybrid, FPGA, and
+ * channel numbers.
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class SvtChannel extends AbstractConditionsObject {
-
+
public static class SvtChannelCollection extends ConditionsObjectCollection<SvtChannel> {
-
+
Map<Integer, SvtChannel> channelMap = new HashMap<Integer, SvtChannel>();
-
+
public void add(SvtChannel channel) {
// Add to map.
if (channelMap.containsKey(channel.getChannelId())) {
throw new IllegalArgumentException("Channel ID already exists: " + channel.getChannelId());
}
channelMap.put(channel.getChannelId(), channel);
-
+
// Add to collection.
try {
super.add(channel);
@@ -35,18 +36,18 @@
throw new RuntimeException(e);
}
}
-
+
public SvtChannel findChannel(int channelId) {
return channelMap.get(channelId);
}
-
+
/**
* Find channels that match a DAQ pair (FPGA, hybrid).
* @param pair The DAQ pair.
* @return The channels matching the DAQ pair or null if not found.
*/
- public Collection<SvtChannel> find(Pair<Integer,Integer> pair) {
- List<SvtChannel> channels = new ArrayList<SvtChannel>();
+ public Collection<SvtChannel> find(Pair<Integer, Integer> pair) {
+ List<SvtChannel> channels = new ArrayList<SvtChannel>();
int fpga = pair.getFirstElement();
int hybrid = pair.getSecondElement();
for (SvtChannel channel : this.getObjects()) {
@@ -56,12 +57,12 @@
}
return channels;
}
-
+
/**
* Convert this object to a human readable string.
* @return This object converted to a string.
*/
- public String toString() {
+ public String toString() {
StringBuffer buff = new StringBuffer();
for (SvtChannel channel : this.getObjects()) {
buff.append(channel.toString() + '\n');
@@ -69,7 +70,7 @@
return buff.toString();
}
}
-
+
/**
* Get the channel ID.
* @return The channel ID.
@@ -77,7 +78,7 @@
public int getChannelId() {
return getFieldValue("channel_id");
}
-
+
/**
* Get the hybrid number.
* @return The hybrid number.
@@ -85,7 +86,7 @@
public int getHybrid() {
return getFieldValue("hybrid");
}
-
+
/**
* Get the FPGA number.
* @return The FPGA number.
@@ -93,15 +94,15 @@
public int getFpga() {
return getFieldValue("fpga");
}
-
+
/**
- * Get the channel number. This is different from the ID.
+ * Get the channel number. This is different from the ID.
* @return The channel number.
*/
public int getChannel() {
return getFieldValue("channel");
- }
-
+ }
+
/**
* Convert this object to a human readable string.
* @return This object as a string.
@@ -109,7 +110,7 @@
public String toString() {
return "channel_id: " + getChannelId() + ", fpga: " + getFpga() + ", hybrid: " + getHybrid() + ", channel: " + getChannel();
}
-
+
/**
* Implementation of equals.
* @return True if the object equals this one; false if not.
@@ -121,10 +122,7 @@
return false;
if (o == this)
return true;
- SvtChannel channel = (SvtChannel)o;
- return getChannelId() == channel.getChannelId()
- && getHybrid() == channel.getHybrid()
- && getFpga() == channel.getFpga()
- && getHybrid() == channel.getHybrid();
- }
+ SvtChannel channel = (SvtChannel) o;
+ return getChannelId() == channel.getChannelId() && getHybrid() == channel.getHybrid() && getFpga() == channel.getFpga() && getHybrid() == channel.getHybrid();
+ }
}
\ No newline at end of file
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditions.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -8,33 +8,33 @@
import org.hps.conditions.svt.SvtTimeShift.SvtTimeShiftCollection;
/**
- * This class contains all SVT conditions data by readout channel.
- * {@link SvtChannel} objects from the {@linkSvtChannelMap} should be
- * used to lookup the conditions using the {@link #getChannelConstants(SvtChannel)} method.
+ * This class contains all SVT conditions data by readout channel. {@link SvtChannel}
+ * objects from the {@linkSvtChannelMap} should be used to lookup the conditions using the
+ * {@link #getChannelConstants(SvtChannel)} method.
*
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: SvtConditions.java,v 1.11 2013/10/15 23:45:56 jeremy Exp $
*/
public final class SvtConditions {
-
+
/** SVT conditions data. */
private Map<SvtChannel, ChannelConstants> channelData = new HashMap<SvtChannel, ChannelConstants>();
private SvtChannelCollection channelMap = null;
private SvtDaqMappingCollection daqMap = null;
private SvtTimeShiftCollection timeShifts = null;
-
+
/**
* Class constructor, which takes a channel map.
* @param channelMap The SVT channel map.
*/
SvtConditions(SvtChannelCollection channelMap) {
this.channelMap = channelMap;
- }
-
+ }
+
/**
- * 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.
+ * 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.
* @return The conditions constants for the channel.
* @throws IllegalArgumentException if .
@@ -49,8 +49,8 @@
if (!channelData.containsKey(channel))
channelData.put(channel, new ChannelConstants());
return channelData.get(channel);
- }
-
+ }
+
/**
* Get the {@link SvtChannelCollection} for this set of conditions.
* @return The SVT channel map.
@@ -58,7 +58,7 @@
public SvtChannelCollection getChannelMap() {
return channelMap;
}
-
+
/**
* Get the {@link SvtDaqMappingCollection} associated with these conditions.
* @return The SVT DAQ map.
@@ -66,7 +66,7 @@
public SvtDaqMappingCollection getDaqMap() {
return daqMap;
}
-
+
/**
* Get the {@link SvtTimeShiftCollection}.
* @return The time shifts by sensor.
@@ -74,7 +74,7 @@
public SvtTimeShiftCollection getTimeShifts() {
return timeShifts;
}
-
+
/**
* Set the {@link SvtDaqMappingCollection} associated with these conditions.
* @param daqMap The SVT DAQ map.
@@ -82,7 +82,7 @@
void setDaqMap(SvtDaqMappingCollection daqMap) {
this.daqMap = daqMap;
}
-
+
/**
* Set the sensor time shifts.
* @param timeShifts The sensor time shifts collection.
@@ -90,21 +90,22 @@
void setTimeShifts(SvtTimeShiftCollection timeShifts) {
this.timeShifts = timeShifts;
}
-
+
/**
- * Convert this object to a human readable string. This method prints a formatted table
- * of channel data independently of how its member objects implement their string conversion method.
- * For now, it does not print the time shifts by sensor as all other information is by channel.
+ * Convert this object to a human readable string. This method prints a formatted
+ * table of channel data independently of how its member objects implement their
+ * string conversion method. For now, it does not print the time shifts by sensor as
+ * all other information is by channel.
* @return This object converted to a string, without the DAQ map.
*/
public String toString() {
StringBuffer buff = new StringBuffer();
-
+
buff.append('\n');
buff.append("Printing SVTConditions ...");
buff.append('\n');
buff.append('\n');
-
+
// Table header:
buff.append("id");
buff.append(" ");
@@ -131,45 +132,44 @@
buff.append("chisq");
buff.append(" ");
buff.append("bad");
- buff.append('\n');
- for (int i=0; i<115; i++) {
+ buff.append('\n');
+ for (int i = 0; i < 115; i++) {
buff.append("-");
- }
+ }
buff.append('\n');
// Loop over channels.
for (SvtChannel channel : channelMap.getObjects()) {
-
+
// Get the conditions for the channel.
ChannelConstants constants = getChannelConstants(channel);
SvtGain gain = constants.getGain();
SvtPulseParameters pulse = constants.getPulseParameters();
SvtCalibration calibration = constants.getCalibration();
-
+
// Channel data.
buff.append(String.format("%-6d %-5d %-8d %-8d ", channel.getChannelId(), channel.getFpga(), channel.getHybrid(), channel.getChannel()));
// Calibration.
buff.append(String.format("%-9.4f %-11.4f ", calibration.getNoise(), calibration.getPedestal()));
-
+
// Gain.
buff.append(String.format("%-6.4f %-9.4f ", gain.getGain(), gain.getOffset()));
-
+
// Pulse shape.
buff.append(String.format("%-10.4f %-8.4f %-8.4f %-10.4f ", pulse.getAmplitude(), pulse.getT0(), pulse.getTimeShift(), pulse.getChisq()));
-
+
// Bad channel.
buff.append(constants.isBadChannel());
-
- buff.append('\n');
+
+ buff.append('\n');
}
-
+
buff.append('\n');
buff.append("Printing SVT DAQ Map...");
buff.append('\n');
buff.append('\n');
buff.append(getDaqMap());
-
+
return buff.toString();
}
}
-
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -19,62 +19,62 @@
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.
+ * This class creates an {@link SvtConditions} object from the database, based on the
+ * current run number known by the conditions manager.
*/
public final class SvtConditionsConverter implements ConditionsConverter<SvtConditions> {
-
+
/**
- * Create and return the SVT conditions object.
+ * Create and return the SVT conditions object.
* @param manager The current conditions manager.
* @param name The conditions key, which is ignored for now.
*/
public SvtConditions getData(ConditionsManager manager, String name) {
-
+
// Get the SVT channel map.
SvtChannelCollection channels = manager.getCachedConditions(SvtChannelCollection.class, SVT_CHANNELS).getCachedData();
-
+
// Create the conditions object.
SvtConditions conditions = new SvtConditions(channels);
-
+
// Create the DAQ map.
SvtDaqMappingCollection daqMap = manager.getCachedConditions(SvtDaqMappingCollection.class, SVT_DAQ_MAP).getCachedData();
conditions.setDaqMap(daqMap);
-
+
// Add calibrations by channel.
SvtCalibrationCollection calibrations = manager.getCachedConditions(SvtCalibrationCollection.class, SVT_CALIBRATIONS).getCachedData();
for (SvtCalibration calibration : calibrations.getObjects()) {
SvtChannel channel = conditions.getChannelMap().findChannel(calibration.getChannelId());
conditions.getChannelConstants(channel).setCalibration(calibration);
}
-
+
// Add pulse parameters by channel.
SvtPulseParametersCollection pulseParametersCollection = manager.getCachedConditions(SvtPulseParametersCollection.class, SVT_PULSE_PARAMETERS).getCachedData();
for (SvtPulseParameters pulseParameters : pulseParametersCollection.getObjects()) {
SvtChannel channel = conditions.getChannelMap().findChannel(pulseParameters.getChannelId());
conditions.getChannelConstants(channel).setPulseParameters(pulseParameters);
}
-
+
// Add bad channels.
- SvtBadChannelCollection badChannels = manager.getCachedConditions(SvtBadChannelCollection.class, SVT_BAD_CHANNELS).getCachedData();
+ SvtBadChannelCollection badChannels = manager.getCachedConditions(SvtBadChannelCollection.class, SVT_BAD_CHANNELS).getCachedData();
for (SvtBadChannel badChannel : badChannels.getObjects()) {
SvtChannel channel = conditions.getChannelMap().findChannel(badChannel.getChannelId());
conditions.getChannelConstants(channel).setBadChannel(true);
}
-
+
// Add gains by channel.
SvtGainCollection gains = manager.getCachedConditions(SvtGainCollection.class, SVT_GAINS).getCachedData();
for (SvtGain object : gains.getObjects()) {
int channelId = object.getChannelID();
- SvtChannel channel = conditions.getChannelMap().findChannel(channelId);
+ SvtChannel channel = conditions.getChannelMap().findChannel(channelId);
conditions.getChannelConstants(channel).setGain(object);
}
-
+
// Set the time shifts by sensor.
SvtTimeShiftCollection timeShifts = manager.getCachedConditions(SvtTimeShiftCollection.class, SVT_TIME_SHIFTS).getCachedData();
conditions.setTimeShifts(timeShifts);
-
- return conditions;
+
+ return conditions;
}
/**
@@ -83,5 +83,5 @@
*/
public Class<SvtConditions> getType() {
return SvtConditions.class;
- }
+ }
}
\ No newline at end of file
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsLoader.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -15,57 +15,57 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class SvtConditionsLoader {
-
+
/**
- * Load conditions data onto a detector object.
- * This method is analogous to {@link org.lcsim.hps.recon.tracking.SvtUtils#setup(Detector)}.
+ * Load conditions data onto a detector object. This method is analogous to
+ * {@link org.lcsim.hps.recon.tracking.SvtUtils#setup(Detector)}.
* @param detector The detector object.
* @param conditions The conditions object.
*/
- // FIXME: Change this to use a Subdetector instead of the Detector.
+ // FIXME: Change this to use a Subdetector instead of the Detector.
public void load(Detector detector, SvtConditions conditions) {
-
- // Find sensor objects.
+
+ // Find sensor objects.
List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class);
SvtChannelCollection channelMap = conditions.getChannelMap();
SvtDaqMappingCollection daqMap = conditions.getDaqMap();
SvtTimeShiftCollection timeShifts = conditions.getTimeShifts();
-
+
// Loop over sensors.
for (HpsSiSensor sensor : sensors) {
-
+
// Reset possible existing conditions data on sensor.
sensor.reset();
-
+
// Get the layer number.
int layerNumber = sensor.getLayerNumber();
-
- // Get info from the DAQ map about this sensor.
- Pair<Integer, Integer> daqPair = null;
+
+ // Get info from the DAQ map about this sensor.
+ Pair<Integer, Integer> daqPair = null;
int half = SvtDaqMappingCollection.TOP_HALF;
if (sensor.isBottomLayer()) {
half = SvtDaqMappingCollection.BOTTOM_HALF;
- }
+ }
daqPair = daqMap.get(half, layerNumber);
if (daqPair == null) {
throw new RuntimeException("Failed to find DAQ pair for sensor: " + sensor.getName());
}
-
+
// Set FPGA value from DAQ map.
sensor.setFpgaNumber(daqPair.getFirstElement());
-
+
// Set hybrid value from DAQ map.
sensor.setHybridNumber(daqPair.getSecondElement());
-
+
// Find all the channels for this sensor.
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();
-
+
//
// Set conditions data for this channel on the sensor object:
//
@@ -78,7 +78,7 @@
sensor.setPedestal(channelNumber, constants.getCalibration().getPedestal());
sensor.setPulseParameters(channelNumber, constants.getPulseParameters().toArray());
}
-
+
// Set the time shift for the sensor.
SvtTimeShift sensorTimeShift = timeShifts.find(daqPair).get(0);
sensor.setTimeShift(sensorTimeShift.getTimeShift());
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConverterRegistry.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtConverterRegistry.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -9,50 +9,49 @@
import org.hps.conditions.svt.SvtPulseParameters.SvtPulseParametersCollection;
import org.hps.conditions.svt.SvtTimeShift.SvtTimeShiftCollection;
-
-@SuppressWarnings({"unchecked", "rawtypes"})
+@SuppressWarnings({ "unchecked", "rawtypes" })
public final class SvtConverterRegistry {
-
- public static class SvtBadChannelConverter extends ConditionsObjectConverter<SvtBadChannelCollection> {
+
+ public static class SvtBadChannelConverter extends ConditionsObjectConverter<SvtBadChannelCollection> {
public Class getType() {
return SvtBadChannelCollection.class;
- }
+ }
public boolean allowMultipleCollections() {
return true;
- }
+ }
}
-
+
public static class SvtCalibrationConverter extends ConditionsObjectConverter<SvtCalibrationCollection> {
public Class getType() {
return SvtCalibrationCollection.class;
}
}
-
+
public static class SvtChannelConverter extends ConditionsObjectConverter<SvtChannelCollection> {
public Class getType() {
return SvtChannelCollection.class;
}
}
-
+
public static class SvtDaqMappingConverter extends ConditionsObjectConverter<SvtDaqMappingCollection> {
public Class getType() {
return SvtDaqMappingCollection.class;
}
}
-
+
public static class SvtGainConverter extends ConditionsObjectConverter<SvtGainCollection> {
public Class getType() {
return SvtGainCollection.class;
}
}
-
+
public static class SvtPulseParametersConverter extends ConditionsObjectConverter<SvtPulseParametersCollection> {
public Class getType() {
return SvtPulseParametersCollection.class;
}
}
-
+
public static class SvtTimeShiftConverter extends ConditionsObjectConverter<SvtTimeShiftCollection> {
public Class getType() {
return SvtTimeShiftCollection.class;
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtDaqMapping.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -7,20 +7,20 @@
public final class SvtDaqMapping extends AbstractConditionsObject {
public static class SvtDaqMappingCollection extends ConditionsObjectCollection<SvtDaqMapping> {
-
+
/**
* Flag values for top or bottom half.
*/
public static final int TOP_HALF = 0;
public static final int BOTTOM_HALF = 1;
-
+
/**
* Get a DAQ pair (FPGA, hybrid) by top/bottom number and layer number.
* @param half Value indicating top or bottom half of detector.
* @param layerNumber The layer number.
* @return The DAQ pair for the half and layer number or null if does not exist.
*/
- Pair<Integer,Integer> get(int half, int layerNumber) {
+ Pair<Integer, Integer> get(int half, int layerNumber) {
for (SvtDaqMapping object : this.getObjects()) {
if (object.getHalf() == half && object.getLayerNumber() == layerNumber) {
return new Pair<Integer, Integer>(object.getFpgaNumber(), object.getHybridNumber());
@@ -28,7 +28,7 @@
}
return null;
}
-
+
/**
* Convert this object to a string.
* @return This object converted to a string.
@@ -49,29 +49,29 @@
buff.append(object.getHalf());
buff.append(" ");
buff.append(String.format("%-2d", object.getLayerNumber()));
- buff.append(" ");
+ buff.append(" ");
buff.append(object.getFpgaNumber());
buff.append(" ");
buff.append(object.getHybridNumber());
buff.append('\n');
- }
+ }
return buff.toString();
- }
+ }
}
-
+
public int getHalf() {
return getFieldValue("half");
}
-
+
public int getLayerNumber() {
return getFieldValue("layer");
}
-
+
public int getFpgaNumber() {
return getFieldValue("fpga");
}
-
+
public int getHybridNumber() {
return getFieldValue("hybrid");
- }
+ }
}
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -8,10 +8,10 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class SvtGain extends AbstractConditionsObject {
-
+
public static class SvtGainCollection extends ConditionsObjectCollection<SvtGain> {
}
-
+
/**
* Get the channel ID.
* @return The channel ID.
@@ -19,7 +19,7 @@
int getChannelID() {
return getFieldValue(Integer.class, "svt_channel_id");
}
-
+
/**
* Get the gain.
* @return The gain value.
@@ -27,7 +27,7 @@
double getGain() {
return getFieldValue(Double.class, "gain");
}
-
+
/**
* Get the offset.
* @return The offset value.
@@ -35,13 +35,12 @@
double getOffset() {
return getFieldValue(Double.class, "offset");
}
-
-
+
/**
* Convert this object to a human-readable string.
* @return This object converted to a string.
*/
public String toString() {
return "" + getGain() + '\t' + getOffset();
- }
+ }
}
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtPulseParameters.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtPulseParameters.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -8,10 +8,10 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class SvtPulseParameters extends AbstractConditionsObject {
-
- public static class SvtPulseParametersCollection extends ConditionsObjectCollection<SvtPulseParameters> {
+
+ public static class SvtPulseParametersCollection extends ConditionsObjectCollection<SvtPulseParameters> {
}
-
+
/**
* Get the SVT channel ID.
* @return The SVT channel ID.
@@ -19,39 +19,39 @@
int getChannelId() {
return getFieldValue(Integer.class, "svt_channel_id");
}
-
+
/**
* Get the amplitude.
* @return The amplifude.
*/
double getAmplitude() {
- return getFieldValue(Double.class, "amplitude");
+ return getFieldValue(Double.class, "amplitude");
}
-
+
/**
* Get the starting time.
* @return The starting time.
*/
double getT0() {
- return getFieldValue(Double.class, "t0");
+ return getFieldValue(Double.class, "t0");
}
-
+
/**
* Get the time shift.
* @return The time shift.
*/
double getTimeShift() {
- return getFieldValue(Double.class, "tp");
+ return getFieldValue(Double.class, "tp");
}
-
+
/**
* Get the chisq.
* @return The chisq.
*/
double getChisq() {
- return getFieldValue(Double.class, "chisq");
+ return getFieldValue(Double.class, "chisq");
}
-
+
/**
* Convert this object to a human readable string.
* @return This object converted to a string.
@@ -59,7 +59,7 @@
public String toString() {
return "amp: " + getAmplitude() + ", t0: " + getT0() + ", shift: " + getTimeShift() + ", chisq: " + getChisq();
}
-
+
/**
* Convert this object to an array of doubles.
* @return This object converted to an array of doubles.
java/trunk/conditions/src/main/java/org/hps/conditions/svt
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtTimeShift.java 2014-04-25 20:22:15 UTC (rev 517)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtTimeShift.java 2014-04-25 20:30:32 UTC (rev 518)
@@ -6,15 +6,15 @@
import org.hps.util.Pair;
/**
- * This class is a data holder for associating a time shift with a specific sensor
- * by FPGA and hybrid numbers.
+ * This class is a data holder for associating a time shift with a specific sensor by FPGA
+ * and hybrid numbers.
* @author Jeremy McCormick <[log in to unmask]>
*/
public final class SvtTimeShift extends AbstractConditionsObject {
-
+
public static class SvtTimeShiftCollection extends ConditionsObjectCollection<SvtTimeShift> {
-
- SvtTimeShiftCollection find(Pair<Integer,Integer> pair) {
+
+ SvtTimeShiftCollection find(Pair<Integer, Integer> pair) {
SvtTimeShiftCollection timeShifts = new SvtTimeShiftCollection();
int fpga = pair.getFirstElement();
int hybrid = pair.getSecondElement();
@@ -30,7 +30,7 @@
return timeShifts;
}
}
-
+
/**
* Get the FPGA number.
* @return The FPGA number.
@@ -38,7 +38,7 @@
int getFpga() {
return getFieldValue("fpga");
}
-
+
/**
* Get the hybrid number.
* @return The hybrid number.
@@ -46,7 +46,7 @@
int getHybrid() {
return getFieldValue("hybrid");
}
-
+
/**
* Get the time shift.
* @return The time shift.
SVNspam 0.1