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

HPS-SVN September 2015

Subject:

r3681 - in /java/trunk: evio/ evio/src/main/java/org/hps/evio/ record-util/src/main/java/org/hps/record/triggerbank/ run-database/src/main/java/org/hps/run/database/

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 23 Sep 2015 15:58:01 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (380 lines)

Author: [log in to unmask]
Date: Wed Sep 23 08:57:56 2015
New Revision: 3681

Log:
use TI time offsets

Modified:
    java/trunk/evio/pom.xml
    java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.java
    java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java
    java/trunk/record-util/src/main/java/org/hps/record/triggerbank/HeadBankData.java
    java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java

Modified: java/trunk/evio/pom.xml
 =============================================================================
--- java/trunk/evio/pom.xml	(original)
+++ java/trunk/evio/pom.xml	Wed Sep 23 08:57:56 2015
@@ -23,6 +23,10 @@
         <dependency>
             <groupId>org.hps</groupId>
             <artifactId>hps-record-util</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hps</groupId>
+            <artifactId>hps-run-database</artifactId>
         </dependency>
     </dependencies>
     <build>

Modified: java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/EvioToLcio.java	Wed Sep 23 08:57:56 2015
@@ -28,6 +28,7 @@
 import org.hps.record.LCSimEventBuilder;
 import org.hps.record.evio.EvioEventQueue;
 import org.hps.record.evio.EvioEventUtilities;
+import org.hps.run.database.RunManager;
 import org.jlab.coda.jevio.BaseStructure;
 import org.jlab.coda.jevio.EvioEvent;
 import org.jlab.coda.jevio.EvioException;
@@ -41,7 +42,8 @@
 
 /**
  * <p>
- * This class converts EVIO to LCIO, performing an LCSim job in the same session. The processed events are then (optionally) written to disk using an
+ * This class converts EVIO to LCIO, performing an LCSim job in the same
+ * session. The processed events are then (optionally) written to disk using an
  * LCIOWriter.
  * <p>
  * To run this class from the command line:<br>
@@ -52,19 +54,24 @@
  * <p>
  * Extra arguments are treated as paths to EVIO files.
  * <p>
- * This class attempts to automatically configure itself for Test Run or Engineering Run based on the run numbers in the EVIO file. It will use an
- * appropriate default detector unless one is given on the command line, and it will also use the correct event builder. It will not handle jobs
- * correctly with files from both the Test and Engineering Run, so don't do this!
+ * This class attempts to automatically configure itself for Test Run or
+ * Engineering Run based on the run numbers in the EVIO file. It will use an
+ * appropriate default detector unless one is given on the command line, and it
+ * will also use the correct event builder. It will not handle jobs correctly
+ * with files from both the Test and Engineering Run, so don't do this!
  * <p>
  * The conditions system can be initialized in one of three ways.<br/>
  * <ol>
- * <li>user specified run number in which case the conditions system is frozen for the rest of the job</li>
+ * <li>user specified run number in which case the conditions system is frozen
+ * for the rest of the job</li>
  * <li>run number from an EVIO pre start event</li>
  * <li>run number from a header bank in an event</li>
  * </ol>
  * <p>
- * In the case where a file has no pre start event and there are header banks present, the "-m" command line option can be used to buffer a number of
- * EVIO events. If there is a head bank found while adding these events to queue, the conditions system will be initialized from it.
+ * In the case where a file has no pre start event and there are header banks
+ * present, the "-m" command line option can be used to buffer a number of EVIO
+ * events. If there is a head bank found while adding these events to queue, the
+ * conditions system will be initialized from it.
  *
  * @author Jeremy McCormick <[log in to unmask]>
  * @author Sho Uemura <[log in to unmask]>
@@ -72,7 +79,8 @@
 public class EvioToLcio {
 
     /**
-     * The default steering resource, which basically does nothing except print event numbers.
+     * The default steering resource, which basically does nothing except print
+     * event numbers.
      */
     private static final String DEFAULT_STEERING_RESOURCE = "/org/hps/steering/EventMarker.lcsim";
 
