This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 44.881 9
created -9.28 44.881 9
created -8.8 34.9074 7
created -8.32 44.881 9
created -7.84 19.9471 4
created -7.36 4.98678 1
created -6.88 39.8942 8
created -6.4 4.98678 1
created -5.92 14.9603 3
created -5.44 44.881 9
created -4.96 49.8678 10
created -4.48 19.9471 4
created -4 49.8678 10
created -3.52 9.97356 2
created -3.04 24.9339 5
created -2.56 44.881 9
created -2.08 49.8678 10
created -1.6 39.8942 8
created -1.12 24.9339 5
created -0.64 39.8942 8
created -0.16 49.8678 10
created 0.32 29.9207 6
created 0.8 34.9074 7
created 1.28 39.8942 8
created 1.76 14.9603 3
created 2.24 14.9603 3
created 2.72 14.9603 3
created 3.2 49.8678 10
created 3.68 24.9339 5
created 4.16 29.9207 6
created 4.64 9.97356 2
created 5.12 34.9074 7
created 5.6 4.98678 1
created 6.08 49.8678 10
created 6.56 9.97356 2
created 7.04 24.9339 5
created 7.52 49.8678 10
created 8 4.98678 1
created 8.48 44.881 9
created 8.96 14.9603 3
created 9.44 39.8942 8
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.69354e-05)
fit chi^2 = 4.54367e-06
found -4.96 (+-0.000234622) 49.8678 (+-0.144188) 10.0001 (+-0.000954838)
found -4 (+-0.000233571) 49.8674 (+-0.144111) 10.0001 (+-0.000954327)
found -2.08 (+-0.000235162) 49.868 (+-0.144228) 10.0002 (+-0.000955104)
found -0.16 (+-0.000234815) 49.8678 (+-0.144202) 10.0001 (+-0.000954928)
found 3.2 (+-0.000233955) 49.8675 (+-0.144138) 10.0001 (+-0.000954507)
found 6.08 (+-0.000232854) 49.8673 (+-0.144061) 10 (+-0.000954001)
found 7.52 (+-0.000233417) 49.8674 (+-0.144102) 10.0001 (+-0.000954268)
found -9.76 (+-0.000247606) 44.8809 (+-0.136797) 9.00009 (+-0.000905894)
found -9.28 (+-0.000247961) 44.8812 (+-0.136832) 9.00016 (+-0.000906128)
found -8.32 (+-0.000247254) 44.881 (+-0.136784) 9.00011 (+-0.000905808)
found -5.44 (+-0.000247398) 44.8811 (+-0.136795) 9.00013 (+-0.000905884)
found -2.56 (+-0.000247777) 44.8812 (+-0.13682) 9.00015 (+-0.000906047)
found 8.48 (+-0.000245798) 44.8806 (+-0.13669) 9.00004 (+-0.000905188)
found -6.88 (+-0.000260195) 39.8938 (+-0.128845) 8.00002 (+-0.000853232)
found -1.6 (+-0.000263044) 39.8945 (+-0.12901) 8.00015 (+-0.000854327)
found -0.639999 (+-0.000263044) 39.8945 (+-0.12901) 8.00015 (+-0.000854327)
found 1.28 (+-0.000262239) 39.8942 (+-0.128961) 8.0001 (+-0.000854002)
found 9.44 (+-0.00025983) 39.8943 (+-0.128836) 8.00011 (+-0.000853172)
found -8.8 (+-0.000282039) 34.9079 (+-0.120723) 7.00018 (+-0.00079945)
found 0.8 (+-0.000281421) 34.9077 (+-0.120689) 7.00014 (+-0.000799224)
found 5.12 (+-0.000278725) 34.9071 (+-0.12055) 7.00003 (+-0.000798303)
found 0.319999 (+-0.000304876) 29.9211 (+-0.11178) 6.00017 (+-0.000740225)
found 4.16 (+-0.000302652) 29.9206 (+-0.111677) 6.00007 (+-0.000739542)
found -1.12 (+-0.00033439) 24.9344 (+-0.102057) 5.00016 (+-0.00067584)
found 3.68 (+-0.000334321) 24.9344 (+-0.102055) 5.00016 (+-0.000675825)
found -3.04 (+-0.000332822) 24.9341 (+-0.101997) 5.00011 (+-0.000675445)
found 7.04 (+-0.000332999) 24.9342 (+-0.102005) 5.00012 (+-0.000675495)
found -7.84 (+-0.000372065) 19.9474 (+-0.0912307) 4.0001 (+-0.000604146)
found -4.48 (+-0.000375599) 19.9479 (+-0.0913406) 4.0002 (+-0.000604874)
found 8.96 (+-0.000434321) 14.961 (+-0.0791191) 3.00017 (+-0.000523941)
found 1.76 (+-0.000431947) 14.9607 (+-0.0790606) 3.00011 (+-0.000523554)
found 2.24 (+-0.000429901) 14.9604 (+-0.0790099) 3.00006 (+-0.000523218)
found 2.72 (+-0.000432515) 14.9608 (+-0.0790755) 3.00013 (+-0.000523652)
found -5.92 (+-0.000430635) 14.9607 (+-0.0790328) 3.0001 (+-0.00052337)
found -3.52 (+-0.000533495) 9.97419 (+-0.0646285) 2.00015 (+-0.000427981)
found 6.56 (+-0.000533495) 9.97419 (+-0.0646285) 2.00015 (+-0.000427981)
found 4.64 (+-0.000532801) 9.97409 (+-0.0646155) 2.00013 (+-0.000427896)
found 8 (+-0.000765419) 4.98768 (+-0.0457991) 1.00019 (+-0.00030329)
found -6.40001 (+-0.000757954) 4.98728 (+-0.045731) 1.00011 (+-0.000302839)
found 5.6 (+-0.000763847) 4.98758 (+-0.0457844) 1.00017 (+-0.000303192)
found -7.35999 (+-0.000759335) 4.98733 (+-0.0457429) 1.00012 (+-0.000302918)
#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++) {
}
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++) {
}
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()