This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 39.8942 10
created -9.1 7.97885 2
created -8.5 35.9048 9
created -7.9 15.9577 4
created -7.3 27.926 7
created -6.7 39.8942 10
created -6.1 3.98942 1
created -5.5 19.9471 5
created -4.9 11.9683 3
created -4.3 35.9048 9
created -3.7 15.9577 4
created -3.1 39.8942 10
created -2.5 23.9365 6
created -1.9 19.9471 5
created -1.3 35.9048 9
created -0.7 7.97885 2
created -0.1 11.9683 3
created 0.5 39.8942 10
created 1.1 27.926 7
created 1.7 7.97885 2
created 2.3 39.8942 10
created 2.9 27.926 7
created 3.5 3.98942 1
created 4.1 19.9471 5
created 4.7 31.9154 8
created 5.3 15.9577 4
created 5.9 19.9471 5
created 6.5 35.9048 9
created 7.1 39.8942 10
created 7.7 31.9154 8
created 8.3 27.926 7
created 8.9 23.9365 6
created 9.5 23.9365 6
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.61938e-05)
fit chi^2 = 4.20711e-06
found -9.7 (+-0.00028361) 39.8936 (+-0.111901) 10 (+-0.000918315)
found -6.7 (+-0.000283512) 39.8939 (+-0.111908) 10.0001 (+-0.000918371)
found -3.1 (+-0.00028424) 39.894 (+-0.111939) 10.0001 (+-0.000918625)
found 0.500001 (+-0.000284167) 39.894 (+-0.111936) 10.0001 (+-0.000918602)
found 2.3 (+-0.000283891) 39.8939 (+-0.111924) 10.0001 (+-0.000918502)
found 7.1 (+-0.000285312) 39.8943 (+-0.111991) 10.0002 (+-0.00091905)
found -8.5 (+-0.000298875) 35.9044 (+-0.106164) 9.00008 (+-0.000871232)
found -4.3 (+-0.000299177) 35.9045 (+-0.106176) 9.00009 (+-0.000871332)
found -1.3 (+-0.000299084) 35.9045 (+-0.106173) 9.00009 (+-0.000871306)
found 6.5 (+-0.000300617) 35.9049 (+-0.106239) 9.00019 (+-0.000871845)
found 7.7 (+-0.000319533) 31.9157 (+-0.100189) 8.00022 (+-0.000822203)
found 4.7 (+-0.000318048) 31.9152 (+-0.100131) 8.00011 (+-0.000821723)
found 1.1 (+-0.000340583) 27.9261 (+-0.093686) 7.00016 (+-0.000768833)
found 2.9 (+-0.000340055) 27.926 (+-0.0936701) 7.00014 (+-0.000768702)
found -7.3 (+-0.000341276) 27.9262 (+-0.0937083) 7.00018 (+-0.000769016)
found 8.3 (+-0.000341436) 27.9262 (+-0.0937129) 7.00018 (+-0.000769054)
found -2.5 (+-0.000369386) 23.9369 (+-0.0867799) 6.00019 (+-0.000712158)
found 8.9 (+-0.00036905) 23.9368 (+-0.086769) 6.00017 (+-0.000712069)
found 9.5 (+-0.000365211) 23.9367 (+-0.0866715) 6.00015 (+-0.000711269)
found -5.5 (+-0.000401269) 19.9469 (+-0.0791369) 5.00005 (+-0.000649436)
found -1.9 (+-0.000405399) 19.9475 (+-0.079238) 5.00019 (+-0.000650265)
found 4.1 (+-0.000402852) 19.9472 (+-0.0791773) 5.00012 (+-0.000649767)
found 5.9 (+-0.000404732) 19.9474 (+-0.0792214) 5.00017 (+-0.000650129)
found -7.9 (+-0.000454574) 15.9582 (+-0.0709004) 4.00021 (+-0.000581843)
found -3.7 (+-0.00045543) 15.9584 (+-0.0709188) 4.00025 (+-0.000581994)
found 5.3 (+-0.000453574) 15.9581 (+-0.0708794) 4.00017 (+-0.000581671)
found -4.9 (+-0.000525624) 11.9688 (+-0.0614136) 3.00018 (+-0.00050399)
found -0.0999944 (+-0.000523934) 11.9687 (+-0.061389) 3.00016 (+-0.000503788)
found -9.1 (+-0.000649627) 7.97968 (+-0.0502093) 2.00025 (+-0.000412042)
found 1.7 (+-0.000648558) 7.97958 (+-0.0501972) 2.00022 (+-0.000411943)
found -0.700006 (+-0.000645077) 7.97932 (+-0.0501595) 2.00016 (+-0.000411633)
found -6.10001 (+-0.000924375) 3.99013 (+-0.0355373) 1.0002 (+-0.000291636)
found 3.5 (+-0.000921675) 3.98997 (+-0.0355207) 1.00016 (+-0.0002915)
#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()