Logo ROOT  
Reference Guide
gtime.C File Reference

Detailed Description

View in nbviewer Open in SWAN Example of TGraphTime.

#include "TCanvas.h"
#include "TRandom3.h"
#include "TMath.h"
#include "TText.h"
#include "TArrow.h"
#include "TGraphTime.h"
#include "TROOT.h"
void gtime(Int_t nsteps = 500, Int_t np=100) {
if (np > 1000) np = 1000;
Int_t color[1000];
Double_t rr[1000], phi[1000], dr[1000], size[1000];
Double_t xmin = -10, xmax = 10, ymin = -10, ymax = 10;
g->SetTitle("TGraphTime demo;X domain;Y domain");
Int_t i,s;
for (i=0;i<np;i++) { //calculate some object parameters
rr[i] = r.Uniform(0.1*xmax,0.2*xmax);
phi[i] = r.Uniform(0,2*TMath::Pi());
dr[i] = r.Uniform(0,1)*0.9*xmax/Double_t(nsteps);
Double_t rc = r.Rndm();
color[i] = kRed;
if (rc > 0.3) color[i] = kBlue;
if (rc > 0.7) color[i] = kYellow;
size[i] = r.Uniform(0.5,6);
}
for (s=0;s<nsteps;s++) { //fill the TGraphTime step by step
for (i=0;i<np;i++) {
Double_t newr = rr[i]+dr[i]*s;
Double_t newsize = 0.2+size[i]*TMath::Abs(TMath::Sin(newr+10));
Double_t newphi = phi[i] + 0.01*s;
Double_t xx = newr*TMath::Cos(newphi);
Double_t yy = newr*TMath::Sin(newphi);
TMarker *m = new TMarker(xx,yy,20);
m->SetMarkerColor(color[i]);
m->SetMarkerSize(newsize);
g->Add(m,s);
if (i==np-1) g->Add(new TArrow(xmin,ymax,xx,yy,0.02,"-|>"), s);
}
g->Add(new TPaveLabel(.90,.92,.98,.97,Form("%d",s+1),"brNDC"),s);
}
g->Draw();
//save object to a file
TFile f("gtime.root","recreate");
g->Write("g");
//to view this object in another session do
// TFile f("gtime.root");
// g.Draw();
}
Author
Rene Brun

Definition in file gtime.C.

TArrow.h
m
auto * m
Definition: textangle.C:8
TGraphTime.h
ymax
float ymax
Definition: THbookFile.cxx:95
f
#define f(i)
Definition: RSha256.hxx:122
TMath::Cos
Double_t Cos(Double_t)
Definition: TMath.h:643
Form
char * Form(const char *fmt,...)
r
ROOT::R::TRInterface & r
Definition: Object.C:4
xmax
float xmax
Definition: THbookFile.cxx:95
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
Int_t
int Int_t
Definition: RtypesCore.h:45
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TCanvas.h
TROOT.h
TMath::Pi
constexpr Double_t Pi()
Definition: TMath.h:43
xmin
float xmin
Definition: THbookFile.cxx:95
TRandom3
Definition: TRandom3.h:27
TRandom3.h
TMath::Sin
Double_t Sin(Double_t)
Definition: TMath.h:639
kRed
@ kRed
Definition: Rtypes.h:66
TFile
Definition: TFile.h:54
ymin
float ymin
Definition: THbookFile.cxx:95
TPaveLabel
Definition: TPaveLabel.h:20
Double_t
double Double_t
Definition: RtypesCore.h:59
TArrow
Definition: TArrow.h:29
kBlue
@ kBlue
Definition: Rtypes.h:66
TGraphTime
Definition: TGraphTime.h:29
TMarker
Definition: TMarker.h:22
kYellow
@ kYellow
Definition: Rtypes.h:66
TText.h
TMath.h
g
#define g(i)
Definition: RSha256.hxx:123