[ROOT] Problems with TTree

From: Flath, Daniel (dflath@SLAC.stanford.edu)
Date: Fri Jun 08 2001 - 06:27:45 MEST


Dear Rooters,

I'm having trouble using some of the functionality of the TTree class.  Specifically, I'd like to store the branches of a TTree in files separate from that containing the TTree itself.  I am able to do this successfully if I create the branches (which store TObject descendants) with split mode turned off.  It is very desirable to me to keep split mode on since the class members in sub branches are often large and slow down analysis significantly.  With split mode those sub branches not being analyzed can be turned off and the analysis is much quicker.  If I turn split mode on, however, one large root file is generated containing tree and branches.

Unfortunately, the code is complex, so I will include here a small piece of code detailing what I do.  Any input on why this occurs would be greatly appreciated.


My thanks in advance,

Dan.

/////////////////////////////// BEGIN CODE ////////////////////////////////////
class A: public TObject {/*A's guts*/};
class B: public TObject {/*B's guts*/};

int 	buffsize = 3200,
	compress = 1,
	split = 1;

A *a = new A();
a->Create();
B *b = new B();
b->Create();
TFile *f = new TFile("tree_file.root", "RECREATE", "tree file", compress);
TTree *tree = new TTree("T", "root tree");
tree->Branch("branch_a", "A", &a, buffsize, split);
tree->Branch("branch_b", "B", &b, buffsize, split);
tree->GetBranch("branch_a")->SetFile("a_file.root");
tree->GetBranch("branch_b")->SetFile("b_file.root");

for (int i=0; i<100; i++) {
	a->Clean();  a->Create();
	b->Clean();  b->Create();

	// set members of a & b

	tree->Fill();
}
f->Write();
f->Close();
//////////////////////////////// END CODE /////////////////////////////////////


Daniel Flath
<dflath@slac.stanford.edu>
(650).926.8794



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