Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hist063_TH1_seism.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_hist
3/// \notebook -js
4/// \preview Strip chart example.
5///
6/// \macro_image
7/// \macro_code
8///
9/// \author Rene Brun
10
11#include "TStopwatch.h"
12#include "TDatime.h"
13#include "TStyle.h"
14#include "TH1F.h"
15#include "TCanvas.h"
16#include "TSystem.h"
17#include "TRandom.h"
18#include <cstdio>
19
21{
22
24 sw.Start();
25 // set time offset
27 gStyle->SetTimeOffset(dtime.Convert());
28
29 TCanvas *c1 = new TCanvas("c1", "Time on axis", 10, 10, 1000, 500);
30 c1->SetGrid();
31
32 Float_t bintime = 1; // one bin = 1 second. change it to set the time scale
33 TH1F *ht = new TH1F("ht", "The ROOT seism", 10, 0, 10 * bintime);
34 Float_t signalval = 1000;
35 ht->SetMaximum(signalval);
36 ht->SetMinimum(-signalval);
37 ht->SetStats(false);
38 ht->SetLineColor(2);
39 ht->GetXaxis()->SetTimeDisplay(1);
40 ht->GetYaxis()->SetNdivisions(520);
41 ht->Draw();
42
43 for (Int_t i = 1; i < 2300; i++) {
44 //======= Build a signal : noisy damped sine ======
45 Float_t noise = gRandom->Gaus(0, 120);
46 if (i > 700)
47 noise += signalval * sin((i - 700.) * 6.28 / 30) * exp((700. - i) / 300.);
48 ht->SetBinContent(i, noise);
49 c1->Modified();
50 c1->Update();
51 gSystem->ProcessEvents(); // canvas can be edited during the loop
52 }
53 printf("Real Time = %8.3fs, Cpu Time = %8.3fs\n", sw.RealTime(), sw.CpuTime());
54}
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
The Canvas class.
Definition TCanvas.h:23
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:650
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:275
Stopwatch class.
Definition TStopwatch.h:28
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition TStyle.cxx:1915
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:416
return c1
Definition legend1.C:41