1#ifndef PULSE_HISTORY_HPP
2#define PULSE_HISTORY_HPP
21#include "BinaryUtils.hpp"
176 Double_t
FormAt(Int_t a, Double_t dt_us)
const;
273Int_t
BinOf(Double_t dt_s);
282Int_t
AmpBinOf(Double_t e_prev, Double_t mode, Int_t n_amp);
303Bool_t
Measure(std::vector<RawHit> &hits,
const std::vector<Int_t> &group_of,
304 Result &res,
const TString &file_label);
320void Apply(std::vector<RawHit> &hits,
const std::vector<Int_t> &group_of,
330TString
Report(
const Result &res,
const TString &file_label,
331 Bool_t detail = kTRUE);
Bool_t GroupWantsForm(Int_t g)
Whether the configuration asks for the pole-zero form on this group rather than the binned kernel.
ChannelGroup
Channel groups, one kernel each.
@ kLONG_LEFT
Long end, left chain.
@ kNONE
Not part of any corrected group.
@ kSHORT_RIGHT
Short end, right chain.
@ kNGROUPS
Count of groups; not a group itself.
@ kSTRIP0
Strip 0, unsegmented.
@ kGRID
The Frisch grid: the seed channel, one per event.
@ kSTRIP17
Strip 17, unsegmented.
@ kSHORT_LEFT
Short end, left chain.
@ kLONG_RIGHT
Long end, right chain.
const Double_t kTauFitLoUs
const Double_t kTauGridLoUs
const Double_t kLogHi
Highest dt bin edge: log10 of 316 us in seconds.
Double_t GroupTauUs(Int_t g)
The preamp decay time the configuration gives for this group, in microseconds; 0 when it is to be pro...
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: twelve per decade, 0....
const Double_t kLogLo
Lowest dt bin edge: log10 of 1 us in seconds.
const Int_t kTauFitMinEntries
Below this many (event, channel) pairs in the window the fit is skipped.
const Double_t kTauFitHiUs
Double_t BinCentreUs(Int_t b)
Centre of a kernel bin, in microseconds, for reports.
const Int_t kMAX_AMP_BINS
Maximum amplitude bands a kernel may split the previous pulse into.
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.
const Long64_t kMinPairsPerChannel
Fewest (event, channel) pairs a channel needs for a kernel of its own; below it the channel is correc...
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 an unsegmented strip.
void SavePlots(Result &res, const TString &file_label)
Draw and save the diagnostics, then free them.
Bool_t GroupEnabled(Int_t g)
Whether the groups in force (Constants::ActivePulseHistoryGroups()) have this group corrected.
const UInt_t kFlagClamped
Flag set on a hit whose correction was clamped rather than applied in full.
const Double_t kTauGridHiUs
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.
TString Report(const Result &res, const TString &file_label, Bool_t detail=kTRUE)
Format the pass as a human-readable report.
Single-exponential summary of the dt profile for this group.
Double_t p0
Level at large dt, ADC.
Bool_t flat
Amplitude within 2 sigma of zero: no decay.
Double_t chi2
Chi2 of the fit over the window.
Double_t p3
Linear lift (the baseline term), ADC/us.
Int_t ndf
Its degrees of freedom.
Bool_t ok
Whether the fit converged.
Double_t p1err
Its error, ADC.
Double_t p2err
Its error, us.
Double_t p1
Tail amplitude at dt = 0, ADC.
Double_t p2
Decay time, us.
One fitted correction: a channel's own, or a group's.
Double_t rms_before
Channel-deviation RMS before correction.
Double_t t_m_us
Read point after a pulse: rise + peaking.
Double_t r2
Coefficient of determination.
Double_t tau_us
The applied form's decay time: given or profiled.
Int_t j_tau
Grid index of the applied tau; internal.
Double_t FormAt(Int_t a, Double_t dt_us) const
The form at one gap for one band, per unit previous height.
Double_t rms_after_form
Deviation RMS after the form.
Double_t k_low[kMAX_AMP_BINS][kNBins]
Free coefficients, bins < n_free.
Long64_t n_beam
Beam-like events passing this group's selection.
Double_t EffectiveWindowUs(Int_t a) const
Effective restorer window implied by the fitted amplitudes, c tau / c_B, in microseconds; 0 when c_B ...
Double_t intercept_form
The form fit's intercept, ADC.
Double_t c[kMAX_AMP_BINS]
Direct-tail amplitude per band; > 0 undershoot.
Double_t r2_binned
And the binned fit's, for comparison.
Double_t k_binned[kMAX_AMP_BINS][kNBins]
The binned fit's coefficients, always kept so the form can be judged against them.
Double_t cb[kMAX_AMP_BINS]
Baseline-term amplitude per band.
Bool_t ok
Whether this kernel was successfully fitted.
Double_t t_lo_us
From where the form holds: (2 rise + flat) - t_m.
Int_t n_free
Bins below t_lo that stay free under the form.
Bool_t tau_given
Whether tau_us came from the configuration.
Long64_t n
(event, channel) pairs entering the fit.
Double_t rms_after_binned
TauFit tau
Summary of the dt profile, all hits.
Bool_t from_group
Channel kernels only: this is a copy of the group's kernel because the channel's own could not be fit...
Double_t tau_free_us
The profile's own preference, on the grid, and its fit quality: the check on a given tau_us.
Double_t r2_form
Coefficient of determination of the form.
Double_t r2_group
Channel kernels only: the R^2 the group's kernel reaches on this channel's pairs, so the gain from a ...
Double_t intercept
Fit intercept, in ADC.
Double_t rms_after
And after, so the gain is visible.
Double_t t_f_us
Baseline freeze after a trigger: 2 rise + flat.
Int_t n_amp
Amplitude bands actually used, at most kMAX_AMP_BINS.
Kernel()
Construct unfitted, with zeroed coefficients.
Double_t k[kMAX_AMP_BINS][kNBins]
The applied kernel at the bin centres, [amplitude band][dt bin]: the binned coefficients themselves,...
Everything one subfile's pulse-history pass produced.
TH1D * dev_after[kNGROUPS]
And after.
std::vector< TProfile * > dtprev_before_ch
Per channel index, deviation against time to previous pulse before and after the channel's own kernel...
~Result()
Frees any diagnostic histograms still held.
Long64_t n_corrected
Hits that received a correction.
std::vector< Double_t > mode
Beam peak per (board, channel) index, in ADC.
TH2D * dev_vs_pred[kNGROUPS]
Channel deviation against predicted shift.
void FreeDiagnostics()
Delete every diagnostic histogram and null the pointers.
Long64_t n_beam_events
Beam-like events the fit drew on.
TProfile * dtprev_after[kNGROUPS]
And after.
Bool_t enabled[kNGROUPS]
Whether the group was configured for correction.
TProfile * dtprev_before[kNGROUPS]
Deviation against time to previous pulse.
Long64_t n_clamped_group[kNGROUPS]
Clamps per group.
Long64_t n_seeds
Hits usable as a previous pulse.
Bool_t sorted_input
Whether the input arrived time-ordered.
std::vector< Int_t > group_of
The group map Measure() was given.
std::vector< TString > name_ch
Channel-map name per index.
Double_t mean_shift[kNGROUPS]
Mean subtracted term per group, ADC.
Long64_t n_clamped
Corrections clamped rather than applied in full.
std::vector< Kernel > kernel_ch
The applied kernels, one per (board, channel) index as in the group map (empty before Measure()): the...
Kernel kernel[kNGROUPS]
The group fits, one per Group: each the fit over the sum of its channels, the fallback for a channel ...
TH1D * shift[kNGROUPS]
Shift applied per hit.
std::vector< TProfile * > dtprev_after_ch
Result()
Construct with zeroed counters and null diagnostics.
Long64_t n_hits
Hits examined.
TH1D * dev_before[kNGROUPS]
Deviation distribution before correction.