38TH1F *FitAwmi_Create_Spectrum(
void)
42 delete gROOT->FindObject(
"h");
62 std::cout <<
"the total number of created peaks = " << npeaks <<
" with sigma = " <<
sigma << std::endl;
69 TH1F *
h = FitAwmi_Create_Spectrum();
73 cFit =
new TCanvas(
"cFit",
"cFit", 10, 10, 1000, 700);
78 Int_t nbins =
h->GetNbinsX();
83 for (i = 0; i < nbins; i++)
84 source[i] =
h->GetBinContent(i + 1);
91 for (i = 0; i < nfound; i++)
92 FixAmp[i] = FixPos[i] =
kFALSE;
97 for (i = 0; i < nfound; i++) {
98 bin = 1 +
Int_t(Pos[i] + 0.5);
99 Amp[i] =
h->GetBinContent(bin);
113 delete gROOT->FindObject(
"d");
115 d->SetNameTitle(
"d",
"");
117 for (i = 0; i < nbins; i++)
118 d->SetBinContent(i + 1, source[i]);
130 std::cout <<
"the total number of found peaks = " << nfound <<
" with sigma = " <<
sigma <<
" (+-" << sigmaErr <<
")"
132 std::cout <<
"fit chi^2 = " << pfit->
GetChi() << std::endl;
133 for (i = 0; i < nfound; i++) {
134 bin = 1 +
Int_t(Positions[i] + 0.5);
135 Pos[i] =
d->GetBinCenter(bin);
136 Amp[i] =
d->GetBinContent(bin);
139 Positions[i] = x1 + Positions[i] * dx;
140 PositionsErrors[i] *= dx;
142 AreasErrors[i] *= dx;
144 std::cout <<
"found " << Positions[i] <<
" (+-" << PositionsErrors[i] <<
") " << Amplitudes[i] <<
" (+-"
145 << AmplitudesErrors[i] <<
") " << Areas[i] <<
" (+-" << AreasErrors[i] <<
")" << std::endl;
147 d->SetLineColor(
kRed);
152 h->GetListOfFunctions()->Remove(pm);
156 h->GetListOfFunctions()->Add(pm);
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
1-D histogram with a float per channel (see TH1 documentation)
A PolyMarker is defined by an array on N points in a 2-D space.
Advanced 1-dimensional spectra fitting functions.
void SetPeakParameters(Double_t sigma, Bool_t fixSigma, const Double_t *positionInit, const Bool_t *fixPosition, const Double_t *ampInit, const Bool_t *fixAmp)
This function sets the following fitting parameters of peaks:
Double_t * GetAmplitudesErrors() const
void FitAwmi(Double_t *source)
This function fits the source spectrum.
Double_t * GetAreasErrors() const
void GetSigma(Double_t &sigma, Double_t &sigmaErr)
This function gets the sigma parameter and its error.
Double_t * GetAreas() const
Double_t * GetAmplitudes() const
void SetFitParameters(Int_t xmin, Int_t xmax, Int_t numberIterations, Double_t alpha, Int_t statisticType, Int_t alphaOptim, Int_t power, Int_t fitTaylor)
This function sets the following fitting parameters:
Double_t * GetPositionsErrors() const
Double_t * GetPositions() const
Advanced Spectra Processing.
Int_t SearchHighRes(Double_t *source, Double_t *destVector, Int_t ssize, Double_t sigma, Double_t threshold, bool backgroundRemove, Int_t deconIterations, bool markov, Int_t averWindow)
Double_t * GetPositionX() const
constexpr Double_t Sqrt2()
Double_t Sqrt(Double_t x)
Returns the square root of x.
constexpr Double_t TwoPi()