created -9.88 99.7356 10
created -9.64 79.7885 8
created -9.4 19.9471 2
created -9.16 99.7356 10
created -8.92 39.8942 4
created -8.68 19.9471 2
created -8.44 69.8149 7
created -8.2 19.9471 2
created -7.96 9.97356 1
created -7.72 19.9471 2
created -7.48 69.8149 7
created -7.24 89.762 9
created -7 49.8678 5
created -6.76 69.8149 7
created -6.52 59.8413 6
created -6.28 79.7885 8
created -6.04 19.9471 2
created -5.8 69.8149 7
created -5.56 59.8413 6
created -5.32 89.762 9
created -5.08 49.8678 5
created -4.84 49.8678 5
created -4.6 89.762 9
created -4.36 79.7885 8
created -4.12 79.7885 8
created -3.88 99.7356 10
created -3.64 39.8942 4
created -3.4 89.762 9
created -3.16 89.762 9
created -2.92 99.7356 10
created -2.68 19.9471 2
created -2.44 59.8413 6
created -2.2 59.8413 6
created -1.96 29.9207 3
created -1.72 79.7885 8
created -1.48 49.8678 5
created -1.24 79.7885 8
created -1 29.9207 3
created -0.76 59.8413 6
created -0.52 29.9207 3
created -0.28 39.8942 4
created -0.04 69.8149 7
created 0.2 59.8413 6
created 0.44 29.9207 3
created 0.68 39.8942 4
created 0.92 29.9207 3
created 1.16 49.8678 5
created 1.4 99.7356 10
created 1.64 19.9471 2
created 1.88 19.9471 2
created 2.12 39.8942 4
created 2.36 29.9207 3
created 2.6 39.8942 4
created 2.84 39.8942 4
created 3.08 59.8413 6
created 3.32 29.9207 3
created 3.56 59.8413 6
created 3.8 39.8942 4
created 4.04 69.8149 7
created 4.28 49.8678 5
created 4.52 79.7885 8
created 4.76 9.97356 1
created 5 99.7356 10
created 5.24 59.8413 6
created 5.48 89.762 9
created 5.72 79.7885 8
created 5.96 19.9471 2
created 6.2 89.762 9
created 6.44 59.8413 6
created 6.68 59.8413 6
created 6.92 19.9471 2
created 7.16 19.9471 2
created 7.4 89.762 9
created 7.64 99.7356 10
created 7.88 29.9207 3
created 8.12 89.762 9
created 8.36 99.7356 10
created 8.6 79.7885 8
created 8.84 99.7356 10
created 9.08 19.9471 2
created 9.32 39.8942 4
created 9.56 89.762 9
created 9.8 99.7356 10
the total number of created peaks = 83 with sigma = 0.04
the total number of found peaks = 83 with sigma = 0.040002 (+-1.77401e-05)
fit chi^2 = 1.68563e-05
found -3.88 (+-0.000215252) 99.7337 (+-0.529336) 10.0003 (+-0.001839)
found -2.92 (+-0.000214968) 99.7334 (+-0.529261) 10.0003 (+-0.00183874)
found 7.64 (+-0.000215179) 99.7337 (+-0.529318) 10.0003 (+-0.00183893)
found 8.36 (+-0.000215824) 99.735 (+-0.52951) 10.0005 (+-0.0018396)
found 8.84 (+-0.000214875) 99.7332 (+-0.529231) 10.0003 (+-0.00183863)
found 9.8 (+-0.000213912) 99.7355 (+-0.52902) 10.0005 (+-0.0018379)
found -9.88 (+-0.000215332) 99.7327 (+-0.529314) 10.0002 (+-0.00183892)
found -9.16 (+-0.000214403) 99.7321 (+-0.529088) 10.0002 (+-0.00183813)
found 1.4 (+-0.000214542) 99.7323 (+-0.529129) 10.0002 (+-0.00183828)
found 5 (+-0.00021437) 99.7324 (+-0.529089) 10.0002 (+-0.00183814)
found -7.24 (+-0.000227095) 89.7606 (+-0.502225) 9.00032 (+-0.00174481)
found -5.32 (+-0.000226974) 89.7604 (+-0.502191) 9.00029 (+-0.00174469)
found -3.16 (+-0.000227883) 89.7625 (+-0.502447) 9.0005 (+-0.00174558)
found 5.48 (+-0.000227343) 89.7612 (+-0.502293) 9.00037 (+-0.00174505)
found -4.6 (+-0.000227207) 89.7609 (+-0.502256) 9.00034 (+-0.00174492)
found -3.4 (+-0.000227156) 89.7609 (+-0.502245) 9.00035 (+-0.00174488)
found 6.2 (+-0.000226409) 89.7596 (+-0.502046) 9.00021 (+-0.00174419)
found 7.4 (+-0.00022684) 89.7606 (+-0.502169) 9.00032 (+-0.00174461)
found 8.12 (+-0.00022707) 89.7609 (+-0.502226) 9.00035 (+-0.00174481)
found 9.56 (+-0.000227253) 89.7612 (+-0.502273) 9.00037 (+-0.00174498)
found -9.64 (+-0.000240787) 79.7876 (+-0.473496) 8.00032 (+-0.001645)
found -6.28 (+-0.000240307) 79.7865 (+-0.473372) 8.00021 (+-0.00164457)
found -4.36 (+-0.000241719) 79.7889 (+-0.473714) 8.00045 (+-0.00164576)
found -4.12 (+-0.000241827) 79.7892 (+-0.473743) 8.00048 (+-0.00164586)
found 5.72 (+-0.00024068) 79.7874 (+-0.473467) 8.00029 (+-0.0016449)
found 8.6 (+-0.000242053) 79.7897 (+-0.473801) 8.00053 (+-0.00164606)
found -1.72 (+-0.000240411) 79.7865 (+-0.473392) 8.00021 (+-0.00164464)
found -1.24 (+-0.000240411) 79.7865 (+-0.473392) 8.00021 (+-0.00164464)
found 4.52 (+-0.0002398) 79.786 (+-0.473259) 8.00016 (+-0.00164418)
found -8.44 (+-0.000256249) 69.8124 (+-0.442663) 7.0001 (+-0.00153788)
found -7.48 (+-0.00025753) 69.8143 (+-0.442938) 7.00029 (+-0.00153884)
found -6.76 (+-0.000257808) 69.8143 (+-0.442986) 7.00029 (+-0.001539)
found -5.8 (+-0.000257108) 69.8135 (+-0.442843) 7.00021 (+-0.00153851)
found -0.0399995 (+-0.000257617) 69.814 (+-0.442946) 7.00026 (+-0.00153886)
found 4.04 (+-0.000257448) 69.8138 (+-0.442909) 7.00024 (+-0.00153873)
found 5.24 (+-0.000280105) 59.8434 (+-0.410443) 6.00051 (+-0.00142594)
found 6.44 (+-0.000279469) 59.8423 (+-0.410319) 6.0004 (+-0.00142551)
found -6.52 (+-0.000279495) 59.8423 (+-0.410323) 6.0004 (+-0.00142553)
found -5.56 (+-0.000279647) 59.8426 (+-0.410353) 6.00042 (+-0.00142563)
found -2.2 (+-0.000278306) 59.8407 (+-0.410099) 6.00024 (+-0.00142475)
found -0.76 (+-0.000277639) 59.8399 (+-0.409975) 6.00016 (+-0.00142432)
found 0.199999 (+-0.000278482) 59.841 (+-0.410133) 6.00027 (+-0.00142487)
found 3.08 (+-0.000277894) 59.8402 (+-0.410021) 6.00019 (+-0.00142448)
found 3.56 (+-0.000277894) 59.8402 (+-0.410021) 6.00019 (+-0.00142448)
found 6.68 (+-0.000277984) 59.8404 (+-0.410043) 6.00021 (+-0.00142455)
found -2.44 (+-0.000277984) 59.8405 (+-0.410043) 6.00021 (+-0.00142455)
found -7 (+-0.000306859) 49.8695 (+-0.374685) 5.00043 (+-0.00130171)
found -5.08 (+-0.000306416) 49.869 (+-0.374613) 5.00037 (+-0.00130147)
found -4.84 (+-0.000306416) 49.869 (+-0.374613) 5.00037 (+-0.00130147)
found -1.48 (+-0.000306873) 49.8695 (+-0.374687) 5.00042 (+-0.00130172)
found 1.16 (+-0.000306017) 49.8687 (+-0.374554) 5.00035 (+-0.00130126)
found 4.28 (+-0.00030668) 49.8692 (+-0.374655) 5.0004 (+-0.00130161)
found -8.92 (+-0.000342357) 39.8954 (+-0.335046) 4.00032 (+-0.001164)
found -3.64 (+-0.000344518) 39.8973 (+-0.335321) 4.00051 (+-0.00116496)
found -0.279998 (+-0.000342163) 39.8949 (+-0.335011) 4.00027 (+-0.00116388)
found 0.68 (+-0.000340941) 39.8938 (+-0.334853) 4.00016 (+-0.00116333)
found 2.6 (+-0.000341309) 39.8941 (+-0.334899) 4.00019 (+-0.00116349)
found 2.84 (+-0.000342278) 39.8949 (+-0.335024) 4.00027 (+-0.00116392)
found 3.8 (+-0.00034314) 39.8957 (+-0.335136) 4.00035 (+-0.00116431)
found 2.12 (+-0.000340488) 39.8935 (+-0.334798) 4.00013 (+-0.00116314)
found 9.32 (+-0.000342155) 39.8952 (+-0.335018) 4.0003 (+-0.0011639)
found -1 (+-0.00039771) 29.9229 (+-0.290386) 3.00037 (+-0.00100885)
found 7.88 (+-0.00039918) 29.9242 (+-0.290537) 3.00051 (+-0.00100937)
found -1.96 (+-0.00039771) 29.9229 (+-0.290386) 3.00037 (+-0.00100885)
found -0.520001 (+-0.000396281) 29.9218 (+-0.290243) 3.00027 (+-0.00100835)
found 0.439999 (+-0.000396281) 29.9218 (+-0.290243) 3.00027 (+-0.00100835)
found 3.32 (+-0.00039707) 29.9223 (+-0.290321) 3.00032 (+-0.00100862)
found 0.920001 (+-0.000395912) 29.9216 (+-0.290206) 3.00024 (+-0.00100822)
found 2.36 (+-0.000395497) 29.9213 (+-0.290164) 3.00021 (+-0.00100808)
found -9.4 (+-0.000491134) 19.9509 (+-0.23738) 2.00048 (+-0.000824696)
found -6.04 (+-0.00048995) 19.9501 (+-0.237296) 2.0004 (+-0.000824404)
found -2.68 (+-0.000490224) 19.9504 (+-0.237317) 2.00043 (+-0.000824477)
found 1.63999 (+-0.000487493) 19.9493 (+-0.237138) 2.00032 (+-0.000823854)
found 5.96 (+-0.000490773) 19.9506 (+-0.237354) 2.00045 (+-0.000824606)
found 9.07999 (+-0.000489078) 19.9499 (+-0.23724) 2.00038 (+-0.000824209)
found -8.20001 (+-0.000485147) 19.9482 (+-0.236982) 2.00021 (+-0.000823313)
found 6.92 (+-0.000485867) 19.9483 (+-0.237021) 2.00022 (+-0.000823448)
found -8.68 (+-0.000487908) 19.949 (+-0.237156) 2.00029 (+-0.000823917)
found 1.88 (+-0.00048475) 19.9477 (+-0.236944) 2.00016 (+-0.000823181)
found 7.16001 (+-0.000487139) 19.9491 (+-0.237112) 2.0003 (+-0.000823764)
found -7.71999 (+-0.000485147) 19.9483 (+-0.236982) 2.00022 (+-0.000823313)
found 4.76 (+-0.000701822) 9.97785 (+-0.168122) 1.00048 (+-0.000584083)
found -7.96 (+-0.000687745) 9.97414 (+-0.167617) 1.00011 (+-0.000582327)
#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;
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 [] 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)}
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.
static constexpr double s
constexpr Double_t Sqrt2()
Double_t Sqrt(Double_t x)
constexpr Double_t TwoPi()
#define dest(otri, vertexptr)