This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 15.9577 4
created -9.1 19.9471 5
created -8.5 11.9683 3
created -7.9 31.9154 8
created -7.3 23.9365 6
created -6.7 35.9048 9
created -6.1 19.9471 5
created -5.5 7.97885 2
created -4.9 39.8942 10
created -4.3 39.8942 10
created -3.7 7.97885 2
created -3.1 35.9048 9
created -2.5 3.98942 1
created -1.9 7.97885 2
created -1.3 19.9471 5
created -0.7 11.9683 3
created -0.1 27.926 7
created 0.5 7.97885 2
created 1.1 35.9048 9
created 1.7 39.8942 10
created 2.3 3.98942 1
created 2.9 3.98942 1
created 3.5 23.9365 6
created 4.1 27.926 7
created 4.7 19.9471 5
created 5.3 15.9577 4
created 5.9 27.926 7
created 6.5 31.9154 8
created 7.1 35.9048 9
created 7.7 15.9577 4
created 8.3 31.9154 8
created 8.9 19.9471 5
created 9.5 39.8942 10
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.84306e-05)
fit chi^2 = 6.91518e-06
found -4.9 (+-0.000364458) 39.8941 (+-0.143518) 10.0002 (+-0.00117778)
found -4.3 (+-0.000364458) 39.8941 (+-0.143518) 10.0002 (+-0.00117778)
found 1.7 (+-0.000363819) 39.894 (+-0.14349) 10.0001 (+-0.00117755)
found 9.5 (+-0.000361798) 39.8942 (+-0.143409) 10.0002 (+-0.00117688)
found -6.7 (+-0.000384654) 35.9047 (+-0.136171) 9.00014 (+-0.00111748)
found -3.1 (+-0.00038195) 35.9043 (+-0.13606) 9.00004 (+-0.00111657)
found 1.1 (+-0.00038443) 35.9047 (+-0.136165) 9.00015 (+-0.00111743)
found 7.1 (+-0.000384792) 35.9047 (+-0.136177) 9.00015 (+-0.00111754)
found -7.9 (+-0.000407671) 31.9152 (+-0.128371) 8.00012 (+-0.00105348)
found 6.5 (+-0.000409476) 31.9156 (+-0.128442) 8.00021 (+-0.00105405)
found 8.3 (+-0.000407759) 31.9152 (+-0.128374) 8.00012 (+-0.0010535)
found -0.1 (+-0.000434699) 27.9257 (+-0.120043) 7.00006 (+-0.000985135)
found 4.1 (+-0.000436937) 27.926 (+-0.120118) 7.00014 (+-0.000985746)
found 5.9 (+-0.000437107) 27.9261 (+-0.120124) 7.00016 (+-0.0009858)
found -7.3 (+-0.000474266) 23.937 (+-0.111278) 6.00022 (+-0.0009132)
found 3.5 (+-0.00047063) 23.9365 (+-0.111173) 6.0001 (+-0.000912342)
found -6.1 (+-0.000517695) 19.9473 (+-0.101539) 5.00014 (+-0.000833275)
found -9.1 (+-0.000516541) 19.9471 (+-0.101507) 5.00009 (+-0.000833017)
found -1.3 (+-0.00051536) 19.947 (+-0.101479) 5.00006 (+-0.000832785)
found 4.7 (+-0.000518271) 19.9473 (+-0.101551) 5.00014 (+-0.000833373)
found 8.9 (+-0.000520712) 19.9477 (+-0.101613) 5.00024 (+-0.000833888)
found 5.3 (+-0.000581118) 15.958 (+-0.0908636) 4.00016 (+-0.000745671)
found 7.7 (+-0.000583188) 15.9583 (+-0.0909073) 4.00022 (+-0.000746029)
found -9.7 (+-0.000578288) 15.9577 (+-0.0907994) 4.00007 (+-0.000745144)
found -8.5 (+-0.000673423) 11.9687 (+-0.0787286) 3.00017 (+-0.000646085)
found -0.699999 (+-0.000672922) 11.9687 (+-0.0787204) 3.00016 (+-0.000646018)
found -3.7 (+-0.000832864) 7.97968 (+-0.0643716) 2.00025 (+-0.000528264)
found 0.500002 (+-0.00083089) 7.97953 (+-0.0643491) 2.00021 (+-0.00052808)
found -5.49999 (+-0.000829825) 7.97948 (+-0.0643378) 2.0002 (+-0.000527987)
found -1.9 (+-0.000820515) 7.97901 (+-0.0642392) 2.00008 (+-0.000527178)
found 2.29998 (+-0.00117457) 3.98993 (+-0.0455052) 1.00015 (+-0.000373438)
found -2.50002 (+-0.00117738) 3.98992 (+-0.045518) 1.00014 (+-0.000373543)
found 2.90001 (+-0.00116985) 3.98972 (+-0.0454758) 1.00009 (+-0.000373197)
#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()