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 7.97885 2
created -8.5 23.9365 6
created -7.9 27.926 7
created -7.3 35.9048 9
created -6.7 15.9577 4
created -6.1 39.8942 10
created -5.5 23.9365 6
created -4.9 27.926 7
created -4.3 31.9154 8
created -3.7 7.97885 2
created -3.1 7.97885 2
created -2.5 35.9048 9
created -1.9 11.9683 3
created -1.3 3.98942 1
created -0.7 7.97885 2
created -0.1 3.98942 1
created 0.5 39.8942 10
created 1.1 27.926 7
created 1.7 35.9048 9
created 2.3 31.9154 8
created 2.9 11.9683 3
created 3.5 7.97885 2
created 4.1 35.9048 9
created 4.7 19.9471 5
created 5.3 7.97885 2
created 5.9 35.9048 9
created 6.5 27.926 7
created 7.1 19.9471 5
created 7.7 31.9154 8
created 8.3 19.9471 5
created 8.9 31.9154 8
created 9.5 39.8942 10
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.78675e-05)
fit chi^2 = 6.89734e-06
found -6.1 (+-0.000363944) 39.894 (+-0.143328) 10.0001 (+-0.00117622)
found 0.500001 (+-0.000363012) 39.8939 (+-0.143288) 10.0001 (+-0.00117589)
found 9.5 (+-0.000361907) 39.8944 (+-0.143252) 10.0002 (+-0.0011756)
found -7.3 (+-0.000384101) 35.9047 (+-0.135993) 9.00014 (+-0.00111602)
found -2.5 (+-0.000382371) 35.9044 (+-0.13592) 9.00006 (+-0.00111543)
found 1.7 (+-0.000385018) 35.9049 (+-0.136033) 9.00019 (+-0.00111635)
found 4.1 (+-0.00038295) 35.9045 (+-0.135945) 9.00009 (+-0.00111563)
found 5.9 (+-0.000383397) 35.9046 (+-0.135964) 9.00011 (+-0.00111579)
found 2.3 (+-0.000407793) 31.9154 (+-0.128232) 8.00015 (+-0.00105233)
found -4.3 (+-0.000406947) 31.9152 (+-0.1282) 8.00011 (+-0.00105207)
found 7.7 (+-0.000407531) 31.9153 (+-0.12822) 8.00013 (+-0.00105224)
found 8.9 (+-0.00040863) 31.9156 (+-0.128264) 8.0002 (+-0.0010526)
found 1.1 (+-0.000438347) 27.9264 (+-0.120033) 7.00025 (+-0.000985045)
found 6.5 (+-0.000437104) 27.9262 (+-0.119989) 7.00018 (+-0.000984686)
found -7.9 (+-0.000437401) 27.9262 (+-0.119999) 7.00019 (+-0.00098477)
found -4.9 (+-0.000437178) 27.9262 (+-0.119991) 7.00018 (+-0.000984704)
found -5.5 (+-0.000473613) 23.937 (+-0.111133) 6.00022 (+-0.000912013)
found -8.5 (+-0.000470797) 23.9366 (+-0.11105) 6.00012 (+-0.000911331)
found 4.7 (+-0.000517027) 19.9473 (+-0.101408) 5.00014 (+-0.0008322)
found -9.7 (+-0.000514458) 19.9468 (+-0.101334) 5.00003 (+-0.000831596)
found 7.1 (+-0.000519136) 19.9475 (+-0.101458) 5.00019 (+-0.000832617)
found 8.3 (+-0.000519462) 19.9476 (+-0.101467) 5.00021 (+-0.000832686)
found -6.7 (+-0.000583137) 15.9584 (+-0.0908051) 4.00025 (+-0.000745191)
found -1.90001 (+-0.000668975) 11.9686 (+-0.0785758) 3.00013 (+-0.000644831)
found 2.9 (+-0.000669973) 11.9686 (+-0.0785882) 3.00013 (+-0.000644933)
found -3.70001 (+-0.000823839) 7.97922 (+-0.0642023) 2.00013 (+-0.000526876)
found 3.50001 (+-0.000825962) 7.97932 (+-0.0642247) 2.00016 (+-0.000527059)
found 5.3 (+-0.000828155) 7.97942 (+-0.0642478) 2.00018 (+-0.000527248)
found -9.1 (+-0.000826028) 7.97927 (+-0.0642236) 2.00014 (+-0.00052705)
found -3.09999 (+-0.000824478) 7.97927 (+-0.0642098) 2.00014 (+-0.000526937)
found -0.7 (+-0.000813868) 7.9788 (+-0.0640986) 2.00003 (+-0.000526024)
found -0.0999824 (+-0.0011769) 3.98998 (+-0.0454658) 1.00016 (+-0.000373115)
found -1.3 (+-0.00116677) 3.98961 (+-0.0454054) 1.00007 (+-0.000372619)
#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()