LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  July 2015

HPS-SVN July 2015

Subject:

r3304 - in /java/trunk/record-util/src/main/java/org/hps/record/scalers: ScalerParameters.java ScalerParametersIndex.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Thu, 30 Jul 2015 00:54:08 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (170 lines)

Author: [log in to unmask]
Date: Wed Jul 29 17:54:07 2015
New Revision: 3304

Log:
Add class for reading selected scaler data from event parameters.  HPSJAVA-562

Added:
    java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParameters.java
    java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParametersIndex.java

Added: java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParameters.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParameters.java	(added)
+++ java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParameters.java	Wed Jul 29 17:54:07 2015
@@ -0,0 +1,133 @@
+package org.hps.record.scalers;
+
+import org.hps.record.epics.EpicsData;
+import org.lcsim.event.EventHeader;
+
+/**
+ * Representation of scaler values from the float parameters in an lcsim event header.
+ *
+ * @author Jeremy McCormick, SLAC
+ */
+public final class ScalerParameters {
+
+    /**
+     * Name of the float parameters in the map.
+     */
+    public static final String NAME = "SCALER_PARAMETERS";
+
+    /**
+     * Conversion from scaler FCUP threshold values to nano Coulomb.
+     */
+    private static float NANO_COULOMB = 905.937f;
+
+    /**
+     * Size of the data array.
+     */
+    private static int SIZE = 5;
+
+    /**
+     * Read scaler parameters from an lcsim event.
+     *
+     * @param event the lcsim event
+     * @return the scaler parameters
+     */
+    public static ScalerParameters read(final EventHeader event) {
+        if (event.getFloatParameters().get(NAME) == null) {
+            throw new IllegalArgumentException("Event is missing scaler parameters array.");
+        }
+        return new ScalerParameters(event.getFloatParameters().get(NAME));
+    }
+
+    /**
+     * The float parameter values.
+     */
+    private float[] values = new float[SIZE];
+
+    /**
+     * Public class constructor.
+     */
+    public ScalerParameters() {
+    }
+
+    /**
+     * Create parameters from float array.
+     *
+     * @param values the float array
+     */
+    ScalerParameters(final float[] values) {
+        this.values = values;
+    }
+
+    /**
+     * Get a scaler parameter value.
+     *
+     * @param scalerParametersIndex the parameter index
+     * @return the scaler parameter value
+     */
+    public float getValue(final ScalerParametersIndex scalerParametersIndex) {
+        return this.values[scalerParametersIndex.ordinal()];
+    }
+
+    /**
+     * Read scaler information from {@link org.hps.record.epics.EpicsData}.
+     *
+     * @param epicsData the <code>EpicsData</code> object
+     */
+    public void readEpicsData(final EpicsData epicsData) {
+        if (epicsData.hasKey("hallb_IPM2H02_XPOS")) {
+            this.setValue(ScalerParametersIndex.BEAM_POS_X, (float) (double) epicsData.getValue("hallb_IPM2H02_XPOS"));
+        }
+        if (epicsData.hasKey("hallb_IPM2H02_YPOS")) {
+            this.setValue(ScalerParametersIndex.BEAM_POS_Y, (float) (double) epicsData.getValue("hallb_IPM2H02_YPOS"));
+        }
+        if (epicsData.hasKey("SVT:bias:top:0:v_sens")) {
+            this.setValue(ScalerParametersIndex.SVT_BIAS_VOLTAGE,
+                    (float) (double) epicsData.getValue("SVT:bias:top:0:v_sens"));
+        }
+    }
+
+    /**
+     * Read scaler information from a {@link ScalerData} object.
+     *
+     * @param scalerData the <code>ScalerData</code> object
+     */
+    public void readScalerData(final ScalerData scalerData) {
+        this.setValue(ScalerParametersIndex.FCUP_TDC_GATED, scalerData.getValue(ScalerDataIndex.FCUP_TDC_GATED)
+                / NANO_COULOMB);
+        this.setValue(ScalerParametersIndex.FCUP_TDC_UNGATED, scalerData.getValue(ScalerDataIndex.FCUP_TDC_UNGATED)
+                / NANO_COULOMB);
+    }
+
+    /**
+     * Set a parameter value by its index.
+     *
+     * @param scalerParametersIndex the parameter index
+     * @param value the new value
+     */
+    void setValue(final ScalerParametersIndex scalerParametersIndex, final float value) {
+        this.values[scalerParametersIndex.ordinal()] = value;
+    }
+
+    /**
+     * Write out scaler parameters to the event header.
+     *
+     * @param event the lcsim event
+     */
+    public void write(final EventHeader event) {
+        event.getFloatParameters().put(NAME, values);
+    }
+    
+    /**
+     * Convert to string.
+     * 
+     * @return this object converted to a string
+     */
+    public String toString() {
+        StringBuffer buff = new StringBuffer();
+        for (ScalerParametersIndex index : ScalerParametersIndex.values()) {
+            buff.append(index.name() + " " + this.getValue(index));
+            buff.append('\n');
+        }
+        return buff.toString();
+    }
+}

Added: java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParametersIndex.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParametersIndex.java	(added)
+++ java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParametersIndex.java	Wed Jul 29 17:54:07 2015
@@ -0,0 +1,14 @@
+package org.hps.record.scalers;
+
+/**
+ * Indices into the {@link ScalerParameters} from the event header.
+ * 
+ * @author Jeremy McCormick, SLAC
+ */
+public enum ScalerParametersIndex {    
+    FCUP_TDC_GATED,
+    FCUP_TDC_UNGATED,
+    BEAM_POS_X,
+    BEAM_POS_Y,
+    SVT_BIAS_VOLTAGE;     
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use