This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 29.9207 6
created -9.28 39.8942 8
created -8.8 14.9603 3
created -8.32 39.8942 8
created -7.84 14.9603 3
created -7.36 44.881 9
created -6.88 39.8942 8
created -6.4 24.9339 5
created -5.92 14.9603 3
created -5.44 4.98678 1
created -4.96 4.98678 1
created -4.48 29.9207 6
created -4 14.9603 3
created -3.52 34.9074 7
created -3.04 44.881 9
created -2.56 4.98678 1
created -2.08 14.9603 3
created -1.6 39.8942 8
created -1.12 34.9074 7
created -0.64 49.8678 10
created -0.16 24.9339 5
created 0.32 9.97356 2
created 0.8 39.8942 8
created 1.28 34.9074 7
created 1.76 14.9603 3
created 2.24 19.9471 4
created 2.72 44.881 9
created 3.2 19.9471 4
created 3.68 39.8942 8
created 4.16 39.8942 8
created 4.64 19.9471 4
created 5.12 4.98678 1
created 5.6 49.8678 10
created 6.08 19.9471 4
created 6.56 49.8678 10
created 7.04 19.9471 4
created 7.52 49.8678 10
created 8 4.98678 1
created 8.48 14.9603 3
created 8.96 14.9603 3
created 9.44 44.881 9
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.080001 (+-2.99481e-05)
fit chi^2 = 5.07989e-06
found -0.64 (+-0.000248016) 49.8677 (+-0.152453) 10.0001 (+-0.00100957)
found 5.6 (+-0.000246641) 49.8674 (+-0.152356) 10 (+-0.00100893)
found 6.56 (+-0.000247404) 49.8675 (+-0.152408) 10.0001 (+-0.00100927)
found 7.52 (+-0.000246641) 49.8674 (+-0.152356) 10 (+-0.00100893)
found -7.36 (+-0.000261354) 44.881 (+-0.144626) 9.00011 (+-0.000957737)
found -3.04 (+-0.000260593) 44.8808 (+-0.144578) 9.00008 (+-0.000957423)
found 2.72 (+-0.000260948) 44.8808 (+-0.144597) 9.00008 (+-0.000957549)
found 9.44 (+-0.00025894) 44.881 (+-0.144484) 9.00012 (+-0.000956798)
found -9.28 (+-0.000277121) 39.8942 (+-0.136349) 8.00009 (+-0.000902925)
found -8.32 (+-0.000276504) 39.894 (+-0.136312) 8.00006 (+-0.000902681)
found -6.88 (+-0.000278007) 39.8944 (+-0.136402) 8.00014 (+-0.00090328)
found -1.6 (+-0.000277281) 39.8942 (+-0.136358) 8.0001 (+-0.00090299)
found 0.800001 (+-0.000276987) 39.8942 (+-0.136342) 8.00009 (+-0.000902881)
found 3.68 (+-0.000277667) 39.8943 (+-0.136382) 8.00012 (+-0.000903143)
found 4.16 (+-0.000277667) 39.8943 (+-0.136382) 8.00012 (+-0.000903143)
found -3.52 (+-0.000297013) 34.9076 (+-0.127584) 7.00012 (+-0.000844883)
found -1.12 (+-0.000298207) 34.9079 (+-0.127648) 7.00018 (+-0.000845305)
found 1.28 (+-0.000296862) 34.9075 (+-0.127575) 7.00011 (+-0.000844826)
found -9.76 (+-0.000321043) 29.9207 (+-0.11812) 6.00008 (+-0.000782213)
found -4.48 (+-0.000318927) 29.9205 (+-0.118035) 6.00004 (+-0.000781651)
found -6.4 (+-0.000352162) 24.9341 (+-0.107856) 5.00011 (+-0.000714243)
found -0.160002 (+-0.0003521) 24.9342 (+-0.107856) 5.00012 (+-0.000714243)
found 3.2 (+-0.000396436) 19.9477 (+-0.0965563) 4.00017 (+-0.000639413)
found 4.64 (+-0.000393165) 19.9473 (+-0.0964557) 4.00009 (+-0.000638747)
found 6.08 (+-0.000397145) 19.9479 (+-0.0965802) 4.0002 (+-0.000639571)
found 7.04 (+-0.000397145) 19.9479 (+-0.0965802) 4.0002 (+-0.000639571)
found 2.24 (+-0.000394721) 19.9475 (+-0.0965018) 4.00012 (+-0.000639052)
found -8.8 (+-0.000458919) 14.961 (+-0.0836495) 3.00016 (+-0.000553942)
found -7.84 (+-0.000459235) 14.961 (+-0.0836576) 3.00017 (+-0.000553996)
found -5.92 (+-0.000453914) 14.9604 (+-0.0835297) 3.00006 (+-0.000553148)
found -4 (+-0.000457855) 14.9608 (+-0.0836225) 3.00013 (+-0.000553763)
found 1.76 (+-0.000456953) 14.9607 (+-0.0836004) 3.00011 (+-0.000553617)
found 8.96 (+-0.000457036) 14.9608 (+-0.0836039) 3.00012 (+-0.00055364)
found -2.08 (+-0.000455029) 14.9606 (+-0.0835582) 3.00009 (+-0.000553338)
found 8.48 (+-0.000452889) 14.9603 (+-0.0835047) 3.00004 (+-0.000552983)
found 0.320002 (+-0.000563248) 9.97409 (+-0.0683204) 2.00013 (+-0.00045243)
found -2.56001 (+-0.000802206) 4.98733 (+-0.0483618) 1.00012 (+-0.00032026)
found 7.99999 (+-0.000802923) 4.98738 (+-0.0483688) 1.00013 (+-0.000320307)
found 5.12001 (+-0.000804391) 4.98743 (+-0.0483813) 1.00014 (+-0.00032039)
found -5.44 (+-0.000791609) 4.98692 (+-0.0482687) 1.00004 (+-0.000319644)
found -4.95999 (+-0.000795236) 4.98707 (+-0.0483017) 1.00007 (+-0.000319863)
#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()