created -9.76 44.881 9
created -9.28 19.9471 4
created -8.8 19.9471 4
created -8.32 19.9471 4
created -7.84 14.9603 3
created -7.36 9.97356 2
created -6.88 49.8678 10
created -6.4 34.9074 7
created -5.92 14.9603 3
created -5.44 49.8678 10
created -4.96 4.98678 1
created -4.48 9.97356 2
created -4 49.8678 10
created -3.52 4.98678 1
created -3.04 34.9074 7
created -2.56 9.97356 2
created -2.08 34.9074 7
created -1.6 19.9471 4
created -1.12 34.9074 7
created -0.64 24.9339 5
created -0.16 34.9074 7
created 0.32 9.97356 2
created 0.8 29.9207 6
created 1.28 14.9603 3
created 1.76 9.97356 2
created 2.24 19.9471 4
created 2.72 29.9207 6
created 3.2 24.9339 5
created 3.68 4.98678 1
created 4.16 19.9471 4
created 4.64 14.9603 3
created 5.12 29.9207 6
created 5.6 49.8678 10
created 6.08 44.881 9
created 6.56 44.881 9
created 7.04 24.9339 5
created 7.52 34.9074 7
created 8 24.9339 5
created 8.48 49.8678 10
created 8.96 29.9207 6
created 9.44 14.9603 3
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-1.80029e-05)
fit chi^2 = 1.7447e-06
found -6.88 (+-0.000144996) 49.8676 (+-0.0893199) 10.0001 (+-0.000591492)
found -5.44 (+-0.000144431) 49.8673 (+-0.0892796) 10 (+-0.000591226)
found -4 (+-0.000144292) 49.8673 (+-0.0892699) 10 (+-0.000591162)
found 5.6 (+-0.000145573) 49.8679 (+-0.0893618) 10.0002 (+-0.00059177)
found 8.48 (+-0.000145272) 49.8677 (+-0.089339) 10.0001 (+-0.000591619)
found -9.76 (+-0.000152997) 44.8806 (+-0.0847386) 9.00004 (+-0.000561154)
found 6.08 (+-0.00015387) 44.8814 (+-0.0848055) 9.00019 (+-0.000561597)
found 6.56 (+-0.000153472) 44.8811 (+-0.084778) 9.00014 (+-0.000561415)
found -6.4 (+-0.000174147) 34.9076 (+-0.074775) 7.00013 (+-0.000495173)
found -3.04 (+-0.000172716) 34.9071 (+-0.0747006) 7.00003 (+-0.000494681)
found -2.08 (+-0.00017333) 34.9073 (+-0.074731) 7.00006 (+-0.000494882)
found -1.12 (+-0.000173814) 34.9074 (+-0.0747559) 7.00009 (+-0.000495047)
found -0.160001 (+-0.000173463) 34.9073 (+-0.0747381) 7.00007 (+-0.000494929)
found 7.52 (+-0.000173948) 34.9075 (+-0.0747629) 7.0001 (+-0.000495094)
found 8.96 (+-0.000188326) 29.9209 (+-0.0692388) 6.00013 (+-0.000458512)
found 0.8 (+-0.000187213) 29.9205 (+-0.0691871) 6.00005 (+-0.000458169)
found 2.72 (+-0.000187946) 29.9207 (+-0.0692199) 6.00009 (+-0.000458386)
found 5.12 (+-0.000188326) 29.9209 (+-0.0692388) 6.00013 (+-0.000458512)
found -0.64 (+-0.00020695) 24.9343 (+-0.0632307) 5.00014 (+-0.000418725)
found 3.2 (+-0.000205488) 24.9339 (+-0.0631758) 5.00007 (+-0.000418361)
found 7.04 (+-0.000207199) 24.9344 (+-0.0632409) 5.00016 (+-0.000418793)
found 8 (+-0.000207311) 24.9344 (+-0.0632455) 5.00017 (+-0.000418823)
found -9.28 (+-0.000231585) 19.9475 (+-0.0565627) 4.00013 (+-0.000374568)
found -1.6 (+-0.000231871) 19.9476 (+-0.0565714) 4.00014 (+-0.000374626)
found -8.8 (+-0.000230705) 19.9473 (+-0.0565338) 4.00008 (+-0.000374377)
found -8.32 (+-0.000230448) 19.9472 (+-0.0565259) 4.00007 (+-0.000374325)
found 2.24 (+-0.000230536) 19.9473 (+-0.0565295) 4.00008 (+-0.000374348)
found 4.16 (+-0.000229434) 19.9471 (+-0.0564958) 4.00004 (+-0.000374126)
found -7.84 (+-0.000266313) 14.9604 (+-0.0489581) 3.00006 (+-0.00032421)
found -5.92 (+-0.000269104) 14.961 (+-0.0490268) 3.00017 (+-0.000324664)
found 1.28 (+-0.000266833) 14.9605 (+-0.048971) 3.00008 (+-0.000324295)
found 4.64 (+-0.000267577) 14.9606 (+-0.0489883) 3.0001 (+-0.00032441)
found 9.44 (+-0.000264618) 14.9606 (+-0.0489295) 3.00009 (+-0.00032402)
found -7.36 (+-0.000329711) 9.97409 (+-0.0400337) 2.00013 (+-0.00026511)
found -2.56 (+-0.000330471) 9.97414 (+-0.0400455) 2.00014 (+-0.000265188)
found 0.319999 (+-0.000330159) 9.97409 (+-0.04004) 2.00013 (+-0.000265152)
found 1.76 (+-0.000327892) 9.97378 (+-0.0400017) 2.00007 (+-0.000264898)
found -4.47999 (+-0.000328283) 9.97399 (+-0.040012) 2.00011 (+-0.000264967)
found -3.52 (+-0.00047333) 4.98758 (+-0.028371) 1.00017 (+-0.000187878)
found -4.96001 (+-0.000469469) 4.98733 (+-0.0283375) 1.00012 (+-0.000187656)
found 3.68 (+-0.000468867) 4.98717 (+-0.0283298) 1.00009 (+-0.000187605)
#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()