@@ -101,7 +109,7 @@
      */
     private LCSimEventBuilder eventBuilder = null;
 
-    /** 
+    /**
      * The command line options which will be defined in the constructor.
      */
     private Options options = null;
@@ -112,7 +120,8 @@
     private Integer runNumber = null;
 
     /**
-     * The default constructor, which defines command line arguments and sets the default log level.
+     * The default constructor, which defines command line arguments and sets
+     * the default log level.
      */
     protected EvioToLcio() {
         LOGGER.config("initializing EVIO to LCIO converter ...");
@@ -135,8 +144,9 @@
     }
 
     /**
-     * Buffer up to <code>maxBufferSize</code> events in the <code>eventQueue</code>. This method will also initialize the conditions system using a
-     * run number if a header bank is found.
+     * Buffer up to <code>maxBufferSize</code> events in the
+     * <code>eventQueue</code>. This method will also initialize the conditions
+     * system using a run number if a header bank is found.
      *
      * @param reader the EVIO reader
      * @param eventQueue the event queue
@@ -170,25 +180,24 @@
                     continue;
                 }
 
-                // Is conditions system not frozen?
-                if (!DatabaseConditionsManager.getInstance().isFrozen()) {
-
-                    // Get head bank from event.
-                    final BaseStructure headBank = EvioEventUtilities.getHeadBank(evioEvent);
-
-                    // Is head bank available in this event?
-                    if (headBank != null) {
-
-                        // Get the run number from the head bank.
-                        runNumber = headBank.getIntData()[1];
-                        LOGGER.finer("got head bank with run number " + runNumber);
-
+                // Get head bank from event.
+                final BaseStructure headBank = EvioEventUtilities.getHeadBank(evioEvent);
+
+                // Is head bank available in this event?
+                if (headBank != null) {
+
+                    // Get the run number from the head bank.
+                    runNumber = headBank.getIntData()[1];
+                    LOGGER.finer("got head bank with run number " + runNumber);
+
+                    // Is conditions system not frozen?
+                    if (!DatabaseConditionsManager.getInstance().isFrozen()) {
                         // Check if the conditions system needs to be updated from the head bank.
                         this.checkConditions(runNumber, false);
-                        
-                    } else {
-                        LOGGER.finest("event " + evioEvent.getEventNumber() + " does not have a head bank");
                     }
+                    RunManager.getRunManager().setRun(runNumber);
+                } else {
+                    LOGGER.finest("event " + evioEvent.getEventNumber() + " does not have a head bank");
                 }
             }
         }
@@ -196,7 +205,8 @@
     }
 
     /**
-     * Check if the conditions system and event builder need to be initialized or updated given a run number.
+     * Check if the conditions system and event builder need to be initialized
+     * or updated given a run number.
      *
      * @param runNumber The run number.
      * @param freeze True to freeze conditions system after it is setup.
@@ -234,8 +244,10 @@
     }
 
     /**
-     * This method will execute the EVIO to LCIO conversion and optionally process the events with LCSim Drivers from a steering file. Then the
-     * resultant LCIO events will be written to disk if this option is enabled in the command line arguments.
+     * This method will execute the EVIO to LCIO conversion and optionally
+     * process the events with LCSim Drivers from a steering file. Then the
+     * resultant LCIO events will be written to disk if this option is enabled
+     * in the command line arguments.
      *
      * @param args The command line arguments.
      */
@@ -442,7 +454,8 @@
 
         // Loop over the input EVIO files.
         EvioReader reader = null;
