created -9.7 27.926 7
created -9.1 39.8942 10
created -8.5 3.98942 1
created -7.9 15.9577 4
created -7.3 15.9577 4
created -6.7 11.9683 3
created -6.1 19.9471 5
created -5.5 31.9154 8
created -4.9 23.9365 6
created -4.3 7.97885 2
created -3.7 3.98942 1
created -3.1 27.926 7
created -2.5 7.97885 2
created -1.9 3.98942 1
created -1.3 3.98942 1
created -0.7 39.8942 10
created -0.1 35.9048 9
created 0.5 27.926 7
created 1.1 35.9048 9
created 1.7 7.97885 2
created 2.3 35.9048 9
created 2.9 23.9365 6
created 3.5 39.8942 10
created 4.1 39.8942 10
created 4.7 15.9577 4
created 5.3 11.9683 3
created 5.9 27.926 7
created 6.5 19.9471 5
created 7.1 39.8942 10
created 7.7 35.9048 9
created 8.3 27.926 7
created 8.9 31.9154 8
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.64953e-05)
fit chi^2 = 8.05576e-07
found -9.1 (+-0.000124061) 39.8939 (+-0.0489691) 10.0001 (+-0.000401865)
found -0.699998 (+-0.000124176) 39.894 (+-0.0489749) 10.0001 (+-0.000401912)
found 3.5 (+-0.000124773) 39.8943 (+-0.0490017) 10.0002 (+-0.000402132)
found 4.1 (+-0.000124614) 39.8942 (+-0.0489943) 10.0002 (+-0.000402071)
found 7.1 (+-0.000124646) 39.8942 (+-0.0489956) 10.0002 (+-0.000402082)
found -0.100001 (+-0.0001317) 35.905 (+-0.046495) 9.00022 (+-0.000381561)
found 1.1 (+-0.000131027) 35.9046 (+-0.0464662) 9.00012 (+-0.000381325)
found 2.3 (+-0.000130955) 35.9045 (+-0.046463) 9.0001 (+-0.000381298)
found 7.7 (+-0.0001317) 35.905 (+-0.046495) 9.00022 (+-0.000381561)
found -5.5 (+-0.000139365) 31.9153 (+-0.0438231) 8.00014 (+-0.000359634)
found 8.9 (+-0.000138872) 31.9152 (+-0.0438056) 8.0001 (+-0.000359491)
found 0.5 (+-0.000149735) 27.9263 (+-0.0410189) 7.00023 (+-0.000336621)
found 8.3 (+-0.000149658) 27.9263 (+-0.0410161) 7.00022 (+-0.000336599)
found -9.7 (+-0.000149292) 27.9259 (+-0.0410004) 7.00013 (+-0.000336469)
found -3.1 (+-0.000147976) 27.9256 (+-0.04096) 7.00004 (+-0.000336138)
found 5.9 (+-0.000148781) 27.9258 (+-0.0409859) 7.0001 (+-0.00033635)
found 2.9 (+-0.000162042) 23.9371 (+-0.0379858) 6.00025 (+-0.00031173)
found -4.9 (+-0.00016099) 23.9366 (+-0.0379546) 6.00013 (+-0.000311474)
found -6.1 (+-0.000176821) 19.9473 (+-0.0346589) 5.00014 (+-0.000284428)
found 6.5 (+-0.000177614) 19.9476 (+-0.0346789) 5.00022 (+-0.000284592)
found 4.7 (+-0.000198303) 15.9581 (+-0.0310127) 4.00017 (+-0.000254506)
found -7.9 (+-0.000196786) 15.9576 (+-0.0309823) 4.00007 (+-0.000254256)
found -7.3 (+-0.000197438) 15.9577 (+-0.0309944) 4.00009 (+-0.000254355)
found -6.7 (+-0.000229038) 11.9685 (+-0.0268581) 3.00012 (+-0.00022041)
found 5.3 (+-0.000229435) 11.9686 (+-0.0268645) 3.00014 (+-0.000220463)
found 1.7 (+-0.00028406) 7.97963 (+-0.0219684) 2.00023 (+-0.000180283)
found -2.50001 (+-0.000280603) 7.97911 (+-0.0219318) 2.0001 (+-0.000179983)
found -4.30001 (+-0.000280343) 7.97906 (+-0.0219289) 2.00009 (+-0.000179959)
found -8.50001 (+-0.000403872) 3.99008 (+-0.015547) 1.00018 (+-0.000127587)
found 9.49999 (+-0.000396159) 3.98982 (+-0.0155106) 1.00012 (+-0.000127288)
found -3.69999 (+-0.000401048) 3.98982 (+-0.0155309) 1.00012 (+-0.000127454)
found -1.9 (+-0.000396576) 3.98951 (+-0.015506) 1.00004 (+-0.000127249)
found -1.29998 (+-0.000400895) 3.98992 (+-0.0155315) 1.00015 (+-0.000127459)
#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()