Store Data with time in a Tree

I’ll try. I just recognized, that the string Labels are saved like: Sat May 1 00:00:00 2010, although I saved them in a string like: day(yyyy-…)"+"time(hh:…). Maybe there is some Problem by reading it…

Sorry I forgot, it’s the same in my plot and as I tried to show the seconds it even doesn’t made any different in that unit between points at an interval of one hour…

I can’t find anything there, the problem has to be the Draw option, because I checked twice and the timeaxis is given in seconds, at points with interval of one hour are 3600 x units in between, but it even doesn’t shoe the seconds in the labels with the right command.

Just to be sure we are speaking about the same macro, the one I have is:

[code]{
TTree t1(“t1”,“t1”);
TDatime zeit;
string day, time, datetime;
float px,py;
int ev = 0;
t1.Branch(“px”,&px);
t1.Branch(“py”,&py);
t1.Branch(“ev”,&ev,“ev/I”);
t1.Branch(“zeit”,&zeit);

std::ifstream file1;
file1.open(“htest1.txt”,ios::in);
for (int i=1;i<10;i++)
{
++ev;
file1 >>day>>time>>px>>py;
if (!file1) {
break;
}
datetime = day +" “+ time;
zeit.Set(datetime.c_str());
t1.Fill();
}
// t1.Write();
t1->Scan(“zeit:px:ev”,”",“colsize=20”);
// And the commends in another Prog. to draw:
c2 = new TCanvas(“c2”);
c2->Divide(2);
c2->cd(1);
t1->Draw(“px:zeit.fDatime”);
htemp->GetXaxis()->SetTimeDisplay(1);
htemp->GetXaxis()->SetTimeFormat("%d/%m/%Y");
gPad->Modified();
c2->cd(2);
t1->Draw(“px:zeit”);
}[/code]
Is that right ?

Yes, there are the same commands and as I tried to make sure, the same result.

I don’t really come forward to solve that problem, I constructed a separated TG axis but that includes other problems… Is there maybe some new Information about it??

I do not see where in you macro you convert the dates into integer as explain here:
root.cern.ch/drupal/content/how- … time-units
I do not see any call to “Convert()” like all the example in the previous howto.

I checked out that I read in Integer by changing the source data and converting the data with atoi before giving them to the tree. The problem has to concern the drawing Process.
There is no possibility (at least shown in the macro, or anything else I searched) to use the Convert Option at the drawing processes. As I have many TDatime objects, I don’t need to Set any timeoffset and that’s the only part where the Convert Option is used. As I mentioned before I don’t see big similarity to the macro, because I need to build the axis with many TDatime Objects, where I can’t use the function to set a fixed point of starting time and let time running.

There is something strange (I never use the time axis n ntuple before). Let me explain what I tried.

I modified your macro to see what integer values you are really plotted.
I found out that the axis starts at the value:

1011200000

Then I tried to convert the date using convert.
The smallest date is 2010-05-01 00:00:01
I did:

root [2] TDatime d(2010,5,1,0,0,1)
root [3] d.Convert()
1272664801

As you see that does not match … I do not understand yet … I need time…

I tried out that (behind the work else) for a long time too, it seems to be a little dodgy. Thank you for your interest and support.
Wolfgang

{
   TTree t1("t1","t1");
   TDatime zeit;
   string day, time, datetime;
   float px,py;
   int t;
   int ev = 0;
   t1.Branch("px",&px);
   t1.Branch("py",&py);
   t1.Branch("ev",&ev,"ev/I");
   t1.Branch("zeit",&zeit);
   t1.Branch("t",&t);      

   std::ifstream file1;
   file1.open("htest1.txt",ios::in);
   for (int i=1;i<10;i++)
   {
      ++ev;
      file1 >>day>>time>>px>>py;
      if (!file1) {
         break;
      }
      datetime = day +" "+ time;
      zeit.Set(datetime.c_str());
      t = zeit.Convert();
      t1.Fill();
   }
   t1->Scan("zeit:t:ev","","colsize=20");    
   // And the commends in another Prog. to draw:
   TCanvas *c = new TCanvas("c","c",1000,500);
   t1->Draw("t");           
   htemp->GetXaxis()->SetTimeDisplay(1);  
   htemp->GetXaxis()->SetTimeFormat("%d\/%m\/%Y");  
   htemp->GetXaxis()->SetTimeOffset(0);           
}

Thanks a lot, works perfectly well.
Wolfgang