MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
PulseHistory Namespace Reference

Classes

struct  Kernel
 One fitted correction: a channel's own, or a group's. More...
struct  Result
 Everything one subfile's pulse-history pass produced. More...

Enumerations

enum  ChannelGroup {
  kNONE = 0 , kLONG_LEFT = 1 , kLONG_RIGHT = 2 , kSHORT_LEFT = 3 ,
  kSHORT_RIGHT = 4 , kSTRIP0 = 5 , kSTRIP17 = 6 , kGRID = 7 ,
  kNGROUPS = 8
}
 Channel groups, one kernel each. More...

Functions

const char * GroupName (Int_t g)
 Human-readable name of a Group.
const char * GroupTag (Int_t g)
 Short tag for filenames: L, R, Ls, Rs, S0, S17.
Int_t ChainOf (Int_t g)
 Which readout chain a group belongs to.
Bool_t IsLongGroup (Int_t g)
 Whether a group is a long end rather than a short end or an unsegmented strip.
Bool_t GroupEnabled (Int_t g)
 Whether the groups in force (Constants::ActivePulseHistoryGroups()) have this group corrected.
Bool_t GroupWantsForm (Int_t g)
 Whether the configuration asks for the pole-zero form on this group rather than the binned kernel.
Double_t GroupTauUs (Int_t g)
 The preamp decay time the configuration gives for this group, in microseconds; 0 when it is to be profiled.
Int_t BinOf (Double_t dt_s)
 Kernel bin for a time since the previous pulse.
Double_t BinCentreUs (Int_t b)
 Centre of a kernel bin, in microseconds, for reports.
Int_t AmpBinOf (Double_t e_prev, Double_t mode, Int_t n_amp)
 Amplitude band of a previous pulse.
std::vector< Int_t > BuildGroupMap ()
 Group lookup for every (board, channel) under the active map.
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.
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.
TString Report (const Result &res, const TString &file_label, Bool_t detail=kTRUE)
 Format the pass as a human-readable report.
void SavePlots (Result &res, const TString &file_label)
 Draw and save the diagnostics, then free them.
void WriteToEventsFile (const TString &events_subpath, const Result &res)
 Record the kernels and counters alongside a subfile's events.
void FitTauDecay (const std::vector< Double_t > &dt_us, const std::vector< Double_t > &dev, Kernel::TauFit &out)
 p0 + p1 exp(-dt / p2) + p3 dt through (dt us, deviation ADC) pairs, the form the pole-zero residual plus the slow baseline lift takes.
TString BandLabel (Int_t a, Int_t n_amp, Bool_t latex)

Variables

const UInt_t kFlagClamped = 0x2000
 Flag set on a hit whose correction was clamped rather than applied in full.
const Int_t kNBins = 30
 Bins in the kernel, spanning kLogLo to kLogHi in log10 of dt: twelve per decade, 0.083 dex each.
const Double_t kLogLo = -6.0
 Lowest dt bin edge: log10 of 1 us in seconds.
const Double_t kLogHi
 Highest dt bin edge: log10 of 316 us in seconds.
const Int_t kMAX_AMP_BINS = 6
 Maximum amplitude bands a kernel may split the previous pulse into.
const Long64_t kMinPairsPerChannel = 2000
 Fewest (event, channel) pairs a channel needs for a kernel of its own; below it the channel is corrected with its group's kernel.
Pole-zero kernel analytic form

The preamp decay time of the analytic form (see kANALYTIC) is not linear in the fit, so it is profiled: the linear coefficients are solved for every tau of a logarithmic grid from kTauGridLoUs to kTauGridHiUs and the tau with the smallest residual is kept.

The grid step is the resolution of the profiled tau, about 15 percent at kNTauGrid = 21. A tau given in the configuration is solved for as well, at its exact value. The grid is the main cost of the fit scan: two features per tau, band and past pulse, so halving it roughly halves the pulse-history time when the form is on.

const Int_t kNTauGrid = 21
const Double_t kTauGridLoUs = 4.0
const Double_t kTauGridHiUs = 64.0
Decay-time fit

Every fitted kernel's group additionally summarises the pre-correction deviation-against-dt profile with p0 + p1 exp(-dt / p2) + p3 dt over this window in microseconds.

p2 is the preamp decay time the pole-zero setting failed to cancel. The window starts after the trapezoid freeze (holdoff plus margin, where the deviation follows the residual itself) and ends inside the kernel reach, where the profile still carries the tail and the linear term has not drowned it.

const Double_t kTauFitLoUs = 8.0
const Double_t kTauFitHiUs = 130.0
const Int_t kTauFitMinEntries = 100
 Below this many (event, channel) pairs in the window the fit is skipped.

Enumeration Type Documentation

◆ ChannelGroup

Channel groups, one kernel each.

The long and short end of the segmented strips on either chain, plus the two unsegmented strips 0 and 17.

Note
A short end fires in only a fraction of beam events and its height follows the track position, so its kernel is fitted on the fired hits alone and describes a smaller share of its variance than a long end's.
Enumerator
kNONE 

Not part of any corrected group.

kLONG_LEFT 

Long end, left chain.

