Filling Histograms with a text file

your macro should be:

{
  auto am241=new TH1F("am241",
           "Count Rate;N_{counts};# occurencies",
           4095,
           -0.5,
           6000);
  ifstream inp; double x;
  inp.open("Am241.txt");
  for (int i=1; i<=4095; i++) {
    inp >> x;
    am241->SetBinContent(i,x);
  }
  am241->Draw();
}

And you will get:

1 Like