This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 23.9365 6
created -9.1 15.9577 4
created -8.5 27.926 7
created -7.9 11.9683 3
created -7.3 19.9471 5
created -6.7 39.8942 10
created -6.1 39.8942 10
created -5.5 27.926 7
created -4.9 7.97885 2
created -4.3 3.98942 1
created -3.7 31.9154 8
created -3.1 23.9365 6
created -2.5 3.98942 1
created -1.9 23.9365 6
created -1.3 19.9471 5
created -0.7 27.926 7
created -0.1 11.9683 3
created 0.5 15.9577 4
created 1.1 39.8942 10
created 1.7 19.9471 5
created 2.3 39.8942 10
created 2.9 39.8942 10
created 3.5 15.9577 4
created 4.1 27.926 7
created 4.7 31.9154 8
created 5.3 35.9048 9
created 5.9 3.98942 1
created 6.5 7.97885 2
created 7.1 11.9683 3
created 7.7 7.97885 2
created 8.3 39.8942 10
created 8.9 39.8942 10
created 9.5 7.97885 2
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-2.23127e-05)
fit chi^2 = 1.47433e-06
found -6.7 (+-0.000168696) 39.8942 (+-0.0662863) 10.0002 (+-0.000543978)
found -6.1 (+-0.000168887) 39.8943 (+-0.0662954) 10.0002 (+-0.000544053)
found 1.1 (+-0.000168164) 39.8939 (+-0.0662605) 10.0001 (+-0.000543767)
found 2.3 (+-0.000168696) 39.8942 (+-0.0662863) 10.0002 (+-0.000543978)
found 2.9 (+-0.000168582) 39.8942 (+-0.066281) 10.0002 (+-0.000543935)
found 8.3 (+-0.000168284) 39.8941 (+-0.0662678) 10.0002 (+-0.000543826)
found 8.9 (+-0.000168284) 39.8941 (+-0.0662678) 10.0002 (+-0.000543826)
found 5.3 (+-0.000177099) 35.9046 (+-0.0628556) 9.00011 (+-0.000515824)
found -3.7 (+-0.000187762) 31.9151 (+-0.0592573) 8.00009 (+-0.000486295)
found 4.7 (+-0.000189071) 31.9156 (+-0.0593064) 8.00021 (+-0.000486697)
found -5.5 (+-0.000201618) 27.926 (+-0.05546) 7.00015 (+-0.000455132)
found -8.5 (+-0.000201122) 27.9258 (+-0.0554417) 7.00009 (+-0.000454982)
found -0.700001 (+-0.000201276) 27.9258 (+-0.055447) 7.0001 (+-0.000455025)
found 4.1 (+-0.000201829) 27.926 (+-0.055466) 7.00016 (+-0.000455181)
found -9.7 (+-0.000217482) 23.9363 (+-0.0513319) 6.00005 (+-0.000421255)
found -3.1 (+-0.000217434) 23.9365 (+-0.0513368) 6.00012 (+-0.000421295)
found -1.9 (+-0.000217015) 23.9364 (+-0.0513239) 6.00008 (+-0.000421189)
found 1.7 (+-0.000240701) 19.9478 (+-0.0469258) 5.00026 (+-0.000385096)
found -7.3 (+-0.000239473) 19.9474 (+-0.0468947) 5.00017 (+-0.000384841)
found -1.3 (+-0.000239699) 19.9474 (+-0.0468995) 5.00017 (+-0.000384881)
found -9.1 (+-0.000268548) 15.9581 (+-0.0419598) 4.00017 (+-0.000344342)
found 3.5 (+-0.000269253) 15.9583 (+-0.0419748) 4.00022 (+-0.000344466)
found 0.500004 (+-0.000268271) 15.9581 (+-0.041955) 4.00017 (+-0.000344303)
found -7.9 (+-0.000310713) 11.9687 (+-0.0363482) 3.00016 (+-0.000298291)
found -0.100002 (+-0.000310387) 11.9686 (+-0.0363431) 3.00014 (+-0.000298249)
found 7.1 (+-0.000307819) 11.9682 (+-0.0363037) 3.00005 (+-0.000297926)
found -4.90001 (+-0.000379608) 7.97911 (+-0.0296701) 2.00011 (+-0.000243487)
found 7.70001 (+-0.000382146) 7.97937 (+-0.0296965) 2.00017 (+-0.000243704)
found 9.5 (+-0.000377669) 7.97931 (+-0.0296586) 2.00016 (+-0.000243393)
found 6.5 (+-0.00037788) 7.9789 (+-0.029651) 2.00005 (+-0.000243331)
found -2.5 (+-0.000545693) 3.98997 (+-0.0210279) 1.00016 (+-0.000172565)
found 5.89998 (+-0.00054364) 3.98992 (+-0.0210174) 1.00014 (+-0.000172479)
found -4.29999 (+-0.000543119) 3.98987 (+-0.0210141) 1.00013 (+-0.000172452)
#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()