kLONG_RIGHT 

Long end, right chain.

kSHORT_LEFT 

Short end, left chain.

kSHORT_RIGHT 

Short end, right chain.

kSTRIP0 

Strip 0, unsegmented.

kSTRIP17 

Strip 17, unsegmented.

kGRID 

The Frisch grid: the seed channel, one per event.

kNGROUPS 

Count of groups; not a group itself.

Definition at line 84 of file PulseHistory.hpp.

Function Documentation

◆ AmpBinOf()

Int_t PulseHistory::AmpBinOf ( Double_t e_prev,
Double_t mode,
Int_t n_amp )

Amplitude band of a previous pulse.

Parameters
e_prevPrevious pulse energy, in ADC.
modeThat channel's beam peak, in ADC.
n_ampBands in use for this kernel.
Returns
The band index.

Definition at line 250 of file PulseHistory.cpp.

◆ Apply()

void PulseHistory::Apply ( std::vector< RawHit > & hits,
const std::vector< Int_t > & group_of,
Result & res )

Apply the measured kernels to the hit stream, in place.

Parameters
[in,out]hitsHits to correct.
group_ofGroup per channel, from BuildGroupMap().
[in,out]resKernels to apply, each channel's own from Result::kernel_ch; its clamp and shift counters are updated as it goes.
Note
Only bins up to Constants::cfg.PULSE_HISTORY_APPLY_MAX_US are used. Beyond that the fitted coefficients are degenerate with the intercept and physically zero, so applying them would add noise rather than remove it.

Definition at line 1320 of file PulseHistory.cpp.

Referenced by RunFusedPipelineForFile().

◆ BandLabel()

TString PulseHistory::BandLabel ( Int_t a,
Int_t n_amp,
Bool_t latex )

Definition at line 260 of file PulseHistory.cpp.

Referenced by Report(), and SavePlots().

◆ BinCentreUs()

Double_t PulseHistory::BinCentreUs ( Int_t b)

Centre of a kernel bin, in microseconds, for reports.

Parameters
bBin index.

Definition at line 201 of file PulseHistory.cpp.

Referenced by Report().

◆ BinOf()

Int_t PulseHistory::BinOf ( Double_t dt_s)

Kernel bin for a time since the previous pulse.

Parameters
dt_sTime difference, in seconds.
Returns
The bin index, or -1 outside the kernel's range.

Definition at line 192 of file PulseHistory.cpp.

Referenced by PulseHistory::Kernel::FormAt(), Measure(), and Report().

◆ BuildGroupMap()

std::vector< Int_t > PulseHistory::BuildGroupMap ( )

Group lookup for every (board, channel) under the active map.

Returns
A vector indexed as the channel map is, holding a Group per channel.

Definition at line 271 of file PulseHistory.cpp.

Referenced by RunFusedPipelineForFile().

◆ ChainOf()

Int_t PulseHistory::ChainOf ( Int_t g)

Which readout chain a group belongs to.

Returns
0 for the left chain, 1 for the right, -1 for strips 0/17.

Definition at line 73 of file PulseHistory.cpp.

◆ FitTauDecay()

void PulseHistory::FitTauDecay ( const std::vector< Double_t > & dt_us,
const std::vector< Double_t > & dev,
Kernel::TauFit & out )

p0 + p1 exp(-dt / p2) + p3 dt through (dt us, deviation ADC) pairs, the form the pole-zero residual plus the slow baseline lift takes.

A p1 within 2 sigma of zero, or a p2 pinned at a limit, means the profile has no decay to measure: the group's pole-zero is matched, and a decay time off such a fit is noise.

Definition at line 211 of file PulseHistory.cpp.

Referenced by Measure().

◆ GroupEnabled()

Bool_t PulseHistory::GroupEnabled ( Int_t g)

Whether the groups in force (Constants::ActivePulseHistoryGroups()) have this group corrected.

A disabled group gets no kernel and no correction but still takes part in the beam-like selection.

Definition at line 111 of file PulseHistory.cpp.

Referenced by Measure().

◆ GroupName()

const char * PulseHistory::GroupName ( Int_t g)

Human-readable name of a Group.

Definition at line 33 of file PulseHistory.cpp.

Referenced by Measure(), and Report().

◆ GroupTag()

const char * PulseHistory::GroupTag ( Int_t g)

Short tag for filenames: L, R, Ls, Rs, S0, S17.

Definition at line 53 of file PulseHistory.cpp.

Referenced by Measure(), and SavePlots().

◆ GroupTauUs()

Double_t PulseHistory::GroupTauUs ( Int_t g)

The preamp decay time the configuration gives for this group, in microseconds; 0 when it is to be profiled.

Definition at line 121 of file PulseHistory.cpp.

Referenced by Measure().

◆ GroupWantsForm()

Bool_t PulseHistory::GroupWantsForm ( Int_t g)

Whether the configuration asks for the pole-zero form on this group rather than the binned kernel.

Definition at line 116 of file PulseHistory.cpp.

Referenced by Measure().

◆ IsLongGroup()

Bool_t PulseHistory::IsLongGroup ( Int_t g)

