Hi,
I have a text file with two column data.
I need to plot a 2D scatter histogram from it.
I am using the program below but it is reading only the first row of the file. I am unable to locate the problem. I am also attaching the txt file for your convenience. MassTKE.txt (2.2 MB)
{
auto *h1 = new TH2D("h1", "Mass vs TKE", 400, 0, 400, 400, 0, 400);
auto *file = new TFile("Histogram.root", "recreate");
h1->GetXaxis()->SetTitle("Mass (a.m.u.)");h1->GetXaxis()->CenterTitle();
h1->GetYaxis()->SetTitle("TKE (MeV)");h1->GetYaxis()->CenterTitle();
ifstream in("MassTKE.txt");
std::vector<std::pair<int, int>> vec;
int N, Z;
while (in >> N && in >> Z)
{ cout<<N<<" "<<Z<<endl;
h1->Fill(N, Z);}
file->cd();
h1->Write();
file->Close();
}