created -9.82 6.64904 1
created -9.46 19.9471 3
created -9.1 39.8942 6
created -8.74 6.64904 1
created -8.38 59.8413 9
created -8.02 33.2452 5
created -7.66 46.5433 7
created -7.3 66.4904 10
created -6.94 59.8413 9
created -6.58 33.2452 5
created -6.22 26.5962 4
created -5.86 6.64904 1
created -5.5 26.5962 4
created -5.14 26.5962 4
created -4.78 19.9471 3
created -4.42 33.2452 5
created -4.06 33.2452 5
created -3.7 26.5962 4
created -3.34 53.1923 8
created -2.98 66.4904 10
created -2.62 26.5962 4
created -2.26 59.8413 9
created -1.9 59.8413 9
created -1.54 59.8413 9
created -1.18 66.4904 10
created -0.82 6.64904 1
created -0.46 19.9471 3
created -0.1 19.9471 3
created 0.26 53.1923 8
created 0.62 66.4904 10
created 0.98 59.8413 9
created 1.34 39.8942 6
created 1.7 46.5433 7
created 2.06 53.1923 8
created 2.42 19.9471 3
created 2.78 6.64904 1
created 3.14 53.1923 8
created 3.5 66.4904 10
created 3.86 39.8942 6
created 4.22 19.9471 3
created 4.58 26.5962 4
created 4.94 19.9471 3
created 5.3 46.5433 7
created 5.66 66.4904 10
created 6.02 39.8942 6
created 6.38 13.2981 2
created 6.74 66.4904 10
created 7.1 66.4904 10
created 7.46 6.64904 1
created 7.82 26.5962 4
created 8.18 33.2452 5
created 8.54 13.2981 2
created 8.9 59.8413 9
created 9.26 39.8942 6
created 9.62 46.5433 7
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.35512e-05)
fit chi^2 = 2.67792e-06
found -7.3 (+-0.000133253) 66.4906 (+-0.145354) 10.0001 (+-0.000733194)
found -2.98 (+-0.000132953) 66.4904 (+-0.145314) 10.0001 (+-0.000732993)
found -1.18 (+-0.0001326) 66.4904 (+-0.145272) 10.0001 (+-0.000732784)
found 0.62 (+-0.000133319) 66.4907 (+-0.145362) 10.0001 (+-0.000733239)
found 3.5 (+-0.000133122) 66.4905 (+-0.145336) 10.0001 (+-0.000733105)
found 5.66 (+-0.000133057) 66.4905 (+-0.145327) 10.0001 (+-0.00073306)
found 6.74 (+-0.000132833) 66.4904 (+-0.145301) 10.0001 (+-0.000732927)
found 7.1 (+-0.000132655) 66.4904 (+-0.14528) 10.0001 (+-0.000732823)
found -6.94 (+-0.00014047) 59.8416 (+-0.137896) 9.0001 (+-0.000695578)
found -1.9 (+-0.000140712) 59.8417 (+-0.137926) 9.00012 (+-0.000695726)
found -1.54 (+-0.000140773) 59.8418 (+-0.137933) 9.00013 (+-0.000695765)
found 0.98 (+-0.000140557) 59.8416 (+-0.137907) 9.00011 (+-0.000695631)
found -8.38 (+-0.000139559) 59.8412 (+-0.13779) 9.00004 (+-0.000695044)
found -2.26 (+-0.00014031) 59.8415 (+-0.137877) 9.00009 (+-0.000695481)
found 8.9 (+-0.000139839) 59.8413 (+-0.137821) 9.00005 (+-0.000695201)
found -3.34 (+-0.000149016) 53.1926 (+-0.130013) 8.00009 (+-0.000655814)
found 0.260001 (+-0.000148887) 53.1925 (+-0.13) 8.00009 (+-0.000655748)
found 2.06 (+-0.000148669) 53.1924 (+-0.129975) 8.00007 (+-0.000655623)
found 3.14 (+-0.00014851) 53.1924 (+-0.129964) 8.00007 (+-0.000655564)
found -7.66 (+-0.000159593) 46.5436 (+-0.121644) 7.0001 (+-0.000613597)
found 1.7 (+-0.000159544) 46.5436 (+-0.121638) 7.00009 (+-0.000613569)
found 5.3 (+-0.000159325) 46.5435 (+-0.121619) 7.00009 (+-0.000613472)
found 9.62 (+-0.000157899) 46.5435 (+-0.121503) 7.00009 (+-0.000612887)
found 1.34 (+-0.000172754) 39.8947 (+-0.112651) 6.00011 (+-0.000568237)
found 3.86 (+-0.000172297) 39.8945 (+-0.112615) 6.00009 (+-0.000568052)
found 6.02 (+-0.000172092) 39.8945 (+-0.112599) 6.00008 (+-0.000567973)
found 9.26 (+-0.000172754) 39.8947 (+-0.112651) 6.00011 (+-0.000568237)
found -9.1 (+-0.000170998) 39.8941 (+-0.11251) 6.00003 (+-0.000567524)
found -8.02 (+-0.000189564) 33.2457 (+-0.102859) 5.00011 (+-0.000518844)
found -6.58 (+-0.000189121) 33.2455 (+-0.102828) 5.00009 (+-0.000518688)
found -4.42 (+-0.000188427) 33.2453 (+-0.102779) 5.00005 (+-0.00051844)
found -4.06 (+-0.00018862) 33.2454 (+-0.102792) 5.00006 (+-0.000518506)
found 8.18 (+-0.000188024) 33.2452 (+-0.102752) 5.00004 (+-0.000518305)
found -6.22 (+-0.000210334) 26.5962 (+-0.0919127) 4.00004 (+-0.000463627)
found -5.14 (+-0.000210833) 26.5963 (+-0.0919375) 4.00005 (+-0.000463752)
found -3.7 (+-0.000211945) 26.5966 (+-0.0920007) 4.00009 (+-0.000464071)
found -2.62 (+-0.000212816) 26.5968 (+-0.0920518) 4.00013 (+-0.000464329)
found -5.5 (+-0.000210137) 26.5962 (+-0.0919015) 4.00003 (+-0.000463571)
found 4.58 (+-0.000210599) 26.5962 (+-0.0919246) 4.00004 (+-0.000463687)
found 7.82 (+-0.000210333) 26.5962 (+-0.0919127) 4.00004 (+-0.000463627)
found -4.78 (+-0.000244579) 19.9474 (+-0.079668) 3.00006 (+-0.000401862)
found 2.42 (+-0.000243974) 19.9474 (+-0.0796468) 3.00006 (+-0.000401755)
found 4.22 (+-0.000244803) 19.9474 (+-0.0796779) 3.00007 (+-0.000401912)
found 4.94 (+-0.000245005) 19.9475 (+-0.079687) 3.00007 (+-0.000401958)
found -9.46 (+-0.000243596) 19.9473 (+-0.0796294) 3.00005 (+-0.000401668)
found -0.46 (+-0.000242824) 19.9472 (+-0.0795957) 3.00003 (+-0.000401497)
found -0.099999 (+-0.000244883) 19.9475 (+-0.0796825) 3.00007 (+-0.000401936)
found 6.38 (+-0.00030278) 13.2987 (+-0.0651466) 2.00011 (+-0.000328613)
found 8.54 (+-0.000302239) 13.2986 (+-0.0651298) 2.00009 (+-0.000328529)
found -0.820004 (+-0.000430516) 6.64958 (+-0.0461045) 1.00009 (+-0.000232561)
found 7.46 (+-0.000431305) 6.64962 (+-0.0461165) 1.0001 (+-0.000232621)
found -8.74 (+-0.000432155) 6.64967 (+-0.0461294) 1.0001 (+-0.000232687)
found 2.78 (+-0.000429714) 6.64949 (+-0.0460907) 1.00007 (+-0.000232491)
found -5.86 (+-0.000428323) 6.64935 (+-0.0460672) 1.00005 (+-0.000232373)
found -9.82 (+-0.000423365) 6.64913 (+-0.0459911) 1.00002 (+-0.000231989)
#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()