{ gSystem->Load("~/rootutorial/libMyClass.so"); gSystem->Load("libPhysics.so"); TChain chain("MyTree"); chain.Add("framework.root"); // -- Set up for reading Int_t nentries(0), nb(0); Int_t iEvent(0), iCand(0); TMyEvent *pEvent = new TMyEvent(0); TMyCand *pCand; chain.SetBranchAddress("TMyEvent", &pEvent); nentries = chain.GetEntries(); cout << "Found " << nentries << " entries in the chain" << endl; for (iEvent = 0; iEvent < nentries; iEvent++) { pEvent->Clear(); nb += chain.GetEvent(iEvent); for (iCand = 0; iCand < pEvent->GetNCand(); ++iCand) { pCand = pEvent->GetCand(iCand); cout << "event " << iEvent << " cand " << iCand << " momentum = " << pCand->getPlab().Mag() << endl; } } }