MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches

Groups time-sorted hits into events. More...

#include <EventBuilder.hpp>

Public Types

typedef std::vector< Int_t > SlotMap
 Board/channel to array slot lookup, indexed as BuildSlotMap() defines.

Static Public Member Functions

static void ResetEventState (EventState &e)
 Clear an event back to its empty state, ready to be seeded.
static void ResetPerChannelData (PerChannelData &p)
 Clear the per-slot detail alongside a reset event.
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 SlotMap BuildSlotMap ()
 Build the board/channel to slot lookup for this dataset.
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.
static Bool_t CheckEventComplete (const EventState &e)
 Whether an event has everything required to be written out.
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 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.

Detailed Description

Groups time-sorted hits into events.

A grid hit seeds an event; hits within the coincidence window are assigned to its slots. A second hit on an already-filled slot is resolved by the configured DedupStrategy.

All-static: the builder holds no state of its own, so the same functions serve the parallel file workers without synchronisation.

Definition at line 74 of file EventBuilder.hpp.

Member Typedef Documentation

◆ SlotMap

typedef std::vector<Int_t> EventBuilder::SlotMap

Board/channel to array slot lookup, indexed as BuildSlotMap() defines.

Definition at line 78 of file EventBuilder.hpp.

Member Function Documentation

◆ AssignHit()

void EventBuilder::AssignHit ( EventState & e,
PerChannelData * pc,
ULong64_t ref_ts,
Int_t slot,
UShort_t energy,
ULong64_t timestamp,
UInt_t flags,
DedupStrategy strategy )
static

Place one hit into an event, resolving any collision.

Parameters
[in,out]eEvent to fill.
[in,out]pcPer-slot detail, or null to skip recording it.
ref_tsSeeding grid hit's timestamp.
slotTarget slot; see SlotLayout.hpp.
energyHit energy, in ADC.
timestampHit timestamp.
flagsHit status flags, OR-ed into EventState::flags_or.
strategyRule for resolving a slot that is already filled.

Definition at line 76 of file EventBuilder.cpp.

Referenced by BuildEventsFromSortedHits().

◆ BuildEventsFromSortedHits()

Bool_t EventBuilder::BuildEventsFromSortedHits ( const std::vector< RawHit > & hits,
const SlotMap & slot_map,
const TString & output_name,
const TString & file_label )
static

Build every event in a subfile and write them to a ROOT tree.

Parameters
hitsHits for one subfile, already sorted by timestamp.
slot_mapLookup from BuildSlotMap().
output_nameOutput basename for the events file.
file_labelLabel from FileSet::FileLabel(), used in logs and plots.
Returns
kTRUE on success.
Warning
The hits must be time-sorted. The builder walks them in order and closes an event once the coincidence window passes, so unsorted input silently produces wrong events rather than an error.

Definition at line 296 of file EventBuilder.cpp.

Referenced by RunFusedPipelineForFile().

◆ BuildSlotMap()

EventBuilder::SlotMap EventBuilder::BuildSlotMap ( )
static

Build the board/channel to slot lookup for this dataset.

Returns
The map, sized and ordered so a hit's board and channel index into it directly.

Definition at line 42 of file EventBuilder.cpp.

◆ CheckEventComplete()

Bool_t EventBuilder::CheckEventComplete ( const EventState & e)
static

Whether an event has everything required to be written out.

Parameters
eEvent to test.
Returns
kTRUE if it is complete by the dataset's criteria.

Definition at line 120 of file EventBuilder.cpp.

Referenced by FinalizeEvent().

◆ GetFlagSummary()

void EventBuilder::GetFlagSummary ( const EventState & e,
Bool_t & has_fake,
Bool_t & has_saturation,
Bool_t & has_pileup )
static

Unpack the OR-ed status flags into the conditions that matter.

Parameters
eEvent to inspect.
[out]has_fakeA synthetic event was inserted by the acquisition.
[out]has_saturationSome channel saturated within its gate.
[out]has_pileupPileup was flagged on some channel.

Definition at line 134 of file EventBuilder.cpp.

Referenced by FinalizeEvent().

◆ ResetEventState()

void EventBuilder::ResetEventState ( EventState & e)
static

Clear an event back to its empty state, ready to be seeded.

Parameters
[out]eEvent to reset.

Definition at line 4 of file EventBuilder.cpp.

Referenced by BuildEventsFromSortedHits().

◆ ResetPerChannelData()

void EventBuilder::ResetPerChannelData ( PerChannelData & p)
static

Clear the per-slot detail alongside a reset event.

Parameters
[out]pData to reset.

Definition at line 19 of file EventBuilder.cpp.

Referenced by BuildEventsFromSortedHits().

◆ ShouldKeepHit()

Bool_t EventBuilder::ShouldKeepHit ( ULong64_t cand_ts,
ULong64_t prev_ts,
UShort_t cand_energy,
UShort_t prev_energy,
ULong64_t ref_ts,
DedupStrategy strategy )
static

Decide which of two hits on the same slot survives.

Parameters
cand_tsCandidate hit's timestamp.
prev_tsTimestamp of the hit already assigned.
cand_energyCandidate hit's energy, in ADC.
prev_energyEnergy of the hit already assigned.
ref_tsTimestamp of the grid hit that seeded the event, which DedupStrategy::kCLOSEST_TO_FIRST_GRID measures against.
strategyResolution rule.
Returns
kTRUE to replace the existing hit with the candidate.
Note
DedupStrategy::kDISCARD is not decided here — it rejects the whole event, which is handled by the caller.

Definition at line 27 of file EventBuilder.cpp.

Referenced by AssignHit().


The documentation for this class was generated from the following files: