This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 19.9471 5
created -9.1 7.97885 2
created -8.5 27.926 7
created -7.9 3.98942 1
created -7.3 7.97885 2
created -6.7 11.9683 3
created -6.1 23.9365 6
created -5.5 27.926 7
created -4.9 3.98942 1
created -4.3 31.9154 8
created -3.7 27.926 7
created -3.1 31.9154 8
created -2.5 35.9048 9
created -1.9 15.9577 4
created -1.3 7.97885 2
created -0.7 7.97885 2
created -0.1 11.9683 3
created 0.5 19.9471 5
created 1.1 27.926 7
created 1.7 15.9577 4
created 2.3 19.9471 5
created 2.9 39.8942 10
created 3.5 11.9683 3
created 4.1 39.8942 10
created 4.7 27.926 7
created 5.3 27.926 7
created 5.9 19.9471 5
created 6.5 27.926 7
created 7.1 19.9471 5
created 7.7 31.9154 8
created 8.3 23.9365 6
created 8.9 35.9048 9
created 9.5 15.9577 4
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.15875e-05)
fit chi^2 = 2.81377e-06
found 2.9 (+-0.000232134) 39.8939 (+-0.0915298) 10.0001 (+-0.000751138)
found 4.1 (+-0.000232395) 39.894 (+-0.0915424) 10.0001 (+-0.000751242)
found -2.5 (+-0.000245453) 35.9047 (+-0.0868655) 9.00015 (+-0.000712861)
found 8.9 (+-0.000245193) 35.9046 (+-0.086854) 9.00013 (+-0.000712766)
found -4.3 (+-0.000259541) 31.9152 (+-0.0818693) 8.0001 (+-0.000671859)
found -3.1 (+-0.000261199) 31.9156 (+-0.081931) 8.00021 (+-0.000672366)
found 7.7 (+-0.000260462) 31.9153 (+-0.0819018) 8.00014 (+-0.000672127)
found 4.7 (+-0.000279677) 27.9263 (+-0.0766553) 7.00022 (+-0.000629071)
found -8.5 (+-0.000276556) 27.9256 (+-0.0765511) 7.00004 (+-0.000628216)
found -5.5 (+-0.000277508) 27.9258 (+-0.076583) 7.00009 (+-0.000628477)
found -3.7 (+-0.000279556) 27.9262 (+-0.0766508) 7.00021 (+-0.000629034)
found 1.1 (+-0.000278312) 27.9259 (+-0.0766076) 7.00012 (+-0.00062868)
found 5.3 (+-0.000278885) 27.926 (+-0.0766273) 7.00016 (+-0.000628842)
found 6.5 (+-0.000278527) 27.9259 (+-0.0766149) 7.00013 (+-0.000628739)
found -6.1 (+-0.000301061) 23.9366 (+-0.0709386) 6.00013 (+-0.000582157)
found 8.3 (+-0.000302527) 23.937 (+-0.0709825) 6.00022 (+-0.000582517)
found -9.7 (+-0.000328589) 19.9468 (+-0.064723) 5.00003 (+-0.000531148)
found 0.500002 (+-0.000330258) 19.9472 (+-0.0647693) 5.00013 (+-0.000531529)
found 2.3 (+-0.000331171) 19.9475 (+-0.0647927) 5.00018 (+-0.000531721)
found 5.9 (+-0.000331369) 19.9475 (+-0.064797) 5.00018 (+-0.000531756)
found 7.1 (+-0.000331577) 19.9475 (+-0.0648024) 5.00019 (+-0.0005318)
found -1.9 (+-0.000369884) 15.958 (+-0.0579459) 4.00014 (+-0.000475532)
found 1.7 (+-0.000370687) 15.958 (+-0.0579606) 4.00016 (+-0.000475653)
found 9.5 (+-0.000367166) 15.958 (+-0.0579034) 4.00017 (+-0.000475184)
found 3.5 (+-0.000431783) 11.9691 (+-0.050256) 3.00026 (+-0.000412425)
found -6.7 (+-0.000427255) 11.9685 (+-0.0501841) 3.0001 (+-0.000411835)
found -0.0999978 (+-0.000426866) 11.9684 (+-0.0501779) 3.00009 (+-0.000411784)
found -9.1 (+-0.000528088) 7.97931 (+-0.0410258) 2.00016 (+-0.000336678)
found -1.3 (+-0.000524087) 7.979 (+-0.0409831) 2.00008 (+-0.000336327)
found -7.3 (+-0.000522037) 7.9789 (+-0.0409625) 2.00005 (+-0.000336159)
found -0.699999 (+-0.000523345) 7.97895 (+-0.0409752) 2.00007 (+-0.000336263)
found -4.9 (+-0.00075645) 3.99013 (+-0.0290651) 1.0002 (+-0.000238522)
found -7.90001 (+-0.000749526) 3.98982 (+-0.0290259) 1.00012 (+-0.000238201)
#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;
}
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()