created -9.88 99.7356 10
created -9.64 29.9207 3
created -9.4 59.8413 6
created -9.16 9.97356 1
created -8.92 69.8149 7
created -8.68 79.7885 8
created -8.44 39.8942 4
created -8.2 49.8678 5
created -7.96 49.8678 5
created -7.72 19.9471 2
created -7.48 39.8942 4
created -7.24 59.8413 6
created -7 19.9471 2
created -6.76 99.7356 10
created -6.52 39.8942 4
created -6.28 99.7356 10
created -6.04 89.762 9
created -5.8 39.8942 4
created -5.56 69.8149 7
created -5.32 79.7885 8
created -5.08 29.9207 3
created -4.84 19.9471 2
created -4.6 49.8678 5
created -4.36 39.8942 4
created -4.12 39.8942 4
created -3.88 99.7356 10
created -3.64 29.9207 3
created -3.4 39.8942 4
created -3.16 79.7885 8
created -2.92 89.762 9
created -2.68 19.9471 2
created -2.44 39.8942 4
created -2.2 59.8413 6
created -1.96 9.97356 1
created -1.72 69.8149 7
created -1.48 39.8942 4
created -1.24 79.7885 8
created -1 69.8149 7
created -0.76 29.9207 3
created -0.52 99.7356 10
created -0.28 69.8149 7
created -0.04 49.8678 5
created 0.2 99.7356 10
created 0.44 89.762 9
created 0.68 69.8149 7
created 0.92 9.97356 1
created 1.16 19.9471 2
created 1.4 69.8149 7
created 1.64 59.8413 6
created 1.88 49.8678 5
created 2.12 59.8413 6
created 2.36 19.9471 2
created 2.6 79.7885 8
created 2.84 9.97356 1
created 3.08 49.8678 5
created 3.32 39.8942 4
created 3.56 89.762 9
created 3.8 89.762 9
created 4.04 59.8413 6
created 4.28 19.9471 2
created 4.52 39.8942 4
created 4.76 19.9471 2
created 5 29.9207 3
created 5.24 29.9207 3
created 5.48 79.7885 8
created 5.72 89.762 9
created 5.96 29.9207 3
created 6.2 69.8149 7
created 6.44 69.8149 7
created 6.68 59.8413 6
created 6.92 69.8149 7
created 7.16 29.9207 3
created 7.4 39.8942 4
created 7.64 19.9471 2
created 7.88 19.9471 2
created 8.12 69.8149 7
created 8.36 59.8413 6
created 8.6 19.9471 2
created 8.84 99.7356 10
created 9.08 19.9471 2
created 9.32 39.8942 4
created 9.56 79.7885 8
created 9.8 89.762 9
the total number of created peaks = 83 with sigma = 0.04
the total number of found peaks = 83 with sigma = 0.040002 (+-1.75837e-05)
fit chi^2 = 1.52656e-05
found -9.88 (+-0.00020431) 99.7314 (+-0.503537) 10.0001 (+-0.00174937)
found -6.76 (+-0.000204035) 99.7321 (+-0.503504) 10.0002 (+-0.00174925)
found -6.28 (+-0.000204933) 99.734 (+-0.503769) 10.0003 (+-0.00175017)
found -3.88 (+-0.000204234) 99.7323 (+-0.503559) 10.0002 (+-0.00174944)
found -0.519999 (+-0.000204589) 99.7332 (+-0.503665) 10.0003 (+-0.00174981)
found 0.200001 (+-0.000205067) 99.7342 (+-0.503808) 10.0004 (+-0.00175031)
found 8.84 (+-0.00020368) 99.7315 (+-0.503404) 10.0001 (+-0.00174891)
found -6.04 (+-0.000216264) 89.7612 (+-0.477986) 9.00037 (+-0.0016606)
found -2.92 (+-0.000215681) 89.7601 (+-0.477832) 9.00026 (+-0.00166006)
found 0.439999 (+-0.000216657) 89.762 (+-0.478093) 9.00045 (+-0.00166097)
found 3.8 (+-0.000216448) 89.7614 (+-0.478034) 9.0004 (+-0.00166076)
found 5.72 (+-0.0002159) 89.7604 (+-0.477886) 9.00029 (+-0.00166025)
found 9.8 (+-0.00021457) 89.7619 (+-0.477602) 9.00045 (+-0.00165926)
found 3.56 (+-0.000216172) 89.7609 (+-0.477959) 9.00034 (+-0.00166051)
found -8.68 (+-0.000229248) 79.7873 (+-0.450613) 8.00029 (+-0.0015655)
found -5.32 (+-0.000229056) 79.7871 (+-0.450569) 8.00026 (+-0.00156535)
found -3.16 (+-0.000229476) 79.7879 (+-0.450672) 8.00034 (+-0.0015657)
found -1.24 (+-0.000229248) 79.7873 (+-0.450613) 8.00029 (+-0.0015655)
found 2.6 (+-0.000227619) 79.7852 (+-0.450238) 8.00008 (+-0.0015642)
found 5.48 (+-0.000229284) 79.7876 (+-0.450627) 8.00032 (+-0.00156555)
found 9.56 (+-0.000229476) 79.7879 (+-0.450672) 8.00035 (+-0.0015657)
found -1 (+-0.000245223) 69.8143 (+-0.421545) 7.00029 (+-0.00146451)
found -0.280001 (+-0.000245862) 69.8154 (+-0.421684) 7.0004 (+-0.001465)
found 0.679998 (+-0.000244691) 69.814 (+-0.421448) 7.00026 (+-0.00146418)
found 6.44 (+-0.000245649) 69.8148 (+-0.421634) 7.00035 (+-0.00146482)
found 6.92 (+-0.000244945) 69.8138 (+-0.421483) 7.00024 (+-0.0014643)
found -8.92 (+-0.000244569) 69.8138 (+-0.42142) 7.00024 (+-0.00146408)
found -5.56 (+-0.000245438) 69.8146 (+-0.42159) 7.00032 (+-0.00146467)
found -1.72 (+-0.000243954) 69.8127 (+-0.421284) 7.00013 (+-0.0014636)
found 1.4 (+-0.000244676) 69.8135 (+-0.42143) 7.00021 (+-0.00146411)
found 6.2 (+-0.00024509) 69.814 (+-0.421515) 7.00027 (+-0.00146441)
found 8.12 (+-0.000244676) 69.8135 (+-0.42143) 7.00021 (+-0.00146411)
found 4.04 (+-0.000265005) 59.8413 (+-0.390307) 6.00029 (+-0.00135599)
found -9.4 (+-0.000263475) 59.8394 (+-0.390026) 6.00011 (+-0.00135501)
found -7.24 (+-0.000264152) 59.8399 (+-0.390142) 6.00016 (+-0.00135541)
found -2.2 (+-0.000263716) 59.8396 (+-0.39007) 6.00013 (+-0.00135517)
found 1.64 (+-0.000265471) 59.8415 (+-0.390384) 6.00032 (+-0.00135626)
found 2.12 (+-0.000264359) 59.8402 (+-0.39018) 6.00019 (+-0.00135555)
found 6.68 (+-0.000265825) 59.842 (+-0.390452) 6.00037 (+-0.00135649)
found 8.36 (+-0.000264709) 59.8407 (+-0.390248) 6.00024 (+-0.00135578)
found -8.2 (+-0.000290582) 49.8677 (+-0.356334) 5.00024 (+-0.00123796)
found -7.96 (+-0.000289937) 49.8671 (+-0.356237) 5.00019 (+-0.00123762)
found -0.0399989 (+-0.00029218) 49.8698 (+-0.356594) 5.00045 (+-0.00123886)
found 1.88 (+-0.000291267) 49.8685 (+-0.356443) 5.00032 (+-0.00123834)
found -4.6 (+-0.000289693) 49.8669 (+-0.356198) 5.00016 (+-0.00123749)
found 3.08 (+-0.000289185) 49.8666 (+-0.356128) 5.00014 (+-0.00123724)
found -6.52 (+-0.000328055) 39.8975 (+-0.319133) 4.00053 (+-0.00110872)
found -5.8 (+-0.000327228) 39.8965 (+-0.319022) 4.00043 (+-0.00110833)
found -8.44 (+-0.000326501) 39.8957 (+-0.318926) 4.00035 (+-0.001108)
found -4.36 (+-0.000325458) 39.8946 (+-0.318789) 4.00024 (+-0.00110752)
found -4.12 (+-0.000326596) 39.8959 (+-0.318941) 4.00037 (+-0.00110805)
found -3.4 (+-0.000325841) 39.8952 (+-0.318842) 4.0003 (+-0.00110771)
found -1.48 (+-0.000327019) 39.8962 (+-0.318993) 4.0004 (+-0.00110823)
found 3.32 (+-0.000326709) 39.8959 (+-0.318954) 4.00037 (+-0.0011081)
found 7.4 (+-0.000324024) 39.8935 (+-0.318609) 4.00013 (+-0.0011069)
found -7.48 (+-0.00032494) 39.8943 (+-0.318727) 4.00021 (+-0.00110731)
found -2.44 (+-0.00032494) 39.8944 (+-0.318727) 4.00021 (+-0.00110731)
found 4.52 (+-0.000323594) 39.8933 (+-0.318557) 4.00011 (+-0.00110672)
found 9.32 (+-0.000325405) 39.8949 (+-0.31879) 4.00027 (+-0.00110753)
found -9.64 (+-0.000378995) 29.9234 (+-0.276398) 3.00043 (+-0.000960251)
found -5.08 (+-0.000376695) 29.9218 (+-0.276173) 3.00027 (+-0.00095947)
found -3.64 (+-0.000378237) 29.9229 (+-0.276324) 3.00037 (+-0.000959992)
found 5.96 (+-0.000379067) 29.9234 (+-0.276405) 3.00043 (+-0.000960273)
found -0.759998 (+-0.000379316) 29.9237 (+-0.276431) 3.00045 (+-0.000960363)
found 7.16 (+-0.000377436) 29.9221 (+-0.27624) 3.00029 (+-0.000959702)
found 5 (+-0.000374899) 29.9205 (+-0.275993) 3.00013 (+-0.000958842)
found 5.24 (+-0.000377262) 29.9221 (+-0.276226) 3.00029 (+-0.000959652)
found -2.68 (+-0.000465089) 19.9496 (+-0.225744) 2.00035 (+-0.000784269)
found 9.07999 (+-0.000465429) 19.9498 (+-0.225768) 2.00038 (+-0.000784355)
found -7.72 (+-0.000463366) 19.9485 (+-0.225623) 2.00024 (+-0.000783848)
found -7 (+-0.00046652) 19.9504 (+-0.225842) 2.00043 (+-0.00078461)
found 2.36 (+-0.000465806) 19.9498 (+-0.225791) 2.00037 (+-0.000784432)
found 4.28 (+-0.000463868) 19.9488 (+-0.225657) 2.00027 (+-0.000783968)
found 8.6 (+-0.00046652) 19.9504 (+-0.225842) 2.00043 (+-0.00078461)
found -4.84 (+-0.000462696) 19.9482 (+-0.225578) 2.00021 (+-0.000783694)
found 4.76 (+-0.000462127) 19.948 (+-0.225539) 2.00019 (+-0.000783559)
found 7.64 (+-0.00046131) 19.9477 (+-0.225487) 2.00016 (+-0.000783376)
found 7.88 (+-0.000462817) 19.9485 (+-0.225591) 2.00024 (+-0.00078374)
found 1.16001 (+-0.000461688) 19.9483 (+-0.225523) 2.00022 (+-0.000783502)
found 2.83999 (+-0.000664331) 9.97652 (+-0.15986) 1.00035 (+-0.000555378)
found 0.91999 (+-0.00065983) 9.97548 (+-0.159703) 1.00024 (+-0.000554833)
found -9.16 (+-0.000664524) 9.97652 (+-0.159865) 1.00035 (+-0.000555398)
found -1.96 (+-0.000664525) 9.97652 (+-0.159865) 1.00035 (+-0.000555398)
#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()