This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 26.5962 4
created -9.46 6.64904 1
created -9.1 39.8942 6
created -8.74 66.4904 10
created -8.38 59.8413 9
created -8.02 66.4904 10
created -7.66 46.5433 7
created -7.3 46.5433 7
created -6.94 26.5962 4
created -6.58 46.5433 7
created -6.22 53.1923 8
created -5.86 13.2981 2
created -5.5 59.8413 9
created -5.14 33.2452 5
created -4.78 46.5433 7
created -4.42 59.8413 9
created -4.06 26.5962 4
created -3.7 59.8413 9
created -3.34 66.4904 10
created -2.98 66.4904 10
created -2.62 46.5433 7
created -2.26 39.8942 6
created -1.9 59.8413 9
created -1.54 6.64904 1
created -1.18 26.5962 4
created -0.82 26.5962 4
created -0.46 13.2981 2
created -0.1 13.2981 2
created 0.26 39.8942 6
created 0.62 33.2452 5
created 0.98 59.8413 9
created 1.34 13.2981 2
created 1.7 33.2452 5
created 2.06 19.9471 3
created 2.42 13.2981 2
created 2.78 66.4904 10
created 3.14 13.2981 2
created 3.5 39.8942 6
created 3.86 13.2981 2
created 4.22 13.2981 2
created 4.58 13.2981 2
created 4.94 66.4904 10
created 5.3 46.5433 7
created 5.66 26.5962 4
created 6.02 33.2452 5
created 6.38 33.2452 5
created 6.74 59.8413 9
created 7.1 19.9471 3
created 7.46 33.2452 5
created 7.82 66.4904 10
created 8.18 66.4904 10
created 8.54 46.5433 7
created 8.9 13.2981 2
created 9.26 19.9471 3
created 9.62 53.1923 8
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.44704e-05)
fit chi^2 = 3.05225e-06
found -8.74 (+-0.000142186) 66.4906 (+-0.15517) 10.0001 (+-0.000782712)
found -8.02 (+-0.000142262) 66.4906 (+-0.15518) 10.0001 (+-0.000782763)
found -3.34 (+-0.000142456) 66.4908 (+-0.155207) 10.0001 (+-0.000782897)
found -2.98 (+-0.000142322) 66.4907 (+-0.155189) 10.0001 (+-0.000782805)
found 2.78 (+-0.000141122) 66.4901 (+-0.155033) 10 (+-0.000782018)
found 4.94 (+-0.000141623) 66.4903 (+-0.155097) 10.0001 (+-0.000782344)
found 7.82 (+-0.000142161) 66.4906 (+-0.155167) 10.0001 (+-0.000782698)
found 8.18 (+-0.000142322) 66.4907 (+-0.155189) 10.0001 (+-0.000782805)
found -8.38 (+-0.000150356) 59.8418 (+-0.147267) 9.00013 (+-0.000742845)
found -5.5 (+-0.000149202) 59.8412 (+-0.147128) 9.00005 (+-0.000742145)
found -4.42 (+-0.000149651) 59.8414 (+-0.14718) 9.00007 (+-0.000742408)
found -3.7 (+-0.000149861) 59.8416 (+-0.147207) 9.00009 (+-0.000742542)
found -1.9 (+-0.000149085) 59.8412 (+-0.147117) 9.00005 (+-0.00074209)
found 0.98 (+-0.000149202) 59.8412 (+-0.147128) 9.00005 (+-0.000742145)
found 6.74 (+-0.000149353) 59.8413 (+-0.147145) 9.00005 (+-0.00074223)
found -6.22 (+-0.000158551) 53.1923 (+-0.138746) 8.00006 (+-0.000699863)
found 9.62 (+-0.000157263) 53.1924 (+-0.138628) 8.00007 (+-0.000699267)
found -7.66 (+-0.000170603) 46.5437 (+-0.129889) 7.00011 (+-0.000655186)
found -2.62 (+-0.000170498) 46.5437 (+-0.129879) 7.00011 (+-0.000655135)
found 5.3 (+-0.000170251) 46.5436 (+-0.129855) 7.00009 (+-0.000655018)
found 8.54 (+-0.000169905) 46.5435 (+-0.129825) 7.00008 (+-0.000654862)
found -7.3 (+-0.000169988) 46.5434 (+-0.129829) 7.00007 (+-0.000654886)
found -6.58 (+-0.000170083) 46.5435 (+-0.129838) 7.00008 (+-0.000654933)
found -4.78 (+-0.000170301) 46.5436 (+-0.129859) 7.00009 (+-0.000655038)
found -9.1 (+-0.000183422) 39.8944 (+-0.120189) 6.00007 (+-0.000606261)
found -2.26 (+-0.000184433) 39.8947 (+-0.120267) 6.00011 (+-0.000606653)
found 0.26 (+-0.00018318) 39.8943 (+-0.120165) 6.00005 (+-0.000606135)
found 3.5 (+-0.000182642) 39.8941 (+-0.120122) 6.00003 (+-0.000605919)
found -5.14 (+-0.00020238) 33.2457 (+-0.109813) 5.00011 (+-0.000553921)
found 0.62 (+-0.00020224) 33.2456 (+-0.109803) 5.0001 (+-0.000553871)
found 1.7 (+-0.000200532) 33.2452 (+-0.109685) 5.00003 (+-0.000553275)
found 6.02 (+-0.000201372) 33.2454 (+-0.109742) 5.00006 (+-0.00055356)
found 6.38 (+-0.000202084) 33.2456 (+-0.109792) 5.00009 (+-0.000553816)
found 7.46 (+-0.000201807) 33.2455 (+-0.109774) 5.00009 (+-0.000553725)
found -6.94 (+-0.000226478) 26.5966 (+-0.0982321) 4.00009 (+-0.000495503)
found -4.06 (+-0.000227071) 26.5968 (+-0.0982671) 4.00012 (+-0.00049568)
found -0.82 (+-0.000224776) 26.5962 (+-0.0981365) 4.00004 (+-0.000495021)
found 5.66 (+-0.00022612) 26.5965 (+-0.0982115) 4.00008 (+-0.000495399)
found -9.82 (+-0.000223787) 26.596 (+-0.098076) 4.00001 (+-0.000494716)
found -1.18 (+-0.000224343) 26.5962 (+-0.0981147) 4.00003 (+-0.000494911)
found 2.06 (+-0.000260389) 19.9473 (+-0.0850241) 3.00005 (+-0.000428879)
found 7.1 (+-0.00026222) 19.9476 (+-0.0851034) 3.00009 (+-0.00042928)
found 9.26 (+-0.000261034) 19.9474 (+-0.0850532) 3.00007 (+-0.000429026)
found 1.34 (+-0.000322672) 13.2986 (+-0.069533) 2.00009 (+-0.000350739)
found 3.14 (+-0.00032325) 13.2987 (+-0.0695509) 2.00011 (+-0.00035083)
found -5.86 (+-0.000323601) 13.2987 (+-0.0695614) 2.00011 (+-0.000350883)
found 3.86 (+-0.000320414) 13.2983 (+-0.0694658) 2.00005 (+-0.0003504)
found 8.9 (+-0.000321291) 13.2984 (+-0.0694913) 2.00007 (+-0.000350529)
found -0.460001 (+-0.000319695) 13.2983 (+-0.0694439) 2.00004 (+-0.00035029)
found -0.0999988 (+-0.000320414) 13.2983 (+-0.0694658) 2.00005 (+-0.0003504)
found 2.42 (+-0.000322046) 13.2986 (+-0.0695155) 2.00009 (+-0.000350651)
found 4.22 (+-0.000318675) 13.2982 (+-0.0694144) 2.00003 (+-0.000350141)
found 4.58 (+-0.000321465) 13.2985 (+-0.0694994) 2.00008 (+-0.00035057)
found -1.54 (+-0.000460051) 6.64958 (+-0.0492272) 1.00009 (+-0.000248312)
found -9.46 (+-0.000458578) 6.64944 (+-0.0492025) 1.00007 (+-0.000248188)
#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()