39TH1F *FitAwmi_Create_Spectrum(
void) {
58 std::cout <<
"created "
64 std::cout <<
"the total number of created peaks = " << npeaks
65 <<
" with sigma = " <<
sigma << std::endl;
71 TH1F *
h = FitAwmi_Create_Spectrum();
74 if (!cFit) cFit =
new TCanvas(
"cFit",
"cFit", 10, 10, 1000, 700);
78 Int_t nbins =
h->GetNbinsX();
83 for (i = 0; i < nbins; i++) source[i] =
h->GetBinContent(i + 1);
90 for(i = 0; i < nfound; i++) FixAmp[i] = FixPos[i] =
kFALSE;
95 for (i = 0; i < nfound; i++) {
96 bin = 1 +
Int_t(Pos[i] + 0.5);
97 Amp[i] =
h->GetBinContent(bin);
112 delete gROOT->FindObject(
"d");
113 TH1F *
d =
new TH1F(*
h);
d->SetNameTitle(
"d",
"");
d->Reset(
"M");
114 for (i = 0; i < nbins; i++)
d->SetBinContent(i + 1, source[i]);
115 Double_t x1 =
d->GetBinCenter(1), dx =
d->GetBinWidth(1);
122 sigma *= dx; sigmaErr *= dx;
124 std::cout <<
"the total number of found peaks = " << nfound
125 <<
" with sigma = " <<
sigma <<
" (+-" << sigmaErr <<
")"
127 std::cout <<
"fit chi^2 = " << pfit->
GetChi() << std::endl;
128 for (i = 0; i < nfound; i++) {
129 bin = 1 +
Int_t(Positions[i] + 0.5);
130 Pos[i] =
d->GetBinCenter(bin);
131 Amp[i] =
d->GetBinContent(bin);
134 Positions[i] =
x1 + Positions[i] * dx;
135 PositionsErrors[i] *= dx;
137 AreasErrors[i] *= dx;
139 std::cout <<
"found "
140 << Positions[i] <<
" (+-" << PositionsErrors[i] <<
") "
141 << Amplitudes[i] <<
" (+-" << AmplitudesErrors[i] <<
") "
142 << Areas[i] <<
" (+-" << AreasErrors[i] <<
")"
145 d->SetLineColor(
kRed);
d->SetLineWidth(1);
149 h->GetListOfFunctions()->Remove(pm);
153 h->GetListOfFunctions()->Add(pm);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char x1
R__EXTERN TRandom * gRandom
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)
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
A PolyMarker is defined by an array on N points in a 2-D space.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
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)
One-dimensional high-resolution peak search function.
Double_t * GetPositionX() const
constexpr Double_t Sqrt2()
Double_t Sqrt(Double_t x)
Returns the square root of x.
constexpr Double_t TwoPi()