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 39.8942 8
created -8.8 34.9074 7
created -8.32 29.9207 6
created -7.84 29.9207 6
created -7.36 29.9207 6
created -6.88 24.9339 5
created -6.4 49.8678 10
created -5.92 9.97356 2
created -5.44 24.9339 5
created -4.96 9.97356 2
created -4.48 14.9603 3
created -4 29.9207 6
created -3.52 34.9074 7
created -3.04 44.881 9
created -2.56 49.8678 10
created -2.08 39.8942 8
created -1.6 24.9339 5
created -1.12 49.8678 10
created -0.64 4.98678 1
created -0.16 44.881 9
created 0.32 24.9339 5
created 0.8 19.9471 4
created 1.28 9.97356 2
created 1.76 34.9074 7
created 2.24 9.97356 2
created 2.72 39.8942 8
created 3.2 19.9471 4
created 3.68 19.9471 4
created 4.16 29.9207 6
created 4.64 24.9339 5
created 5.12 39.8942 8
created 5.6 19.9471 4
created 6.08 24.9339 5
created 6.56 24.9339 5
created 7.04 44.881 9
created 7.52 19.9471 4
created 8 39.8942 8
created 8.48 44.881 9
created 8.96 24.9339 5
created 9.44 34.9074 7
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.5648e-05)
fit chi^2 = 3.95716e-06
found -6.4 (+-0.000218122) 49.8675 (+-0.134499) 10.0001 (+-0.000890676)
found -2.56 (+-0.00021946) 49.868 (+-0.134598) 10.0002 (+-0.00089133)
found -1.12 (+-0.000217831) 49.8674 (+-0.13448) 10.0001 (+-0.00089055)
found -3.04 (+-0.000231505) 44.8813 (+-0.127703) 9.00017 (+-0.000845672)
found -0.159999 (+-0.000229732) 44.8807 (+-0.127586) 9.00006 (+-0.0008449)
found 7.04 (+-0.000230475) 44.8809 (+-0.127632) 9.00009 (+-0.000845204)
found 8.48 (+-0.000231024) 44.8811 (+-0.12767) 9.00013 (+-0.000845452)
found -9.28 (+-0.00024494) 39.8942 (+-0.120362) 8.00011 (+-0.000797061)
found -2.08 (+-0.00024548) 39.8945 (+-0.120396) 8.00015 (+-0.000797283)
found 2.72 (+-0.000243993) 39.894 (+-0.120306) 8.00006 (+-0.000796691)
found 5.12 (+-0.00024464) 39.8941 (+-0.120344) 8.00009 (+-0.000796939)
found 8 (+-0.000245188) 39.8944 (+-0.120378) 8.00013 (+-0.000797165)
found -8.8 (+-0.00026263) 34.9077 (+-0.11263) 7.00014 (+-0.000745859)
found -3.52 (+-0.000262765) 34.9077 (+-0.112638) 7.00015 (+-0.000745909)
found 1.76 (+-0.000260514) 34.9072 (+-0.11252) 7.00004 (+-0.000745126)
found 9.44 (+-0.000259749) 34.9076 (+-0.112496) 7.00012 (+-0.000744966)
found -8.32 (+-0.000283871) 29.9209 (+-0.104285) 6.00013 (+-0.000690592)
found -7.84 (+-0.000283688) 29.9209 (+-0.104276) 6.00012 (+-0.000690535)
found -7.36 (+-0.000283485) 29.9208 (+-0.104267) 6.00011 (+-0.000690472)
found -4 (+-0.000283163) 29.9208 (+-0.104252) 6.0001 (+-0.000690379)
found 4.16 (+-0.00028305) 29.9207 (+-0.104246) 6.00009 (+-0.000690339)
found -6.88 (+-0.000311998) 24.9344 (+-0.0952404) 5.00016 (+-0.000630699)
found -1.6 (+-0.00031241) 24.9345 (+-0.095257) 5.00018 (+-0.000630809)
found 0.319999 (+-0.000311318) 24.9342 (+-0.0952134) 5.00013 (+-0.000630521)
found 4.64 (+-0.000311651) 24.9343 (+-0.095226) 5.00014 (+-0.000630604)
found 8.96 (+-0.000312046) 24.9344 (+-0.095242) 5.00016 (+-0.00063071)
found -5.44 (+-0.000308806) 24.9338 (+-0.0951165) 5.00004 (+-0.000629879)
found 6.08 (+-0.000310494) 24.934 (+-0.0951801) 5.00009 (+-0.0006303)
found 6.56 (+-0.000311591) 24.9343 (+-0.095224) 5.00014 (+-0.00063059)
found 3.2 (+-0.000348556) 19.9475 (+-0.0851771) 4.00012 (+-0.000564058)
found 5.6 (+-0.000348887) 19.9475 (+-0.0851876) 4.00013 (+-0.000564128)
found 7.52 (+-0.000349894) 19.9477 (+-0.0852206) 4.00017 (+-0.000564346)
found -9.76 (+-0.000347712) 19.9473 (+-0.0851446) 4.00008 (+-0.000563843)
found 0.799999 (+-0.000346906) 19.9472 (+-0.0851251) 4.00007 (+-0.000563714)
found 3.68 (+-0.000348062) 19.9474 (+-0.0851608) 4.0001 (+-0.00056395)
found -4.48 (+-0.000401856) 14.9605 (+-0.0737513) 3.00008 (+-0.000488395)
found -5.92 (+-0.000497873) 9.97419 (+-0.0603132) 2.00015 (+-0.000399405)
found -4.96 (+-0.000494405) 9.97383 (+-0.0602534) 2.00008 (+-0.000399009)
found 1.28 (+-0.000496098) 9.97398 (+-0.0602821) 2.00011 (+-0.000399199)
found 2.24 (+-0.000498121) 9.97419 (+-0.0603168) 2.00015 (+-0.000399428)
found -0.640001 (+-0.000714311) 4.98768 (+-0.042741) 1.00019 (+-0.000283039)
#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()