ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
seism.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphs
3 /// Strip chart example.
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Rene Brun
9 
10 #include "TStopwatch.h"
11 #include "TDatime.h"
12 #include "TStyle.h"
13 #include "TH1F.h"
14 #include "TCanvas.h"
15 #include "TSystem.h"
16 #include "TRandom.h"
17 #include <stdio.h>
18 
19 void seism() {
20 
21  TStopwatch sw; sw.Start();
22  //set time offset
23  TDatime dtime;
24  gStyle->SetTimeOffset(dtime.Convert());
25 
26  TCanvas *c1 = new TCanvas("c1","Time on axis",10,10,1000,500);
27  c1->SetFillColor(42);
28  c1->SetFrameFillColor(33);
29  c1->SetGrid();
30 
31  Float_t bintime = 1; //one bin = 1 second. change it to set the time scale
32  TH1F *ht = new TH1F("ht","The ROOT seism",10,0,10*bintime);
33  Float_t signal = 1000;
34  ht->SetMaximum( signal);
35  ht->SetMinimum(-signal);
36  ht->SetStats(0);
37  ht->SetLineColor(2);
38  ht->GetXaxis()->SetTimeDisplay(1);
39  ht->GetYaxis()->SetNdivisions(520);
40  ht->Draw();
41 
42  for (Int_t i=1;i<2300;i++) {
43  //======= Build a signal : noisy damped sine ======
44  Float_t noise = gRandom->Gaus(0,120);
45  if (i > 700) noise += signal*sin((i-700.)*6.28/30)*exp((700.-i)/300.);
46  ht->SetBinContent(i,noise);
47  c1->Modified();
48  c1->Update();
49  gSystem->ProcessEvents(); //canvas can be edited during the loop
50  }
51  printf("Real Time = %8.3fs, Cpu Time = %8.3fs\n",sw.RealTime(),sw.CpuTime());
52 }
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:420
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
Definition: TDatime.cxx:179
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
Definition: TStopwatch.cxx:108
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:394
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:56
float Float_t
Definition: RtypesCore.h:53
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
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition: TAttAxis.cxx:212
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:395
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
Definition: TStopwatch.cxx:123
int Int_t
Definition: RtypesCore.h:41
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition: TStyle.cxx:1463
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:326
double sin(double)
virtual void SetTimeDisplay(Int_t value)
Definition: TAxis.h:161
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Definition: TH1.cxx:8543
TAxis * GetYaxis()
Definition: TH1.h:320
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
The Canvas class.
Definition: TCanvas.h:48
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
void SetFrameFillColor(Color_t color=1)
Definition: TAttPad.h:83
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2179
double exp(double)
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8320
void Modified(Bool_t flag=1)
Definition: TPad.h:407
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
Stopwatch class.
Definition: TStopwatch.h:30