created -9.76 49.8678 10
created -9.28 34.9074 7
created -8.8 19.9471 4
created -8.32 39.8942 8
created -7.84 4.98678 1
created -7.36 49.8678 10
created -6.88 39.8942 8
created -6.4 49.8678 10
created -5.92 4.98678 1
created -5.44 39.8942 8
created -4.96 19.9471 4
created -4.48 19.9471 4
created -4 29.9207 6
created -3.52 19.9471 4
created -3.04 29.9207 6
created -2.56 34.9074 7
created -2.08 49.8678 10
created -1.6 44.881 9
created -1.12 39.8942 8
created -0.64 44.881 9
created -0.16 24.9339 5
created 0.32 39.8942 8
created 0.8 4.98678 1
created 1.28 29.9207 6
created 1.76 34.9074 7
created 2.24 4.98678 1
created 2.72 24.9339 5
created 3.2 29.9207 6
created 3.68 49.8678 10
created 4.16 9.97356 2
created 4.64 29.9207 6
created 5.12 34.9074 7
created 5.6 34.9074 7
created 6.08 49.8678 10
created 6.56 29.9207 6
created 7.04 44.881 9
created 7.52 4.98678 1
created 8 34.9074 7
created 8.48 4.98678 1
created 8.96 9.97356 2
created 9.44 14.9603 3
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-1.70199e-05)
fit chi^2 = 1.76989e-06
found -9.76 (+-0.000146408) 49.8675 (+-0.0899809) 10.0001 (+-0.00059587)
found -7.36 (+-0.000145914) 49.8676 (+-0.0899549) 10.0001 (+-0.000595698)
found -6.4 (+-0.000145914) 49.8676 (+-0.0899549) 10.0001 (+-0.000595698)
found -2.08 (+-0.000146698) 49.8679 (+-0.0900104) 10.0002 (+-0.000596065)
found 3.68 (+-0.000145961) 49.8675 (+-0.0899563) 10.0001 (+-0.000595707)
found 6.08 (+-0.000146482) 49.8678 (+-0.0899939) 10.0001 (+-0.000595956)
found -1.6 (+-0.000154904) 44.8813 (+-0.0854103) 9.00018 (+-0.000565602)
found -0.64 (+-0.000154503) 44.8811 (+-0.0853826) 9.00013 (+-0.000565419)
found 7.04 (+-0.000153734) 44.8808 (+-0.0853333) 9.00007 (+-0.000565093)
found -8.32 (+-0.000162939) 39.8939 (+-0.0804454) 8.00005 (+-0.000532724)
found -6.88 (+-0.000164617) 39.8947 (+-0.0805456) 8.0002 (+-0.000533387)
found -5.44 (+-0.000162939) 39.8939 (+-0.0804454) 8.00005 (+-0.000532724)
found -1.12 (+-0.000164467) 39.8946 (+-0.080536) 8.00018 (+-0.000533324)
found 0.319999 (+-0.000163058) 39.894 (+-0.0804526) 8.00006 (+-0.000532771)
found -9.28 (+-0.000175559) 34.9077 (+-0.0753209) 7.00014 (+-0.000498788)
found -2.56 (+-0.000175815) 34.9078 (+-0.0753344) 7.00016 (+-0.000498878)
found 1.76 (+-0.000174558) 34.9073 (+-0.0752692) 7.00007 (+-0.000498446)
found 5.12 (+-0.000175543) 34.9076 (+-0.0753192) 7.00013 (+-0.000498777)
found 5.6 (+-0.000175922) 34.9078 (+-0.0753402) 7.00017 (+-0.000498917)
found 8 (+-0.000173692) 34.9071 (+-0.0752251) 7.00002 (+-0.000498154)
found 6.56 (+-0.000190495) 29.9212 (+-0.0697745) 6.00019 (+-0.00046206)
found -4 (+-0.000189143) 29.9207 (+-0.0697106) 6.00008 (+-0.000461636)
found -3.04 (+-0.000189555) 29.9208 (+-0.0697298) 6.00011 (+-0.000461763)
found 1.28 (+-0.000188836) 29.9207 (+-0.0696992) 6.00008 (+-0.000461561)
found 3.2 (+-0.000190019) 29.921 (+-0.069752) 6.00015 (+-0.00046191)
found 4.64 (+-0.000189148) 29.9207 (+-0.069712) 6.00009 (+-0.000461645)
found -0.16 (+-0.000208821) 24.9344 (+-0.063701) 5.00017 (+-0.00042184)
found 2.72 (+-0.000206966) 24.9339 (+-0.0636301) 5.00007 (+-0.00042137)
found -8.8 (+-0.000233697) 19.9476 (+-0.0569835) 4.00015 (+-0.000377355)
found -4.96 (+-0.000233106) 19.9475 (+-0.0569645) 4.00012 (+-0.000377229)
found -3.52 (+-0.000233191) 19.9475 (+-0.0569668) 4.00012 (+-0.000377245)
found -4.48 (+-0.000232776) 19.9474 (+-0.0569536) 4.0001 (+-0.000377157)
found 9.44 (+-0.000265289) 14.9604 (+-0.049251) 3.00005 (+-0.000326149)
found 4.16 (+-0.00033332) 9.97424 (+-0.0403421) 2.00016 (+-0.000267153)
found 8.96 (+-0.000328372) 9.97363 (+-0.0402598) 2.00004 (+-0.000266608)
found -7.84 (+-0.000477246) 4.98763 (+-0.0285798) 1.00018 (+-0.000189261)
found -5.92 (+-0.000477246) 4.98763 (+-0.0285798) 1.00018 (+-0.000189261)
found 7.52 (+-0.000476304) 4.98753 (+-0.0285709) 1.00016 (+-0.000189202)
found 0.799997 (+-0.000475276) 4.98743 (+-0.0285613) 1.00014 (+-0.000189138)
found 2.24 (+-0.00047414) 4.98733 (+-0.0285509) 1.00012 (+-0.000189069)
found 8.47999 (+-0.000471475) 4.98717 (+-0.028528) 1.00009 (+-0.000188918)
#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;
}
static const double x1[5]
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)}
virtual TObject * FindObject(const char *name) const
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)
constexpr Double_t TwoPi()
#define dest(otri, vertexptr)