Trouble with a fitting demo example from ROOT manual

From: Mushtari Afroz <>
Date: Tue, 19 Sep 2006 21:28:28 -0400 (EDT)


I am trying a fitting example from ROOT manual and it is giving me the following error message :

Non-static-const variable in array dimension FILE:background_fit.C LINE:44
 (cint allows this only in interactive command and special form macro which
  is special extension. It is not allowed in source code. Please ignore
  subsequent errors.)
*** Interpreter error recovered ***

ROOT version : Version 3.05/07 21 September 2003

In the ROOT session I am doing

root[0] .L background_fit.C
root[1] fittingDemo()

The codes is given below

#include "TFile.h"
#include "TH1.h"
#include "TF1.h"
#include "TCanvas.h"
#include "TString.h"
#include Riostream.h"
#include "TGraph.h"
#include "TStyle.h"
#include "TMath.h"

Double_t kTH = -0.5;
Double_t Background(Double_t *x, Double_t *par)
Double_t Gaussian(Double_t *x, Double_t *par)

par[0]*TMath::Exp(kTH*((x-par[1])/par[2])*((x-par[1])/par[2])); }


                         Double_t fitfunction(Double_t
*x, Double_t *par)

 Double_t tot = Background(x,par) +

   return tot;


void fittingDemo()
int nBins = 50;
 Stat_t data[nBins] =
{332,301,347,381,372,400,399,433,420,403,476,468,464,493,501,528, 577,646,687,759,875,903,1044,1183,1146,1106, 1152,1103,1126,975,875,820,738,746,677,695,655,645,621,621,594,600,609,584,615,$TH1F *histo = new TH1F("assignment","Gaussian Peak on a smooth

                         for (int i = 0.5;

histo->SetBinError(i,TMath::Sqrt(data[i])); }


TF1 *fitFcn = new TF1("fitFcn","fitFunction",0,3,6); histo->Fit("fitFcn");



Thank you.

Mushtari Afroz
Hons. BSc. Program
Trinity College, University of Toronto
Toronto, Canada.

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around Received on Wed Sep 20 2006 - 03:28:37 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET