created -9.88 49.8678 5
created -9.64 29.9207 3
created -9.4 19.9471 2
created -9.16 69.8149 7
created -8.92 49.8678 5
created -8.68 39.8942 4
created -8.44 59.8413 6
created -8.2 99.7356 10
created -7.96 19.9471 2
created -7.72 79.7885 8
created -7.48 19.9471 2
created -7.24 59.8413 6
created -7 49.8678 5
created -6.76 39.8942 4
created -6.52 19.9471 2
created -6.28 39.8942 4
created -6.04 99.7356 10
created -5.8 9.97356 1
created -5.56 19.9471 2
created -5.32 99.7356 10
created -5.08 29.9207 3
created -4.84 29.9207 3
created -4.6 9.97356 1
created -4.36 99.7356 10
created -4.12 99.7356 10
created -3.88 59.8413 6
created -3.64 79.7885 8
created -3.4 19.9471 2
created -3.16 49.8678 5
created -2.92 69.8149 7
created -2.68 79.7885 8
created -2.44 59.8413 6
created -2.2 99.7356 10
created -1.96 29.9207 3
created -1.72 79.7885 8
created -1.48 39.8942 4
created -1.24 99.7356 10
created -1 19.9471 2
created -0.76 99.7356 10
created -0.52 39.8942 4
created -0.28 49.8678 5
created -0.04 9.97356 1
created 0.2 79.7885 8
created 0.44 69.8149 7
created 0.68 39.8942 4
created 0.92 19.9471 2
created 1.16 39.8942 4
created 1.4 89.762 9
created 1.64 19.9471 2
created 1.88 99.7356 10
created 2.12 29.9207 3
created 2.36 9.97356 1
created 2.6 39.8942 4
created 2.84 39.8942 4
created 3.08 19.9471 2
created 3.32 59.8413 6
created 3.56 29.9207 3
created 3.8 89.762 9
created 4.04 29.9207 3
created 4.28 89.762 9
created 4.52 99.7356 10
created 4.76 39.8942 4
created 5 9.97356 1
created 5.24 39.8942 4
created 5.48 19.9471 2
created 5.72 69.8149 7
created 5.96 79.7885 8
created 6.2 79.7885 8
created 6.44 99.7356 10
created 6.68 9.97356 1
created 6.92 49.8678 5
created 7.16 39.8942 4
created 7.4 9.97356 1
created 7.64 39.8942 4
created 7.88 49.8678 5
created 8.12 39.8942 4
created 8.36 59.8413 6
created 8.6 89.762 9
created 8.84 79.7885 8
created 9.08 99.7356 10
created 9.32 89.762 9
created 9.56 59.8413 6
created 9.8 39.8942 4
the total number of created peaks = 83 with sigma = 0.04
the total number of found peaks = 83 with sigma = 0.040002 (+-1.23912e-05)
fit chi^2 = 7.51721e-06
found -8.2 (+-0.000143353) 99.7326 (+-0.353377) 10.0002 (+-0.00122769)
found -4.12 (+-0.000144044) 99.7347 (+-0.353582) 10.0004 (+-0.0012284)
found -2.2 (+-0.000143493) 99.7328 (+-0.353416) 10.0002 (+-0.00122782)
found 4.52 (+-0.000143808) 99.7339 (+-0.353511) 10.0003 (+-0.00122815)
found 6.44 (+-0.000143297) 99.7328 (+-0.35337) 10.0002 (+-0.00122766)
found 9.08 (+-0.000144128) 99.735 (+-0.353607) 10.0005 (+-0.00122849)
found -6.04 (+-0.000142983) 99.7317 (+-0.353274) 10.0001 (+-0.00122733)
found -5.32 (+-0.000143068) 99.7317 (+-0.353294) 10.0001 (+-0.0012274)
found -4.36 (+-0.000143417) 99.7333 (+-0.353408) 10.0003 (+-0.0012278)
found -1.24 (+-0.000143178) 99.7321 (+-0.353325) 10.0002 (+-0.00122751)
found -0.76 (+-0.000143178) 99.732 (+-0.353325) 10.0002 (+-0.00122751)
found 1.88 (+-0.000143068) 99.7318 (+-0.353294) 10.0001 (+-0.0012274)
found 8.6 (+-0.00015182) 89.7611 (+-0.335432) 9.00037 (+-0.00116534)
found 9.32 (+-0.000151954) 89.7617 (+-0.335471) 9.00042 (+-0.00116548)
found 1.4 (+-0.000151005) 89.759 (+-0.335215) 9.00016 (+-0.00116459)
found 3.8 (+-0.000151037) 89.759 (+-0.335221) 9.00016 (+-0.00116461)
found 4.28 (+-0.000151638) 89.7609 (+-0.335387) 9.00035 (+-0.00116519)
found -3.64 (+-0.000160478) 79.7865 (+-0.316118) 8.00021 (+-0.00109825)
found -2.68 (+-0.000161085) 79.7878 (+-0.316262) 8.00035 (+-0.00109874)
found 5.96 (+-0.000161259) 79.7884 (+-0.316306) 8.0004 (+-0.0010989)
found 6.2 (+-0.000161493) 79.7891 (+-0.316366) 8.00048 (+-0.0010991)
found 8.84 (+-0.00016157) 79.7894 (+-0.316386) 8.00051 (+-0.00109917)
found -7.72 (+-0.000159965) 79.7854 (+-0.315997) 8.00011 (+-0.00109782)
found -1.72 (+-0.000160434) 79.7863 (+-0.316104) 8.00019 (+-0.0010982)
found 0.200001 (+-0.000160327) 79.7865 (+-0.31609) 8.00021 (+-0.00109815)
found 0.439999 (+-0.000172232) 69.8145 (+-0.295843) 7.00032 (+-0.00102781)
found -9.16 (+-0.000171586) 69.8132 (+-0.295706) 7.00018 (+-0.00102733)
found -2.92 (+-0.000172361) 69.8148 (+-0.295871) 7.00034 (+-0.0010279)
found 5.72 (+-0.000171892) 69.814 (+-0.295775) 7.00027 (+-0.00102757)
found -3.88 (+-0.000186953) 59.8431 (+-0.274074) 6.00048 (+-0.000952176)
found 9.56 (+-0.000186351) 59.8418 (+-0.273959) 6.00035 (+-0.000951777)
found -8.44 (+-0.000186446) 59.842 (+-0.273978) 6.00037 (+-0.000951843)
found -2.44 (+-0.000186953) 59.8431 (+-0.274074) 6.00048 (+-0.000952176)
found 8.36 (+-0.000186351) 59.8417 (+-0.273959) 6.00035 (+-0.000951777)
found -7.24 (+-0.000185509) 59.8401 (+-0.273802) 6.00019 (+-0.000951233)
found 3.32 (+-0.000185194) 59.8396 (+-0.273744) 6.00013 (+-0.000951031)
found -8.92 (+-0.000204203) 49.8682 (+-0.250099) 5.00029 (+-0.000868882)
found -7 (+-0.000204064) 49.8679 (+-0.250076) 5.00026 (+-0.000868803)
found -0.280001 (+-0.00020293) 49.8666 (+-0.249906) 5.00014 (+-0.000868215)
found 7.88 (+-0.000203738) 49.8674 (+-0.250024) 5.00021 (+-0.000868622)
found -9.88 (+-0.000203163) 49.8661 (+-0.249914) 5.00008 (+-0.000868242)
found -3.16 (+-0.000203749) 49.8676 (+-0.250031) 5.00024 (+-0.000868646)
found 6.92 (+-0.00020293) 49.8666 (+-0.249906) 5.00013 (+-0.000868215)
found -0.520002 (+-0.000229399) 39.8962 (+-0.223839) 4.0004 (+-0.000777652)
found 4.76 (+-0.000228191) 39.8951 (+-0.223695) 4.0003 (+-0.000777151)
found -8.68 (+-0.000228787) 39.8951 (+-0.223757) 4.00029 (+-0.000777366)
found -6.76 (+-0.000227834) 39.8941 (+-0.223637) 4.00019 (+-0.000776949)
found -1.48 (+-0.000229923) 39.897 (+-0.223908) 4.00048 (+-0.000777891)
found 0.679998 (+-0.000228191) 39.8946 (+-0.223684) 4.00024 (+-0.000777114)
found 2.84 (+-0.000227623) 39.8938 (+-0.223609) 4.00016 (+-0.000776854)
found 7.16 (+-0.000227403) 39.8938 (+-0.223588) 4.00016 (+-0.000776779)
found 8.12 (+-0.000228787) 39.8951 (+-0.223757) 4.00029 (+-0.000777366)
found 9.8 (+-0.000226348) 39.8948 (+-0.223498) 4.00026 (+-0.000776466)
found -6.28 (+-0.000228626) 39.8954 (+-0.223744) 4.00032 (+-0.000777321)
found 1.16 (+-0.000228492) 39.8951 (+-0.223725) 4.00029 (+-0.000777256)
found 2.6 (+-0.000227193) 39.8935 (+-0.22356) 4.00013 (+-0.000776684)
found 5.24 (+-0.00022665) 39.893 (+-0.223493) 4.00008 (+-0.000776449)
found 7.64 (+-0.000227403) 39.8938 (+-0.223588) 4.00016 (+-0.000776779)
found -5.08 (+-0.000265095) 29.9226 (+-0.193874) 3.00035 (+-0.00067355)
found -1.96 (+-0.000266384) 29.9239 (+-0.194001) 3.00048 (+-0.000673991)
found 2.11999 (+-0.00026414) 29.9221 (+-0.193789) 3.0003 (+-0.000673255)
found 4.04 (+-0.000266398) 29.9239 (+-0.194003) 3.00048 (+-0.000673996)
found -9.64 (+-0.000263674) 29.921 (+-0.193732) 3.00019 (+-0.000673055)
found 3.56 (+-0.000265779) 29.9231 (+-0.19394) 3.0004 (+-0.000673777)
found -4.84 (+-0.000262532) 29.9202 (+-0.193625) 3.00011 (+-0.000672684)
found -7.96 (+-0.00032798) 19.9509 (+-0.158523) 2.00048 (+-0.000550733)
found -7.48 (+-0.000326872) 19.9498 (+-0.158445) 2.00037 (+-0.000550462)
found -3.4 (+-0.000326515) 19.9496 (+-0.15842) 2.00035 (+-0.000550377)
found -1 (+-0.000328486) 19.9514 (+-0.158559) 2.00053 (+-0.000550858)
found 1.64 (+-0.000328244) 19.9512 (+-0.158541) 2.00051 (+-0.000550798)
found -9.4 (+-0.000325352) 19.9488 (+-0.158342) 2.00027 (+-0.000550105)
found -6.52 (+-0.000324758) 19.9482 (+-0.1583) 2.00021 (+-0.000549958)
found 0.92 (+-0.000324758) 19.9482 (+-0.1583) 2.00021 (+-0.000549958)
found 3.08 (+-0.000325512) 19.9488 (+-0.158351) 2.00027 (+-0.000550136)
found 5.48 (+-0.000325826) 19.949 (+-0.158373) 2.00029 (+-0.000550213)
found -5.55999 (+-0.00032475) 19.9491 (+-0.158313) 2.0003 (+-0.000550004)
found -5.80002 (+-0.000464322) 9.97628 (+-0.11212) 1.00032 (+-0.000389521)
found 6.67999 (+-0.00046702) 9.97706 (+-0.112211) 1.0004 (+-0.00038984)
found -0.0399941 (+-0.000466183) 9.97652 (+-0.112179) 1.00035 (+-0.000389727)
found 5 (+-0.000463122) 9.97519 (+-0.112067) 1.00021 (+-0.000389339)
found 7.4 (+-0.000463122) 9.97518 (+-0.112067) 1.00021 (+-0.000389339)
found -4.59999 (+-0.000465421) 9.97653 (+-0.112156) 1.00035 (+-0.000389648)
found 2.36 (+-0.000462266) 9.97492 (+-0.112037) 1.00019 (+-0.000389235)
#include <iostream>
TH1F *FitAwmi_Create_Spectrum(
void) {
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;
Areas[i] *= dx;
AreasErrors[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)
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
A PolyMarker is defined by an array on N points in a 2-D space.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
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()