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  January 2015

HPS-SVN January 2015

Subject:

r1962 - in /java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank: ./ AbstractIntData.java

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 21 Jan 2015 22:36:37 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (136 lines)

Author: [log in to unmask]
Date: Wed Jan 21 14:36:30 2015
New Revision: 1962

Log:
abstract class for EVIO int banks

Added:
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/AbstractIntData.java

Added: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/AbstractIntData.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/AbstractIntData.java	(added)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/AbstractIntData.java	Wed Jan 21 14:36:30 2015
@@ -0,0 +1,119 @@
+package org.hps.readout.ecal.triggerbank;
+
+import java.util.Arrays;
+import org.lcsim.event.GenericObject;
+
+/**
+ * GenericObject representation of a UINT32 bank read from EVIO. The bank header
+ * tag identifies the type of data, and is stored as the first int in the
+ * GenericObject. The contents of the bank are the remaining N-1 ints.
+ * Constructors are provided from int[] (for reading from EVIO) and from
+ * GenericObject (for reading from LCIO).
+ *
+ * Subclasses must implement the two constructors and two abstract methods, plus
+ * whatever methods are needed to access the parsed data.
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: $
+ */
+public abstract class AbstractIntData implements GenericObject {
+
+    protected int[] bank;
+
+    /**
+     * Constructor from EVIO int bank. Bank tag must be checked by EVIO reader
+     * before the constructor is called.
+     *
+     * @param bank
+     */
+    protected AbstractIntData(int[] bank) {
+        this.bank = Arrays.copyOf(bank, bank.length);
+    }
+
+    /**
+     * Constructor from LCIO GenericObject. Checks the bank tag; subclass must
+     * set the expected value of the tag.
+     *
+     * @param data
+     * @param expectedTag
+     */
+    protected AbstractIntData(GenericObject data, int expectedTag) {
+        if (getTag(data) != expectedTag) {
+            throw new RuntimeException("expected tag " + expectedTag + ", got " + getTag(data));
+        }
+        this.bank = getBank(data);
+    }
+
+    public int[] getBank() {
+        return bank;
+    }
+
+    public static int[] getBank(GenericObject object) {
+        int N = object.getNInt() - 1;
+        int[] bank = new int[N];
+        for (int i = 0; i < N; i++) {
+            bank[i] = object.getIntVal(i + 1);
+        }
+        return bank;
+    }
+
+    /**
+     * Returns the EVIO bank header tag expected for this data.
+     *
+     * @return
+     */
+    public abstract int getTag();
+
+    /**
+     * Parses the bank so the object can be used in analysis.
+     */
+    protected abstract void decodeData();
+
+    /**
+     * Returns the EVIO bank tag for a data object.
+     *
+     * @param data
+     * @return
+     */
+    public static int getTag(GenericObject data) {
+        return data.getIntVal(0);
+    }
+
+    @Override
+    public int getNInt() {
+        return bank.length + 1;
+    }
+
+    @Override
+    public int getNFloat() {
+        return 0;
+    }
+
+    @Override
+    public int getNDouble() {
+        return 0;
+    }
+
+    @Override
+    public int getIntVal(int index) {
+        if (index == 0) {
+            return getTag();
+        }
+        return bank[index - 1];
+    }
+
+    @Override
+    public float getFloatVal(int index) {
+        throw new UnsupportedOperationException("No float values in " + this.getClass().getSimpleName());
+    }
+
+    @Override
+    public double getDoubleVal(int index) {
+        throw new UnsupportedOperationException("No double values in " + this.getClass().getSimpleName());
+    }
+
+    @Override
+    public boolean isFixedSize() {
+        return true;
+    }
+}

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