ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
parallelcoordtrans.C
Go to the documentation of this file.
1 // Script illustrating the use of transparency with ||-Coord.
2 // It displays the same data set twice. The first time without transparency and
3 // the second time with transparency. On the second plot, several clusters
4 // appear.
5 
6 //Authors: by Timur Pocheptsov, based on macro by Olivier Couet.
7 
8 
9 //All these includes are (only) to make the macro
10 //ACLiCable.
11 #include <cassert>
12 
13 #include "TParallelCoordVar.h"
14 #include "TParallelCoord.h"
15 #include "TNtuple.h"
16 #include "TCanvas.h"
17 #include "TRandom.h"
18 #include "TColor.h"
19 #include "TStyle.h"
20 #include "TError.h"
21 #include "TList.h"
22 #include "TROOT.h"
23 
24 namespace ROOT {
25 namespace GLTutorials {
26 
27 Double_t r1, r2, r3, r4, r5, r6, r7, r8, r9;
29 
30 //______________________________________________________________________
32 {
33  const Double_t dr = 3.5;
34 
35  r.Rannor(r1, r4);
36  r.Rannor(r7, r9);
37 
38  r2 = (2 * dr * r.Rndm(i)) - dr;
39  r3 = (2 * dr * r.Rndm(i)) - dr;
40  r5 = (2 * dr * r.Rndm(i)) - dr;
41  r6 = (2 * dr * r.Rndm(i)) - dr;
42  r8 = (2 * dr * r.Rndm(i)) - dr;
43 }
44 
45 }//GLTutorials
46 }//ROOT
47 
49 {
50  //This macro shows how to use parallel coords and semi-transparent lines
51  //(the system color is updated with alpha == 0.01 (1% opaque).
52 
53  using namespace ROOT::GLTutorials;
54 
55  Double_t s1x = 0., s1y = 0., s1z = 0.;
56  Double_t s2x = 0., s2y = 0., s2z = 0.;
57  Double_t s3x = 0., s3y = 0., s3z = 0.;
58 
60  TCanvas *c1 = new TCanvas("parallel coors", "parallel coords", 0, 0, 900, 1000);
61 
62  TNtuple * const nt = new TNtuple("nt", "Demo ntuple", "x:y:z:u:v:w:a:b:c");
63 
64  for (Int_t i = 0; i < 1500; ++i) {
65  r.Sphere(s1x, s1y, s1z, 0.1);
66  r.Sphere(s2x, s2y, s2z, 0.2);
67  r.Sphere(s3x, s3y, s3z, 0.05);
68 
69  generate_random(i);
70  nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9);
71 
72  generate_random(i);
73  nt->Fill(s1x, s1y, s1z, s2x, s2y, s2z, r7, r8, r9);
74 
75  generate_random(i);
76  nt->Fill(r1, r2, r3, r4, r5, r6, r7, s3y, r9);
77 
78  generate_random(i);
79  nt->Fill(s2x - 1, s2y - 1, s2z, s1x + .5, s1y + .5, s1z + .5, r7, r8, r9);
80 
81  generate_random(i);
82  nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9);
83 
84  generate_random(i);
85  nt->Fill(s1x + 1, s1y + 1, s1z + 1, s3x - 2, s3y - 2, s3z - 2, r7, r8, r9);
86 
87  generate_random(i);
88  nt->Fill(r1, r2, r3, r4, r5, r6, s3x, r8, s3z);
89  }
90 
91  c1->Divide(1, 2);
92  c1->cd(1);
93 
94  // ||-Coord plot without transparency
95  nt->Draw("x:y:z:u:v:w:a:b:c", "", "para");
96  TParallelCoord * const para1 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
97  assert(para1 != 0 && "parallelcoordtrans, 'ParaCoord' is null");
98 
99  para1->SetLineColor(25);
100  TParallelCoordVar *pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("x");
101  pcv->SetHistogramHeight(0.);
102 
103  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("y");
104  pcv->SetHistogramHeight(0.);
105 
106  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("z");
107  pcv->SetHistogramHeight(0.);
108 
109  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("a");
110  pcv->SetHistogramHeight(0.);
111 
112  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("b");
113  pcv->SetHistogramHeight(0.);
114 
115  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("c");
116  pcv->SetHistogramHeight(0.);
117 
118  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("u");
119  pcv->SetHistogramHeight(0.);
120 
121  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("v");
122  pcv->SetHistogramHeight(0.);
123 
124  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("w");
125  pcv->SetHistogramHeight(0.);
126 
127  // ||-Coord plot with transparency
128  // We modify a 'system' color! You'll probably
129  // have to restart ROOT or reset this color later.
130  TColor * const col26 = gROOT->GetColor(26);
131  assert(col26 != 0 && "parallelcoordtrans, color with index 26 not found");
132 
133  col26->SetAlpha(0.01);
134 
135  c1->cd(2);
136  nt->Draw("x:y:z:u:v:w:a:b:c","","para");
137  TParallelCoord * const para2 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
138  assert(para2 != 0 && "parallelcoordtrans, 'ParaCoord' is null");
139 
140  para2->SetLineColor(26);
141 
142  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("x");
143  pcv->SetHistogramHeight(0.);
144 
145  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("y");
146  pcv->SetHistogramHeight(0.);
147 
148  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("z");
149  pcv->SetHistogramHeight(0.);
150 
151  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("a");
152  pcv->SetHistogramHeight(0.);
153 
154  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("b");
155  pcv->SetHistogramHeight(0.);
156 
157  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("c");
158  pcv->SetHistogramHeight(0.);
159 
160  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("u");
161  pcv->SetHistogramHeight(0.);
162 
163  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("v");
164  pcv->SetHistogramHeight(0.);
165 
166  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("w");
167  pcv->SetHistogramHeight(0.);
168 }
void generate_random(Int_t i)
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition: TRandom.cxx:460
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
Definition: TRandom.cxx:512
TCanvas * c1
Definition: legend1.C:2
#define assert(cond)
Definition: unittest.h:542
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
#define gROOT
Definition: TROOT.h:344
int Int_t
Definition: RtypesCore.h:41
TParallelCoord axes.
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:29
void parallelcoordtrans()
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Definition: TStyle.h:337
double Double_t
Definition: RtypesCore.h:55
The color creation and management class.
Definition: TColor.h:47
virtual void Sphere(Double_t &x, Double_t &y, Double_t &z, Double_t r)
Generates random vectors, uniformly distributed over the surface of a sphere of given radius...
Definition: TRandom.cxx:588
Parallel Coordinates class.
#define gPad
Definition: TVirtualPad.h:288
Double_t dr
Definition: parallelcoord.C:14
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:379