38 Double_t range_high, Int_t num_peaks = 1,
39 const TString &info_label =
"");
61Double_t
Gaussian(Double_t *x, Double_t *par);
76Double_t
Step(Double_t *x, Double_t *par);
86Double_t
LowTail(Double_t *x, Double_t *par);
95Double_t
HighTail(Double_t *x, Double_t *par);
246 Float_t fit_range_low_;
247 Float_t fit_range_high_;
249 Bool_t use_flat_background_;
251 Bool_t use_low_exp_tail_;
252 Bool_t use_low_lin_tail_;
253 Bool_t use_high_exp_tail_;
255 Bool_t use_manual_init_;
257 Double_t tail_ratio_max_ = 100.0;
258 std::vector<Double_t> manual_params_;
260 Double_t EstimateBackground();
261 Double_t ClampToBounds(Int_t param_index, Double_t value);
263 void SaveInteractiveParams(
const TString &input_name,
264 const TString &peak_name);
265 Bool_t LoadInteractiveParams(
const TString &input_name,
266 const TString &peak_name);
268 void SortPeaksByMu(Int_t num_peaks);
269 void AppendPeakGraphs(std::vector<TGraph *> &components, Int_t param_offset,
270 Style_t line_style, TF1 *background, Int_t npts,
288 FittingUtils(TH1 *working_hist, Float_t fit_range_low, Float_t fit_range_high,
289 Bool_t use_flat_background = kFALSE, Bool_t use_step = kFALSE,
290 Bool_t use_low_exp_tail = kFALSE,
291 Bool_t use_low_lin_tail = kFALSE,
292 Bool_t use_high_exp_tail = kFALSE);
299 use_flat_background_ = use_flat_background;
303 void SetStep(Bool_t use_step = kTRUE) { use_step_ = use_step; }
307 use_low_exp_tail_ = use_low_exp_tail;
312 use_low_lin_tail_ = use_low_lin_tail;
317 use_high_exp_tail_ = use_high_exp_tail;
335 interactive_ = interactive;
357 use_manual_init_ = kFALSE;
358 manual_params_.clear();
380 const TString label =
"");
388 const TString label =
"");
396 const TString label =
"");
416 Double_t mu1_init, Double_t mu2_init);
Bool_t LaunchInteractiveFitEditor(TH1 *hist, TF1 *fit_func, Double_t range_low, Double_t range_high, Int_t num_peaks=1, const TString &info_label="")
void SetManualParameter(Int_t index, Double_t value)
Override one starting value.
void PlotFitDoublePeak(const TString input_name, const TString peak_name, const TString label="")
Draw and save the double-peak fit with its residual panel.
void SetFitFunction(TF1 *func)
Substitute a fit function of your own.
void PlotFitSinglePeak(const TString input_name, const TString peak_name, const TString label="")
Draw and save the single-peak fit with its residual panel.
void SetBackgroundModel(Bool_t use_flat_background)
Choose the background shape.
~FittingUtils()
Releases the fit function this object owns.
void SetStep(Bool_t use_step=kTRUE)
Offer the step shelf to the component search.
void SetTailRatioMax(Double_t ratio_max)
Cap the tail decay constants during fitting.
FitResult FitTriplePeak(const TString input_name, const TString peak_name, const FitResult &constrained_peaks, Double_t mu3_init)
Fit three peaks with the first two constrained by an earlier fit.
FitResult FitDoublePeak(const TString input_name, const TString peak_name, Double_t mu1_init, Double_t mu2_init)
Fit two peaks from centroid guesses.
void ClearManualParameters()
Discard manual starting values and return to automatic guesses.
FittingUtils(TH1 *working_hist, Float_t fit_range_low, Float_t fit_range_high, Bool_t use_flat_background=kFALSE, Bool_t use_step=kFALSE, Bool_t use_low_exp_tail=kFALSE, Bool_t use_low_lin_tail=kFALSE, Bool_t use_high_exp_tail=kFALSE)
Build a fitter for one histogram and range.
void SetInteractive(Bool_t interactive=kTRUE)
Open the GUI editor after the automated fit.
void SetLowLinTail(Bool_t use_low_lin_tail=kTRUE)
Offer the low-energy linear tail.
void PlotFitTriplePeak(const TString input_name, const TString peak_name, const TString label="")
Draw and save the triple-peak fit with its residual panel.
void SetManualParameters(const std::vector< Double_t > ¶ms)
Supply explicit starting values for every parameter.
TF1 * GetFitFunction()
The fit function, for inspection or manual adjustment.
void SetLowExpTail(Bool_t use_low_exp_tail=kTRUE)
Offer the low-energy exponential tail.
FitResult FitSinglePeak(const TString input_name, const TString peak_name)
Fit one peak, pruning components that do not earn their place.
void SetHighExpTail(Bool_t use_high_exp_tail=kTRUE)
Offer the high-energy exponential tail.
Raw model functions in TF1 form: f(Double_t *x, Double_t *par).
Double_t LinearBackground(Double_t *x, Double_t *par)
Straight-line background.
Double_t Step(Double_t *x, Double_t *par)
Resolution-smeared step shelf below the peak.
Double_t DoublePeakFunction(Double_t *x, Double_t *par)
Two peaks sharing one linear background.
Double_t PeakFunction(Double_t *x, Double_t *par)
One peak with every optional component, plus a linear background.
Double_t TriplePeakFunction(Double_t *x, Double_t *par)
Three peaks sharing one linear background.
Double_t Gaussian(Double_t *x, Double_t *par)
Gaussian peak.
Double_t LowTail(Double_t *x, Double_t *par)
Combined exponential and linear tail below the peak.
Double_t HighTail(Double_t *x, Double_t *par)
Exponential tail above the peak, from pileup.
One fitted parameter's value, error and proximity to its limits.
Bool_t has_limits
Whether the parameter was bounded.
Double_t error
Fitted uncertainty.
std::string name
Parameter name as RooFit knows it.
Bool_t near_lower
Sits within a small margin of lo.
Bool_t near_limit
Either of the two above.
Bool_t near_upper
Sits within a small margin of hi.
Double_t lo
Lower bound, if has_limits.
Double_t value
Fitted value.
Double_t hi
Upper bound, if has_limits.
Result of one fit: peaks, background, quality, and diagnostics.
Int_t cov_qual
Covariance quality: 0 Exact, 1 NotPositiveDefinite, 2 Approximate, 3 External.
Int_t fit_status
Minuit migrad status; 0 means success.
Double_t edm
Estimated distance to the minimum.
Double_t min_nll
Minimised negative log-likelihood.
std::vector< PeakFitResult > peaks
One entry per peak; 1 to 3 supported.
Bool_t valid
In the RooFit backend this is computed post hoc against the display binning, and drives component pru...
Int_t n_invalid_nll
Invalid NLL evaluations; -1 if unknown.
std::vector< FitParameterDiagnostic > parameter_diagnostics
One entry per fitted RooRealVar, peak and background alike.
Float_t lin_bkg_slope_error
Background slope.
Float_t reduced_chi2
Chi-squared per degree of freedom.
Float_t bkg_constant_error
Background offset.
Bool_t has_fit_diagnostics
Whether a RooFitResult was available, and hence whether the fields in this group mean anything.
Fitted parameters and errors for one peak.
Float_t mu_error
Centroid, in the histogram's x units.
Float_t high_exp_tail_amplitude
High-energy exponential tail scale.
Float_t low_lin_tail_amplitude
Low-energy linear tail scale.
Float_t high_exp_tail_ratio
High-energy exponential decay constant, in units of sigma.
Float_t low_exp_tail_amplitude
Low-energy exponential tail scale.
Float_t sigma_error
Gaussian resolution.
Float_t low_exp_tail_ratio
Low-energy exponential decay constant, in units of sigma.
Float_t low_lin_tail_slope
Slope of the linear tail factor.
Float_t gaus_amplitude_error
Gaussian scale.
Float_t low_lin_tail_slope_error
Float_t low_exp_tail_ratio_error
Float_t step_amplitude_error
Step shelf scale.
Float_t low_lin_tail_amplitude_error
Float_t high_exp_tail_amplitude_error
Float_t high_exp_tail_ratio_error
Float_t low_exp_tail_amplitude_error