Logo ROOT   6.14/05
Reference Guide
timeonaxis2.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphs
3 /// \notebook
4 /// Define the time offset as 2003, January 1st.
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Olivier Couet
10 
11 TCanvas *timeonaxis2() {
12  TCanvas *ct2 = new TCanvas("ct2","ct2",10,10,700,500);
13 
14  TDatime T0(2003, 1, 1, 0, 0, 0);
15  int X0 = T0.Convert();
16  gStyle->SetTimeOffset(X0);
17 
18  // Define the lowest histogram limit as 2002, September 23rd
19  TDatime T1(2002, 9, 23, 0, 0, 0);
20  int X1 = T1.Convert()-X0;
21 
22  // Define the highest histogram limit as 2003, March 7th
23  TDatime T2(2003, 3, 7, 0, 0, 0);
24  int X2 = T2.Convert(1)-X0;
25 
26  TH1F * h1 = new TH1F("h1","test",100,X1,X2);
27 
28  TRandom r;
29  for (Int_t i=0;i<30000;i++) {
30  Double_t noise = r.Gaus(0.5*(X1+X2),0.1*(X2-X1));
31  h1->Fill(noise);
32  }
33 
34  h1->GetXaxis()->SetTimeDisplay(1);
35  h1->GetXaxis()->SetLabelSize(0.03);
36  h1->GetXaxis()->SetTimeFormat("%Y/%m/%d");
37  h1->Draw();
38  return ct2;
39 }
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3251
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition: TAxis.cxx:1002
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:256
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:285
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:567
int Int_t
Definition: RtypesCore.h:41
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition: TStyle.cxx:1655
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
TH1F * h1
Definition: legend1.C:5
virtual void SetTimeDisplay(Int_t value)
Definition: TAxis.h:161
ROOT::R::TRInterface & r
Definition: Object.C:4
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2974
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:204
The Canvas class.
Definition: TCanvas.h:31
double Double_t
Definition: RtypesCore.h:55
#define T2
Definition: md5.inl:146
#define T1
Definition: md5.inl:145
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:315
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37