This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 23.9365 6
created -9.1 31.9154 8
created -8.5 3.98942 1
created -7.9 39.8942 10
created -7.3 11.9683 3
created -6.7 39.8942 10
created -6.1 11.9683 3
created -5.5 15.9577 4
created -4.9 35.9048 9
created -4.3 23.9365 6
created -3.7 23.9365 6
created -3.1 35.9048 9
created -2.5 35.9048 9
created -1.9 23.9365 6
created -1.3 27.926 7
created -0.7 19.9471 5
created -0.1 31.9154 8
created 0.5 7.97885 2
created 1.1 35.9048 9
created 1.7 7.97885 2
created 2.3 11.9683 3
created 2.9 19.9471 5
created 3.5 11.9683 3
created 4.1 23.9365 6
created 4.7 3.98942 1
created 5.3 7.97885 2
created 5.9 23.9365 6
created 6.5 27.926 7
created 7.1 11.9683 3
created 7.7 27.926 7
created 8.3 7.97885 2
created 8.9 35.9048 9
created 9.5 31.9154 8
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.36708e-05)
fit chi^2 = 5.55949e-06
found -7.9 (+-0.000325074) 39.8937 (+-0.128604) 10 (+-0.00105538)
found -6.7 (+-0.000325821) 39.8938 (+-0.128636) 10.0001 (+-0.00105565)
found -4.9 (+-0.000344653) 35.9046 (+-0.122085) 9.00013 (+-0.00100189)
found -3.1 (+-0.000345637) 35.9049 (+-0.122128) 9.00019 (+-0.00100224)
found -2.5 (+-0.000345637) 35.9049 (+-0.122128) 9.00019 (+-0.00100224)
found 1.1 (+-0.000342945) 35.9043 (+-0.122014) 9.00005 (+-0.00100131)
found 8.9 (+-0.000344385) 35.9046 (+-0.122076) 9.00013 (+-0.00100181)
found 9.5 (+-0.000363754) 31.9156 (+-0.115053) 8.00022 (+-0.000944183)
found -9.1 (+-0.00036461) 31.9151 (+-0.11507) 8.00009 (+-0.000944322)
found -0.100001 (+-0.00036491) 31.9151 (+-0.115079) 8.00009 (+-0.000944397)
found -1.3 (+-0.000391773) 27.926 (+-0.107702) 7.00014 (+-0.000883855)
found 6.5 (+-0.000391117) 27.9259 (+-0.10768) 7.00012 (+-0.000883676)
found 7.7 (+-0.000389767) 27.9257 (+-0.107635) 7.00006 (+-0.000883307)
found -4.3 (+-0.000424719) 23.9369 (+-0.0997597) 6.00019 (+-0.000818677)
found -1.9 (+-0.000424993) 23.9369 (+-0.099768) 6.00021 (+-0.000818745)
found -9.7 (+-0.000423486) 23.9365 (+-0.0997151) 6.0001 (+-0.000818311)
found -3.7 (+-0.000424719) 23.9369 (+-0.0997597) 6.00019 (+-0.000818677)
found 4.1 (+-0.000420675) 23.9363 (+-0.0996428) 6.00005 (+-0.000817718)
found 5.9 (+-0.000422679) 23.9365 (+-0.0997002) 6.00012 (+-0.000818188)
found -0.7 (+-0.000466077) 19.9475 (+-0.0910887) 5.00019 (+-0.000747519)
found 2.9 (+-0.000462676) 19.947 (+-0.0910034) 5.00008 (+-0.000746819)
found -5.5 (+-0.000520648) 15.958 (+-0.0814647) 4.00016 (+-0.000668539)
found -7.3 (+-0.000606931) 11.9691 (+-0.0706417) 3.00026 (+-0.000579721)
found -6.1 (+-0.000603974) 11.9688 (+-0.0705943) 3.00018 (+-0.000579332)
found 3.5 (+-0.000602871) 11.9686 (+-0.0705755) 3.00014 (+-0.000579177)
found 7.1 (+-0.000604418) 11.9688 (+-0.0706003) 3.00018 (+-0.00057938)
found 2.3 (+-0.000600019) 11.9684 (+-0.0705319) 3.00009 (+-0.000578819)
found 0.500001 (+-0.000745645) 7.97958 (+-0.0577049) 2.00022 (+-0.000473554)
found 8.3 (+-0.000745006) 7.97953 (+-0.0576977) 2.00021 (+-0.000473495)
found 1.69999 (+-0.000741545) 7.97932 (+-0.0576606) 2.00016 (+-0.000473191)
found 5.30001 (+-0.000736467) 7.97906 (+-0.0576077) 2.00009 (+-0.000472757)
found -8.5 (+-0.00106643) 3.99028 (+-0.040874) 1.00023 (+-0.000335432)
found 4.69999 (+-0.00105234) 3.98977 (+-0.0407926) 1.0001 (+-0.000334764)
#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()