1#ifndef GAMR_SPECT_FIT_HH
2#define GAMR_SPECT_FIT_HH
54 TGraph *gWidth = NULL;
57 TGraph *gSkewAmp = NULL;
58 TGraph *gSkew2 = NULL;
59 TGraph *gSkewAmp2 = NULL;
63 std::map<std::string,GamR::TK::FPeak*> fPeaks;
64 std::map<int, std::string> fPeakKeys;
65 std::map<std::string,int> fPeakEnFix;
72 std::map<std::string,PeakParams> fPeakParamInds;
75 for (
auto &peak : fPeaks) {
76 auto key = peak.first;
77 auto val = peak.second;
90 PeakFit(
double Low,
double High);
116 void SetOpts(Option_t *option);
118 void SetPeaks(std::vector<double> Peaks);
119 void SetPeaks(std::map<std::string,double> Peaks);
121 void SetGuesses(TH1* hist, std::map<std::string,GamR::TK::FPeak*> Peaks, std::vector<std::string> FixPeaks={});
122 void SetGuesses(TH1* hist, std::map<std::string,double> Peaks, std::vector<std::string> FixPeaks={});
123 void SetIndices(std::map<std::string,GamR::TK::FPeak*> Peaks);
124 void SetLimit(std::string peakKey, std::string parameterKey,
double lowerLimit,
double upperLimit);
129 void SetUp(TH1 *hist, std::map<std::string,double> Peaks, Option_t *option, std::vector<std::string> FixPeaks={}) {
136 void Fit(TH1* hist, Option_t *foption);
141 double GetAmp(std::string peakKey);
143 double GetCent(std::string peakKey);
145 double GetWidth(std::string peakKey);
147 double GetArea(std::string peakKey) {
return fPeaks[peakKey]->GetArea(); }
148 double GetAreaError(std::string peakKey) {
return fPeaks[peakKey]->GetAreaError(); }
159 void SetAmp(std::string peakKey,
double amp);
160 void SetAmpError(std::string peakKey,
double error);
161 void SetCent(std::string peakKey,
double centroid);
163 void SetWidth(std::string peakKey,
double width);
179 void ToText(std::string filename, std::string delimiter=
" ",
int nPoints=1000);
190 std::map<std::string,GamR::TK::FPeak*>
GetPeaks() {
return fPeaks; }
201 TF1 *
GetFunc(std::string peakKey) {
return fPeaks[peakKey]->GetFunc(); }
204 PeakFit *
FitPeaks(TH1 *hist,
double Low,
double High, std::map<std::string,double> Peaks, Option_t *foption =
"",
205 Option_t *option =
"", std::vector<std::string> FixEnergies = {});
206 PeakFit *
FitPeaks(TH1 *hist,
double Low,
double High, std::vector<double> Peaks, Option_t *foption =
"",
207 Option_t *option =
"", std::vector<std::string> FixEnergies = {});
208 PeakFit *
FitPeaks(TCanvas *canvas = gPad->GetCanvas(), Option_t *foption =
"", Option_t *option =
"");
210 TF1 *
FitGaussians(TH1 *hist,
double Low,
double High, std::map<std::string,double> Peaks, Option_t *foption =
"",
211 Option_t *option =
"");
212 TF1 *
FitGaussians(TH1 *hist,
double Low,
double High, std::vector<double> Peaks, Option_t *foption =
"",
213 Option_t *option =
"");
214 TF1 *
FitGaussians(TCanvas *canvas = gPad->GetCanvas(), Option_t *foption =
"", Option_t *option =
"");
216 TSpectrum *
FindPeaks(TCanvas *canvas = gPad->GetCanvas(),
double sigma = 2, Option_t *option=
"",
double threshold = 0.05);
double GetWidthError(int i)
void SetAmpError(int i, double error)
void SetWidth(std::string peakKey, double width)
double GetArea(std::string peakKey)
void SetCent(int i, double centroid)
void ToText(std::string filename, std::string delimiter=" ", int nPoints=1000)
TF1 * GetPeakBG(std::string peakKey)
TF1 * GetPeakStepBG(std::string peakKey)
void SetCentError(int i, double error)
GamR::TK::PeakType GetPeakType()
void SetPeaks(std::vector< double > Peaks)
void SetOpts(Option_t *option)
TF1 * GetPeakStepBG(int i)
TGraph * GetSkewAmpGraph()
PeakFitGuesses * fFitGuesses
void SetCentError(std::string peakKey, double error)
void SetAmp(int i, double amp)
double GetAreaError(int i)
void SetLimit(std::string peakKey, std::string parameterKey, double lowerLimit, double upperLimit)
double GetAmpError(std::string peakKey)
double GetCent(std::string peakKey)
std::map< std::string, GamR::TK::FPeak * > GetPeaks()
void SetParamCount(int i)
void SetWidthError(std::string peakKey, double error)
void SetCent(std::string peakKey, double centroid)
TF1 * GetFunc(std::string peakKey)
void SetHigh(double High)
GamR::TK::FPeak * Get(int i)
void SetAmp(std::string peakKey, double amp)
void AddPeak(std::string peakKey, GamR::TK::FPeak *peak)
void SetWidthError(int i, double error)
void SetUp(TH1 *hist, std::map< std::string, double > Peaks, Option_t *option, std::vector< std::string > FixPeaks={})
TGraph * GetSkewAmp2Graph()
void SetWidth(int i, double width)
void FixPeakEnergy(std::string peakKey)
double GetWidthError(std::string peakKey)
void SetResults(TH1 *hist)
TF1 * GetPeakGaussBG(std::string peakKey)
double GetCentError(int i)
GamR::TK::FPeak * Get(std::string peakKey)
void SetIndices(std::map< std::string, GamR::TK::FPeak * > Peaks)
double GetAmpError(int i)
void SetChi2(double Chi2)
double GetCentError(std::string peakKey)
double GetAmp(std::string peakKey)
void Fit(TH1 *hist, Option_t *foption)
TF1 * GetPeakGaussBG(int i)
double GetAreaError(std::string peakKey)
void SetAmpError(std::string peakKey, double error)
double GetWidth(std::string peakKey)
TF1 * FitGaussians(TH1 *hist, double Low, double High, std::vector< double > Peaks, Option_t *foption, Option_t *option)
TSpectrum * FindPeaks(TCanvas *canvas, double sigma, Option_t *option, double threshold)
GamR::Spect::PeakFit * FitPeaks(TH1 *hist, double Low, double High, std::vector< double > Peaks, Option_t *foption, Option_t *option, std::vector< std::string > FixPeaks)