created -9.76 24.9339 5
created -9.28 24.9339 5
created -8.8 29.9207 6
created -8.32 34.9074 7
created -7.84 19.9471 4
created -7.36 39.8942 8
created -6.88 34.9074 7
created -6.4 4.98678 1
created -5.92 9.97356 2
created -5.44 9.97356 2
created -4.96 29.9207 6
created -4.48 49.8678 10
created -4 4.98678 1
created -3.52 44.881 9
created -3.04 44.881 9
created -2.56 49.8678 10
created -2.08 44.881 9
created -1.6 44.881 9
created -1.12 4.98678 1
created -0.64 44.881 9
created -0.16 24.9339 5
created 0.32 39.8942 8
created 0.8 14.9603 3
created 1.28 39.8942 8
created 1.76 44.881 9
created 2.24 14.9603 3
created 2.72 14.9603 3
created 3.2 39.8942 8
created 3.68 24.9339 5
created 4.16 4.98678 1
created 4.64 29.9207 6
created 5.12 19.9471 4
created 5.6 19.9471 4
created 6.08 34.9074 7
created 6.56 14.9603 3
created 7.04 9.97356 2
created 7.52 39.8942 8
created 8 49.8678 10
created 8.48 34.9074 7
created 8.96 44.881 9
created 9.44 49.8678 10
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-3.0423e-05)
fit chi^2 = 5.6377e-06
found -4.48 (+-0.000260157) 49.8675 (+-0.160527) 10.0001 (+-0.00106304)
found -2.56 (+-0.000262066) 49.868 (+-0.160665) 10.0002 (+-0.00106395)
found 8 (+-0.000261702) 49.8679 (+-0.160637) 10.0002 (+-0.00106377)
found 9.44 (+-0.000259617) 49.8681 (+-0.160507) 10.0002 (+-0.0010629)
found -3.52 (+-0.000274794) 44.8809 (+-0.152328) 9.0001 (+-0.00100874)
found -3.04 (+-0.000276595) 44.8814 (+-0.152445) 9.00019 (+-0.00100952)
found -2.08 (+-0.000276595) 44.8814 (+-0.152445) 9.00019 (+-0.00100952)
found -1.6 (+-0.000274794) 44.8809 (+-0.152328) 9.0001 (+-0.00100874)
found -0.639999 (+-0.000274209) 44.8807 (+-0.152287) 9.00006 (+-0.00100847)
found 1.76 (+-0.00027533) 44.881 (+-0.152359) 9.00011 (+-0.00100895)
found 8.96 (+-0.000276325) 44.8813 (+-0.152426) 9.00017 (+-0.0010094)
found -7.36 (+-0.00029236) 39.8943 (+-0.143665) 8.00011 (+-0.000951373)
found 0.32 (+-0.000291752) 39.8941 (+-0.143628) 8.00008 (+-0.000951131)
found 1.28 (+-0.000292405) 39.8943 (+-0.143669) 8.00012 (+-0.0009514)
found 3.2 (+-0.000291752) 39.8941 (+-0.143628) 8.00008 (+-0.000951131)
found 7.52 (+-0.000292225) 39.8943 (+-0.14366) 8.00012 (+-0.000951341)
found -8.32 (+-0.000312657) 34.9075 (+-0.134392) 7.0001 (+-0.000889965)
found -6.88 (+-0.000311902) 34.9074 (+-0.134357) 7.00009 (+-0.000889735)
found 6.08 (+-0.000311923) 34.9073 (+-0.134353) 7.00007 (+-0.000889709)
found 8.48 (+-0.000314314) 34.908 (+-0.134482) 7.00019 (+-0.000890566)
found -8.8 (+-0.000338585) 29.9209 (+-0.124463) 6.00012 (+-0.000824217)
found -4.96 (+-0.000338129) 29.9209 (+-0.124445) 6.00012 (+-0.0008241)
found 4.64 (+-0.0003363) 29.9205 (+-0.124362) 6.00005 (+-0.000823544)
found -0.16 (+-0.000372693) 24.9344 (+-0.113691) 5.00017 (+-0.000752879)
found 3.68 (+-0.000369862) 24.934 (+-0.113584) 5.00009 (+-0.000752171)
found -9.76 (+-0.000370037) 24.9338 (+-0.113576) 5.00005 (+-0.000752123)
found -9.28 (+-0.000371214) 24.9341 (+-0.113631) 5.00011 (+-0.000752484)
found -7.84 (+-0.00041709) 19.9476 (+-0.101701) 4.00015 (+-0.000673484)
found 5.12 (+-0.000415448) 19.9474 (+-0.101648) 4.0001 (+-0.000673132)
found 5.6 (+-0.000415756) 19.9474 (+-0.101658) 4.00011 (+-0.000673199)
found 2.24 (+-0.000481475) 14.9608 (+-0.0880745) 3.00012 (+-0.000583245)
found 0.8 (+-0.000483459) 14.961 (+-0.0881225) 3.00016 (+-0.000583563)
found 2.72 (+-0.000481147) 14.9607 (+-0.0880659) 3.00011 (+-0.000583188)
found 6.56 (+-0.000480046) 14.9606 (+-0.0880397) 3.00009 (+-0.000583015)
found 7.04 (+-0.000591796) 9.97399 (+-0.0719479) 2.00011 (+-0.000476452)
found -5.92 (+-0.000585029) 9.97358 (+-0.0718371) 2.00003 (+-0.000475718)
found -5.44 (+-0.000589684) 9.97383 (+-0.0719125) 2.00008 (+-0.000476217)
found -4 (+-0.000852602) 4.98769 (+-0.0510157) 1.0002 (+-0.000337835)
found -1.12 (+-0.00085183) 4.98763 (+-0.0510084) 1.00018 (+-0.000337786)
found -6.40001 (+-0.000841466) 4.98718 (+-0.0509154) 1.00009 (+-0.000337171)
found 4.16 (+-0.000845227) 4.98728 (+-0.050947) 1.00011 (+-0.00033738)
#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()