created -9.88 29.9207 3
created -9.64 89.762 9
created -9.4 99.7356 10
created -9.16 59.8413 6
created -8.92 49.8678 5
created -8.68 79.7885 8
created -8.44 69.8149 7
created -8.2 89.762 9
created -7.96 39.8942 4
created -7.72 59.8413 6
created -7.48 29.9207 3
created -7.24 49.8678 5
created -7 69.8149 7
created -6.76 99.7356 10
created -6.52 69.8149 7
created -6.28 69.8149 7
created -6.04 19.9471 2
created -5.8 19.9471 2
created -5.56 39.8942 4
created -5.32 69.8149 7
created -5.08 99.7356 10
created -4.84 29.9207 3
created -4.6 49.8678 5
created -4.36 19.9471 2
created -4.12 29.9207 3
created -3.88 79.7885 8
created -3.64 49.8678 5
created -3.4 99.7356 10
created -3.16 59.8413 6
created -2.92 49.8678 5
created -2.68 89.762 9
created -2.44 69.8149 7
created -2.2 89.762 9
created -1.96 19.9471 2
created -1.72 49.8678 5
created -1.48 99.7356 10
created -1.24 69.8149 7
created -1 89.762 9
created -0.76 69.8149 7
created -0.52 69.8149 7
created -0.28 89.762 9
created -0.04 69.8149 7
created 0.2 69.8149 7
created 0.44 59.8413 6
created 0.68 9.97356 1
created 0.92 9.97356 1
created 1.16 99.7356 10
created 1.4 49.8678 5
created 1.64 59.8413 6
created 1.88 89.762 9
created 2.12 99.7356 10
created 2.36 99.7356 10
created 2.6 99.7356 10
created 2.84 49.8678 5
created 3.08 19.9471 2
created 3.32 49.8678 5
created 3.56 59.8413 6
created 3.8 49.8678 5
created 4.04 19.9471 2
created 4.28 29.9207 3
created 4.52 39.8942 4
created 4.76 39.8942 4
created 5 49.8678 5
created 5.24 49.8678 5
created 5.48 99.7356 10
created 5.72 69.8149 7
created 5.96 99.7356 10
created 6.2 59.8413 6
created 6.44 59.8413 6
created 6.68 99.7356 10
created 6.92 39.8942 4
created 7.16 89.762 9
created 7.4 49.8678 5
created 7.64 99.7356 10
created 7.88 69.8149 7
created 8.12 29.9207 3
created 8.36 69.8149 7
created 8.6 59.8413 6
created 8.84 49.8678 5
created 9.08 99.7356 10
created 9.32 89.762 9
created 9.56 19.9471 2
created 9.8 49.8678 5
the total number of created peaks = 83 with sigma = 0.04
the total number of found peaks = 83 with sigma = 0.0400021 (+-1.24057e-05)
fit chi^2 = 8.78914e-06
found -9.4 (+-0.000155691) 99.7344 (+-0.382307) 10.0004 (+-0.00132819)
found -6.76 (+-0.00015563) 99.7341 (+-0.382287) 10.0004 (+-0.00132813)
found -5.08 (+-0.000155238) 99.7331 (+-0.382172) 10.0003 (+-0.00132773)
found 2.12 (+-0.000155977) 99.7355 (+-0.382396) 10.0005 (+-0.0013285)
found 2.36 (+-0.000156041) 99.7357 (+-0.382416) 10.0005 (+-0.00132857)
found 2.6 (+-0.000155665) 99.7344 (+-0.3823) 10.0004 (+-0.00132817)
found 5.96 (+-0.000155549) 99.7339 (+-0.382262) 10.0003 (+-0.00132804)
found 6.68 (+-0.000155279) 99.7331 (+-0.382181) 10.0003 (+-0.00132776)
found -3.4 (+-0.00015538) 99.7333 (+-0.382211) 10.0003 (+-0.00132786)
found -1.48 (+-0.00015546) 99.7336 (+-0.382236) 10.0003 (+-0.00132795)
found 1.16 (+-0.000154707) 99.732 (+-0.382024) 10.0002 (+-0.00132721)
found 5.48 (+-0.00015546) 99.7336 (+-0.382236) 10.0003 (+-0.00132795)
found 7.64 (+-0.00015546) 99.7336 (+-0.382236) 10.0003 (+-0.00132795)
found 9.08 (+-0.000155601) 99.7341 (+-0.38228) 10.0004 (+-0.0013281)
found -8.2 (+-0.000163872) 89.7603 (+-0.362622) 9.00029 (+-0.00125981)
found -2.2 (+-0.000163575) 89.7598 (+-0.362547) 9.00024 (+-0.00125955)
found -1 (+-0.00016417) 89.7611 (+-0.362703) 9.00037 (+-0.00126009)
found -0.28 (+-0.00016417) 89.7611 (+-0.362703) 9.00037 (+-0.00126009)
found 1.88 (+-0.000164307) 89.7616 (+-0.362743) 9.00043 (+-0.00126023)
found 9.32 (+-0.000163799) 89.7606 (+-0.362612) 9.00032 (+-0.00125977)
found -9.64 (+-0.000163965) 89.7608 (+-0.362653) 9.00034 (+-0.00125991)
found -2.68 (+-0.000163984) 89.7606 (+-0.362652) 9.00032 (+-0.00125991)
found 7.16 (+-0.000163688) 89.7598 (+-0.362571) 9.00024 (+-0.00125963)
found -8.68 (+-0.000174072) 79.7875 (+-0.341946) 8.00032 (+-0.00118798)
found -3.88 (+-0.000173599) 79.7865 (+-0.341832) 8.00021 (+-0.00118758)
found -8.44 (+-0.000186804) 69.8158 (+-0.320019) 7.00045 (+-0.0011118)
found -6.52 (+-0.00018679) 69.8158 (+-0.320017) 7.00045 (+-0.00111179)
found -6.28 (+-0.000185765) 69.8137 (+-0.319797) 7.00024 (+-0.00111103)
found -2.44 (+-0.000186899) 69.8161 (+-0.320041) 7.00048 (+-0.00111187)
found -1.24 (+-0.000186988) 69.8164 (+-0.320061) 7.00051 (+-0.00111194)
found -0.760001 (+-0.000186701) 69.8156 (+-0.319997) 7.00043 (+-0.00111172)
found -0.519999 (+-0.000186701) 69.8156 (+-0.319997) 7.00043 (+-0.00111172)
found -0.0400005 (+-0.000186701) 69.8156 (+-0.319997) 7.00043 (+-0.00111172)
found 0.2 (+-0.000186394) 69.8148 (+-0.319928) 7.00035 (+-0.00111148)
found 5.72 (+-0.000187077) 69.8166 (+-0.320082) 7.00053 (+-0.00111202)
found 7.88 (+-0.000186253) 69.8148 (+-0.319903) 7.00035 (+-0.00111139)
found -7 (+-0.000186556) 69.8153 (+-0.319966) 7.0004 (+-0.00111161)
found -5.32 (+-0.000186417) 69.815 (+-0.319936) 7.00037 (+-0.00111151)
found 8.36 (+-0.00018586) 69.8137 (+-0.319813) 7.00024 (+-0.00111108)
found -9.16 (+-0.000201763) 59.8423 (+-0.296281) 6.0004 (+-0.00102933)
found -3.16 (+-0.000201763) 59.8423 (+-0.296281) 6.0004 (+-0.00102933)
found 6.2 (+-0.000201905) 59.8425 (+-0.296308) 6.00043 (+-0.00102942)
found -7.72 (+-0.000200665) 59.8401 (+-0.296072) 6.00019 (+-0.0010286)
found 0.439998 (+-0.000200524) 59.8404 (+-0.296059) 6.00021 (+-0.00102855)
found 1.64 (+-0.000201661) 59.842 (+-0.296261) 6.00037 (+-0.00102926)
found 3.56 (+-0.000201167) 59.8409 (+-0.296165) 6.00026 (+-0.00102892)
found 6.44 (+-0.000201905) 59.8425 (+-0.296308) 6.00043 (+-0.00102942)
found 8.6 (+-0.000201435) 59.8415 (+-0.296216) 6.00032 (+-0.0010291)
found 1.4 (+-0.000221549) 49.8695 (+-0.270552) 5.00043 (+-0.00093994)
found 2.84 (+-0.000220698) 49.8684 (+-0.270422) 5.00032 (+-0.00093949)
found 7.4 (+-0.000221971) 49.8703 (+-0.270621) 5.00051 (+-0.000940181)
found -8.92 (+-0.000221299) 49.869 (+-0.27051) 5.00037 (+-0.000939795)
found -7.24 (+-0.000220586) 49.8679 (+-0.270397) 5.00027 (+-0.000939403)
found -4.6 (+-0.000219597) 49.8666 (+-0.270243) 5.00013 (+-0.000938867)
found -3.64 (+-0.000221841) 49.87 (+-0.2706) 5.00048 (+-0.000940106)
found -2.92 (+-0.000221428) 49.8692 (+-0.270532) 5.0004 (+-0.00093987)
found 3.8 (+-0.000220164) 49.8673 (+-0.270333) 5.00021 (+-0.000939179)
found 5 (+-0.000220488) 49.8676 (+-0.270379) 5.00024 (+-0.000939341)
found 5.24 (+-0.000221381) 49.8692 (+-0.270525) 5.0004 (+-0.000939847)
found 8.84 (+-0.000221549) 49.8695 (+-0.270552) 5.00043 (+-0.00093994)
found -1.72 (+-0.000220698) 49.8684 (+-0.270422) 5.00032 (+-0.00093949)
found 3.32 (+-0.000220164) 49.8674 (+-0.270333) 5.00021 (+-0.000939179)
found 9.8 (+-0.000217876) 49.8671 (+-0.270027) 5.00018 (+-0.000938115)
found -7.96 (+-0.000248107) 39.8962 (+-0.242043) 4.0004 (+-0.000840896)
found 6.92 (+-0.000248774) 39.8972 (+-0.242132) 4.00051 (+-0.000841205)
found 4.52 (+-0.000246456) 39.894 (+-0.241828) 4.00019 (+-0.000840148)
found 4.76 (+-0.000246952) 39.8946 (+-0.241891) 4.00024 (+-0.000840367)
found -5.56 (+-0.000246743) 39.8946 (+-0.241869) 4.00024 (+-0.000840291)
found -4.84 (+-0.000287304) 29.9231 (+-0.209699) 3.0004 (+-0.000728528)
found -7.48 (+-0.000286453) 29.9221 (+-0.209611) 3.00029 (+-0.000728223)
found 8.12 (+-0.000287205) 29.9229 (+-0.209687) 3.00037 (+-0.000728486)
found -4.12 (+-0.00028583) 29.9218 (+-0.209555) 3.00027 (+-0.000728028)
found 4.28 (+-0.000284812) 29.9207 (+-0.209452) 3.00016 (+-0.000727669)
found -9.87999 (+-0.000285681) 29.9216 (+-0.209527) 3.00024 (+-0.000727931)
found -1.96 (+-0.000353341) 19.9498 (+-0.171319) 2.00038 (+-0.000595191)
found 9.56 (+-0.000353341) 19.9498 (+-0.171319) 2.00038 (+-0.000595191)
found -6.04 (+-0.000351177) 19.9485 (+-0.171174) 2.00024 (+-0.000594687)
found -4.36 (+-0.000351085) 19.9482 (+-0.171164) 2.00021 (+-0.000594653)
found 3.08 (+-0.000352029) 19.9488 (+-0.171228) 2.00027 (+-0.000594872)
found 4.04 (+-0.000351085) 19.9482 (+-0.171164) 2.00021 (+-0.000594653)
found -5.8 (+-0.000350034) 19.9477 (+-0.171095) 2.00016 (+-0.000594412)
found 0.679991 (+-0.000498469) 9.97495 (+-0.121106) 1.00019 (+-0.00042074)
found 0.920017 (+-0.000500427) 9.97602 (+-0.121182) 1.0003 (+-0.000421007)
#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()