Problem with TTree->StartViewer()

Hi,

I have a mysterious problem.
I want to open a 20Go TFile composed by 3 TTree in order to “open” one of those TTree with “StartViewer()”.
I can do it without compiling, just by using this :

root [0] TFile f("solo_1.root")
(TFile &) Name: solo_1.root Title: 
root [1] TTree* t = (TTree*)f.Get("helium_tree");
root [2] t->StartViewer()
(TTreeViewer *) 0x36f06c0
File name : solo_1.root
root [3] Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

It worked perfectly. But when I want to compile a c++ program, I get a “segmentation violation”…
This is my program (named “main_class.cpp”) :

root [0] 
Processing main_class.cpp+...
Info in <TUnixSystem::ACLiC>: creating shared library /home/sncuser/William/main_enternship/./main_class_cpp.so
(TTreeViewer *) 0x3ac5c20
File name : solo_1.root
root [1] 
 *** Break *** segmentation violation

So I tried to use a 27Mo TFile called “solo_1.root” with the same TTrees but with less datas.
Unfortunatly, no change was noticed…

Did I make something wrong ?
To test, I give you main_class.cpp and solo_1.root.
Into main_class.cpp, there is the entire stack trace of the segv.

main_forum.cpp (4.3 KB)

http://ovh.to/sAXoLFL

Regard,
William

Hi William,

Try this way:

#include "TFile.h"
#include "TTree.h"

void main_forum()
{
   TFile *f = TFile::Open("solo_1.root");
   f->GetListOfKeys()->Print();
   TTree* t = (TTree*)f->Get("helium_tree");
   t->StartViewer();
}

Cheers, Bertrand.

1 Like

It worked…

I am so confused : this is a stupid mistake :slight_smile:

Thank you so much Bertrand for this quick responce !

Regard,
William.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.