This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 14.9603 3
created -9.28 24.9339 5
created -8.8 19.9471 4
created -8.32 19.9471 4
created -7.84 39.8942 8
created -7.36 24.9339 5
created -6.88 9.97356 2
created -6.4 39.8942 8
created -5.92 24.9339 5
created -5.44 24.9339 5
created -4.96 39.8942 8
created -4.48 19.9471 4
created -4 49.8678 10
created -3.52 4.98678 1
created -3.04 19.9471 4
created -2.56 24.9339 5
created -2.08 9.97356 2
created -1.6 34.9074 7
created -1.12 49.8678 10
created -0.64 4.98678 1
created -0.16 49.8678 10
created 0.32 34.9074 7
created 0.8 29.9207 6
created 1.28 39.8942 8
created 1.76 49.8678 10
created 2.24 9.97356 2
created 2.72 24.9339 5
created 3.2 39.8942 8
created 3.68 19.9471 4
created 4.16 4.98678 1
created 4.64 19.9471 4
created 5.12 39.8942 8
created 5.6 14.9603 3
created 6.08 39.8942 8
created 6.56 39.8942 8
created 7.04 49.8678 10
created 7.52 19.9471 4
created 8 14.9603 3
created 8.48 4.98678 1
created 8.96 14.9603 3
created 9.44 34.9074 7
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.67612e-05)
fit chi^2 = 3.96846e-06
found -4 (+-0.000217997) 49.8674 (+-0.134661) 10 (+-0.000891751)
found -1.12 (+-0.000218387) 49.8675 (+-0.13469) 10.0001 (+-0.000891944)
found -0.159999 (+-0.000218386) 49.8675 (+-0.13469) 10.0001 (+-0.000891944)
found 1.76 (+-0.000218784) 49.8676 (+-0.134718) 10.0001 (+-0.000892125)
found 7.04 (+-0.000219171) 49.8677 (+-0.134745) 10.0001 (+-0.000892304)
found -7.84 (+-0.00024499) 39.8941 (+-0.120516) 8.00009 (+-0.000798077)
found -6.4 (+-0.00024452) 39.894 (+-0.120489) 8.00007 (+-0.000797899)
found -4.96 (+-0.00024499) 39.8942 (+-0.120516) 8.00009 (+-0.000798077)
found 1.28 (+-0.00024599) 39.8945 (+-0.120577) 8.00016 (+-0.000798485)
found 3.2 (+-0.00024499) 39.8941 (+-0.120516) 8.00009 (+-0.000798077)
found 5.12 (+-0.0002446) 39.894 (+-0.120493) 8.00007 (+-0.000797925)
found 6.08 (+-0.000245207) 39.8943 (+-0.12053) 8.00011 (+-0.000798172)
found 6.56 (+-0.000246265) 39.8946 (+-0.120594) 8.00018 (+-0.000798597)
found -1.6 (+-0.000262348) 34.9076 (+-0.112759) 7.00012 (+-0.000746709)
found 0.319999 (+-0.000263265) 34.9078 (+-0.112806) 7.00016 (+-0.000747021)
found 9.44 (+-0.000259692) 34.9075 (+-0.112633) 7.0001 (+-0.000745879)
found 0.8 (+-0.000284627) 29.921 (+-0.10445) 6.00015 (+-0.000691689)
found -7.36 (+-0.000310865) 24.9341 (+-0.0953154) 5.0001 (+-0.000631196)
found -5.92 (+-0.000311856) 24.9342 (+-0.0953525) 5.00013 (+-0.000631442)
found -9.28 (+-0.000310348) 24.9339 (+-0.0952934) 5.00007 (+-0.00063105)
found -5.44 (+-0.000311856) 24.9342 (+-0.0953525) 5.00013 (+-0.000631442)
found -2.56 (+-0.000309954) 24.9339 (+-0.0952789) 5.00006 (+-0.000630954)
found 2.72 (+-0.000310865) 24.9341 (+-0.0953154) 5.0001 (+-0.000631196)
found -4.48 (+-0.000350597) 19.9478 (+-0.0853492) 4.00018 (+-0.000565198)
found 3.68 (+-0.000347504) 19.9473 (+-0.0852534) 4.00009 (+-0.000564563)
found 7.52 (+-0.000349079) 19.9475 (+-0.085301) 4.00013 (+-0.000564879)
found -8.8 (+-0.000348271) 19.9473 (+-0.0852731) 4.00009 (+-0.000564694)
found -8.32 (+-0.000349053) 19.9475 (+-0.0852988) 4.00012 (+-0.000564864)
found -3.04 (+-0.000346731) 19.9472 (+-0.0852277) 4.00006 (+-0.000564393)
found 4.64 (+-0.000347504) 19.9473 (+-0.0852534) 4.00009 (+-0.000564563)
found 5.6 (+-0.00040562) 14.961 (+-0.0739345) 3.00016 (+-0.000489608)
found 8 (+-0.000400781) 14.9604 (+-0.0738183) 3.00005 (+-0.000488838)
found -9.76 (+-0.000401711) 14.9604 (+-0.0738335) 3.00005 (+-0.000488939)
found 8.96 (+-0.000401886) 14.9605 (+-0.0738461) 3.00008 (+-0.000489022)
found 2.24 (+-0.000498584) 9.97419 (+-0.0603993) 2.00015 (+-0.000399975)
found -6.88 (+-0.000497833) 9.97409 (+-0.0603857) 2.00013 (+-0.000399885)
found -2.08 (+-0.000497409) 9.97404 (+-0.0603782) 2.00012 (+-0.000399835)
found -0.64 (+-0.000715981) 4.98774 (+-0.0428082) 1.00021 (+-0.000283484)
found -3.52001 (+-0.00071097) 4.98743 (+-0.0427624) 1.00014 (+-0.00028318)
found 4.16 (+-0.000706061) 4.98712 (+-0.0427166) 1.00008 (+-0.000282877)
found 8.48 (+-0.000703523) 4.98702 (+-0.0426944) 1.00006 (+-0.00028273)
#include <iostream>
{
delete gROOT->FindObject(
"h");
<< std::endl;
}
std::cout <<
"the total number of created peaks = " <<
npeaks <<
" with sigma = " <<
sigma << std::endl;
}
void FitAwmi(void)
{
else
for (i = 0; i < nbins; i++)
source[i] =
h->GetBinContent(i + 1);
for (i = 0; i <
nfound; i++) {
}
pfit->SetFitParameters(0, (nbins - 1), 1000, 0.1,
pfit->kFitOptimChiCounts,
pfit->kFitAlphaHalving,
pfit->kFitPower2,
pfit->kFitTaylorOrderFirst);
delete gROOT->FindObject(
"d");
d->SetNameTitle(
"d",
"");
for (i = 0; i < nbins; i++)
d->SetBinContent(i + 1,
source[i]);
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++) {
}
h->GetListOfFunctions()->Remove(
pm);
}
h->GetListOfFunctions()->Add(
pm);
delete s;
return;
}
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
double Double_t
Double 8 bytes.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
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.
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.
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()