This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 9.97356 2
created -9.28 9.97356 2
created -8.8 14.9603 3
created -8.32 44.881 9
created -7.84 4.98678 1
created -7.36 44.881 9
created -6.88 44.881 9
created -6.4 44.881 9
created -5.92 29.9207 6
created -5.44 9.97356 2
created -4.96 44.881 9
created -4.48 19.9471 4
created -4 34.9074 7
created -3.52 49.8678 10
created -3.04 34.9074 7
created -2.56 14.9603 3
created -2.08 9.97356 2
created -1.6 14.9603 3
created -1.12 14.9603 3
created -0.64 4.98678 1
created -0.16 34.9074 7
created 0.32 4.98678 1
created 0.8 9.97356 2
created 1.28 44.881 9
created 1.76 39.8942 8
created 2.24 44.881 9
created 2.72 14.9603 3
created 3.2 4.98678 1
created 3.68 14.9603 3
created 4.16 14.9603 3
created 4.64 34.9074 7
created 5.12 49.8678 10
created 5.6 24.9339 5
created 6.08 9.97356 2
created 6.56 34.9074 7
created 7.04 44.881 9
created 7.52 9.97356 2
created 8 4.98678 1
created 8.48 44.881 9
created 8.96 49.8678 10
created 9.44 39.8942 8
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.88264e-05)
fit chi^2 = 4.52249e-06
found -3.52 (+-0.000234278) 49.8678 (+-0.143866) 10.0001 (+-0.000952704)
found 5.12 (+-0.000234014) 49.8677 (+-0.143846) 10.0001 (+-0.000952573)
found 8.96 (+-0.000234613) 49.868 (+-0.143891) 10.0002 (+-0.000952875)
found -8.32 (+-0.000245224) 44.8806 (+-0.136371) 9.00004 (+-0.000903076)
found -7.36 (+-0.000246119) 44.8809 (+-0.136432) 9.0001 (+-0.000903481)
found -6.88 (+-0.000247624) 44.8813 (+-0.13653) 9.00018 (+-0.000904125)
found -6.4 (+-0.000247244) 44.8812 (+-0.136503) 9.00015 (+-0.00090395)
found -4.96 (+-0.000245766) 44.8807 (+-0.136405) 9.00006 (+-0.000903298)
found 1.28 (+-0.000246348) 44.8809 (+-0.136445) 9.0001 (+-0.000903562)
found 2.24 (+-0.000246599) 44.881 (+-0.13646) 9.00011 (+-0.000903665)
found 7.04 (+-0.000246224) 44.8809 (+-0.136436) 9.00009 (+-0.000903504)
found 8.48 (+-0.000246225) 44.881 (+-0.13644) 9.00011 (+-0.000903531)
found 1.76 (+-0.000262902) 39.8946 (+-0.128738) 8.00018 (+-0.000852524)
found 9.44 (+-0.00026032) 39.8946 (+-0.128603) 8.00018 (+-0.000851634)
found -4 (+-0.000280633) 34.9077 (+-0.120401) 7.00014 (+-0.000797319)
found -3.04 (+-0.000280378) 34.9076 (+-0.120388) 7.00013 (+-0.000797233)
found -0.16 (+-0.000277649) 34.9071 (+-0.120248) 7.00002 (+-0.000796305)
found 4.64 (+-0.000280378) 34.9076 (+-0.120388) 7.00013 (+-0.000797233)
found 6.56 (+-0.00027993) 34.9075 (+-0.120365) 7.00011 (+-0.000797079)
found -5.92 (+-0.000302693) 29.9208 (+-0.111452) 6.00011 (+-0.000738055)
found 5.6 (+-0.000332222) 24.9342 (+-0.101767) 5.00012 (+-0.000673918)
found -4.48 (+-0.0003738) 19.9477 (+-0.0910965) 4.00016 (+-0.000603258)
found 2.72 (+-0.00042963) 14.9606 (+-0.0788484) 3.0001 (+-0.000522148)
found -2.56 (+-0.000429953) 14.9606 (+-0.0788526) 3.00009 (+-0.000522176)
found -1.12 (+-0.00042732) 14.9603 (+-0.0787902) 3.00004 (+-0.000521763)
found 4.16 (+-0.000430619) 14.9606 (+-0.0788679) 3.0001 (+-0.000522277)
found -8.8 (+-0.000430564) 14.9607 (+-0.0788686) 3.00011 (+-0.000522282)
found -1.6 (+-0.000428239) 14.9604 (+-0.0788103) 3.00005 (+-0.000521896)
found 3.68 (+-0.00042732) 14.9603 (+-0.0787902) 3.00004 (+-0.000521763)
found 7.51999 (+-0.00052816) 9.97394 (+-0.0644126) 2.0001 (+-0.000426552)
found -5.44 (+-0.000532429) 9.97419 (+-0.0644802) 2.00015 (+-0.000427)
found -2.08 (+-0.000527159) 9.97373 (+-0.0643906) 2.00006 (+-0.000426406)
found 6.08 (+-0.000530995) 9.97404 (+-0.0644552) 2.00012 (+-0.000426834)
found -9.76 (+-0.000524026) 9.97353 (+-0.0643362) 2.00002 (+-0.000426046)
found -9.28 (+-0.000526222) 9.97368 (+-0.0643757) 2.00005 (+-0.000426307)
found 0.800005 (+-0.00052816) 9.97394 (+-0.0644126) 2.0001 (+-0.000426552)
found -7.84 (+-0.000762941) 4.98763 (+-0.0456856) 1.00018 (+-0.000302538)
found -0.639995 (+-0.000755387) 4.98722 (+-0.0456167) 1.0001 (+-0.000302082)
found 0.319994 (+-0.000753658) 4.98718 (+-0.0456023) 1.00009 (+-0.000301987)
found 8.00001 (+-0.000755177) 4.98728 (+-0.0456169) 1.00011 (+-0.000302084)
found 3.2 (+-0.000751028) 4.98702 (+-0.0455773) 1.00006 (+-0.000301821)
#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()