This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 13.2981 2
created -9.46 26.5962 4
created -9.1 26.5962 4
created -8.74 19.9471 3
created -8.38 26.5962 4
created -8.02 66.4904 10
created -7.66 6.64904 1
created -7.3 26.5962 4
created -6.94 33.2452 5
created -6.58 19.9471 3
created -6.22 59.8413 9
created -5.86 13.2981 2
created -5.5 13.2981 2
created -5.14 33.2452 5
created -4.78 66.4904 10
created -4.42 6.64904 1
created -4.06 53.1923 8
created -3.7 46.5433 7
created -3.34 39.8942 6
created -2.98 19.9471 3
created -2.62 66.4904 10
created -2.26 66.4904 10
created -1.9 53.1923 8
created -1.54 19.9471 3
created -1.18 33.2452 5
created -0.82 66.4904 10
created -0.46 59.8413 9
created -0.1 59.8413 9
created 0.26 26.5962 4
created 0.62 53.1923 8
created 0.98 39.8942 6
created 1.34 6.64904 1
created 1.7 26.5962 4
created 2.06 59.8413 9
created 2.42 59.8413 9
created 2.78 6.64904 1
created 3.14 46.5433 7
created 3.5 6.64904 1
created 3.86 66.4904 10
created 4.22 39.8942 6
created 4.58 59.8413 9
created 4.94 59.8413 9
created 5.3 46.5433 7
created 5.66 66.4904 10
created 6.02 26.5962 4
created 6.38 33.2452 5
created 6.74 46.5433 7
created 7.1 53.1923 8
created 7.46 26.5962 4
created 7.82 26.5962 4
created 8.18 6.64904 1
created 8.54 66.4904 10
created 8.9 19.9471 3
created 9.26 66.4904 10
created 9.62 26.5962 4
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.03129e-05)
fit chi^2 = 1.55585e-06
found -8.02 (+-0.000100798) 66.4901 (+-0.110693) 10 (+-0.000558361)
found -4.78 (+-0.000100865) 66.4902 (+-0.110702) 10 (+-0.000558406)
found -2.62 (+-0.000101348) 66.4905 (+-0.110764) 10.0001 (+-0.000558718)
found -2.26 (+-0.000101662) 66.4907 (+-0.110805) 10.0001 (+-0.000558925)
found -0.82 (+-0.000101455) 66.4905 (+-0.110777) 10.0001 (+-0.000558784)
found 3.86 (+-0.000100924) 66.4902 (+-0.11071) 10 (+-0.000558446)
found 5.66 (+-0.000101291) 66.4904 (+-0.110755) 10.0001 (+-0.000558674)
found 8.54 (+-0.000100719) 66.4901 (+-0.110683) 10 (+-0.00055831)
found 9.26 (+-0.00010103) 66.4902 (+-0.110721) 10 (+-0.000558501)
found -0.46 (+-0.000107301) 59.8418 (+-0.105137) 9.00013 (+-0.000530331)
found -0.1 (+-0.000106948) 59.8415 (+-0.105094) 9.00009 (+-0.000530115)
found 2.42 (+-0.000106602) 59.8414 (+-0.105056) 9.00007 (+-0.000529923)
found 4.94 (+-0.00010715) 59.8416 (+-0.105118) 9.00011 (+-0.000530236)
found -6.22 (+-0.000106363) 59.8411 (+-0.105024) 9.00003 (+-0.000529766)
found 2.06 (+-0.000106948) 59.8415 (+-0.105094) 9.00009 (+-0.000530115)
found 4.58 (+-0.00010709) 59.8416 (+-0.10511) 9.0001 (+-0.000530199)
found -1.9 (+-0.000113486) 53.1925 (+-0.0990896) 8.00009 (+-0.000499829)
found -4.06 (+-0.000113033) 53.1923 (+-0.099043) 8.00005 (+-0.000499594)
found 0.62 (+-0.000113352) 53.1924 (+-0.0990736) 8.00007 (+-0.000499748)
found 7.1 (+-0.000113417) 53.1924 (+-0.0990808) 8.00007 (+-0.000499785)
found -3.7 (+-0.000121608) 46.5436 (+-0.092716) 7.00009 (+-0.000467679)
found 5.3 (+-0.000121934) 46.5438 (+-0.0927481) 7.00013 (+-0.000467841)
found 3.14 (+-0.000120259) 46.543 (+-0.0925935) 7.00001 (+-0.000467061)
found 6.74 (+-0.000121526) 46.5435 (+-0.0927081) 7.00009 (+-0.000467639)
found 0.979999 (+-0.00013082) 39.8943 (+-0.0857984) 6.00006 (+-0.000432785)
found 4.22 (+-0.000131894) 39.8948 (+-0.0858845) 6.00013 (+-0.000433219)
found -3.34 (+-0.000131116) 39.8944 (+-0.0858194) 6.00007 (+-0.000432891)
found -6.94 (+-0.000143499) 33.2453 (+-0.0783325) 5.00005 (+-0.000395126)
found -5.14 (+-0.000143898) 33.2455 (+-0.0783625) 5.00008 (+-0.000395277)
found -1.18 (+-0.000144082) 33.2455 (+-0.0783744) 5.00009 (+-0.000395337)
found 6.38 (+-0.00014398) 33.2455 (+-0.0783659) 5.00007 (+-0.000395294)
found -9.1 (+-0.000160703) 26.5963 (+-0.0700772) 4.00005 (+-0.000353484)
found 0.26 (+-0.000162018) 26.5967 (+-0.0701527) 4.00011 (+-0.000353865)
found 6.02 (+-0.000161744) 26.5966 (+-0.0701371) 4.0001 (+-0.000353787)
found 7.46 (+-0.000161396) 26.5965 (+-0.0701168) 4.00008 (+-0.000353684)
found 7.82 (+-0.000160172) 26.5962 (+-0.0700498) 4.00003 (+-0.000353346)
found 9.62 (+-0.000159998) 26.5966 (+-0.0700555) 4.00009 (+-0.000353375)
found -9.46 (+-0.000160481) 26.5962 (+-0.0700654) 4.00004 (+-0.000353425)
found -8.38 (+-0.000161409) 26.5965 (+-0.0701187) 4.00009 (+-0.000353693)
found -7.3 (+-0.000160322) 26.5962 (+-0.0700584) 4.00004 (+-0.000353389)
found 1.7 (+-0.000160779) 26.5964 (+-0.0700856) 4.00007 (+-0.000353526)
found -8.74 (+-0.000186229) 19.9473 (+-0.0607166) 3.00005 (+-0.000306268)
found -6.58 (+-0.000187215) 19.9476 (+-0.0607603) 3.00009 (+-0.000306488)
found -2.98 (+-0.000187508) 19.9477 (+-0.0607735) 3.00011 (+-0.000306554)
found -1.54 (+-0.000187086) 19.9476 (+-0.0607544) 3.00009 (+-0.000306458)
found 8.9 (+-0.000188055) 19.9479 (+-0.0607982) 3.00013 (+-0.000306679)
found -5.86 (+-0.000229348) 13.2985 (+-0.0496143) 2.00007 (+-0.000250265)
found -5.5 (+-0.000228523) 13.2983 (+-0.0495884) 2.00005 (+-0.000250134)
found -9.82 (+-0.000227674) 13.2982 (+-0.0495605) 2.00003 (+-0.000249994)
found -4.42 (+-0.000330446) 6.6498 (+-0.0351784) 1.00012 (+-0.000177447)
found -7.66 (+-0.000328753) 6.64962 (+-0.0351513) 1.00009 (+-0.00017731)
found 2.78 (+-0.000329792) 6.64971 (+-0.0351675) 1.00011 (+-0.000177392)
found 3.5 (+-0.000330091) 6.64976 (+-0.0351726) 1.00012 (+-0.000177418)
found 1.34 (+-0.000327406) 6.64944 (+-0.0351286) 1.00007 (+-0.000177196)
found 8.18 (+-0.000328753) 6.64962 (+-0.0351513) 1.00009 (+-0.00017731)
#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()