This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 39.8942 6
created -9.46 46.5433 7
created -9.1 19.9471 3
created -8.74 13.2981 2
created -8.38 33.2452 5
created -8.02 6.64904 1
created -7.66 59.8413 9
created -7.3 33.2452 5
created -6.94 33.2452 5
created -6.58 19.9471 3
created -6.22 59.8413 9
created -5.86 53.1923 8
created -5.5 46.5433 7
created -5.14 26.5962 4
created -4.78 39.8942 6
created -4.42 6.64904 1
created -4.06 39.8942 6
created -3.7 59.8413 9
created -3.34 39.8942 6
created -2.98 19.9471 3
created -2.62 19.9471 3
created -2.26 46.5433 7
created -1.9 66.4904 10
created -1.54 26.5962 4
created -1.18 59.8413 9
created -0.82 66.4904 10
created -0.46 59.8413 9
created -0.1 59.8413 9
created 0.26 53.1923 8
created 0.62 66.4904 10
created 0.98 53.1923 8
created 1.34 66.4904 10
created 1.7 46.5433 7
created 2.06 13.2981 2
created 2.42 53.1923 8
created 2.78 13.2981 2
created 3.14 59.8413 9
created 3.5 59.8413 9
created 3.86 6.64904 1
created 4.22 59.8413 9
created 4.58 66.4904 10
created 4.94 66.4904 10
created 5.3 26.5962 4
created 5.66 33.2452 5
created 6.02 39.8942 6
created 6.38 6.64904 1
created 6.74 6.64904 1
created 7.1 33.2452 5
created 7.46 19.9471 3
created 7.82 66.4904 10
created 8.18 33.2452 5
created 8.54 53.1923 8
created 8.9 33.2452 5
created 9.26 26.5962 4
created 9.62 13.2981 2
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-7.25014e-06)
fit chi^2 = 7.92493e-07
found -1.9 (+-7.22914e-05) 66.4904 (+-0.0790459) 10.0001 (+-0.000398724)
found -0.82 (+-7.2558e-05) 66.4907 (+-0.0790817) 10.0001 (+-0.000398905)
found 0.62 (+-7.24926e-05) 66.4906 (+-0.0790727) 10.0001 (+-0.000398859)
found 1.34 (+-7.24572e-05) 66.4906 (+-0.0790679) 10.0001 (+-0.000398835)
found 4.58 (+-7.25885e-05) 66.4908 (+-0.0790859) 10.0001 (+-0.000398926)
found 4.94 (+-7.23893e-05) 66.4905 (+-0.0790594) 10.0001 (+-0.000398792)
found 7.82 (+-7.21532e-05) 66.4903 (+-0.0790278) 10.0001 (+-0.000398633)
found -0.46 (+-7.65807e-05) 59.8418 (+-0.0750357) 9.00013 (+-0.000378496)
found -0.1 (+-7.65113e-05) 59.8417 (+-0.075027) 9.00011 (+-0.000378452)
found 3.5 (+-7.60818e-05) 59.8414 (+-0.0749781) 9.00007 (+-0.000378205)
found -7.66 (+-7.592e-05) 59.8412 (+-0.074958) 9.00004 (+-0.000378104)
found -6.22 (+-7.62304e-05) 59.8414 (+-0.0749934) 9.00007 (+-0.000378283)
found -3.7 (+-7.63131e-05) 59.8415 (+-0.0750026) 9.00008 (+-0.000378329)
found -1.18 (+-7.6362e-05) 59.8415 (+-0.0750093) 9.00009 (+-0.000378363)
found 3.14 (+-7.61883e-05) 59.8414 (+-0.0749893) 9.00007 (+-0.000378262)
found 4.22 (+-7.61146e-05) 59.8414 (+-0.0749823) 9.00007 (+-0.000378227)
found -5.86 (+-8.11872e-05) 53.1926 (+-0.0707401) 8.00011 (+-0.000356828)
found 0.26 (+-8.13072e-05) 53.1928 (+-0.0707535) 8.00013 (+-0.000356896)
found 0.98 (+-8.13444e-05) 53.1928 (+-0.0707577) 8.00013 (+-0.000356917)
found 2.42 (+-8.04789e-05) 53.1921 (+-0.0706652) 8.00003 (+-0.00035645)
found 8.54 (+-8.09061e-05) 53.1924 (+-0.0707093) 8.00007 (+-0.000356673)
found -5.5 (+-8.66657e-05) 46.5435 (+-0.0661593) 7.00008 (+-0.000333722)
found 1.7 (+-8.65751e-05) 46.5435 (+-0.0661522) 7.00008 (+-0.000333686)
found -9.46 (+-8.64868e-05) 46.5433 (+-0.0661423) 7.00006 (+-0.000333636)
found -2.26 (+-8.66725e-05) 46.5435 (+-0.0661608) 7.00009 (+-0.000333729)
found -3.34 (+-9.36827e-05) 39.8945 (+-0.0612583) 6.00008 (+-0.000309)
found -9.82 (+-9.35762e-05) 39.8943 (+-0.0612439) 6.00005 (+-0.000308927)
found -4.78 (+-9.3111e-05) 39.8942 (+-0.0612125) 6.00003 (+-0.000308769)
found -4.06 (+-9.34164e-05) 39.8944 (+-0.0612385) 6.00007 (+-0.0003089)
found 6.02 (+-9.31863e-05) 39.8942 (+-0.0612187) 6.00004 (+-0.0003088)
found -7.3 (+-0.000102972) 33.2456 (+-0.0559448) 5.00009 (+-0.000282198)
found 8.18 (+-0.000103244) 33.2458 (+-0.0559642) 5.00012 (+-0.000282295)
found 8.9 (+-0.000102823) 33.2455 (+-0.0559343) 5.00008 (+-0.000282144)
found -8.38 (+-0.000101873) 33.2451 (+-0.0558706) 5.00002 (+-0.000281823)
found -6.94 (+-0.000102504) 33.2453 (+-0.0559119) 5.00005 (+-0.000282032)
found 5.66 (+-0.000102688) 33.2454 (+-0.0559245) 5.00007 (+-0.000282095)
found 7.1 (+-0.000102001) 33.2451 (+-0.055879) 5.00003 (+-0.000281866)
found -5.14 (+-0.000115316) 26.5965 (+-0.0500492) 4.00009 (+-0.000252459)
found -1.54 (+-0.000115772) 26.5968 (+-0.0500762) 4.00013 (+-0.000252595)
found 5.3 (+-0.000115437) 26.5966 (+-0.0500567) 4.0001 (+-0.000252497)
found 9.26 (+-0.000114643) 26.5963 (+-0.0500117) 4.00005 (+-0.00025227)
found -9.1 (+-0.000132911) 19.9474 (+-0.0433344) 3.00006 (+-0.000218588)
found -6.58 (+-0.000133615) 19.9476 (+-0.0433645) 3.00009 (+-0.00021874)
found -2.98 (+-0.000133008) 19.9474 (+-0.0433378) 3.00006 (+-0.000218605)
found 7.46 (+-0.0001337) 19.9476 (+-0.0433685) 3.0001 (+-0.00021876)
found -2.62 (+-0.000133117) 19.9474 (+-0.0433428) 3.00007 (+-0.00021863)
found 2.06 (+-0.00016462) 13.2987 (+-0.0354366) 2.0001 (+-0.00017875)
found 2.78 (+-0.000164891) 13.2987 (+-0.0354451) 2.00011 (+-0.000178793)
found -8.74 (+-0.000163389) 13.2983 (+-0.0353993) 2.00005 (+-0.000178562)
found 9.62 (+-0.0001613) 13.2983 (+-0.0353484) 2.00004 (+-0.000178305)
found 3.86 (+-0.000235856) 6.6498 (+-0.025107) 1.00012 (+-0.000126645)
found -8.02 (+-0.000234779) 6.64962 (+-0.0250894) 1.00009 (+-0.000126556)
found -4.42 (+-0.000234336) 6.64953 (+-0.0250818) 1.00008 (+-0.000126518)
found 6.38 (+-0.000231953) 6.64931 (+-0.0250461) 1.00005 (+-0.000126338)
found 6.74 (+-0.000231652) 6.64926 (+-0.0250411) 1.00004 (+-0.000126313)
#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()