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 39.8942 10
created -8.5 27.926 7
created -7.9 3.98942 1
created -7.3 19.9471 5
created -6.7 7.97885 2
created -6.1 27.926 7
created -5.5 39.8942 10
created -4.9 23.9365 6
created -4.3 23.9365 6
created -3.7 23.9365 6
created -3.1 7.97885 2
created -2.5 7.97885 2
created -1.9 23.9365 6
created -1.3 15.9577 4
created -0.7 7.97885 2
created -0.1 35.9048 9
created 0.5 15.9577 4
created 1.1 23.9365 6
created 1.7 7.97885 2
created 2.3 7.97885 2
created 2.9 27.926 7
created 3.5 11.9683 3
created 4.1 3.98942 1
created 4.7 31.9154 8
created 5.3 15.9577 4
created 5.9 39.8942 10
created 6.5 11.9683 3
created 7.1 31.9154 8
created 7.7 31.9154 8
created 8.3 15.9577 4
created 8.9 35.9048 9
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.91824e-05)
fit chi^2 = 6.89688e-06
found -9.1 (+-0.000364783) 39.8942 (+-0.143364) 10.0002 (+-0.00117651)
found -5.5 (+-0.000364588) 39.8942 (+-0.143354) 10.0002 (+-0.00117643)
found 5.9 (+-0.000363186) 39.8938 (+-0.143288) 10.0001 (+-0.00117589)
found 9.5 (+-0.000362055) 39.8944 (+-0.143256) 10.0002 (+-0.00117563)
found -0.0999995 (+-0.00038267) 35.9044 (+-0.135929) 9.00008 (+-0.0011155)
found 8.9 (+-0.000384629) 35.9049 (+-0.136013) 9.00018 (+-0.00111619)
found 4.7 (+-0.00040555) 31.915 (+-0.128144) 8.00006 (+-0.00105161)
found 7.1 (+-0.000407581) 31.9154 (+-0.12822) 8.00014 (+-0.00105223)
found 7.7 (+-0.000407932) 31.9154 (+-0.128233) 8.00015 (+-0.00105234)
found -8.5 (+-0.000435395) 27.926 (+-0.119932) 7.00014 (+-0.000984221)
found -9.7 (+-0.000436827) 27.926 (+-0.119967) 7.00013 (+-0.000984506)
found -6.1 (+-0.000436071) 27.9261 (+-0.119953) 7.00016 (+-0.000984388)
found 2.9 (+-0.000434124) 27.9257 (+-0.119885) 7.00006 (+-0.000983831)
found -4.9 (+-0.000473291) 23.9369 (+-0.11112) 6.00021 (+-0.000911907)
found -4.3 (+-0.000472216) 23.9367 (+-0.111087) 6.00016 (+-0.000911634)
found -3.7 (+-0.00047048) 23.9365 (+-0.111037) 6.0001 (+-0.000911225)
found -1.9 (+-0.000469764) 23.9364 (+-0.111016) 6.00008 (+-0.00091105)
found 1.1 (+-0.000469764) 23.9364 (+-0.111016) 6.00008 (+-0.00091105)
found -7.3 (+-0.000513125) 19.9469 (+-0.101309) 5.00004 (+-0.00083139)
found -1.3 (+-0.000577921) 15.9578 (+-0.0906951) 4.0001 (+-0.000744288)
found 0.499998 (+-0.000581587) 15.9582 (+-0.0907695) 4.00019 (+-0.000744898)
found 5.3 (+-0.000582754) 15.9583 (+-0.0907943) 4.00023 (+-0.000745102)
found 8.3 (+-0.000582416) 15.9583 (+-0.0907869) 4.00022 (+-0.000745042)
found 3.5 (+-0.000668009) 11.9685 (+-0.0785573) 3.0001 (+-0.00064468)
found 6.5 (+-0.000675104) 11.969 (+-0.0786662) 3.00023 (+-0.000645573)
found -0.699995 (+-0.000827123) 7.97937 (+-0.0642349) 2.00017 (+-0.000527143)
found -6.7 (+-0.000826777) 7.97932 (+-0.0642302) 2.00016 (+-0.000527104)
found -3.1 (+-0.000822351) 7.97911 (+-0.0641835) 2.0001 (+-0.000526721)
found 1.7 (+-0.000822351) 7.97911 (+-0.0641835) 2.0001 (+-0.000526721)
found -2.5 (+-0.000822351) 7.97911 (+-0.0641835) 2.0001 (+-0.000526721)
found 2.30001 (+-0.000823117) 7.97917 (+-0.0641922) 2.00012 (+-0.000526792)
found -7.9 (+-0.00118008) 3.98997 (+-0.0454796) 1.00016 (+-0.000373227)
found 4.10001 (+-0.00117739) 3.98992 (+-0.0454651) 1.00014 (+-0.000373109)
#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()