#include #include #include "TFile.h" #include #include "TTree.h" #include "TH2F.h" #include "TCanvas.h" #include "TBranch.h" #include "TLeaf.h" #include "TTreeReader.h" using namespace std; void readfile() { Int_t np; // Float_t Px[1000000], Py[1000000], Pz[1000000]; Int_t *PId = new Int_t[np]; Float_t *Px = new Float_t[np]; // PId[0] = 0; TFile *f = new TFile("DAT000002.root"); TTree *tr = (TTree*)f->Get("cor"); // tr->GetBranch("Particle")->GetLeaf("np")->SetAddress(&np); TBranch *b = (TBranch*)tr->GetBranch("Particle"); b->GetLeaf("np")->SetAddress(&np); b->GetLeaf("PId")->SetAddress(&PId); b->GetLeaf("Px")->SetAddress(&Px); Int_t nevent = tr->GetEntries(); cout << nevent << endl; for(Int_t i=0; iGetEntry(i); cout << np << endl; for(int j=0; jGetLeaf("Px")->SetAddress(&Px); if(PId[j]==6) { cout << PId[j] << Px[j] << endl; // break; } } } }