This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 26.5962 4
created -9.46 39.8942 6
created -9.1 59.8413 9
created -8.74 53.1923 8
created -8.38 59.8413 9
created -8.02 19.9471 3
created -7.66 33.2452 5
created -7.3 33.2452 5
created -6.94 13.2981 2
created -6.58 26.5962 4
created -6.22 6.64904 1
created -5.86 26.5962 4
created -5.5 19.9471 3
created -5.14 39.8942 6
created -4.78 53.1923 8
created -4.42 19.9471 3
created -4.06 26.5962 4
created -3.7 53.1923 8
created -3.34 46.5433 7
created -2.98 46.5433 7
created -2.62 19.9471 3
created -2.26 53.1923 8
created -1.9 13.2981 2
created -1.54 13.2981 2
created -1.18 66.4904 10
created -0.82 13.2981 2
created -0.46 13.2981 2
created -0.1 46.5433 7
created 0.26 59.8413 9
created 0.62 46.5433 7
created 0.98 66.4904 10
created 1.34 26.5962 4
created 1.7 13.2981 2
created 2.06 33.2452 5
created 2.42 13.2981 2
created 2.78 53.1923 8
created 3.14 53.1923 8
created 3.5 66.4904 10
created 3.86 26.5962 4
created 4.22 6.64904 1
created 4.58 6.64904 1
created 4.94 66.4904 10
created 5.3 26.5962 4
created 5.66 39.8942 6
created 6.02 19.9471 3
created 6.38 53.1923 8
created 6.74 66.4904 10
created 7.1 66.4904 10
created 7.46 6.64904 1
created 7.82 39.8942 6
created 8.18 46.5433 7
created 8.54 26.5962 4
created 8.9 26.5962 4
created 9.26 66.4904 10
created 9.62 13.2981 2
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-7.59611e-06)
fit chi^2 = 7.90593e-07
found -1.18 (+-7.18224e-05) 66.4901 (+-0.0789024) 10 (+-0.000398)
found 0.98 (+-7.22047e-05) 66.4904 (+-0.0789511) 10.0001 (+-0.000398246)
found 3.5 (+-7.22398e-05) 66.4904 (+-0.0789559) 10.0001 (+-0.00039827)
found 4.94 (+-7.18527e-05) 66.4901 (+-0.078907) 10 (+-0.000398023)
found 6.74 (+-7.24688e-05) 66.4907 (+-0.0789866) 10.0001 (+-0.000398425)
found 7.1 (+-7.2078e-05) 66.4904 (+-0.0789376) 10.0001 (+-0.000398178)
found 9.26 (+-7.19484e-05) 66.4902 (+-0.0789182) 10 (+-0.00039808)
found -8.38 (+-7.6139e-05) 59.8414 (+-0.0749035) 9.00007 (+-0.000377829)
found -9.1 (+-7.63025e-05) 59.8415 (+-0.0749226) 9.00009 (+-0.000377926)
found 0.26 (+-7.63063e-05) 59.8415 (+-0.074923) 9.00009 (+-0.000377928)
found -8.74 (+-8.11727e-05) 53.1927 (+-0.0706645) 8.00012 (+-0.000356447)
found 3.14 (+-8.11699e-05) 53.1927 (+-0.0706642) 8.00012 (+-0.000356445)
found -4.78 (+-8.07324e-05) 53.1923 (+-0.0706167) 8.00006 (+-0.000356205)
found -3.7 (+-8.08486e-05) 53.1924 (+-0.070629) 8.00007 (+-0.000356268)
found -2.26 (+-8.04674e-05) 53.1921 (+-0.0705891) 8.00003 (+-0.000356066)
found 2.78 (+-8.07355e-05) 53.1924 (+-0.070618) 8.00007 (+-0.000356212)
found 6.38 (+-8.08975e-05) 53.1925 (+-0.0706352) 8.00009 (+-0.000356299)
found -3.34 (+-8.67406e-05) 46.5436 (+-0.066097) 7.0001 (+-0.000333407)
found 0.62 (+-8.69198e-05) 46.5438 (+-0.0661147) 7.00013 (+-0.000333497)
found -2.98 (+-8.64355e-05) 46.5434 (+-0.0660681) 7.00007 (+-0.000333262)
found -0.0999994 (+-8.64303e-05) 46.5434 (+-0.0660687) 7.00007 (+-0.000333265)
found 8.18 (+-8.64613e-05) 46.5434 (+-0.0660701) 7.00007 (+-0.000333272)
found -9.46 (+-9.36604e-05) 39.8945 (+-0.0611919) 6.00009 (+-0.000308665)
found -5.14 (+-9.35199e-05) 39.8944 (+-0.0611804) 6.00007 (+-0.000308607)
found 5.66 (+-9.32628e-05) 39.8943 (+-0.0611588) 6.00005 (+-0.000308498)
found 7.82 (+-9.32001e-05) 39.8943 (+-0.061156) 6.00005 (+-0.000308484)
found -7.66 (+-0.000102381) 33.2453 (+-0.0558449) 5.00005 (+-0.000281693)
found -7.3 (+-0.000102251) 33.2453 (+-0.0558364) 5.00005 (+-0.000281651)
found 2.06 (+-0.00010193) 33.2451 (+-0.0558147) 5.00003 (+-0.000281541)
found 1.34 (+-0.000114899) 26.5965 (+-0.0499751) 4.00008 (+-0.000252085)
found 3.86 (+-0.000114676) 26.5965 (+-0.049964) 4.00007 (+-0.000252029)
found 5.3 (+-0.000115395) 26.5967 (+-0.0500022) 4.00011 (+-0.000252222)
found 8.54 (+-0.000114972) 26.5965 (+-0.0499776) 4.00007 (+-0.000252098)
found 8.9 (+-0.000115188) 26.5966 (+-0.0499906) 4.00009 (+-0.000252163)
found -9.82 (+-0.000114598) 26.5962 (+-0.0499529) 4.00004 (+-0.000251973)
found -6.58 (+-0.000113895) 26.5961 (+-0.0499191) 4.00002 (+-0.000251802)
found -5.86 (+-0.000114051) 26.5961 (+-0.0499275) 4.00003 (+-0.000251845)
found -4.06 (+-0.000114922) 26.5965 (+-0.0499752) 4.00007 (+-0.000252086)
found -8.02 (+-0.000133455) 19.9476 (+-0.0433125) 3.00009 (+-0.000218478)
found -5.5 (+-0.000133013) 19.9474 (+-0.0432928) 3.00007 (+-0.000218378)
found -4.42 (+-0.000133222) 19.9475 (+-0.0433023) 3.00008 (+-0.000218426)
found -2.62 (+-0.000133597) 19.9476 (+-0.0433186) 3.0001 (+-0.000218508)
found 6.02 (+-0.000133486) 19.9476 (+-0.0433137) 3.00009 (+-0.000218484)
found -0.820002 (+-0.000163606) 13.2985 (+-0.035371) 2.00008 (+-0.000178419)
found 9.62 (+-0.000161981) 13.2985 (+-0.0353341) 2.00008 (+-0.000178233)
found -1.9 (+-0.000163362) 13.2984 (+-0.0353631) 2.00007 (+-0.000178379)
found -6.94 (+-0.000163427) 13.2984 (+-0.0353637) 2.00006 (+-0.000178382)
found -1.54 (+-0.000163606) 13.2985 (+-0.035371) 2.00008 (+-0.000178419)
found -0.459999 (+-0.000163224) 13.2984 (+-0.0353587) 2.00006 (+-0.000178357)
found 1.7 (+-0.000163427) 13.2984 (+-0.0353637) 2.00006 (+-0.000178382)
found 2.42 (+-0.000164092) 13.2986 (+-0.035384) 2.00009 (+-0.000178485)
found 7.46 (+-0.000235023) 6.64971 (+-0.0250679) 1.00011 (+-0.000126448)
found -6.22 (+-0.000232728) 6.64935 (+-0.0250305) 1.00005 (+-0.000126259)
found 4.22 (+-0.000231029) 6.64922 (+-0.0250055) 1.00003 (+-0.000126133)
found 4.58001 (+-0.000232614) 6.64949 (+-0.0250322) 1.00008 (+-0.000126268)
#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()