This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 35.9048 9
created -9.1 23.9365 6
created -8.5 15.9577 4
created -7.9 7.97885 2
created -7.3 31.9154 8
created -6.7 3.98942 1
created -6.1 27.926 7
created -5.5 3.98942 1
created -4.9 19.9471 5
created -4.3 7.97885 2
created -3.7 35.9048 9
created -3.1 11.9683 3
created -2.5 15.9577 4
created -1.9 15.9577 4
created -1.3 15.9577 4
created -0.7 27.926 7
created -0.1 11.9683 3
created 0.5 23.9365 6
created 1.1 27.926 7
created 1.7 23.9365 6
created 2.3 39.8942 10
created 2.9 11.9683 3
created 3.5 27.926 7
created 4.1 19.9471 5
created 4.7 3.98942 1
created 5.3 27.926 7
created 5.9 39.8942 10
created 6.5 27.926 7
created 7.1 11.9683 3
created 7.7 11.9683 3
created 8.3 19.9471 5
created 8.9 15.9577 4
created 9.5 11.9683 3
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-2.86803e-05)
fit chi^2 = 2.14895e-06
found 2.3 (+-0.000202985) 39.8939 (+-0.0799949) 10.0001 (+-0.000656478)
found 5.9 (+-0.000203621) 39.8942 (+-0.0800249) 10.0002 (+-0.000656724)
found -9.7 (+-0.000214384) 35.9044 (+-0.0759012) 9.00008 (+-0.000622882)
found -3.7 (+-0.000213431) 35.9044 (+-0.0758676) 9.00006 (+-0.000622607)
found -7.3 (+-0.000225946) 31.9149 (+-0.0715135) 8.00004 (+-0.000586875)
found 6.5 (+-0.000243687) 27.9261 (+-0.0669656) 7.00017 (+-0.000549553)
found -6.1 (+-0.000241316) 27.9255 (+-0.0668877) 7.00002 (+-0.000548913)
found -0.7 (+-0.000242815) 27.9258 (+-0.0669349) 7.00009 (+-0.000549301)
found 1.1 (+-0.000243739) 27.926 (+-0.0669662) 7.00015 (+-0.000549558)
found 3.5 (+-0.000243001) 27.9258 (+-0.0669413) 7.0001 (+-0.000549353)
found 5.3 (+-0.000243036) 27.926 (+-0.0669456) 7.00014 (+-0.000549388)
found -9.1 (+-0.00026365) 23.9367 (+-0.0620107) 6.00017 (+-0.00050889)
found 0.500001 (+-0.000263101) 23.9366 (+-0.0619943) 6.00013 (+-0.000508755)
found 1.7 (+-0.00026436) 23.937 (+-0.062032) 6.00022 (+-0.000509065)
found -4.9 (+-0.000286424) 19.9469 (+-0.0565502) 5.00004 (+-0.000464079)
found 4.1 (+-0.000287739) 19.9471 (+-0.0565829) 5.0001 (+-0.000464347)
found 8.3 (+-0.000287949) 19.9471 (+-0.0565859) 5.00009 (+-0.000464371)
found -8.5 (+-0.000322593) 15.9578 (+-0.0506256) 4.0001 (+-0.000415459)
found 8.9 (+-0.000322774) 15.9578 (+-0.0506286) 4.0001 (+-0.000415483)
found -2.5 (+-0.000322471) 15.9578 (+-0.0506224) 4.00009 (+-0.000415433)
found -1.9 (+-0.000322829) 15.9578 (+-0.0506296) 4.0001 (+-0.000415491)
found -1.3 (+-0.000323642) 15.958 (+-0.0506464) 4.00014 (+-0.000415629)
found -3.1 (+-0.000375266) 11.9687 (+-0.0438859) 3.00017 (+-0.00036015)
found -0.100001 (+-0.00037547) 11.9687 (+-0.0438887) 3.00017 (+-0.000360172)
found 2.9 (+-0.000376558) 11.9689 (+-0.0439065) 3.00022 (+-0.000360319)
found 7.1 (+-0.000374266) 11.9686 (+-0.0438701) 3.00013 (+-0.000360019)
found 7.7 (+-0.00037362) 11.9685 (+-0.0438596) 3.0001 (+-0.000359933)
found 9.5 (+-0.000369576) 11.9684 (+-0.0438078) 3.00009 (+-0.000359509)
found -7.9 (+-0.000461337) 7.97932 (+-0.0358515) 2.00016 (+-0.000294215)
found -4.3 (+-0.000462258) 7.97942 (+-0.0358616) 2.00018 (+-0.000294298)
found -6.7 (+-0.000661072) 3.99013 (+-0.0254004) 1.0002 (+-0.000208448)
found -5.5 (+-0.000658718) 3.98997 (+-0.0253865) 1.00016 (+-0.000208334)
found 4.7 (+-0.000658717) 3.98997 (+-0.0253865) 1.00016 (+-0.000208334)
#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()