This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 27.926 7
created -9.1 35.9048 9
created -8.5 7.97885 2
created -7.9 11.9683 3
created -7.3 19.9471 5
created -6.7 7.97885 2
created -6.1 39.8942 10
created -5.5 11.9683 3
created -4.9 7.97885 2
created -4.3 7.97885 2
created -3.7 39.8942 10
created -3.1 11.9683 3
created -2.5 19.9471 5
created -1.9 35.9048 9
created -1.3 27.926 7
created -0.7 31.9154 8
created -0.1 15.9577 4
created 0.5 31.9154 8
created 1.1 35.9048 9
created 1.7 31.9154 8
created 2.3 31.9154 8
created 2.9 35.9048 9
created 3.5 15.9577 4
created 4.1 3.98942 1
created 4.7 3.98942 1
created 5.3 15.9577 4
created 5.9 19.9471 5
created 6.5 35.9048 9
created 7.1 11.9683 3
created 7.7 19.9471 5
created 8.3 15.9577 4
created 8.9 31.9154 8
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.83463e-05)
fit chi^2 = 6.8848e-06
found -6.1 (+-0.000362233) 39.8937 (+-0.143134) 10.0001 (+-0.00117463)
found -3.7 (+-0.000362233) 39.8937 (+-0.143134) 10.0001 (+-0.00117463)
found 9.5 (+-0.000361577) 39.8944 (+-0.143122) 10.0002 (+-0.00117453)
found -9.1 (+-0.000383048) 35.9046 (+-0.135841) 9.00011 (+-0.00111477)
found -1.9 (+-0.000384022) 35.9048 (+-0.135881) 9.00015 (+-0.0011151)
found 1.1 (+-0.000384864) 35.905 (+-0.135918) 9.00021 (+-0.00111541)
found 2.9 (+-0.000383946) 35.9047 (+-0.135878) 9.00015 (+-0.00111508)
found 6.5 (+-0.000382989) 35.9045 (+-0.135837) 9.0001 (+-0.00111474)
found 1.7 (+-0.000408792) 31.9157 (+-0.128168) 8.00022 (+-0.00105181)
found -0.700001 (+-0.00040736) 31.9154 (+-0.128112) 8.00014 (+-0.00105135)
found 0.500001 (+-0.000407773) 31.9155 (+-0.128128) 8.00017 (+-0.00105148)
found 2.3 (+-0.000408792) 31.9157 (+-0.128168) 8.00022 (+-0.00105181)
found 8.9 (+-0.000407958) 31.9155 (+-0.128136) 8.00018 (+-0.00105155)
found -1.3 (+-0.000437515) 27.9263 (+-0.119908) 7.00022 (+-0.000984021)
found -9.7 (+-0.000436237) 27.9259 (+-0.119854) 7.00012 (+-0.000983582)
found -7.3 (+-0.000514226) 19.947 (+-0.101256) 5.00006 (+-0.000830954)
found -2.5 (+-0.000517218) 19.9474 (+-0.101331) 5.00016 (+-0.000831569)
found 5.9 (+-0.000517752) 19.9474 (+-0.101344) 5.00017 (+-0.000831675)
found 7.7 (+-0.000515405) 19.9471 (+-0.101284) 5.00009 (+-0.000831186)
found -0.1 (+-0.000581543) 15.9582 (+-0.0906996) 4.00021 (+-0.000744325)
found 3.5 (+-0.000577464) 15.9579 (+-0.0906206) 4.00013 (+-0.000743677)
found 8.3 (+-0.000580232) 15.9581 (+-0.0906722) 4.00017 (+-0.0007441)
found 5.3 (+-0.000575828) 15.9577 (+-0.0905856) 4.00008 (+-0.000743389)
found -5.50001 (+-0.00067024) 11.9687 (+-0.0785316) 3.00016 (+-0.000644468)
found -3.1 (+-0.000672829) 11.9688 (+-0.0785703) 3.0002 (+-0.000644786)
found 7.1 (+-0.000672402) 11.9688 (+-0.0785631) 3.00018 (+-0.000644727)
found -7.9 (+-0.000667717) 11.9684 (+-0.0784899) 3.00009 (+-0.000644126)
found -8.50001 (+-0.000825211) 7.97932 (+-0.0641663) 2.00016 (+-0.00052658)
found -6.69999 (+-0.000828001) 7.97948 (+-0.0641963) 2.0002 (+-0.000526826)
found -4.9 (+-0.000818633) 7.97896 (+-0.0640948) 2.00007 (+-0.000525993)
found -4.29999 (+-0.000824319) 7.97932 (+-0.0641583) 2.00016 (+-0.000526515)
found 4.09999 (+-0.00116402) 3.98961 (+-0.0453566) 1.00007 (+-0.000372218)
found 4.70001 (+-0.00116402) 3.98961 (+-0.0453566) 1.00007 (+-0.000372218)
#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()