created -9.82 33.2452 5
created -9.46 26.5962 4
created -9.1 6.64904 1
created -8.74 19.9471 3
created -8.38 66.4904 10
created -8.02 53.1923 8
created -7.66 66.4904 10
created -7.3 19.9471 3
created -6.94 39.8942 6
created -6.58 13.2981 2
created -6.22 39.8942 6
created -5.86 6.64904 1
created -5.5 13.2981 2
created -5.14 46.5433 7
created -4.78 13.2981 2
created -4.42 59.8413 9
created -4.06 6.64904 1
created -3.7 59.8413 9
created -3.34 33.2452 5
created -2.98 13.2981 2
created -2.62 6.64904 1
created -2.26 13.2981 2
created -1.9 13.2981 2
created -1.54 19.9471 3
created -1.18 6.64904 1
created -0.82 39.8942 6
created -0.46 6.64904 1
created -0.1 59.8413 9
created 0.26 26.5962 4
created 0.62 46.5433 7
created 0.98 6.64904 1
created 1.34 13.2981 2
created 1.7 66.4904 10
created 2.06 13.2981 2
created 2.42 19.9471 3
created 2.78 66.4904 10
created 3.14 33.2452 5
created 3.5 66.4904 10
created 3.86 66.4904 10
created 4.22 33.2452 5
created 4.58 19.9471 3
created 4.94 53.1923 8
created 5.3 33.2452 5
created 5.66 59.8413 9
created 6.02 53.1923 8
created 6.38 66.4904 10
created 6.74 53.1923 8
created 7.1 6.64904 1
created 7.46 39.8942 6
created 7.82 6.64904 1
created 8.18 53.1923 8
created 8.54 59.8413 9
created 8.9 39.8942 6
created 9.26 19.9471 3
created 9.62 13.2981 2
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-7.91644e-06)
fit chi^2 = 7.98207e-07
found -8.38 (+-7.25294e-05) 66.4904 (+-0.0793279) 10.0001 (+-0.000400147)
found -7.66 (+-7.25294e-05) 66.4904 (+-0.0793279) 10.0001 (+-0.000400147)
found 1.7 (+-7.21674e-05) 66.4901 (+-0.0792814) 10 (+-0.000399912)
found 2.78 (+-7.24129e-05) 66.4903 (+-0.0793122) 10.0001 (+-0.000400068)
found 3.5 (+-7.26989e-05) 66.4906 (+-0.0793503) 10.0001 (+-0.00040026)
found 3.86 (+-7.2699e-05) 66.4906 (+-0.0793503) 10.0001 (+-0.00040026)
found 6.38 (+-7.27535e-05) 66.4906 (+-0.0793573) 10.0001 (+-0.000400295)
found 8.54 (+-7.66691e-05) 59.8415 (+-0.0752825) 9.00009 (+-0.000379741)
found -4.42 (+-7.60018e-05) 59.8411 (+-0.0752056) 9.00002 (+-0.000379353)
found -3.7 (+-7.61933e-05) 59.8412 (+-0.0752278) 9.00004 (+-0.000379465)
found -0.0999998 (+-7.61403e-05) 59.8411 (+-0.0752215) 9.00003 (+-0.000379433)
found 5.66 (+-7.66216e-05) 59.8415 (+-0.0752769) 9.00009 (+-0.000379712)
found -8.02 (+-8.16371e-05) 53.1928 (+-0.0710124) 8.00013 (+-0.000358201)
found 6.02 (+-8.15998e-05) 53.1928 (+-0.0710081) 8.00013 (+-0.00035818)
found 6.74 (+-8.108e-05) 53.1924 (+-0.0709546) 8.00007 (+-0.00035791)
found 4.94 (+-8.10681e-05) 53.1923 (+-0.0709502) 8.00005 (+-0.000357888)
found 8.18 (+-8.10435e-05) 53.1924 (+-0.0709504) 8.00007 (+-0.000357889)
found -5.14 (+-8.64023e-05) 46.5431 (+-0.0663441) 7.00003 (+-0.000334654)
found 0.62 (+-8.64427e-05) 46.5432 (+-0.0663486) 7.00003 (+-0.000334676)
found 8.9 (+-9.40198e-05) 39.8945 (+-0.0614787) 6.00008 (+-0.000310112)
found -6.94 (+-9.35107e-05) 39.8942 (+-0.061437) 6.00003 (+-0.000309901)
found -6.22 (+-9.32477e-05) 39.8941 (+-0.0614172) 6.00002 (+-0.000309801)
found -0.82 (+-9.30958e-05) 39.894 (+-0.0614059) 6.00001 (+-0.000309744)
found 7.46 (+-9.30958e-05) 39.894 (+-0.0614059) 6.00001 (+-0.000309744)
found -3.34 (+-0.000103014) 33.2454 (+-0.0561243) 5.00007 (+-0.000283103)
found 3.14 (+-0.000103731) 33.2459 (+-0.0561741) 5.00013 (+-0.000283354)
found 4.22 (+-0.000103201) 33.2455 (+-0.056137) 5.00009 (+-0.000283167)
found 5.3 (+-0.000103559) 33.2457 (+-0.0561615) 5.00011 (+-0.000283291)
found -9.82 (+-0.000102721) 33.2451 (+-0.0560981) 5.00003 (+-0.000282971)
found -9.46 (+-0.000114833) 26.5962 (+-0.0501805) 4.00004 (+-0.000253121)
found 0.26 (+-0.000115969) 26.5967 (+-0.0502433) 4.00011 (+-0.000253438)
found -7.3 (+-0.000134305) 19.9477 (+-0.04353) 3.00011 (+-0.000219575)
found 4.58 (+-0.000134004) 19.9476 (+-0.0435164) 3.00009 (+-0.000219506)
found 9.26 (+-0.000133281) 19.9473 (+-0.0434854) 3.00005 (+-0.00021935)
found -8.74 (+-0.000133374) 19.9475 (+-0.043492) 3.00007 (+-0.000219383)
found -1.54 (+-0.00013237) 19.9471 (+-0.0434475) 3.00002 (+-0.000219159)
found 2.42 (+-0.000133664) 19.9475 (+-0.0435031) 3.00008 (+-0.000219439)
found 2.06 (+-0.00016469) 13.2986 (+-0.0355492) 2.00009 (+-0.000179318)
found -6.58 (+-0.000164759) 13.2985 (+-0.0355501) 2.00008 (+-0.000179322)
found -4.78 (+-0.000165342) 13.2987 (+-0.0355682) 2.00011 (+-0.000179414)
found -2.98 (+-0.000163272) 13.2983 (+-0.0355075) 2.00004 (+-0.000179107)
found -1.9 (+-0.000163255) 13.2982 (+-0.0355057) 2.00003 (+-0.000179098)
found 9.62 (+-0.000161655) 13.2982 (+-0.0354688) 2.00003 (+-0.000178912)
found -5.5 (+-0.000163595) 13.2983 (+-0.0355176) 2.00005 (+-0.000179158)
found -2.26 (+-0.00016256) 13.2981 (+-0.0354865) 2.00002 (+-0.000179002)
found 1.34 (+-0.000163976) 13.2985 (+-0.0355299) 2.00007 (+-0.00017922)
found -4.06 (+-0.000236705) 6.6498 (+-0.0251974) 1.00012 (+-0.000127101)
found 7.1 (+-0.000235708) 6.64962 (+-0.0251808) 1.00009 (+-0.000127017)
found -0.459998 (+-0.000235939) 6.64967 (+-0.0251847) 1.0001 (+-0.000127037)
found 0.979997 (+-0.00023382) 6.6494 (+-0.0251515) 1.00006 (+-0.000126869)
found 7.82 (+-0.000235708) 6.64962 (+-0.0251808) 1.00009 (+-0.000127017)
found -5.86 (+-0.000233548) 6.64935 (+-0.0251469) 1.00005 (+-0.000126846)
found -9.1 (+-0.000233424) 6.64931 (+-0.0251442) 1.00005 (+-0.000126833)
found -1.18 (+-0.000234084) 6.6494 (+-0.0251549) 1.00006 (+-0.000126887)
found -2.62 (+-0.00023195) 6.64917 (+-0.0251218) 1.00003 (+-0.00012672)
#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()