Class DaqScalersSequence

java.lang.Object
org.jlab.detector.scalers.DaqScalersSequence
All Implemented Interfaces:
Comparator<DaqScalers>
Direct Known Subclasses:
QadbBin, QadbBinSequence

public class DaqScalersSequence extends Object implements Comparator<DaqScalers>
For easy access to most recent scaler readout for any given event. See the main() method for example use case, where only the 2 lines marked with "!!!" are specific to accessing scalers.
Author:
baltzell
  • Field Details

  • Constructor Details

    • DaqScalersSequence

      protected DaqScalersSequence()
    • DaqScalersSequence

      public DaqScalersSequence(org.jlab.jnp.hipo4.data.SchemaFactory schema)
    • DaqScalersSequence

      public DaqScalersSequence(List<DaqScalers> inputScalers)
  • Method Details

    • compare

      public int compare(DaqScalers o1, DaqScalers o2)
      Specified by:
      compare in interface Comparator<DaqScalers>
    • size

      public int size()
      Returns:
      the number of scalers in this sequence
    • findIndex

      protected int findIndex(long timestamp)
    • clear

      public void clear()
      remove all readouts from the sequence
    • clear

      public void clear(int keep)
      remove all but the latest readouts from the sequence
      Parameters:
      keep - the number of readouts to keep
    • add

      protected boolean add(DaqScalers ds)
    • add

      public boolean add(org.jlab.jnp.hipo4.data.Event event)
    • get

      public DaqScalers get(long timestamp)
      Parameters:
      timestamp - TI timestamp (i.e. RUN::config.timestamp)
      Returns:
      the most recent DaqScalers for the given timestamp
    • get

      public DaqScalers get(org.jlab.jnp.hipo4.data.Event event)
      Parameters:
      event -
      Returns:
      the most recent DaqScalers for the given event
    • getInterval

      public DaqScalersSequence.Interval getInterval()
      Returns:
      largest available interval of scaler readings
    • getInterval

      public DaqScalersSequence.Interval getInterval(long timestamp)
      Parameters:
      timestamp - TI timestamp (i.e. RUN::config.timestamp)
      Returns:
      smallest interval of scaler readings around that timestamp
    • getInterval

      public DaqScalersSequence.Interval getInterval(org.jlab.jnp.hipo4.data.Event event)
      Parameters:
      event -
      Returns:
      smallest interval of scaler readings around that event
    • getInterval

      public DaqScalersSequence.Interval getInterval(long t1, long t2)
      Parameters:
      t1 - first TI timestamp (i.e. RUN::config.timestamp)
      t2 - second TI timestamp
      Returns:
      smallest interval of scaler readings around those timestamps
    • getInterval

      public DaqScalersSequence.Interval getInterval(org.jlab.jnp.hipo4.data.Event event1, org.jlab.jnp.hipo4.data.Event event2)
      Parameters:
      event1 - first event
      event2 - second event
      Returns:
      smallest interval of scaler readings around those events
    • readSequence

      public static DaqScalersSequence readSequence(List<String> filenames)
      This reads tag=1 events for RUN::scaler banks, and initializes and returns a DaqScalersSequence that can be used to access the most recent scaler readout for any given event.
      Parameters:
      filenames - list of names of HIPO files to read
      Returns:
      sequence
    • readFiles

      protected void readFiles(List<String> filenames)
      Parameters:
      filenames - list of names of HIPO files to read
    • rebuildSequence

      public static DaqScalersSequence rebuildSequence(int tags, ConstantsManager conman, List<String> filenames)
      Reads the RAW::scaler bank and rebuilds the RUN::scaler and HEL::scaler banks
      Parameters:
      tags -
      conman -
      filenames -
      Returns:
    • validateOrdering

      public boolean validateOrdering()
      Checks if the scalers list is sorted such that the scalers' timestamp and event number orderings are consistent and monotonically increasing.
      Returns:
      true if timestamp and event number orderings are consistent
    • fixClockRollover

      public void fixClockRollover()
      Try to fix clock rollover on the run-integrating DSC2 scaler. 1. Assume the first clock readout has no rollover. 2. Assume any subsequent clock decrease is a rollover.
    • main

      public static void main(String[] args)