created -9.88 99.7356 10
created -9.64 49.8678 5
created -9.4 89.762 9
created -9.16 49.8678 5
created -8.92 99.7356 10
created -8.68 79.7885 8
created -8.44 69.8149 7
created -8.2 79.7885 8
created -7.96 9.97356 1
created -7.72 69.8149 7
created -7.48 49.8678 5
created -7.24 19.9471 2
created -7 29.9207 3
created -6.76 89.762 9
created -6.52 9.97356 1
created -6.28 39.8942 4
created -6.04 39.8942 4
created -5.8 69.8149 7
created -5.56 9.97356 1
created -5.32 59.8413 6
created -5.08 69.8149 7
created -4.84 89.762 9
created -4.6 89.762 9
created -4.36 69.8149 7
created -4.12 19.9471 2
created -3.88 29.9207 3
created -3.64 59.8413 6
created -3.4 19.9471 2
created -3.16 79.7885 8
created -2.92 29.9207 3
created -2.68 49.8678 5
created -2.44 9.97356 1
created -2.2 9.97356 1
created -1.96 79.7885 8
created -1.72 69.8149 7
created -1.48 99.7356 10
created -1.24 19.9471 2
created -1 29.9207 3
created -0.76 99.7356 10
created -0.52 59.8413 6
created -0.28 49.8678 5
created -0.04 29.9207 3
created 0.2 19.9471 2
created 0.44 29.9207 3
created 0.68 9.97356 1
created 0.92 69.8149 7
created 1.16 19.9471 2
created 1.4 99.7356 10
created 1.64 89.762 9
created 1.88 39.8942 4
created 2.12 49.8678 5
created 2.36 69.8149 7
created 2.6 49.8678 5
created 2.84 89.762 9
created 3.08 99.7356 10
created 3.32 39.8942 4
created 3.56 89.762 9
created 3.8 69.8149 7
created 4.04 89.762 9
created 4.28 29.9207 3
created 4.52 39.8942 4
created 4.76 39.8942 4
created 5 79.7885 8
created 5.24 99.7356 10
created 5.48 69.8149 7
created 5.72 89.762 9
created 5.96 29.9207 3
created 6.2 69.8149 7
created 6.44 49.8678 5
created 6.68 99.7356 10
created 6.92 89.762 9
created 7.16 39.8942 4
created 7.4 29.9207 3
created 7.64 69.8149 7
created 7.88 99.7356 10
created 8.12 59.8413 6
created 8.36 49.8678 5
created 8.6 19.9471 2
created 8.84 19.9471 2
created 9.08 99.7356 10
created 9.32 79.7885 8
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.05937e-05)
fit chi^2 = 5.83749e-06
found -1.48 (+-0.00012639) 99.7328 (+-0.311424) 10.0002 (+-0.00108193)
found 3.08 (+-0.000126727) 99.7339 (+-0.311521) 10.0003 (+-0.00108227)
found 5.24 (+-0.000126893) 99.7344 (+-0.31157) 10.0004 (+-0.00108244)
found 7.88 (+-0.000126768) 99.7339 (+-0.311531) 10.0003 (+-0.00108231)
found -9.88 (+-0.000126522) 99.7319 (+-0.31143) 10.0001 (+-0.00108196)
found -8.92 (+-0.000126755) 99.7339 (+-0.311528) 10.0003 (+-0.0010823)
found -0.759999 (+-0.000126449) 99.7328 (+-0.311438) 10.0002 (+-0.00108198)
found 1.4 (+-0.000126505) 99.7334 (+-0.31146) 10.0003 (+-0.00108206)
found 6.68 (+-0.00012681) 99.7342 (+-0.311546) 10.0004 (+-0.00108236)
found 9.08 (+-0.00012645) 99.7331 (+-0.311442) 10.0003 (+-0.001082)
found -4.84 (+-0.00013392) 89.7617 (+-0.295627) 9.00042 (+-0.00102706)
found -4.6 (+-0.00013392) 89.7617 (+-0.295627) 9.00042 (+-0.00102706)
found 1.64 (+-0.000133734) 89.7611 (+-0.295578) 9.00037 (+-0.00102688)
found 4.04 (+-0.000133443) 89.7601 (+-0.295498) 9.00026 (+-0.00102661)
found 5.72 (+-0.000133443) 89.7601 (+-0.295498) 9.00027 (+-0.00102661)
found 6.92 (+-0.000133734) 89.7611 (+-0.295578) 9.00037 (+-0.00102688)
found -9.4 (+-0.00013349) 89.7601 (+-0.295508) 9.00027 (+-0.00102664)
found -6.76 (+-0.000132774) 89.7584 (+-0.295326) 9.0001 (+-0.00102601)
found 2.84 (+-0.000133825) 89.7614 (+-0.295602) 9.0004 (+-0.00102697)
found 3.56 (+-0.000133551) 89.7604 (+-0.295525) 9.00029 (+-0.0010267)
found -8.68 (+-0.000142237) 79.7889 (+-0.27877) 8.00045 (+-0.00096849)
found -8.2 (+-0.000141284) 79.7865 (+-0.278545) 8.00021 (+-0.00096771)
found 9.32 (+-0.000141486) 79.7873 (+-0.278598) 8.00029 (+-0.000967893)
found -3.16 (+-0.000141112) 79.7857 (+-0.278497) 8.00013 (+-0.000967542)
found -1.96 (+-0.000141284) 79.7865 (+-0.278545) 8.00021 (+-0.000967711)
found 5 (+-0.000141967) 79.7881 (+-0.278704) 8.00037 (+-0.000968261)
found -8.44 (+-0.000152161) 69.8156 (+-0.260788) 7.00043 (+-0.000906018)
found -5.08 (+-0.000152065) 69.8153 (+-0.260767) 7.0004 (+-0.000905945)
found -4.36 (+-0.000151551) 69.8143 (+-0.26066) 7.00029 (+-0.000905576)
found -1.72 (+-0.000152311) 69.8161 (+-0.260822) 7.00048 (+-0.000906137)
found 3.8 (+-0.000152316) 69.8161 (+-0.260823) 7.00048 (+-0.00090614)
found 5.48 (+-0.000152389) 69.8164 (+-0.26084) 7.00051 (+-0.000906198)
found -7.72 (+-0.000150968) 69.8129 (+-0.260538) 7.00016 (+-0.000905151)
found -5.8 (+-0.000150857) 69.8127 (+-0.260514) 7.00013 (+-0.000905067)
found 0.92 (+-0.000150562) 69.8121 (+-0.260454) 7.00008 (+-0.000904857)
found 2.36 (+-0.000151616) 69.814 (+-0.260667) 7.00027 (+-0.000905599)
found 6.2 (+-0.000151371) 69.8135 (+-0.260616) 7.00021 (+-0.00090542)
found 7.64 (+-0.00015179) 69.8148 (+-0.26071) 7.00035 (+-0.000905748)
found -0.520002 (+-0.00016443) 59.8423 (+-0.241459) 6.0004 (+-0.000838868)
found 8.12 (+-0.00016443) 59.8423 (+-0.241459) 6.0004 (+-0.000838868)
found -3.64 (+-0.000163197) 59.8396 (+-0.241229) 6.00013 (+-0.000838068)
found -5.32 (+-0.00016342) 59.8404 (+-0.241278) 6.00021 (+-0.000838238)
found -9.64 (+-0.000180899) 49.8703 (+-0.220547) 5.0005 (+-0.000766217)
found -9.16 (+-0.000180899) 49.8703 (+-0.220547) 5.00051 (+-0.000766217)
found -7.48 (+-0.000179548) 49.8676 (+-0.220332) 5.00024 (+-0.00076547)
found -2.68 (+-0.000178651) 49.8663 (+-0.220196) 5.00011 (+-0.000764995)
found -0.280001 (+-0.000179648) 49.8676 (+-0.220345) 5.00024 (+-0.000765513)
found 2.12 (+-0.000179948) 49.8682 (+-0.220392) 5.00029 (+-0.000765678)
found 2.6 (+-0.00018058) 49.8695 (+-0.220495) 5.00043 (+-0.000766033)
found 6.44 (+-0.000180679) 49.8698 (+-0.220511) 5.00045 (+-0.00076609)
found 8.36 (+-0.000179426) 49.8674 (+-0.220312) 5.00021 (+-0.0007654)
found 1.88 (+-0.000202031) 39.8959 (+-0.197235) 4.00037 (+-0.000685226)
found 3.32 (+-0.000202742) 39.8973 (+-0.19733) 4.00051 (+-0.000685555)
found 7.16 (+-0.000201622) 39.8954 (+-0.197184) 4.00032 (+-0.000685048)
found -6.04 (+-0.000201575) 39.8951 (+-0.197175) 4.00029 (+-0.000685017)
found 4.52 (+-0.000200853) 39.8941 (+-0.197082) 4.00019 (+-0.000684693)
found 4.76 (+-0.000201714) 39.8954 (+-0.197194) 4.00032 (+-0.000685082)
found -6.28 (+-0.000200207) 39.8936 (+-0.197006) 4.00014 (+-0.000684431)
found -2.92 (+-0.000233826) 29.9226 (+-0.170865) 3.00035 (+-0.000593611)
found 4.28 (+-0.000233743) 29.9226 (+-0.170858) 3.00035 (+-0.000593586)
found 5.96 (+-0.000234408) 29.9234 (+-0.170924) 3.00043 (+-0.000593816)
found -0.0400019 (+-0.000232355) 29.921 (+-0.170721) 3.00019 (+-0.00059311)
found -7 (+-0.000233105) 29.9221 (+-0.170798) 3.00029 (+-0.000593378)
found -3.88 (+-0.00023257) 29.9213 (+-0.170742) 3.00021 (+-0.000593186)
found -0.999995 (+-0.000233256) 29.9224 (+-0.170814) 3.00032 (+-0.000593434)
found 0.439999 (+-0.000231007) 29.92 (+-0.170594) 3.00008 (+-0.000592671)
found 7.4 (+-0.0002334) 29.9221 (+-0.170822) 3.0003 (+-0.000593463)
found 9.8 (+-0.000229119) 29.9202 (+-0.17045) 3.00011 (+-0.000592171)
found -1.24001 (+-0.000287393) 19.9496 (+-0.139584) 2.00035 (+-0.000484936)
found -7.24 (+-0.000286123) 19.9482 (+-0.139493) 2.00022 (+-0.000484622)
found -4.12 (+-0.000286707) 19.9488 (+-0.139534) 2.00027 (+-0.000484764)
found -3.4 (+-0.000288046) 19.9498 (+-0.139625) 2.00037 (+-0.000485079)
found 1.16 (+-0.000288769) 19.9506 (+-0.139676) 2.00045 (+-0.000485256)
found 8.6 (+-0.000285616) 19.948 (+-0.139461) 2.00019 (+-0.000484509)
found 0.2 (+-0.00028536) 19.9477 (+-0.139442) 2.00016 (+-0.000484444)
found 8.84001 (+-0.00028688) 19.9493 (+-0.139551) 2.00032 (+-0.000484822)
found -7.96 (+-0.000411835) 9.97705 (+-0.0988918) 1.0004 (+-0.000343566)
found -6.52001 (+-0.000410557) 9.97652 (+-0.0988468) 1.00035 (+-0.000343409)
found 9.55999 (+-0.000409408) 9.976 (+-0.0988056) 1.0003 (+-0.000343266)
found -5.56 (+-0.00041093) 9.97652 (+-0.0988579) 1.00035 (+-0.000343448)
found -2.44001 (+-0.000405709) 9.97467 (+-0.0986775) 1.00016 (+-0.000342821)
found 0.680008 (+-0.000408989) 9.97572 (+-0.0987895) 1.00027 (+-0.00034321)
found -2.19999 (+-0.000407113) 9.97548 (+-0.098731) 1.00024 (+-0.000343007)
#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()