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 11.9683 3
created -8.5 15.9577 4
created -7.9 27.926 7
created -7.3 35.9048 9
created -6.7 3.98942 1
created -6.1 19.9471 5
created -5.5 31.9154 8
created -4.9 15.9577 4
created -4.3 11.9683 3
created -3.7 39.8942 10
created -3.1 31.9154 8
created -2.5 3.98942 1
created -1.9 23.9365 6
created -1.3 7.97885 2
created -0.7 3.98942 1
created -0.1 3.98942 1
created 0.5 15.9577 4
created 1.1 11.9683 3
created 1.7 39.8942 10
created 2.3 7.97885 2
created 2.9 35.9048 9
created 3.5 19.9471 5
created 4.1 3.98942 1
created 4.7 11.9683 3
created 5.3 15.9577 4
created 5.9 3.98942 1
created 6.5 15.9577 4
created 7.1 39.8942 10
created 7.7 23.9365 6
created 8.3 35.9048 9
created 8.9 23.9365 6
created 9.5 35.9048 9
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.90847e-05)
fit chi^2 = 6.22755e-06
found -3.7 (+-0.000345901) 39.894 (+-0.136196) 10.0001 (+-0.00111769)
found 1.7 (+-0.000344509) 39.8937 (+-0.136131) 10.0001 (+-0.00111715)
found 7.1 (+-0.000345822) 39.894 (+-0.136191) 10.0001 (+-0.00111765)
found -7.3 (+-0.000363798) 35.9045 (+-0.129175) 9.0001 (+-0.00106007)
found 2.9 (+-0.000363881) 35.9045 (+-0.129175) 9.00009 (+-0.00106008)
found 8.3 (+-0.000365255) 35.9048 (+-0.129233) 9.00015 (+-0.00106055)
found 9.5 (+-0.000362252) 35.9049 (+-0.129123) 9.00019 (+-0.00105965)
found -3.1 (+-0.000386681) 31.9154 (+-0.12182) 8.00014 (+-0.000999712)
found -5.5 (+-0.000386955) 31.9152 (+-0.121825) 8.00011 (+-0.000999752)
found -7.9 (+-0.000415017) 27.9261 (+-0.114003) 7.00017 (+-0.000935566)
found 7.7 (+-0.00045054) 23.9371 (+-0.105615) 6.00025 (+-0.000866729)
found 8.9 (+-0.000450313) 23.937 (+-0.105608) 6.00023 (+-0.000866671)
found -1.9 (+-0.00044471) 23.9362 (+-0.105445) 6.00004 (+-0.000865334)
found 3.5 (+-0.000490411) 19.9473 (+-0.0963388) 5.00013 (+-0.000790603)
found -9.7 (+-0.00048946) 19.9469 (+-0.0963028) 5.00004 (+-0.000790307)
found -6.1 (+-0.000490131) 19.9472 (+-0.0963313) 5.00012 (+-0.000790541)
found -4.9 (+-0.000550702) 15.958 (+-0.086213) 4.00014 (+-0.000707506)
found -8.5 (+-0.000550331) 15.9579 (+-0.0862051) 4.00013 (+-0.000707441)
found 0.500001 (+-0.000546538) 15.9576 (+-0.0861307) 4.00005 (+-0.00070683)
found 5.3 (+-0.000546538) 15.9576 (+-0.0861307) 4.00005 (+-0.00070683)
found 6.5 (+-0.000549522) 15.958 (+-0.0861936) 4.00014 (+-0.000707347)
found -9.1 (+-0.000636814) 11.9685 (+-0.0746758) 3.00012 (+-0.000612826)
found -4.3 (+-0.000639233) 11.9688 (+-0.0747155) 3.00018 (+-0.000613152)
found 1.1 (+-0.000639233) 11.9688 (+-0.0747155) 3.00018 (+-0.000613152)
found 4.7 (+-0.000633023) 11.9683 (+-0.07462) 3.00006 (+-0.000612368)
found 2.3 (+-0.000790371) 7.97968 (+-0.0610873) 2.00025 (+-0.000501312)
found -1.30001 (+-0.000779462) 7.97906 (+-0.0609707) 2.00009 (+-0.000500356)
found -6.70001 (+-0.00112364) 3.99008 (+-0.0432303) 1.00018 (+-0.000354769)
found -2.5 (+-0.00112404) 3.99008 (+-0.0432322) 1.00018 (+-0.000354785)
found 5.9 (+-0.00111518) 3.98977 (+-0.0431805) 1.0001 (+-0.00035436)
found 4.1 (+-0.00111486) 3.98977 (+-0.043179) 1.0001 (+-0.000354348)
found -0.700002 (+-0.00110264) 3.98951 (+-0.0431126) 1.00004 (+-0.000353803)
found -0.0999936 (+-0.00110707) 3.98961 (+-0.0431374) 1.00007 (+-0.000354006)
#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()