Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
hist063_TH1_seism.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Strip chart example.

#include "TStopwatch.h"
#include "TDatime.h"
#include "TStyle.h"
#include "TH1F.h"
#include "TCanvas.h"
#include "TSystem.h"
#include "TRandom.h"
#include <cstdio>
void hist063_TH1_seism()
{
sw.Start();
// set time offset
TDatime dtime;
gStyle->SetTimeOffset(dtime.Convert());
TCanvas *c1 = new TCanvas("c1", "Time on axis", 10, 10, 1000, 500);
c1->SetGrid();
Float_t bintime = 1; // one bin = 1 second. change it to set the time scale
TH1F *ht = new TH1F("ht", "The ROOT seism", 10, 0, 10 * bintime);
Float_t signalval = 1000;
ht->SetMaximum(signalval);
ht->SetMinimum(-signalval);
ht->SetStats(false);
ht->SetLineColor(2);
ht->GetYaxis()->SetNdivisions(520);
ht->Draw();
for (Int_t i = 1; i < 2300; i++) {
//======= Build a signal : noisy damped sine ======
Float_t noise = gRandom->Gaus(0, 120);
if (i > 700)
noise += signalval * sin((i - 700.) * 6.28 / 30) * exp((700. - i) / 300.);
ht->SetBinContent(i, noise);
c1->Modified();
c1->Update();
gSystem->ProcessEvents(); // canvas can be edited during the loop
}
printf("Real Time = %8.3fs, Cpu Time = %8.3fs\n", sw.RealTime(), sw.CpuTime());
}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
externTRandom * gRandom
Definition TRandom.h:62
externTStyle * gStyle
Definition TStyle.h:442
externTSystem * gSystem
Definition TSystem.h:582
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition TAttAxis.cxx:214
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
virtual void SetTimeDisplay(Int_t value)
Definition TAxis.h:173
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
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
Definition TDatime.cxx:181
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:878
TAxis * GetXaxis()
Definition TH1.h:571
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:652
TAxis * GetYaxis()
Definition TH1.h:572
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3097
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:653
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:9356
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:9127
Stopwatch class.
Definition TStopwatch.h:28
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
return c1
Definition legend1.C:41
Author
Rene Brun

Definition in file hist063_TH1_seism.C.