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 34.9074 7
created -8.8 49.8678 10
created -8.32 4.98678 1
created -7.84 19.9471 4
created -7.36 34.9074 7
created -6.88 19.9471 4
created -6.4 49.8678 10
created -5.92 24.9339 5
created -5.44 14.9603 3
created -4.96 24.9339 5
created -4.48 24.9339 5
created -4 44.881 9
created -3.52 24.9339 5
created -3.04 39.8942 8
created -2.56 19.9471 4
created -2.08 4.98678 1
created -1.6 29.9207 6
created -1.12 39.8942 8
created -0.64 4.98678 1
created -0.16 34.9074 7
created 0.32 14.9603 3
created 0.8 29.9207 6
created 1.28 34.9074 7
created 1.76 19.9471 4
created 2.24 39.8942 8
created 2.72 34.9074 7
created 3.2 9.97356 2
created 3.68 39.8942 8
created 4.16 29.9207 6
created 4.64 19.9471 4
created 5.12 14.9603 3
created 5.6 44.881 9
created 6.08 24.9339 5
created 6.56 34.9074 7
created 7.04 34.9074 7
created 7.52 34.9074 7
created 8 24.9339 5
created 8.48 19.9471 4
created 8.96 4.98678 1
created 9.44 19.9471 4
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.04974e-05)
fit chi^2 = 2.2971e-06
found -8.8 (+-0.000166152) 49.8675 (+-0.102474) 10.0001 (+-0.000678604)
found -6.4 (+-0.000166479) 49.8676 (+-0.102495) 10.0001 (+-0.000678742)
found -4 (+-0.000175722) 44.8809 (+-0.0972513) 9.0001 (+-0.000644016)
found 5.6 (+-0.000175455) 44.8808 (+-0.0972338) 9.00008 (+-0.0006439)
found -3.04 (+-0.000186391) 39.8941 (+-0.09169) 8.00009 (+-0.000607188)
found -1.12 (+-0.000185881) 39.894 (+-0.0916624) 8.00007 (+-0.000607005)
found 2.24 (+-0.00018662) 39.8942 (+-0.091704) 8.00011 (+-0.000607281)
found 3.68 (+-0.000186153) 39.8941 (+-0.0916769) 8.00008 (+-0.000607101)
found -9.28 (+-0.000199289) 34.9075 (+-0.0857739) 7.00011 (+-0.00056801)
found -7.36 (+-0.000199287) 34.9074 (+-0.0857695) 7.00008 (+-0.000567981)
found -0.16 (+-0.000198401) 34.9072 (+-0.0857253) 7.00004 (+-0.000567689)
found 1.28 (+-0.000199575) 34.9075 (+-0.0857849) 7.0001 (+-0.000568083)
found 2.72 (+-0.000199402) 34.9075 (+-0.0857773) 7.0001 (+-0.000568033)
found 6.56 (+-0.000199851) 34.9076 (+-0.0857996) 7.00012 (+-0.000568181)
found 7.04 (+-0.000200109) 34.9077 (+-0.0858136) 7.00014 (+-0.000568273)
found 7.52 (+-0.000199851) 34.9076 (+-0.0857996) 7.00012 (+-0.000568181)
found 4.16 (+-0.000216076) 29.9209 (+-0.0794454) 6.00012 (+-0.000526102)
found -1.6 (+-0.000215256) 29.9207 (+-0.0794105) 6.00009 (+-0.000525871)
found 0.800001 (+-0.000215742) 29.9208 (+-0.07943) 6.0001 (+-0.000526)
found -5.92 (+-0.000237075) 24.9342 (+-0.0725393) 5.00013 (+-0.000480368)
found -3.52 (+-0.000237898) 24.9344 (+-0.072571) 5.00017 (+-0.000480578)
found 6.08 (+-0.000237748) 24.9344 (+-0.0725649) 5.00016 (+-0.000480538)
found 8 (+-0.000236909) 24.9341 (+-0.0725314) 5.00011 (+-0.000480316)
found -4.96 (+-0.000236323) 24.934 (+-0.0725085) 5.00008 (+-0.000480165)
found -4.48 (+-0.000237401) 24.9343 (+-0.0725512) 5.00014 (+-0.000480447)
found -6.88 (+-0.000266558) 19.9477 (+-0.0649289) 4.00017 (+-0.000429971)
found -2.56 (+-0.000264386) 19.9473 (+-0.0648619) 4.00009 (+-0.000429528)
found 1.76 (+-0.000266238) 19.9476 (+-0.064918) 4.00015 (+-0.000429899)
found 4.64 (+-0.000264893) 19.9473 (+-0.0648749) 4.00009 (+-0.000429613)
found -7.84 (+-0.000264209) 19.9473 (+-0.064856) 4.00008 (+-0.000429488)
found 8.48 (+-0.000263798) 19.9471 (+-0.0648424) 4.00006 (+-0.000429398)
found 9.44 (+-0.000260999) 19.9471 (+-0.0647671) 4.00005 (+-0.000428899)
found -5.44 (+-0.000307069) 14.9606 (+-0.0562118) 3.0001 (+-0.000372245)
found 0.32 (+-0.000307886) 14.9608 (+-0.0562322) 3.00013 (+-0.00037238)
found 5.12 (+-0.000307718) 14.9608 (+-0.0562287) 3.00013 (+-0.000372357)
found 3.2 (+-0.000379519) 9.97419 (+-0.0459554) 2.00015 (+-0.000304325)
found -0.640001 (+-0.000542096) 4.98748 (+-0.0325442) 1.00015 (+-0.000215514)
found -8.32001 (+-0.000540916) 4.98743 (+-0.0325342) 1.00014 (+-0.000215447)
found -9.75999 (+-0.000534061) 4.98707 (+-0.0324741) 1.00007 (+-0.00021505)
found -2.08 (+-0.000538705) 4.98722 (+-0.0325132) 1.0001 (+-0.000215308)
found 8.96 (+-0.000537181) 4.98712 (+-0.0324994) 1.00008 (+-0.000215217)
#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()