Problem in reading ascii file

Dear Developers,

I am trying to plot 4th column of “inputs.lhco” file and when i run “input.c” file i get following error

"Error in : unexpected character or eof found "

Kindly help me in solving this issue.
Thanks.

Regards,
Nab
nab.zip (1.1 MB)

Some lines in your “inputs.lhco” file have 3 numbers while another lines have 11 and your “input.c” macro is not able to deal with it (it expects 5 numbers per line).

I have done it with 11 numbers per line but it is giving same error.

Yes some lines are having just 3 numbers and others having 11. How to deal with this kind of file?

In order to understand what this data file contains and how to read it, you need to talk to the author of this file.

Assuming:

  1. you are on Linux
  2. you want to skip lines starting with 0 (line with 3 numbers only ).

Then the following macro will do the job:

{
   gSystem->Exec("cat inputs.lhco | sed -e 's/^  0/# 0/' > inputs.lhco2");
   TNtuple t("t","test","h:a:b:c:m:v6:v7:v8:v9:v10:v11");
   t.ReadFile("inputs.lhco2");
   TCanvas *c1 = new TCanvas("c1","c1",600,400);
   TFile *mfile = new TFile ("input2.4.root","RECREATE");
   t.Write("t");
   t.Draw("a");
}

Thank you so much for your time. This is working now.

Cheers,
Nab

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.