created -9.82 26.5962 4
created -9.46 6.64904 1
created -9.1 19.9471 3
created -8.74 39.8942 6
created -8.38 59.8413 9
created -8.02 26.5962 4
created -7.66 33.2452 5
created -7.3 6.64904 1
created -6.94 13.2981 2
created -6.58 6.64904 1
created -6.22 59.8413 9
created -5.86 46.5433 7
created -5.5 39.8942 6
created -5.14 53.1923 8
created -4.78 26.5962 4
created -4.42 13.2981 2
created -4.06 26.5962 4
created -3.7 26.5962 4
created -3.34 19.9471 3
created -2.98 26.5962 4
created -2.62 26.5962 4
created -2.26 53.1923 8
created -1.9 13.2981 2
created -1.54 19.9471 3
created -1.18 6.64904 1
created -0.82 19.9471 3
created -0.46 13.2981 2
created -0.1 53.1923 8
created 0.26 26.5962 4
created 0.62 33.2452 5
created 0.98 26.5962 4
created 1.34 53.1923 8
created 1.7 6.64904 1
created 2.06 19.9471 3
created 2.42 46.5433 7
created 2.78 33.2452 5
created 3.14 46.5433 7
created 3.5 39.8942 6
created 3.86 13.2981 2
created 4.22 59.8413 9
created 4.58 26.5962 4
created 4.94 19.9471 3
created 5.3 59.8413 9
created 5.66 13.2981 2
created 6.02 66.4904 10
created 6.38 13.2981 2
created 6.74 53.1923 8
created 7.1 53.1923 8
created 7.46 13.2981 2
created 7.82 46.5433 7
created 8.18 33.2452 5
created 8.54 46.5433 7
created 8.9 13.2981 2
created 9.26 66.4904 10
created 9.62 59.8413 9
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.67127e-05)
fit chi^2 = 3.42973e-06
found 6.02 (+-0.000149594) 66.4901 (+-0.16434) 10 (+-0.000828966)
found 9.26 (+-0.000150265) 66.4904 (+-0.164428) 10.0001 (+-0.00082941)
found 9.62 (+-0.000157756) 59.8418 (+-0.155937) 9.00013 (+-0.000786578)
found -8.38 (+-0.000158547) 59.8414 (+-0.156005) 9.00007 (+-0.000786924)
found -6.22 (+-0.000158122) 59.8413 (+-0.15596) 9.00005 (+-0.000786695)
found 4.22 (+-0.000158049) 59.8412 (+-0.155948) 9.00004 (+-0.000786633)
found 5.3 (+-0.00015792) 59.8412 (+-0.155933) 9.00003 (+-0.000786558)
found 7.1 (+-0.000168158) 53.1924 (+-0.147085) 8.00007 (+-0.000741929)
found -5.14 (+-0.000168296) 53.1924 (+-0.147097) 8.00007 (+-0.00074199)
found -2.26 (+-0.000167743) 53.1922 (+-0.14704) 8.00004 (+-0.0007417)
found -0.0999998 (+-0.000167743) 53.1922 (+-0.14704) 8.00004 (+-0.0007417)
found 1.34 (+-0.000167498) 53.1922 (+-0.147016) 8.00003 (+-0.000741582)
found 6.74 (+-0.000168158) 53.1924 (+-0.147085) 8.00007 (+-0.000741929)
found -5.86 (+-0.000180648) 46.5436 (+-0.137667) 7.0001 (+-0.000694422)
found 2.42 (+-0.0001798) 46.5433 (+-0.137586) 7.00005 (+-0.000694014)
found 3.14 (+-0.000180223) 46.5434 (+-0.137626) 7.00007 (+-0.000694213)
found 7.82 (+-0.000179599) 46.5433 (+-0.137568) 7.00005 (+-0.000693924)
found 8.54 (+-0.000179599) 46.5433 (+-0.137568) 7.00005 (+-0.000693924)
found -8.74 (+-0.000194891) 39.8945 (+-0.127437) 6.00008 (+-0.000642821)
found -5.5 (+-0.0001954) 39.8946 (+-0.127478) 6.0001 (+-0.000643027)
found 3.5 (+-0.00019444) 39.8944 (+-0.127401) 6.00006 (+-0.000642636)
found -7.66 (+-0.000212411) 33.2452 (+-0.116262) 5.00003 (+-0.000586448)
found 0.62 (+-0.000213276) 33.2453 (+-0.116317) 5.00005 (+-0.000586728)
found 2.78 (+-0.000214271) 33.2456 (+-0.116387) 5.00009 (+-0.000587081)
found 8.18 (+-0.000214271) 33.2456 (+-0.116387) 5.00009 (+-0.000587081)
found -8.02 (+-0.000240007) 26.5966 (+-0.104126) 4.00009 (+-0.000525234)
found -4.78 (+-0.000239029) 26.5964 (+-0.104072) 4.00007 (+-0.000524962)
found -3.7 (+-0.0002386) 26.5963 (+-0.104046) 4.00005 (+-0.000524828)
found -2.62 (+-0.00023963) 26.5965 (+-0.104104) 4.00008 (+-0.000525125)
found 0.26 (+-0.000239858) 26.5966 (+-0.104117) 4.00009 (+-0.000525189)
found 0.98 (+-0.000239858) 26.5966 (+-0.104117) 4.00009 (+-0.000525189)
found 4.58 (+-0.000239511) 26.5965 (+-0.104099) 4.00008 (+-0.000525096)
found -9.82 (+-0.000237221) 26.596 (+-0.103964) 4.00001 (+-0.000524416)
found -4.06 (+-0.000238271) 26.5962 (+-0.104028) 4.00004 (+-0.00052474)
found -2.98 (+-0.0002386) 26.5963 (+-0.104046) 4.00005 (+-0.000524828)
found -3.34 (+-0.0002765) 19.9473 (+-0.0901477) 3.00005 (+-0.000454724)
found 4.94 (+-0.000277669) 19.9476 (+-0.0902) 3.00009 (+-0.000454988)
found -9.1 (+-0.000275677) 19.9473 (+-0.0901167) 3.00005 (+-0.000454567)
found -1.54 (+-0.000274386) 19.9471 (+-0.0900611) 3.00002 (+-0.000454287)
found -0.82 (+-0.000274386) 19.9471 (+-0.0900611) 3.00002 (+-0.000454287)
found 2.06 (+-0.000275902) 19.9473 (+-0.0901269) 3.00005 (+-0.000454619)
found 5.66 (+-0.000343549) 13.2988 (+-0.0737541) 2.00013 (+-0.000372031)
found 6.38 (+-0.000343278) 13.2988 (+-0.0737455) 2.00012 (+-0.000371988)
found -1.9 (+-0.000340869) 13.2985 (+-0.0736724) 2.00007 (+-0.000371619)
found 3.86 (+-0.000342408) 13.2987 (+-0.0737184) 2.0001 (+-0.000371851)
found 7.46 (+-0.000342464) 13.2987 (+-0.0737198) 2.0001 (+-0.000371858)
found 8.9 (+-0.000342982) 13.2987 (+-0.0737364) 2.00011 (+-0.000371942)
found -4.42 (+-0.000339979) 13.2983 (+-0.0736442) 2.00005 (+-0.000371477)
found -0.459998 (+-0.000340869) 13.2985 (+-0.0736724) 2.00007 (+-0.000371619)
found -6.94 (+-0.00033613) 13.2981 (+-0.0735363) 2.00001 (+-0.000370933)
found 1.7 (+-0.000486308) 6.64949 (+-0.0521609) 1.00007 (+-0.000263111)
found -7.3 (+-0.000483483) 6.64931 (+-0.0521159) 1.00005 (+-0.000262884)
found -9.46 (+-0.000483858) 6.64931 (+-0.0521207) 1.00005 (+-0.000262908)
found -6.58 (+-0.000485657) 6.64949 (+-0.0521524) 1.00007 (+-0.000263068)
found -1.18 (+-0.000482988) 6.64926 (+-0.0521072) 1.00004 (+-0.00026284)
#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()