created -9.82 66.4904 10
created -9.46 6.64904 1
created -9.1 59.8413 9
created -8.74 26.5962 4
created -8.38 6.64904 1
created -8.02 26.5962 4
created -7.66 59.8413 9
created -7.3 13.2981 2
created -6.94 46.5433 7
created -6.58 13.2981 2
created -6.22 13.2981 2
created -5.86 33.2452 5
created -5.5 26.5962 4
created -5.14 19.9471 3
created -4.78 66.4904 10
created -4.42 26.5962 4
created -4.06 6.64904 1
created -3.7 26.5962 4
created -3.34 66.4904 10
created -2.98 26.5962 4
created -2.62 46.5433 7
created -2.26 19.9471 3
created -1.9 66.4904 10
created -1.54 66.4904 10
created -1.18 33.2452 5
created -0.82 33.2452 5
created -0.46 46.5433 7
created -0.1 13.2981 2
created 0.26 46.5433 7
created 0.62 46.5433 7
created 0.98 46.5433 7
created 1.34 26.5962 4
created 1.7 66.4904 10
created 2.06 13.2981 2
created 2.42 33.2452 5
created 2.78 66.4904 10
created 3.14 33.2452 5
created 3.5 33.2452 5
created 3.86 46.5433 7
created 4.22 13.2981 2
created 4.58 13.2981 2
created 4.94 46.5433 7
created 5.3 13.2981 2
created 5.66 59.8413 9
created 6.02 33.2452 5
created 6.38 33.2452 5
created 6.74 19.9471 3
created 7.1 46.5433 7
created 7.46 13.2981 2
created 7.82 39.8942 6
created 8.18 59.8413 9
created 8.54 19.9471 3
created 8.9 33.2452 5
created 9.26 19.9471 3
created 9.62 33.2452 5
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.20381e-05)
fit chi^2 = 1.92412e-06
found -9.82 (+-0.000112168) 66.49 (+-0.123099) 10 (+-0.000620935)
found -4.78 (+-0.000112353) 66.4902 (+-0.12313) 10 (+-0.000621094)
found -3.34 (+-0.000112441) 66.4903 (+-0.123141) 10.0001 (+-0.000621151)
found -1.9 (+-0.000112706) 66.4905 (+-0.123178) 10.0001 (+-0.000621336)
found -1.54 (+-0.000112872) 66.4906 (+-0.123199) 10.0001 (+-0.000621442)
found 1.7 (+-0.000112244) 66.4902 (+-0.123117) 10 (+-0.000621027)
found 2.78 (+-0.000112593) 66.4904 (+-0.123161) 10.0001 (+-0.00062125)
found -9.1 (+-0.000118215) 59.8411 (+-0.116789) 9.00003 (+-0.000589107)
found -7.66 (+-0.00011838) 59.8412 (+-0.116806) 9.00004 (+-0.000589195)
found 5.66 (+-0.000118462) 59.8412 (+-0.116816) 9.00005 (+-0.000589244)
found 8.18 (+-0.000118655) 59.8413 (+-0.116838) 9.00006 (+-0.000589356)
found -6.94 (+-0.000134148) 46.5431 (+-0.103006) 7.00003 (+-0.000519583)
found -2.62 (+-0.000134568) 46.5433 (+-0.103043) 7.00005 (+-0.000519773)
found -0.46 (+-0.000134521) 46.5433 (+-0.10304) 7.00005 (+-0.000519755)
found 0.26 (+-0.000134693) 46.5433 (+-0.103057) 7.00006 (+-0.000519839)
found 0.62 (+-0.000135245) 46.5436 (+-0.103108) 7.00009 (+-0.000520096)
found 0.98 (+-0.000134966) 46.5434 (+-0.103081) 7.00007 (+-0.000519963)
found 3.86 (+-0.000134521) 46.5433 (+-0.10304) 7.00005 (+-0.000519755)
found 4.94 (+-0.000134148) 46.5431 (+-0.103006) 7.00003 (+-0.000519583)
found 7.1 (+-0.000134297) 46.5432 (+-0.103019) 7.00003 (+-0.00051965)
found 7.82 (+-0.000145801) 39.8944 (+-0.0954384) 6.00007 (+-0.000481412)
found -1.18 (+-0.000160536) 33.2456 (+-0.0871788) 5.0001 (+-0.000439748)
found 3.14 (+-0.000160536) 33.2456 (+-0.0871788) 5.0001 (+-0.000439748)
found 6.02 (+-0.00016045) 33.2456 (+-0.0871724) 5.00009 (+-0.000439716)
found -5.86 (+-0.000159379) 33.2452 (+-0.0870983) 5.00004 (+-0.000439342)
found -0.82 (+-0.000160257) 33.2455 (+-0.0871583) 5.00008 (+-0.000439645)
found 2.42 (+-0.000160025) 33.2455 (+-0.0871449) 5.00008 (+-0.000439577)
found 3.5 (+-0.000160257) 33.2455 (+-0.0871583) 5.00008 (+-0.000439645)
found 6.38 (+-0.000159721) 33.2453 (+-0.0871211) 5.00005 (+-0.000439457)
found 8.9 (+-0.000159419) 33.2452 (+-0.0871005) 5.00004 (+-0.000439353)
found 9.62 (+-0.000158166) 33.2453 (+-0.0870305) 5.00005 (+-0.000439)
found -8.74 (+-0.000178798) 26.5964 (+-0.0779403) 4.00007 (+-0.000393147)
found -5.5 (+-0.000178882) 26.5963 (+-0.0779406) 4.00005 (+-0.000393149)
found -4.42 (+-0.000178901) 26.5965 (+-0.0779466) 4.00007 (+-0.000393179)
found -2.98 (+-0.000180157) 26.5967 (+-0.078014) 4.00011 (+-0.000393519)
found 1.34 (+-0.000180157) 26.5967 (+-0.078014) 4.00011 (+-0.000393519)
found -8.02 (+-0.000178798) 26.5964 (+-0.0779403) 4.00007 (+-0.000393147)
found -3.7 (+-0.000178901) 26.5965 (+-0.0779466) 4.00007 (+-0.000393179)
found -5.14 (+-0.000208108) 19.9476 (+-0.0675667) 3.00009 (+-0.000340821)
found -2.26 (+-0.000208695) 19.9477 (+-0.0675923) 3.00011 (+-0.00034095)
found 6.74 (+-0.000207898) 19.9475 (+-0.0675563) 3.00008 (+-0.000340768)
found 8.54 (+-0.000208196) 19.9476 (+-0.06757) 3.00009 (+-0.000340837)
found 9.26 (+-0.000207536) 19.9474 (+-0.0675402) 3.00007 (+-0.000340687)
found -7.3 (+-0.00025671) 13.2987 (+-0.0552232) 2.00011 (+-0.000278557)
found 2.06 (+-0.000256379) 13.2987 (+-0.0552134) 2.0001 (+-0.000278508)
found -6.58 (+-0.000254638) 13.2984 (+-0.0551615) 2.00006 (+-0.000278246)
found -0.1 (+-0.000256288) 13.2986 (+-0.0552099) 2.00009 (+-0.00027849)
found 4.22 (+-0.000254638) 13.2984 (+-0.0551615) 2.00006 (+-0.000278246)
found 5.3 (+-0.00025671) 13.2987 (+-0.0552232) 2.00011 (+-0.000278557)
found 7.46 (+-0.000256046) 13.2986 (+-0.0552024) 2.00009 (+-0.000278453)
found -6.22 (+-0.000254134) 13.2983 (+-0.0551459) 2.00005 (+-0.000278168)
found 4.58 (+-0.000254638) 13.2984 (+-0.0551615) 2.00006 (+-0.000278246)
found -9.46 (+-0.000367843) 6.64985 (+-0.039127) 1.00013 (+-0.000197365)
found -8.38 (+-0.000363069) 6.64935 (+-0.039049) 1.00005 (+-0.000196971)
found -4.06 (+-0.000363069) 6.64935 (+-0.039049) 1.00005 (+-0.000196971)
#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()