created -9.76 14.9603 3
created -9.28 4.98678 1
created -8.8 29.9207 6
created -8.32 49.8678 10
created -7.84 24.9339 5
created -7.36 14.9603 3
created -6.88 34.9074 7
created -6.4 14.9603 3
created -5.92 39.8942 8
created -5.44 34.9074 7
created -4.96 19.9471 4
created -4.48 49.8678 10
created -4 44.881 9
created -3.52 14.9603 3
created -3.04 39.8942 8
created -2.56 4.98678 1
created -2.08 29.9207 6
created -1.6 49.8678 10
created -1.12 44.881 9
created -0.64 9.97356 2
created -0.16 34.9074 7
created 0.32 19.9471 4
created 0.8 19.9471 4
created 1.28 34.9074 7
created 1.76 24.9339 5
created 2.24 14.9603 3
created 2.72 34.9074 7
created 3.2 34.9074 7
created 3.68 24.9339 5
created 4.16 34.9074 7
created 4.64 14.9603 3
created 5.12 44.881 9
created 5.6 39.8942 8
created 6.08 34.9074 7
created 6.56 19.9471 4
created 7.04 24.9339 5
created 7.52 24.9339 5
created 8 44.881 9
created 8.48 29.9207 6
created 8.96 29.9207 6
created 9.44 4.98678 1
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-1.03292e-05)
fit chi^2 = 6.25767e-07
found -8.32 (+-8.70016e-05) 49.8676 (+-0.053504) 10.0001 (+-0.000354313)
found -4.48 (+-8.70708e-05) 49.8678 (+-0.0535095) 10.0001 (+-0.00035435)
found -1.6 (+-8.71816e-05) 49.8679 (+-0.0535177) 10.0002 (+-0.000354404)
found -4 (+-9.18119e-05) 44.881 (+-0.0507662) 9.00013 (+-0.000336183)
found -1.12 (+-9.17185e-05) 44.881 (+-0.0507604) 9.00012 (+-0.000336144)
found 5.12 (+-9.17293e-05) 44.8809 (+-0.0507603) 9.00011 (+-0.000336144)
found 8 (+-9.1772e-05) 44.8809 (+-0.0507627) 9.00011 (+-0.00033616)
found -5.92 (+-9.73195e-05) 39.8942 (+-0.0478587) 8.0001 (+-0.000316929)
found -3.04 (+-9.68029e-05) 39.8939 (+-0.0478289) 8.00004 (+-0.000316732)
found 5.6 (+-9.76942e-05) 39.8945 (+-0.0478814) 8.00016 (+-0.000317079)
found -6.88 (+-0.000103827) 34.9073 (+-0.0447564) 7.00006 (+-0.000296385)
found -5.44 (+-0.000104286) 34.9076 (+-0.0447808) 7.00012 (+-0.000296547)
found -0.16 (+-0.000103805) 34.9073 (+-0.0447555) 7.00006 (+-0.000296379)
found 1.28 (+-0.000104095) 34.9074 (+-0.0447703) 7.00009 (+-0.000296477)
found 2.72 (+-0.000104134) 34.9075 (+-0.0447728) 7.0001 (+-0.000296493)
found 3.2 (+-0.000104309) 34.9076 (+-0.0447818) 7.00012 (+-0.000296554)
found 4.16 (+-0.000104001) 34.9074 (+-0.0447655) 7.00008 (+-0.000296445)
found 6.08 (+-0.000104286) 34.9076 (+-0.0447808) 7.00012 (+-0.000296547)
found 8.48 (+-0.000113012) 29.921 (+-0.0414763) 6.00015 (+-0.000274664)
found 8.96 (+-0.000112213) 29.9206 (+-0.0414405) 6.00007 (+-0.000274427)
found -8.8 (+-0.000112466) 29.9208 (+-0.0414529) 6.00011 (+-0.000274509)
found -2.08 (+-0.000112466) 29.9208 (+-0.0414529) 6.00011 (+-0.000274509)
found -7.84 (+-0.000123738) 24.9342 (+-0.0378608) 5.00013 (+-0.000250721)
found 1.76 (+-0.000123524) 24.9341 (+-0.0378519) 5.0001 (+-0.000250662)
found 3.68 (+-0.00012394) 24.9343 (+-0.0378681) 5.00014 (+-0.000250769)
found 7.04 (+-0.000123472) 24.934 (+-0.0378495) 5.00009 (+-0.000250647)
found 7.52 (+-0.000123908) 24.9343 (+-0.037867) 5.00014 (+-0.000250762)
found -4.96 (+-0.000139126) 19.9477 (+-0.0338886) 4.00017 (+-0.000224417)
found 0.319999 (+-0.000138514) 19.9474 (+-0.0338686) 4.00011 (+-0.000224284)
found 6.56 (+-0.000138646) 19.9475 (+-0.0338728) 4.00012 (+-0.000224312)
found 0.800001 (+-0.000138514) 19.9474 (+-0.0338686) 4.00011 (+-0.000224284)
found -3.52 (+-0.000161181) 14.961 (+-0.0293619) 3.00017 (+-0.00019444)
found -7.36 (+-0.000160549) 14.9607 (+-0.0293459) 3.00012 (+-0.000194334)
found -6.4 (+-0.000160949) 14.9609 (+-0.029356) 3.00015 (+-0.000194401)
found 2.24 (+-0.000160549) 14.9607 (+-0.0293459) 3.00012 (+-0.000194334)
found 4.64 (+-0.00016106) 14.9609 (+-0.0293588) 3.00016 (+-0.00019442)
found -9.76 (+-0.000158574) 14.9602 (+-0.029297) 3.00001 (+-0.00019401)
found -0.640001 (+-0.00019824) 9.97424 (+-0.0239885) 2.00016 (+-0.000158856)
found -2.56 (+-0.000282604) 4.98743 (+-0.0169829) 1.00014 (+-0.000112464)
found 9.44 (+-0.000276329) 4.98707 (+-0.0169351) 1.00007 (+-0.000112147)
found -9.28 (+-0.00028066) 4.98717 (+-0.0169654) 1.00009 (+-0.000112348)
#include <iostream>
TH1F *FitAwmi_Create_Spectrum(
void) {
delete gROOT->FindObject(
"h");
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;
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)
A PolyMarker is defined by an array on N points in a 2-D space.
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()