Dear Rooters,
I’m fighting with tree and branch. I’m running version 3.10 under MacOSX Panther on a 1GHz PowerPC G4 with 512 MB SDRAM.
I have a rootple with simple data and want to produce a new one with object.
I ran MakeClass and obtained a MyClass.h and MyClass.C
I defined 2 new classes: RecMuon and MCPart.
They are basically a TLorentzVector plus some integer.
I then wrote my own event class ZEvent, which has 2 TClonesArray member one for the MCpart and another for the RecMuon.
While looping on the first tree with MyClass::Loop
I’d like to size the ZEvent, event by event and fill the tree.
I Wrote something like
TFile *fp = new TFile(“my.root”,“recreate”);
fp->SetCompressionLevel(9);
TTree *Ztree = new TTree(“Ztree”, “Tree for Z analisys”);
Ztree->SetBranchStyle(1);
ZEvent *event =0;
TBranch *branch = Ztree->Branch(“event”,“ZEvent”,&event, bufsize,split);
for (jentry=0; jentry<nentries;jentry++) {
cout<<"####### “<<jentry<<”##########"<<endl;
nb = fChain->GetEntry(jentry); nbytes += nb;
//Npar number of MCPart and NMUO number of RecMuon
event = new ZEvent(jentry,NPar,NMUO);
Ztree->SetBranchAddress(“event”,&event);
for(loop over MCpart){ … }
for(loop over NMUO){ … }
event->Print();
Ztree->Fill();
delete event;
}
After 4 event the program crashes on the Ztree->Fill(), and gdb says something like
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x018b92fc in TClass::Streamer(void*, TBuffer&) ()
I’m Sure that the probolem is the uncorrect pointing of the branch to the event object, but I do I handle such a situation??
Thank for your help
PS. here find Attached a tar file with the sources+Makefile