78 virtual Bool_t
Open(
const char *fname) {
80 file.open(fname, std::ios::binary);
82 if (!
file.is_open()) {
83 std::cerr <<
"ERROR: Cannot open file " << fname << std::endl;
255 UShort_t global_header;
269 Bool_t
Open(
const char *fname)
override;
280 Bool_t
Open(
const char *fname, UShort_t header_override);
342 Bool_t corrections_enabled;
351 :
BinaryReader(), corrections_enabled(with_corrections) {}
478 const std::size_t len =
static_cast<std::size_t
>(
trace_len);
481 return reinterpret_cast<const Int_t *
>(
trace_data.data());
495 const std::size_t len =
static_cast<std::size_t
>(
trace_len);
497 return reinterpret_cast<const Int_t *
>(
trace_data.data() + len * 4);
512 const std::size_t len =
static_cast<std::size_t
>(
trace_len);
516 return reinterpret_cast<const UChar_t *
>(
trace_data.data() + len * 8 +
530 static_cast<std::size_t
>(
trace_len) *
sizeof(Int_t)) {
531 return reinterpret_cast<const Int_t *
>(
trace_data.data());
612 const char *outputDir,
613 Double_t chunkSeconds,
BinaryReader()
Construct a reader with no file open.
Bool_t IsOpen() const
Whether a file is currently open.
Long64_t GetBytesRead() const
Bytes consumed so far, for progress reporting.
virtual ~BinaryReader()
Closes the file if it is still open.
virtual Bool_t Open(const char *fname)
Open a binary file for reading.
virtual Bool_t ReadEvent()=0
Decode the next record into the derived reader's current event.
TString GetFileName() const
Path most recently passed to Open().
virtual void Close()
Close the file. Safe to call when nothing is open.
Bool_t IsEOF() const
Whether the file is exhausted or was never opened.
One decoded CoMPASS event, with header-bit and status-flag accessors.
static const UInt_t FIRST_AFTER_BUSY
static const UInt_t PLL_LOCK_LOSS
Bool_t hasDeadtime() const
Deadtime occurred before this event.
Bool_t isFirstAfterBusy() const
First event after a busy period.
UShort_t energy_short_ch
Short-gate energy; valid if hasEnergyShort().
UShort_t channel
Channel index on that board.
UShort_t energy_ch
Energy in ADC channel units; valid if hasEnergyCh().
std::vector< TString > getActiveFlags() const
Names of every status flag currently set in flags.
static const UInt_t MEMORY_FULL
static const UInt_t N_TRIGGERS_COUNTED
static const UInt_t N_TRIGGERS_LOST
void Print() const
Print the whole event to stdout.
TArrayS samples
Waveform samples; valid if hasWaveform().
void PrintFlags() const
Print the active status flags to stdout.
Bool_t isOverTemperature() const
The board reported over-temperature.
static const UInt_t DEADTIME_OCCURRED
UShort_t board
Digitiser board id.
static const UInt_t TRIGGERS_1024_COUNTED
Bool_t hasTriggerLost() const
At least one trigger was lost.
static const UInt_t FINE_TIMESTAMP
Bool_t hasPLLLockLoss() const
The PLL lost lock.
static const UInt_t SATURATION_IN_GATE
Bool_t isPileup() const
Pileup was detected.
static const UInt_t INPUT_SATURATING
Bool_t hasNTriggersCounted() const
The counted-trigger field is present.
static const UInt_t TRIGGER_LOST
static const UInt_t NOT_MATCHED_TIMEFILTER
static const UInt_t PILEUP
UInt_t flags
Status bits; see the flag constants above.
Bool_t hasTimestampRollover() const
The timestamp counter rolled over.
UChar_t getControlBits() const
The four header control bits as a nibble.
Bool_t hasEnergyShort() const
Whether the record carries a short-gate energy (header bit 2).
Double_t energy_cal
Calibrated energy; valid if hasEnergyCal().
Bool_t hasFineTimestamp() const
A fine timestamp is available.
Bool_t isNotMatchedTimeFilter() const
The event failed the coincidence time filter.
Bool_t hasMemoryFull() const
Board memory was full.
ULong64_t timestamp
Acquisition timestamp, in picoseconds.
static const UInt_t FAKE_EVENT
Bool_t has1024Triggers() const
1024 triggers have been counted.
WaveformCode
Which CoMPASS processing stage a stored waveform came from.
UShort_t header
Global header word; says which fields are valid.
static const UInt_t ADC_SHUTDOWN
Bool_t isInputSaturating() const
The input is currently saturating.
UInt_t num_samples
Length of samples.
static const UInt_t TIMESTAMP_ROLLOVER
Bool_t hasSaturation() const
The input saturated within the integration gate.
static const UInt_t OVER_TEMPERATURE
CoMPASSData()
Construct with all fields zeroed.
static const UInt_t TIMESTAMP_RESET_EXT
Bool_t hasEnergyCal() const
Whether the record carries a calibrated energy (header bit 1).
TString getWaveformCodeName() const
Human-readable name for waveform_code.
void PrintHeader() const
Print the header fields to stdout.
Bool_t isADCShutdown() const
The ADC shut down.
Bool_t hasNTriggersLost() const
The lost-trigger count field is present.
Bool_t isFakeEvent() const
Synthetic event inserted by the acquisition.
Bool_t hasEnergyCh() const
Whether the record carries an uncalibrated energy (header bit 0).
void PrintWaveform() const
Print the waveform samples to stdout.
UChar_t waveform_code
Processing stage of samples; see WaveformCode.
Bool_t hasTimestampResetExt() const
An external timestamp reset was applied.
Bool_t hasWaveform() const
Whether the record carries waveform samples (header bit 3).
const CoMPASSData & GetCurrentEvent() const
The event most recently read.
CoMPASSReader()
Construct a reader with no file open.
Bool_t ReadEvent() override
Decode the next event into the current-event object.
CoMPASSData & GetCurrentEvent()
Mutable access to the event most recently read.
UShort_t GetGlobalHeader() const
The global header in force, read from the file or overridden.
Bool_t Open(const char *fname) override
Open a file and read its global header.
One decoded SOL block, optionally carrying its traces.
void clearTraces()
Release the trace buffer, invalidating every trace pointer.
UChar_t ana_probe_type[2]
UShort_t block_header
Raw block header word.
Bool_t hasTraces() const
Whether this block carries traces.
const UChar_t * getDigital(UInt_t ch) const
Pointer to one digital probe trace.
std::vector< Char_t > trace_data
Raw trace bytes, exactly as written by the DAQ.
const Int_t * getAnalog0() const
Pointer to the first analogue trace.
const Int_t * getOneTrace() const
Pointer to the single trace of a OneTrace block.
TString getDataTypeName() const
Human-readable name for data_type.
DataType
SOL block layout, which decides both the fields and the traces present.
UInt_t getSamples() const
Samples per trace in this block.
SOLData()
Construct with all fields zeroed and no traces.
UChar_t dig_probe_type[4]
const Int_t * getAnalog1() const
Pointer to the second analogue trace.
SOLHit ToHit() const
Copy the current block's header fields into a standalone SOLHit.
static std::vector< TString > SplitSolFileByTime(const char *inputFile, const char *outputDir, Double_t chunkSeconds, Int_t &totalBlocks, Int_t &totalChunks)
Split a run file into time-bounded chunks.
Long64_t GetBlockID() const
Zero-based index of the block most recently read.
SOLData & GetCurrentEvent()
Mutable access to the block most recently read.
SOLReader()
Construct a reader with no file open and traces enabled.
const SOLData & GetCurrentEvent() const
The block most recently read.
Bool_t ReadEvent() override
Decode the next record into the derived reader's current event.
Bool_t GetSkipTraces() const
Whether trace payloads are being skipped.
void SetSkipTraces(Bool_t skip)
Skip trace payloads while still parsing every block.
One decoded WaveDump event from a DT5742-family digitiser.
UInt_t pattern
Front-panel I/O pattern word.
WaveDump742Data()
Construct with all fields zeroed.
UInt_t start_index_cell
Switched-capacitor start cell.
UInt_t group_trigger_time_tag
Group trigger time tag.
virtual ~WaveDump742Data()
TArrayS samples
Waveform samples, in ADC counts.
UInt_t event_counter
Board's running event counter.
UInt_t board_id
Digitiser board id.
UInt_t event_size
Record size in 32-bit words.
UInt_t channel
Channel index.
UInt_t dc_offset
DC offset applied to this channel.
void SetCorrectionsEnabled(Bool_t enable)
Turn the DT5742 timing corrections on or off.
WaveDump742Data & GetCurrentEvent()
Mutable access to the event most recently read.
Bool_t GetCorrectionsEnabled() const
Whether the timing corrections are being applied.
Bool_t ReadEvent() override
Decode the next record into the derived reader's current event.
virtual ~WaveDump742Reader()
WaveDump742Reader(Bool_t with_corrections=kTRUE)
Construct a reader with no file open.
const WaveDump742Data & GetCurrentEvent() const
The event most recently read.
Minimal CoMPASS hit: header fields only, no waveform.
UInt_t flags
CoMPASS status bits; see CoMPASSData's constants.
UShort_t energy
Energy in ADC channel units.
UShort_t board
Digitiser board id.
UShort_t channel
Channel index on that board.
ULong64_t timestamp
Acquisition timestamp, in picoseconds.
Lightweight SOL block: header fields only, traces stripped.
Bool_t is_psd
Whether this block came from a PSD firmware.
UChar_t data_type
Block format; see SOLData::DataType.
UChar_t board_fail
Board failure indicator.
ULong64_t event_size
Size of the source block, in bytes.
UShort_t energy_short
Short-gate energy; meaningful when is_psd.
UChar_t dig_probe_type[4]
Digital probe selection for traces 0 to 3.
ULong64_t trace_len
Samples the source block carried, though this struct stores none of them.
UChar_t down_sampling
Trace downsampling factor applied on-board.
UShort_t trigger_thr
Trigger threshold in force.
ULong64_t timestamp
Coarse timestamp, in nanoseconds.
UChar_t flush
Flush indicator.
ULong64_t block_id
Zero-based index of this block in the file.
UChar_t ana_probe_type[2]
Analogue probe selection for traces 0 and 1.
UShort_t flags_high
Upper status word.
UShort_t energy
Long-gate energy, in ADC channel units.
UChar_t channel
Channel index.
UShort_t fine_timestamp
Sub-nanosecond refinement of timestamp.
UInt_t agg_counter
Aggregate counter from the board.
UShort_t flags_low
Lower status word.