{ ifstream infile("my_data.txt"); // Input data file TH1F *h1 = new TH1F("h1", "Spectra", 200, 0, 20); // for(int i=0; i<3000; ++i) { for(int i=0 ; ; ++i) { double a; infile >> a; if ( infile.eof() ) break; // break if End Of File is reached h1->Fill(a); } c1=new TCanvas("c1", "Spectra", 600, 400); c1->cd(); h1->Draw(); }