This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 49.8678 10
created -9.28 49.8678 10
created -8.8 44.881 9
created -8.32 19.9471 4
created -7.84 19.9471 4
created -7.36 39.8942 8
created -6.88 29.9207 6
created -6.4 34.9074 7
created -5.92 29.9207 6
created -5.44 9.97356 2
created -4.96 9.97356 2
created -4.48 34.9074 7
created -4 29.9207 6
created -3.52 14.9603 3
created -3.04 49.8678 10
created -2.56 44.881 9
created -2.08 4.98678 1
created -1.6 39.8942 8
created -1.12 34.9074 7
created -0.64 9.97356 2
created -0.16 34.9074 7
created 0.32 44.881 9
created 0.8 49.8678 10
created 1.28 19.9471 4
created 1.76 4.98678 1
created 2.24 29.9207 6
created 2.72 14.9603 3
created 3.2 39.8942 8
created 3.68 49.8678 10
created 4.16 29.9207 6
created 4.64 24.9339 5
created 5.12 49.8678 10
created 5.6 14.9603 3
created 6.08 19.9471 4
created 6.56 34.9074 7
created 7.04 19.9471 4
created 7.52 39.8942 8
created 8 44.881 9
created 8.48 19.9471 4
created 8.96 9.97356 2
created 9.44 29.9207 6
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.3462e-05)
fit chi^2 = 3.40423e-06
found -9.76 (+-0.000203324) 49.8676 (+-0.124813) 10.0001 (+-0.000826537)
found -9.28 (+-0.000203729) 49.8681 (+-0.124854) 10.0002 (+-0.000826808)
found -3.04 (+-0.000202923) 49.8677 (+-0.124794) 10.0001 (+-0.000826411)
found 0.799999 (+-0.000203084) 49.8678 (+-0.124806) 10.0001 (+-0.000826486)
found 3.68 (+-0.000203251) 49.8678 (+-0.124818) 10.0001 (+-0.000826565)
found 5.12 (+-0.000202506) 49.8675 (+-0.124763) 10.0001 (+-0.0008262)
found -8.8 (+-0.000214319) 44.8811 (+-0.118418) 9.00014 (+-0.000784189)
found -2.56 (+-0.000213625) 44.881 (+-0.118376) 9.00011 (+-0.000783906)
found 0.32 (+-0.000214723) 44.8813 (+-0.118446) 9.00017 (+-0.000784368)
found 8 (+-0.000214126) 44.881 (+-0.118405) 9.00012 (+-0.000784098)
found -7.36 (+-0.000227052) 39.8942 (+-0.111629) 8.0001 (+-0.000739227)
found -1.6 (+-0.000226415) 39.8941 (+-0.111594) 8.00008 (+-0.000738999)
found 3.2 (+-0.000227321) 39.8944 (+-0.111647) 8.00013 (+-0.000739346)
found 7.52 (+-0.000227414) 39.8944 (+-0.111652) 8.00013 (+-0.000739377)
found -6.4 (+-0.000243308) 34.9076 (+-0.10445) 7.00012 (+-0.000691687)
found -4.48 (+-0.000242464) 34.9074 (+-0.104406) 7.00008 (+-0.000691398)
found -1.12 (+-0.000242745) 34.9075 (+-0.104422) 7.0001 (+-0.000691502)
found -0.159999 (+-0.000242868) 34.9075 (+-0.104429) 7.00011 (+-0.000691548)
found 6.56 (+-0.000242604) 34.9074 (+-0.104413) 7.00008 (+-0.000691439)
found -6.88 (+-0.000263618) 29.921 (+-0.0967405) 6.00015 (+-0.000640633)
found -5.92 (+-0.000262324) 29.9207 (+-0.0966816) 6.00009 (+-0.000640243)
found -4 (+-0.000262636) 29.9208 (+-0.0966951) 6.0001 (+-0.000640332)
found 4.16 (+-0.000263532) 29.921 (+-0.0967371) 6.00015 (+-0.00064061)
found 2.24 (+-0.000261079) 29.9205 (+-0.096626) 6.00004 (+-0.000639875)
found 9.44 (+-0.000259613) 29.9207 (+-0.096573) 6.00008 (+-0.000639524)
found 4.64 (+-0.000289381) 24.9344 (+-0.0883363) 5.00016 (+-0.000584979)
found -8.32 (+-0.000323489) 19.9475 (+-0.0790093) 4.00013 (+-0.000523214)
found 1.28 (+-0.000322235) 19.9474 (+-0.0789736) 4.00011 (+-0.000522978)
found 7.04 (+-0.000324107) 19.9476 (+-0.0790288) 4.00015 (+-0.000523343)
found 8.48 (+-0.000322677) 19.9474 (+-0.0789849) 4.00011 (+-0.000523052)
found -7.84 (+-0.000323288) 19.9475 (+-0.0790025) 4.00012 (+-0.000523169)
found 6.08 (+-0.000322709) 19.9474 (+-0.0789841) 4.0001 (+-0.000523047)
found 5.6 (+-0.000374842) 14.9609 (+-0.068457) 3.00014 (+-0.000453335)
found -3.52 (+-0.000375585) 14.961 (+-0.0684751) 3.00016 (+-0.000453454)
found 2.72 (+-0.000375089) 14.9609 (+-0.0684622) 3.00014 (+-0.000453369)
found -5.44 (+-0.000458224) 9.97384 (+-0.0558808) 2.00008 (+-0.000370053)
found -0.64 (+-0.000461616) 9.97414 (+-0.0559373) 2.00014 (+-0.000370427)
found 8.96 (+-0.000459704) 9.97394 (+-0.0559046) 2.0001 (+-0.00037021)
found -4.96 (+-0.000458652) 9.97389 (+-0.0558884) 2.00009 (+-0.000370103)
found -2.08 (+-0.000661281) 4.98758 (+-0.0396308) 1.00017 (+-0.000262442)
found 1.76 (+-0.000655799) 4.98722 (+-0.0395803) 1.0001 (+-0.000262108)
#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()