created -9.7 11.9683 3
created -9.1 31.9154 8
created -8.5 31.9154 8
created -7.9 7.97885 2
created -7.3 23.9365 6
created -6.7 3.98942 1
created -6.1 15.9577 4
created -5.5 11.9683 3
created -4.9 3.98942 1
created -4.3 27.926 7
created -3.7 3.98942 1
created -3.1 27.926 7
created -2.5 3.98942 1
created -1.9 3.98942 1
created -1.3 27.926 7
created -0.7 23.9365 6
created -0.1 35.9048 9
created 0.5 31.9154 8
created 1.1 15.9577 4
created 1.7 39.8942 10
created 2.3 7.97885 2
created 2.9 23.9365 6
created 3.5 35.9048 9
created 4.1 11.9683 3
created 4.7 35.9048 9
created 5.3 7.97885 2
created 5.9 35.9048 9
created 6.5 15.9577 4
created 7.1 31.9154 8
created 7.7 27.926 7
created 8.3 3.98942 1
created 8.9 35.9048 9
created 9.5 27.926 7
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.23999e-05)
fit chi^2 = 4.90523e-06
found 1.7 (+-0.000305993) 39.8938 (+-0.120828) 10.0001 (+-0.00099157)
found -0.0999995 (+-0.000324511) 35.9048 (+-0.11471) 9.00018 (+-0.000941369)
found 3.5 (+-0.000323473) 35.9046 (+-0.114666) 9.00011 (+-0.000941003)
found 4.7 (+-0.000322458) 35.9044 (+-0.114623) 9.00006 (+-0.000940655)
found 5.9 (+-0.000322722) 35.9044 (+-0.114634) 9.00008 (+-0.000940745)
found 8.9 (+-0.000322873) 35.9045 (+-0.114643) 9.0001 (+-0.00094082)
found 0.499999 (+-0.000344194) 31.9154 (+-0.108151) 8.00017 (+-0.000887537)
found -9.1 (+-0.00034373) 31.9153 (+-0.108133) 8.00014 (+-0.000887391)
found -8.5 (+-0.000343364) 31.9153 (+-0.10812) 8.00013 (+-0.000887283)
found 7.1 (+-0.000343845) 31.9153 (+-0.108137) 8.00014 (+-0.000887421)
found 9.5 (+-0.000365479) 27.9262 (+-0.101099) 7.0002 (+-0.00082967)
found -4.3 (+-0.000364589) 27.9255 (+-0.101056) 7.00002 (+-0.000829317)
found -3.1 (+-0.000364589) 27.9255 (+-0.101056) 7.00002 (+-0.000829317)
found -1.3 (+-0.000366405) 27.9258 (+-0.101116) 7.00009 (+-0.000829803)
found 7.7 (+-0.000366828) 27.9259 (+-0.101131) 7.00012 (+-0.000829927)
found -7.3 (+-0.000394683) 23.9362 (+-0.0935832) 6.00004 (+-0.000767989)
found -0.699999 (+-0.000399203) 23.9369 (+-0.0937138) 6.00021 (+-0.000769061)
found 2.9 (+-0.000397474) 23.9367 (+-0.093664) 6.00014 (+-0.000768652)
found 1.1 (+-0.00049146) 15.9583 (+-0.0765705) 4.00023 (+-0.000628375)
found 6.5 (+-0.000491176) 15.9583 (+-0.0765644) 4.00022 (+-0.000628325)
found -6.1 (+-0.000485056) 15.9576 (+-0.0764415) 4.00005 (+-0.000627316)
found 4.1 (+-0.000569372) 11.969 (+-0.0663428) 3.00023 (+-0.000544442)
found -9.69999 (+-0.000564526) 11.9685 (+-0.0662624) 3.00011 (+-0.000543782)
found -5.5 (+-0.000561811) 11.9683 (+-0.0662257) 3.00007 (+-0.00054348)
found 5.3 (+-0.000700948) 7.97963 (+-0.0542094) 2.00023 (+-0.000444869)
found -7.9 (+-0.000698588) 7.97942 (+-0.0541828) 2.00018 (+-0.00044465)
found 2.3 (+-0.000699642) 7.97953 (+-0.0541949) 2.00021 (+-0.00044475)
found -6.7 (+-0.000992536) 3.98987 (+-0.0383392) 1.00013 (+-0.00031463)
found -3.7 (+-0.000997708) 3.99007 (+-0.0383694) 1.00018 (+-0.000314878)
found 8.3 (+-0.000999744) 3.99018 (+-0.0383817) 1.00021 (+-0.000314979)
found -2.50001 (+-0.000986411) 3.98977 (+-0.0383078) 1.00011 (+-0.000314373)
found -4.89999 (+-0.000991896) 3.98987 (+-0.0383362) 1.00013 (+-0.000314606)
found -1.89999 (+-0.000986411) 3.98977 (+-0.0383078) 1.00011 (+-0.000314373)
#include <iostream>
TH1F *FitAwmi_Create_Spectrum(
void) {
delete gROOT->FindObject(
"h");
npeaks++;
std::cout << "created "
<< area << std::endl;
}
std::cout << "the total number of created peaks = " << npeaks
<<
" with sigma = " <<
sigma << std::endl;
}
void FitAwmi(void) {
TH1F *
h = FitAwmi_Create_Spectrum();
if (!cFit) cFit =
new TCanvas(
"cFit",
"cFit", 10, 10, 1000, 700);
for (
i = 0;
i < nbins;
i++) source[
i] =
h->GetBinContent(
i + 1);
for(
i = 0;
i < nfound;
i++) FixAmp[
i] = FixPos[
i] =
kFALSE;
for (
i = 0;
i < nfound;
i++) {
bin = 1 +
Int_t(Pos[
i] + 0.5);
Amp[
i] =
h->GetBinContent(bin);
}
delete gROOT->FindObject(
"d");
TH1F *
d =
new TH1F(*
h);
d->SetNameTitle(
"d",
"");
d->Reset(
"M");
for (
i = 0;
i < nbins;
i++)
d->SetBinContent(
i + 1, source[
i]);
sigma *= dx; sigmaErr *= dx;
std::cout << "the total number of found peaks = " << nfound
<<
" with sigma = " <<
sigma <<
" (+-" << sigmaErr <<
")"
<< std::endl;
std::cout <<
"fit chi^2 = " << pfit->
GetChi() << std::endl;
for (
i = 0;
i < nfound;
i++) {
bin = 1 +
Int_t(Positions[
i] + 0.5);
Pos[
i] =
d->GetBinCenter(bin);
Amp[
i] =
d->GetBinContent(bin);
Positions[
i] =
x1 + Positions[
i] * dx;
PositionsErrors[
i] *= dx;
std::cout << "found "
<< Positions[
i] <<
" (+-" << PositionsErrors[
i] <<
") "
<< Amplitudes[
i] <<
" (+-" << AmplitudesErrors[
i] <<
") "
<< Areas[
i] <<
" (+-" << AreasErrors[
i] <<
")"
<< std::endl;
}
d->SetLineColor(
kRed);
d->SetLineWidth(1);
if (pm) {
h->GetListOfFunctions()->Remove(pm);
delete pm;
}
h->GetListOfFunctions()->Add(pm);
delete pfit;
delete [] Amp;
delete [] FixAmp;
delete [] FixPos;
delete s;
delete [] source;
return;
}
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)
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)
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()