Hello all,
I’m new to root, and have some questions on TClonesArray impl details
(currently using v3.10/02, may not be easy to change version as I need to
match the version in our library system)
(1) user’s guide (latest version) and on-line documentation may not match?
on-line doc (generated by header file?) :
objects to be stored need to be same type (class)
user’s guide : same type and fixed same size <== may be out dated?
as I see there was some updates to allow TClonesArray can store not just
fixed size (but same type) in the release note some time ago?
(2) In user’s guide (or on-line doc), it’s not clear what requirements for objects to be
stored in the TClonesArray (or TCollection): e.g. Object Class need to define
default ctor(), …, but not necessarily dtor(), copy assignment, operator=()?
And it’s not clear what will happen when I store objects in my compiled application,
root interactive version … etc. Say
(a) In my compiled exe application to store objects (MainEvent.cc like), both
ctor() and dtor() are called (as I call Delete() for every event)
(b) It seems to me that if I loop my TClonesArray using TTree::GetEntry() method
only ctor() of objects is called, but not dtor(). Also, if I call Clear() before Delete()
dtor() not called. How memory will be free-ed?
© TTree::Draw() on TClonesArray – similar to T->Draw(“fTrack.fPX”) in user’s
guide example (for test/Event example) – ctor()/dtor() never called. I wonder
why and how memory will be handled?
(3) The primary reason why I use TClonesArray is to store array of objects (like Event/Track
example), but I still want to use TTree::Draw() on member of array. I tried TObjArray
but TTree::Draw() does not seem to support it ? (at least in v3.10/02)
Draw() may not call Clear(), but GetEntry() loop need to call Clear() … what’s the
difference? Memory will be properly free-ed in both case?
(4) I wonder why TClonesArray member (Track) in mother class(Event) are pointer to
TClonesArray? I made my member to have TClonesArray not a pointer to it to simplify
memory allocation process … etc. It seems to work: say
class Event : public TObject {
TClonesArray fTracks;
…
Do I need to make it “TClonesArray *fTracks”, as in the test/Event example? Then, why?
Also, SetOwner() shouldn’t be called for TClonesArray?
(5) What if I want to make Array of objects which have array of objects(say TRefArray or
another TClonesArray), are they supposed to be suppored in v3.10/02? I did some
test and it seem to be working but it’s not clear how memory alloc/de-alloc are done
to me.
Regards,
Chul Su