MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
Timing.hpp
Go to the documentation of this file.
1#ifndef TIMING_HPP
2#define TIMING_HPP
3
4#include "BinaryUtils.hpp"
5#include "Constants.hpp"
6#include "FileSet.hpp"
7#include "GpuAccel.hpp"
8#include "PlottingUtils.hpp"
9#include <Rtypes.h>
10#include <TCanvas.h>
11#include <TGraph.h>
12#include <TH2F.h>
13#include <TLine.h>
14#include <TMath.h>
15#include <TString.h>
16#include <algorithm>
17#include <iostream>
18#include <map>
19#include <mutex>
20#include <utility>
21#include <vector>
22
35
40 std::vector<Long64_t> board_shifts;
41};
42
44struct LongChan {
45 UShort_t board;
46 UShort_t channel;
47 TString name;
48};
49
55class Timing {
56public:
69 static Double_t FindDensestTimeWindowStartS(std::vector<Double_t> times,
70 Double_t window_width_s,
71 Double_t fallback_start_s);
92 static void ComputeNSD2(const std::vector<Double_t> &ref_x,
93 const std::vector<Double_t> &ref_y,
94 const std::vector<Double_t> &gr_x,
95 const std::vector<Double_t> &gr_y, Double_t shift,
96 Double_t thresh_dt_us, Int_t &npts, Double_t &nsd2);
97
100 static Bool_t IsLongChannel(const TString &name);
105 static Bool_t LongChanOrder(const LongChan &a, const LongChan &b);
107 static std::vector<LongChan> BuildLongChannelList();
108
121 static void PlotExtremeEvents2D(TH2F *h_before, TH2F *h_after,
122 TH2F *h_before_zoom, TH2F *h_after_zoom,
123 const TString &file_label);
138 static void PlotCostLandscape(const std::vector<Double_t> &shifts,
139 const std::vector<Double_t> &inv_nsd2_values,
140 Double_t best_shift, UShort_t ref_board,
141 UShort_t board, const TString &file_label,
142 const TString &tag);
143
161 static Double_t FindShiftBeam(TGraph *ref, TGraph *gr,
162 Double_t overlap_tmin_s,
163 Double_t overlap_tmax_s, Double_t thresh_dt_us,
164 UShort_t ref_board, UShort_t board,
165 const TString &file_label);
166
181 static std::vector<TGraph *> ExtractAllChannelsTimingStructureFromHits(
182 const std::vector<RawHit> &hits, const std::vector<LongChan> &channels,
183 Double_t min_energy, Double_t max_energy, Double_t tmin_s,
184 Double_t tmax_s, Double_t thresh_dt_us);
185
201 const std::vector<RawHit> &hits, const TString &file_label,
202 UShort_t ref_board, const std::vector<UShort_t> &board_channels,
203 Double_t min_energy, Double_t max_energy, Double_t overlap_margin_s,
204 Double_t thresh_dt_us);
205
213 static void ApplyShiftsInPlace(std::vector<RawHit> &hits,
214 const std::vector<Long64_t> &board_shifts);
215
223 static void SortHitsByTimestamp(std::vector<RawHit> &hits);
224};
225
226#endif
Dataset configuration.
Multi-board timing alignment and hit sorting.
Definition Timing.hpp:55
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.
Definition Timing.cpp:808
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.
Definition Timing.cpp:654
static void SortHitsByTimestamp(std::vector< RawHit > &hits)
Sort hits into ascending timestamp order, in place.
Definition Timing.cpp:794
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.
Definition Timing.cpp:88
static void ApplyShiftsInPlace(std::vector< RawHit > &hits, const std::vector< Long64_t > &board_shifts)
Add the measured offsets to the hits, in place.
Definition Timing.cpp:784
static void PlotExtremeEvents2D(TH2F *h_before, TH2F *h_after, TH2F *h_before_zoom, TH2F *h_after_zoom, const TString &file_label)
Save the before-and-after alignment diagnostic figures.
Definition Timing.cpp:181
static std::vector< LongChan > BuildLongChannelList()
Every long-end channel in the active map, in stable order.
Definition Timing.cpp:164
static Bool_t LongChanOrder(const LongChan &a, const LongChan &b)
Ordering predicate giving a stable channel sequence.
Definition Timing.cpp:158
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.
Definition Timing.cpp:412
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.
Definition Timing.cpp:252
static Bool_t IsLongChannel(const TString &name)
Whether a channel name denotes a long end.
Definition Timing.cpp:138
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.
Definition Timing.cpp:297
One long-end channel, used as a timing reference.
Definition Timing.hpp:44
UShort_t channel
Channel on that board.
Definition Timing.hpp:46
TString name
Channel name from the active map.
Definition Timing.hpp:47
UShort_t board
Board id.
Definition Timing.hpp:45
Per-board timing offsets, indexed by board number.
Definition Timing.hpp:37
std::vector< Long64_t > board_shifts
Offset to add to each board's timestamps, in picoseconds.
Definition Timing.hpp:40