This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 4.98678 1
created -9.28 19.9471 4
created -8.8 39.8942 8
created -8.32 9.97356 2
created -7.84 9.97356 2
created -7.36 19.9471 4
created -6.88 14.9603 3
created -6.4 19.9471 4
created -5.92 39.8942 8
created -5.44 29.9207 6
created -4.96 14.9603 3
created -4.48 4.98678 1
created -4 29.9207 6
created -3.52 19.9471 4
created -3.04 44.881 9
created -2.56 9.97356 2
created -2.08 39.8942 8
created -1.6 29.9207 6
created -1.12 24.9339 5
created -0.64 39.8942 8
created -0.16 4.98678 1
created 0.32 49.8678 10
created 0.8 29.9207 6
created 1.28 39.8942 8
created 1.76 39.8942 8
created 2.24 49.8678 10
created 2.72 49.8678 10
created 3.2 49.8678 10
created 3.68 19.9471 4
created 4.16 39.8942 8
created 4.64 34.9074 7
created 5.12 49.8678 10
created 5.6 34.9074 7
created 6.08 4.98678 1
created 6.56 29.9207 6
created 7.04 39.8942 8
created 7.52 29.9207 6
created 8 14.9603 3
created 8.48 49.8678 10
created 8.96 4.98678 1
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.07495e-05)
fit chi^2 = 5.64563e-06
found 0.320001 (+-0.00026034) 49.8675 (+-0.16064) 10.0001 (+-0.00106379)
found 2.24 (+-0.000262242) 49.868 (+-0.160778) 10.0002 (+-0.0010647)
found 2.72 (+-0.000262471) 49.8681 (+-0.160795) 10.0002 (+-0.00106482)
found 3.2 (+-0.00026164) 49.8678 (+-0.160733) 10.0001 (+-0.0010644)
found 5.12 (+-0.000261758) 49.8678 (+-0.16074) 10.0001 (+-0.00106445)
found 8.48 (+-0.00025981) 49.8673 (+-0.160601) 10 (+-0.00106353)
found 9.44 (+-0.000258312) 49.8677 (+-0.160511) 10.0001 (+-0.00106293)
found -3.04 (+-0.000274593) 44.8807 (+-0.152404) 9.00006 (+-0.00100925)
found -8.8 (+-0.000291435) 39.894 (+-0.143699) 8.00006 (+-0.0009516)
found -5.92 (+-0.000292397) 39.8942 (+-0.143755) 8.0001 (+-0.000951973)
found -2.08 (+-0.000291835) 39.8941 (+-0.143723) 8.00008 (+-0.000951761)
found -0.640001 (+-0.000291222) 39.894 (+-0.143689) 8.00006 (+-0.000951534)
found 1.28 (+-0.000293126) 39.8944 (+-0.1438) 8.00014 (+-0.000952267)
found 1.76 (+-0.000293729) 39.8946 (+-0.143837) 8.00018 (+-0.000952517)
found 4.16 (+-0.000292566) 39.8943 (+-0.143766) 8.00011 (+-0.000952042)
found 7.04 (+-0.0002928) 39.8943 (+-0.143779) 8.00012 (+-0.000952133)
found 4.64 (+-0.000314374) 34.9079 (+-0.134568) 7.00018 (+-0.000891133)
found 5.6 (+-0.000312427) 34.9075 (+-0.134469) 7.00011 (+-0.000890477)
found -5.44 (+-0.000338419) 29.9208 (+-0.124533) 6.00011 (+-0.00082468)
found -1.6 (+-0.000339022) 29.9209 (+-0.12456) 6.00013 (+-0.00082486)
found 0.8 (+-0.000340041) 29.9212 (+-0.124609) 6.00018 (+-0.000825183)
found 7.52 (+-0.000338419) 29.9208 (+-0.124533) 6.00011 (+-0.00082468)
found -4 (+-0.000336536) 29.9205 (+-0.124449) 6.00005 (+-0.000824124)
found 6.56 (+-0.000337459) 29.9207 (+-0.124493) 6.00009 (+-0.000824415)
found -1.12 (+-0.000372249) 24.9343 (+-0.113742) 5.00014 (+-0.000753219)
found -3.52 (+-0.000417332) 19.9476 (+-0.101771) 4.00015 (+-0.000673949)
found 3.68 (+-0.000418171) 19.9478 (+-0.101799) 4.00018 (+-0.000674133)
found -9.28 (+-0.000414481) 19.9473 (+-0.101685) 4.00009 (+-0.000673376)
found -7.36 (+-0.000413511) 19.9471 (+-0.10165) 4.00005 (+-0.000673146)
found -6.4 (+-0.000415863) 19.9474 (+-0.101725) 4.00011 (+-0.00067364)
found -6.88 (+-0.000480388) 14.9605 (+-0.0880995) 3.00008 (+-0.000583411)
found -4.96 (+-0.000478957) 14.9605 (+-0.0880691) 3.00007 (+-0.00058321)
found 8 (+-0.000483677) 14.961 (+-0.0881819) 3.00016 (+-0.000583957)
found -2.56 (+-0.000595956) 9.97429 (+-0.0720622) 2.00017 (+-0.000477209)
found -8.32 (+-0.000591149) 9.97394 (+-0.0719818) 2.0001 (+-0.000476676)
found -7.84 (+-0.000588778) 9.97373 (+-0.0719404) 2.00006 (+-0.000476402)
found -0.159997 (+-0.000852365) 4.98763 (+-0.0510437) 1.00018 (+-0.000338021)
found 8.96 (+-0.000853977) 4.98774 (+-0.051059) 1.00021 (+-0.000338122)
found 6.08 (+-0.000847942) 4.98738 (+-0.0510022) 1.00013 (+-0.000337746)
found -4.48 (+-0.000843005) 4.98717 (+-0.0509581) 1.00009 (+-0.000337454)
found -9.75999 (+-0.000833971) 4.98692 (+-0.0508794) 1.00004 (+-0.000336932)
#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()