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

Helpers for the 2-D beam-spot description. More...

#include <BeamFit2D.hpp>

Classes

struct  SpotFit
 Result of a beam spot fit: the spot to use, and whether the Gaussian fit (rather than the clipped-moments fallback) made it. More...

Static Public Member Functions

static Bool_t InEllipseXY (const BeamFit2D &b, Double_t x, Double_t y, Double_t n)
 Whether a point lies inside the fitted ellipse at n sigma: the correlation-aware Mahalanobis chi2 below n^2, one level, since a density contour has one.
static void DrawEllipse (const BeamFit2D &b, Double_t n, Color_t color)
 Draw the n-sigma contour of a fitted spot on the current pad.
static Moments2D ComputeMoments (TH2F *h, Int_t lo_bx, Int_t hi_bx, Int_t lo_by, Int_t hi_by, Double_t thresh, Double_t bw_x, Double_t bw_y)
 Second moments of a histogram region above a threshold.
static Moments2D ClippedMoments (const std::vector< std::pair< Float_t, Float_t > > &pts, const Moments2D &seed, Double_t clip=3.0)
 Sigma-clipped centroid and covariance of a point sample, the 2-D counterpart of the strip-width clip: each pass keeps the points within clip (Mahalanobis) of the current estimate and takes their mean and covariance, scaled up by the variance a 2-D Gaussian loses outside clip.
static Moments2D SeedSpotMoments (TH2F *h, Int_t seed_half_bins)
 Second moments of a coarse spot histogram's seed window: the maximum bin, ± seed_half_bins around it, over the bins at or above 0.3 of the peak.
static SpotFit FitSpotFromPoints (TH2F *h, std::vector< std::pair< Float_t, Float_t > > &pts, const Moments2D &seed)
 A beam spot from a coarse histogram and the same events unbinned: the sample's sigma-clipped moments seeded from seed, then a correlated Gaussian on a flat pedestal over a fine histogram re-binned around the clip — the inner 2 sigma fitted, the rest judged.
static BeamFit2D FitSpot (TH2F *h, const Moments2D &seed, Double_t window_nsigma=2.0, Double_t *chi2_ndf=nullptr)
 Fit a correlated 2-D Gaussian on a flat pedestal to h: ROOT's bigaus written out, Poisson likelihood, Minuit limits from seed.
static Bool_t FitPeak (TH1F *h, Double_t seed_mu, Double_t seed_sigma, Double_t window_nsigma, Bool_t fix_mu, Double_t &mu, Double_t &sigma, Double_t *chi2_ndf=nullptr)
 The 1-D counterpart: a Gaussian on a flat pedestal, fitted over window_nsigma of the seed and judged over the whole of h.

Detailed Description

Helpers for the 2-D beam-spot description.

Definition at line 42 of file BeamFit2D.hpp.

Member Function Documentation

◆ ClippedMoments()

Moments2D BeamFitUtils::ClippedMoments ( const std::vector< std::pair< Float_t, Float_t > > & pts,
const Moments2D & seed,
Double_t clip = 3.0 )
static

Sigma-clipped centroid and covariance of a point sample, the 2-D counterpart of the strip-width clip: each pass keeps the points within clip (Mahalanobis) of the current estimate and takes their mean and covariance, scaled up by the variance a 2-D Gaussian loses outside clip.

The widths are then a Gaussian's sigma for a Gaussian spot, and the clipped RMS of anything else; no binning or peak-fraction threshold enters.

Parameters
ptsThe (x, y) sample.
seedStarting estimate, e.g. ComputeMoments over the core. Its widths may be too narrow; the passes grow them.
clipMahalanobis radius kept per pass.
Returns
The converged moments; the seed when fewer than 10 points are kept.

Definition at line 94 of file BeamFit2D.cpp.

Referenced by FitSpotFromPoints().

◆ ComputeMoments()

Moments2D BeamFitUtils::ComputeMoments ( TH2F * h,
Int_t lo_bx,
Int_t hi_bx,
Int_t lo_by,
Int_t hi_by,
Double_t thresh,
Double_t bw_x,
Double_t bw_y )
static

Second moments of a histogram region above a threshold.

Parameters
hHistogram to measure. Must not be null.
lo_bxFirst x bin, inclusive.
hi_bxLast x bin, inclusive.
lo_byFirst y bin, inclusive.
hi_byLast y bin, inclusive.
threshBin contents at or below this are ignored, which keeps background out of the widths.
bw_xx bin width, for converting bin indices to physical units.
bw_yy bin width.
Returns
The moments; weight == 0 when nothing cleared thresh.

Definition at line 42 of file BeamFit2D.cpp.

Referenced by FindBeamGateStrips(), and SeedSpotMoments().

◆ DrawEllipse()

void BeamFitUtils::DrawEllipse ( const BeamFit2D & b,
Double_t n,
Color_t color )
static

