created -9.7 19.9471 5
created -9.1 39.8942 10
created -8.5 23.9365 6
created -7.9 23.9365 6
created -7.3 35.9048 9
created -6.7 11.9683 3
created -6.1 11.9683 3
created -5.5 3.98942 1
created -4.9 27.926 7
created -4.3 15.9577 4
created -3.7 39.8942 10
created -3.1 31.9154 8
created -2.5 15.9577 4
created -1.9 11.9683 3
created -1.3 31.9154 8
created -0.7 3.98942 1
created -0.1 23.9365 6
created 0.5 39.8942 10
created 1.1 27.926 7
created 1.7 19.9471 5
created 2.3 35.9048 9
created 2.9 39.8942 10
created 3.5 3.98942 1
created 4.1 31.9154 8
created 4.7 3.98942 1
created 5.3 11.9683 3
created 5.9 19.9471 5
created 6.5 3.98942 1
created 7.1 35.9048 9
created 7.7 15.9577 4
created 8.3 35.9048 9
created 8.9 23.9365 6
created 9.5 19.9471 5
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.46611e-05)
fit chi^2 = 3.54074e-06
found -9.1 (+-0.000260936) 39.894 (+-0.1027) 10.0001 (+-0.000842808)
found -3.7 (+-0.000261026) 39.8941 (+-0.102705) 10.0002 (+-0.000842847)
found 0.5 (+-0.00026123) 39.8941 (+-0.102714) 10.0002 (+-0.000842924)
found 2.9 (+-0.000260334) 39.894 (+-0.102676) 10.0001 (+-0.000842607)
found -7.3 (+-0.000274824) 35.9046 (+-0.0974207) 9.00011 (+-0.000799482)
found 2.3 (+-0.000275784) 35.9049 (+-0.0974625) 9.00019 (+-0.000799825)
found 7.1 (+-0.000273805) 35.9044 (+-0.0973794) 9.00006 (+-0.000799143)
found 8.3 (+-0.00027505) 35.9046 (+-0.09743) 9.00013 (+-0.000799559)
found -3.1 (+-0.000292561) 31.9155 (+-0.0918908) 8.00018 (+-0.000754101)
found -1.3 (+-0.000290332) 31.915 (+-0.0918069) 8.00005 (+-0.000753412)
found 4.1 (+-0.000289607) 31.9149 (+-0.0917812) 8.00002 (+-0.000753201)
found 1.1 (+-0.000313327) 27.9262 (+-0.0859754) 7.00019 (+-0.000705557)
found -4.9 (+-0.000310854) 27.9257 (+-0.0858929) 7.00006 (+-0.000704879)
found -8.5 (+-0.000339117) 23.9369 (+-0.0796185) 6.00021 (+-0.000653389)
found 8.9 (+-0.000338702) 23.9368 (+-0.0796059) 6.00018 (+-0.000653285)
found -7.9 (+-0.000338946) 23.9369 (+-0.0796131) 6.00019 (+-0.000653344)
found -0.0999969 (+-0.000337307) 23.9367 (+-0.0795682) 6.00014 (+-0.000652976)
found -9.7 (+-0.000370941) 19.9473 (+-0.0726632) 5.00013 (+-0.00059631)
found 1.7 (+-0.000372167) 19.9476 (+-0.0726989) 5.00021 (+-0.000596603)
found 5.9 (+-0.000368122) 19.9469 (+-0.0725997) 5.00005 (+-0.000595788)
found 9.5 (+-0.000367295) 19.9473 (+-0.0725912) 5.00014 (+-0.000595719)
found -4.3 (+-0.000417264) 15.9583 (+-0.0650488) 4.00022 (+-0.000533822)
found -2.5 (+-0.000415246) 15.958 (+-0.0650072) 4.00014 (+-0.000533481)
found 7.7 (+-0.000417567) 15.9583 (+-0.0650551) 4.00023 (+-0.000533874)
found -6.7 (+-0.000481097) 11.9687 (+-0.0563236) 3.00016 (+-0.000462219)
found -6.1 (+-0.000476735) 11.9683 (+-0.0562567) 3.00005 (+-0.00046167)
found -1.9 (+-0.000481367) 11.9687 (+-0.0563271) 3.00016 (+-0.000462248)
found 5.3 (+-0.000477813) 11.9684 (+-0.0562735) 3.00008 (+-0.000461808)
found 3.5 (+-0.000851064) 3.99028 (+-0.0326195) 1.00023 (+-0.000267691)
found -0.700004 (+-0.00084756) 3.99008 (+-0.0325984) 1.00018 (+-0.000267518)
found 4.69999 (+-0.000843608) 3.98992 (+-0.0325761) 1.00014 (+-0.000267335)
found 6.50001 (+-0.000847257) 3.99007 (+-0.0325969) 1.00018 (+-0.000267506)
found -5.49999 (+-0.00084272) 3.98987 (+-0.0325707) 1.00013 (+-0.000267291)
#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()