40TH1F *FitAwmi_Create_Spectrum(
void) {
43 delete gROOT->FindObject(
"h");
59 std::cout <<
"created "
65 std::cout <<
"the total number of created peaks = " << npeaks
66 <<
" with sigma = " <<
sigma << std::endl;
72 TH1F *
h = FitAwmi_Create_Spectrum();
75 if (!cFit) cFit =
new TCanvas(
"cFit",
"cFit", 10, 10, 1000, 700);
79 Int_t nbins =
h->GetNbinsX();
84 for (i = 0; i < nbins; i++) source[i] =
h->GetBinContent(i + 1);
91 for(i = 0; i < nfound; i++) FixAmp[i] = FixPos[i] =
kFALSE;
95 Pos =
s->GetPositionX();
96 for (i = 0; i < nfound; i++) {
97 bin = 1 +
Int_t(Pos[i] + 0.5);
98 Amp[i] =
h->GetBinContent(bin);
113 delete gROOT->FindObject(
"d");
114 TH1F *
d =
new TH1F(*
h);
d->SetNameTitle(
"d",
"");
d->Reset(
"M");
115 for (i = 0; i < nbins; i++)
d->SetBinContent(i + 1, source[i]);
116 Double_t x1 =
d->GetBinCenter(1), dx =
d->GetBinWidth(1);
123 sigma *= dx; sigmaErr *= dx;
125 std::cout <<
"the total number of found peaks = " << nfound
126 <<
" with sigma = " <<
sigma <<
" (+-" << sigmaErr <<
")"
128 std::cout <<
"fit chi^2 = " << pfit->
GetChi() << std::endl;
129 for (i = 0; i < nfound; i++) {
130 bin = 1 +
Int_t(Positions[i] + 0.5);
131 Pos[i] =
d->GetBinCenter(bin);
132 Amp[i] =
d->GetBinContent(bin);
135 Positions[i] =
x1 + Positions[i] * dx;
136 PositionsErrors[i] *= dx;
138 AreasErrors[i] *= dx;
140 std::cout <<
"found "
141 << Positions[i] <<
" (+-" << PositionsErrors[i] <<
") "
142 << Amplitudes[i] <<
" (+-" << AmplitudesErrors[i] <<
") "
143 << Areas[i] <<
" (+-" << AreasErrors[i] <<
")"
146 d->SetLineColor(
kRed);
d->SetLineWidth(1);
150 h->GetListOfFunctions()->Remove(pm);
154 h->GetListOfFunctions()->Add(pm);
static const double x1[5]
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="")
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.
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.
static constexpr double s
constexpr Double_t Sqrt2()
Double_t Sqrt(Double_t x)
constexpr Double_t TwoPi()
#define dest(otri, vertexptr)