53 for (
Int_t p = 0; p < npeaks; p++) {
57#if defined(__PEAKS_C_FIT_AREAS__)
64void peaks(
Int_t np = 10)
67 TH1F *
h =
new TH1F(
"h",
"test", 500, 0, 1000);
73 for (p = 0; p < npeaks; p++) {
75 par[3 * p + 3] = 10 +
gRandom->Rndm() * 980;
76 par[3 * p + 4] = 3 + 2 *
gRandom->Rndm();
77#if defined(__PEAKS_C_FIT_AREAS__)
81 TF1 *
f =
new TF1(
"f", fpeaks, 0, 1000, 2 + 3 * npeaks);
83 f->SetParameters(par);
87 h->FillRandom(
"f", 200000);
93 printf(
"Found %d candidate peaks to fit\n", nfound);
103 TF1 *fline =
new TF1(
"fline",
"pol1", 0, 1000);
104 h->Fit(
"fline",
"qn");
111 for (p = 0; p < nfound; p++) {
113 Int_t bin =
h->GetXaxis()->FindBin(xp);
117 par[3 * npeaks + 2] = yp;
118 par[3 * npeaks + 3] = xp;
119 par[3 * npeaks + 4] = 3;
120#if defined(__PEAKS_C_FIT_AREAS__)
125 printf(
"Found %d useful peaks to fit\n", npeaks);
126 printf(
"Now fitting: Be patient\n");
127 TF1 *fit =
new TF1(
"fit", fpeaks, 0, 1000, 2 + 3 * npeaks);
int Int_t
Signed integer 4 bytes (int).
double Double_t
Double 8 bytes.
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
virtual void SetNpx(Int_t npx=100)
virtual void SetParameters(const Double_t *params)
virtual Double_t GetParameter(Int_t ipar) const
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
Advanced Spectra Processing.
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
One-dimensional peak search function.
Double_t * GetPositionX() const
virtual TH1 * Background(const TH1 *hist, Int_t nIter=20, Option_t *option="")
One-dimensional background estimation function.
static TVirtualFitter * Fitter(TObject *obj, Int_t maxpar=25)
Static function returning a pointer to the current fitter.
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculates a gaussian function with mean and sigma.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
constexpr Double_t TwoPi()