seism.C

Go to the documentation of this file.
00001 // strip chart example
00002 // Author: Rene Brun
00003    
00004 void seism() {
00005    
00006    TStopwatch sw; sw.Start();
00007    //set time offset
00008    TDatime dtime;
00009    gStyle->SetTimeOffset(dtime.Convert());
00010 
00011    TCanvas *c1 = new TCanvas("c1","Time on axis",10,10,1000,500);
00012    c1->SetFillColor(42);
00013    c1->SetFrameFillColor(33);
00014    c1->SetGrid();
00015    
00016    Float_t bintime = 1; //one bin = 1 second. change it to set the time scale
00017    TH1F *ht = new TH1F("ht","The ROOT seism",10,0,10*bintime);
00018    Float_t signal = 1000;
00019    ht->SetMaximum( signal);
00020    ht->SetMinimum(-signal);
00021    ht->SetStats(0);
00022    ht->SetLineColor(2);
00023    ht->GetXaxis()->SetTimeDisplay(1);
00024    ht->GetYaxis()->SetNdivisions(520);
00025    ht->Draw();
00026    
00027    for (Int_t i=1;i<2300;i++) {
00028       //======= Build a signal : noisy damped sine ======
00029       Float_t noise  = gRandom->Gaus(0,120);
00030       if (i > 700) noise += signal*sin((i-700.)*6.28/30)*exp((700.-i)/300.);
00031       ht->SetBinContent(i,noise);
00032       c1->Modified();
00033       c1->Update();
00034       gSystem->ProcessEvents(); //canvas can be edited during the loop
00035    }
00036    printf("Real Time = %8.3fs, Cpu Time = %8.3fs\n",sw.RealTime(),sw.CpuTime());
00037 }

Generated on Tue Jul 5 15:44:22 2011 for ROOT_528-00b_version by  doxygen 1.5.1