Package org.jlab.detector.qadb
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>
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacelambda type to initialize each bin's generic dataNested classes/interfaces inherited from class org.jlab.detector.scalers.DaqScalersSequence
DaqScalersSequence.Interval -
Field Summary
Fields inherited from class org.jlab.detector.scalers.DaqScalersSequence
logger, scalers, TI_CLOCK_FREQ -
Constructor Summary
ConstructorsConstructorDescriptionQadbBinSequence(String file_name) alternative constructor, which reads bin specification file produced bywriteBinSpec(java.lang.String); no charge info will be read, this is just for bin _boundary_ info onlyQadbBinSequence(List<String> filenames, int binWidth) alternative constructor, with noQadbBin.datainitialization parameterQadbBinSequence(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidcorrectLowerBound(int evnumMin, long timestampMin) correct the first bin's lower bound, if you know it from tag-0 eventsvoidcorrectUpperBound(int evnumMax, long timestampMax) correct the last bin's upper bound, if you know it from tag-0 eventsfindBin(long timestamp) getBin(int idx) iterator()iterable interface implementationstatic voidDemonstrate how to use this classintsize()voidwriteBinSpec(String file_name) write a bin specification fileMethods inherited from class org.jlab.detector.scalers.DaqScalersSequence
add, add, clear, clear, compare, findIndex, fixClockRollover, get, get, getInterval, getInterval, getInterval, getInterval, getInterval, readFiles, readSequence, rebuildSequence, validateOrderingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
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
binWidthconsecutive scaler readouts (excluding the first); the last bin may contain less -
QadbBinobjects are defined for each pair of consecutive bin boundaries - an initial (final)
QadbBinobject is also defined, for events which occur before (after) the first (last) scaler readout - the
privatelist 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 readbinWidth- the number of consecutive scaler-readout intervals in each bininitDataFunction- a lambda to create the initial data for each bin; must be of the form(binNumber) -> { return initData object }
- bin boundaries are set such that each bin contains
-
QadbBinSequence
alternative constructor, with noQadbBin.datainitialization parameterQadbBin.datawill be initialized tonull- Parameters:
filenames- list of HIPO files to readbinWidth- the number of consecutive scaler-readout intervals in each bin
-
QadbBinSequence
alternative constructor, which reads bin specification file produced bywriteBinSpec(java.lang.String); no charge info will be read, this is just for bin _boundary_ info only- Parameters:
file_name- the path to the bin specification file
-
-
Method Details
-
iterator
iterable interface implementation -
size
public int size()- Overrides:
sizein classDaqScalersSequence- Returns:
- the number of bins in this sequence
-
getBin
- Parameters:
idx- bin index- Returns:
- a bin for a given index
-
findBin
- 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 numbertimestampMin- 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 numbertimestampMax- the correct maximum timestamp
-
writeBinSpec
write a bin specification file- Parameters:
file_name- the path to the file
-
main
Demonstrate how to use this class- Parameters:
args- command-line arguments
-