Classes inside trees: problem with Draw()

Following the example with “Event” class in “Tree” chapter of the user guide, i included tree istances of my class in a tree.

You can see the output of tree.Print() in the first attachment and the definition of my “GenericDAQBoard” class in the second attachment.

Inside the class, i have a variable lenght array:

Int_t* iValue; //nData

According to the manual, i can plot all the elements of this array simply using:

tree.Draw(“TDC1.iValue”)

But in this way i get only the first element of the array each entry. In fact i get the same histogram of:

tree.Draw(“TDC1.iValue[0]”)

while if i do:

tree.Draw(“TDC1.iValue[1]”, “TDC1.nData>=2”)
(or any other following element)

i get empty histograms.

But tree is correctly filled with values also in the next elements of these arrays, as u can check with the output of tree.Show (included in the third attachment)

Where am I wrong?

Thx a lot
TreeShowOutput.txt (974 Bytes)
ClassDefinitions.txt (1.32 KB)
TreePrintOutput.txt (7.03 KB)

Hi,

The problem is likely that TTree::Draw is getting ‘confused’ between all the branch that are named nData.

I recommend that you produce your tree suffixing your branch name with a dot:mytree->Branch("TDC2.",&mypointer);

Cheers,
Philippe.

Thx Philippe,
but i still have the same problem.

I tried also to remove all but one istance of such class, to avoid any confusion.

In the macro, i declare:

class GenericDAQBoard* TDC1 = new GenericDAQBoard();

and i add a branch in the tree using (i leave default split lvl, is it important?):

CosmicRaysRun.Branch("TDC1", "GenericDAQBoard", & TDC1);
  • or (as suggested) -
CosmicRaysRun.Branch("TDC1.", "GenericDAQBoard", & TDC1);

Also in the 2nd case only the first element of the array is drawn, but the output of Show() is changed (worse because the array variables miss):

root [1] CosmicRaysRun.Show(10,1000)
======> EVENT:10
 iEvt            = 11
 Trig            = 0

 [.. not different ..]

 TDC1.           = NULL
 TDC1.nData      = 7

(i checked the object TDC1 before calling tree.Fill() during debug and it is filled)

With only one instance of such class my code seems very similar to the one of the example… is possible that i have to derive my class from TObject?

Humm … strange :slight_smile:

Could you please try with ROOT 5.10/00?

Could you please send us a way to reproduce your problem?

Thanks,
Philippe.

I send you all source files and a ¨reduced¨ raw data file (in a tgz renamed as tar because .tgz is not allowed)

The ROOT version i’m using is:
Version 4.03/04 12 April 2005
CINT/ROOT C/C++ Interpreter version 5.15.169, Mar 14 2005

I’ll update it to ROOT 5, but i cannot do it immediately (the machine where it runs is not mine)
CR.tar (6.89 KB)

Simply replace

UInt_t nData;with

Currently the index has to be a Int_t (or int).

Sorry for the inconvenience :frowning:

Cheers,
Philippe.

Thank you very much.
I think it would be very useful to add this information as a note in the user guide or some other place in the docs, if possible.

bye
Matteo