I have in my tree several variable length arrays, similar to the examples given in the manual:
Tree->Branch("nTracks",(void *)&Tracks, "nTracks/I"); Tree->Branch("px",(void *)px, "px[nTracks]/F");
The number of tracks is of course random, from say 10 to 100.
I then need a small class to do some calculations. I get the skeleton with the “MakeClass” method. There, for the variable array “px”, I get
where this number 10 is of course the maximum number of tracks (maximum array length) per event I had in the tree from which the MakeClass method generates the skeleton.
But what if I had 50 tracks per events in my next tree? If you leave the size declaration at 10 and try to access track 11, you get a segmentation violation obviously.
It seems to me that I have to change the declaration of px to px either manually or get a new class through MakeClass. Does it mean that the class thus derived can only work for trees with a particular number of tracks, or maximum number of tracks?
Right now I have to tell people whom I give the code to change the 10 to whatever maximum number they get… not very user friendly!
How can I modify the declaration of “px”, or the class, such that it is not tied to a particular number of tracks, and that the same code can be used no matter this number, and not be changed each time?
Thanks for your help,