This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 31.9154 8
created -9.1 35.9048 9
created -8.5 23.9365 6
created -7.9 31.9154 8
created -7.3 19.9471 5
created -6.7 3.98942 1
created -6.1 15.9577 4
created -5.5 23.9365 6
created -4.9 11.9683 3
created -4.3 19.9471 5
created -3.7 3.98942 1
created -3.1 15.9577 4
created -2.5 19.9471 5
created -1.9 23.9365 6
created -1.3 39.8942 10
created -0.7 23.9365 6
created -0.1 35.9048 9
created 0.5 39.8942 10
created 1.1 7.97885 2
created 1.7 11.9683 3
created 2.3 11.9683 3
created 2.9 31.9154 8
created 3.5 7.97885 2
created 4.1 31.9154 8
created 4.7 35.9048 9
created 5.3 15.9577 4
created 5.9 15.9577 4
created 6.5 23.9365 6
created 7.1 11.9683 3
created 7.7 31.9154 8
created 8.3 39.8942 10
created 8.9 3.98942 1
created 9.5 19.9471 5
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.49641e-05)
fit chi^2 = 3.50312e-06
found -1.3 (+-0.0002597) 39.8941 (+-0.10216) 10.0002 (+-0.000838378)
found 0.499998 (+-0.000259294) 39.894 (+-0.102143) 10.0001 (+-0.000838237)
found 8.3 (+-0.000258832) 39.8939 (+-0.102123) 10.0001 (+-0.000838071)
found -9.1 (+-0.000274237) 35.9048 (+-0.0969394) 9.00018 (+-0.000795532)
found -0.0999991 (+-0.000274485) 35.9049 (+-0.0969507) 9.00021 (+-0.000795624)
found 4.7 (+-0.000273875) 35.9047 (+-0.0969239) 9.00015 (+-0.000795405)
found -9.7 (+-0.00029091) 31.9152 (+-0.0913899) 8.00012 (+-0.00074999)
found -7.9 (+-0.000290621) 31.9153 (+-0.0913855) 8.00014 (+-0.000749954)
found 2.9 (+-0.000289207) 31.915 (+-0.0913323) 8.00006 (+-0.000749518)
found 4.1 (+-0.000290311) 31.9153 (+-0.0913756) 8.00014 (+-0.000749873)
found 7.7 (+-0.000290752) 31.9154 (+-0.0913921) 8.00017 (+-0.000750008)
found -8.5 (+-0.000337558) 23.937 (+-0.0792017) 6.00022 (+-0.000649968)
found -0.7 (+-0.000337911) 23.9371 (+-0.0792128) 6.00025 (+-0.000650059)
found -5.5 (+-0.000335193) 23.9364 (+-0.079131) 6.00009 (+-0.000649387)
found -1.9 (+-0.000337067) 23.9369 (+-0.0791872) 6.00019 (+-0.000649849)
found 6.5 (+-0.000335193) 23.9364 (+-0.079131) 6.00009 (+-0.000649387)
found -7.3 (+-0.000367605) 19.9472 (+-0.0722497) 5.00012 (+-0.000592917)
found -4.3 (+-0.000366161) 19.9469 (+-0.0722129) 5.00005 (+-0.000592615)
found -2.5 (+-0.000368626) 19.9473 (+-0.0722718) 5.00013 (+-0.000593098)
found 9.50001 (+-0.000363302) 19.947 (+-0.072155) 5.00008 (+-0.000592139)
found 5.3 (+-0.000413752) 15.9581 (+-0.0646756) 4.00017 (+-0.000530759)
found -6.1 (+-0.000411084) 15.9578 (+-0.0646232) 4.00009 (+-0.000530329)
found -3.1 (+-0.000410747) 15.9577 (+-0.0646161) 4.00008 (+-0.000530271)
found 5.9 (+-0.000412911) 15.9579 (+-0.0646576) 4.00013 (+-0.000530612)
found -4.9 (+-0.000478558) 11.9686 (+-0.0560227) 3.00014 (+-0.000459749)
found 7.1 (+-0.000479749) 11.9688 (+-0.0560419) 3.00018 (+-0.000459907)
found 1.7 (+-0.000475215) 11.9683 (+-0.0559713) 3.00007 (+-0.000459328)
found 2.3 (+-0.000478208) 11.9686 (+-0.0560181) 3.00014 (+-0.000459712)
found 3.5 (+-0.000591427) 7.97952 (+-0.0458007) 2.00021 (+-0.000375863)
found 1.09999 (+-0.00058906) 7.97937 (+-0.0457758) 2.00017 (+-0.000375659)
found 8.89999 (+-0.000843498) 3.99013 (+-0.032428) 1.0002 (+-0.00026612)
found -6.7 (+-0.00083767) 3.98982 (+-0.0323933) 1.00012 (+-0.000265835)
found -3.7 (+-0.00083767) 3.98981 (+-0.0323933) 1.00012 (+-0.000265835)
#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()