40 TH1F *FitAwmi_Create_Spectrum(
void) {
43 delete gROOT->FindObject(
"h");
44 TH1F *
h =
new TH1F(
"h",
"simulated spectrum", nbins, xmin,
xmax);
46 TF1 f(
"f",
"TMath::Gaus(x, [0], [1], 1)", xmin,
xmax);
53 while (
xmax > (xmin + 6. * sigma)) {
56 f.SetParameters(xmin, sigma);
59 std::cout <<
"created " 65 std::cout <<
"the total number of created peaks = " << npeaks
66 <<
" with sigma = " << sigma << std::endl;
72 TH1F *h = FitAwmi_Create_Spectrum();
75 if (!cFit) cFit =
new TCanvas(
"cFit",
"cFit", 10, 10, 1000, 700);
84 for (i = 0; i < nbins; i++) source[i] = h->
GetBinContent(i + 1);
91 for(i = 0; i < nfound; i++) FixAmp[i] = FixPos[i] =
kFALSE;
96 for (i = 0; i < nfound; i++) {
97 bin = 1 +
Int_t(Pos[i] + 0.5);
113 delete gROOT->FindObject(
"d");
115 for (i = 0; i < nbins; i++) d->
SetBinContent(i + 1, source[i]);
123 sigma *= dx; sigmaErr *= dx;
125 std::cout <<
"the total number of found peaks = " << nfound
126 <<
" with sigma = " << sigma <<
" (+-" << sigmaErr <<
")" 128 std::cout <<
"fit chi^2 = " << pfit->
GetChi() << std::endl;
129 for (i = 0; i < nfound; i++) {
130 bin = 1 +
Int_t(Positions[i] + 0.5);
135 Positions[i] = x1 + Positions[i] * dx;
136 PositionsErrors[i] *= dx;
138 AreasErrors[i] *= dx;
140 std::cout <<
"found " 141 << Positions[i] <<
" (+-" << PositionsErrors[i] <<
") " 142 << Amplitudes[i] <<
" (+-" << AmplitudesErrors[i] <<
") " 143 << Areas[i] <<
" (+-" << AreasErrors[i] <<
")" virtual void SetNameTitle(const char *name, const char *title)
Change the name and title of this histogram.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Double_t * GetAmplitudes() const
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
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:
constexpr Double_t Sqrt2()
constexpr Double_t TwoPi()
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
1-D histogram with a float per channel (see TH1 documentation)}
Double_t * GetAreasErrors() const
virtual void Reset(Option_t *option="")
Reset.
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
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)
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Double_t * GetPositionX() const
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Double_t * GetAmplitudesErrors() const
Double_t * GetPositions() const
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
R__EXTERN TRandom * gRandom
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:
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
A PolyMarker is defined by an array on N points in a 2-D space.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
static const double x1[5]
Double_t * GetPositionsErrors() const
static constexpr double s
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Advanced Spectra Processing.
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 if errors are defined (see TH1::Sumw2), errors are also recalculated.
Double_t * GetAreas() const
virtual void Add(TObject *obj)
Advanced 1-dimensional spectra fitting functions.
#define dest(otri, vertexptr)
virtual Int_t GetNbinsX() const
Double_t Sqrt(Double_t x)
void GetSigma(Double_t &sigma, Double_t &sigmaErr)
This function gets the sigma parameter and its error.
TList * GetListOfFunctions() const
void FitAwmi(Double_t *source)
This function fits the source spectrum.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.