How draw number of entries from TClonesArray object?

see $(ROOTSYS)/test/Event.*

If I need in my file output.root data only from Track class and number of tracks = fNtracks from TEvent class, is this way correct ?:

Event *event = new Event();
TTree *tree = new TTree("T","only tracks tree");
TClonesArray *c_tracks = event->GetTracks();

T.Branch("nt",event->GetNtrackAddress(),"nt/I"); // ?!

public function GetNtrackAddress() in Event class

   char *GetNtrackAddress() const { return (char*)&fNtracks; }

maybe exist other(better) way without serious re-write Event source code ?

We assume a file output.root has branch only from TClonesArray (see above) without information about number of tracks, how draw number of tracks = TClonessArray::GetEntriesFast
T->Draw(" ??? ")

Thanks and sorry to my poor English, Jan

You should make only one top level branch with your event pointer.
In turn, this will create subbranchs with each memeber of your class.
In this way you do not have to specify addresses of each member.
In case of a TClonesArray, you will see as many branches as you have data in your TClonesArray. See example in our standard test example
in $ROOTSYS/test/Event.cxx,MainEvent.cxx.
Use $ROOTSYS/test/Makefile as an example.


OK, but I need only one (or only two) member(s) of my class, for example fNtracks. How write this member(s) ?

  1. exist any way how draw TClonesArray::GetEntriesFast ? in this case I dont need write fNtracks = TClonesArray::GetEntriesFast

In your simple case, you can do:

For more complex cases we are planning on introducing the @ notation as follow:

When TTree::Draw see fCollection.Something (and fCollection is an STL Collection or a TClonesArray), it plots ‘Something’ for each elements. With the @ notation, when TTree::Draw will see @fCollection.Something it will plots ‘Something’ for the collection itself.