This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 7.97885 2
created -9.1 15.9577 4
created -8.5 11.9683 3
created -7.9 39.8942 10
created -7.3 7.97885 2
created -6.7 3.98942 1
created -6.1 19.9471 5
created -5.5 3.98942 1
created -4.9 15.9577 4
created -4.3 23.9365 6
created -3.7 7.97885 2
created -3.1 3.98942 1
created -2.5 39.8942 10
created -1.9 19.9471 5
created -1.3 31.9154 8
created -0.7 3.98942 1
created -0.1 35.9048 9
created 0.5 27.926 7
created 1.1 3.98942 1
created 1.7 19.9471 5
created 2.3 35.9048 9
created 2.9 39.8942 10
created 3.5 11.9683 3
created 4.1 23.9365 6
created 4.7 23.9365 6
created 5.3 27.926 7
created 5.9 35.9048 9
created 6.5 39.8942 10
created 7.1 3.98942 1
created 7.7 31.9154 8
created 8.3 19.9471 5
created 8.9 39.8942 10
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.35932e-05)
fit chi^2 = 1.51887e-06
found -7.9 (+-0.000170138) 39.8937 (+-0.0672291) 10.0001 (+-0.000551715)
found -2.5 (+-0.000170159) 39.8937 (+-0.067231) 10.0001 (+-0.000551731)
found 2.9 (+-0.000170903) 39.8941 (+-0.067265) 10.0002 (+-0.00055201)
found 6.5 (+-0.000170508) 39.894 (+-0.0672482) 10.0001 (+-0.000551872)
found 8.9 (+-0.000170386) 39.8938 (+-0.0672406) 10.0001 (+-0.000551809)
found -0.0999986 (+-0.000179664) 35.9045 (+-0.0637939) 9.0001 (+-0.000523524)
found 2.3 (+-0.000180627) 35.9049 (+-0.0638338) 9.00019 (+-0.000523851)
found 5.9 (+-0.00018084) 35.905 (+-0.063843) 9.00022 (+-0.000523927)
found -1.3 (+-0.000190456) 31.9151 (+-0.060141) 8.00008 (+-0.000493547)
found 7.7 (+-0.000190456) 31.9151 (+-0.060141) 8.00008 (+-0.000493547)
found 0.499998 (+-0.000204227) 27.9259 (+-0.0562784) 7.00013 (+-0.000461849)
found 5.3 (+-0.000205258) 27.9262 (+-0.0563115) 7.00019 (+-0.00046212)
found -4.3 (+-0.000220452) 23.9364 (+-0.0520977) 6.00008 (+-0.000427539)
found 4.1 (+-0.00022105) 23.9365 (+-0.052115) 6.00012 (+-0.000427681)
found 4.7 (+-0.000221745) 23.9367 (+-0.0521354) 6.00017 (+-0.000427849)
found -1.9 (+-0.000244038) 19.9477 (+-0.0476222) 5.00023 (+-0.000390811)
found -6.1 (+-0.00024038) 19.9468 (+-0.047533) 5.00002 (+-0.000390079)
found 1.7 (+-0.000242193) 19.9472 (+-0.0475776) 5.00013 (+-0.000390445)
found 8.3 (+-0.000244038) 19.9477 (+-0.0476222) 5.00023 (+-0.000390811)
found -9.1 (+-0.000270431) 15.9576 (+-0.0425457) 4.00006 (+-0.000349151)
found -4.9 (+-0.000270685) 15.9577 (+-0.0425521) 4.00009 (+-0.000349203)
found 3.5 (+-0.000316315) 11.9689 (+-0.0369086) 3.00021 (+-0.00030289)
found -8.5 (+-0.00031569) 11.9688 (+-0.0368988) 3.00018 (+-0.00030281)
found -7.30001 (+-0.000386196) 7.97927 (+-0.0301254) 2.00014 (+-0.000247224)
found 9.5 (+-0.000383331) 7.97931 (+-0.0301033) 2.00016 (+-0.000247043)
found -3.70001 (+-0.000384943) 7.97906 (+-0.0301108) 2.00009 (+-0.000247104)
found -9.7 (+-0.000384138) 7.9789 (+-0.0300994) 2.00005 (+-0.00024701)
found 7.1 (+-0.000557411) 3.99028 (+-0.0213644) 1.00023 (+-0.000175327)
found -0.699998 (+-0.000556908) 3.99023 (+-0.0213613) 1.00022 (+-0.000175301)
found 1.1 (+-0.000553792) 3.98997 (+-0.0213427) 1.00016 (+-0.000175149)
found -5.5 (+-0.000551577) 3.98981 (+-0.0213298) 1.00012 (+-0.000175043)
found -6.69999 (+-0.000549329) 3.98971 (+-0.0213175) 1.00009 (+-0.000174942)
found -3.09998 (+-0.00055228) 3.98997 (+-0.0213356) 1.00016 (+-0.00017509)
#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()