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 <TCanvas.h>
13#include <TFile.h>
14#include <TH1F.h>
15#include <TH2F.h>
16#include <TObject.h>
17#include <TParameter.h>
18#include <TString.h>
19#include <TTree.h>
20#include <array>
21#include <iostream>
22#include <map>
23#include <mutex>
24#include <utility>
25#include <vector>
26
34struct EventState {
35 Int_t leftdE[18];
36 Int_t rightdE[18];
37 Int_t totaldE[18];
38 Int_t
40 Int_t cathode;
41 Int_t grid;
44 UInt_t flags_or;
45 Bool_t had_cathode;
49 ULong64_t ref_ts;
50};
51
63
75public:
78 typedef std::vector<Int_t> SlotMap;
79
82 static void ResetEventState(EventState &e);
85 static void ResetPerChannelData(PerChannelData &p);
102 static Bool_t ShouldKeepHit(ULong64_t cand_ts, ULong64_t prev_ts,
103 UShort_t cand_energy, UShort_t prev_energy,
104 ULong64_t ref_ts, DedupStrategy strategy);
110 static SlotMap BuildSlotMap();
123 static void AssignHit(EventState &e, PerChannelData *pc, ULong64_t ref_ts,
124 Int_t slot, UShort_t energy, ULong64_t timestamp,
125 UInt_t flags, DedupStrategy strategy);
131 static Bool_t CheckEventComplete(const EventState &e);
140 static void GetFlagSummary(const EventState &e, Bool_t &has_fake,
141 Bool_t &has_saturation, Bool_t &has_pileup);
156 static Bool_t BuildEventsFromSortedHits(const std::vector<RawHit> &hits,
157 const SlotMap &slot_map,
158 const TString &output_name,
159 const TString &file_label);
160};
161
162#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.
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.