Whether a group is a long end rather than a short end or an unsegmented strip.

Definition at line 85 of file PulseHistory.cpp.

Referenced by Measure().

◆ Measure()

Bool_t PulseHistory::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.

Parameters
[in,out]hitsRaw hits for the subfile. Sorted in place if not already time-ordered, which the event builder needs anyway.
group_ofGroup per channel, from BuildGroupMap().
[out]resFitted kernels and diagnostics.
file_labelLabel from FileSet::FileLabel(), used in plots and logs.
Returns
kFALSE when no channel could be fitted.
Todo
Always pass through pulse history, and sort here before event building by default, so the CUDA sort can be used.

Definition at line 971 of file PulseHistory.cpp.

Referenced by RunFusedPipelineForFile().

◆ Report()

TString PulseHistory::Report ( const Result & res,
const TString & file_label,
Bool_t detail = kTRUE )

Format the pass as a human-readable report.

Parameters
resResult to summarise.
file_labelSubfile label.
detailFull report (form lines, kernel rows, tau fit, one line per channel) or, when false, the header and one line per group with its R^2 and rms before and after; the pipeline passes Constants::FileInSample().

Definition at line 1409 of file PulseHistory.cpp.

Referenced by RunFusedPipelineForFile().

◆ SavePlots()

void PulseHistory::SavePlots ( Result & res,
const TString & file_label )

Draw and save the diagnostics, then free them.

Parameters
[in,out]resResult whose histograms are drawn and then deleted.
file_labelSubfile label, used in the plot names.

Definition at line 1674 of file PulseHistory.cpp.

Referenced by RunFusedPipelineForFile().

◆ WriteToEventsFile()

void PulseHistory::WriteToEventsFile ( const TString & events_subpath,
const Result & res )

Record the kernels and counters alongside a subfile's events.

Parameters
events_subpathEvents file to write into.
resResult to record.

Definition at line 1843 of file PulseHistory.cpp.

Referenced by RunFusedPipelineForFile().

Variable Documentation

◆ kFlagClamped

const UInt_t PulseHistory::kFlagClamped = 0x2000

Flag set on a hit whose correction was clamped rather than applied in full.

Definition at line 33 of file PulseHistory.hpp.

Referenced by Apply().

◆ kLogHi

const Double_t PulseHistory::kLogHi
Initial value:
=
-3.5

Highest dt bin edge: log10 of 316 us in seconds.

Definition at line 38 of file PulseHistory.hpp.

Referenced by BinCentreUs(), BinOf(), Measure(), Report(), and SavePlots().

◆ kLogLo

const Double_t PulseHistory::kLogLo = -6.0

Lowest dt bin edge: log10 of 1 us in seconds.

Definition at line 37 of file PulseHistory.hpp.

Referenced by BinCentreUs(), BinOf(), Measure(), Report(), and SavePlots().

◆ kMAX_AMP_BINS

const Int_t PulseHistory::kMAX_AMP_BINS = 6

Maximum amplitude bands a kernel may split the previous pulse into.

Definition at line 41 of file PulseHistory.hpp.

Referenced by PulseHistory::Kernel::EffectiveWindowUs(), PulseHistory::Kernel::FormAt(), PulseHistory::Kernel::Kernel(), Measure(), and WriteToEventsFile().

◆ kMinPairsPerChannel

const Long64_t PulseHistory::kMinPairsPerChannel = 2000

Fewest (event, channel) pairs a channel needs for a kernel of its own; below it the channel is corrected with its group's kernel.

Definition at line 44 of file PulseHistory.hpp.

Referenced by Measure().

◆ kNBins

const Int_t PulseHistory::kNBins = 30

Bins in the kernel, spanning kLogLo to kLogHi in log10 of dt: twelve per decade, 0.083 dex each.

Definition at line 36 of file PulseHistory.hpp.

Referenced by BinCentreUs(), BinOf(), PulseHistory::Kernel::Kernel(), Measure(), Report(), SavePlots(), and WriteToEventsFile().

◆ kNTauGrid

const Int_t PulseHistory::kNTauGrid = 21

Definition at line 55 of file PulseHistory.hpp.

Referenced by Measure().

◆ kTauFitHiUs

const Double_t PulseHistory::kTauFitHiUs = 130.0

Definition at line 69 of file PulseHistory.hpp.

Referenced by FitTauDecay().

◆ kTauFitLoUs

const Double_t PulseHistory::kTauFitLoUs = 8.0

Definition at line 68 of file PulseHistory.hpp.

Referenced by FitTauDecay().

◆ kTauFitMinEntries

const Int_t PulseHistory::kTauFitMinEntries = 100

Below this many (event, channel) pairs in the window the fit is skipped.

Definition at line 71 of file PulseHistory.hpp.

Referenced by FitTauDecay().

◆ kTauGridHiUs

const Double_t PulseHistory::kTauGridHiUs = 64.0

Definition at line 57 of file PulseHistory.hpp.

Referenced by Measure().

◆ kTauGridLoUs

const Double_t PulseHistory::kTauGridLoUs = 4.0

Definition at line 56 of file PulseHistory.hpp.

Referenced by Measure().