created -9.76 19.9471 4
created -9.28 14.9603 3
created -8.8 44.881 9
created -8.32 49.8678 10
created -7.84 49.8678 10
created -7.36 34.9074 7
created -6.88 34.9074 7
created -6.4 34.9074 7
created -5.92 39.8942 8
created -5.44 24.9339 5
created -4.96 24.9339 5
created -4.48 34.9074 7
created -4 19.9471 4
created -3.52 4.98678 1
created -3.04 29.9207 6
created -2.56 39.8942 8
created -2.08 39.8942 8
created -1.6 4.98678 1
created -1.12 24.9339 5
created -0.64 9.97356 2
created -0.16 14.9603 3
created 0.32 34.9074 7
created 0.8 49.8678 10
created 1.28 19.9471 4
created 1.76 24.9339 5
created 2.24 34.9074 7
created 2.72 9.97356 2
created 3.2 44.881 9
created 3.68 44.881 9
created 4.16 49.8678 10
created 4.64 29.9207 6
created 5.12 44.881 9
created 5.6 44.881 9
created 6.08 24.9339 5
created 6.56 4.98678 1
created 7.04 14.9603 3
created 7.52 34.9074 7
created 8 14.9603 3
created 8.48 34.9074 7
created 8.96 34.9074 7
created 9.44 39.8942 8
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.69247e-05)
fit chi^2 = 4.50622e-06
found -8.32 (+-0.000234395) 49.8681 (+-0.143648) 10.0002 (+-0.000951265)
found -7.84 (+-0.000234175) 49.868 (+-0.143631) 10.0002 (+-0.000951152)
found 0.8 (+-0.000233435) 49.8677 (+-0.143575) 10.0001 (+-0.000950782)
found 4.16 (+-0.000233951) 49.8679 (+-0.143614) 10.0002 (+-0.000951039)
found -8.8 (+-0.000246376) 44.8811 (+-0.136231) 9.00013 (+-0.000902143)
found 3.2 (+-0.000246019) 44.881 (+-0.136207) 9.00011 (+-0.000901989)
found 3.68 (+-0.000247286) 44.8814 (+-0.136292) 9.00019 (+-0.000902548)
found 5.12 (+-0.000246799) 44.8812 (+-0.136258) 9.00015 (+-0.000902323)
found 5.6 (+-0.000246646) 44.8811 (+-0.136247) 9.00014 (+-0.000902255)
found -5.92 (+-0.000261573) 39.8943 (+-0.128453) 8.00012 (+-0.000850638)
found -2.56 (+-0.000261881) 39.8944 (+-0.128472) 8.00014 (+-0.000850763)
found -2.08 (+-0.000260633) 39.8941 (+-0.128401) 8.00009 (+-0.000850295)
found 9.44 (+-0.000259476) 39.8944 (+-0.128347) 8.00015 (+-0.00084994)
found -7.36 (+-0.000280707) 34.9078 (+-0.120215) 7.00017 (+-0.000796088)
found -6.88 (+-0.000280274) 34.9077 (+-0.120191) 7.00014 (+-0.000795928)
found -6.4 (+-0.00028043) 34.9077 (+-0.1202) 7.00015 (+-0.000795985)
found -4.48 (+-0.000279337) 34.9074 (+-0.120141) 7.00009 (+-0.000795594)
found 0.320001 (+-0.000279873) 34.9076 (+-0.120171) 7.00013 (+-0.000795797)
found 2.24 (+-0.000278773) 34.9073 (+-0.120112) 7.00007 (+-0.000795405)
found 7.52 (+-0.000278619) 34.9073 (+-0.120103) 7.00006 (+-0.000795347)
found 8.48 (+-0.000279443) 34.9075 (+-0.120147) 7.0001 (+-0.000795637)
found 8.96 (+-0.00028043) 34.9078 (+-0.1202) 7.00015 (+-0.000795985)
found 4.64 (+-0.000303961) 29.9212 (+-0.111335) 6.00019 (+-0.000737278)
found -3.04 (+-0.000301489) 29.9207 (+-0.111223) 6.00009 (+-0.000736538)
found -5.44 (+-0.000332315) 24.9342 (+-0.101608) 5.00013 (+-0.000672865)
found 6.08 (+-0.000330859) 24.9341 (+-0.101556) 5.0001 (+-0.000672521)
found -4.96 (+-0.000332107) 24.9342 (+-0.101599) 5.00012 (+-0.000672809)
found -1.12 (+-0.000328956) 24.9337 (+-0.101481) 5.00003 (+-0.000672024)
found 1.76 (+-0.000331816) 24.9341 (+-0.101588) 5.00011 (+-0.000672735)
found -4 (+-0.000370053) 19.9473 (+-0.0908378) 4.00008 (+-0.000601544)
found 1.28 (+-0.000372752) 19.9476 (+-0.0909208) 4.00015 (+-0.000602094)
found -9.76 (+-0.000369466) 19.947 (+-0.0908086) 4.00003 (+-0.000601351)
found -9.28 (+-0.000430993) 14.9608 (+-0.0787544) 3.00013 (+-0.000521526)
found 8 (+-0.000431583) 14.9608 (+-0.0787682) 3.00014 (+-0.000521617)
found -0.159998 (+-0.000429179) 14.9606 (+-0.0787107) 3.00009 (+-0.000521236)
found 7.04 (+-0.000428251) 14.9605 (+-0.0786906) 3.00008 (+-0.000521103)
found -0.640001 (+-0.000527592) 9.97383 (+-0.0642978) 2.00008 (+-0.000425791)
found 2.72 (+-0.000531974) 9.97424 (+-0.0643729) 2.00016 (+-0.000426289)
found -1.6 (+-0.000757357) 4.98738 (+-0.0455643) 1.00013 (+-0.000301735)
found 6.56 (+-0.000752159) 4.98712 (+-0.0455173) 1.00008 (+-0.000301424)
found -3.52 (+-0.000754514) 4.98722 (+-0.0455382) 1.0001 (+-0.000301562)
#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)