created -9.76 19.9471 4
created -9.28 49.8678 10
created -8.8 29.9207 6
created -8.32 14.9603 3
created -7.84 39.8942 8
created -7.36 44.881 9
created -6.88 24.9339 5
created -6.4 29.9207 6
created -5.92 24.9339 5
created -5.44 4.98678 1
created -4.96 14.9603 3
created -4.48 19.9471 4
created -4 9.97356 2
created -3.52 29.9207 6
created -3.04 19.9471 4
created -2.56 19.9471 4
created -2.08 24.9339 5
created -1.6 49.8678 10
created -1.12 39.8942 8
created -0.64 39.8942 8
created -0.16 19.9471 4
created 0.32 49.8678 10
created 0.8 19.9471 4
created 1.28 34.9074 7
created 1.76 4.98678 1
created 2.24 29.9207 6
created 2.72 19.9471 4
created 3.2 39.8942 8
created 3.68 24.9339 5
created 4.16 44.881 9
created 4.64 14.9603 3
created 5.12 44.881 9
created 5.6 34.9074 7
created 6.08 29.9207 6
created 6.56 39.8942 8
created 7.04 9.97356 2
created 7.52 14.9603 3
created 8 4.98678 1
created 8.48 44.881 9
created 8.96 14.9603 3
created 9.44 9.97356 2
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-1.45654e-05)
fit chi^2 = 1.1803e-06
found -9.28 (+-0.000119406) 49.8676 (+-0.0734754) 10.0001 (+-0.000486568)
found -1.6 (+-0.000119608) 49.8678 (+-0.0734906) 10.0001 (+-0.000486668)
found 0.32 (+-0.000119255) 49.8675 (+-0.0734643) 10.0001 (+-0.000486494)
found -7.36 (+-0.000126172) 44.8811 (+-0.0697257) 9.00013 (+-0.000461736)
found 4.16 (+-0.000125768) 44.8808 (+-0.0696986) 9.00008 (+-0.000461557)
found 5.12 (+-0.000125916) 44.8809 (+-0.0697087) 9.0001 (+-0.000461623)
found 8.48 (+-0.000125277) 44.8806 (+-0.0696676) 9.00004 (+-0.000461352)
found -7.84 (+-0.000133792) 39.8943 (+-0.0657367) 8.00012 (+-0.00043532)
found -1.12 (+-0.000134304) 39.8946 (+-0.0657676) 8.00018 (+-0.000435525)
found -0.640001 (+-0.000133842) 39.8943 (+-0.0657392) 8.00012 (+-0.000435337)
found 3.2 (+-0.000133608) 39.8941 (+-0.0657248) 8.00009 (+-0.000435241)
found 6.56 (+-0.000133438) 39.8941 (+-0.0657154) 8.00008 (+-0.000435179)
found 1.28 (+-0.000142344) 34.9072 (+-0.0614558) 7.00005 (+-0.000406972)
found 5.6 (+-0.000143507) 34.9077 (+-0.0615162) 7.00015 (+-0.000407372)
found -8.8 (+-0.000154898) 29.9209 (+-0.0569489) 6.00013 (+-0.000377126)
found 6.08 (+-0.000155225) 29.921 (+-0.0569633) 6.00015 (+-0.000377221)
found -6.4 (+-0.000154712) 29.9208 (+-0.0569391) 6.0001 (+-0.000377061)
found -3.52 (+-0.000154129) 29.9206 (+-0.056913) 6.00006 (+-0.000376888)
found 2.24 (+-0.000153877) 29.9205 (+-0.0569025) 6.00005 (+-0.000376819)
found -6.88 (+-0.000170304) 24.9343 (+-0.0520109) 5.00015 (+-0.000344426)
found -5.92 (+-0.000169014) 24.9339 (+-0.051962) 5.00007 (+-0.000344102)
found 3.68 (+-0.000170529) 24.9344 (+-0.0520199) 5.00017 (+-0.000344486)
found -2.08 (+-0.000170114) 24.9343 (+-0.0520038) 5.00014 (+-0.000344379)
found -3.04 (+-0.000190091) 19.9474 (+-0.0465098) 4.0001 (+-0.000307997)
found -0.159999 (+-0.000191203) 19.9478 (+-0.0465463) 4.00018 (+-0.000308238)
found 0.799999 (+-0.000191073) 19.9477 (+-0.046542) 4.00017 (+-0.000308209)
found 2.72 (+-0.000190701) 19.9476 (+-0.0465296) 4.00014 (+-0.000308127)
found -9.76 (+-0.000190126) 19.9474 (+-0.0465087) 4.0001 (+-0.000307989)
found -4.48 (+-0.000189072) 19.9471 (+-0.0464781) 4.00005 (+-0.000307787)
found -2.56 (+-0.000189934) 19.9473 (+-0.0465047) 4.00009 (+-0.000307963)
found 4.64 (+-0.000221515) 14.961 (+-0.040329) 3.00018 (+-0.000267066)
found 8.96 (+-0.000219961) 14.9607 (+-0.0402913) 3.00011 (+-0.000266817)
found -8.32 (+-0.000220862) 14.9608 (+-0.0403123) 3.00014 (+-0.000266955)
found -4.96 (+-0.000218571) 14.9604 (+-0.0402577) 3.00005 (+-0.000266594)
found 7.52 (+-0.000217971) 14.9603 (+-0.0402435) 3.00003 (+-0.0002665)
found -4 (+-0.000270686) 9.97393 (+-0.0329181) 2.0001 (+-0.000217989)
found 7.04 (+-0.000270781) 9.97398 (+-0.0329203) 2.00011 (+-0.000218004)
found 9.44 (+-0.000266194) 9.97368 (+-0.0328532) 2.00005 (+-0.00021756)
found -5.44 (+-0.000384946) 4.98712 (+-0.0232952) 1.00008 (+-0.000154265)
found 1.76 (+-0.00038771) 4.98738 (+-0.02332) 1.00013 (+-0.00015443)
found 8.00001 (+-0.000386683) 4.98733 (+-0.0233116) 1.00012 (+-0.000154373)
#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()