TTree - missing TLeaves

Hello Rooters,

I’m trying to create a TTree with a couple of branches. It’s difficult for me to include my code (too many lines and depends on other structures), so I’ll try to describe the situation as best I can.

I have classes
MyEvent
MyTrack1
MyTrack2
all derived from TObject, with private data members and public functions.

I have in my code

[code]MyEvent *mEvent = new MyEvent();
TClonesArray array1 = new TClonesArray(“MyTrack1”,100);
TClonesArray
array2 = new TClonesArray(“MyTrack2”,100);

TTree *mTree = new TTree(“MyTree”,“Tree”)
mTree->Branch(“Event”,“MyEvent”,&mEvent);
mTree->Branch(“Track1”,“MyTrack1”,&array1);
mTree->Branch(“Track2”,“MyTrack2”,&array2);[/code]

There’s a loop where I assign values to the members of mEvent and fill array1 and array2 with MyTrack1 and MyTrack2 objects whose members’ values are also assigned in this loop. At the end of every iteration, TTree::Fill and TTree::Write is called.

It doesn’t complain when it runs but when I check the output, I don’t actually get MyEvent and MyTrack1 objects. In their leaf list I only see fUniqueID and fBits. I get blanks when I do a TTree::Scan on any MyEvent or MyTrack1 member. Trying to call TTree::Draw on any member results in error messages of the following form:

Error in <TTreeFormula::DefinedVariable> MyEventMember is not a datamember of MyEvent Error in <TTreeFormula::Compile>: Bad numerical expression : "MyEvent.MyEventMember"

What I can’t understand is how it’s working fine for Track2 branch. I see all the data members of MyTrack2 as the leaves. MyTrack1 and MyTrack2 essentially have the same structures, just different members. MyEvent has similar structure as well.

I’ve made such a TTree before (just slightly different classes), and have the same steps to initialize, set branches, fill, write, etc. This is the first time the class members don’t show up.

Having different results for essentially the same process leaves me with no idea what the problem is or how to fix it.

Any insight on what’s going on here?

Regards,
Priscilla

We need the shortest possible running example reproducing this problem.

Rene

I’ll see what I can do.

[quote]It doesn’t complain when it runs but when I check the output, I don’t actually get MyEvent and MyTrack1 objects. In their leaf list I only see fUniqueID and fBits.[/quote]Did you generate, compile, link and load the dictionaries for MyEvent and Track1?

Cheers,
Philippe.

Apparently all I had to do was increment the ClassVersionID (it was 0) used in the ClassDef statement. I’m not even sure why I had it set to 0 to begin with.

Thanks for the time.

Regards,
Priscilla

[quote]Apparently all I had to do was increment the ClassVersionID (it was 0) used in the ClassDef statement[/quote]A class version of 0, explicitly request for the class content to not be streamed to disk ! :slight_smile:

Cheers,
Philippe.