|
Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
|
Binned chi-squared photopeak fitting over a TH1. More...
#include <FittingUtils.hpp>
Public Member Functions | |
| 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. | |
| ~FittingUtils () | |
| Releases the fit function this object owns. | |
| void | SetBackgroundModel (Bool_t use_flat_background) |
| Choose the background shape. | |
| void | SetStep (Bool_t use_step=kTRUE) |
| Offer the step shelf to the component search. | |
| void | SetLowExpTail (Bool_t use_low_exp_tail=kTRUE) |
| Offer the low-energy exponential tail. | |
| void | SetLowLinTail (Bool_t use_low_lin_tail=kTRUE) |
| Offer the low-energy linear tail. | |
| void | SetHighExpTail (Bool_t use_high_exp_tail=kTRUE) |
| Offer the high-energy exponential tail. | |
| void | SetInteractive (Bool_t interactive=kTRUE) |
| Open the GUI editor after the automated fit. | |
| void | SetTailRatioMax (Double_t ratio_max) |
| Cap the tail decay constants during fitting. | |
| void | SetManualParameters (const std::vector< Double_t > ¶ms) |
| Supply explicit starting values for every parameter. | |
| void | SetManualParameter (Int_t index, Double_t value) |
| Override one starting value. | |
| void | ClearManualParameters () |
| Discard manual starting values and return to automatic guesses. | |
| TF1 * | GetFitFunction () |
| The fit function, for inspection or manual adjustment. | |
| 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 | PlotFitDoublePeak (const TString input_name, const TString peak_name, const TString label="") |
| Draw and save the double-peak fit with its residual panel. | |
| void | PlotFitTriplePeak (const TString input_name, const TString peak_name, const TString label="") |
| Draw and save the triple-peak fit with its residual panel. | |
| FitResult | FitSinglePeak (const TString input_name, const TString peak_name) |
| Fit one peak, pruning components that do not earn their place. | |
| FitResult | FitDoublePeak (const TString input_name, const TString peak_name, Double_t mu1_init, Double_t mu2_init) |
| Fit two peaks from centroid guesses. | |
| FitResult | FitDoublePeak (const TString input_name, const TString peak_name, const PeakFitResult &constrained_peak, Double_t mu2_init) |
| Fit two peaks with the first constrained by an earlier fit. | |
| 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. | |
Binned chi-squared photopeak fitting over a TH1.
Construct with the histogram, the fit range, and which optional components the model should offer, then call one of the Fit* methods. Component selection is not final: the fitter tests the low-side components as a group and prunes those that do not improve the reduced chi-squared, and tests the high-energy tail separately.
Definition at line 242 of file FittingUtils.hpp.
| FittingUtils::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.
| working_hist | Histogram to fit. Borrowed, not owned; it must outlive this object. |
| fit_range_low | Lower fit bound, in the histogram's x units. |
| fit_range_high | Upper fit bound, in the histogram's x units. |
| use_flat_background | kTRUE for a constant background, kFALSE (default) for a linear one. |
| use_step | Enable the step shelf. |
| use_low_exp_tail | Enable the low-energy exponential tail. |
| use_low_lin_tail | Enable the low-energy linear tail. |
| use_high_exp_tail | Enable the high-energy exponential tail. |
Definition at line 331 of file FittingUtils.cpp.
| FittingUtils::~FittingUtils | ( | ) |
Releases the fit function this object owns.
Definition at line 453 of file FittingUtils.cpp.
|
inline |
Discard manual starting values and return to automatic guesses.
Definition at line 356 of file FittingUtils.hpp.
| FitResult FittingUtils::FitDoublePeak | ( | const TString | input_name, |
| const TString | peak_name, | ||
| const PeakFitResult & | constrained_peak, | ||
| Double_t | mu2_init ) |
Fit two peaks with the first constrained by an earlier fit.
Useful when one peak is well measured in isolation and the other is not: the known shape anchors the fit instead of floating freely.
| input_name | Input identifier. |
| peak_name | Peak identifier. |
| constrained_peak | Previously fitted peak supplying the constraint. |
| mu2_init | Starting centroid for the free peak. |
Definition at line 1765 of file FittingUtils.cpp.
| FitResult FittingUtils::FitDoublePeak | ( | const TString | input_name, |
| const TString | peak_name, | ||
| Double_t | mu1_init, | ||
| Double_t | mu2_init ) |
Fit two peaks from centroid guesses.
| input_name | Input identifier. |
| peak_name | Peak identifier. |
| mu1_init | Starting centroid for the first peak. |
| mu2_init | Starting centroid for the second. |
Definition at line 1222 of file FittingUtils.cpp.
| FitResult FittingUtils::FitSinglePeak | ( | const TString | input_name, |
| const TString | peak_name ) |
Fit one peak, pruning components that do not earn their place.
| input_name | Input identifier, used for saved parameters and output filenames. |
| peak_name | Peak identifier, used the same way. |
Definition at line 850 of file FittingUtils.cpp.
| FitResult FittingUtils::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.
| input_name | Input identifier. |
| peak_name | Peak identifier. |
| constrained_peaks | Previous result supplying the two constraints. |
| mu3_init | Starting centroid for the free peak. |
Definition at line 2167 of file FittingUtils.cpp.
|
inline |
The fit function, for inspection or manual adjustment.
Definition at line 363 of file FittingUtils.hpp.
| void FittingUtils::PlotFitDoublePeak | ( | const TString | input_name, |
| const TString | peak_name, | ||
| const TString | label = "" ) |
Draw and save the double-peak fit with its residual panel.
| input_name | Input identifier, used in the output filename. |
| peak_name | Peak identifier, used in the output filename. |
| label | Optional annotation drawn on the plot. |
Definition at line 732 of file FittingUtils.cpp.
Referenced by FitDoublePeak(), and FitDoublePeak().
| void FittingUtils::PlotFitSinglePeak | ( | const TString | input_name, |
| const TString | peak_name, | ||
| const TString | label = "" ) |
Draw and save the single-peak fit with its residual panel.
| input_name | Input identifier, used in the output filename. |
| peak_name | Peak identifier, used in the output filename. |
| label | Optional annotation drawn on the plot. |
Definition at line 616 of file FittingUtils.cpp.
Referenced by FitSinglePeak().
| void FittingUtils::PlotFitTriplePeak | ( | const TString | input_name, |
| const TString | peak_name, | ||
| const TString | label = "" ) |
Draw and save the triple-peak fit with its residual panel.
| input_name | Input identifier, used in the output filename. |
| peak_name | Peak identifier, used in the output filename. |
| label | Optional annotation drawn on the plot. |
Definition at line 778 of file FittingUtils.cpp.
Referenced by FitTriplePeak().
|
inline |
Choose the background shape.
| use_flat_background | kTRUE for constant, kFALSE for linear. |
Definition at line 298 of file FittingUtils.hpp.
|
inline |
Substitute a fit function of your own.
| func | Replacement function. |
Definition at line 371 of file FittingUtils.hpp.
|
inline |
Offer the high-energy exponential tail.
| use_high_exp_tail | kTRUE to enable. |
Definition at line 316 of file FittingUtils.hpp.
|
inline |
Open the GUI editor after the automated fit.
On the first run the editor opens once the automated fit finishes, and the accepted parameters and range are written to <plots_base>/fits/<peak_name>_<input_name>.fits. On later runs that file is loaded and the editor is skipped, so the manual step happens once. Delete the file to redo it.
| interactive | kTRUE to enable. |
Definition at line 334 of file FittingUtils.hpp.
|
inline |
Offer the low-energy exponential tail.
| use_low_exp_tail | kTRUE to enable. |
Definition at line 306 of file FittingUtils.hpp.
|
inline |
Offer the low-energy linear tail.
| use_low_lin_tail | kTRUE to enable. |
Definition at line 311 of file FittingUtils.hpp.
| void FittingUtils::SetManualParameter | ( | Int_t | index, |
| Double_t | value ) |
Override one starting value.
| index | Parameter index in the active model. |
| value | Initial value. |
Definition at line 517 of file FittingUtils.cpp.
| void FittingUtils::SetManualParameters | ( | const std::vector< Double_t > & | params | ) |
Supply explicit starting values for every parameter.
| params | Initial values, in the parameter order documented on the matching FittingFunctions model. Switches the fitter off its automatic initial-guess path. |
Definition at line 494 of file FittingUtils.cpp.
|
inline |
Offer the step shelf to the component search.
| use_step | kTRUE to enable. |
Definition at line 303 of file FittingUtils.hpp.
|
inline |
Cap the tail decay constants during fitting.
| ratio_max | Upper bound on any tail ratio, in units of sigma. Defaults to 100. |
Definition at line 340 of file FittingUtils.hpp.