ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
timeonaxis2.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphs
3 /// Define the time offset as 2003, January 1st.
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Olivier Couet
9 
10 TCanvas *timeonaxis2() {
11  TCanvas *ct2 = new TCanvas("ct2","ct2",10,10,700,500);
12 
13  TDatime T0(2003, 1, 1, 0, 0, 0);
14  int X0 = T0.Convert();
15  gStyle->SetTimeOffset(X0);
16 
17  // Define the lowest histogram limit as 2002, September 23rd
18  TDatime T1(2002, 9, 23, 0, 0, 0);
19  int X1 = T1.Convert()-X0;
20 
21  // Define the highest histogram limit as 2003, March 7th
22  TDatime T2(2003, 3, 7, 0, 0, 0);
23  int X2 = T2.Convert(1)-X0;
24 
25  TH1F * h1 = new TH1F("h1","test",100,X1,X2);
26 
27  TRandom r;
28  for (Int_t i=0;i<30000;i++) {
29  Double_t noise = r.Gaus(0.5*(X1+X2),0.1*(X2-X1));
30  h1->Fill(noise);
31  }
32 
33  h1->GetXaxis()->SetTimeDisplay(1);
34  h1->GetXaxis()->SetLabelSize(0.03);
35  h1->GetXaxis()->SetTimeFormat("%Y/%m/%d");
36  h1->Draw();
37  return ct2;
38 }
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3159
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition: TAxis.cxx:943
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:235
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
int Int_t
Definition: RtypesCore.h:41
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition: TStyle.cxx:1463
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:29
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:2878
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:187
The Canvas class.
Definition: TCanvas.h:48
double Double_t
Definition: RtypesCore.h:55
#define T2
Definition: md5.inl:146
#define T1
Definition: md5.inl:145
TAxis * GetXaxis()
Definition: TH1.h:319
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:39