This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 44.881 9
created -9.28 49.8678 10
created -8.8 19.9471 4
created -8.32 24.9339 5
created -7.84 9.97356 2
created -7.36 4.98678 1
created -6.88 49.8678 10
created -6.4 19.9471 4
created -5.92 29.9207 6
created -5.44 24.9339 5
created -4.96 44.881 9
created -4.48 44.881 9
created -4 34.9074 7
created -3.52 29.9207 6
created -3.04 39.8942 8
created -2.56 29.9207 6
created -2.08 4.98678 1
created -1.6 9.97356 2
created -1.12 44.881 9
created -0.64 39.8942 8
created -0.16 24.9339 5
created 0.32 44.881 9
created 0.8 39.8942 8
created 1.28 14.9603 3
created 1.76 44.881 9
created 2.24 49.8678 10
created 2.72 34.9074 7
created 3.2 44.881 9
created 3.68 14.9603 3
created 4.16 49.8678 10
created 4.64 49.8678 10
created 5.12 39.8942 8
created 5.6 9.97356 2
created 6.08 4.98678 1
created 6.56 39.8942 8
created 7.04 14.9603 3
created 7.52 39.8942 8
created 8 39.8942 8
created 8.48 19.9471 4
created 8.96 14.9603 3
created 9.44 44.881 9
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.8017e-05)
fit chi^2 = 5.0723e-06
found -9.28 (+-0.000247896) 49.8678 (+-0.152345) 10.0001 (+-0.00100886)
found -6.88 (+-0.000246457) 49.8674 (+-0.152242) 10 (+-0.00100817)
found 2.24 (+-0.000248344) 49.8679 (+-0.152378) 10.0002 (+-0.00100907)
found 4.16 (+-0.000247803) 49.8678 (+-0.152339) 10.0001 (+-0.00100882)
found 4.64 (+-0.00024857) 49.868 (+-0.152395) 10.0002 (+-0.00100919)
found -9.76 (+-0.000261728) 44.8809 (+-0.144544) 9.0001 (+-0.000957196)
found -4.96 (+-0.00026168) 44.8811 (+-0.144552) 9.00014 (+-0.000957251)
found -4.48 (+-0.000261988) 44.8812 (+-0.144573) 9.00016 (+-0.000957389)
found -1.12 (+-0.000260894) 44.8809 (+-0.144501) 9.0001 (+-0.000956912)
found 0.32 (+-0.000261558) 44.8811 (+-0.144544) 9.00013 (+-0.000957194)
found 1.76 (+-0.000261394) 44.8811 (+-0.144534) 9.00013 (+-0.000957132)
found 3.2 (+-0.000261027) 44.8809 (+-0.144508) 9.0001 (+-0.00095696)
found 9.44 (+-0.000258746) 44.881 (+-0.144376) 9.00012 (+-0.000956083)
found -3.04 (+-0.000277535) 39.8943 (+-0.136283) 8.00012 (+-0.000902493)
found -0.640001 (+-0.000277799) 39.8944 (+-0.1363) 8.00014 (+-0.000902605)
found 0.799999 (+-0.000277355) 39.8943 (+-0.136274) 8.00012 (+-0.000902433)
found 5.12 (+-0.000277185) 39.8943 (+-0.136266) 8.00012 (+-0.000902377)
found 6.56 (+-0.000275604) 39.8939 (+-0.136172) 8.00004 (+-0.000901754)
found 7.52 (+-0.00027722) 39.8943 (+-0.136266) 8.00011 (+-0.000902376)
found 8 (+-0.000277459) 39.8943 (+-0.13628) 8.00012 (+-0.000902468)
found -4 (+-0.000297494) 34.9078 (+-0.127525) 7.00015 (+-0.000844494)
found 2.72 (+-0.000298137) 34.908 (+-0.127561) 7.00019 (+-0.00084473)
found -3.52 (+-0.000321787) 29.921 (+-0.118087) 6.00015 (+-0.000781992)
found -2.56 (+-0.000319866) 29.9207 (+-0.118002) 6.00009 (+-0.000781433)
found -5.92 (+-0.00032046) 29.9207 (+-0.118025) 6.00009 (+-0.00078158)
found -5.44 (+-0.000353045) 24.9343 (+-0.10782) 5.00015 (+-0.000714005)
found -0.16 (+-0.000353511) 24.9344 (+-0.107839) 5.00017 (+-0.00071413)
found -8.32 (+-0.00035042) 24.9339 (+-0.107718) 5.00006 (+-0.000713328)
found -8.8 (+-0.000395473) 19.9476 (+-0.0964628) 4.00015 (+-0.000638794)
found -6.4 (+-0.000395803) 19.9477 (+-0.0964734) 4.00016 (+-0.000638864)
found 8.48 (+-0.000394182) 19.9474 (+-0.0964213) 4.00011 (+-0.000638519)
found 3.68 (+-0.000459501) 14.9611 (+-0.0836109) 3.00019 (+-0.000553686)
found 1.28 (+-0.000458891) 14.961 (+-0.0835951) 3.00017 (+-0.000553582)
found 7.04 (+-0.000458576) 14.961 (+-0.083587) 3.00016 (+-0.000553528)
found 8.96 (+-0.000457263) 14.9608 (+-0.0835548) 3.00013 (+-0.000553315)
found -7.84 (+-0.000557345) 9.97374 (+-0.06818) 2.00006 (+-0.0004515)
found 5.6 (+-0.000558913) 9.97389 (+-0.0682078) 2.00009 (+-0.000451685)
found -1.59999 (+-0.000559344) 9.97394 (+-0.0682157) 2.0001 (+-0.000451737)
found -7.35999 (+-0.000800476) 4.98733 (+-0.0483173) 1.00012 (+-0.000319966)
found -2.08001 (+-0.00079723) 4.98713 (+-0.0482861) 1.00008 (+-0.000319759)
found 6.08001 (+-0.000798996) 4.98723 (+-0.0483029) 1.0001 (+-0.00031987)
#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()