created -9.7 19.9471 5
created -9.1 15.9577 4
created -8.5 19.9471 5
created -7.9 31.9154 8
created -7.3 19.9471 5
created -6.7 39.8942 10
created -6.1 23.9365 6
created -5.5 15.9577 4
created -4.9 15.9577 4
created -4.3 19.9471 5
created -3.7 7.97885 2
created -3.1 31.9154 8
created -2.5 7.97885 2
created -1.9 3.98942 1
created -1.3 31.9154 8
created -0.7 27.926 7
created -0.1 35.9048 9
created 0.5 19.9471 5
created 1.1 35.9048 9
created 1.7 35.9048 9
created 2.3 15.9577 4
created 2.9 11.9683 3
created 3.5 23.9365 6
created 4.1 3.98942 1
created 4.7 23.9365 6
created 5.3 7.97885 2
created 5.9 27.926 7
created 6.5 3.98942 1
created 7.1 3.98942 1
created 7.7 11.9683 3
created 8.3 15.9577 4
created 8.9 27.926 7
created 9.5 3.98942 1
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-1.75179e-05)
fit chi^2 = 7.83132e-07
found -6.7 (+-0.000122717) 39.894 (+-0.0482993) 10.0001 (+-0.000396368)
found -0.1 (+-0.000129517) 35.9047 (+-0.0458278) 9.00015 (+-0.000376086)
found 1.1 (+-0.000129643) 35.9048 (+-0.0458335) 9.00018 (+-0.000376132)
found 1.7 (+-0.000129552) 35.9048 (+-0.0458297) 9.00017 (+-0.000376101)
found -7.9 (+-0.000137321) 31.9153 (+-0.0432048) 8.00013 (+-0.00035456)
found -3.1 (+-0.000136597) 31.915 (+-0.0431779) 8.00005 (+-0.000354339)
found -1.3 (+-0.000136924) 31.9152 (+-0.0431911) 8.0001 (+-0.000354447)
found -0.7 (+-0.000147559) 27.9263 (+-0.0404407) 7.00022 (+-0.000331876)
found 5.9 (+-0.0001459) 27.9256 (+-0.0403854) 7.00004 (+-0.000331422)
found 8.9 (+-0.000146193) 27.9257 (+-0.040395) 7.00006 (+-0.000331501)
found -6.1 (+-0.000159239) 23.9368 (+-0.0374369) 6.00018 (+-0.000307226)
found 3.5 (+-0.000157887) 23.9363 (+-0.0373978) 6.00005 (+-0.000306905)
found 4.7 (+-0.000157702) 23.9362 (+-0.0373926) 6.00004 (+-0.000306862)
found 0.5 (+-0.00017524) 19.9477 (+-0.0341954) 5.00023 (+-0.000280625)
found -9.7 (+-0.000173748) 19.9469 (+-0.0341549) 5.00005 (+-0.000280292)
found -8.5 (+-0.00017452) 19.9473 (+-0.034177) 5.00016 (+-0.000280473)
found -7.3 (+-0.000175232) 19.9477 (+-0.0341953) 5.00023 (+-0.000280623)
found -4.3 (+-0.000173608) 19.947 (+-0.0341544) 5.00008 (+-0.000280288)
found -9.1 (+-0.000195253) 15.9579 (+-0.0305714) 4.00013 (+-0.000250884)
found -5.5 (+-0.00019523) 15.9579 (+-0.030571) 4.00013 (+-0.00025088)
found 2.3 (+-0.000195409) 15.958 (+-0.0305752) 4.00016 (+-0.000250915)
found -4.9 (+-0.000195069) 15.9578 (+-0.0305676) 4.00012 (+-0.000250853)
found 8.3 (+-0.000195157) 15.9579 (+-0.0305697) 4.00013 (+-0.00025087)
found 2.9 (+-0.000226031) 11.9686 (+-0.0264846) 3.00013 (+-0.000217345)
found 7.7 (+-0.00022448) 11.9683 (+-0.0264615) 3.00006 (+-0.000217156)
found -3.7 (+-0.000278836) 7.97936 (+-0.0216463) 2.00017 (+-0.00017764)
found -2.50001 (+-0.000276899) 7.97916 (+-0.0216268) 2.00012 (+-0.00017748)
found 5.3 (+-0.000278894) 7.97936 (+-0.0216469) 2.00017 (+-0.000177645)
found 4.1 (+-0.000397712) 3.98997 (+-0.0153255) 1.00016 (+-0.000125769)
found 6.49999 (+-0.000394136) 3.98976 (+-0.0153065) 1.00011 (+-0.000125612)
found 9.49999 (+-0.000390202) 3.98976 (+-0.0152905) 1.0001 (+-0.000125481)
found -1.89999 (+-0.000395836) 3.98987 (+-0.0153155) 1.00013 (+-0.000125687)
found 7.1 (+-0.000391889) 3.98956 (+-0.0152932) 1.00005 (+-0.000125504)
#include <iostream>
TH1F *FitAwmi_Create_Spectrum(
void) {
npeaks++;
std::cout << "created "
<< area << std::endl;
}
std::cout << "the total number of created peaks = " << npeaks
<<
" with sigma = " <<
sigma << std::endl;
}
void FitAwmi(void) {
TH1F *
h = FitAwmi_Create_Spectrum();
if (!cFit) cFit =
new TCanvas(
"cFit",
"cFit", 10, 10, 1000, 700);
for (i = 0; i < nbins; i++) source[i] =
h->GetBinContent(i + 1);
for(i = 0; i < nfound; i++) FixAmp[i] = FixPos[i] =
kFALSE;
for (i = 0; i < nfound; i++) {
bin = 1 +
Int_t(Pos[i] + 0.5);
Amp[i] =
h->GetBinContent(bin);
}
delete gROOT->FindObject(
"d");
TH1F *
d =
new TH1F(*
h);
d->SetNameTitle(
"d",
"");
d->Reset(
"M");
for (i = 0; i < nbins; i++)
d->SetBinContent(i + 1, source[i]);
sigma *= dx; sigmaErr *= dx;
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++) {
bin = 1 +
Int_t(Positions[i] + 0.5);
Pos[i] =
d->GetBinCenter(bin);
Amp[i] =
d->GetBinContent(bin);
Positions[i] =
x1 + Positions[i] * dx;
PositionsErrors[i] *= dx;
Areas[i] *= dx;
AreasErrors[i] *= dx;
std::cout << "found "
<< Positions[i] << " (+-" << PositionsErrors[i] << ") "
<< Amplitudes[i] << " (+-" << AmplitudesErrors[i] << ") "
<< Areas[i] << " (+-" << AreasErrors[i] << ")"
<< std::endl;
}
d->SetLineColor(
kRed);
d->SetLineWidth(1);
if (pm) {
h->GetListOfFunctions()->Remove(pm);
delete pm;
}
h->GetListOfFunctions()->Add(pm);
delete pfit;
delete [] Amp;
delete [] FixAmp;
delete [] FixPos;
delete s;
delete [] source;
return;
}
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
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
1-D histogram with a float per channel (see TH1 documentation)
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
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.
void SetPeakParameters(Double_t sigma, Bool_t fixSigma, const Double_t *positionInit, const Bool_t *fixPosition, const Double_t *ampInit, const Bool_t *fixAmp)
This function sets the following fitting parameters of peaks:
Double_t * GetAmplitudesErrors() const
void FitAwmi(Double_t *source)
This function fits the source spectrum.
Double_t * GetAreasErrors() const
void GetSigma(Double_t &sigma, Double_t &sigmaErr)
This function gets the sigma parameter and its error.
Double_t * GetAreas() const
Double_t * GetAmplitudes() const
void SetFitParameters(Int_t xmin, Int_t xmax, Int_t numberIterations, Double_t alpha, Int_t statisticType, Int_t alphaOptim, Int_t power, Int_t fitTaylor)
This function sets the following fitting parameters:
Double_t * GetPositionsErrors() const
Double_t * GetPositions() const
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()