Print

Print


Author: [log in to unmask]
Date: Tue Mar 24 15:25:04 2015
New Revision: 2528

Log:
Add additional methods to EPICS scalar API including access to item descriptions as listed on Confluence EVIO page.

Modified:
    java/trunk/record-util/src/main/java/org/hps/record/epics/EpicsScalarData.java

Modified: java/trunk/record-util/src/main/java/org/hps/record/epics/EpicsScalarData.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/epics/EpicsScalarData.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/epics/EpicsScalarData.java	Tue Mar 24 15:25:04 2015
@@ -6,6 +6,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.GenericObject;
@@ -13,7 +14,8 @@
 /**
  * This is an API for reading and writing EPICS scalar data to LCIO events,
  * as well as parsing the scalar data from a CDATA section of an EVIO string
- * data bank.
+ * data bank.  The {@link #read(EventHeader)} method should be used to create
+ * one of these objects from an LCIO event.
  * 
  * @author Jeremy McCormick <[log in to unmask]>
 */
@@ -31,6 +33,39 @@
     
     // The map of scalar keys to values.
     private Map<String, Double> dataMap = new LinkedHashMap<String, Double>();
+    
+    // EPICS key descriptions from
+    // https://confluence.slac.stanford.edu/display/hpsg/EVIO+Data+Format           
+    private final static Map<String, String> DESCRIPTIONS = new HashMap<String, String>();
+    static {
+        DESCRIPTIONS.put("MBSY2C_energy",       "Beam energy according to Hall B BSY dipole string");
+        DESCRIPTIONS.put("PSPECIRBCK",          "Pair Spectrometer Current Readback");
+        DESCRIPTIONS.put("HPS:LS450_2:FIELD",   "Frascati probe field");
+        DESCRIPTIONS.put("HPS:LS450_1:FIELD",   "Pair Spectrometer probe field");
+        DESCRIPTIONS.put("MTIRBCK",             "Frascati Current Readback");
+        DESCRIPTIONS.put("VCG2C21 2C21",        "Vacuum gauge pressure");
+        DESCRIPTIONS.put("VCG2C21A",            "2C21A Vacuum gauge pressure");
+        DESCRIPTIONS.put("VCG2C24A",            "2C24A Vacuum gauge pressure");
+        DESCRIPTIONS.put("VCG2H00A",            "2H00 Vacuum gauge pressure");
+        DESCRIPTIONS.put("VCG2H01A",            "2H01 Vacuum gauge pressure");
+        DESCRIPTIONS.put("VCG2H02A",            "2H02 Vacuum gauge pressure");
+        DESCRIPTIONS.put("scaler_calc1",        "Faraday cup current");
+        DESCRIPTIONS.put("scalerS12b",          "HPS-Left beam halo count");
+        DESCRIPTIONS.put("scalerS13b",          "HPS-Right beam halo count");
+        DESCRIPTIONS.put("scalerS14b",          "HPS-Top beam halo count");
+        DESCRIPTIONS.put("scalerS15b",          "HPS-SC beam halo count");
+        DESCRIPTIONS.put("hallb_IPM2C21A_XPOS", "Beam position X at 2C21");
+        DESCRIPTIONS.put("hallb_IPM2C21A_YPOS", "Beam position Y at 2C21");
+        DESCRIPTIONS.put("hallb_IPM2C21A_CUR",  "Current at 2C21");
+        DESCRIPTIONS.put("hallb_IPM2C24A_XPOS", "Beam position X at 2C24");
+        DESCRIPTIONS.put("hallb_IPM2C24A_YPOS", "Beam position Y at 2C24");
+        DESCRIPTIONS.put("hallb_IPM2C24A_CUR",  "Current at 2C24");
+        DESCRIPTIONS.put("hallb_IPM2H00_XPOS",  "Beam position X at 2H00");
+        DESCRIPTIONS.put("hallb_IPM2H00_YPOS",  "Beam position Y at 2H00");
+        DESCRIPTIONS.put("hallb_IPM2H00_CUR",   "Current at 2H00");
+        DESCRIPTIONS.put("hallb_IPM2H02_YPOS",  "Beam position X at 2H02");
+        DESCRIPTIONS.put("hallb_IPM2H02_XPOS",  "Beam position Y at 2H02");
+    };
        
     /**
      * Write this object's data into a GenericObject collection in the LCIO event using 
@@ -62,8 +97,42 @@
      * Get a double value from the key.
      * @return The value from the key.
      */
-    public Double getValue(String key) {
-        return dataMap.get(key);
+    public Double getValue(String name) {
+        return dataMap.get(name);
+    }
+    
+    /**
+     * Get the description of a named EPICS scalar.
+     * @param name The name of the scalar.
+     */
+    public static String getDescription(String name) {
+        return DESCRIPTIONS.get(name);
+    }
+    
+    /**
+     * Get the static list of default, available EPICs scalar names.
+     * <p>
+     * This could be different than the names which were actually 
+     * written into the collection header.  For this, use the method
+     * {@link #getUsedNames()}.
+     * 
+     * @return The list of default EPICS scalar names. 
+     */
+    public static Set<String> getDefaultNames() {
+        return DESCRIPTIONS.keySet();
+    }
+    
+    /**
+     * Get the list of used EPICS scalars in this object.
+     * <p>
+     * This could potentially be different than the list of
+     * default names from {@link #getDefaultNames()} but it
+     * will usually be the same.
+     * 
+     * @return The list of used EPICS scalar names.
+     */
+    public Set<String> getUsedNames() {
+        return dataMap.keySet();
     }
     
     /**
@@ -118,15 +187,15 @@
     }
 
     /**
-     * Given a list of keys, read the double values from the 
+     * Given a list of names, read the double values from the 
      * {@link org.lcsim.event.GenericObject} into the data map
      * of this object.
-     * @param object
-     * @param keys
-     */
-    void fromGenericObject(GenericObject object, String[] keys) {
-        for (int index = 0; index < keys.length; index++) {                      
-            dataMap.put(keys[index], object.getDoubleVal(index)); 
+     * @param object The GenericObject with the scalar values.
+     * @param names The list of names.
+     */
+    void fromGenericObject(GenericObject object, String[] names) {
+        for (int index = 0; index < names.length; index++) {                      
+            dataMap.put(names[index], object.getDoubleVal(index)); 
         }
     }