Logo ROOT  
Reference Guide
gtime2.C File Reference

Detailed Description

View in nbviewer Open in SWAN Example of TGraphTime showing how the class could be used to visualize a set of particles with their time stamp in a MonteCarlo program.

#include "TRandom3.h"
#include "TMath.h"
#include "TMarker.h"
#include "TPaveLabel.h"
#include "TArrow.h"
#include "TGraphTime.h"
void gtime2(Int_t nsteps = 200, Int_t np=5000) {
if (np > 5000) np = 5000;
Int_t color[5000];
Double_t cosphi[5000], sinphi[5000], speed[5000];
Double_t xmin = 0, xmax = 10, ymin = -10, ymax = 10;
g->SetTitle("TGraphTime demo 2;X;Y");
Int_t i,s;
Double_t phi,fact = xmax/Double_t(nsteps);
for (i=0;i<np;i++) { //calculate some object parameters
speed[i] = r.Uniform(0.5,1);
phi = r.Gaus(0,TMath::Pi()/6.);
cosphi[i] = fact*speed[i]*TMath::Cos(phi);
sinphi[i] = fact*speed[i]*TMath::Sin(phi);
Double_t rc = r.Rndm();
color[i] = kRed;
if (rc > 0.3) color[i] = kBlue;
if (rc > 0.7) color[i] = kYellow;
}
for (s=0;s<nsteps;s++) { //fill the TGraphTime step by step
for (i=0;i<np;i++) {
Double_t xx = s*cosphi[i];
if (xx < xmin) continue;
Double_t yy = s*sinphi[i];
TMarker *m = new TMarker(xx,yy,25);
m->SetMarkerColor(color[i]);
m->SetMarkerSize(1.5 -s/(speed[i]*nsteps));
g->Add(m,s);
}
g->Add(new TPaveLabel(.70,.92,.98,.99,Form("shower at %5.3f nsec",3.*s/nsteps),"brNDC"),s);
}
g->Draw();
}
Author
Rene Brun

Definition in file gtime2.C.

TArrow.h
m
auto * m
Definition: textangle.C:8
TGraphTime.h
ymax
float ymax
Definition: THbookFile.cxx:95
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
TPaveLabel.h
TMath::Pi
constexpr Double_t Pi()
Definition: TMath.h:43
xmin
float xmin
Definition: THbookFile.cxx:95
TRandom3
Definition: TRandom3.h:27
TMarker.h
TRandom3.h
TMath::Sin
Double_t Sin(Double_t)
Definition: TMath.h:639
kRed
@ kRed
Definition: Rtypes.h:66
ymin
float ymin
Definition: THbookFile.cxx:95
TPaveLabel
Definition: TPaveLabel.h:20
Double_t
double Double_t
Definition: RtypesCore.h:59
kBlue
@ kBlue
Definition: Rtypes.h:66
TGraphTime
Definition: TGraphTime.h:29
TMarker
Definition: TMarker.h:22
kYellow
@ kYellow
Definition: Rtypes.h:66
TMath.h
g
#define g(i)
Definition: RSha256.hxx:123