Logo ROOT  
Reference Guide
parallelcoord.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_tree
3 /// \notebook -nodraw
4 /// Script illustrating the use of the TParalleCoord class
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Bastien Dallapiazza
10 
11 #include "TFile.h"
12 #include "TCanvas.h"
13 #include "TStyle.h"
14 #include "TRandom.h"
15 #include "TNtuple.h"
16 #include "TParallelCoord.h"
17 #include "TParallelCoordVar.h"
18 #include "TParallelCoordRange.h"
19 
20 Double_t r1,r2,r3,r4,r5,r6,r7,r8,r9;
21 Double_t dr = 3.5;
22 TRandom *r;
23 
24 void generate_random(Int_t i) {
25  r1 = (2*dr*r->Rndm(i))-dr;
26  r2 = (2*dr*r->Rndm(i))-dr;
27  r7 = (2*dr*r->Rndm(i))-dr;
28  r9 = (2*dr*r->Rndm(i))-dr;
29  r4 = (2*dr*r->Rndm(i))-dr;
30  r3 = (2*dr*r->Rndm(i))-dr;
31  r5 = (2*dr*r->Rndm(i))-dr;
32  r6 = (2*dr*r->Rndm(i))-dr;
33  r8 = (2*dr*r->Rndm(i))-dr;
34 }
35 
36 void parallelcoord() {
37 
38  TNtuple *nt = NULL;
39 
40  Double_t s1x, s1y, s1z;
41  Double_t s2x, s2y, s2z;
42  Double_t s3x, s3y, s3z;
43  r = new TRandom();;
44 
45  new TCanvas("c1", "c1",0,0,800,700);
46 
47  nt = new TNtuple("nt","Demo ntuple","x:y:z:u:v:w");
48 
49  for (Int_t i=0; i<20000; i++) {
50  r->Sphere(s1x, s1y, s1z, 0.1);
51  r->Sphere(s2x, s2y, s2z, 0.2);
52  r->Sphere(s3x, s3y, s3z, 0.05);
53 
54  generate_random(i);
55  nt->Fill(r1, r2, r3, r4, r5, r6);
56 
57  generate_random(i);
58  nt->Fill(s1x, s1y, s1z, s2x, s2y, s2z);
59 
60  generate_random(i);
61  nt->Fill(r1, r2, r3, r4, r5, r6);
62 
63  generate_random(i);
64  nt->Fill(s2x-1, s2y-1, s2z, s1x+.5, s1y+.5, s1z+.5);
65 
66  generate_random(i);
67  nt->Fill(r1, r2, r3, r4, r5, r6);
68 
69  generate_random(i);
70  nt->Fill(s1x+1, s1y+1, s1z+1, s3x-2, s3y-2, s3z-2);
71 
72  generate_random(i);
73  nt->Fill(r1, r2, r3, r4, r5, r6);
74  }
75  nt->Draw("x:y:z:u:v:w","","para",5000);
76  TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
77  para->SetDotsSpacing(5);
78  TParallelCoordVar* firstaxis = (TParallelCoordVar*)para->GetVarList()->FindObject("x");
79  firstaxis->AddRange(new TParallelCoordRange(firstaxis,0.846018,1.158469));
80  para->AddSelection("violet");
82  firstaxis->AddRange(new TParallelCoordRange(firstaxis,-0.169447,0.169042));
83  para->AddSelection("Orange");
85  firstaxis->AddRange(new TParallelCoordRange(firstaxis,-1.263024,-0.755292));
86 }
TParallelCoordVar
TParallelCoord axes.
Definition: TParallelCoordVar.h:24
TParallelCoordVar::AddRange
void AddRange(TParallelCoordRange *range)
Add a range to the current selection on the axis.
Definition: TParallelCoordVar.cxx:102
TNtuple
A simple TTree restricted to a list of float variables only.
Definition: TNtuple.h:28
TList::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:577
r
ROOT::R::TRInterface & r
Definition: Object.C:4
kViolet
@ kViolet
Definition: Rtypes.h:67
TParallelCoord::GetVarList
TList * GetVarList()
Definition: TParallelCoord.h:102
TRandom.h
TParallelCoordVar.h
TStyle.h
TParallelCoord
Parallel Coordinates class.
Definition: TParallelCoord.h:28
Int_t
int Int_t
Definition: RtypesCore.h:45
kOrange
@ kOrange
Definition: Rtypes.h:67
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
TCanvas.h
TFile.h
TNtuple.h
TParallelCoord::GetCurrentSelection
TParallelCoordSelect * GetCurrentSelection()
Return the selection currently being edited.
Definition: TParallelCoord.cxx:438
TParallelCoordRange.h
TRandom
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
TParallelCoord.h
TTree::Draw
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TTree.h:427
TParallelCoord::SetDotsSpacing
void SetDotsSpacing(Int_t s=0)
Set dots spacing.
Definition: TParallelCoord.cxx:1114
TParallelCoordRange
A TParallelCoordRange is a range used for parallel coordinates plots.
Definition: TParallelCoordRange.h:25
Double_t
double Double_t
Definition: RtypesCore.h:59
TCanvas
The Canvas class.
Definition: TCanvas.h:23
gPad
#define gPad
Definition: TVirtualPad.h:287
TParallelCoord::AddSelection
void AddSelection(const char *title)
Add a selection.
Definition: TParallelCoord.cxx:242
TNtuple::Fill
virtual Int_t Fill()
Fill a Ntuple with current values in fArgs.
Definition: TNtuple.cxx:169