MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
EventBuilder.hpp
Go to the documentation of this file.
1#ifndef EVENT_BUILDER_HPP
2#define EVENT_BUILDER_HPP
3
4#include "BinaryUtils.hpp"
5#include "DedupStrategy.hpp"
6#include "FileSet.hpp"
7#include "IOUtils.hpp"
8#include "PlottingUtils.hpp"
9#include "SlotLayout.hpp"
10#include <Rtypes.h>
11#include <TBranch.h>
12#include <TFile.h>
13#include <TObject.h>
14#include <TParameter.h>
15#include <TString.h>
16#include <TTree.h>
17#include <array>
18#include <iostream>
19#include <map>
20#include <mutex>
21#include <utility>
22#include <vector>
23
31struct EventState {
32 Int_t leftdE[16];
33 Int_t rightdE[16];
34 Int_t strip0dE;
35 Int_t strip17dE;
36 Int_t
38 Int_t cathode;
39 Int_t grid;
42 UInt_t flags_or;
43 Bool_t had_cathode;
47 ULong64_t ref_ts;
50 Int_t Total(Int_t strip) const {
51 if (strip <= 0)
52 return strip0dE;
53 if (strip >= 17)
54 return strip17dE;
55 return leftdE[strip - 1] + rightdE[strip - 1];
56 }
57};
58
70
82public:
85 typedef std::vector<Int_t> SlotMap;
86
89 static void ResetEventState(EventState &e);
92 static void ResetPerChannelData(PerChannelData &p);
109 static Bool_t ShouldKeepHit(ULong64_t cand_ts, ULong64_t prev_ts,
110 UShort_t cand_energy, UShort_t prev_energy,
111 ULong64_t ref_ts, DedupStrategy strategy);
117 static SlotMap BuildSlotMap();
130 static void AssignHit(EventState &e, PerChannelData *pc, ULong64_t ref_ts,
131 Int_t slot, UShort_t energy, ULong64_t timestamp,
132 UInt_t flags, DedupStrategy strategy);
142 static Bool_t CheckEventComplete(const EventState &e);
151 static void GetFlagSummary(const EventState &e, Bool_t &has_fake,
152 Bool_t &has_saturation, Bool_t &has_pileup);
167 static Bool_t BuildEventsFromSortedHits(const std::vector<RawHit> &hits,
168 const SlotMap &slot_map,
169 const TString &output_name,
170 const TString &file_label);
171};
172
173#endif
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.