I tried to store my Data with TDatime in the tree, in order to be able to draw TGraphs afterward with the treeviewer. Therefore I need the x axis as time-axis. I read in my Data as Integer with
sscanf(&line,"%d%d%d%d%d%d",&staff.year,…) to convert by
This is a bit complected, it maybe would be easier to read just two strings for day and time but its possible…
Now I don’t know how to store all 6 data in one Tree.
I couldn’t find anywhere any example containing how to get the usual time format (yyyy-mm-dd hh:mm:ss) as time in a tree and setting the corresponding data in right intervals in a next step in relation to the time axis. Maybe its just because I’m still starting using ROOT but I really spend a lot of time for that problem.
You should store directly the TDatime object: mytree->Branch("when.",&object); and then you have 2 choices, either use the string representation as the x values:mytree->Draw("when.AsString()");or use the SetTimeDisplay option:mytree->Draw("when.fDatime");
I just still have some little Problems:
I declared my Object (1), build a Branch (2), and tried to fill it (3).
TDatime time1; 1
for ( i=1;i<10;i++)
time1 = TDatime(day,time)…}
before I saved time as a Char Array(Char_t day,time…t1.Branch(“time”,time,“time/C”) so I could go on with that, too.
Anyway there is still some mistake inside, (I’m sorry if its a simple problem, I’m still beginner…)
Thanks it almost works, I just have my data in format 2010-06-02 18:00:00.00,
As I stored the Data in a Char. Array I would convert them into Int (with atoi()) and use the Set function afterward. I thought it should be possible to use Strings in Set(…) but that didn’t work. Anyway, maybe there is a way more elegant to work with strings…
[quote]. I just wondered if it’s possible to use the strings without converting them (with atoi).[/quote]Humm I am confused … isn’t:mydatime.Set(line); // line is the string with the human readable date/time exactly what you are looking for?
gPad->Modified();Humm The 3rd lines does not seem correct, shouldn’t it be? :mytree->Draw("x:time.fDatime>>ht");
Sorry, That was just a mistake by copying it. To put the strings inside worked well, by scanning the tree its all right. But there is still something false by drawing it. (time alone and time on x axis against some values…) I’m sorry for asking so much but especially for that topic I didn’t found any explanation or example.
You really can Reproduce it right?
I get on my time axis Labels with:
which is not in between 2010 and 2015 and somehow there are 31 months?
I checked out the intervals in between and they should be fine. I tried to add an time offset but that didn’t work, somehow it’s not drawing the right format…
I tried the macro Philippe sent me again, replacing “%y” by “%Y” in the time format to make the year more clear. I see it goes from 2026 to 2036. Is does the match the date shown in the other plot. I guess there is something wrong in your time conversion. See: root.cern.ch/drupal/content/how- … time-units