created -9.88 59.8413 6
created -9.64 69.8149 7
created -9.4 79.7885 8
created -9.16 39.8942 4
created -8.92 79.7885 8
created -8.68 9.97356 1
created -8.44 99.7356 10
created -8.2 29.9207 3
created -7.96 59.8413 6
created -7.72 49.8678 5
created -7.48 89.762 9
created -7.24 89.762 9
created -7 9.97356 1
created -6.76 19.9471 2
created -6.52 99.7356 10
created -6.28 69.8149 7
created -6.04 29.9207 3
created -5.8 89.762 9
created -5.56 59.8413 6
created -5.32 19.9471 2
created -5.08 79.7885 8
created -4.84 9.97356 1
created -4.6 89.762 9
created -4.36 59.8413 6
created -4.12 9.97356 1
created -3.88 99.7356 10
created -3.64 19.9471 2
created -3.4 59.8413 6
created -3.16 99.7356 10
created -2.92 29.9207 3
created -2.68 69.8149 7
created -2.44 19.9471 2
created -2.2 99.7356 10
created -1.96 59.8413 6
created -1.72 49.8678 5
created -1.48 59.8413 6
created -1.24 69.8149 7
created -1 89.762 9
created -0.76 39.8942 4
created -0.52 29.9207 3
created -0.28 69.8149 7
created -0.04 69.8149 7
created 0.2 49.8678 5
created 0.44 9.97356 1
created 0.68 99.7356 10
created 0.92 59.8413 6
created 1.16 49.8678 5
created 1.4 29.9207 3
created 1.64 79.7885 8
created 1.88 29.9207 3
created 2.12 19.9471 2
created 2.36 79.7885 8
created 2.6 79.7885 8
created 2.84 69.8149 7
created 3.08 59.8413 6
created 3.32 79.7885 8
created 3.56 19.9471 2
created 3.8 89.762 9
created 4.04 69.8149 7
created 4.28 39.8942 4
created 4.52 69.8149 7
created 4.76 9.97356 1
created 5 39.8942 4
created 5.24 99.7356 10
created 5.48 39.8942 4
created 5.72 39.8942 4
created 5.96 19.9471 2
created 6.2 89.762 9
created 6.44 69.8149 7
created 6.68 69.8149 7
created 6.92 99.7356 10
created 7.16 49.8678 5
created 7.4 9.97356 1
created 7.64 69.8149 7
created 7.88 69.8149 7
created 8.12 49.8678 5
created 8.36 69.8149 7
created 8.6 89.762 9
created 8.84 9.97356 1
created 9.08 59.8413 6
created 9.32 99.7356 10
created 9.56 9.97356 1
created 9.8 29.9207 3
the total number of created peaks = 83 with sigma = 0.04
the total number of found peaks = 83 with sigma = 0.040002 (+-1.0898e-05)
fit chi^2 = 6.20776e-06
found -3.16 (+-0.000130398) 99.7328 (+-0.321163) 10.0002 (+-0.00111577)
found 6.92 (+-0.000130651) 99.7336 (+-0.321237) 10.0003 (+-0.00111603)
found 9.32 (+-0.000130092) 99.7323 (+-0.321081) 10.0002 (+-0.00111549)
found -8.44 (+-0.000129834) 99.7315 (+-0.321005) 10.0001 (+-0.00111522)
found -6.52 (+-0.000130337) 99.7328 (+-0.321148) 10.0002 (+-0.00111572)
found -3.88 (+-0.000129708) 99.7312 (+-0.32097) 10.0001 (+-0.0011151)
found -2.2 (+-0.00013027) 99.7326 (+-0.321128) 10.0002 (+-0.00111565)
found 0.680001 (+-0.000130092) 99.7323 (+-0.321081) 10.0002 (+-0.00111549)
found 5.24 (+-0.000130339) 99.7325 (+-0.321144) 10.0002 (+-0.00111571)
found -7.24 (+-0.000137404) 89.76 (+-0.304681) 9.00026 (+-0.00105851)
found -1 (+-0.000137721) 89.7603 (+-0.304754) 9.00029 (+-0.00105876)
found 8.6 (+-0.000137275) 89.7595 (+-0.304644) 9.00021 (+-0.00105838)
found -7.48 (+-0.000137945) 89.7611 (+-0.304816) 9.00037 (+-0.00105898)
found -5.8 (+-0.000137537) 89.7598 (+-0.304704) 9.00024 (+-0.00105859)
found -4.6 (+-0.000137202) 89.7593 (+-0.304623) 9.00018 (+-0.00105831)
found 3.8 (+-0.000137471) 89.7598 (+-0.30469) 9.00024 (+-0.00105854)
found 6.2 (+-0.000137471) 89.7598 (+-0.30469) 9.00024 (+-0.00105854)
found -9.4 (+-0.00014619) 79.7873 (+-0.287352) 8.00029 (+-0.000998308)
found 2.6 (+-0.000146542) 79.7883 (+-0.287439) 8.0004 (+-0.00099861)
found 3.32 (+-0.000145832) 79.7865 (+-0.287269) 8.00021 (+-0.000998018)
found -8.92 (+-0.000145423) 79.7857 (+-0.287176) 8.00013 (+-0.000997694)
found -5.08 (+-0.000145151) 79.7852 (+-0.287113) 8.00008 (+-0.000997476)
found 1.64 (+-0.000145671) 79.7859 (+-0.287228) 8.00016 (+-0.000997875)
found 2.36 (+-0.000145989) 79.787 (+-0.287309) 8.00026 (+-0.000998156)
found -9.64 (+-0.000156734) 69.815 (+-0.268892) 7.00037 (+-0.000934172)
found -6.28 (+-0.00015653) 69.8148 (+-0.268851) 7.00035 (+-0.000934032)
found -1.24 (+-0.000156813) 69.8153 (+-0.26891) 7.0004 (+-0.000934235)
found -0.0400005 (+-0.000156545) 69.8145 (+-0.26885) 7.00032 (+-0.000934027)
found 2.84 (+-0.000156734) 69.8151 (+-0.268892) 7.00037 (+-0.000934172)
found 4.04 (+-0.000156593) 69.8148 (+-0.268862) 7.00035 (+-0.000934071)
found 6.44 (+-0.000156907) 69.8156 (+-0.26893) 7.00043 (+-0.000934306)
found 6.68 (+-0.000156981) 69.8158 (+-0.268947) 7.00045 (+-0.000934366)
found 7.88 (+-0.000156545) 69.8145 (+-0.26885) 7.00032 (+-0.000934027)
found -2.68 (+-0.000155676) 69.8127 (+-0.268667) 7.00014 (+-0.000933391)
found -0.279999 (+-0.000156292) 69.814 (+-0.268797) 7.00026 (+-0.000933843)
found 4.52 (+-0.000155568) 69.8126 (+-0.268649) 7.00013 (+-0.000933329)
found 7.64 (+-0.000155875) 69.8134 (+-0.268717) 7.00021 (+-0.000933565)
found 8.36 (+-0.00015671) 69.815 (+-0.268887) 7.00037 (+-0.000934157)
found -5.56 (+-0.000168991) 59.8412 (+-0.248895) 6.00029 (+-0.000864702)
found -4.36 (+-0.000168711) 59.841 (+-0.24885) 6.00027 (+-0.000864543)
found -1.96 (+-0.000169565) 59.8423 (+-0.248999) 6.0004 (+-0.000865063)
found 0.919998 (+-0.000169565) 59.8423 (+-0.248999) 6.0004 (+-0.000865063)
found -7.96 (+-0.000168775) 59.8404 (+-0.248849) 6.00022 (+-0.00086454)
found -1.48 (+-0.000169289) 59.8415 (+-0.248945) 6.00032 (+-0.000864873)
found 3.08 (+-0.000169614) 59.8423 (+-0.249007) 6.0004 (+-0.00086509)
found -9.88 (+-0.000168951) 59.8402 (+-0.248862) 6.00019 (+-0.000864585)
found -3.4 (+-0.000169076) 59.8415 (+-0.248912) 6.00032 (+-0.000864761)
found 9.08 (+-0.000168796) 59.8412 (+-0.248867) 6.00029 (+-0.000864603)
found 7.16 (+-0.000185151) 49.8682 (+-0.227222) 5.0003 (+-0.000789405)
found -7.72 (+-0.000186092) 49.8692 (+-0.227359) 5.0004 (+-0.000789882)
found -1.72 (+-0.000185739) 49.8684 (+-0.227301) 5.00032 (+-0.00078968)
found 0.199998 (+-0.000184829) 49.8674 (+-0.227168) 5.00022 (+-0.000789216)
found 1.16 (+-0.000185257) 49.8676 (+-0.227226) 5.00024 (+-0.000789418)
found 8.12 (+-0.000185993) 49.869 (+-0.227342) 5.00037 (+-0.000789824)
found -0.760003 (+-0.000207918) 39.8954 (+-0.203341) 4.00032 (+-0.000706439)
found 5.48 (+-0.000208268) 39.8959 (+-0.203386) 4.00037 (+-0.000706596)
found -9.16 (+-0.000208682) 39.8964 (+-0.203439) 4.00043 (+-0.000706778)
found 4.28 (+-0.000208394) 39.8959 (+-0.2034) 4.00037 (+-0.000706645)
found 5.72 (+-0.00020685) 39.8938 (+-0.203202) 4.00016 (+-0.000705957)
found 5 (+-0.000207366) 39.8951 (+-0.20328) 4.0003 (+-0.000706227)
found -8.2 (+-0.000241682) 29.9234 (+-0.176257) 3.00043 (+-0.000612345)
found -2.92 (+-0.000241887) 29.9237 (+-0.176278) 3.00045 (+-0.000612416)
found 1.88 (+-0.000240216) 29.9218 (+-0.176114) 3.00027 (+-0.000611846)
found -6.04 (+-0.000241728) 29.9234 (+-0.176261) 3.00043 (+-0.000612359)
found 1.4 (+-0.000241127) 29.9226 (+-0.1762) 3.00035 (+-0.000612147)
found -0.519998 (+-0.000240688) 29.9221 (+-0.176156) 3.00029 (+-0.000611995)
found 9.8 (+-0.000236274) 29.9202 (+-0.175773) 3.00011 (+-0.000610662)
found -3.64 (+-0.000297496) 19.9504 (+-0.144018) 2.00043 (+-0.00050034)
found 3.56 (+-0.000297829) 19.9506 (+-0.14404) 2.00045 (+-0.000500418)
found -5.32 (+-0.000297041) 19.9498 (+-0.143985) 2.00037 (+-0.000500226)
found -2.44 (+-0.000297786) 19.9506 (+-0.144038) 2.00045 (+-0.000500409)
found 2.12 (+-0.000295917) 19.949 (+-0.14391) 2.0003 (+-0.000499965)
found 5.96 (+-0.000296584) 19.9496 (+-0.143955) 2.00035 (+-0.000500122)
found -6.75999 (+-0.000295113) 19.9491 (+-0.143865) 2.0003 (+-0.00049981)
found 9.55999 (+-0.000422946) 9.97654 (+-0.101921) 1.00035 (+-0.000354088)
found -8.68 (+-0.000425906) 9.97784 (+-0.102026) 1.00048 (+-0.000354455)
found -7.00001 (+-0.000421589) 9.97602 (+-0.101873) 1.0003 (+-0.000353924)
found -4.84 (+-0.000425538) 9.97758 (+-0.102012) 1.00045 (+-0.000354405)
found 8.83999 (+-0.000424599) 9.97706 (+-0.101977) 1.0004 (+-0.000354284)
found 4.75999 (+-0.000422546) 9.97599 (+-0.101901) 1.0003 (+-0.000354022)
found -4.11999 (+-0.000424965) 9.97732 (+-0.101991) 1.00043 (+-0.000354334)
found 0.44001 (+-0.000424399) 9.97706 (+-0.101971) 1.0004 (+-0.000354263)
found 7.4 (+-0.0004232) 9.97626 (+-0.101925) 1.00032 (+-0.000354102)
#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()