Class QadbBinSequence<T>

java.lang.Object
org.jlab.detector.scalers.DaqScalersSequence
org.jlab.detector.qadb.QadbBinSequence<T>
All Implemented Interfaces:
Iterable<QadbBin<T>>, Comparator<DaqScalers>

public class QadbBinSequence<T> extends DaqScalersSequence implements Iterable<QadbBin<T>>
A sequence of bins for the Quality Assurance Database (QADB).

The bins may hold generic data, such as a class instance, accessible by QadbBin.data; the data type is set by a generic type parameter, and all bins will hold the same type of data.

Author:
dilks
See Also:
  • Constructor Details

    • QadbBinSequence

      public QadbBinSequence(List<String> filenames, int binWidth, QadbBinSequence.DataInitializer<T> initDataFunction)
      read a list of HIPO files for a run and generate a sequence of QADB bins. The original sequence of scalers (DaqScalersSequence) is sampled:
      • bin boundaries are set such that each bin contains binWidth consecutive scaler readouts (excluding the first); the last bin may contain less
      • QadbBin objects are defined for each pair of consecutive bin boundaries
      • an initial (final) QadbBin object is also defined, for events which occur before (after) the first (last) scaler readout
      • the private list of scalers becomes filled with ONLY the scaler readouts at the bin boundaries
      • each bin's scaler subsequence is stored within its QadbBin
      Parameters:
      filenames - list of HIPO files to read
      binWidth - the number of consecutive scaler-readout intervals in each bin
      initDataFunction - a lambda to create the initial data for each bin; must be of the form (binNumber) -> { return initData object }
    • QadbBinSequence

      public QadbBinSequence(List<String> filenames, int binWidth)
      alternative constructor, with no QadbBin.data initialization parameter

      QadbBin.data will be initialized to null

      Parameters:
      filenames - list of HIPO files to read
      binWidth - the number of consecutive scaler-readout intervals in each bin
  • Method Details

    • iterator

      public Iterator<QadbBin<T>> iterator()
      iterable interface implementation
      Specified by:
      iterator in interface Iterable<T>
    • size

      public int size()
      Overrides:
      size in class DaqScalersSequence
      Returns:
      the number of bins in this sequence
    • getBin

      public QadbBin<T> getBin(int idx)
      Parameters:
      idx - bin index
      Returns:
      a bin for a given index
    • findBin

      public Optional<QadbBin<T>> findBin(long timestamp)
      Parameters:
      timestamp - the timestamp
      Returns:
      the bin which contains the timestamp, if found
    • correctLowerBound

      public void correctLowerBound(int evnumMin, long timestampMin)
      correct the first bin's lower bound, if you know it from tag-0 events
      Parameters:
      evnumMin - the correct minimum event number
      timestampMin - the correct minimum timestamp
    • correctUpperBound

      public void correctUpperBound(int evnumMax, long timestampMax)
      correct the last bin's upper bound, if you know it from tag-0 events
      Parameters:
      evnumMax - the correct maximum event number
      timestampMax - the correct maximum timestamp
    • main

      public static void main(String[] args)
      Demonstrate how to use this class
      Parameters:
      args - command-line arguments