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 34.9074 7
created -8.8 39.8942 8
created -8.32 9.97356 2
created -7.84 19.9471 4
created -7.36 14.9603 3
created -6.88 39.8942 8
created -6.4 39.8942 8
created -5.92 19.9471 4
created -5.44 34.9074 7
created -4.96 4.98678 1
created -4.48 9.97356 2
created -4 39.8942 8
created -3.52 19.9471 4
created -3.04 39.8942 8
created -2.56 24.9339 5
created -2.08 29.9207 6
created -1.6 4.98678 1
created -1.12 19.9471 4
created -0.64 29.9207 6
created -0.16 9.97356 2
created 0.32 34.9074 7
created 0.8 34.9074 7
created 1.28 14.9603 3
created 1.76 14.9603 3
created 2.24 44.881 9
created 2.72 4.98678 1
created 3.2 49.8678 10
created 3.68 39.8942 8
created 4.16 24.9339 5
created 4.64 39.8942 8
created 5.12 19.9471 4
created 5.6 14.9603 3
created 6.08 29.9207 6
created 6.56 34.9074 7
created 7.04 4.98678 1
created 7.52 34.9074 7
created 8 24.9339 5
created 8.48 24.9339 5
created 8.96 29.9207 6
created 9.44 44.881 9
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-3.0753e-05)
fit chi^2 = 5.07616e-06
found 3.2 (+-0.000247111) 49.8676 (+-0.152342) 10.0001 (+-0.00100884)
found 2.24 (+-0.000259802) 44.8806 (+-0.144478) 9.00004 (+-0.000956761)
found 9.44 (+-0.000259391) 44.8812 (+-0.144468) 9.00015 (+-0.000956691)
found -8.8 (+-0.000276885) 39.8942 (+-0.136292) 8.00009 (+-0.000902549)
found -6.88 (+-0.000277326) 39.8943 (+-0.136318) 8.00011 (+-0.00090272)
found -6.4 (+-0.000277565) 39.8943 (+-0.136331) 8.00012 (+-0.000902811)
found -4 (+-0.000276346) 39.894 (+-0.136259) 8.00006 (+-0.000902331)
found -3.04 (+-0.000277079) 39.8942 (+-0.136301) 8.00009 (+-0.000902613)
found 3.68 (+-0.000278031) 39.8945 (+-0.13636) 8.00015 (+-0.000903002)
found 4.64 (+-0.000277079) 39.8942 (+-0.136301) 8.00009 (+-0.000902613)
found -9.28 (+-0.00029642) 34.9075 (+-0.127512) 7.0001 (+-0.000844407)
found -5.44 (+-0.000295196) 34.9072 (+-0.127448) 7.00005 (+-0.000843986)
found 0.320001 (+-0.000296257) 34.9074 (+-0.127503) 7.00009 (+-0.000844346)
found 0.799999 (+-0.000296589) 34.9075 (+-0.127519) 7.0001 (+-0.000844455)
found 6.56 (+-0.00029562) 34.9073 (+-0.127471) 7.00007 (+-0.000844137)
found 7.52 (+-0.000295422) 34.9073 (+-0.12746) 7.00006 (+-0.000844066)
found -2.08 (+-0.00031937) 29.9206 (+-0.118018) 6.00006 (+-0.000781534)
found -0.64 (+-0.000319636) 29.9206 (+-0.118027) 6.00006 (+-0.000781598)
found 6.08 (+-0.00032071) 29.9208 (+-0.118076) 6.0001 (+-0.000781923)
found 8.96 (+-0.000321643) 29.921 (+-0.11812) 6.00014 (+-0.000782209)
found -2.56 (+-0.000352976) 24.9343 (+-0.107853) 5.00014 (+-0.000714221)
found 4.16 (+-0.000353441) 24.9344 (+-0.107872) 5.00016 (+-0.000714346)
found 8 (+-0.000352484) 24.9342 (+-0.107833) 5.00012 (+-0.000714091)
found 8.48 (+-0.000352242) 24.9341 (+-0.107823) 5.00011 (+-0.000714026)
found -5.92 (+-0.000395774) 19.9476 (+-0.0965036) 4.00015 (+-0.000639064)
found -3.52 (+-0.000396043) 19.9477 (+-0.0965125) 4.00016 (+-0.000639123)
found 5.12 (+-0.000394332) 19.9474 (+-0.096458) 4.00011 (+-0.000638762)
found -7.84 (+-0.000392102) 19.9471 (+-0.0963874) 4.00005 (+-0.000638294)
found -1.12 (+-0.00039247) 19.9472 (+-0.0964017) 4.00007 (+-0.00063839)
found -7.36 (+-0.000457125) 14.9607 (+-0.0835784) 3.00012 (+-0.000553472)
found 1.28 (+-0.000456218) 14.9607 (+-0.0835563) 3.0001 (+-0.000553325)
found 1.76 (+-0.000456868) 14.9608 (+-0.0835732) 3.00012 (+-0.000553437)
found 5.6 (+-0.000456411) 14.9606 (+-0.0835602) 3.0001 (+-0.000553351)
found -8.32 (+-0.000562359) 9.97404 (+-0.0682839) 2.00012 (+-0.000452188)
found -0.159999 (+-0.000563157) 9.97409 (+-0.068297) 2.00013 (+-0.000452275)
found -9.76 (+-0.000558705) 9.97379 (+-0.0682204) 2.00007 (+-0.000451768)
found -4.48 (+-0.000559125) 9.97389 (+-0.0682338) 2.00009 (+-0.000451857)
found 2.72 (+-0.000809028) 4.98768 (+-0.0484084) 1.00019 (+-0.000320569)
found 7.04 (+-0.00080499) 4.98743 (+-0.0483704) 1.00014 (+-0.000320317)
found -4.96001 (+-0.000798461) 4.98718 (+-0.0483132) 1.00009 (+-0.000319939)
found -1.6 (+-0.000800809) 4.98722 (+-0.0483323) 1.0001 (+-0.000320065)
#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()