Hi Chris,
Thanks for sending the small script. The problem is simple.
When you use classes that request the graphics event loop, such as
the TreeViewer, you must have a TApplication object created to control
the event loop (or TRint to also get the CINT prompt).
For this reason, it is in general a bad idea to define your own main
program. It is better to submit this type of task with a simple 3 lines long
script from a standard ROOT session.
Your original script:
#include "TTree.h"
#include "TFile.h"
int main()
{
TFile *f = new TFile("chambers.root");
TTree *tree = (TTree*)f->Get("tree");
tree->StartViewer();
return 0;
}
The script modified to run correctly
#include "TTree.h"
#include "TFile.h"
#include "TRint.h"
int main()
{
TRint app("app",0,0);
TFile *f = new TFile("chambers.root");
TTree *tree = (TTree*)f->Get("tree");
tree->StartViewer();
app.Run();
return 0;
}
You better run the following script from a normal ROOT session
root > .x myscript.C
where myscript.C is
{
TFile *f = new TFile("chambers.root");
TTree *tree = (TTree*)f->Get("tree");
tree->StartViewer();
}
Rene Brun
Chris Hayward wrote:
>
> Hello ROOTers,
> I am using ROOT 3.05/07 with gcc 2.96 on lxplus.
>
> I have a program which creates a TTree fine, but when I load the TTree I
> get the following error message:
>
> Error in <TObjArray::At>: index 12 out of bounds (size: 13, this:
> 0x08971d20)
>
> I have looked at my arrays but I do not seem to be going out of bounds
> anywhere in my program. Is there a way for me to trace what object is at
> the given address? Is there some other way to find out what the problem
> is?
>
> Additionally, I would like to create a new tree on each run of my program
> and add it as a friend to the first tree. I would like to name them tree0,
> tree1, tree2, etc. Is there a simple way to keep a running count of trees
> in the file, i.e. some command that returns the number of trees stored?
>
> Thanks,
> Chris
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET