Dear ROOT-forumers
I have a problem trying to use the TTimeStamp for the x-axis of my histogram. It seems to me that the problem is that the precision is lost. I typically make the x-axis from a 9-digit number that I get from the GetSec() method of TTimeStamp, making this into a float, and defining a histogram using these floats as the x-axis bin-values (I need to use floats, so that the values of the histogram and the values on the x-axis both are floats, I have understood must be required). A test-code is pasted below as an example showing the problem
>>> from ROOT import *
>>> from numpy import asarray
>>> x_list = [float(1343670783),float(1343670784),float(1343670785),float(1343670786)]
>>> x_array = asarray(x_list)
>>> h = TH1F("h","h",len(x_array)-1,x_array)
>>> h.SetBinContent(1,2)
>>> h.SetBinContent(2,4)
>>> h.Draw()
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
TCanvas::ResizePad:0: RuntimeWarning: c1 width changed from 0 to 10
TCanvas::ResizePad:0: RuntimeWarning: c1 width changed from 0 to 10
Error in <TGaxis::PaintAxis>: length of axis is 0
Error in <TGaxis::PaintAxis>: length of axis is 0
>>> TCanvas::ResizePad:0: RuntimeWarning: c1 width changed from 0 to 10
The histogram looks like the following if I make a .C file and look into it. You can see that I have not managed correctly setting the x-axis (the precision is gone).
{
//========= Macro generated from object: h/h
//========= by ROOT version5.30/02
Double_t xAxis1[4] = {1.34367e+09, 1.34367e+09, 1.34367e+09, 1.34367e+09};
TH1F *h = new TH1F("h","h",3, xAxis1);
h->SetBinContent(1,2);
h->SetBinContent(2,4);
h->SetEntries(2);
.....<and-so-on>
}
How do I correctly deal with this?
Thanks a lot,
Maiken