#include #include "TFile.h" #include "TTree.h" #include "TChain.h" #include "TMyEvent.hh" #include "TMyCand.hh" #include "TRandom.h" #include "TROOT.h" extern void InitGui(); VoidFuncPtr_t initfuncs[] = {InitGui, 0}; TROOT root("Rint","The ROOT Interactive Interface", initfuncs); int main() { //gSystem->Load("./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; } } }