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 "ChannelTiming.hpp"
6#include "Constants.hpp"
7#include "FileSet.hpp"
8#include "GpuAccel.hpp"
9#include "PlottingUtils.hpp"
10#include <Rtypes.h>
11#include <TCanvas.h>
12#include <TGraph.h>
13#include <TH2F.h>
14#include <TLine.h>
15#include <TMath.h>
16#include <TString.h>
17#include <algorithm>
18#include <iostream>
19#include <map>
20#include <mutex>
21#include <utility>
22#include <vector>
23
36
41 std::vector<Long64_t> board_shifts;
42};
43
45struct LongChan {
46 UShort_t board;
47 UShort_t channel;
48 TString name;
49};
50
56class Timing {
57public:
70 static Double_t FindDensestTimeWindowStartS(std::vector<Double_t> times,
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);
98
101 static Bool_t IsLongChannel(const TString &name);
106 static Bool_t LongChanOrder(const LongChan &a, const LongChan &b);
108 static std::vector<LongChan> BuildLongChannelList();
109
124 static void PlotExtremeEvents2D(TH2F *h_before, TH2F *h_after,
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);
143 static void PlotCostLandscape(const std::vector<Double_t> &shifts,
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,
147 const TString &tag);
148
166 static Double_t FindShiftBeam(TGraph *ref, TGraph *gr,
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);
171
186 static std::vector<TGraph *> ExtractAllChannelsTimingStructureFromHits(
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);
190
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);
210
218 static void ApplyShiftsInPlace(std::vector<RawHit> &hits,
219 const std::vector<Long64_t> &board_shifts);
220
228 static void SortHitsByTimestamp(std::vector<RawHit> &hits);
229};
230
231#endif
Per-channel trapezoidal-trigger-filter timing offsets.
The dataset configuration, and how it is layered.
Multi-board timing alignment and hit sorting.
Definition Timing.hpp:56
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:740
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:476
static void SortHitsByTimestamp(std::vector< RawHit > &hits)
Sort hits into ascending timestamp order, in place.
Definition Timing.cpp:726
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:87
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:712
static std::vector< LongChan > BuildLongChannelList()
Every long-end channel in the active map, in stable order.
Definition Timing.cpp:163
static Bool_t LongChanOrder(const LongChan &a, const LongChan &b)
Ordering predicate giving a stable channel sequence.
Definition Timing.cpp:157
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:413
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:253
static Bool_t IsLongChannel(const TString &name)
Whether a channel name denotes a long end.
Definition Timing.cpp:137
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.
Definition Timing.cpp:180
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:298
One long-end channel, used as a timing reference.
Definition Timing.hpp:45
UShort_t channel
Channel on that board.
Definition Timing.hpp:47
TString name
Channel name from the active map.
Definition Timing.hpp:48
UShort_t board
Board id.
Definition Timing.hpp:46
Per-board timing offsets, indexed by board number.
Definition Timing.hpp:38
std::vector< Long64_t > board_shifts
Offset to add to each board's timestamps, in picoseconds.
Definition Timing.hpp:41