1#ifndef EVENT_BUILDER_HPP
2#define EVENT_BUILDER_HPP
4#include "BinaryUtils.hpp"
8#include "PlottingUtils.hpp"
14#include <TParameter.h>
50 Int_t
Total(Int_t strip)
const {
109 static Bool_t
ShouldKeepHit(ULong64_t cand_ts, ULong64_t prev_ts,
110 UShort_t cand_energy, UShort_t prev_energy,
131 Int_t slot, UShort_t energy, ULong64_t timestamp,
152 Bool_t &has_saturation, Bool_t &has_pileup);
169 const TString &output_name,
170 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: the long end of every split strip,...
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[16]
Left end of strips 1-16, in ADC, index strip - 1.
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 hits[Constants::N_ARR_SLOTS]
Hit count per slot; see SlotLayout.hpp.
Int_t strip17dE
Strip 17, unsegmented, in ADC.
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 strip0dE
Strip 0, unsegmented, in ADC.
Int_t grid
Frisch grid energy, in ADC.
Int_t Total(Int_t strip) const
A strip's deposit: the sum of its ends, or the unsegmented value.
Int_t rightdE[16]
Right end of strips 1-16, in ADC, index strip - 1.
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.