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 35.9048 9
created -8.5 11.9683 3
created -7.9 11.9683 3
created -7.3 11.9683 3
created -6.7 39.8942 10
created -6.1 39.8942 10
created -5.5 15.9577 4
created -4.9 7.97885 2
created -4.3 3.98942 1
created -3.7 39.8942 10
created -3.1 7.97885 2
created -2.5 19.9471 5
created -1.9 27.926 7
created -1.3 39.8942 10
created -0.7 15.9577 4
created -0.1 31.9154 8
created 0.5 31.9154 8
created 1.1 19.9471 5
created 1.7 39.8942 10
created 2.3 35.9048 9
created 2.9 23.9365 6
created 3.5 3.98942 1
created 4.1 3.98942 1
created 4.7 19.9471 5
created 5.3 3.98942 1
created 5.9 39.8942 10
created 6.5 15.9577 4
created 7.1 7.97885 2
created 7.7 3.98942 1
created 8.3 31.9154 8
created 8.9 3.98942 1
created 9.5 3.98942 1
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-1.73908e-05)
fit chi^2 = 8.14457e-07
found -6.7 (+-0.0001252) 39.8941 (+-0.0492591) 10.0002 (+-0.000404244)
found -6.1 (+-0.000125299) 39.8942 (+-0.0492636) 10.0002 (+-0.000404281)
found -3.7 (+-0.000124303) 39.8936 (+-0.0492178) 10 (+-0.000403905)
found -1.3 (+-0.000125129) 39.894 (+-0.0492551) 10.0001 (+-0.000404212)
found 1.7 (+-0.000125331) 39.8942 (+-0.0492649) 10.0002 (+-0.000404292)
found 5.9 (+-0.00012452) 39.8937 (+-0.0492276) 10.0001 (+-0.000403986)
found -9.1 (+-0.000131881) 35.9046 (+-0.046727) 9.00013 (+-0.000383465)
found 2.3 (+-0.00013235) 35.9049 (+-0.0467473) 9.00021 (+-0.000383632)
found -0.099999 (+-0.000140183) 31.9154 (+-0.0440662) 8.00015 (+-0.000361629)
found 0.499999 (+-0.000140286) 31.9154 (+-0.0440701) 8.00017 (+-0.000361661)
found 8.3 (+-0.000138898) 31.9149 (+-0.044019) 8.00002 (+-0.000361242)
found -9.7 (+-0.000150042) 27.9259 (+-0.0412232) 7.00012 (+-0.000338297)
found -1.9 (+-0.000150274) 27.9262 (+-0.0412345) 7.00019 (+-0.000338391)
found 2.9 (+-0.000161695) 23.9366 (+-0.038159) 6.00013 (+-0.000313152)
found -2.5 (+-0.000177455) 19.9472 (+-0.0348412) 5.00012 (+-0.000285924)
found 1.1 (+-0.000178702) 19.9477 (+-0.0348725) 5.00023 (+-0.000286181)
found 4.7 (+-0.000176024) 19.9468 (+-0.0348071) 5.00003 (+-0.000285645)
found -5.5 (+-0.000199115) 15.958 (+-0.0311779) 4.00016 (+-0.000255861)
found -0.700001 (+-0.000200259) 15.9583 (+-0.0312008) 4.00023 (+-0.000256049)
found 6.5 (+-0.000199115) 15.958 (+-0.0311779) 4.00016 (+-0.000255861)
found -8.5 (+-0.000230738) 11.9687 (+-0.0270132) 3.00016 (+-0.000221684)
found -7.9 (+-0.00022949) 11.9684 (+-0.0269933) 3.00008 (+-0.00022152)
found -7.29999 (+-0.000230884) 11.9687 (+-0.0270157) 3.00017 (+-0.000221704)
found -3.10001 (+-0.000284786) 7.97947 (+-0.02208) 2.0002 (+-0.000181199)
found -4.9 (+-0.000281256) 7.97896 (+-0.0220424) 2.00007 (+-0.000180891)
found 7.1 (+-0.000281256) 7.97896 (+-0.0220424) 2.00007 (+-0.000180891)
found 8.89998 (+-0.00040236) 3.98982 (+-0.0156122) 1.00012 (+-0.000128121)
found 3.49999 (+-0.000401478) 3.98971 (+-0.0156068) 1.00009 (+-0.000128077)
found 5.30001 (+-0.000406715) 3.99013 (+-0.015636) 1.0002 (+-0.000128317)
found -4.29998 (+-0.000404421) 3.98997 (+-0.0156235) 1.00016 (+-0.000128214)
found 7.70001 (+-0.000403675) 3.98987 (+-0.0156188) 1.00013 (+-0.000128176)
found 4.10001 (+-0.000400958) 3.98966 (+-0.0156037) 1.00008 (+-0.000128051)
found 9.5 (+-0.000393605) 3.98945 (+-0.0155684) 1.00003 (+-0.000127762)
#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()