This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 15.9577 4
created -9.1 7.97885 2
created -8.5 35.9048 9
created -7.9 7.97885 2
created -7.3 19.9471 5
created -6.7 7.97885 2
created -6.1 27.926 7
created -5.5 23.9365 6
created -4.9 23.9365 6
created -4.3 23.9365 6
created -3.7 35.9048 9
created -3.1 19.9471 5
created -2.5 23.9365 6
created -1.9 35.9048 9
created -1.3 19.9471 5
created -0.7 3.98942 1
created -0.1 31.9154 8
created 0.5 27.926 7
created 1.1 27.926 7
created 1.7 3.98942 1
created 2.3 3.98942 1
created 2.9 15.9577 4
created 3.5 19.9471 5
created 4.1 7.97885 2
created 4.7 23.9365 6
created 5.3 27.926 7
created 5.9 15.9577 4
created 6.5 39.8942 10
created 7.1 35.9048 9
created 7.7 39.8942 10
created 8.3 39.8942 10
created 8.9 31.9154 8
created 9.5 7.97885 2
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-2.24009e-05)
fit chi^2 = 1.46288e-06
found 6.5 (+-0.000167855) 39.8941 (+-0.0660195) 10.0002 (+-0.000541789)
found 7.7 (+-0.000168388) 39.8944 (+-0.0660452) 10.0002 (+-0.000542)
found 8.3 (+-0.000168312) 39.8944 (+-0.0660414) 10.0002 (+-0.000541969)
found -8.5 (+-0.000175918) 35.9043 (+-0.0625889) 9.00005 (+-0.000513635)
found -3.7 (+-0.000176918) 35.9047 (+-0.0626305) 9.00014 (+-0.000513976)
found -1.9 (+-0.000176918) 35.9047 (+-0.0626305) 9.00014 (+-0.000513976)
found 7.1 (+-0.000177726) 35.9051 (+-0.0626664) 9.00026 (+-0.000514271)
found 8.9 (+-0.000187688) 31.9154 (+-0.0590516) 8.00016 (+-0.000484606)
found -0.0999984 (+-0.000187139) 31.9152 (+-0.059031) 8.0001 (+-0.000484438)
found -6.1 (+-0.000200404) 27.9258 (+-0.0552287) 7.0001 (+-0.000453234)
found 0.5 (+-0.000201459) 27.9262 (+-0.0552643) 7.00019 (+-0.000453526)
found 1.1 (+-0.000200216) 27.9258 (+-0.0552236) 7.0001 (+-0.000453192)
found 5.3 (+-0.00020081) 27.9259 (+-0.0552419) 7.00013 (+-0.000453342)
found -5.5 (+-0.00021762) 23.9367 (+-0.0511654) 6.00017 (+-0.000419888)
found -4.9 (+-0.000217479) 23.9367 (+-0.0511611) 6.00016 (+-0.000419854)
found -4.3 (+-0.000217865) 23.9368 (+-0.051173) 6.00019 (+-0.000419951)
found -2.5 (+-0.000217708) 23.9368 (+-0.0511683) 6.00018 (+-0.000419913)
found 4.7 (+-0.000216819) 23.9365 (+-0.0511425) 6.00012 (+-0.0004197)
found -3.1 (+-0.000239053) 19.9475 (+-0.0467245) 5.00019 (+-0.000383445)
found -1.3 (+-0.000237687) 19.9472 (+-0.0466924) 5.00013 (+-0.000383181)
found -7.3 (+-0.000236735) 19.9469 (+-0.0466672) 5.00005 (+-0.000382974)
found 3.5 (+-0.000237277) 19.947 (+-0.0466802) 5.00008 (+-0.000383081)
found 5.9 (+-0.000268205) 15.9583 (+-0.0418115) 4.00022 (+-0.000343125)
found -9.7 (+-0.00026507) 15.9575 (+-0.0417443) 4.00003 (+-0.000342574)
found 2.9 (+-0.00026543) 15.9577 (+-0.0417558) 4.00008 (+-0.000342669)
found -9.09999 (+-0.000380932) 7.97936 (+-0.0295834) 2.00017 (+-0.000242776)
found -7.9 (+-0.000381395) 7.97942 (+-0.0295883) 2.00018 (+-0.000242816)
found 9.5 (+-0.000375649) 7.97921 (+-0.0295366) 2.00013 (+-0.000242392)
found -6.7 (+-0.000380773) 7.97931 (+-0.0295812) 2.00016 (+-0.000242758)
found 4.1 (+-0.000380415) 7.97926 (+-0.0295772) 2.00014 (+-0.000242725)
found -0.699993 (+-0.000544064) 3.99002 (+-0.0209491) 1.00017 (+-0.000171919)
found 1.69999 (+-0.000538681) 3.98977 (+-0.02092) 1.00011 (+-0.00017168)
found 2.30001 (+-0.000536562) 3.98961 (+-0.0209073) 1.00007 (+-0.000171576)
#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()