This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 34.9074 7
created -9.28 14.9603 3
created -8.8 14.9603 3
created -8.32 29.9207 6
created -7.84 4.98678 1
created -7.36 9.97356 2
created -6.88 14.9603 3
created -6.4 14.9603 3
created -5.92 9.97356 2
created -5.44 49.8678 10
created -4.96 49.8678 10
created -4.48 14.9603 3
created -4 14.9603 3
created -3.52 34.9074 7
created -3.04 39.8942 8
created -2.56 44.881 9
created -2.08 49.8678 10
created -1.6 4.98678 1
created -1.12 29.9207 6
created -0.64 34.9074 7
created -0.16 44.881 9
created 0.32 19.9471 4
created 0.8 19.9471 4
created 1.28 19.9471 4
created 1.76 29.9207 6
created 2.24 19.9471 4
created 2.72 44.881 9
created 3.2 29.9207 6
created 3.68 9.97356 2
created 4.16 49.8678 10
created 4.64 19.9471 4
created 5.12 4.98678 1
created 5.6 49.8678 10
created 6.08 29.9207 6
created 6.56 24.9339 5
created 7.04 4.98678 1
created 7.52 19.9471 4
created 8 29.9207 6
created 8.48 49.8678 10
created 8.96 19.9471 4
created 9.44 49.8678 10
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.080001 (+-3.17431e-05)
fit chi^2 = 5.63004e-06
found -5.44 (+-0.000260817) 49.8677 (+-0.160479) 10.0001 (+-0.00106272)
found -4.96 (+-0.000261072) 49.8678 (+-0.160496) 10.0001 (+-0.00106283)
found -2.08 (+-0.00026036) 49.8676 (+-0.160447) 10.0001 (+-0.00106251)
found 4.16 (+-0.000259999) 49.8674 (+-0.160416) 10.0001 (+-0.00106231)
found 5.6 (+-0.00025998) 49.8675 (+-0.160418) 10.0001 (+-0.00106232)
found 8.48 (+-0.000260786) 49.8676 (+-0.160473) 10.0001 (+-0.00106268)
found 9.44 (+-0.000258742) 49.8678 (+-0.160344) 10.0001 (+-0.00106183)
found -2.56 (+-0.000276277) 44.8813 (+-0.152333) 9.00018 (+-0.00100877)
found -0.16 (+-0.00027523) 44.881 (+-0.152261) 9.00011 (+-0.0010083)
found 2.72 (+-0.000275077) 44.8809 (+-0.15225) 9.0001 (+-0.00100823)
found -3.04 (+-0.000293034) 39.8945 (+-0.14362) 8.00016 (+-0.00095108)
found -9.76 (+-0.000311604) 34.9071 (+-0.134245) 7.00003 (+-0.000888994)
found -3.52 (+-0.000312524) 34.9076 (+-0.134306) 7.00011 (+-0.000889397)
found -0.639999 (+-0.000313423) 34.9078 (+-0.134353) 7.00015 (+-0.000889712)
found 3.2 (+-0.00033773) 29.9208 (+-0.124353) 6.00011 (+-0.000823485)
found 6.08 (+-0.000338907) 29.921 (+-0.124405) 6.00015 (+-0.000823835)
found -8.32 (+-0.000335752) 29.9205 (+-0.124263) 6.00004 (+-0.000822889)
found -1.12 (+-0.000336797) 29.9207 (+-0.124311) 6.00008 (+-0.000823212)
found 1.76 (+-0.000337345) 29.9207 (+-0.124332) 6.00008 (+-0.000823346)
found 8 (+-0.000338629) 29.921 (+-0.124393) 6.00014 (+-0.000823751)
found 6.56 (+-0.000369131) 24.9339 (+-0.113487) 5.00007 (+-0.00075153)
found 0.319998 (+-0.000416012) 19.9475 (+-0.101607) 4.00013 (+-0.000672861)
found 2.24 (+-0.000416756) 19.9476 (+-0.101631) 4.00015 (+-0.000673017)
found 4.64 (+-0.000414399) 19.9474 (+-0.101561) 4.00011 (+-0.000672557)
found 8.96 (+-0.000418097) 19.9479 (+-0.101676) 4.00021 (+-0.000673313)
found 0.8 (+-0.00041443) 19.9473 (+-0.101555) 4.00008 (+-0.000672518)
found 1.28 (+-0.000415165) 19.9474 (+-0.101579) 4.0001 (+-0.000672674)
found 7.52 (+-0.000413327) 19.9472 (+-0.101525) 4.00007 (+-0.000672316)
found -4.48 (+-0.000481452) 14.9608 (+-0.0880227) 3.00013 (+-0.000582902)
found -9.28 (+-0.000480463) 14.9606 (+-0.0879969) 3.0001 (+-0.000582731)
found -8.8 (+-0.000480071) 14.9606 (+-0.0879869) 3.00009 (+-0.000582665)
found -6.4 (+-0.000477808) 14.9604 (+-0.0879326) 3.00005 (+-0.000582306)
found -4 (+-0.000480463) 14.9607 (+-0.0879969) 3.0001 (+-0.000582731)
found -6.88 (+-0.000477808) 14.9604 (+-0.0879326) 3.00005 (+-0.000582306)
found -5.92 (+-0.000592282) 9.97409 (+-0.0719151) 2.00013 (+-0.000476235)
found 3.68 (+-0.000594489) 9.97424 (+-0.0719517) 2.00016 (+-0.000476477)
found -7.36 (+-0.000585664) 9.97363 (+-0.071805) 2.00004 (+-0.000475505)
found -1.60001 (+-0.000849264) 4.98753 (+-0.0509555) 1.00016 (+-0.000337436)
found -7.84001 (+-0.000839918) 4.98712 (+-0.0508716) 1.00008 (+-0.000336881)
found 5.12001 (+-0.000846829) 4.98743 (+-0.0509338) 1.00014 (+-0.000337293)
found 7.04 (+-0.000842257) 4.98717 (+-0.0508908) 1.00009 (+-0.000337008)
#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()