Draw the n-sigma contour of a fitted spot on the current pad.

The correlated 2-D Gaussian's TEllipse rotated per the covariance eigen-decomposition, so the drawn contour is the InEllipseXY() gate (chi2 < n^2).

Parameters
bFitted spot; ok must be true.
nLevel, in sigma.
colorLine colour of the contour.

Definition at line 24 of file BeamFit2D.cpp.

Referenced by FindBeamGateStrips().

◆ FitPeak()

Bool_t BeamFitUtils::FitPeak ( TH1F * h,
Double_t seed_mu,
Double_t seed_sigma,
Double_t window_nsigma,
Bool_t fix_mu,
Double_t & mu,
Double_t & sigma,
Double_t * chi2_ndf = nullptr )
static

The 1-D counterpart: a Gaussian on a flat pedestal, fitted over window_nsigma of the seed and judged over the whole of h.

Parameters
hHistogram to fit, and to judge chi2 over; must not be null, and a couple of bins per seed sigma would do.
seed_muSeed centre; sets the fitted window and mu's limits.
seed_sigmaSeed width; positive, and sets the fitted window and sigma's limits at 0.2 to 5 times the seed.
window_nsigmaHalf-width fitted, in the seed's sigma.
fix_muHold the centre at seed_mu, for a distribution with more than one peak.
muFitted centre, untouched when the fit is rejected.
sigmaFitted width, untouched when the fit is rejected.
chi2_ndfReduced chi2 over the whole of h, so what the window excluded is what it notices; -1 if no fit ran.
Returns
kFALSE when the fit failed or ran away; mu and sigma are then untouched.

Definition at line 289 of file BeamFit2D.cpp.

◆ FitSpot()

BeamFit2D BeamFitUtils::FitSpot ( TH2F * h,
const Moments2D & seed,
Double_t window_nsigma = 2.0,
Double_t * chi2_ndf = nullptr )
static

Fit a correlated 2-D Gaussian on a flat pedestal to h: ROOT's bigaus written out, Poisson likelihood, Minuit limits from seed.

Parameters
hFinely binned spot reaching past the fit window; a couple of bins per sigma would fit the binning.
seedSets the window and the limits, e.g. ClippedMoments.
window_nsigmaHalf-width fitted, in the seed's sigma; narrow keeps a shoulder out of the width (+4 percent at 2, +10 at 4).
chi2_ndfReduced chi2 over the whole of h, so what the window excluded is what it notices; -1 if no fit ran.
Returns
ok == kFALSE when the fit failed or ran away: keep the seed.

Definition at line 206 of file BeamFit2D.cpp.

Referenced by FitSpotFromPoints().

◆ FitSpotFromPoints()

BeamFitUtils::SpotFit BeamFitUtils::FitSpotFromPoints ( TH2F * h,
std::vector< std::pair< Float_t, Float_t > > & pts,
const Moments2D & seed )
static

A beam spot from a coarse histogram and the same events unbinned: the sample's sigma-clipped moments seeded from seed, then a correlated Gaussian on a flat pedestal over a fine histogram re-binned around the clip — the inner 2 sigma fitted, the rest judged.

Parameters
hCoarse histogram; names the fine one and supplies the fallback amplitude.
ptsThe spot's events unbinned (up to a cap); consumed.
seedSeed moments, e.g. SeedSpotMoments(); weight must be > 0.
Returns
The spot: the fit when it holds, the clipped moments otherwise.

Definition at line 164 of file BeamFit2D.cpp.

Referenced by FindBeamGateStrips().

◆ InEllipseXY()

Bool_t BeamFitUtils::InEllipseXY ( const BeamFit2D & b,
Double_t x,
Double_t y,
Double_t n )
static

Whether a point lies inside the fitted ellipse at n sigma: the correlation-aware Mahalanobis chi2 below n^2, one level, since a density contour has one.

A Gaussian keeps 1 - exp(-n^2/2) inside.

Parameters
bFitted spot; ok must be true.
xPoint x coordinate.
yPoint y coordinate.
nLevel, in sigma.

Definition at line 9 of file BeamFit2D.cpp.

Referenced by CollectAnchorSamplesOneSubfile().

◆ SeedSpotMoments()

Moments2D BeamFitUtils::SeedSpotMoments ( TH2F * h,
Int_t seed_half_bins )
static

Second moments of a coarse spot histogram's seed window: the maximum bin, ± seed_half_bins around it, over the bins at or above 0.3 of the peak.

Parameters
hCoarse histogram of the spot, already filled.
seed_half_binsHalf-width of the seed window, in bins of h.
Returns
The moments; weight <= 0 when no bin clears the threshold.

Definition at line 147 of file BeamFit2D.cpp.

Referenced by FindBeamGateStrips().


The documentation for this class was generated from the following files: