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 3.98942 1
created -8.5 3.98942 1
created -7.9 3.98942 1
created -7.3 23.9365 6
created -6.7 23.9365 6
created -6.1 31.9154 8
created -5.5 23.9365 6
created -4.9 11.9683 3
created -4.3 39.8942 10
created -3.7 11.9683 3
created -3.1 35.9048 9
created -2.5 35.9048 9
created -1.9 11.9683 3
created -1.3 27.926 7
created -0.7 3.98942 1
created -0.1 3.98942 1
created 0.5 7.97885 2
created 1.1 27.926 7
created 1.7 39.8942 10
created 2.3 3.98942 1
created 2.9 39.8942 10
created 3.5 27.926 7
created 4.1 7.97885 2
created 4.7 15.9577 4
created 5.3 7.97885 2
created 5.9 23.9365 6
created 6.5 27.926 7
created 7.1 27.926 7
created 7.7 7.97885 2
created 8.3 35.9048 9
created 8.9 23.9365 6
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.49755e-05)
fit chi^2 = 5.57249e-06
found -9.7 (+-0.000325969) 39.8935 (+-0.128767) 10 (+-0.00105673)
found -4.3 (+-0.000326202) 39.8938 (+-0.128786) 10.0001 (+-0.00105688)
found 1.7 (+-0.000326291) 39.8939 (+-0.128793) 10.0001 (+-0.00105694)
found 2.9 (+-0.000326291) 39.8939 (+-0.128793) 10.0001 (+-0.00105694)
found -3.1 (+-0.000345298) 35.9048 (+-0.12224) 9.00015 (+-0.00100316)
found -2.5 (+-0.000345298) 35.9048 (+-0.12224) 9.00015 (+-0.00100316)
found 8.3 (+-0.000344423) 35.9045 (+-0.122202) 9.0001 (+-0.00100285)
found -6.1 (+-0.000366779) 31.9154 (+-0.115268) 8.00015 (+-0.000945945)
found 9.5 (+-0.000363608) 31.9155 (+-0.115164) 8.00018 (+-0.000945094)
found 3.5 (+-0.000391973) 27.9261 (+-0.107822) 7.00015 (+-0.00088484)
found -1.3 (+-0.000389622) 27.9256 (+-0.107743) 7.00005 (+-0.000884189)
found 1.1 (+-0.000391973) 27.9261 (+-0.107822) 7.00015 (+-0.00088484)
found 6.5 (+-0.000392736) 27.9261 (+-0.107845) 7.00017 (+-0.000885031)
found 7.1 (+-0.000391372) 27.9259 (+-0.1078) 7.00012 (+-0.000884662)
found 8.9 (+-0.00042574) 23.937 (+-0.0998922) 6.00022 (+-0.000819764)
found -7.3 (+-0.000422207) 23.9365 (+-0.09979) 6.00009 (+-0.000818925)
found -6.7 (+-0.000424985) 23.9368 (+-0.0998691) 6.00018 (+-0.000819574)
found -5.5 (+-0.000423923) 23.9367 (+-0.0998382) 6.00014 (+-0.000819321)
found 5.9 (+-0.000423172) 23.9366 (+-0.0998166) 6.00012 (+-0.000819143)
found 4.7 (+-0.000517277) 15.9576 (+-0.0814793) 4.00005 (+-0.000668659)
found -4.9 (+-0.000605877) 11.9689 (+-0.0706955) 3.00021 (+-0.000580161)
found -3.7 (+-0.000607251) 11.969 (+-0.0707178) 3.00025 (+-0.000580344)
found -1.9 (+-0.000605992) 11.9689 (+-0.070697) 3.00021 (+-0.000580174)
found 7.7 (+-0.000745876) 7.97953 (+-0.0577651) 2.00021 (+-0.000474048)
found 4.1 (+-0.000742268) 7.97927 (+-0.0577251) 2.00014 (+-0.00047372)
found 5.3 (+-0.000741573) 7.97922 (+-0.0577173) 2.00013 (+-0.000473656)
found 0.500006 (+-0.000738011) 7.97912 (+-0.0576828) 2.0001 (+-0.000473373)
found 2.3 (+-0.00106969) 3.99039 (+-0.040934) 1.00026 (+-0.000335925)
found -9.10002 (+-0.00105439) 3.98993 (+-0.0408493) 1.00014 (+-0.000335229)
found -0.700013 (+-0.00105136) 3.98977 (+-0.0408303) 1.0001 (+-0.000335073)
found -7.89999 (+-0.00105015) 3.98972 (+-0.0408229) 1.00009 (+-0.000335012)
found -8.5 (+-0.00103971) 3.98946 (+-0.0407648) 1.00003 (+-0.000334536)
found -0.0999979 (+-0.00104303) 3.98951 (+-0.0407821) 1.00004 (+-0.000334678)
#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()