This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 44.881 9
created -9.28 19.9471 4
created -8.8 24.9339 5
created -8.32 29.9207 6
created -7.84 9.97356 2
created -7.36 24.9339 5
created -6.88 24.9339 5
created -6.4 19.9471 4
created -5.92 29.9207 6
created -5.44 19.9471 4
created -4.96 34.9074 7
created -4.48 9.97356 2
created -4 19.9471 4
created -3.52 49.8678 10
created -3.04 44.881 9
created -2.56 24.9339 5
created -2.08 14.9603 3
created -1.6 14.9603 3
created -1.12 9.97356 2
created -0.64 44.881 9
created -0.16 44.881 9
created 0.32 49.8678 10
created 0.8 44.881 9
created 1.28 4.98678 1
created 1.76 39.8942 8
created 2.24 19.9471 4
created 2.72 34.9074 7
created 3.2 24.9339 5
created 3.68 39.8942 8
created 4.16 9.97356 2
created 4.64 34.9074 7
created 5.12 49.8678 10
created 5.6 34.9074 7
created 6.08 24.9339 5
created 6.56 9.97356 2
created 7.04 39.8942 8
created 7.52 9.97356 2
created 8 4.98678 1
created 8.48 39.8942 8
created 8.96 24.9339 5
created 9.44 29.9207 6
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.44174e-05)
fit chi^2 = 3.4039e-06
found -3.52 (+-0.000203074) 49.8678 (+-0.1248) 10.0001 (+-0.000826446)
found 0.32 (+-0.000203633) 49.868 (+-0.124842) 10.0002 (+-0.000826724)
found 5.12 (+-0.000203251) 49.8678 (+-0.124812) 10.0001 (+-0.000826529)
found -9.76 (+-0.000213703) 44.8806 (+-0.118361) 9.00004 (+-0.000783808)
found -3.04 (+-0.00021446) 44.8812 (+-0.118423) 9.00015 (+-0.000784217)
found -0.639999 (+-0.000213821) 44.881 (+-0.118381) 9.00011 (+-0.000783941)
found -0.16 (+-0.000214923) 44.8814 (+-0.118455) 9.00019 (+-0.000784427)
found 0.799999 (+-0.000213615) 44.881 (+-0.11837) 9.00011 (+-0.000783868)
found 1.76 (+-0.000225965) 39.894 (+-0.111562) 8.00005 (+-0.000738784)
found 3.68 (+-0.00022646) 39.8941 (+-0.11159) 8.00007 (+-0.000738967)
found 7.04 (+-0.000225863) 39.8939 (+-0.111555) 8.00004 (+-0.000738737)
found 8.48 (+-0.000226129) 39.894 (+-0.111572) 8.00006 (+-0.00073885)
found -4.96 (+-0.000242103) 34.9073 (+-0.104383) 7.00006 (+-0.000691241)
found 2.72 (+-0.000242779) 34.9074 (+-0.104417) 7.00009 (+-0.000691471)
found 4.64 (+-0.000242971) 34.9076 (+-0.104431) 7.00012 (+-0.000691558)
found 5.6 (+-0.000243654) 34.9077 (+-0.104465) 7.00015 (+-0.000691788)
found -8.32 (+-0.000261956) 29.9206 (+-0.0966601) 6.00007 (+-0.000640101)
found -5.92 (+-0.000262305) 29.9207 (+-0.096675) 6.00008 (+-0.000640199)
found 9.44 (+-0.000260356) 29.9208 (+-0.0966028) 6.00011 (+-0.000639721)
found -2.56 (+-0.000288438) 24.9342 (+-0.0882958) 5.00012 (+-0.000584711)
found 3.2 (+-0.000289245) 24.9343 (+-0.0883266) 5.00015 (+-0.000584915)
found 6.08 (+-0.000287726) 24.934 (+-0.0882682) 5.00009 (+-0.000584528)
found 8.96 (+-0.000289045) 24.9343 (+-0.0883187) 5.00014 (+-0.000584862)
found -8.8 (+-0.000288192) 24.9341 (+-0.0882848) 5.0001 (+-0.000584638)
found -7.36 (+-0.00028731) 24.9339 (+-0.0882515) 5.00007 (+-0.000584417)
found -6.88 (+-0.000287972) 24.934 (+-0.088276) 5.00009 (+-0.00058458)
found -9.28 (+-0.000323781) 19.9476 (+-0.0790152) 4.00014 (+-0.000523253)
found -5.44 (+-0.000323631) 19.9475 (+-0.0790098) 4.00013 (+-0.000523217)
found 2.24 (+-0.000324092) 19.9476 (+-0.0790249) 4.00015 (+-0.000523317)
found -6.4 (+-0.000323121) 19.9474 (+-0.0789932) 4.00011 (+-0.000523107)
found -4 (+-0.000322846) 19.9475 (+-0.0789874) 4.00012 (+-0.000523069)
found -2.08 (+-0.000372942) 14.9605 (+-0.0684064) 3.00008 (+-0.000452999)
found -1.6 (+-0.000371523) 14.9604 (+-0.0683727) 3.00005 (+-0.000452776)
found -7.84 (+-0.000460238) 9.97399 (+-0.0559112) 2.00011 (+-0.000370254)
found -4.48 (+-0.000460113) 9.97399 (+-0.0559094) 2.00011 (+-0.000370242)
found -1.12 (+-0.000460202) 9.97404 (+-0.0559121) 2.00012 (+-0.00037026)
found 4.16 (+-0.000461989) 9.97419 (+-0.0559416) 2.00015 (+-0.000370455)
found 6.56 (+-0.000461064) 9.97409 (+-0.0559257) 2.00013 (+-0.00037035)
found 7.52 (+-0.000457857) 9.97389 (+-0.0558753) 2.00009 (+-0.000370017)
found 1.28 (+-0.000661249) 4.98758 (+-0.0396289) 1.00017 (+-0.00026243)
found 8.00001 (+-0.000654532) 4.98723 (+-0.0395694) 1.0001 (+-0.000262035)
#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()