-        fileLoop: for (final String evioFileName : evioFileList) {
+        fileLoop:
+        for (final String evioFileName : evioFileList) {
 
             // Get the next EVIO input file.
             final File evioFile = new File(evioFileName);
@@ -463,7 +476,8 @@
 
             // Loop over events.
             final EvioEventQueue eventQueue = new EvioEventQueue(-1L, maxBufferSize);
-            eventLoop: for (;;) {
+            eventLoop:
+            for (;;) {
 
                 // Buffer the EVIO events into the queue.
                 this.bufferEvents(reader, eventQueue, maxBufferSize);
@@ -475,7 +489,8 @@
                 }
 
                 // Loop over the EVIO events in the buffer until it is empty.
-                recordLoop: while (eventQueue.hasNext()) {
+                recordLoop:
+                while (eventQueue.hasNext()) {
 
                     // Read and parse the next EVIO event.
                     EvioEvent evioEvent = null;
@@ -565,7 +580,7 @@
 
                         // Write out this LCIO event.
                         if (writer != null) {
-                            try {                                
+                            try {
                                 writer.write(lcioEvent);
                                 writer.flush();
                                 LOGGER.finest("wrote LCSim event " + lcioEvent.getEventNumber());
@@ -629,10 +644,13 @@
     }
 
     /**
-     * Setup the LCSimEventBuilder based on the current detector name and run number.
+     * Setup the LCSimEventBuilder based on the current detector name and run
+     * number.
      *
-     * @param detectorName The detector name to be assigned to the event builder.
-     * @param runNumber The run number which determines which event builder to use.
+     * @param detectorName The detector name to be assigned to the event
+     * builder.
+     * @param runNumber The run number which determines which event builder to
+     * use.
      * @return The LCSimEventBuilder for the Test Run or Engineering Run.
      */
     private void setupEventBuilder(final int runNumber) {

Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java	Wed Sep 23 08:57:56 2015
@@ -15,6 +15,8 @@
 import org.hps.record.triggerbank.SSPData;
 import org.hps.record.triggerbank.TDCData;
 import org.hps.record.triggerbank.TIData;
+import org.hps.run.database.RunManager;
+import org.hps.run.database.RunSummary;
 import org.jlab.coda.jevio.EvioEvent;
 import org.lcsim.conditions.ConditionsEvent;
 import org.lcsim.event.EventHeader;
@@ -22,13 +24,15 @@
 import org.lcsim.util.log.LogUtil;
 
 /**
- * This is the {@link org.hps.record.LCSimEventBuilder} implementation for the Engineering Run and the Commissioning Run
- * for converting EVIO to LCIO events.
+ * This is the {@link org.hps.record.LCSimEventBuilder} implementation for the
+ * Engineering Run and the Commissioning Run for converting EVIO to LCIO events.
  * <p>
- * It has several modifications from the Test Run builder including different values for certain bank tags.
+ * It has several modifications from the Test Run builder including different
+ * values for certain bank tags.
  * <p>
- * Additionally, this builder will write DAQ config information, EPICS control data, and scalar bank data into the
- * output LCSim events if these banks are present in the EVIO data.
+ * Additionally, this builder will write DAQ config information, EPICS control
+ * data, and scalar bank data into the output LCSim events if these banks are
+ * present in the EVIO data.
  *
  * @author Sho Uemura, SLAC
  * @author Jeremy McCormick, SLAC
@@ -60,6 +64,11 @@
      * Reads trigger config.
      */
     private TriggerConfigEvioReader triggerConfigReader = null;
+
+    /**
+     * Modulus of TI timestamp offset (units of nanoseconds).
+     */
+    private final long timestampCycle = 24 * 6 * 35;
 
     /**
      * Class constructor.
@@ -72,10 +81,10 @@
         sspCrateBankTag = 0x2E; // A.C. modification after Sergey's confirmation
         sspBankTag = 0xe10c;
         intBanks = new ArrayList<IntBankDefinition>();
-        intBanks.add(new IntBankDefinition(SSPData.class, new int[] {sspCrateBankTag, sspBankTag}));
-        intBanks.add(new IntBankDefinition(TIData.class, new int[] {sspCrateBankTag, 0xe10a}));
-        intBanks.add(new IntBankDefinition(HeadBankData.class, new int[] {sspCrateBankTag, 0xe10f}));
-        intBanks.add(new IntBankDefinition(TDCData.class, new int[] {0x3a, 0xe107}));
+        intBanks.add(new IntBankDefinition(SSPData.class, new int[]{sspCrateBankTag, sspBankTag}));
+        intBanks.add(new IntBankDefinition(TIData.class, new int[]{sspCrateBankTag, 0xe10a}));
+        intBanks.add(new IntBankDefinition(HeadBankData.class, new int[]{sspCrateBankTag, 0xe10f}));
+        intBanks.add(new IntBankDefinition(TDCData.class, new int[]{0x3a, 0xe107}));
         // ecalReader = new ECalEvioReader(0x25, 0x27);
         triggerConfigReader = new TriggerConfigEvioReader();
         svtEventFlagger = new SvtEventFlagger();
@@ -94,10 +103,17 @@
      */
     @Override
     protected long getTime(final List<AbstractIntData> triggerList) {
+        long tiTimeOffset = 0;
+        RunSummary runSummary = RunManager.getRunManager().getRunSummary();
+        if (runSummary != null) {
+            tiTimeOffset = runSummary.getTriggerConfig().getTiTimeOffset();
+            tiTimeOffset = (tiTimeOffset / timestampCycle) * timestampCycle;
+        }
+
         for (final AbstractIntData data : triggerList) {
             if (data instanceof TIData) {
                 final TIData tiData = (TIData) data;
-                return tiData.getTime();
+                return tiData.getTime() + tiTimeOffset;
             }
         }
         return 0;
@@ -136,13 +152,13 @@
         try {
             svtReader.makeHits(evioEvent, lcsimEvent);
         } catch (final SvtEvioHeaderException e) {
-            LOGGER.log(Level.SEVERE, "Error reading header information from the SVT.",e);
+            LOGGER.log(Level.SEVERE, "Error reading header information from the SVT.", e);
         } catch (final SvtEvioReaderException e) {
-            LOGGER.log(Level.SEVERE, "Error making SVT hits.",e);
+            LOGGER.log(Level.SEVERE, "Error making SVT hits.", e);
         } catch (final Exception e) {
             LOGGER.log(Level.SEVERE, "Error making SVT hits. Don't think I should be able to get here?", e);
         }
-        
+
         // Write the current EPICS data into this event.
         this.writeEpicsData(lcsimEvent);
 

Modified: java/trunk/record-util/src/main/java/org/hps/record/triggerbank/HeadBankData.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/triggerbank/HeadBankData.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/triggerbank/HeadBankData.java	Wed Sep 23 08:57:56 2015
@@ -18,15 +18,8 @@
     public static final int UNIX_TIME = 3;
     public static final int EVENT_TYPE = 4;
 
-    public static int lastGoodTime = 0;
-
     public HeadBankData(int[] bank) {
         super(bank);
-        if (this.bank[UNIX_TIME] == 0) { //if the timestamp is 0, use the most recent nonzero timestamp
-            this.bank[UNIX_TIME] = lastGoodTime;
-        } else if (this.bank[UNIX_TIME] >= lastGoodTime) { //if the timestamp goes down, the event is out of sequence - keep the timestamp for this event, but don't apply it to later events
-            lastGoodTime = this.bank[UNIX_TIME];
-        }
         decodeData();
     }
 

Modified: java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java
 =============================================================================
--- java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java	(original)
+++ java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java	Wed Sep 23 08:57:56 2015
@@ -166,6 +166,10 @@
      * @param run the run number
      */
     public synchronized void setRun(final int run) {
+        // Don't do anything if the run number has already been set.
+        if (run == this.run) {
+            return;
+        }
 
         // Check if run number is valid.
         if (run < 0) {

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