This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 35.9048 9
created -9.1 35.9048 9
created -8.5 19.9471 5
created -7.9 11.9683 3
created -7.3 39.8942 10
created -6.7 7.97885 2
created -6.1 19.9471 5
created -5.5 11.9683 3
created -4.9 27.926 7
created -4.3 27.926 7
created -3.7 3.98942 1
created -3.1 39.8942 10
created -2.5 19.9471 5
created -1.9 35.9048 9
created -1.3 11.9683 3
created -0.7 7.97885 2
created -0.1 15.9577 4
created 0.5 19.9471 5
created 1.1 11.9683 3
created 1.7 27.926 7
created 2.3 11.9683 3
created 2.9 27.926 7
created 3.5 19.9471 5
created 4.1 7.97885 2
created 4.7 15.9577 4
created 5.3 3.98942 1
created 5.9 35.9048 9
created 6.5 39.8942 10
created 7.1 39.8942 10
created 7.7 31.9154 8
created 8.3 23.9365 6
created 8.9 39.8942 10
created 9.5 27.926 7
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.0253e-05)
fit chi^2 = 4.87249e-06
found -7.3 (+-0.000304732) 39.8937 (+-0.120413) 10.0001 (+-0.000988166)
found -3.1 (+-0.000304769) 39.8938 (+-0.120416) 10.0001 (+-0.000988195)
found 6.5 (+-0.000307314) 39.8945 (+-0.120535) 10.0002 (+-0.00098917)
found 7.1 (+-0.000307176) 39.8944 (+-0.120528) 10.0002 (+-0.000989114)
found 8.9 (+-0.000306445) 39.8942 (+-0.120492) 10.0002 (+-0.000988819)
found -9.7 (+-0.00032331) 35.9046 (+-0.114313) 9.00012 (+-0.000938107)
found -9.1 (+-0.000323377) 35.9048 (+-0.114325) 9.00018 (+-0.000938208)
found -1.9 (+-0.000322193) 35.9045 (+-0.114274) 9.0001 (+-0.000937787)
found 5.9 (+-0.000322244) 35.9047 (+-0.114281) 9.00014 (+-0.000937843)
found 7.7 (+-0.000343674) 31.9156 (+-0.107814) 8.00021 (+-0.000884772)
found 9.5 (+-0.000364428) 27.9263 (+-0.100768) 7.00022 (+-0.000826948)
found -4.9 (+-0.000366377) 27.9259 (+-0.100816) 7.00013 (+-0.000827341)
found -4.3 (+-0.000365401) 27.9258 (+-0.100785) 7.0001 (+-0.000827094)
found 1.7 (+-0.000365297) 27.9257 (+-0.100779) 7.00008 (+-0.000827039)
found 2.9 (+-0.000365907) 27.9258 (+-0.100799) 7.0001 (+-0.000827207)
found 8.3 (+-0.000398304) 23.937 (+-0.0934141) 6.00023 (+-0.000766601)
found -8.5 (+-0.000435115) 19.9474 (+-0.0852455) 5.00016 (+-0.000699566)
found -2.5 (+-0.000437345) 19.9477 (+-0.0853019) 5.00025 (+-0.000700029)
found -6.1 (+-0.000432598) 19.947 (+-0.0851824) 5.00007 (+-0.000699048)
found 0.5 (+-0.00043359) 19.9471 (+-0.0852061) 5.00009 (+-0.000699243)
found 3.5 (+-0.000434041) 19.9472 (+-0.0852188) 5.00012 (+-0.000699347)
found -0.0999984 (+-0.000485356) 15.9578 (+-0.076223) 4.00009 (+-0.000625523)
found 4.7 (+-0.000482772) 15.9575 (+-0.0761731) 4.00004 (+-0.000625114)
found -7.9 (+-0.000566024) 11.9688 (+-0.066098) 3.0002 (+-0.000542433)
found -5.5 (+-0.000564857) 11.9687 (+-0.0660786) 3.00016 (+-0.000542274)
found -1.3 (+-0.000563491) 11.9686 (+-0.0660594) 3.00014 (+-0.000542116)
found 1.1 (+-0.000564857) 11.9687 (+-0.0660786) 3.00016 (+-0.000542274)
found 2.3 (+-0.000565842) 11.9688 (+-0.0660944) 3.00018 (+-0.000542403)
found -6.70001 (+-0.000696564) 7.97947 (+-0.0540058) 2.0002 (+-0.000443198)
found -0.699999 (+-0.000690889) 7.97906 (+-0.0539432) 2.00009 (+-0.000442684)
found 4.1 (+-0.000692707) 7.97916 (+-0.0539626) 2.00012 (+-0.000442843)
found -3.69999 (+-0.000997299) 3.99023 (+-0.038259) 1.00022 (+-0.000313972)
found 5.30001 (+-0.000992381) 3.99003 (+-0.0382303) 1.00017 (+-0.000313736)
#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()