This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 19.9471 4
created -9.28 19.9471 4
created -8.8 29.9207 6
created -8.32 24.9339 5
created -7.84 24.9339 5
created -7.36 34.9074 7
created -6.88 39.8942 8
created -6.4 49.8678 10
created -5.92 34.9074 7
created -5.44 24.9339 5
created -4.96 39.8942 8
created -4.48 39.8942 8
created -4 4.98678 1
created -3.52 34.9074 7
created -3.04 14.9603 3
created -2.56 49.8678 10
created -2.08 4.98678 1
created -1.6 44.881 9
created -1.12 34.9074 7
created -0.64 49.8678 10
created -0.16 14.9603 3
created 0.32 14.9603 3
created 0.8 9.97356 2
created 1.28 9.97356 2
created 1.76 19.9471 4
created 2.24 44.881 9
created 2.72 14.9603 3
created 3.2 44.881 9
created 3.68 4.98678 1
created 4.16 49.8678 10
created 4.64 29.9207 6
created 5.12 34.9074 7
created 5.6 9.97356 2
created 6.08 29.9207 6
created 6.56 9.97356 2
created 7.04 9.97356 2
created 7.52 14.9603 3
created 8 34.9074 7
created 8.48 14.9603 3
created 8.96 39.8942 8
created 9.44 14.9603 3
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-1.78578e-05)
fit chi^2 = 1.75866e-06
found -6.4 (+-0.000146166) 49.8679 (+-0.0897194) 10.0002 (+-0.000594138)
found -2.56 (+-0.000145007) 49.8673 (+-0.0896361) 10 (+-0.000593586)
found -0.640001 (+-0.000145716) 49.8676 (+-0.0896862) 10.0001 (+-0.000593918)
found 4.16 (+-0.000145303) 49.8675 (+-0.0896578) 10.0001 (+-0.000593731)
found -1.6 (+-0.00015333) 44.8808 (+-0.0850681) 9.00008 (+-0.000563337)
found 2.24 (+-0.000153413) 44.8807 (+-0.0850712) 9.00007 (+-0.000563357)
found 3.2 (+-0.000152921) 44.8806 (+-0.0850405) 9.00004 (+-0.000563154)
found -6.88 (+-0.000163852) 39.8945 (+-0.0802745) 8.00017 (+-0.000531592)
found -4.96 (+-0.000163496) 39.8943 (+-0.0802524) 8.00013 (+-0.000531446)
found -4.48 (+-0.000162823) 39.8941 (+-0.0802147) 8.00009 (+-0.000531196)
found 8.96 (+-0.000162692) 39.894 (+-0.0802042) 8.00006 (+-0.000531127)
found -7.36 (+-0.000174964) 34.9076 (+-0.075079) 7.00013 (+-0.000497187)
found -5.92 (+-0.000175137) 34.9077 (+-0.0750887) 7.00015 (+-0.000497251)
found -3.52 (+-0.000173598) 34.9072 (+-0.0750086) 7.00004 (+-0.00049672)
found -1.12 (+-0.000175552) 34.9079 (+-0.0751114) 7.00019 (+-0.000497401)
found 5.12 (+-0.000174273) 34.9074 (+-0.0750428) 7.00008 (+-0.000496947)
found 8 (+-0.000174059) 34.9073 (+-0.075031) 7.00006 (+-0.000496869)
found 4.64 (+-0.000189675) 29.9211 (+-0.0695425) 6.00017 (+-0.000460523)
found -8.8 (+-0.000188696) 29.9207 (+-0.0694962) 6.00009 (+-0.000460217)
found 6.08 (+-0.000187738) 29.9205 (+-0.0694536) 6.00004 (+-0.000459935)
found -8.32 (+-0.000207331) 24.9341 (+-0.0634654) 5.00011 (+-0.000420279)
found -5.44 (+-0.000207907) 24.9343 (+-0.0634884) 5.00015 (+-0.000420432)
found -7.84 (+-0.000207474) 24.9342 (+-0.0634711) 5.00012 (+-0.000420317)
found -9.76 (+-0.000231069) 19.9471 (+-0.0567379) 4.00004 (+-0.000375729)
found -9.28 (+-0.000232037) 19.9474 (+-0.0567727) 4.0001 (+-0.000375959)
found 1.76 (+-0.000231926) 19.9474 (+-0.0567709) 4.00011 (+-0.000375947)
found -0.160003 (+-0.000269085) 14.9608 (+-0.049196) 3.00013 (+-0.000325785)
found 2.72 (+-0.000270395) 14.961 (+-0.049228) 3.00018 (+-0.000325997)
found -3.04 (+-0.000270178) 14.961 (+-0.0492225) 3.00017 (+-0.00032596)
found 0.32 (+-0.000267048) 14.9604 (+-0.0491457) 3.00005 (+-0.000325452)
found 8.48 (+-0.00026982) 14.9609 (+-0.0492132) 3.00015 (+-0.000325899)
found 9.44 (+-0.000266081) 14.9607 (+-0.0491355) 3.00011 (+-0.000325384)
found 7.52 (+-0.000268117) 14.9606 (+-0.0491721) 3.00009 (+-0.000325627)
found 0.799999 (+-0.00032815) 9.97368 (+-0.0401444) 2.00005 (+-0.000265843)
found 5.6 (+-0.000331477) 9.97408 (+-0.0401999) 2.00013 (+-0.000266211)
found 6.56 (+-0.000329352) 9.97383 (+-0.0401647) 2.00008 (+-0.000265978)
found 1.28 (+-0.000328615) 9.97373 (+-0.0401521) 2.00006 (+-0.000265894)
found 7.04 (+-0.000328149) 9.97368 (+-0.0401444) 2.00005 (+-0.000265843)
found -4 (+-0.000474327) 4.98748 (+-0.0284758) 1.00015 (+-0.000188572)
found -2.08 (+-0.000476198) 4.98768 (+-0.0284934) 1.00019 (+-0.000188689)
found 3.68 (+-0.000476198) 4.98768 (+-0.0284934) 1.00019 (+-0.000188689)
#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()