Re: Make txt_files in files.root

From: Brett Viren <bv_at_bnl.gov>
Date: Mon, 08 Aug 2005 10:24:48 -0400


Demetra Tsiakkouri <dtsiak_at_mail.cern.ch> writes:

> Hi
>
> I have a txt file with three coloums day, time and temperature
> e.g: 2004/10/12 12:15:32 19.605
> 2004/10/12 12:20:47 19.705
> .
> .
> .
>
> So I want to make a programma in C++ that reads the daytime and make it a
> root file! Is this possible?Do you know how to help me?

See strptime(3) ("man 3 strptime"). This lets you parse the date string to a "struct tm" data structure. Then use mktime(3) to produce "unix epoch seconds". To access these in C++ do "#include <ctime>". In more recent compilers these will be in the "std::" namespace older ones have them in the base namespace.

If your goal is just to make a plot, you could fill a TGraph directly from the text file and plot it. You'll probably want to look at TAxis::SetTimeFormat() and TAxis::SetTimeDisplay() to tell ROOT how you best want to display the times.

Rather, if your final goal is to make a "root file" you'll need to decide how you want to store the data. TGraph? TTree? Something else?

In all this, you'll need to be wary of how different codes interpret the times. Some assume local time, some UTC.

-Brett. Received on Mon Aug 08 2005 - 16:25:01 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:11 MET