ROOT logo
// strip chart example
// Author: Rene Brun
   
void seism() {
   
   TStopwatch sw; sw.Start();
   //set time offset
   TDatime dtime;
   gStyle->SetTimeOffset(dtime.Convert());

   TCanvas *c1 = new TCanvas("c1","Time on axis",10,10,1000,500);
   c1->SetFillColor(42);
   c1->SetFrameFillColor(33);
   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 signal = 1000;
   ht->SetMaximum( signal);
   ht->SetMinimum(-signal);
   ht->SetStats(0);
   ht->SetLineColor(2);
   ht->GetXaxis()->SetTimeDisplay(1);
   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 += signal*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());
}
 seism.C:1
 seism.C:2
 seism.C:3
 seism.C:4
 seism.C:5
 seism.C:6
 seism.C:7
 seism.C:8
 seism.C:9
 seism.C:10
 seism.C:11
 seism.C:12
 seism.C:13
 seism.C:14
 seism.C:15
 seism.C:16
 seism.C:17
 seism.C:18
 seism.C:19
 seism.C:20
 seism.C:21
 seism.C:22
 seism.C:23
 seism.C:24
 seism.C:25
 seism.C:26
 seism.C:27
 seism.C:28
 seism.C:29
 seism.C:30
 seism.C:31
 seism.C:32
 seism.C:33
 seism.C:34
 seism.C:35
 seism.C:36
 seism.C:37
 seism.C:38
thumb