This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 49.8678 10
created -9.28 9.97356 2
created -8.8 4.98678 1
created -8.32 24.9339 5
created -7.84 44.881 9
created -7.36 14.9603 3
created -6.88 9.97356 2
created -6.4 9.97356 2
created -5.92 29.9207 6
created -5.44 9.97356 2
created -4.96 9.97356 2
created -4.48 14.9603 3
created -4 14.9603 3
created -3.52 44.881 9
created -3.04 34.9074 7
created -2.56 39.8942 8
created -2.08 19.9471 4
created -1.6 14.9603 3
created -1.12 34.9074 7
created -0.64 4.98678 1
created -0.16 44.881 9
created 0.32 44.881 9
created 0.8 39.8942 8
created 1.28 44.881 9
created 1.76 24.9339 5
created 2.24 9.97356 2
created 2.72 49.8678 10
created 3.2 44.881 9
created 3.68 39.8942 8
created 4.16 14.9603 3
created 4.64 44.881 9
created 5.12 34.9074 7
created 5.6 29.9207 6
created 6.08 44.881 9
created 6.56 4.98678 1
created 7.04 24.9339 5
created 7.52 24.9339 5
created 8 24.9339 5
created 8.48 39.8942 8
created 8.96 34.9074 7
created 9.44 29.9207 6
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.43734e-05)
fit chi^2 = 3.4059e-06
found -9.76 (+-0.000202377) 49.8672 (+-0.124771) 10 (+-0.000826253)
found 2.72 (+-0.000202776) 49.8677 (+-0.124811) 10.0001 (+-0.000826524)
found -7.84 (+-0.000213644) 44.8808 (+-0.118398) 9.00008 (+-0.000784052)
found -3.52 (+-0.000213894) 44.8809 (+-0.118415) 9.0001 (+-0.000784165)
found -0.159999 (+-0.000213586) 44.8809 (+-0.118398) 9.0001 (+-0.000784055)
found 0.32 (+-0.000214791) 44.8813 (+-0.118476) 9.00017 (+-0.000784567)
found 1.28 (+-0.000214329) 44.8811 (+-0.118444) 9.00013 (+-0.000784356)
found 3.2 (+-0.000214885) 44.8813 (+-0.118482) 9.00018 (+-0.000784611)
found 4.64 (+-0.000213894) 44.8809 (+-0.118415) 9.0001 (+-0.000784165)
found 6.08 (+-0.000213262) 44.8808 (+-0.118375) 9.00007 (+-0.000783904)
found -2.56 (+-0.000227239) 39.8943 (+-0.111664) 8.00011 (+-0.000739462)
found 0.8 (+-0.000228151) 39.8946 (+-0.111721) 8.00018 (+-0.000739834)
found 3.68 (+-0.000227274) 39.8943 (+-0.111668) 8.00012 (+-0.000739484)
found 8.48 (+-0.000227406) 39.8943 (+-0.111674) 8.00012 (+-0.000739528)
found -3.04 (+-0.000244061) 34.9078 (+-0.104514) 7.00017 (+-0.00069211)
found -1.12 (+-0.000241585) 34.9072 (+-0.104384) 7.00004 (+-0.000691252)
found 5.12 (+-0.000243776) 34.9077 (+-0.104498) 7.00015 (+-0.000692007)
found 8.96 (+-0.000243651) 34.9077 (+-0.104491) 7.00014 (+-0.00069196)
found 5.6 (+-0.000263826) 29.9211 (+-0.0967712) 6.00016 (+-0.000640836)
found 9.44 (+-0.000260781) 29.9209 (+-0.096648) 6.00013 (+-0.000640021)
found -5.92 (+-0.000261263) 29.9205 (+-0.096654) 6.00004 (+-0.00064006)
found 1.76 (+-0.000288154) 24.9341 (+-0.0883084) 5.00011 (+-0.000584794)
found -8.32 (+-0.000287643) 24.9341 (+-0.0882907) 5.0001 (+-0.000584677)
found 7.04 (+-0.000286887) 24.9339 (+-0.0882598) 5.00006 (+-0.000584472)
found 7.52 (+-0.000288308) 24.9341 (+-0.0883118) 5.0001 (+-0.000584816)
found 8 (+-0.000288908) 24.9342 (+-0.0883359) 5.00013 (+-0.000584976)
found -2.08 (+-0.000323006) 19.9474 (+-0.0790108) 4.00011 (+-0.000523224)
found -7.36 (+-0.00037365) 14.9607 (+-0.0684434) 3.00011 (+-0.000453244)
found -4 (+-0.000374231) 14.9608 (+-0.0684566) 3.00012 (+-0.000453332)
found -1.6 (+-0.000374162) 14.9607 (+-0.0684537) 3.00011 (+-0.000453313)
found 4.16 (+-0.000376031) 14.961 (+-0.0685006) 3.00017 (+-0.000453623)
found -4.48 (+-0.000371633) 14.9604 (+-0.0683928) 3.00005 (+-0.00045291)
found -9.28001 (+-0.000458673) 9.97399 (+-0.0559043) 2.00011 (+-0.000370208)
found -6.88 (+-0.000456664) 9.97368 (+-0.0558662) 2.00005 (+-0.000369956)
found -5.44 (+-0.000458337) 9.97383 (+-0.0558946) 2.00008 (+-0.000370144)
found 2.24 (+-0.000461895) 9.97419 (+-0.0559547) 2.00015 (+-0.000370542)
found -6.4 (+-0.000458337) 9.97383 (+-0.0558946) 2.00008 (+-0.000370144)
found -4.96 (+-0.000456664) 9.97368 (+-0.0558662) 2.00005 (+-0.000369956)
found -0.639997 (+-0.000660735) 4.98753 (+-0.0396339) 1.00016 (+-0.000262463)
found 6.55999 (+-0.000659072) 4.98743 (+-0.0396188) 1.00014 (+-0.000262363)
found -8.8 (+-0.000652423) 4.98707 (+-0.0395594) 1.00007 (+-0.000261969)
#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;
}
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()