[ROOT] TClonesArray question: vectors ok?

From: Dr. John Krane (jkrane@netzero.com)
Date: Wed Jul 02 2003 - 19:36:10 MEST


Hi,

I'm trying to create arbitrary numbers of TClonesArrays, one for each 
name in a file.  So, my solution looks something like:

Char stk[80];
vector<TClonesArray*> vh1;
vector<MyObj*> com;
vector<TBranch*> b;
Int_t count=0;
while (1) {
	in >> stk;
	if (!in.good()) break;
	vh1.push_back( new TClonesArray("TradeEvent",10) );
	com.push_back( new MyObj() );
	(com[count])->set_theArray(vh1[count]);

	b.push_back(  tree->Branch( "this", "that",
			&(com[count]), bufsize, 2)  );
	...etc.
	count++
}


So I'm using "new" to just feed my vectors as many times as I have names 
in the file.  It occured to me that doing things this way might confuse 
root even though it works within the scope of my file.  Could you please 
either reassure me that this should be OK with root or let me know that 
this is probably not the right way.  Specifically, my code chokes at 
tree->Fill() in a place where it is working with the TClonesArray.  If 
the above looks fine, I have another problem somewhere.

	- John



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET