Logo ROOT   6.10/09
Reference Guide
tornado.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_pyroot
3 ## Tornado example.
4 ## \notebook
5 ##
6 ## \macro_image
7 ## \macro_code
8 ##
9 ## \author Wim Lavrijsen
10 
11 from ROOT import TCanvas, TView, TPolyMarker3D, TPaveText
12 from ROOT import gROOT, gBenchmark
13 from math import cos, sin, pi
14 
15 gBenchmark.Start( 'tornado' )
16 
17 d = 16
18 numberOfPoints = 200
19 numberOfCircles = 40
20 
21 # create and open a canvas
22 sky = TCanvas( 'sky', 'Tornado', 300, 10, 700, 500 )
23 sky.SetFillColor( 14 )
24 
25 # creating view
26 view = TView.CreateView()
27 rng = numberOfCircles * d
28 view.SetRange( 0, 0, 0, 4.0*rng, 2.0*rng, rng )
29 
30 polymarkers = []
31 for j in range( d, numberOfCircles * d, d ):
32 
33  # create a PolyMarker3D
34  pm3d = TPolyMarker3D( numberOfPoints )
35 
36  # set points
37  for i in range( 1, numberOfPoints ) :
38  csin = sin( 2*pi / numberOfPoints * i ) + 1
39  ccos = cos( 2*pi / numberOfPoints * i ) + 1
40  esin = sin( 2*pi / (numberOfCircles*d) * j ) + 1
41  x = j * ( csin + esin );
42  y = j * ccos;
43  z = j;
44  pm3d.SetPoint( i, x, y, z );
45 
46  # set marker size, color & style
47  pm3d.SetMarkerSize( 1 )
48  pm3d.SetMarkerColor( 2 + ( d == ( j & d ) ) )
49  pm3d.SetMarkerStyle( 3 )
50 
51  # draw
52  pm3d.Draw()
53 
54  # save a reference
55  polymarkers.append( pm3d )
56 
57 gBenchmark.Show( 'tornado' )
58 
59 ct = gBenchmark.GetCpuTime( 'tornado' )
60 timeStr = 'Execution time: %g sec.' % ct
61 
62 text = TPaveText( 0.1, 0.81, 0.9, 0.97 )
63 text.SetFillColor( 42 )
64 text.AddText( 'PyROOT example: tornado.py' )
65 text.AddText( timeStr )
66 text.Draw()
67 
68 sky.Update()
double cos(double)
double sin(double)
The Canvas class.
Definition: TCanvas.h:31
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
static TView * CreateView(Int_t system=1, const Double_t *rmin=0, const Double_t *rmax=0)
Create a concrete default 3-d view via the plug-in manager.
Definition: TView.cxx:39
A 3D polymarker.
Definition: TPolyMarker3D.h:32