MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
PulseHistory.hpp
Go to the documentation of this file.
1#ifndef PULSE_HISTORY_HPP
2#define PULSE_HISTORY_HPP
3
16#include "BinaryUtils.hpp"
17#include <Rtypes.h>
18#include <TString.h>
19#include <vector>
20
21class TH1D;
22class TH2D;
23class TProfile;
24
25namespace PulseHistory {
26
28const UInt_t kFlagClamped = 0x2000;
30const Int_t kNBins = 12;
31const Double_t kLogLo = -6.0;
32const Double_t kLogHi =
33 -4.0;
35const Int_t kMaxAmpBins = 6;
36
57
58const char *GroupName(Int_t g);
60const char *GroupTag(Int_t g);
63Int_t ChainOf(Int_t g);
65Bool_t IsLongGroup(Int_t g);
66
73struct Kernel {
74 Bool_t ok = kFALSE;
75 Int_t n_amp = 1;
76 Double_t k[kMaxAmpBins]
77 [kNBins];
78 Double_t intercept = 0.0;
79 Double_t r2 = 0.0;
80 Double_t rms_before = 0.0;
81 Double_t rms_after = 0.0;
82 Long64_t n = 0;
83 Long64_t n_beam = 0;
84
86 Kernel();
87};
88
95struct Result {
97 Long64_t n_hits = 0;
98 Long64_t n_seeds = 0;
99 Long64_t n_beam_events = 0;
100 Long64_t n_corrected = 0;
101 Long64_t n_clamped = 0;
104 Bool_t sorted_input = kTRUE;
107 std::vector<Double_t> mode;
116 TProfile
120
121 Result();
122 ~Result();
123};
124
128Int_t BinOf(Double_t dt_s);
131Double_t BinCentreUs(Int_t b);
137Int_t AmpBinOf(Double_t e_prev, Double_t mode, Int_t n_amp);
138
141std::vector<Int_t> BuildGroupMap();
142
158Bool_t Measure(std::vector<RawHit> &hits, const std::vector<Int_t> &group_of,
159 Result &res, const TString &file_label);
160
174void Apply(std::vector<RawHit> &hits, const std::vector<Int_t> &group_of,
175 Result &res);
176
180TString Report(const Result &res, const TString &file_label);
184void SavePlots(Result &res, const TString &file_label);
188void WriteToEventsFile(const TString &events_subpath, const Result &res);
189
190} // namespace PulseHistory
191
192#endif
const Double_t kLogHi
Highest dt bin edge: log10 of 100 us in seconds.
const Int_t kMaxAmpBins
Maximum amplitude bands a kernel may split the previous pulse into.
Int_t ChainOf(Int_t g)
Which readout chain a group belongs to.
const Int_t kNBins
Bins in the kernel, spanning kLogLo to kLogHi in log10 of dt.
TString Report(const Result &res, const TString &file_label)
Format the pass as a human-readable report.
const Double_t kLogLo
Lowest dt bin edge: log10 of 1 us in seconds.
Double_t BinCentreUs(Int_t b)
Centre of a kernel bin, in microseconds, for reports.
const char * GroupTag(Int_t g)
Short tag for filenames: L, R, Ls, Rs, S0, S17.
std::vector< Int_t > BuildGroupMap()
Group lookup for every (board, channel) under the active map.
Group
Channel groups, one kernel each.
@ kShortLeft
Short end, left chain.
@ kLongLeft
Long end, left chain.
@ kShortRight
Short end, right chain.
@ kGuard17
Single-pad guard after strip 17.
@ kNone
Not part of any corrected group.
@ kNGroups
Count of groups; not a group itself.
@ kGuard0
Single-pad guard before strip 0.
@ kLongRight
Long end, right chain.
Int_t BinOf(Double_t dt_s)
Kernel bin for a time since the previous pulse.
void Apply(std::vector< RawHit > &hits, const std::vector< Int_t > &group_of, Result &res)
Apply the measured kernels to the hit stream, in place.
Bool_t Measure(std::vector< RawHit > &hits, const std::vector< Int_t > &group_of, Result &res, const TString &file_label)
Measure the kernels on this subfile's beam-like events.
Bool_t IsLongGroup(Int_t g)
Whether a group is a long end rather than a short end or guard.
void SavePlots(Result &res, const TString &file_label)
Draw and save the diagnostics, then free them.
const UInt_t kFlagClamped
Flag set on a hit whose correction was clamped rather than applied in full.
Int_t AmpBinOf(Double_t e_prev, Double_t mode, Int_t n_amp)
Amplitude band of a previous pulse.
void WriteToEventsFile(const TString &events_subpath, const Result &res)
Record the kernels and counters alongside a subfile's events.
const char * GroupName(Int_t g)
Human-readable name of a Group.
The fitted correction for one channel group.
Double_t rms_before
Channel-deviation RMS before correction.
Double_t r2
Coefficient of determination.
Long64_t n_beam
Beam-like events passing this group's selection.
Bool_t ok
Whether this group was successfully fitted.
Double_t k[kMaxAmpBins][kNBins]
Coefficients, [amplitude band][dt bin].
Long64_t n
(event, channel) pairs entering the fit.
Double_t intercept
Fit intercept, in ADC.
Double_t rms_after
And after, so the gain is visible.
Int_t n_amp
Amplitude bands actually used, at most kMaxAmpBins.
Kernel()
Construct unfitted, with zeroed coefficients.
Everything one subfile's pulse-history pass produced.
TH1D * dev_after[kNGroups]
And after.
TH1D * dev_before[kNGroups]
Deviation distribution before correction.
Double_t mean_shift[kNGroups]
Mean subtracted term per group, ADC.
~Result()
Frees any diagnostic histograms still held.
Long64_t n_corrected
Hits that received a correction.
Kernel kernel[kNGroups]
One kernel per Group.
std::vector< Double_t > mode
Beam peak per (board, channel) index, in ADC.
Long64_t n_beam_events
Beam-like events the fit drew on.
TH1D * shift[kNGroups]
Shift applied per hit.
TProfile * dtprev_before[kNGroups]
Deviation against time to previous pulse.
Long64_t n_seeds
Hits usable as a previous pulse.
Bool_t sorted_input
Whether the input arrived time-ordered.
Long64_t n_clamped_group[kNGroups]
Clamps per group.
Long64_t n_clamped
Corrections clamped rather than applied in full.
TProfile * dtprev_after[kNGroups]
And after.
Result()
Construct with zeroed counters and null diagnostics.
TH2D * dev_vs_pred[kNGroups]
Channel deviation against predicted shift.
Long64_t n_hits
Hits examined.