GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TPeakFitter Class Reference

Detailed Description

This class is used to fit things that resemble "peaks" in data

Definition at line 31 of file TPeakFitter.h.

Public Member Functions

 TPeakFitter ()
 
 TPeakFitter (const Double_t &rangeLow, const Double_t &rangeHigh)
 
 TPeakFitter (const TPeakFitter &)=default
 
 TPeakFitter (TPeakFitter &&) noexcept=default
 
 ~TPeakFitter ()=default
 
void AddPeak (TSinglePeak *peak)
 
void DrawPeaks (Option_t *="") const
 
TFitResultPtr Fit (TH1 *fit_hist, Option_t *opt="")
 
TF1 * GetBackground ()
 
TF1 * GetFitFunction ()
 
Int_t GetNParameters () const
 
void InitializeBackgroundParameters (TH1 *fit_hist)
 
void InitializeParameters (TH1 *fit_hist)
 
TPeakFitteroperator= (const TPeakFitter &)=default
 
TPeakFitteroperator= (TPeakFitter &&) noexcept=default
 
void Print (Option_t *opt="") const override
 
void PrintParameters () const
 
void RemoveAllPeaks ()
 
void RemovePeak (TSinglePeak *peak)
 
void ResetInitFlag ()
 
void SetBackground (TF1 *bg_to_fit)
 
void SetColorIndex (const int &index)
 
void SetRange (const Double_t &low, const Double_t &high)
 

Private Member Functions

Double_t BackgroundFunction (Double_t *dim, Double_t *par)
 
Double_t DefaultBackgroundFunction (Double_t *dim, Double_t *par)
 
Double_t FitFunction (Double_t *dim, Double_t *par)
 
void ResetTotalFitFunction ()
 
void UpdateFitterParameters ()
 
void UpdatePeakParameters (const TFitResultPtr &fit_res, TH1 *fit_hist)
 

Private Attributes

TF1 * fBGToFit {nullptr}
 
int fColorIndex {0}
 
bool fInitFlag {false}
 
TH1 * fLastHistFit {nullptr}
 
MultiplePeak_t fPeaksToFit
 
Double_t fRangeHigh {0.}
 
Double_t fRangeLow {0.}
 
TF1 * fTotalFitFunction {nullptr}
 
+ Inheritance diagram for TPeakFitter:
+ Collaboration diagram for TPeakFitter:

Constructor & Destructor Documentation

◆ TPeakFitter() [1/4]

TPeakFitter::TPeakFitter ( )
inline

Definition at line 34 of file TPeakFitter.h.

◆ TPeakFitter() [2/4]

TPeakFitter::TPeakFitter ( const Double_t & rangeLow,
const Double_t & rangeHigh )

Definition at line 8 of file TPeakFitter.cxx.

References DefaultBackgroundFunction(), fBGToFit, fColorIndex, fRangeHigh, and fRangeLow.

◆ TPeakFitter() [3/4]

TPeakFitter::TPeakFitter ( const TPeakFitter & )
default

◆ TPeakFitter() [4/4]

TPeakFitter::TPeakFitter ( TPeakFitter && )
defaultnoexcept

◆ ~TPeakFitter()

TPeakFitter::~TPeakFitter ( )
default

Member Function Documentation

◆ AddPeak()

void TPeakFitter::AddPeak ( TSinglePeak * peak)
inline

Definition at line 42 of file TPeakFitter.h.

References fPeaksToFit, and ResetTotalFitFunction().

Referenced by main(), and TBGSubtraction::PeakComboSelected().

◆ BackgroundFunction()

Double_t TPeakFitter::BackgroundFunction ( Double_t * dim,
Double_t * par )
private

Definition at line 324 of file TPeakFitter.cxx.

References fBGToFit, and fPeaksToFit.

Referenced by UpdatePeakParameters().

◆ DefaultBackgroundFunction()

Double_t TPeakFitter::DefaultBackgroundFunction ( Double_t * dim,
Double_t * par )
private

Definition at line 380 of file TPeakFitter.cxx.

Referenced by TPeakFitter().

◆ DrawPeaks()

void TPeakFitter::DrawPeaks ( Option_t * = "") const

Definition at line 391 of file TPeakFitter.cxx.

References fColorIndex, fPeaksToFit, and fTotalFitFunction.

◆ Fit()

TFitResultPtr TPeakFitter::Fit ( TH1 * fit_hist,
Option_t * opt = "" )

Fit the histogram. Recognized options are "q" for a quiet fit, "retryfit" to retry a fit without parameter limits if one of the parameters got close to its limit. All options (apart from "retryfit") are passed on to the actual call to TH1::Fit.

Definition at line 77 of file TPeakFitter.cxx.

References TGRSIFunctions::CheckParameterErrors(), fBGToFit, fColorIndex, fInitFlag, FitFunction(), fLastHistFit, fPeaksToFit, fRangeHigh, fRangeLow, fTotalFitFunction, GetNParameters(), GREEN, InitializeBackgroundParameters(), InitializeParameters(), Print(), PrintParameters(), RED, RESET_COLOR, UpdateFitterParameters(), UpdatePeakParameters(), and YELLOW.

Referenced by TBGSubtraction::DoPeakFit(), and main().

◆ FitFunction()

Double_t TPeakFitter::FitFunction ( Double_t * dim,
Double_t * par )
private

Definition at line 309 of file TPeakFitter.cxx.

References fBGToFit, and fPeaksToFit.

