{ gROOT->Reset(); TFile f("e02.root","read"); TFile out("Ntuple.root","update"); TTree *tree = (TTree*)f.Get("h20"); Float_t Enestrip[4224]; tree->SetBranchAddress("Enestrip",Enestrip); TNtuple *ntup = new TNtuple("Nt","Ntuple with Sum of energy of strips","sum"); UInt_t w,z,MaxEntr; Float_t sum; MaxEntr = (UInt_t)(tree->GetEntries()); cout << "MaxEntr " << MaxEntr << endl; for( z = 0 ; z < MaxEntr ; z++) { tree->GetEntry(z); sum=0; for(w=0; w<4224; w++) { if ((Enestrip[w] < 0.1) && (Enestrip[w] >= 0)) sum+=Enestrip[w]; } ntup->Fill(sum); } cout << z << " events processed" << endl; ntup->Write(); out.Close(); cout << "Finished" << endl; cout << "Remember to deallocate tree and ntup" << endl; }