This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 39.8942 8
created -9.28 39.8942 8
created -8.8 39.8942 8
created -8.32 19.9471 4
created -7.84 49.8678 10
created -7.36 39.8942 8
created -6.88 44.881 9
created -6.4 14.9603 3
created -5.92 44.881 9
created -5.44 14.9603 3
created -4.96 44.881 9
created -4.48 19.9471 4
created -4 39.8942 8
created -3.52 14.9603 3
created -3.04 39.8942 8
created -2.56 24.9339 5
created -2.08 49.8678 10
created -1.6 44.881 9
created -1.12 4.98678 1
created -0.64 29.9207 6
created -0.16 19.9471 4
created 0.32 4.98678 1
created 0.8 14.9603 3
created 1.28 34.9074 7
created 1.76 49.8678 10
created 2.24 34.9074 7
created 2.72 49.8678 10
created 3.2 49.8678 10
created 3.68 24.9339 5
created 4.16 34.9074 7
created 4.64 9.97356 2
created 5.12 34.9074 7
created 5.6 29.9207 6
created 6.08 24.9339 5
created 6.56 24.9339 5
created 7.04 9.97356 2
created 7.52 44.881 9
created 8 14.9603 3
created 8.48 44.881 9
created 8.96 39.8942 8
created 9.44 24.9339 5
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.10108e-05)
fit chi^2 = 2.85278e-06
found -7.84 (+-0.000185826) 49.8677 (+-0.114244) 10.0001 (+-0.000756547)
found -2.08 (+-0.000186035) 49.8678 (+-0.11426) 10.0001 (+-0.00075665)
found 1.76 (+-0.000186071) 49.8678 (+-0.114262) 10.0001 (+-0.000756665)
found 2.72 (+-0.000186324) 49.868 (+-0.114282) 10.0002 (+-0.000756795)
found 3.2 (+-0.000186113) 49.8679 (+-0.114266) 10.0002 (+-0.000756691)
found -6.88 (+-0.000195856) 44.881 (+-0.108381) 9.00011 (+-0.000717717)
found -5.92 (+-0.000195232) 44.8807 (+-0.108339) 9.00006 (+-0.000717438)
found -4.96 (+-0.000195392) 44.8808 (+-0.108349) 9.00007 (+-0.000717507)
found -1.6 (+-0.000195559) 44.881 (+-0.108365) 9.00011 (+-0.000717611)
found 7.52 (+-0.000195035) 44.8807 (+-0.108326) 9.00005 (+-0.000717356)
found 8.48 (+-0.000195856) 44.881 (+-0.108381) 9.00011 (+-0.000717717)
found -9.76 (+-0.000208098) 39.8941 (+-0.102195) 8.00008 (+-0.000676756)
found -9.28 (+-0.0002086) 39.8945 (+-0.102234) 8.00016 (+-0.000677014)
found -8.8 (+-0.00020808) 39.8943 (+-0.102203) 8.00012 (+-0.000676805)
found -7.36 (+-0.0002089) 39.8947 (+-0.102253) 8.00019 (+-0.00067714)
found -4 (+-0.000207386) 39.894 (+-0.102161) 8.00007 (+-0.000676527)
found -3.04 (+-0.000207538) 39.8941 (+-0.10217) 8.00008 (+-0.000676587)
found 8.96 (+-0.000208335) 39.8944 (+-0.102218) 8.00014 (+-0.000676908)
found 1.28 (+-0.000222684) 34.9076 (+-0.0956158) 7.00013 (+-0.000633185)
found 2.24 (+-0.000223695) 34.908 (+-0.09567) 7.0002 (+-0.000633544)
found 4.16 (+-0.000221809) 34.9073 (+-0.0955686) 7.00007 (+-0.000632873)
found 5.12 (+-0.000221959) 34.9074 (+-0.0955767) 7.00008 (+-0.000632927)
found 5.6 (+-0.000240853) 29.9209 (+-0.0885368) 6.00012 (+-0.000586307)
found -0.639999 (+-0.000239227) 29.9205 (+-0.0884646) 6.00005 (+-0.000585829)
found -2.56 (+-0.000265258) 24.9345 (+-0.0808797) 5.00018 (+-0.0005356)
found 3.68 (+-0.000265091) 24.9344 (+-0.0808729) 5.00017 (+-0.000535555)
found 6.08 (+-0.000264063) 24.9341 (+-0.0808313) 5.00011 (+-0.00053528)
found 9.44 (+-0.000261816) 24.9342 (+-0.0807612) 5.00013 (+-0.000534815)
found 6.56 (+-0.000263025) 24.9339 (+-0.0807919) 5.00007 (+-0.000535018)
found -8.32 (+-0.000297257) 19.9478 (+-0.072364) 4.00018 (+-0.000479207)
found -4.48 (+-0.000297084) 19.9477 (+-0.0723581) 4.00017 (+-0.000479169)
found -0.160002 (+-0.00029422) 19.9472 (+-0.0722689) 4.00007 (+-0.000478578)
found -6.4 (+-0.000344383) 14.9611 (+-0.0626982) 3.00018 (+-0.000415199)
found -5.44 (+-0.000344383) 14.9611 (+-0.0626982) 3.00018 (+-0.000415199)
found 8 (+-0.000344383) 14.9611 (+-0.0626982) 3.00018 (+-0.000415199)
found -3.52 (+-0.000343909) 14.9609 (+-0.0626859) 3.00016 (+-0.000415118)
found 0.800003 (+-0.000340743) 14.9605 (+-0.062611) 3.00008 (+-0.000414622)
found 4.64 (+-0.000422577) 9.97414 (+-0.0512067) 2.00014 (+-0.0003391)
found 7.04 (+-0.000422422) 9.97414 (+-0.0512044) 2.00014 (+-0.000339085)
found -1.12 (+-0.000603991) 4.98748 (+-0.0362666) 1.00015 (+-0.000240164)
found 0.319999 (+-0.000597561) 4.98707 (+-0.0362082) 1.00007 (+-0.000239777)
#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()