Referenced by Fit().

◆ GetBackground()

TF1 * TPeakFitter::GetBackground ( )
inline

Definition at line 65 of file TPeakFitter.h.

References fBGToFit.

Referenced by main().

◆ GetFitFunction()

TF1 * TPeakFitter::GetFitFunction ( )
inline

Definition at line 66 of file TPeakFitter.h.

References fTotalFitFunction.

◆ GetNParameters()

Int_t TPeakFitter::GetNParameters ( ) const

Definition at line 58 of file TPeakFitter.cxx.

References fBGToFit, and fPeaksToFit.

Referenced by Fit().

◆ InitializeBackgroundParameters()

void TPeakFitter::InitializeBackgroundParameters ( TH1 * fit_hist)

Definition at line 338 of file TPeakFitter.cxx.

References fBGToFit, fPeaksToFit, fRangeHigh, and fRangeLow.

Referenced by Fit().

◆ InitializeParameters()

void TPeakFitter::InitializeParameters ( TH1 * fit_hist)

Definition at line 266 of file TPeakFitter.cxx.

References fPeaksToFit, fRangeHigh, and fRangeLow.

Referenced by Fit().

◆ operator=() [1/2]

TPeakFitter & TPeakFitter::operator= ( const TPeakFitter & )
default

◆ operator=() [2/2]

TPeakFitter & TPeakFitter::operator= ( TPeakFitter && )
defaultnoexcept

◆ Print()

void TPeakFitter::Print ( Option_t * opt = "") const
override

Print information from the fit, opt is passed along to each individual peaks Print function.

Definition at line 16 of file TPeakFitter.cxx.

References fBGToFit, fPeaksToFit, fRangeHigh, fRangeLow, and fTotalFitFunction.

Referenced by Fit().

◆ PrintParameters()

void TPeakFitter::PrintParameters ( ) const

Print the range of the fit and the parameters of each peak on a single line.

Definition at line 46 of file TPeakFitter.cxx.

References fPeaksToFit, fRangeHigh, and fRangeLow.

Referenced by Fit().

◆ RemoveAllPeaks()

void TPeakFitter::RemoveAllPeaks ( )
inline

Definition at line 52 of file TPeakFitter.h.

References fPeaksToFit, and ResetTotalFitFunction().

◆ RemovePeak()

void TPeakFitter::RemovePeak ( TSinglePeak * peak)
inline

Definition at line 47 of file TPeakFitter.h.

References fPeaksToFit, and ResetTotalFitFunction().

Referenced by TBGSubtraction::PeakComboSelected().

◆ ResetInitFlag()

void TPeakFitter::ResetInitFlag ( )
inline

Definition at line 72 of file TPeakFitter.h.

References fInitFlag.

Referenced by TBGSubtraction::DoPeakFit(), and TBGSubtraction::PeakComboSelected().

◆ ResetTotalFitFunction()

void TPeakFitter::ResetTotalFitFunction ( )
inlineprivate

Definition at line 80 of file TPeakFitter.h.

References fTotalFitFunction.

Referenced by AddPeak(), RemoveAllPeaks(), and RemovePeak().

◆ SetBackground()

void TPeakFitter::SetBackground ( TF1 * bg_to_fit)
inline

Definition at line 58 of file TPeakFitter.h.

References fBGToFit.

◆ SetColorIndex()

void TPeakFitter::SetColorIndex ( const int & index)
inline

Definition at line 74 of file TPeakFitter.h.

References fColorIndex.

◆ SetRange()

void TPeakFitter::SetRange ( const Double_t & low,
const Double_t & high )

Definition at line 71 of file TPeakFitter.cxx.

References fRangeHigh, and fRangeLow.

Referenced by TBGSubtraction::DoPeakFit().

◆ UpdateFitterParameters()

void TPeakFitter::UpdateFitterParameters ( )
private

This functions gets the parameters and their limits from the peak functions and sets them for the total fit function

Definition at line 273 of file TPeakFitter.cxx.

References fBGToFit, fPeaksToFit, and fTotalFitFunction.

Referenced by Fit().

◆ UpdatePeakParameters()

void TPeakFitter::UpdatePeakParameters ( const TFitResultPtr & fit_res,
TH1 * fit_hist )
private

Definition at line 174 of file TPeakFitter.cxx.

References BackgroundFunction(), fBGToFit, fPeaksToFit, fRangeHigh, fRangeLow, and fTotalFitFunction.

Referenced by Fit().

Member Data Documentation

◆ fBGToFit

◆ fColorIndex

int TPeakFitter::fColorIndex {0}
private

this index is added to the colors kRed for the total function and kMagenta for the individual peaks

Definition at line 103 of file TPeakFitter.h.

Referenced by TPeakFitter(), DrawPeaks(), Fit(), and SetColorIndex().

◆ fInitFlag

bool TPeakFitter::fInitFlag {false}
private

Definition at line 99 of file TPeakFitter.h.

Referenced by Fit(), and ResetInitFlag().

◆ fLastHistFit

TH1* TPeakFitter::fLastHistFit {nullptr}
private

Definition at line 101 of file TPeakFitter.h.

Referenced by Fit().

◆ fPeaksToFit

◆ fRangeHigh

Double_t TPeakFitter::fRangeHigh {0.}
private

◆ fRangeLow

Double_t TPeakFitter::fRangeLow {0.}
private

◆ fTotalFitFunction

TF1* TPeakFitter::fTotalFitFunction {nullptr}
private