1#ifndef EVENT_BUILDER_HPP
2#define EVENT_BUILDER_HPP
4#include "BinaryUtils.hpp"
8#include "PlottingUtils.hpp"
17#include <TParameter.h>
102 static Bool_t
ShouldKeepHit(ULong64_t cand_ts, ULong64_t prev_ts,
103 UShort_t cand_energy, UShort_t prev_energy,
124 Int_t slot, UShort_t energy, ULong64_t timestamp,
141 Bool_t &has_saturation, Bool_t &has_pileup);
158 const TString &output_name,
159 const TString &file_label);
DedupStrategy
How to resolve more than one hit on the same channel within an event.
Fixed array indices for the per-event channel arrays.
Groups time-sorted hits into events.
static Bool_t CheckEventComplete(const EventState &e)
Whether an event has everything required to be written out.
static SlotMap BuildSlotMap()
Build the board/channel to slot lookup for this dataset.
static void ResetEventState(EventState &e)
Clear an event back to its empty state, ready to be seeded.
static Bool_t ShouldKeepHit(ULong64_t cand_ts, ULong64_t prev_ts, UShort_t cand_energy, UShort_t prev_energy, ULong64_t ref_ts, DedupStrategy strategy)
Decide which of two hits on the same slot survives.
static void GetFlagSummary(const EventState &e, Bool_t &has_fake, Bool_t &has_saturation, Bool_t &has_pileup)
Unpack the OR-ed status flags into the conditions that matter.
static void ResetPerChannelData(PerChannelData &p)
Clear the per-slot detail alongside a reset event.
static Bool_t BuildEventsFromSortedHits(const std::vector< RawHit > &hits, const SlotMap &slot_map, const TString &output_name, const TString &file_label)
Build every event in a subfile and write them to a ROOT tree.
std::vector< Int_t > SlotMap
Board/channel to array slot lookup, indexed as BuildSlotMap() defines.
static void AssignHit(EventState &e, PerChannelData *pc, ULong64_t ref_ts, Int_t slot, UShort_t energy, ULong64_t timestamp, UInt_t flags, DedupStrategy strategy)
Place one hit into an event, resolving any collision.
const Int_t N_ARR_SLOTS
Length of the per-event channel arrays.
One built event: the per-slot energies and the flags seen while building it.
Int_t leftdE[18]
Left-side energy per anode strip, in ADC.
UInt_t flags_or
Bitwise OR of the CoMPASS status flags of every hit in the event, so a single test covers pileup or s...
Int_t totaldE[18]
Summed energy per anode strip, in ADC.
Int_t rightdE[18]
Right-side energy per anode strip, in ADC.
Int_t hits[Constants::N_ARR_SLOTS]
Hit count per slot; see SlotLayout.hpp.
Bool_t had_cathode
Whether a cathode hit was seen at all.
ULong64_t ref_ts
Timestamp of the reference grid hit that seeded this event.
Int_t cathode
Cathode energy, in ADC.
Int_t grid
Frisch grid energy, in ADC.
Raw per-slot detail for one event, kept alongside EventState.
ULong64_t timestamps[Constants::N_ARR_SLOTS]
Hit timestamp per slot.
UInt_t flags[Constants::N_ARR_SLOTS]
Status flags per slot.
UShort_t energies[Constants::N_ARR_SLOTS]
Hit energy per slot, ADC.