4#include "BinaryUtils.hpp"
9#include "PlottingUtils.hpp"
71 Double_t window_width_s,
72 Double_t fallback_start_s);
93 static void ComputeNSD2(
const std::vector<Double_t> &ref_x,
94 const std::vector<Double_t> &ref_y,
95 const std::vector<Double_t> &gr_x,
96 const std::vector<Double_t> &gr_y, Double_t shift,
97 Double_t thresh_dt_us, Int_t &npts, Double_t &nsd2);
125 TH2F *h_before_zoom, TH2F *h_after_zoom,
126 const TString &file_label,
127 Double_t before_zoom_t0_s,
128 Double_t after_zoom_t0_s);
144 const std::vector<Double_t> &inv_nsd2_values,
145 Double_t best_shift, UShort_t ref_board,
146 UShort_t board,
const TString &file_label,
167 Double_t overlap_tmin_s,
168 Double_t overlap_tmax_s, Double_t thresh_dt_us,
169 UShort_t ref_board, UShort_t board,
170 const TString &file_label);
187 const std::vector<RawHit> &hits,
const std::vector<LongChan> &channels,
188 Double_t min_energy, Double_t max_energy, Double_t tmin_s,
189 Double_t tmax_s, Double_t thresh_dt_us);
206 const std::vector<RawHit> &hits,
const TString &file_label,
207 UShort_t ref_board,
const std::vector<UShort_t> &board_channels,
208 Double_t min_energy, Double_t max_energy, Double_t overlap_margin_s,
209 Double_t thresh_dt_us);
219 const std::vector<Long64_t> &board_shifts);
Per-channel trapezoidal-trigger-filter timing offsets.
The dataset configuration, and how it is layered.
Multi-board timing alignment and hit sorting.
static Double_t FindDensestTimeWindowStartS(std::vector< Double_t > times, Double_t window_width_s, Double_t fallback_start_s)
Start of the busiest window of a given width.
static TimeShiftResult CalcTimeShiftsBeamMethodFromHits(const std::vector< RawHit > &hits, const TString &file_label, UShort_t ref_board, const std::vector< UShort_t > &board_channels, Double_t min_energy, Double_t max_energy, Double_t overlap_margin_s, Double_t thresh_dt_us)
Measure every board's offset against a reference board.
static void SortHitsByTimestamp(std::vector< RawHit > &hits)
Sort hits into ascending timestamp order, in place.
static void ComputeNSD2(const std::vector< Double_t > &ref_x, const std::vector< Double_t > &ref_y, const std::vector< Double_t > &gr_x, const std::vector< Double_t > &gr_y, Double_t shift, Double_t thresh_dt_us, Int_t &npts, Double_t &nsd2)
Normalised squared deviation between two timing structures at a shift.
static void ApplyShiftsInPlace(std::vector< RawHit > &hits, const std::vector< Long64_t > &board_shifts)
Add the measured offsets to the hits, in place.
static std::vector< LongChan > BuildLongChannelList()
Every long-end channel in the active map, in stable order.
static Bool_t LongChanOrder(const LongChan &a, const LongChan &b)
Ordering predicate giving a stable channel sequence.
static std::vector< TGraph * > ExtractAllChannelsTimingStructureFromHits(const std::vector< RawHit > &hits, const std::vector< LongChan > &channels, Double_t min_energy, Double_t max_energy, Double_t tmin_s, Double_t tmax_s, Double_t thresh_dt_us)
Build the beam timing structure for each channel.
static void PlotCostLandscape(const std::vector< Double_t > &shifts, const std::vector< Double_t > &inv_nsd2_values, Double_t best_shift, UShort_t ref_board, UShort_t board, const TString &file_label, const TString &tag)
Save the shift-search cost landscape for one board pair.
static Bool_t IsLongChannel(const TString &name)
Whether a channel name denotes a long end.
static void PlotExtremeEvents2D(TH2F *h_before, TH2F *h_after, TH2F *h_before_zoom, TH2F *h_after_zoom, const TString &file_label, Double_t before_zoom_t0_s, Double_t after_zoom_t0_s)
Save the before-and-after alignment diagnostic figures.
static Double_t FindShiftBeam(TGraph *ref, TGraph *gr, Double_t overlap_tmin_s, Double_t overlap_tmax_s, Double_t thresh_dt_us, UShort_t ref_board, UShort_t board, const TString &file_label)
Best shift aligning one board's beam structure to the reference's.
One long-end channel, used as a timing reference.
UShort_t channel
Channel on that board.
TString name
Channel name from the active map.
Per-board timing offsets, indexed by board number.
std::vector< Long64_t > board_shifts
Offset to add to each board's timestamps, in picoseconds.