RE: [ROOT] Problem with TTree and Histograms

From: Philippe Canal (pcanal@fnal.gov)
Date: Mon Apr 30 2001 - 18:19:11 MEST


Hi,

This is a known problem in CINT that has been fixed in ROOT 3.0x.

In order to work around the problem you need to declare all the variables
you are using for the histograms (that's a good idea anyway).  So you code
now should look like:

  TH1F* Delta_R = new TH1F("Matched_Delta_R",
	"Delta R of matched generated electrons", nbins1,0,7.5);

Thanks,

Philippe.


-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Shawn Kwang
Sent: Monday, April 30, 2001 10:47 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] Problem with TTree and Histograms



I am having a problems with CINT and ROOT.

I have a function which declares a number of histograms (TH1F's).  In the
previous version of ROOT the code worked fine, but since we have upgraded,
something broke.  Specifically, there seems to be a problem with the TTree
variable (fChain is the variable name) and the Histogram declarations.

I added lines like this to my function to "debug" the value of fChain.

cout << "This is (1) " << fChain << endl;

Here is some code where I think things are breaking:

=====================================================

  cout << "This is (5) " << fChain << endl;

  //Declare Histograms

  Delta_R = new TH1F("Matched_Delta_R","Delta R of matched generated
electrons", nbins1,0,7.5);

...

  cout << "This is (6) " << fChain << endl;

=====================================================

Here is the corresponding output when I run this code:

=====================================================

This is (1) 0x8829380
This is (2) 0x8829380
This is (3) 0x8829380
This is (4) 0x8829380
This is (5) 0x8829380

Error: No symbol fChain in current scope
FILE:/home/skwang/Proj4/Pmcsana1.C LINE:84

This is (6) 0

Error: No symbol fChain in current scope
FILE:/home/skwang/Proj4/Pmcsana1.C LINE:90

Error: Failed to evaluate
fChain->GetEntry(jentry) FILE:/home/skwang/Proj4/Pmcsana1.C LINE:90
Possible candidates are...
filename       line:size busy function type and name

======================================================

As you can see the variable fChain is fine for the first 5 instances, but
as soon as I declare my histograms the variable "dies."

Line 84 is:
cout << "This is (6) " << fChain << endl;

Consequently, in line 90 when I need to use the variable fChain, my
program fails.

Line 90 is:
nb = fChain->GetEntry(jentry);

If I remove all my histogram declarations from my function the program
runs fine.

I am using ROOT version2.26/00 on a Linux (FermiLab) machine at the
University of Maryland.

Thanks in advance,
Shawn Kwang



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:44 MET