This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 53.1923 8
created -9.46 66.4904 10
created -9.1 59.8413 9
created -8.74 46.5433 7
created -8.38 33.2452 5
created -8.02 6.64904 1
created -7.66 33.2452 5
created -7.3 46.5433 7
created -6.94 59.8413 9
created -6.58 26.5962 4
created -6.22 59.8413 9
created -5.86 66.4904 10
created -5.5 66.4904 10
created -5.14 53.1923 8
created -4.78 66.4904 10
created -4.42 66.4904 10
created -4.06 33.2452 5
created -3.7 59.8413 9
created -3.34 66.4904 10
created -2.98 6.64904 1
created -2.62 53.1923 8
created -2.26 39.8942 6
created -1.9 46.5433 7
created -1.54 66.4904 10
created -1.18 6.64904 1
created -0.82 6.64904 1
created -0.46 66.4904 10
created -0.1 66.4904 10
created 0.26 66.4904 10
created 0.62 33.2452 5
created 0.98 6.64904 1
created 1.34 13.2981 2
created 1.7 13.2981 2
created 2.06 26.5962 4
created 2.42 13.2981 2
created 2.78 46.5433 7
created 3.14 66.4904 10
created 3.5 59.8413 9
created 3.86 26.5962 4
created 4.22 66.4904 10
created 4.58 59.8413 9
created 4.94 19.9471 3
created 5.3 39.8942 6
created 5.66 46.5433 7
created 6.02 6.64904 1
created 6.38 33.2452 5
created 6.74 59.8413 9
created 7.1 19.9471 3
created 7.46 39.8942 6
created 7.82 46.5433 7
created 8.18 39.8942 6
created 8.54 59.8413 9
created 8.9 39.8942 6
created 9.26 46.5433 7
created 9.62 46.5433 7
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.27818e-05)
fit chi^2 = 2.68057e-06
found -9.46 (+-0.000133385) 66.4907 (+-0.145435) 10.0001 (+-0.000733603)
found -5.86 (+-0.000133501) 66.4908 (+-0.145451) 10.0001 (+-0.000733684)
found -5.5 (+-0.000133441) 66.4907 (+-0.145442) 10.0001 (+-0.000733642)
found -4.78 (+-0.000133441) 66.4907 (+-0.145442) 10.0001 (+-0.000733642)
found -4.42 (+-0.000133225) 66.4906 (+-0.145413) 10.0001 (+-0.000733496)
found -3.34 (+-0.000132666) 66.4904 (+-0.145344) 10.0001 (+-0.000733148)
found -1.54 (+-0.000132543) 66.4903 (+-0.145327) 10.0001 (+-0.000733061)
found -0.459999 (+-0.000132721) 66.4904 (+-0.145352) 10.0001 (+-0.000733187)
found -0.1 (+-0.000133557) 66.4908 (+-0.145458) 10.0001 (+-0.000733723)
found 0.26 (+-0.000133225) 66.4906 (+-0.145413) 10.0001 (+-0.000733496)
found 3.14 (+-0.000133319) 66.4906 (+-0.145426) 10.0001 (+-0.000733558)
found 4.22 (+-0.000133079) 66.4905 (+-0.145394) 10.0001 (+-0.000733399)
found -9.1 (+-0.000140705) 59.8417 (+-0.137985) 9.00011 (+-0.000696024)
found 3.5 (+-0.000140441) 59.8416 (+-0.137953) 9.00009 (+-0.000695865)
found 4.58 (+-0.000140325) 59.8415 (+-0.13794) 9.00009 (+-0.000695798)
found -6.94 (+-0.000140244) 59.8414 (+-0.137928) 9.00007 (+-0.00069574)
found -6.22 (+-0.000140441) 59.8416 (+-0.137953) 9.00009 (+-0.000695865)
found -3.7 (+-0.00014054) 59.8416 (+-0.137965) 9.0001 (+-0.000695923)
found 6.74 (+-0.000139965) 59.8413 (+-0.137895) 9.00005 (+-0.000695573)
found 8.54 (+-0.000140351) 59.8415 (+-0.137941) 9.00008 (+-0.000695803)
found -5.14 (+-0.000149604) 53.1928 (+-0.130134) 8.00013 (+-0.000656422)
found -9.82 (+-0.000149088) 53.1924 (+-0.130067) 8.00007 (+-0.000656083)
found -2.62 (+-0.000148282) 53.1922 (+-0.129994) 8.00005 (+-0.000655717)
found -8.74 (+-0.000159596) 46.5436 (+-0.121696) 7.00009 (+-0.000613862)
found -7.3 (+-0.000159596) 46.5436 (+-0.121696) 7.00009 (+-0.000613862)
found -1.9 (+-0.000159781) 46.5437 (+-0.121714) 7.00011 (+-0.000613953)
found 2.78 (+-0.000159224) 46.5435 (+-0.121664) 7.00008 (+-0.000613697)
found 5.66 (+-0.000158638) 46.5433 (+-0.121609) 7.00005 (+-0.000613422)
found 7.82 (+-0.000159437) 46.5435 (+-0.12168) 7.00008 (+-0.000613781)
found 9.26 (+-0.000159534) 46.5435 (+-0.12169) 7.00009 (+-0.000613829)
found 9.62 (+-0.000158072) 46.5436 (+-0.121573) 7.00009 (+-0.000613238)
found -2.26 (+-0.000172746) 39.8946 (+-0.112699) 6.0001 (+-0.000568478)
found 8.9 (+-0.00017284) 39.8947 (+-0.112707) 6.00011 (+-0.000568519)
found 5.3 (+-0.000172103) 39.8944 (+-0.112646) 6.00007 (+-0.000568211)
found 7.46 (+-0.000172103) 39.8944 (+-0.112646) 6.00007 (+-0.000568211)
found 8.18 (+-0.00017284) 39.8947 (+-0.112707) 6.00011 (+-0.000568519)
found -4.06 (+-0.00018999) 33.2458 (+-0.102934) 5.00013 (+-0.000519223)
found 0.619999 (+-0.000188543) 33.2455 (+-0.102838) 5.00007 (+-0.000518735)
found -8.38 (+-0.000188219) 33.2453 (+-0.102814) 5.00005 (+-0.000518613)
found -7.66 (+-0.000188219) 33.2453 (+-0.102814) 5.00005 (+-0.000518613)
found 6.38 (+-0.000188443) 33.2454 (+-0.10283) 5.00007 (+-0.000518697)
found -6.58 (+-0.000212797) 26.5968 (+-0.09209) 4.00012 (+-0.000464521)
found 3.86 (+-0.000212921) 26.5968 (+-0.0920974) 4.00013 (+-0.000464559)
found 2.06 (+-0.000210125) 26.5961 (+-0.0919392) 4.00003 (+-0.000463761)
found 4.94 (+-0.000245965) 19.9476 (+-0.0797637) 3.0001 (+-0.000402345)
found 7.1 (+-0.000245965) 19.9476 (+-0.0797637) 3.0001 (+-0.000402345)
found 1.7 (+-0.000299599) 13.2983 (+-0.0650786) 2.00004 (+-0.00032827)
found 2.42 (+-0.000301527) 13.2985 (+-0.0651356) 2.00007 (+-0.000328558)
found 1.34 (+-0.000297899) 13.2981 (+-0.0650309) 2.00002 (+-0.00032803)
found -2.98 (+-0.000433742) 6.6498 (+-0.046175) 1.00012 (+-0.000232917)
found -1.18001 (+-0.000428325) 6.6495 (+-0.0460932) 1.00008 (+-0.000232504)
found 6.02 (+-0.000430914) 6.64953 (+-0.0461283) 1.00008 (+-0.000232681)
found -8.02 (+-0.000429838) 6.64944 (+-0.0461107) 1.00007 (+-0.000232592)
found 0.979998 (+-0.00042743) 6.64931 (+-0.0460739) 1.00005 (+-0.000232406)
found -0.819995 (+-0.000428325) 6.6495 (+-0.0460932) 1.00008 (+-0.000232504)
#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()