created -9.88 99.7356 10
created -9.64 59.8413 6
created -9.4 79.7885 8
created -9.16 69.8149 7
created -8.92 89.762 9
created -8.68 99.7356 10
created -8.44 9.97356 1
created -8.2 29.9207 3
created -7.96 29.9207 3
created -7.72 69.8149 7
created -7.48 39.8942 4
created -7.24 79.7885 8
created -7 79.7885 8
created -6.76 19.9471 2
created -6.52 79.7885 8
created -6.28 9.97356 1
created -6.04 39.8942 4
created -5.8 79.7885 8
created -5.56 69.8149 7
created -5.32 9.97356 1
created -5.08 99.7356 10
created -4.84 9.97356 1
created -4.6 49.8678 5
created -4.36 29.9207 3
created -4.12 59.8413 6
created -3.88 19.9471 2
created -3.64 79.7885 8
created -3.4 59.8413 6
created -3.16 99.7356 10
created -2.92 69.8149 7
created -2.68 9.97356 1
created -2.44 99.7356 10
created -2.2 69.8149 7
created -1.96 29.9207 3
created -1.72 89.762 9
created -1.48 79.7885 8
created -1.24 19.9471 2
created -1 79.7885 8
created -0.76 39.8942 4
created -0.52 79.7885 8
created -0.28 29.9207 3
created -0.04 29.9207 3
created 0.2 9.97356 1
created 0.44 39.8942 4
created 0.68 59.8413 6
created 0.92 19.9471 2
created 1.16 69.8149 7
created 1.4 9.97356 1
created 1.64 79.7885 8
created 1.88 99.7356 10
created 2.12 59.8413 6
created 2.36 79.7885 8
created 2.6 49.8678 5
created 2.84 9.97356 1
created 3.08 49.8678 5
created 3.32 29.9207 3
created 3.56 19.9471 2
created 3.8 59.8413 6
created 4.04 79.7885 8
created 4.28 59.8413 6
created 4.52 59.8413 6
created 4.76 99.7356 10
created 5 49.8678 5
created 5.24 39.8942 4
created 5.48 79.7885 8
created 5.72 89.762 9
created 5.96 69.8149 7
created 6.2 19.9471 2
created 6.44 9.97356 1
created 6.68 29.9207 3
created 6.92 49.8678 5
created 7.16 69.8149 7
created 7.4 59.8413 6
created 7.64 69.8149 7
created 7.88 49.8678 5
created 8.12 69.8149 7
created 8.36 79.7885 8
created 8.6 19.9471 2
created 8.84 89.762 9
created 9.08 19.9471 2
created 9.32 49.8678 5
created 9.56 79.7885 8
created 9.8 19.9471 2
the total number of created peaks = 83 with sigma = 0.04
the total number of found peaks = 83 with sigma = 0.040002 (+-9.38637e-06)
fit chi^2 = 4.42785e-06
found -8.68 (+-0.000110025) 99.7331 (+-0.27122) 10.0003 (+-0.000942261)
found -3.16 (+-0.000110406) 99.7339 (+-0.271322) 10.0003 (+-0.000942615)
found 1.88 (+-0.000110458) 99.7342 (+-0.271338) 10.0004 (+-0.000942671)
found 4.76 (+-0.000110286) 99.7334 (+-0.271286) 10.0003 (+-0.000942489)
found -9.88 (+-0.000110255) 99.7321 (+-0.271253) 10.0002 (+-0.000942375)
found -5.08 (+-0.000109397) 99.7309 (+-0.271038) 10 (+-0.00094163)
found -2.44 (+-0.000109926) 99.7326 (+-0.271189) 10.0002 (+-0.000942152)
found -8.92 (+-0.000116685) 89.7619 (+-0.257485) 9.00045 (+-0.000894543)
found 5.72 (+-0.000116581) 89.7614 (+-0.257455) 9.0004 (+-0.00089444)
found -1.72 (+-0.000116277) 89.7603 (+-0.257374) 9.00029 (+-0.000894157)
found 8.84 (+-0.000115685) 89.7585 (+-0.257218) 9.0001 (+-0.000893615)
found -9.4 (+-0.00012363) 79.7878 (+-0.242725) 8.00035 (+-0.000843266)
found -7 (+-0.000123296) 79.787 (+-0.242649) 8.00027 (+-0.000843)
found -1.48 (+-0.000123354) 79.7873 (+-0.242664) 8.00029 (+-0.000843053)
found 2.36 (+-0.000123484) 79.7873 (+-0.242689) 8.00029 (+-0.00084314)
found 4.04 (+-0.00012356) 79.7876 (+-0.242708) 8.00032 (+-0.000843206)
found 8.36 (+-0.000123232) 79.7868 (+-0.242632) 8.00024 (+-0.000842943)
found -7.24 (+-0.000123529) 79.7876 (+-0.242702) 8.00032 (+-0.000843184)
found -6.52 (+-0.000122588) 79.7852 (+-0.242483) 8.00008 (+-0.000842425)
found -5.8 (+-0.000123465) 79.7873 (+-0.242685) 8.00029 (+-0.000843128)
found -3.64 (+-0.000123164) 79.7865 (+-0.242615) 8.00021 (+-0.000842883)
found -1 (+-0.000123001) 79.786 (+-0.242575) 8.00016 (+-0.000842744)
found -0.52 (+-0.00012313) 79.7862 (+-0.242604) 8.00018 (+-0.000842845)
found 1.64 (+-0.000123224) 79.7873 (+-0.242639) 8.00029 (+-0.000842967)
found 5.48 (+-0.000123588) 79.7878 (+-0.242717) 8.00035 (+-0.000843237)
found 9.56 (+-0.000123087) 79.7862 (+-0.242596) 8.00018 (+-0.000842817)
found -9.16 (+-0.000132589) 69.8159 (+-0.227143) 7.00045 (+-0.000789131)
found -5.56 (+-0.000131717) 69.8137 (+-0.226963) 7.00024 (+-0.000788505)
found -2.92 (+-0.000131845) 69.8143 (+-0.226993) 7.0003 (+-0.000788608)
found -2.2 (+-0.000132198) 69.8148 (+-0.22706) 7.00035 (+-0.000788843)
found 5.96 (+-0.00013199) 69.8142 (+-0.227017) 7.00029 (+-0.000788693)
found 7.64 (+-0.000132133) 69.8143 (+-0.227042) 7.00029 (+-0.000788778)
found -7.72 (+-0.000131736) 69.8132 (+-0.226957) 7.00019 (+-0.000788484)
found 1.16 (+-0.000131129) 69.8121 (+-0.226837) 7.00008 (+-0.000788067)
found 7.16 (+-0.000132133) 69.8142 (+-0.227042) 7.00029 (+-0.000788778)
found 8.12 (+-0.000132284) 69.8148 (+-0.227075) 7.00035 (+-0.000788895)
found -9.64 (+-0.000143483) 59.8431 (+-0.210347) 6.00048 (+-0.000730778)
found 2.12 (+-0.000143483) 59.8431 (+-0.210347) 6.00048 (+-0.000730778)
found -4.12 (+-0.000142133) 59.8396 (+-0.210094) 6.00013 (+-0.000729898)
found -3.4 (+-0.000143483) 59.8431 (+-0.210347) 6.00048 (+-0.000730778)
found 0.679999 (+-0.000142264) 59.8399 (+-0.210117) 6.00016 (+-0.000729981)
found 4.28 (+-0.000143157) 59.842 (+-0.210283) 6.00037 (+-0.000730557)
found 4.52 (+-0.000143308) 59.8425 (+-0.210313) 6.00043 (+-0.00073066)
found 7.4 (+-0.000143165) 59.842 (+-0.210284) 6.00037 (+-0.000730561)
found 3.8 (+-0.000142646) 59.8409 (+-0.210191) 6.00027 (+-0.000730237)
found 5 (+-0.000156997) 49.869 (+-0.191992) 5.00037 (+-0.000667011)
found 2.6 (+-0.000156196) 49.8676 (+-0.191872) 5.00024 (+-0.000666595)
found 6.92 (+-0.000156567) 49.8679 (+-0.191922) 5.00027 (+-0.000666769)
found 7.88 (+-0.000157082) 49.869 (+-0.192004) 5.00037 (+-0.000667051)
found -4.6 (+-0.000155593) 49.8663 (+-0.191775) 5.00011 (+-0.000666256)
found 3.08 (+-0.000155593) 49.8663 (+-0.191775) 5.00011 (+-0.000666256)
found 9.32 (+-0.000156472) 49.8679 (+-0.19191) 5.00027 (+-0.000666727)
found -7.48 (+-0.000176122) 39.8962 (+-0.171799) 4.0004 (+-0.000596858)
found -0.76 (+-0.000176244) 39.8964 (+-0.171816) 4.00043 (+-0.000596915)
found 5.24 (+-0.000175843) 39.8957 (+-0.171763) 4.00035 (+-0.000596731)
found -6.04 (+-0.000174919) 39.8946 (+-0.171652) 4.00024 (+-0.000596347)
found 0.440002 (+-0.000174671) 39.894 (+-0.171618) 4.00019 (+-0.00059623)
found -0.280003 (+-0.000203181) 29.9221 (+-0.148766) 3.00029 (+-0.000516837)
found -4.36 (+-0.000203319) 29.9221 (+-0.148778) 3.00029 (+-0.000516877)
found -1.96 (+-0.000204153) 29.9234 (+-0.148862) 3.00043 (+-0.000517172)
found 3.32 (+-0.000202365) 29.921 (+-0.148686) 3.00019 (+-0.000516557)
found -7.96 (+-0.000203026) 29.9218 (+-0.14875) 3.00027 (+-0.000516781)
found -0.0400013 (+-0.000201489) 29.9202 (+-0.148604) 3.00011 (+-0.000516272)
found -8.2 (+-0.000201488) 29.9202 (+-0.148604) 3.00011 (+-0.000516272)
found 6.68 (+-0.000201942) 29.9207 (+-0.148648) 3.00016 (+-0.000516428)
found -6.76 (+-0.000251333) 19.9504 (+-0.121636) 2.00043 (+-0.000422582)
found -1.24 (+-0.000251332) 19.9504 (+-0.121636) 2.00043 (+-0.000422582)
found 8.6 (+-0.000251534) 19.9506 (+-0.12165) 2.00045 (+-0.000422631)
found 9.08 (+-0.000250794) 19.9498 (+-0.121599) 2.00037 (+-0.000422454)
found 9.8 (+-0.000247018) 19.9488 (+-0.121386) 2.00027 (+-0.000421713)
found -3.88 (+-0.000250868) 19.9498 (+-0.121603) 2.00037 (+-0.000422469)
found 0.920001 (+-0.000250649) 19.9496 (+-0.121588) 2.00035 (+-0.000422415)
found 6.19999 (+-0.00024865) 19.9482 (+-0.121459) 2.00022 (+-0.000421969)
found 3.56 (+-0.000249462) 19.9485 (+-0.121508) 2.00024 (+-0.000422137)
found -8.44001 (+-0.000357202) 9.97653 (+-0.0860778) 1.00035 (+-0.000299048)
found -4.84001 (+-0.000358429) 9.97705 (+-0.0861202) 1.0004 (+-0.000299195)
found -6.28001 (+-0.000357232) 9.97626 (+-0.0860756) 1.00032 (+-0.00029904)
found -5.31999 (+-0.000359326) 9.97758 (+-0.0861528) 1.00045 (+-0.000299309)
found -2.67999 (+-0.000359326) 9.97759 (+-0.0861528) 1.00046 (+-0.000299309)
found 1.4 (+-0.00035868) 9.97705 (+-0.0861277) 1.0004 (+-0.000299221)
found 2.84 (+-0.000356533) 9.97572 (+-0.0860485) 1.00027 (+-0.000298946)
found 0.200002 (+-0.000354781) 9.97492 (+-0.0859865) 1.00019 (+-0.000298731)
found 6.44 (+-0.000353304) 9.97439 (+-0.0859357) 1.00013 (+-0.000298554)
#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()