--- PamelaLevel2/doc/examples/example3.C 2006/10/09 12:37:52 1.2 +++ PamelaLevel2/doc/examples/example3.C 2007/01/15 11:51:39 1.3 @@ -15,66 +15,68 @@ // All selected trees in all the files are chained and made friends. // The whole "blob" can be accessed as if it was a single tree. // +// --- Modified on January 2007 --- +// +// see the comment at the beginning of example1.C +// void example3(TString dir,TString list="", TString treelist="+ALL", Int_t nmax=500000000){ - // Create a timer object to benchmark this loop - TStopwatch timer; - timer.Start(); - TString wd=gSystem->WorkingDirectory(); - // - PamLevel2* event = new PamLevel2(); // << create pamela event + // Create a timer object to benchmark this loop + TStopwatch timer; + timer.Start(); + TString wd=gSystem->WorkingDirectory(); + // + PamLevel2* event = new PamLevel2(); // << create pamela event - // ========================================================= - // << First a TList of root files is created - // << (either from a specific list or from the whole input directory) - TList *l = event->GetListOfLevel2Files(dir,list); - // << Hence a TChain is created from the list. - // << All the trees required by the user are made friend. - TChain *T = event->GetPamTree(l,treelist); - // << In the following the TChain can be used similarly to a TTree. - // - // NB! It is still possible to read a single file and get a TTree, by means of the methods: - // TTree* LoadPamTrees(TFile *f); - // TTree* LoadPamTrees(TFile *f,TString treelist); - // ========================================================= + // ========================================================= + // << First a TList of root files is created + // << (either from a specific list or from the whole input directory) + TList *l = event->GetListOfLevel2Files(dir,list); + // << Hence a TChain is created from the list. + // << All the trees required by the user are made friend. + TChain *T = event->GetPamTree(l,treelist); + // << In the following the TChain can be used similarly to a TTree. + // + // NB! It is still possible to read a single file and get a TTree, by means of the methods: + // TTree* LoadPamTrees(TFile *f); + // TTree* LoadPamTrees(TFile *f,TString treelist); + // ========================================================= - Int_t nevent = T->GetEntries(); + Int_t nevent = T->GetEntries(); - Int_t ntrk=0; - if(nevent < nmax)nmax=nevent; - cout << endl<<" Start loop over events "<GetEntry(i); + event->Clear(); + T->GetEntry(i); - if(event->GetNTracks() > 1)cout << " Ev "<GetNTracks() << endl; + if(event->GetTrkLevel2()->GetNTracks() > 1)cout << " Ev "<GetTrkLevel2()->GetNTracks() << endl; - if(event->TrkLevel2::ntrk() >0){ - ntrk++; - }; + if(event->GetTrkLevel2()->ntrk() >0){ + ntrk++; + }; - for(Int_t it=0; itGetNTracks(); it++){ + for(Int_t it=0; itGetTrkLevel2()->GetNTracks(); it++){ - PamTrack *track = event->GetTrack(it); - PamTrack *image = 0; + PamTrack *track = event->GetTrack(it); + PamTrack *image = 0; - if(track->HasImage())image = event->GetTrackImage(it); + if(track->GetTrkTrack()->HasImage())image = event->GetTrackImage(it); - delete track; - if(image)delete image; - - }; + }; }; // end loop over the events cout << endl << endl << " Done "<< endl<ChangeDirectory(wd); + gSystem->ChangeDirectory(wd); };