created -9.88 69.8149 7
created -9.64 59.8413 6
created -9.4 89.762 9
created -9.16 9.97356 1
created -8.92 59.8413 6
created -8.68 79.7885 8
created -8.44 79.7885 8
created -8.2 59.8413 6
created -7.96 79.7885 8
created -7.72 79.7885 8
created -7.48 89.762 9
created -7.24 19.9471 2
created -7 9.97356 1
created -6.76 99.7356 10
created -6.52 9.97356 1
created -6.28 59.8413 6
created -6.04 69.8149 7
created -5.8 59.8413 6
created -5.56 69.8149 7
created -5.32 29.9207 3
created -5.08 89.762 9
created -4.84 59.8413 6
created -4.6 59.8413 6
created -4.36 29.9207 3
created -4.12 59.8413 6
created -3.88 39.8942 4
created -3.64 9.97356 1
created -3.4 49.8678 5
created -3.16 39.8942 4
created -2.92 69.8149 7
created -2.68 9.97356 1
created -2.44 19.9471 2
created -2.2 79.7885 8
created -1.96 49.8678 5
created -1.72 29.9207 3
created -1.48 69.8149 7
created -1.24 59.8413 6
created -1 59.8413 6
created -0.76 29.9207 3
created -0.52 89.762 9
created -0.28 9.97356 1
created -0.04 39.8942 4
created 0.2 9.97356 1
created 0.44 79.7885 8
created 0.68 19.9471 2
created 0.92 69.8149 7
created 1.16 29.9207 3
created 1.4 29.9207 3
created 1.64 79.7885 8
created 1.88 99.7356 10
created 2.12 49.8678 5
created 2.36 99.7356 10
created 2.6 9.97356 1
created 2.84 19.9471 2
created 3.08 49.8678 5
created 3.32 19.9471 2
created 3.56 49.8678 5
created 3.8 59.8413 6
created 4.04 9.97356 1
created 4.28 99.7356 10
created 4.52 69.8149 7
created 4.76 49.8678 5
created 5 9.97356 1
created 5.24 39.8942 4
created 5.48 89.762 9
created 5.72 29.9207 3
created 5.96 49.8678 5
created 6.2 9.97356 1
created 6.44 99.7356 10
created 6.68 49.8678 5
created 6.92 9.97356 1
created 7.16 29.9207 3
created 7.4 69.8149 7
created 7.64 99.7356 10
created 7.88 39.8942 4
created 8.12 79.7885 8
created 8.36 89.762 9
created 8.6 39.8942 4
created 8.84 49.8678 5
created 9.08 79.7885 8
created 9.32 69.8149 7
created 9.56 69.8149 7
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.61278e-06)
fit chi^2 = 4.47237e-06
found 1.88 (+-0.000110948) 99.7339 (+-0.27268) 10.0003 (+-0.000947333)
found 7.64 (+-0.000110823) 99.7334 (+-0.272642) 10.0003 (+-0.000947203)
found -6.76 (+-0.000109946) 99.7309 (+-0.272398) 10 (+-0.000946353)
found 2.36 (+-0.000110358) 99.732 (+-0.272512) 10.0002 (+-0.000946751)
found 4.28 (+-0.000110477) 99.7326 (+-0.272549) 10.0002 (+-0.000946878)
found 6.44 (+-0.000110358) 99.732 (+-0.272512) 10.0002 (+-0.000946751)
found -9.4 (+-0.000116456) 89.7593 (+-0.258562) 9.00018 (+-0.000898286)
found -7.48 (+-0.000116742) 89.76 (+-0.258635) 9.00026 (+-0.00089854)
found 8.36 (+-0.000116954) 89.7606 (+-0.258689) 9.00032 (+-0.000898726)
found -5.08 (+-0.00011674) 89.7598 (+-0.258631) 9.00024 (+-0.000898525)
found -0.52 (+-0.000116216) 89.7584 (+-0.258498) 9.0001 (+-0.000898062)
found 5.48 (+-0.000116592) 89.7592 (+-0.258591) 9.00018 (+-0.000898385)
found -8.68 (+-0.000124314) 79.7881 (+-0.243959) 8.00037 (+-0.000847552)
found -8.44 (+-0.000124314) 79.7881 (+-0.243959) 8.00037 (+-0.000847552)
found -7.96 (+-0.000124314) 79.7881 (+-0.243959) 8.00037 (+-0.000847552)
found -7.72 (+-0.000124508) 79.7889 (+-0.244008) 8.00045 (+-0.000847723)
found -2.2 (+-0.000123705) 79.7862 (+-0.243813) 8.00018 (+-0.000847045)
found 0.44 (+-0.000123203) 79.7851 (+-0.243699) 8.00008 (+-0.00084665)
found 1.64 (+-0.000124159) 79.7878 (+-0.243925) 8.00034 (+-0.000847433)
found 8.12 (+-0.000124208) 79.7878 (+-0.243934) 8.00035 (+-0.000847466)
found 9.08 (+-0.000124173) 79.7876 (+-0.243924) 8.00032 (+-0.00084743)
found -6.04 (+-0.000132883) 69.8145 (+-0.228199) 7.00032 (+-0.000792801)
found -5.56 (+-0.000132581) 69.8137 (+-0.228135) 7.00024 (+-0.000792578)
found 4.52 (+-0.000133078) 69.8153 (+-0.228244) 7.0004 (+-0.000792956)
found 9.32 (+-0.000133114) 69.8153 (+-0.228251) 7.0004 (+-0.000792979)
found 9.56 (+-0.000132514) 69.8137 (+-0.228124) 7.00024 (+-0.000792538)
found -9.88 (+-0.000132604) 69.813 (+-0.22812) 7.00017 (+-0.000792526)
found -2.92 (+-0.000132045) 69.8126 (+-0.228027) 7.00013 (+-0.000792203)
found -1.48 (+-0.000132581) 69.8137 (+-0.228135) 7.00024 (+-0.000792578)
found 0.92 (+-0.000132137) 69.8126 (+-0.228042) 7.00013 (+-0.000792255)
found 7.4 (+-0.000132862) 69.8148 (+-0.228199) 7.00034 (+-0.0007928)
found -4.84 (+-0.000143953) 59.8423 (+-0.211353) 6.0004 (+-0.000734275)
found -9.64 (+-0.000144045) 59.8425 (+-0.211371) 6.00042 (+-0.000734336)
found -8.2 (+-0.000144051) 59.8425 (+-0.211372) 6.00043 (+-0.000734339)
found -5.8 (+-0.000143883) 59.842 (+-0.211339) 6.00037 (+-0.000734225)
found -4.6 (+-0.000143354) 59.8407 (+-0.21124) 6.00024 (+-0.000733881)
found -4.12 (+-0.000143142) 59.8401 (+-0.2112) 6.00018 (+-0.000733742)
found -1.24 (+-0.000143792) 59.8417 (+-0.211322) 6.00034 (+-0.000734164)
found -1 (+-0.000143354) 59.8407 (+-0.21124) 6.00024 (+-0.000733881)
found 3.8 (+-0.000142853) 59.8399 (+-0.211154) 6.00016 (+-0.000733581)
found -8.92 (+-0.000143124) 59.8407 (+-0.211207) 6.00024 (+-0.000733765)
found -6.28 (+-0.000143041) 59.8404 (+-0.21119) 6.00022 (+-0.000733708)
found 2.12 (+-0.000158428) 49.8705 (+-0.193059) 5.00053 (+-0.000670718)
found 6.68 (+-0.000157155) 49.8682 (+-0.192864) 5.00029 (+-0.000670042)
found -1.96 (+-0.000157451) 49.8682 (+-0.192901) 5.00029 (+-0.00067017)
found 4.76 (+-0.000156881) 49.8674 (+-0.192818) 5.00021 (+-0.000669881)
found 5.96 (+-0.000156373) 49.8663 (+-0.192737) 5.00011 (+-0.000669598)
found 8.84 (+-0.000157607) 49.8684 (+-0.192925) 5.00032 (+-0.000670253)
found -3.4 (+-0.000156527) 49.8666 (+-0.192761) 5.00013 (+-0.000669681)
found 3.08 (+-0.000156456) 49.8663 (+-0.192746) 5.0001 (+-0.000669632)
found 3.56 (+-0.000157052) 49.8674 (+-0.192839) 5.00021 (+-0.000669953)
found 7.88 (+-0.000177346) 39.897 (+-0.172707) 4.00048 (+-0.000600011)
found 8.6 (+-0.000176837) 39.8959 (+-0.17264) 4.00037 (+-0.000599777)
found -3.88 (+-0.000175547) 39.8941 (+-0.172479) 4.00019 (+-0.00059922)
found -3.16 (+-0.000176603) 39.8954 (+-0.172608) 4.00032 (+-0.000599667)
found -0.04 (+-0.000174494) 39.8928 (+-0.172349) 4.00006 (+-0.000598768)
found 5.24 (+-0.000175907) 39.8949 (+-0.172528) 4.00027 (+-0.000599391)
found 5.72 (+-0.000204811) 29.9229 (+-0.149572) 3.00037 (+-0.000519638)
found -5.32 (+-0.000205177) 29.9234 (+-0.149609) 3.00043 (+-0.000519766)
found -4.36 (+-0.000204529) 29.9223 (+-0.149543) 3.00032 (+-0.000519536)
found -1.72 (+-0.00020451) 29.9223 (+-0.149541) 3.00032 (+-0.00051953)
found -0.759998 (+-0.000205004) 29.9231 (+-0.149592) 3.0004 (+-0.000519705)
found 1.16 (+-0.000204044) 29.9218 (+-0.149496) 3.00027 (+-0.000519373)
found 1.4 (+-0.0002042) 29.9221 (+-0.149512) 3.0003 (+-0.000519429)
found 7.16 (+-0.000203311) 29.9213 (+-0.149431) 3.00022 (+-0.000519145)
found -7.24001 (+-0.000250309) 19.9488 (+-0.122098) 2.00027 (+-0.000424189)
found 0.679999 (+-0.000252372) 19.9501 (+-0.12223) 2.0004 (+-0.000424647)
found 3.32 (+-0.000251116) 19.9488 (+-0.122143) 2.00027 (+-0.000424345)
found 9.8 (+-0.000248046) 19.9485 (+-0.121979) 2.00024 (+-0.000423774)
found -2.43999 (+-0.000250112) 19.9485 (+-0.122084) 2.00024 (+-0.000424139)
found 2.84 (+-0.000249391) 19.9477 (+-0.122033) 2.00016 (+-0.000423961)
found -6.52001 (+-0.000360707) 9.97732 (+-0.0865694) 1.00043 (+-0.000300756)
found 2.59998 (+-0.000358146) 9.97628 (+-0.0864814) 1.00032 (+-0.00030045)
found -9.16001 (+-0.000360397) 9.97705 (+-0.0865573) 1.0004 (+-0.000300714)
found -0.28001 (+-0.00035936) 9.97652 (+-0.0865204) 1.00035 (+-0.000300585)
found -2.68001 (+-0.000357146) 9.97547 (+-0.0864421) 1.00024 (+-0.000300313)
found 4.04001 (+-0.000360707) 9.97732 (+-0.0865694) 1.00043 (+-0.000300756)
found -3.64 (+-0.000357769) 9.97545 (+-0.0864605) 1.00024 (+-0.000300377)
found 0.200008 (+-0.000359024) 9.97625 (+-0.0865073) 1.00032 (+-0.00030054)
found 5 (+-0.000357769) 9.97546 (+-0.0864605) 1.00024 (+-0.000300377)
found 6.20001 (+-0.000360227) 9.97705 (+-0.0865522) 1.0004 (+-0.000300696)
found 6.92 (+-0.000357106) 9.97519 (+-0.0864374) 1.00022 (+-0.000300297)
found -6.99998 (+-0.000358146) 9.97628 (+-0.0864814) 1.00032 (+-0.00030045)
#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 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()
#define dest(otri, vertexptr)