Hey everyone. This may be answered somewhere already, but I couldn’t find it. I’m trying to write a TClonesArray of a user-defined class to a tree that has several other branches. The tree seems to be written properly (the array size is normal in the writing code, and I can look at it in the browser and it’s there and seems fine) but when I try to read out the array in a loop, it always has size zero. Here’s the relevant code:
TClonesArray* DOMArray_ = new TClonesArray(“DOMInfo”, 100);
…
eventTree_->Branch(“EventID”, &EventID_, “EventID/I”);
eventTree_->Branch(“RunID”, &RunID_, “RunID/I”);
eventTree_->Branch(“DOMArray”, “TClonesArray”, &DOMArray_, 32000, 99);
…
DOMInfo* thisDOM = new((*DOMArray_)[DOMInfoCount_++]) DOMInfo();
…
eventTree_->Fill();
Just before the fill statement, the size of the array is as it should be. I now try to do the following to read the array back in from my tree:
TChain* events = new TChain(“Events”);
events->Add(“blah”);
…
TClonesArray* nugenDOMArray = new TClonesArray(“DOMInfo”, 100);
…
events->SetMakeClass(1);
events->SetBranchStatus(“DOMArray”, 1);
events->SetBranchAddress(“DOMArray”, nugenDOMArray);
…
for(Long64_t i=0; i<nugenEntries; i++){
nugenTree->GetEntry(i);
cout << nugenDOMArray->GetLast() << endl;
}
Now the size of the array always comes out as zero. This seems like it should work. Am I doing something obviously wrong? Thanks!
Michelangelo
P.S. I forgot to mention that I load the relevant libraries that have my class definitions in them…