created -9.76 4.98678 1
created -9.28 34.9074 7
created -8.8 29.9207 6
created -8.32 9.97356 2
created -7.84 9.97356 2
created -7.36 14.9603 3
created -6.88 49.8678 10
created -6.4 29.9207 6
created -5.92 14.9603 3
created -5.44 4.98678 1
created -4.96 49.8678 10
created -4.48 39.8942 8
created -4 29.9207 6
created -3.52 14.9603 3
created -3.04 4.98678 1
created -2.56 49.8678 10
created -2.08 24.9339 5
created -1.6 34.9074 7
created -1.12 29.9207 6
created -0.64 4.98678 1
created -0.16 34.9074 7
created 0.32 9.97356 2
created 0.8 4.98678 1
created 1.28 14.9603 3
created 1.76 4.98678 1
created 2.24 14.9603 3
created 2.72 49.8678 10
created 3.2 44.881 9
created 3.68 14.9603 3
created 4.16 9.97356 2
created 4.64 39.8942 8
created 5.12 39.8942 8
created 5.6 9.97356 2
created 6.08 29.9207 6
created 6.56 49.8678 10
created 7.04 29.9207 6
created 7.52 44.881 9
created 8 34.9074 7
created 8.48 9.97356 2
created 8.96 34.9074 7
created 9.44 44.881 9
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-3.08249e-05)
fit chi^2 = 5.07739e-06
found -6.88 (+-0.000247461) 49.8676 (+-0.152379) 10.0001 (+-0.00100908)
found -4.96 (+-0.000247141) 49.8676 (+-0.15236) 10.0001 (+-0.00100896)
found -2.56 (+-0.000246745) 49.8674 (+-0.15233) 10.0001 (+-0.00100876)
found 2.72 (+-0.000247824) 49.8677 (+-0.152407) 10.0001 (+-0.00100927)
found 6.56 (+-0.00024797) 49.8677 (+-0.152416) 10.0001 (+-0.00100933)
found 3.2 (+-0.000261525) 44.8811 (+-0.144607) 9.00013 (+-0.000957612)
found 7.52 (+-0.000261718) 44.8811 (+-0.144618) 9.00013 (+-0.000957685)
found 9.44 (+-0.000259564) 44.8812 (+-0.144495) 9.00016 (+-0.000956873)
found -4.48 (+-0.000278245) 39.8945 (+-0.136388) 8.00016 (+-0.000903183)
found 4.64 (+-0.000277064) 39.8942 (+-0.136318) 8.0001 (+-0.000902719)
found 5.12 (+-0.000277064) 39.8942 (+-0.136318) 8.0001 (+-0.000902719)
found -9.28 (+-0.000295656) 34.9073 (+-0.127487) 7.00007 (+-0.00084424)
found -1.6 (+-0.000296942) 34.9075 (+-0.127551) 7.00011 (+-0.000844663)
found -0.16 (+-0.000294641) 34.9071 (+-0.127434) 7.00003 (+-0.000843888)
found 8 (+-0.000296607) 34.9075 (+-0.127536) 7.00011 (+-0.000844565)
found 8.96 (+-0.000296607) 34.9076 (+-0.127536) 7.00011 (+-0.000844565)
found -8.8 (+-0.000320367) 29.9207 (+-0.118074) 6.00009 (+-0.000781908)
found -6.4 (+-0.00032127) 29.9209 (+-0.118116) 6.00013 (+-0.000782186)
found -4 (+-0.000320936) 29.9208 (+-0.1181) 6.00011 (+-0.000782077)
found -1.12 (+-0.00031984) 29.9207 (+-0.118053) 6.00008 (+-0.000781765)
found 7.04 (+-0.00032265) 29.9212 (+-0.11818) 6.00019 (+-0.00078261)
found 6.08 (+-0.000320886) 29.9209 (+-0.1181) 6.00012 (+-0.000782077)
found -2.08 (+-0.000353656) 24.9344 (+-0.107892) 5.00017 (+-0.00071448)
found 3.68 (+-0.000456215) 14.9607 (+-0.0835672) 3.00011 (+-0.000553397)
found -5.92 (+-0.000454214) 14.9605 (+-0.0835195) 3.00007 (+-0.000553081)
found -3.52 (+-0.000454214) 14.9605 (+-0.0835195) 3.00007 (+-0.000553081)
found -7.36 (+-0.000456503) 14.9608 (+-0.0835748) 3.00012 (+-0.000553447)
found 1.28 (+-0.000451125) 14.9602 (+-0.0834467) 3.00002 (+-0.000552599)
found 2.24 (+-0.000455511) 14.9607 (+-0.0835534) 3.00011 (+-0.000553306)
found -8.32 (+-0.000559615) 9.97383 (+-0.0682455) 2.00008 (+-0.000451934)
found 0.319996 (+-0.000558723) 9.97383 (+-0.0682336) 2.00008 (+-0.000451855)
found 4.16 (+-0.000561619) 9.97399 (+-0.0682791) 2.00011 (+-0.000452156)
found 5.6 (+-0.000563707) 9.97414 (+-0.0683138) 2.00014 (+-0.000452386)
found 8.48 (+-0.000563757) 9.97414 (+-0.0683145) 2.00014 (+-0.000452391)
found -7.84 (+-0.000557572) 9.97368 (+-0.0682109) 2.00005 (+-0.000451705)
found -0.639999 (+-0.000804138) 4.98738 (+-0.0483675) 1.00013 (+-0.000320298)
found -5.43999 (+-0.000802725) 4.98738 (+-0.0483568) 1.00013 (+-0.000320228)
found -3.03999 (+-0.000802725) 4.98738 (+-0.0483568) 1.00013 (+-0.000320228)
found -9.75999 (+-0.000794002) 4.98708 (+-0.0482801) 1.00007 (+-0.000319719)
found 0.800001 (+-0.00079397) 4.98697 (+-0.0482773) 1.00005 (+-0.000319701)
found 1.76 (+-0.00079577) 4.98702 (+-0.0482926) 1.00006 (+-0.000319802)
#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 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()
#define dest(otri, vertexptr)