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 9.97356 2
created -8.8 29.9207 6
created -8.32 4.98678 1
created -7.84 34.9074 7
created -7.36 44.881 9
created -6.88 19.9471 4
created -6.4 19.9471 4
created -5.92 39.8942 8
created -5.44 44.881 9
created -4.96 19.9471 4
created -4.48 9.97356 2
created -4 9.97356 2
created -3.52 39.8942 8
created -3.04 34.9074 7
created -2.56 19.9471 4
created -2.08 29.9207 6
created -1.6 24.9339 5
created -1.12 49.8678 10
created -0.64 44.881 9
created -0.16 19.9471 4
created 0.32 19.9471 4
created 0.8 19.9471 4
created 1.28 49.8678 10
created 1.76 19.9471 4
created 2.24 24.9339 5
created 2.72 19.9471 4
created 3.2 34.9074 7
created 3.68 39.8942 8
created 4.16 4.98678 1
created 4.64 14.9603 3
created 5.12 14.9603 3
created 5.6 44.881 9
created 6.08 19.9471 4
created 6.56 19.9471 4
created 7.04 19.9471 4
created 7.52 4.98678 1
created 8 29.9207 6
created 8.48 4.98678 1
created 8.96 29.9207 6
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.080001 (+-2.70519e-05)
fit chi^2 = 3.9573e-06
found -9.76 (+-0.000218144) 49.8672 (+-0.134492) 10 (+-0.000890628)
found -1.12 (+-0.000219109) 49.8678 (+-0.134573) 10.0001 (+-0.00089117)
found 1.28 (+-0.000218363) 49.8675 (+-0.134518) 10.0001 (+-0.0008908)
found -7.36 (+-0.000230749) 44.881 (+-0.127653) 9.00011 (+-0.000845342)
found -5.44 (+-0.000230866) 44.881 (+-0.127661) 9.00012 (+-0.000845396)
found -0.640001 (+-0.000231074) 44.8811 (+-0.127676) 9.00014 (+-0.000845494)
found 5.6 (+-0.000230129) 44.8808 (+-0.127612) 9.00007 (+-0.000845068)
found -5.92 (+-0.000245193) 39.8944 (+-0.12038) 8.00013 (+-0.000797179)
found -3.52 (+-0.000244473) 39.8942 (+-0.120338) 8.00009 (+-0.000796898)
found 3.68 (+-0.000244115) 39.8941 (+-0.120319) 8.00008 (+-0.000796771)
found -7.84 (+-0.000261449) 34.9075 (+-0.112574) 7.0001 (+-0.000745484)
found -3.04 (+-0.000262253) 34.9076 (+-0.112612) 7.00012 (+-0.000745738)
found 3.2 (+-0.000262253) 34.9076 (+-0.112612) 7.00012 (+-0.000745738)
found 9.44 (+-0.000259927) 34.9076 (+-0.112507) 7.00013 (+-0.000745042)
found -8.8 (+-0.000281159) 29.9204 (+-0.104165) 6.00003 (+-0.000689802)
found -2.08 (+-0.000283055) 29.9207 (+-0.104248) 6.00009 (+-0.000690351)
found 8 (+-0.000280702) 29.9204 (+-0.104146) 6.00002 (+-0.000689676)
found 8.96 (+-0.000282366) 29.9207 (+-0.104221) 6.00008 (+-0.000690169)
found -1.6 (+-0.000312004) 24.9344 (+-0.0952421) 5.00016 (+-0.000630711)
found 2.24 (+-0.000310229) 24.934 (+-0.0951713) 5.00008 (+-0.000630241)
found -6.88 (+-0.000348778) 19.9475 (+-0.085186) 4.00013 (+-0.000564117)
found -4.96 (+-0.000347902) 19.9474 (+-0.0851597) 4.00011 (+-0.000563943)
found -2.56 (+-0.000348948) 19.9475 (+-0.0851906) 4.00013 (+-0.000564148)
found -0.160002 (+-0.000348778) 19.9475 (+-0.085186) 4.00013 (+-0.000564117)
found 1.76 (+-0.000349312) 19.9476 (+-0.0852033) 4.00015 (+-0.000564232)
found 6.08 (+-0.000348778) 19.9475 (+-0.085186) 4.00013 (+-0.000564117)
found -6.4 (+-0.000348562) 19.9475 (+-0.0851787) 4.00012 (+-0.000564069)
found 0.32 (+-0.000347452) 19.9473 (+-0.0851426) 4.00008 (+-0.00056383)
found 0.800002 (+-0.000348979) 19.9476 (+-0.0851929) 4.00014 (+-0.000564163)
found 2.72 (+-0.000348658) 19.9475 (+-0.0851813) 4.00012 (+-0.000564086)
found 6.56 (+-0.000347452) 19.9473 (+-0.0851426) 4.00008 (+-0.00056383)
found 7.04 (+-0.000345919) 19.9471 (+-0.0850973) 4.00005 (+-0.00056353)
found 5.12 (+-0.000403388) 14.9608 (+-0.0737902) 3.00012 (+-0.000488652)
found 4.64 (+-0.000399728) 14.9603 (+-0.0737026) 3.00004 (+-0.000488072)
found -9.28 (+-0.000498411) 9.97424 (+-0.0603232) 2.00016 (+-0.000399471)
found -4.48 (+-0.000492941) 9.97374 (+-0.0602304) 2.00006 (+-0.000398857)
found -4 (+-0.000494926) 9.97394 (+-0.0602651) 2.0001 (+-0.000399086)
found -8.32 (+-0.00070992) 4.98738 (+-0.0427004) 1.00013 (+-0.00028277)
found 4.15999 (+-0.000707357) 4.98728 (+-0.0426783) 1.00011 (+-0.000282623)
found 8.48 (+-0.000709084) 4.98733 (+-0.0426927) 1.00012 (+-0.000282719)
found 7.52 (+-0.000707067) 4.98722 (+-0.0426746) 1.0001 (+-0.000282599)
#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()