created -9.7 27.926 7
created -9.1 23.9365 6
created -8.5 15.9577 4
created -7.9 19.9471 5
created -7.3 27.926 7
created -6.7 7.97885 2
created -6.1 27.926 7
created -5.5 7.97885 2
created -4.9 7.97885 2
created -4.3 7.97885 2
created -3.7 7.97885 2
created -3.1 7.97885 2
created -2.5 35.9048 9
created -1.9 11.9683 3
created -1.3 39.8942 10
created -0.7 3.98942 1
created -0.1 11.9683 3
created 0.5 15.9577 4
created 1.1 11.9683 3
created 1.7 15.9577 4
created 2.3 27.926 7
created 2.9 3.98942 1
created 3.5 15.9577 4
created 4.1 7.97885 2
created 4.7 35.9048 9
created 5.3 15.9577 4
created 5.9 31.9154 8
created 6.5 39.8942 10
created 7.1 7.97885 2
created 7.7 39.8942 10
created 8.3 31.9154 8
created 8.9 3.98942 1
created 9.5 27.926 7
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.42971e-05)
fit chi^2 = 4.88362e-06
found -1.3 (+-0.000304674) 39.8937 (+-0.120533) 10 (+-0.000989153)
found 6.5 (+-0.000306014) 39.894 (+-0.120595) 10.0001 (+-0.000989659)
found 7.7 (+-0.000306014) 39.894 (+-0.120595) 10.0001 (+-0.000989659)
found -2.5 (+-0.000321747) 35.9044 (+-0.114371) 9.00006 (+-0.000938581)
found 4.7 (+-0.00032201) 35.9044 (+-0.114382) 9.00008 (+-0.000938671)
found 8.3 (+-0.000342425) 31.9154 (+-0.107877) 8.00014 (+-0.000885294)
found 5.9 (+-0.00034359) 31.9155 (+-0.107919) 8.00018 (+-0.000885632)
found -9.7 (+-0.000366794) 27.9258 (+-0.100922) 7.00008 (+-0.000828213)
found -7.3 (+-0.000365916) 27.9258 (+-0.100901) 7.00009 (+-0.000828044)
found -6.1 (+-0.000364902) 27.9256 (+-0.100868) 7.00005 (+-0.000827769)
found 2.3 (+-0.000365073) 27.9257 (+-0.100874) 7.00006 (+-0.000827825)
found 9.50001 (+-0.000362284) 27.9258 (+-0.100795) 7.0001 (+-0.000827177)
found -9.1 (+-0.000397007) 23.9367 (+-0.0934674) 6.00014 (+-0.000767039)
found -7.9 (+-0.000435539) 19.9473 (+-0.0853398) 5.00014 (+-0.00070034)
found -8.5 (+-0.000487991) 15.958 (+-0.0763513) 4.00014 (+-0.000626575)
found 5.3 (+-0.000490093) 15.9583 (+-0.0763955) 4.00022 (+-0.000626939)
found 0.5 (+-0.000485586) 15.9577 (+-0.0763028) 4.00008 (+-0.000626178)
found 1.7 (+-0.000487345) 15.9579 (+-0.0763388) 4.00013 (+-0.000626473)
found 3.5 (+-0.000483323) 15.9576 (+-0.07626) 4.00004 (+-0.000625827)
found -1.9 (+-0.000568479) 11.969 (+-0.0662026) 3.00025 (+-0.000543291)
found -0.099998 (+-0.000560572) 11.9683 (+-0.0660796) 3.00007 (+-0.000542282)
found 1.1 (+-0.00056334) 11.9685 (+-0.0661199) 3.0001 (+-0.000542612)
found 7.1 (+-0.000700423) 7.97974 (+-0.0541017) 2.00026 (+-0.000443985)
found -6.7 (+-0.00069711) 7.97942 (+-0.0540639) 2.00018 (+-0.000443675)
found -5.50001 (+-0.000692638) 7.97916 (+-0.0540166) 2.00012 (+-0.000443286)
found 4.10001 (+-0.000696009) 7.97937 (+-0.0540525) 2.00017 (+-0.000443581)
found -3.09999 (+-0.00069376) 7.97927 (+-0.0540296) 2.00014 (+-0.000443393)
found -4.9 (+-0.000688249) 7.97891 (+-0.0539694) 2.00005 (+-0.000442899)
found -4.3 (+-0.000688249) 7.9789 (+-0.0539694) 2.00005 (+-0.000442899)
found -3.7 (+-0.000688249) 7.97891 (+-0.0539694) 2.00005 (+-0.000442899)
found -0.700015 (+-0.000992589) 3.99003 (+-0.0382695) 1.00017 (+-0.000314058)
found 8.9 (+-0.000996567) 3.99013 (+-0.0382912) 1.0002 (+-0.000314236)
found 2.89999 (+-0.000991506) 3.98992 (+-0.0382616) 1.00014 (+-0.000313993)
#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()