#include void arrayit() { // TCanvas *c1 = new TCanvas("c1", "c1", 1450, 850); TCanvas *c1 = new TCanvas("c1", "c1", 1000, 450); TH3F *h3d = new TH3F("h3d","blah",50,0,500,50,0,500,50,0,4500); gStyle->SetPalette(1); Float_t Xa,Ya,Za; Xa=0; Ya=0; Za=0; Int_t i,j; Float_t arr[500][500]; ifstream in; in.open("testin.txt", ios::in); Int_t nlines = 0; while (1) { for(i=0;i<500;i++) { in >> arr[i][nlines]; } if (!in.good()) break; nlines++; } printf(" found %d points\n",nlines); in.close(); TFile *newfile = new TFile("Arraytobranches.root","RECREATE"); TTree *TreeHouse=new TTree("TreeHouse","rumble in the jungle"); TBranch * b_X = TreeHouse->Branch("X", &Xa, " /F"); TBranch * b_Y = TreeHouse->Branch("Y", &Ya, " /F"); TBranch * b_Z = TreeHouse->Branch("Z", &Za, " /F"); for(i=0;i<500;i++) { for(j=0;j<500;j++) { Xa=i; Ya=j; Za=arr[i][j]; h3d->Fill(Xa,Ya,Za); TreeHouse->Fill(); } } c1->cd(); //h3d->Draw("box"); //h3d->Draw("text"); //h3d->Draw("col"), //h3d->Draw("colz"); h3d->Draw("surf"); h3d->Write(); TreeHouse->Write(); }