created -9.82 66.4904 10
created -9.46 59.8413 9
created -9.1 26.5962 4
created -8.74 53.1923 8
created -8.38 53.1923 8
created -8.02 26.5962 4
created -7.66 59.8413 9
created -7.3 13.2981 2
created -6.94 39.8942 6
created -6.58 13.2981 2
created -6.22 46.5433 7
created -5.86 33.2452 5
created -5.5 33.2452 5
created -5.14 19.9471 3
created -4.78 26.5962 4
created -4.42 59.8413 9
created -4.06 6.64904 1
created -3.7 66.4904 10
created -3.34 19.9471 3
created -2.98 53.1923 8
created -2.62 53.1923 8
created -2.26 13.2981 2
created -1.9 33.2452 5
created -1.54 6.64904 1
created -1.18 6.64904 1
created -0.82 33.2452 5
created -0.46 53.1923 8
created -0.1 59.8413 9
created 0.26 59.8413 9
created 0.62 13.2981 2
created 0.98 6.64904 1
created 1.34 53.1923 8
created 1.7 19.9471 3
created 2.06 6.64904 1
created 2.42 6.64904 1
created 2.78 59.8413 9
created 3.14 66.4904 10
created 3.5 39.8942 6
created 3.86 26.5962 4
created 4.22 39.8942 6
created 4.58 19.9471 3
created 4.94 66.4904 10
created 5.3 66.4904 10
created 5.66 6.64904 1
created 6.02 13.2981 2
created 6.38 39.8942 6
created 6.74 59.8413 9
created 7.1 13.2981 2
created 7.46 13.2981 2
created 7.82 19.9471 3
created 8.18 46.5433 7
created 8.54 33.2452 5
created 8.9 26.5962 4
created 9.26 66.4904 10
created 9.62 39.8942 6
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.30166e-05)
fit chi^2 = 2.30433e-06
found -9.82 (+-0.000123468) 66.4903 (+-0.134804) 10.0001 (+-0.00067998)
found -3.7 (+-0.000122574) 66.4901 (+-0.134701) 10 (+-0.000679462)
found 3.14 (+-0.000123543) 66.4906 (+-0.134825) 10.0001 (+-0.000680087)
found 4.94 (+-0.00012334) 66.4905 (+-0.1348) 10.0001 (+-0.000679958)
found 5.3 (+-0.000123055) 66.4904 (+-0.134766) 10.0001 (+-0.000679787)
found 9.26 (+-0.000123205) 66.4904 (+-0.13478) 10.0001 (+-0.000679859)
found -9.46 (+-0.000130212) 59.8416 (+-0.127906) 9.00009 (+-0.000645184)
found -0.0999999 (+-0.000130467) 59.8417 (+-0.127936) 9.00011 (+-0.000645336)
found 0.26 (+-0.000129916) 59.8414 (+-0.127872) 9.00007 (+-0.000645011)
found -7.66 (+-0.000129549) 59.8412 (+-0.127827) 9.00004 (+-0.000644785)
found -4.42 (+-0.000129369) 59.8411 (+-0.127808) 9.00003 (+-0.000644688)
found 2.78 (+-0.00012979) 59.8414 (+-0.12786) 9.00007 (+-0.000644951)
found 6.74 (+-0.000129719) 59.8413 (+-0.127847) 9.00005 (+-0.000644887)
found -8.38 (+-0.000138101) 53.1925 (+-0.120589) 8.00008 (+-0.000608277)
found -2.62 (+-0.000137835) 53.1924 (+-0.120562) 8.00007 (+-0.000608141)
found -8.74 (+-0.000138101) 53.1925 (+-0.120589) 8.00008 (+-0.000608277)
found -2.98 (+-0.000137982) 53.1924 (+-0.120577) 8.00007 (+-0.000608215)
found -0.46 (+-0.00013827) 53.1926 (+-0.120607) 8.00009 (+-0.000608369)
found 1.34 (+-0.000137177) 53.1921 (+-0.120494) 8.00002 (+-0.000607796)
found -6.22 (+-0.000147213) 46.5433 (+-0.112762) 7.00005 (+-0.000568793)
found 8.18 (+-0.000147378) 46.5433 (+-0.112776) 7.00005 (+-0.000568867)
found 3.5 (+-0.000159982) 39.8946 (+-0.104477) 6.00009 (+-0.000527002)
found 9.62 (+-0.000158657) 39.8947 (+-0.104388) 6.00011 (+-0.000526555)
found -6.94 (+-0.000158695) 39.8941 (+-0.104372) 6.00003 (+-0.000526474)
found 4.22 (+-0.000159222) 39.8943 (+-0.104413) 6.00005 (+-0.000526682)
found 6.38 (+-0.000159557) 39.8944 (+-0.104443) 6.00007 (+-0.000526832)
found -5.86 (+-0.000175377) 33.2455 (+-0.0953816) 5.00008 (+-0.000481125)
found -5.5 (+-0.00017479) 33.2453 (+-0.0953409) 5.00005 (+-0.00048092)
found -1.9 (+-0.000173713) 33.2451 (+-0.0952704) 5.00002 (+-0.000480564)
found -0.819999 (+-0.000174619) 33.2454 (+-0.0953334) 5.00006 (+-0.000480882)
found 8.54 (+-0.000175223) 33.2455 (+-0.0953711) 5.00007 (+-0.000481072)
found -9.1 (+-0.000197175) 26.5967 (+-0.0853755) 4.00011 (+-0.000430652)
found -8.02 (+-0.000197175) 26.5967 (+-0.0853755) 4.00011 (+-0.000430652)
found 3.86 (+-0.00019649) 26.5965 (+-0.0853353) 4.00008 (+-0.000430449)
found 8.9 (+-0.000196842) 26.5966 (+-0.0853566) 4.0001 (+-0.000430557)
found -4.78 (+-0.000196321) 26.5965 (+-0.0853273) 4.00008 (+-0.000430409)
found -5.14 (+-0.000226878) 19.9474 (+-0.0739022) 3.00006 (+-0.000372779)
found -3.34 (+-0.000228558) 19.9478 (+-0.0739773) 3.00012 (+-0.000373157)
found 1.7 (+-0.000226317) 19.9474 (+-0.0738826) 3.00006 (+-0.000372679)
found 4.58 (+-0.000228196) 19.9477 (+-0.0739611) 3.00011 (+-0.000373075)
found 7.82 (+-0.00022664) 19.9474 (+-0.0738938) 3.00006 (+-0.000372736)
found -7.3 (+-0.000280664) 13.2987 (+-0.0604252) 2.0001 (+-0.000304798)
found 0.619998 (+-0.00027841) 13.2984 (+-0.0603618) 2.00007 (+-0.000304478)
found 7.1 (+-0.000279116) 13.2985 (+-0.0603804) 2.00007 (+-0.000304572)
found -6.58 (+-0.000280204) 13.2986 (+-0.0604107) 2.00009 (+-0.000304724)
found -2.26 (+-0.000280146) 13.2986 (+-0.0604092) 2.00009 (+-0.000304717)
found 7.46 (+-0.000277384) 13.2982 (+-0.0603272) 2.00003 (+-0.000304303)
found 6.02 (+-0.000277702) 13.2983 (+-0.0603392) 2.00005 (+-0.000304363)
found -4.06 (+-0.000402548) 6.64985 (+-0.0428186) 1.00013 (+-0.000215986)
found 5.66 (+-0.000398437) 6.64954 (+-0.0427543) 1.00008 (+-0.000215662)
found -1.54 (+-0.000395013) 6.64926 (+-0.0427) 1.00004 (+-0.000215388)
found 0.980004 (+-0.000397698) 6.64945 (+-0.0427415) 1.00007 (+-0.000215597)
found 2.06 (+-0.000393721) 6.64918 (+-0.0426794) 1.00003 (+-0.000215284)
found 2.42 (+-0.000396778) 6.64945 (+-0.0427299) 1.00007 (+-0.000215539)
found -1.18 (+-0.000395013) 6.64927 (+-0.0427) 1.00004 (+-0.000215388)
#include <iostream>
TH1F *FitAwmi_Create_Spectrum(
void) {
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;
Areas[i] *= dx;
AreasErrors[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)
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()