I recently posted (errantly) the following bug report (the solution is posted below the report) and I wish to discuss it further. When I use the TTreePlayer::Draw,Scan functions, I have the difficulty mentioned below. But when I use the TTree->GetEntry() function and read the tree data into my objects, I get the correct object data. Why does this work?
Also, the Scan and Draw functions worked correctly in previous versions of root for my initial code. Why did this work then but not now?
Beau
-----Original Message-----
Maybe this is already known, but I found a problem in the
TTreePlayer::Draw/Scan functions. It seems that when you store two objects
of the same class onto a tree, these functions can only see one of the
objects. What I mean is this. Lets say i have two objects of type
emcPhoton, which contains a public data member float e. Also, I have a TTree
named emcttree.
emcPhoton* emcph1 = new emcPhoton();
emcPhoton* emcph2 = new emcPhoton();
emcttree->Branch(“emcph1”,“emcPhoton”,&emcph1);
emcttree->Branch(“emcph2”,“emcPhoton”,&emcph2);
emcph1->e = 2;
emcph2->e = 5;
emcttree->Fill();
If I now use the scan or draw functions, then the output for
emctree->Scan(“emcph1.e:emcph2.e”) would be
- Row * emcph1.e * emcph2.e *
-
0 * 2 * 2 *
I have no problem with say version 5.15.
///solution starts here----------------------------------------
Posted by: Rene Brun
Related to: [ROOT bugs #42195] TTreePlayer::Draw/Scan produce bad output for
objects
URL: http://savannah.cern.ch/bugs/?42195
Follow-up Comment:
When creating your branches, do
emcttree->Branch(“emcph1.”,“emcPhoton”,&emcph1);
emcttree->Branch(“emcph2.”,“emcPhoton”,&emcph2);
Note the “.” at the end of the branch name ansd see the explanation in the
TTree documentation.
Rene