This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 27.926 7
created -9.1 3.98942 1
created -8.5 7.97885 2
created -7.9 31.9154 8
created -7.3 3.98942 1
created -6.7 27.926 7
created -6.1 23.9365 6
created -5.5 39.8942 10
created -4.9 23.9365 6
created -4.3 15.9577 4
created -3.7 7.97885 2
created -3.1 23.9365 6
created -2.5 39.8942 10
created -1.9 3.98942 1
created -1.3 15.9577 4
created -0.7 7.97885 2
created -0.1 27.926 7
created 0.5 7.97885 2
created 1.1 19.9471 5
created 1.7 35.9048 9
created 2.3 35.9048 9
created 2.9 31.9154 8
created 3.5 35.9048 9
created 4.1 23.9365 6
created 4.7 35.9048 9
created 5.3 11.9683 3
created 5.9 19.9471 5
created 6.5 11.9683 3
created 7.1 31.9154 8
created 7.7 39.8942 10
created 8.3 27.926 7
created 8.9 15.9577 4
created 9.5 39.8942 10
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.7929e-05)
fit chi^2 = 6.91239e-06
found -5.5 (+-0.000364803) 39.8941 (+-0.143506) 10.0002 (+-0.00117768)
found -2.5 (+-0.000363216) 39.8938 (+-0.143435) 10.0001 (+-0.0011771)
found 7.7 (+-0.000365372) 39.8943 (+-0.143533) 10.0002 (+-0.00117791)
found 9.5 (+-0.000361486) 39.8942 (+-0.143369) 10.0002 (+-0.00117655)
found 1.7 (+-0.000385165) 35.9049 (+-0.13617) 9.00018 (+-0.00111747)
found 2.3 (+-0.000385815) 35.905 (+-0.136198) 9.00022 (+-0.00111771)
found 3.5 (+-0.000385224) 35.9049 (+-0.136172) 9.00018 (+-0.00111749)
found 4.7 (+-0.000383992) 35.9046 (+-0.136119) 9.00012 (+-0.00111706)
found 2.9 (+-0.000409812) 31.9157 (+-0.128433) 8.00023 (+-0.00105398)
found -7.9 (+-0.000405234) 31.9149 (+-0.12826) 8.00004 (+-0.00105256)
found 7.1 (+-0.000408422) 31.9155 (+-0.128379) 8.00017 (+-0.00105354)
found 8.3 (+-0.00043745) 27.9262 (+-0.120116) 7.00018 (+-0.000985729)
found -9.7 (+-0.000434204) 27.9255 (+-0.119998) 7.00001 (+-0.00098476)
found -6.7 (+-0.000434957) 27.9258 (+-0.120033) 7.00009 (+-0.000985053)
found -0.1 (+-0.000434129) 27.9256 (+-0.120004) 7.00005 (+-0.00098481)
found -4.9 (+-0.000473093) 23.9368 (+-0.111224) 6.00018 (+-0.000912756)
found 4.1 (+-0.000474428) 23.937 (+-0.111264) 6.00023 (+-0.000913082)
found -6.1 (+-0.00047413) 23.937 (+-0.111254) 6.00022 (+-0.000913008)
found -3.1 (+-0.000472074) 23.9367 (+-0.111195) 6.00015 (+-0.000912523)
found 1.1 (+-0.000517591) 19.9473 (+-0.101518) 5.00014 (+-0.000833108)
found 5.9 (+-0.000515909) 19.9471 (+-0.101474) 5.00008 (+-0.000832744)
found -4.3 (+-0.000578571) 15.9578 (+-0.0907971) 4.0001 (+-0.000745125)
found 8.9 (+-0.000583012) 15.9583 (+-0.090888) 4.00022 (+-0.000745871)
found -1.3 (+-0.000575017) 15.9576 (+-0.0907278) 4.00004 (+-0.000744556)
found 5.3 (+-0.000673748) 11.9688 (+-0.0787204) 3.00018 (+-0.000646018)
found 6.5 (+-0.000673287) 11.9687 (+-0.0787128) 3.00017 (+-0.000645955)
found 0.499998 (+-0.000827706) 7.97932 (+-0.0643024) 2.00016 (+-0.000527697)
found -8.49999 (+-0.000822654) 7.97917 (+-0.0642525) 2.00012 (+-0.000527287)
found -3.7 (+-0.000825931) 7.97922 (+-0.064283) 2.00013 (+-0.000527537)
found -0.699997 (+-0.000826706) 7.97927 (+-0.0642917) 2.00014 (+-0.000527609)
found -1.90001 (+-0.00118306) 3.99008 (+-0.0455417) 1.00018 (+-0.000373737)
found -7.3 (+-0.00118563) 3.99013 (+-0.0455556) 1.0002 (+-0.000373852)
found -9.10001 (+-0.00117478) 3.98982 (+-0.0454943) 1.00012 (+-0.000373348)
#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()