This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 19.9471 4
created -9.28 4.98678 1
created -8.8 34.9074 7
created -8.32 29.9207 6
created -7.84 4.98678 1
created -7.36 4.98678 1
created -6.88 44.881 9
created -6.4 44.881 9
created -5.92 24.9339 5
created -5.44 39.8942 8
created -4.96 14.9603 3
created -4.48 19.9471 4
created -4 24.9339 5
created -3.52 24.9339 5
created -3.04 19.9471 4
created -2.56 49.8678 10
created -2.08 49.8678 10
created -1.6 39.8942 8
created -1.12 24.9339 5
created -0.64 34.9074 7
created -0.16 14.9603 3
created 0.32 9.97356 2
created 0.8 34.9074 7
created 1.28 49.8678 10
created 1.76 29.9207 6
created 2.24 24.9339 5
created 2.72 29.9207 6
created 3.2 34.9074 7
created 3.68 29.9207 6
created 4.16 4.98678 1
created 4.64 29.9207 6
created 5.12 19.9471 4
created 5.6 29.9207 6
created 6.08 4.98678 1
created 6.56 29.9207 6
created 7.04 14.9603 3
created 7.52 39.8942 8
created 8 9.97356 2
created 8.48 49.8678 10
created 8.96 49.8678 10
created 9.44 49.8678 10
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-3.11685e-05)
fit chi^2 = 5.62587e-06
found -2.56 (+-0.000261182) 49.8678 (+-0.160451) 10.0001 (+-0.00106254)
found -2.08 (+-0.000261783) 49.868 (+-0.160496) 10.0002 (+-0.00106283)
found 1.28 (+-0.00026116) 49.8678 (+-0.160448) 10.0001 (+-0.00106252)
found 8.48 (+-0.000260721) 49.8677 (+-0.160419) 10.0001 (+-0.00106233)
found 8.96 (+-0.000262011) 49.8681 (+-0.160514) 10.0002 (+-0.00106295)
found 9.44 (+-0.000259452) 49.8681 (+-0.160347) 10.0002 (+-0.00106184)
found -6.88 (+-0.000274505) 44.8809 (+-0.152168) 9.0001 (+-0.00100769)
found -6.4 (+-0.00027559) 44.8811 (+-0.152236) 9.00014 (+-0.00100813)
found -5.44 (+-0.000291446) 39.8941 (+-0.143477) 8.00008 (+-0.000950133)
found -1.6 (+-0.000292698) 39.8945 (+-0.143554) 8.00015 (+-0.000950639)
found 7.52 (+-0.000290676) 39.894 (+-0.143433) 8.00005 (+-0.000949837)
found -8.8 (+-0.000311216) 34.9073 (+-0.134196) 7.00007 (+-0.000888669)
found -0.64 (+-0.000311835) 34.9074 (+-0.134225) 7.00008 (+-0.00088886)
found 0.800001 (+-0.000312364) 34.9076 (+-0.134256) 7.00012 (+-0.000889068)
found 3.2 (+-0.000312782) 34.9076 (+-0.134275) 7.00012 (+-0.000889191)
found -8.32 (+-0.000336673) 29.9207 (+-0.124265) 6.00008 (+-0.000822907)
found 1.76 (+-0.000338782) 29.921 (+-0.124359) 6.00015 (+-0.00082353)
found 3.68 (+-0.000336672) 29.9207 (+-0.124265) 6.00008 (+-0.000822907)
found 2.72 (+-0.00033823) 29.9209 (+-0.124332) 6.00012 (+-0.000823352)
found 4.64 (+-0.000335947) 29.9205 (+-0.124231) 6.00005 (+-0.00082268)
found 5.6 (+-0.000335947) 29.9205 (+-0.124231) 6.00005 (+-0.00082268)
found 6.56 (+-0.000335628) 29.9205 (+-0.124217) 6.00004 (+-0.000822585)
found -5.92 (+-0.000372302) 24.9344 (+-0.113571) 5.00017 (+-0.000752089)
found -1.12 (+-0.000371853) 24.9343 (+-0.113553) 5.00015 (+-0.000751968)
found 2.24 (+-0.000371109) 24.9342 (+-0.113523) 5.00012 (+-0.000751769)
found -4 (+-0.000370217) 24.934 (+-0.113488) 5.00009 (+-0.000751537)
found -3.52 (+-0.000370217) 24.934 (+-0.113488) 5.00009 (+-0.000751537)
found 5.12 (+-0.000415751) 19.9475 (+-0.101565) 4.00012 (+-0.000672581)
found -9.76 (+-0.000411465) 19.9469 (+-0.101425) 4.00001 (+-0.000671656)
found -4.48 (+-0.000414206) 19.9473 (+-0.101516) 4.00008 (+-0.000672257)
found -3.04 (+-0.000416494) 19.9476 (+-0.10159) 4.00015 (+-0.000672749)
found -4.96 (+-0.00048124) 14.9608 (+-0.0879876) 3.00012 (+-0.00058267)
found -0.160002 (+-0.000479543) 14.9606 (+-0.0879473) 3.00009 (+-0.000582403)
found 7.04 (+-0.000482192) 14.9608 (+-0.0880108) 3.00014 (+-0.000582824)
found 0.320003 (+-0.000590674) 9.97394 (+-0.0718634) 2.0001 (+-0.000475893)
found 8 (+-0.000595345) 9.97434 (+-0.0719438) 2.00018 (+-0.000476424)
found -9.28 (+-0.000844044) 4.98728 (+-0.0508913) 1.00011 (+-0.000337011)
found -7.84001 (+-0.00083688) 4.98708 (+-0.0508312) 1.00007 (+-0.000336613)
found 4.16 (+-0.00084546) 4.98733 (+-0.0509037) 1.00012 (+-0.000337093)
found 6.08 (+-0.00084546) 4.98733 (+-0.0509037) 1.00012 (+-0.000337093)
found -7.35999 (+-0.000839525) 4.98723 (+-0.0508567) 1.0001 (+-0.000336782)
#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++) {
Amp[i] =
h->GetBinContent(bin);
}
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++) {
Pos[i] =
d->GetBinCenter(bin);
Amp[i] =
d->GetBinContent(bin);
}
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()