Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
Loading...
Searching...
No Matches
FittingUtils.hpp File Reference

Binned chi-squared photopeak fitting on a TF1 + Minuit2 backend. More...

#include "PlottingUtils.hpp"
#include <TCanvas.h>
#include <TF1.h>
#include <TFile.h>
#include <TFitResult.h>
#include <TH1.h>
#include <TMath.h>
#include <TPad.h>
#include <TROOT.h>
#include <TSystem.h>
#include <TTree.h>
#include <fstream>
#include <iomanip>
Include dependency graph for FittingUtils.hpp:

Go to the source code of this file.

Classes

struct  PeakFitResult
 Fitted parameters and errors for one peak. More...
struct  FitParameterDiagnostic
 One fitted parameter's value, error and proximity to its limits. More...
struct  FitResult
 Result of one fit: peaks, background, quality, and diagnostics. More...
class  FittingUtils
 Binned chi-squared photopeak fitting over a TH1. More...

Namespaces

namespace  FittingFunctions
 Raw model functions in TF1 form: f(Double_t *x, Double_t *par).

Functions

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="")
Double_t FittingFunctions::Gaussian (Double_t *x, Double_t *par)
 Gaussian peak.
Double_t FittingFunctions::LinearBackground (Double_t *x, Double_t *par)
 Straight-line background.
Double_t FittingFunctions::Step (Double_t *x, Double_t *par)
 Resolution-smeared step shelf below the peak.
Double_t FittingFunctions::LowTail (Double_t *x, Double_t *par)
 Combined exponential and linear tail below the peak.
Double_t FittingFunctions::HighTail (Double_t *x, Double_t *par)
 Exponential tail above the peak, from pileup.
Double_t FittingFunctions::PeakFunction (Double_t *x, Double_t *par)
 One peak with every optional component, plus a linear background.
Double_t FittingFunctions::DoublePeakFunction (Double_t *x, Double_t *par)
 Two peaks sharing one linear background.
Double_t FittingFunctions::TriplePeakFunction (Double_t *x, Double_t *par)
 Three peaks sharing one linear background.

Detailed Description

Binned chi-squared photopeak fitting on a TF1 + Minuit2 backend.

The counterpart to RooFitUtils, which fits the same model by unbinned extended maximum likelihood. Both take the same constructor arguments, expose the same Set* component flags, and return the same FitResult, so a call site can swap one for the other. This backend is faster, because the model is evaluated pointwise and never normalised; the RooFit backend is the one to reach for when you need correct likelihood errors or simultaneous fits.

Saved interactive parameters use the .fits extension here and .roofits in the RooFit backend, so both can coexist for the same input.

Definition in file FittingUtils.hpp.

Function Documentation

◆ LaunchInteractiveFitEditor()

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 = "" )