53 for (
Int_t p=0;p<npeaks;p++) {
57#if defined(__PEAKS_C_FIT_AREAS__)
64void peaks(
Int_t np=10) {
66 TH1F *
h =
new TH1F(
"h",
"test",500,0,1000);
72 for (p=0;p<npeaks;p++) {
76#if defined(__PEAKS_C_FIT_AREAS__)
80 TF1 *
f =
new TF1(
"f",fpeaks,0,1000,2+3*npeaks);
82 f->SetParameters(par);
86 h->FillRandom(
"f",200000);
91 Int_t nfound =
s->Search(
h,2,
"",0.10);
92 printf(
"Found %d candidate peaks to fit\n",nfound);
94 TH1 *hb =
s->Background(
h,20,
"same");
100 TF1 *fline =
new TF1(
"fline",
"pol1",0,1000);
101 h->Fit(
"fline",
"qn");
107 xpeaks =
s->GetPositionX();
108 for (p=0;p<nfound;p++) {
110 Int_t bin =
h->GetXaxis()->FindBin(xp);
113 par[3*npeaks+2] = yp;
114 par[3*npeaks+3] = xp;
116#if defined(__PEAKS_C_FIT_AREAS__)
121 printf(
"Found %d useful peaks to fit\n",npeaks);
122 printf(
"Now fitting: Be patient\n");
123 TF1 *fit =
new TF1(
"fit",fpeaks,0,1000,2+3*npeaks);
R__EXTERN TRandom * gRandom
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
virtual void SetParameters(const Double_t *params)
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
virtual Double_t GetParameter(Int_t ipar) const
1-D histogram with a float per channel (see TH1 documentation)}
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.
virtual Double_t Rndm()
Machine independent random number generator.
Advanced Spectra Processing.
static TVirtualFitter * Fitter(TObject *obj, Int_t maxpar=25)
Static function returning a pointer to the current fitter.
static constexpr double s
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculate a gaussian function with mean and sigma.
Double_t Sqrt(Double_t x)
constexpr Double_t TwoPi()