created -9.82 6.64904 1
created -9.46 46.5433 7
created -9.1 6.64904 1
created -8.74 33.2452 5
created -8.38 33.2452 5
created -8.02 59.8413 9
created -7.66 26.5962 4
created -7.3 59.8413 9
created -6.94 33.2452 5
created -6.58 39.8942 6
created -6.22 6.64904 1
created -5.86 26.5962 4
created -5.5 13.2981 2
created -5.14 13.2981 2
created -4.78 66.4904 10
created -4.42 59.8413 9
created -4.06 39.8942 6
created -3.7 59.8413 9
created -3.34 46.5433 7
created -2.98 13.2981 2
created -2.62 53.1923 8
created -2.26 26.5962 4
created -1.9 19.9471 3
created -1.54 26.5962 4
created -1.18 53.1923 8
created -0.82 46.5433 7
created -0.46 39.8942 6
created -0.1 59.8413 9
created 0.26 66.4904 10
created 0.62 13.2981 2
created 0.98 26.5962 4
created 1.34 33.2452 5
created 1.7 33.2452 5
created 2.06 59.8413 9
created 2.42 26.5962 4
created 2.78 26.5962 4
created 3.14 66.4904 10
created 3.5 19.9471 3
created 3.86 19.9471 3
created 4.22 6.64904 1
created 4.58 46.5433 7
created 4.94 66.4904 10
created 5.3 53.1923 8
created 5.66 66.4904 10
created 6.02 59.8413 9
created 6.38 33.2452 5
created 6.74 6.64904 1
created 7.1 66.4904 10
created 7.46 46.5433 7
created 7.82 33.2452 5
created 8.18 6.64904 1
created 8.54 46.5433 7
created 8.9 26.5962 4
created 9.26 66.4904 10
created 9.62 19.9471 3
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-9.05875e-06)
fit chi^2 = 1.17022e-06
found -4.78 (+-8.7773e-05) 66.4904 (+-0.0960461) 10.0001 (+-0.000484477)
found 0.26 (+-8.7773e-05) 66.4904 (+-0.0960461) 10.0001 (+-0.000484477)
found 3.14 (+-8.76194e-05) 66.4902 (+-0.0960244) 10 (+-0.000484367)
found 4.94 (+-8.80477e-05) 66.4906 (+-0.0960807) 10.0001 (+-0.000484652)
found 5.66 (+-8.81304e-05) 66.4907 (+-0.096092) 10.0001 (+-0.000484709)
found 7.1 (+-8.75742e-05) 66.4903 (+-0.0960212) 10.0001 (+-0.000484351)
found 9.26 (+-8.76194e-05) 66.4902 (+-0.0960244) 10 (+-0.000484367)
found -4.42 (+-9.29156e-05) 59.8416 (+-0.0911634) 9.00011 (+-0.000459848)
found 6.02 (+-9.2858e-05) 59.8416 (+-0.0911566) 9.0001 (+-0.000459813)
found -8.02 (+-9.25539e-05) 59.8413 (+-0.0911194) 9.00006 (+-0.000459625)
found -7.3 (+-9.25539e-05) 59.8413 (+-0.0911194) 9.00006 (+-0.000459625)
found -3.7 (+-9.27847e-05) 59.8415 (+-0.0911471) 9.00009 (+-0.000459765)
found -0.0999997 (+-9.29156e-05) 59.8416 (+-0.0911634) 9.00011 (+-0.000459848)
found 2.06 (+-9.25539e-05) 59.8413 (+-0.0911194) 9.00006 (+-0.000459625)
found 5.3 (+-9.88471e-05) 53.1928 (+-0.0859825) 8.00013 (+-0.000433714)
found -2.62 (+-9.79825e-05) 53.1922 (+-0.0858893) 8.00004 (+-0.000433244)
found -1.18 (+-9.83626e-05) 53.1924 (+-0.0859291) 8.00007 (+-0.000433445)
found -3.34 (+-0.000105153) 46.5434 (+-0.080381) 7.00007 (+-0.000405459)
found -0.82 (+-0.000105466) 46.5436 (+-0.0804091) 7.00009 (+-0.000405601)
found 7.46 (+-0.000105499) 46.5436 (+-0.0804127) 7.0001 (+-0.000405619)
found -9.46 (+-0.000104296) 46.543 (+-0.0803029) 7.00001 (+-0.000405065)
found 4.58 (+-0.00010504) 46.5434 (+-0.0803724) 7.00007 (+-0.000405415)
found 8.54 (+-0.000104666) 46.5432 (+-0.0803356) 7.00003 (+-0.00040523)
found -4.06 (+-0.000114329) 39.8948 (+-0.0744794) 6.00012 (+-0.00037569)
found -6.58 (+-0.000113237) 39.8942 (+-0.074391) 6.00004 (+-0.000375244)
found -0.46 (+-0.000114199) 39.8947 (+-0.0744683) 6.00011 (+-0.000375634)
found -6.94 (+-0.000125225) 33.2456 (+-0.0679891) 5.0001 (+-0.000342951)
found 6.38 (+-0.000124509) 33.2454 (+-0.0679423) 5.00007 (+-0.000342715)
found -8.74 (+-0.000124181) 33.2452 (+-0.0679185) 5.00004 (+-0.000342595)
found -8.38 (+-0.000125129) 33.2456 (+-0.0679823) 5.00009 (+-0.000342917)
found 1.34 (+-0.000124688) 33.2454 (+-0.067951) 5.00006 (+-0.000342759)
found 1.7 (+-0.000125129) 33.2456 (+-0.0679823) 5.00009 (+-0.000342917)
found 7.82 (+-0.00012436) 33.2453 (+-0.0679313) 5.00005 (+-0.00034266)
found -7.66 (+-0.0001406) 26.5968 (+-0.060846) 4.00012 (+-0.00030692)
found -2.26 (+-0.000139817) 26.5965 (+-0.0608012) 4.00007 (+-0.000306694)
found 2.42 (+-0.00014006) 26.5965 (+-0.0608149) 4.00009 (+-0.000306764)
found 2.78 (+-0.000140141) 26.5966 (+-0.0608199) 4.00009 (+-0.000306788)
found 8.9 (+-0.000140498) 26.5967 (+-0.0608401) 4.00011 (+-0.00030689)
found -5.86 (+-0.000138568) 26.5961 (+-0.0607329) 4.00002 (+-0.000306349)
found -1.54 (+-0.000139817) 26.5965 (+-0.0608012) 4.00007 (+-0.000306694)
found 0.98 (+-0.00013931) 26.5963 (+-0.0607726) 4.00005 (+-0.00030655)
found -1.9 (+-0.00016151) 19.9473 (+-0.0526573) 3.00005 (+-0.000265615)
found 3.5 (+-0.000162093) 19.9476 (+-0.0526842) 3.00009 (+-0.00026575)
found 9.62 (+-0.000160491) 19.9476 (+-0.0526293) 3.00009 (+-0.000265473)
found 3.86 (+-0.000160519) 19.9472 (+-0.0526168) 3.00003 (+-0.00026541)
found 0.619998 (+-0.000199696) 13.2986 (+-0.0430516) 2.00009 (+-0.000217162)
found -2.98 (+-0.000200041) 13.2987 (+-0.0430614) 2.0001 (+-0.000217211)
found -5.5 (+-0.000197952) 13.2983 (+-0.042999) 2.00004 (+-0.000216896)
found -5.14 (+-0.000199048) 13.2985 (+-0.0430333) 2.00008 (+-0.000217069)
found -9.1 (+-0.000284715) 6.64953 (+-0.030478) 1.00008 (+-0.000153738)
found 6.74 (+-0.000285553) 6.64967 (+-0.0304922) 1.0001 (+-0.000153809)
found 8.18 (+-0.000284715) 6.64953 (+-0.030478) 1.00008 (+-0.000153738)
found -6.22 (+-0.000283947) 6.64944 (+-0.0304657) 1.00007 (+-0.000153675)
found 4.22 (+-0.000283763) 6.64944 (+-0.0304633) 1.00007 (+-0.000153663)
found -9.82 (+-0.000281466) 6.64931 (+-0.0304287) 1.00005 (+-0.000153489)
#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()