TTree of TObjArray of TClonesArray

Hi all,
I would like to implement the storage model in subj, and for that playing with

void Tree()
  const char *descrip="branch of TObjArray of 2 TClonesArray of TVector3";
  const char *filename="~/kir.root";
  const char *treename="Tree";
  const char *branchname="Branch";
  TFile *pFile=TFile::Open(filename,"RECREATE");
  TTree *pTr=new TTree(treename,descrip);
  TObjArray *pLstAll=new TObjArray(2); 
  pTr->Branch(branchname,&pLstAll,32000,0); //here set split to 1

  TClonesArray *pLst[2];  
  for(Int_t i=0;i<2>AddAt(pLst[i]=new TClonesArray("TVector3"),i);  
  for(Int_t iEvt=0;iEvt<3;iEvt++){
    for(Int_t iHit=0;iHit<iEvt;iHit++) 
      new((*pLst[0])[iHit]) TVector3(iEvt,iHit,111);
    for(Int_t iHit=0;iHit<iEvt>Fill();
  delete pFile;      
  for(Int_t i=0;i<pTr>GetEntries();i++){
    Printf("Event %i first list:",i);pLst[0]->Print();
    Printf("Event %i second list:",i);pLst[1]->Print();

If i fill the tree in spliting mode the message that splitting for TObjArray is not allowed is printed also claiming that split is reset to 0, but in this case
there are problems namely no entries for the first list and only single entry for the second. In case i put no spliting manually everything works as expected.
I can’t figure out what is going on.

I use v5-13-06 selfcompiled on SLC4


When copy/paste code, please disable the HTML in your post.

[quote]I would like to implement the storage model: TTree of TObjArray of TClonesArray[/quote]What is your intent? What are your goals.

TObjArray can not be split (and apparently your hit some sort of problems in the code trying to change the request). In consequence, the advantage of TClonesArray (since they are not going to be split) is going to be must less than it could have been.


PS. Please provide a running example, if you need the odd behavior to be fixed.


I have N lists of the same objects, say MyHit. Each list holds hits for one out of N identical detectors. I would like to store them in separate lists because they need to be processed separately. Storing them in the single list is not affordable as i need to extract subset of hits for the same detector part few times per event. Other possibility is to assign separate branch to each TClonesArray,
but this means i need to do something like

TClonesArray *pCA[N];
for(int i=0;i<N>SetBranchAddress(Form(Name%i",i),&pCA[i]);

in few different classes.
Working macro in attachment.
Tree.C (1.28 KB)

[quote]but this means i need to do something like …[/quote]This is indeed, in my opinion, the best way to store the object in your cases. You will gain the full advantages of splitting: you’ll be able to read each ‘detectors’ independently, you’ll be able to browse your file in the gui, you’ll be able to use TTree::Draw on your data [none of which would work with a TObjArray of].