more queries on using CINT & Root macros

Richard Dubois (richard@SLAC.stanford.edu)
Sun, 04 Apr 1999 20:03:26 -0700


I am finding that CINT/Root usage is *very* non-intuitive. I believe
(and said as much at the Root meeting) that Root really needs to provide
a way for the person who 'just wants to do analysis' to not have to
figure out so many obscure details.

Most of the details that bother me are the ones involved with iterating
(debugging) a macro. When does one do a gROOT->Reset()? When does one
delete the TFile - the TBrowser can end up showing several Root files if
one doesn't? What about deleting the histograms - I have seen cases
where I have big scatter plots and the machine memory gets exhausted
after a few iterations? If I do a Reset, my TBrowser goes away; then I
have to navigate back to the Root file to see my histograms (do-able,
but annoying after a few times!).

Here are some specific items illustrating my point.

I sent in an item last month on a helper class I'm trying to write to
help users do the simple things in analyzing data with CINT. The item is

http://root.cern.ch/root/roottalk/roottalk99/0577.html

The essence of it is to give the user a specific spot to put in his
histogram definitions and event loop code. The helper class then takes
care of opening/closing (T)files, rewinding, clearing histograms etc.

I thought I had it working before the Root meeting, but now it seems
not to. Since I didn't know why it worked the first time (scope of the
histogram pointers), I don't know why it is failing now! The hitch is
that it 'forgets' the histogram pointers the 2nd time through Go(); it
says that the Fill() method cannot be called for the helper class.

However, I've found that if I once interactively reference all the
histograms (eg Fred->Draw()) after the first Go(), then the helper class
is happy for all future Go's. Obviously, Root is treating the histograms
specially concerning scope, but I can't figure out how...

Next: I'd like to use a script to do some things I want to do
repetitively when debugging a macro. Even typing up-arrow is getting
tiresome when 6-10 lines are being repeated.

I want to .L a couple of macro files, then create some objects from the
classes I loaded, then use those objects. I cannot find a combination
where I can mix commands to CINT and C++ code. For example, I'd like to
do

.x LoadSharedLibs
.L MyEvent.C
.L EventDisplay.C
MyEvent* m = new MyEvent("rootfile.root");
EventDisplay* ed = new EventDisplay(m);
m->Go(1);
ed->Draw();

How can I get these commands into the smallest number of files (one or
two)?

Richard

--
Richard Dubois
SLD, Stanford Linear Accelerator Center
Richard@slac.stanford.edu
http://www.slac.stanford.edu/~richard/
650-926-3824
650-926-2923 (FAX)