This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 39.8942 10
created -9.1 31.9154 8
created -8.5 31.9154 8
created -7.9 23.9365 6
created -7.3 15.9577 4
created -6.7 7.97885 2
created -6.1 27.926 7
created -5.5 11.9683 3
created -4.9 35.9048 9
created -4.3 7.97885 2
created -3.7 23.9365 6
created -3.1 11.9683 3
created -2.5 35.9048 9
created -1.9 7.97885 2
created -1.3 3.98942 1
created -0.7 7.97885 2
created -0.1 39.8942 10
created 0.5 39.8942 10
created 1.1 15.9577 4
created 1.7 39.8942 10
created 2.3 15.9577 4
created 2.9 35.9048 9
created 3.5 19.9471 5
created 4.1 3.98942 1
created 4.7 19.9471 5
created 5.3 35.9048 9
created 5.9 27.926 7
created 6.5 15.9577 4
created 7.1 27.926 7
created 7.7 3.98942 1
created 8.3 27.926 7
created 8.9 7.97885 2
created 9.5 19.9471 5
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.5027e-05)
fit chi^2 = 3.51443e-06
found -9.7 (+-0.000260265) 39.8939 (+-0.102324) 10.0001 (+-0.000839721)
found -0.0999983 (+-0.000259821) 39.8941 (+-0.102313) 10.0002 (+-0.000839634)
found 0.499999 (+-0.00026028) 39.8942 (+-0.102334) 10.0002 (+-0.000839802)
found 1.7 (+-0.000259461) 39.8939 (+-0.102294) 10.0001 (+-0.000839476)
found -4.9 (+-0.000272943) 35.9044 (+-0.0970222) 9.00006 (+-0.000796211)
found -2.5 (+-0.000272943) 35.9044 (+-0.0970222) 9.00006 (+-0.000796211)
found 2.9 (+-0.000273857) 35.9046 (+-0.09706) 9.00011 (+-0.000796522)
found 5.3 (+-0.000274371) 35.9047 (+-0.0970822) 9.00015 (+-0.000796704)
found -9.1 (+-0.000292202) 31.9157 (+-0.0915771) 8.00023 (+-0.000751526)
found -8.5 (+-0.000291601) 31.9155 (+-0.091553) 8.00018 (+-0.000751329)
found 5.9 (+-0.000311771) 27.9261 (+-0.0856419) 7.00017 (+-0.000702819)
found -6.1 (+-0.000309895) 27.9257 (+-0.0855784) 7.00006 (+-0.000702298)
found 7.1 (+-0.000309696) 27.9257 (+-0.0855732) 7.00006 (+-0.000702255)
found 8.3 (+-0.000309076) 27.9256 (+-0.0855529) 7.00004 (+-0.000702089)
found -7.9 (+-0.000336983) 23.9367 (+-0.0792958) 6.00015 (+-0.00065074)
found -3.7 (+-0.000335017) 23.9363 (+-0.0792384) 6.00007 (+-0.000650269)
found 3.5 (+-0.000368408) 19.9473 (+-0.0723719) 5.00013 (+-0.000593919)
found 4.7 (+-0.000368408) 19.9473 (+-0.0723719) 5.00013 (+-0.000593919)
found 9.5 (+-0.000364518) 19.9471 (+-0.0722858) 5.00009 (+-0.000593212)
found -7.3 (+-0.000412543) 15.9578 (+-0.0647419) 4.0001 (+-0.000531303)
found 1.1 (+-0.000416495) 15.9584 (+-0.0648234) 4.00026 (+-0.000531973)
found 2.3 (+-0.000416253) 15.9584 (+-0.0648182) 4.00025 (+-0.00053193)
found 6.5 (+-0.00041493) 15.9581 (+-0.0647899) 4.00018 (+-0.000531697)
found -5.5 (+-0.000481249) 11.9689 (+-0.0561441) 3.00021 (+-0.000460746)
found -3.1 (+-0.000480852) 11.9688 (+-0.0561377) 3.00019 (+-0.000460694)
found -4.3 (+-0.000591778) 7.97947 (+-0.045868) 2.00019 (+-0.000376415)
found -1.90001 (+-0.000587037) 7.97922 (+-0.0458198) 2.00013 (+-0.00037602)
found 8.9 (+-0.000590187) 7.97932 (+-0.0458501) 2.00016 (+-0.000376268)
found -6.7 (+-0.000589473) 7.97927 (+-0.0458425) 2.00014 (+-0.000376206)
found -0.69999 (+-0.000587456) 7.97927 (+-0.0458248) 2.00014 (+-0.000376061)
found 7.7 (+-0.000844503) 3.99007 (+-0.0324775) 1.00018 (+-0.000266526)
found 4.1 (+-0.000840295) 3.98987 (+-0.0324528) 1.00013 (+-0.000266323)
found -1.3 (+-0.000830985) 3.98956 (+-0.0324009) 1.00005 (+-0.000265898)
#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()