This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 4.98678 1
created -9.28 24.9339 5
created -8.8 29.9207 6
created -8.32 9.97356 2
created -7.84 4.98678 1
created -7.36 34.9074 7
created -6.88 49.8678 10
created -6.4 39.8942 8
created -5.92 19.9471 4
created -5.44 29.9207 6
created -4.96 29.9207 6
created -4.48 39.8942 8
created -4 29.9207 6
created -3.52 44.881 9
created -3.04 39.8942 8
created -2.56 14.9603 3
created -2.08 39.8942 8
created -1.6 24.9339 5
created -1.12 4.98678 1
created -0.64 39.8942 8
created -0.16 14.9603 3
created 0.32 4.98678 1
created 0.8 14.9603 3
created 1.28 9.97356 2
created 1.76 19.9471 4
created 2.24 49.8678 10
created 2.72 44.881 9
created 3.2 24.9339 5
created 3.68 19.9471 4
created 4.16 14.9603 3
created 4.64 44.881 9
created 5.12 39.8942 8
created 5.6 34.9074 7
created 6.08 14.9603 3
created 6.56 14.9603 3
created 7.04 34.9074 7
created 7.52 4.98678 1
created 8 44.881 9
created 8.48 44.881 9
created 8.96 24.9339 5
created 9.44 24.9339 5
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.26122e-05)
fit chi^2 = 2.84676e-06
found -6.88 (+-0.000185965) 49.8679 (+-0.114149) 10.0002 (+-0.000755912)
found 2.24 (+-0.000185713) 49.8678 (+-0.11413) 10.0001 (+-0.000755791)
found -3.52 (+-0.000196069) 44.8811 (+-0.108294) 9.00014 (+-0.000717143)
found 2.72 (+-0.000196125) 44.8812 (+-0.108298) 9.00015 (+-0.000717172)
found 4.64 (+-0.000195649) 44.881 (+-0.108266) 9.00011 (+-0.000716959)
found 8 (+-0.000195268) 44.8809 (+-0.108244) 9.0001 (+-0.000716813)
found 8.48 (+-0.000196039) 44.8811 (+-0.108292) 9.00014 (+-0.000717131)
found -6.4 (+-0.000208056) 39.8944 (+-0.102107) 8.00014 (+-0.000676173)
found -4.48 (+-0.000207917) 39.8943 (+-0.102098) 8.00012 (+-0.000676109)
found -3.04 (+-0.000207783) 39.8943 (+-0.102091) 8.00012 (+-0.000676064)
found -2.08 (+-0.000207319) 39.8941 (+-0.102062) 8.00008 (+-0.000675873)
found -0.64 (+-0.00020647) 39.8939 (+-0.102014) 8.00004 (+-0.000675555)
found 5.12 (+-0.000208371) 39.8945 (+-0.102126) 8.00016 (+-0.000676296)
found -7.36 (+-0.000221854) 34.9075 (+-0.0954863) 7.00011 (+-0.000632327)
found 5.6 (+-0.00022223) 34.9075 (+-0.0955024) 7.00011 (+-0.000632434)
found 7.04 (+-0.000220866) 34.9072 (+-0.0954322) 7.00004 (+-0.000631969)
found -4.96 (+-0.000240913) 29.921 (+-0.0884582) 6.00014 (+-0.000585786)
found -4 (+-0.000241342) 29.9211 (+-0.0884787) 6.00017 (+-0.000585922)
found -8.8 (+-0.000239561) 29.9206 (+-0.0883963) 6.00007 (+-0.000585376)
found -5.44 (+-0.000240247) 29.9208 (+-0.088427) 6.0001 (+-0.000585579)
found -1.6 (+-0.000262824) 24.934 (+-0.0807124) 5.00009 (+-0.000534492)
found 3.2 (+-0.000264051) 24.9342 (+-0.0807574) 5.00013 (+-0.00053479)
found 8.96 (+-0.000264283) 24.9343 (+-0.0807663) 5.00014 (+-0.000534849)
found -9.28 (+-0.000262483) 24.9339 (+-0.0806984) 5.00007 (+-0.000534399)
found 9.44 (+-0.000261007) 24.9341 (+-0.0806539) 5.0001 (+-0.000534105)
found -5.92 (+-0.000296163) 19.9476 (+-0.0722616) 4.00014 (+-0.00047853)
found 1.76 (+-0.000295245) 19.9475 (+-0.0722345) 4.00012 (+-0.00047835)
found 3.68 (+-0.000294644) 19.9473 (+-0.0722129) 4.00008 (+-0.000478207)
found -2.56 (+-0.000343545) 14.9609 (+-0.0626197) 3.00016 (+-0.000414679)
found -0.160003 (+-0.000340634) 14.9606 (+-0.0625514) 3.00009 (+-0.000414227)
found 4.16 (+-0.000342562) 14.9608 (+-0.0625956) 3.00013 (+-0.00041452)
found 6.08 (+-0.000341649) 14.9606 (+-0.062573) 3.0001 (+-0.00041437)
found 6.56 (+-0.000341649) 14.9606 (+-0.062573) 3.0001 (+-0.00041437)
found 0.8 (+-0.000338515) 14.9603 (+-0.0624993) 3.00003 (+-0.000413882)
found -8.32 (+-0.000417973) 9.97378 (+-0.0510851) 2.00007 (+-0.000338295)
found 1.28 (+-0.000418838) 9.97378 (+-0.0510967) 2.00007 (+-0.000338372)
found -1.12 (+-0.000601964) 4.98738 (+-0.0362154) 1.00013 (+-0.000239825)
found 7.52 (+-0.000604069) 4.98753 (+-0.0362348) 1.00016 (+-0.000239954)
found -7.83999 (+-0.000597945) 4.98717 (+-0.0361804) 1.00009 (+-0.000239593)
found 0.32 (+-0.000595858) 4.98702 (+-0.0361606) 1.00006 (+-0.000239462)
found -9.75999 (+-0.000593084) 4.98697 (+-0.0361375) 1.00005 (+-0.000239309)
#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()