This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 19.9471 5
created -9.1 15.9577 4
created -8.5 27.926 7
created -7.9 31.9154 8
created -7.3 31.9154 8
created -6.7 35.9048 9
created -6.1 39.8942 10
created -5.5 27.926 7
created -4.9 31.9154 8
created -4.3 15.9577 4
created -3.7 7.97885 2
created -3.1 39.8942 10
created -2.5 27.926 7
created -1.9 39.8942 10
created -1.3 3.98942 1
created -0.7 27.926 7
created -0.1 15.9577 4
created 0.5 23.9365 6
created 1.1 31.9154 8
created 1.7 23.9365 6
created 2.3 19.9471 5
created 2.9 23.9365 6
created 3.5 7.97885 2
created 4.1 11.9683 3
created 4.7 7.97885 2
created 5.3 35.9048 9
created 5.9 19.9471 5
created 6.5 39.8942 10
created 7.1 35.9048 9
created 7.7 19.9471 5
created 8.3 27.926 7
created 8.9 11.9683 3
created 9.5 11.9683 3
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-2.60766e-05)
fit chi^2 = 2.14264e-06
found -6.1 (+-0.000203512) 39.8943 (+-0.0799168) 10.0002 (+-0.000655836)
found -3.1 (+-0.000202598) 39.8939 (+-0.079874) 10.0001 (+-0.000655485)
found -1.9 (+-0.000202327) 39.8939 (+-0.0798626) 10.0001 (+-0.000655392)
found 6.5 (+-0.000203282) 39.8942 (+-0.0799058) 10.0002 (+-0.000655746)
found -6.7 (+-0.000214896) 35.905 (+-0.0758325) 9.00023 (+-0.000622319)
found 5.3 (+-0.00021344) 35.9045 (+-0.0757698) 9.00009 (+-0.000621804)
found 7.1 (+-0.000214534) 35.9049 (+-0.0758167) 9.00019 (+-0.000622189)
found -7.9 (+-0.000227819) 31.9155 (+-0.071491) 8.00019 (+-0.00058669)
found -7.3 (+-0.000228051) 31.9156 (+-0.0715003) 8.00022 (+-0.000586767)
found -4.9 (+-0.000227252) 31.9153 (+-0.0714689) 8.00014 (+-0.000586509)
found 1.1 (+-0.000227434) 31.9154 (+-0.0714757) 8.00015 (+-0.000586565)
found -5.5 (+-0.000244191) 27.9263 (+-0.0668965) 7.00023 (+-0.000548986)
found -2.5 (+-0.000244433) 27.9264 (+-0.0669052) 7.00026 (+-0.000549057)
found -8.5 (+-0.00024331) 27.926 (+-0.0668658) 7.00015 (+-0.000548734)
found -0.699999 (+-0.000241815) 27.9257 (+-0.0668166) 7.00006 (+-0.00054833)
found 8.3 (+-0.000242644) 27.9258 (+-0.0668429) 7.0001 (+-0.000548546)
found 0.500001 (+-0.000263121) 23.9367 (+-0.0619152) 6.00016 (+-0.000508106)
found 1.7 (+-0.000263337) 23.9367 (+-0.0619215) 6.00017 (+-0.000508158)
found 2.9 (+-0.000262048) 23.9364 (+-0.0618838) 6.00009 (+-0.000507849)
found 5.9 (+-0.000290016) 19.9477 (+-0.0565662) 5.00025 (+-0.00046421)
found 7.7 (+-0.000289511) 19.9476 (+-0.056553) 5.00021 (+-0.000464101)
found -9.7 (+-0.000287394) 19.9469 (+-0.056495) 5.00005 (+-0.000463625)
found 2.3 (+-0.000288765) 19.9473 (+-0.0565336) 5.00016 (+-0.000463943)
found -9.1 (+-0.000323473) 15.958 (+-0.0505781) 4.00016 (+-0.000415069)
found -4.3 (+-0.000322573) 15.9579 (+-0.050561) 4.00013 (+-0.000414928)
found -0.1 (+-0.000323742) 15.9581 (+-0.0505837) 4.00017 (+-0.000415115)
found 8.9 (+-0.000373716) 11.9686 (+-0.0438056) 3.00013 (+-0.00035949)
found 4.1 (+-0.000371084) 11.9682 (+-0.0437652) 3.00005 (+-0.000359159)
found 9.5 (+-0.000368588) 11.9683 (+-0.0437365) 3.00008 (+-0.000358923)
found -3.69999 (+-0.000461351) 7.97942 (+-0.0358069) 2.00018 (+-0.000293849)
found 4.70001 (+-0.000460357) 7.97931 (+-0.0357961) 2.00016 (+-0.00029376)
found 3.5 (+-0.00045918) 7.97916 (+-0.0357827) 2.00012 (+-0.00029365)
found -1.30001 (+-0.00066134) 3.99023 (+-0.0253707) 1.00022 (+-0.000208204)
#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()