Logo ROOT   6.10/09
Reference Guide
TParallelCoord.cxx
Go to the documentation of this file.
1 // @(#)root/treeviewer:$Id$
2 // Author: Bastien Dalla Piazza 02/08/2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TParallelCoord.h"
13 #include "TParallelCoordVar.h"
14 #include "TParallelCoordRange.h"
15 
16 #include "Riostream.h"
17 #include "TROOT.h"
18 #include "TVirtualX.h"
19 #include "TPad.h"
20 #include "TPolyLine.h"
21 #include "TGraph.h"
22 #include "TPaveText.h"
23 #include "float.h"
24 #include "TMath.h"
25 #include "TBox.h"
26 #include "TH1.h"
27 #include "TStyle.h"
28 #include "TEntryList.h"
29 #include "TFrame.h"
30 #include "TTree.h"
31 #include "TTreePlayer.h"
32 #include "TSelectorDraw.h"
33 #include "TTreeFormula.h"
34 #include "TView.h"
35 #include "TRandom.h"
36 #include "TEnv.h"
37 #include "TCanvas.h"
38 #include "TGaxis.h"
39 #include "TFile.h"
40 
42 
43 /** \class TParallelCoord
44 Parallel Coordinates class.
45 
46 The multidimensional system of Parallel coordinates is a common way of studying
47 high-dimensional geometry and visualizing multivariate problems. It has first
48 been proposed by A. Inselberg in 1981.
49 
50 To show a set of points in an n-dimensional space, a backdrop is drawn
51 consisting of n parallel lines. A point in n-dimensional space is represented as
52 a polyline with vertices on the parallel axes; the position of the vertex on the
53 i-th axis corresponds to the i-th coordinate of the point.
54 
55 This tool comes with a rather large gui in the editor. It is necessary to use
56 this editor in order to explore a data set, as explained below.
57 
58 ### Reduce cluttering:
59 
60 The main issue for parallel coordinates is the very high cluttering of the
61 output when dealing with large data set. Two techniques have been implemented to
62 bypass that so far:
63 
64  - Draw doted lines instead of plain lines with an adjustable dots spacing. A
65  slider to adjust the dots spacing is available in the editor.
66  - Sort the entries to display with a "weight cut". On each axis is drawn a
67  histogram describing the distribution of the data on the corresponding
68  variable. The "weight" of an entry is the sum of the bin content of each bin
69  the entry is going through. An entry going through the histograms peaks will
70  have a big weight wether an entry going randomly through the histograms will
71  have a rather small weight. Setting a cut on this weight allows to draw only
72  the most representative entries. A slider set the cut is also available in
73  the gui.
74 
75 ## Selections:
76 
77 Selections of specific entries can be defined over the data se using parallel
78 coordinates. With that representation, a selection is an ensemble of ranges
79 defined on the axes. Ranges defined on the same axis are conjugated with OR
80 (an entry must be in one or the other ranges to be selected). Ranges on
81 different axes are are conjugated with AND (an entry must be in all the ranges
82 to be selected). Several selections can be defined with different colors. It is
83 possible to generate an entry list from a given selection and apply it to the
84 tree using the editor ("Apply to tree" button).
85 
86 ## Axes:
87 
88 Options can be defined each axis separately using the right mouse click. These
89 options can be applied to every axes using the editor.
90 
91  - Axis width: If set to 0, the axis is simply a line. If higher, a color
92  histogram is drawn on the axis.
93  - Axis histogram height: If not 0, a usual bar histogram is drawn on the plot.
94 
95 The order in which the variables are drawn is essential to see the clusters. The
96 axes can be dragged to change their position. A zoom is also available. The
97 logarithm scale is also available by right clicking on the axis.
98 
99 ## Candle chart:
100 
101 TParallelCoord can also be used to display a candle chart. In that mode, every
102 variable is drawn in the same scale. The candle chart can be combined with the
103 parallel coordinates mode, drawing the candle sticks over the axes.
104 
105 ~~~ {.cpp}
106 {
107  TCanvas *c1 = new TCanvas("c1");
108  TFile *f = TFile::Open("cernstaff.root");
109  TTree *T = (TTree*)f->Get("T");
110  T->Draw("Age:Grade:Step:Cost:Division:Nation","","para");
111  TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
112  TParallelCoordVar* grade = (TParallelCoordVar*)para->GetVarList()->FindObject("Grade");
113  grade->AddRange(new TParallelCoordRange(grade,11.5,14));
114  para->AddSelection("less30");
115  para->GetCurrentSelection()->SetLineColor(kViolet);
116  TParallelCoordVar* age = (TParallelCoordVar*)para->GetVarList()->FindObject("Age");
117  age->AddRange(new TParallelCoordRange(age,21,30));
118 }
119 ~~~
120 
121 ### Some references:
122 
123  - Alfred Inselberg's Homepage <http://www.math.tau.ac.il/~aiisreal>, with
124  Visual Tutorial, History, Selected Publications and Applications.
125  - Almir Olivette Artero, Maria Cristina Ferreira de Oliveira, Haim Levkowitz,
126  "Uncovering Clusters in Crowded Parallel Coordinates Visualizations,"
127  infovis, pp. 81-88, IEEE Symposium on Information Visualization
128  (INFOVIS'04), 2004.
129 */
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Default constructor.
133 
135  :TNamed()
136 {
137  Init();
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// Constructor without a reference to a tree,
142 /// the datas must be added afterwards with
143 /// TParallelCoord::AddVariable(Double_t*,const char*).
144 
146 {
147  Init();
150  fVarList = new TList();
151  fSelectList = new TList();
154 }
155 
156 ////////////////////////////////////////////////////////////////////////////////
157 /// Normal constructor, the datas must be added afterwards
158 /// with TParallelCoord::AddVariable(Double_t*,const char*).
159 
161  :TNamed("ParaCoord","ParaCoord")
162 {
163  Init();
164  Int_t estimate = tree->GetEstimate();
165  if (nentries>estimate) {
166  Warning("TParallelCoord","Call tree->SetEstimate(tree->GetEntries()) to display all the tree variables");
168  } else {
170  }
172  fTree = tree;
173  fTreeName = fTree->GetName();
175  else fTreeFileName = "";
176  fVarList = new TList();
177  fSelectList = new TList();
180 }
181 
182 ////////////////////////////////////////////////////////////////////////////////
183 /// Destructor.
184 
186 {
188  if (fVarList) {
189  fVarList->Delete();
190  delete fVarList;
191  }
192  if (fSelectList) {
193  fSelectList->Delete();
194  delete fSelectList;
195  }
196  if (fCandleAxis) delete fCandleAxis;
197  SetDotsSpacing(0);
198 }
199 
200 ////////////////////////////////////////////////////////////////////////////////
201 /// Add a variable.
202 
203 void TParallelCoord::AddVariable(Double_t* val, const char* title)
204 {
205  ++fNvar;
206  fVarList->Add(new TParallelCoordVar(val,title,fVarList->GetSize(),this));
207  SetAxesPosition();
208 }
209 
210 ////////////////////////////////////////////////////////////////////////////////
211 /// Add a variable from an expression.
212 
213 void TParallelCoord::AddVariable(const char* varexp)
214 {
215  if(!fTree) return; // The tree from which one will get the data must be defined.
216 
217  // Select in the only the entries of this TParallelCoord.
218  TEntryList *list = GetEntryList(kFALSE);
219  fTree->SetEntryList(list);
220 
221  // ensure that there is only one variable given:
222 
223  TString exp = varexp;
224 
225  if (exp.Contains(':') || exp.Contains(">>") || exp.Contains("<<")) {
226  Warning("AddVariable","Only a single variable can be added at a time.");
227  return;
228  }
229  if (exp == ""){
230  Warning("AddVariable","Nothing to add");
231  return;
232  }
233 
234  Long64_t en = fTree->Draw(varexp,"","goff");
235  if (en<0) {
236  Warning("AddVariable","%s could not be evaluated",varexp);
237  return;
238  }
239 
240  AddVariable(fTree->GetV1(),varexp);
242  var->Draw();
243 }
244 
245 ////////////////////////////////////////////////////////////////////////////////
246 /// Add a selection.
247 
248 void TParallelCoord::AddSelection(const char* title)
249 {
250  TParallelCoordSelect *sel = new TParallelCoordSelect(title);
251  fSelectList->Add(sel);
252  fCurrentSelection = sel;
253 }
254 
255 ////////////////////////////////////////////////////////////////////////////////
256 /// Apply the current selection to the tree.
257 
259 {
260  if(!fTree) return;
261  if(fSelectList) {
262  if(fSelectList->GetSize() == 0) return;
264  }
267  fCurrentFirst = 0;
270  TString varexp = "";
271  TIter next(fVarList);
272  TParallelCoordVar* var;
273  while ((var = (TParallelCoordVar*)next())) varexp.Append(Form(":%s",var->GetTitle()));
274  varexp.Remove(TString::kLeading,':');
275  TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)fTree->GetPlayer())->GetSelector();
276  fTree->Draw(varexp.Data(),"","goff");
277  next.Reset();
278  Int_t i = 0;
279  while ((var = (TParallelCoordVar*)next())) {
280  var->SetValues(fNentries, selector->GetVal(i));
281  ++i;
282  }
283  if (fSelectList) { // FIXME It would be better to update the selections by deleting
284  fSelectList->Delete(); // the meaningless ranges (selecting everything or nothing for example)
285  fCurrentSelection = 0; // after applying a new entrylist to the tree.
286  }
287  gPad->Modified();
288  gPad->Update();
289 }
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 /// Call constructor and add the variables.
293 
295 {
296  TParallelCoord* pc = new TParallelCoord(selector->GetTree(),selector->GetNfill());
297  pc->SetBit(kCanDelete);
298  selector->SetObject(pc);
299  TString varexp = "";
300  for(Int_t i=0;i<selector->GetDimension();++i) {
301  if (selector->GetVal(i)) {
302  if (selector->GetVar(i)) {
303  pc->AddVariable(selector->GetVal(i),selector->GetVar(i)->GetTitle());
304  varexp.Append(Form(":%s",selector->GetVar(i)->GetTitle()));
305  }
306  }
307  }
308  varexp.Remove(TString::kLeading,':');
309  if (selector->GetSelect()) varexp.Append(Form("{%s}",selector->GetSelect()->GetTitle()));
310  pc->SetTitle(varexp.Data());
311  if (!candle) pc->Draw();
312  else pc->Draw("candle");
313 }
314 
315 ////////////////////////////////////////////////////////////////////////////////
316 /// Clean up the selections from the ranges which could have been deleted
317 /// when a variable has been deleted.
318 
320 {
321  TIter next(fSelectList);
322  TParallelCoordSelect* select;
323  while ((select = (TParallelCoordSelect*)next())){
324  if(select->Contains(range)) select->Remove(range);
325  }
326 }
327 
328 ////////////////////////////////////////////////////////////////////////////////
329 /// Delete a selection.
330 
332 {
333  fSelectList->Remove(sel);
334  delete sel;
335  if(fSelectList->GetSize() == 0) fCurrentSelection = 0;
337 }
338 
339 ////////////////////////////////////////////////////////////////////////////////
340 /// Compute the distance from the TParallelCoord.
341 
343 {
344  if(!gPad) return 9999;
345 
346  TFrame *frame = gPad->GetFrame();
347 
348  Double_t x1,x2,y1,y2,xx,yy;
349 
350  x1 = frame->GetX1()+0.01;
351  x2 = frame->GetX2()-0.01;
352  y2 = frame->GetY2()-0.01;
353  y1 = frame->GetY1()+0.01;
354 
355  xx = gPad->AbsPixeltoX(px);
356  yy = gPad->AbsPixeltoY(py);
357 
358  if(xx>x1 && xx<x2 && yy>y1 && yy<y2) return 0;
359  else return 9999;
360 }
361 
362 ////////////////////////////////////////////////////////////////////////////////
363 /// Draw the parallel coordinates graph.
364 
366 {
367  if (!GetTree()) return;
369  Bool_t optcandle = kFALSE;
370  TString opt = option;
371  opt.ToLower();
372  if(opt.Contains("candle")) {
373  optcandle = kTRUE;
374  opt.ReplaceAll("candle","");
375  }
376  if(optcandle) {
380  }
381 
382  if (gPad) {
383  if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
384  } else gROOT->MakeDefCanvas();
385  TView *view = gPad->GetView();
386  if(view){
387  delete view;
388  gPad->SetView(0);
389  }
390  gPad->Clear();
391  if (!optcandle) {
392  if (gPad && gPad->IsA() == TCanvas::Class()
393  && !((TCanvas*)gPad)->GetShowEditor()) {
394  ((TCanvas*)gPad)->ToggleEditor();
395  ((TCanvas*)gPad)->ToggleEventStatus();
396  }
397  }
398 
399  gPad->SetBit(TGraph::kClipFrame,kTRUE);
400 
401  TFrame *frame = new TFrame(0.1,0.1,0.9,0.9);
402  frame->SetBorderSize(0);
403  frame->SetBorderMode(0);
404  frame->SetFillStyle(0);
405  frame->SetLineColor(gPad->GetFillColor());
406  frame->Draw();
407  AppendPad(option);
408  TPaveText *title = new TPaveText(0.05,0.95,0.35,1);
409  title->AddText(GetTitle());
410  title->Draw();
411  SetAxesPosition();
412  TIter next(fVarList);
413  TParallelCoordVar* var;
414  while ((var = (TParallelCoordVar*)next())) {
415  if(optcandle) {
416  var->SetBoxPlot(kTRUE);
417  var->SetHistogramHeight(0.5);
418  var->SetHistogramLineWidth(0);
419  }
420  var->Draw();
421  }
422 
423  if (optcandle) {
424  if (TestBit(kVertDisplay)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,GetGlobalMin(),GetGlobalMax());
425  else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,GetGlobalMin(),GetGlobalMax());
426  fCandleAxis->Draw();
427  }
428 
429  if (gPad && gPad->IsA() == TCanvas::Class())
430  ((TCanvas*)gPad)->Selected(gPad,this,1);
431 }
432 
433 ////////////////////////////////////////////////////////////////////////////////
434 /// Execute the corresponding entry.
435 
436 void TParallelCoord::ExecuteEvent(Int_t /*entry*/, Int_t /*px*/, Int_t /*py*/)
437 {
438  if (!gPad) return;
439  gPad->SetCursor(kHand);
440 }
441 
442 ////////////////////////////////////////////////////////////////////////////////
443 /// Return the selection currently being edited.
444 
446 {
447  if (!fSelectList) return 0;
448  if (!fCurrentSelection) {
450  }
451  return fCurrentSelection;
452 }
453 
454 ////////////////////////////////////////////////////////////////////////////////
455 /// Get the whole entry list or one for a selection.
456 
458 {
459  if(!sel || fCurrentSelection->GetSize() == 0){ // If no selection is specified, return the entry list of all the entries.
460  return fInitEntries;
461  } else { // return the entry list corresponding to the current selection.
462  TEntryList *enlist = new TEntryList(fTree);
463  TIter next(fVarList);
464  for (Long64_t li=0;li<fNentries;++li) {
465  next.Reset();
466  Bool_t inrange=kTRUE;
467  TParallelCoordVar* var;
468  while((var = (TParallelCoordVar*)next())){
469  if(!var->Eval(li,fCurrentSelection)) inrange = kFALSE;
470  }
471  if(!inrange) continue;
472  enlist->Enter(fCurrentEntries->GetEntry(li));
473  }
474  return enlist;
475  }
476 }
477 
478 ////////////////////////////////////////////////////////////////////////////////
479 /// return the global maximum.
480 
482 {
483  Double_t gmax=-DBL_MAX;
484  TIter next(fVarList);
485  TParallelCoordVar* var;
486  while ((var = (TParallelCoordVar*)next())) {
487  if (gmax < var->GetCurrentMax()) gmax = var->GetCurrentMax();
488  }
489  return gmax;
490 }
491 
492 ////////////////////////////////////////////////////////////////////////////////
493 /// return the global minimum.
494 
496 {
497  Double_t gmin=DBL_MAX;
498  TIter next(fVarList);
499  TParallelCoordVar* var;
500  while ((var = (TParallelCoordVar*)next())) {
501  if (gmin > var->GetCurrentMin()) gmin = var->GetCurrentMin();
502  }
503  return gmin;
504 }
505 
506 ////////////////////////////////////////////////////////////////////////////////
507 /// get the binning of the histograms.
508 
510 {
511  return ((TParallelCoordVar*)fVarList->First())->GetNbins();
512 }
513 
514 ////////////////////////////////////////////////////////////////////////////////
515 /// Get a selection from its title.
516 
518 {
519  TIter next(fSelectList);
521  while ((sel = (TParallelCoordSelect*)next()) && strcmp(title,sel->GetTitle())) { }
522  return sel;
523 }
524 
525 ////////////////////////////////////////////////////////////////////////////////
526 /// return the tree if fTree is defined. If not, the method try to load the tree
527 /// from fTreeFileName.
528 
530 {
531  if (fTree) return fTree;
532  if (fTreeFileName=="" || fTreeName=="") {
533  Error("GetTree","Cannot load the tree: no tree defined!");
534  return 0;
535  }
537  if (!f) {
538  Error("GetTree","Tree file name : \"%s\" does not exist (Are you in the correct directory?).",fTreeFileName.Data());
539  return 0;
540  } else if (f->IsZombie()) {
541  Error("GetTree","while opening \"%s\".",fTreeFileName.Data());
542  return 0;
543  } else {
544  fTree = (TTree*)f->Get(fTreeName.Data());
545  if (!fTree) {
546  Error("GetTree","\"%s\" not found in \"%s\".", fTreeName.Data(), fTreeFileName.Data());
547  return 0;
548  } else {
550  TString varexp = "";
551  TIter next(fVarList);
552  TParallelCoordVar* var;
553  while ((var = (TParallelCoordVar*)next())) varexp.Append(Form(":%s",var->GetTitle()));
554  varexp.Remove(TString::kLeading,':');
555  fTree->Draw(varexp.Data(),"","goff");
556  TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)fTree->GetPlayer())->GetSelector();
557  next.Reset();
558  Int_t i = 0;
559  while ((var = (TParallelCoordVar*)next())) {
560  var->SetValues(fNentries, selector->GetVal(i));
561  ++i;
562  }
563  return fTree;
564  }
565  }
566 }
567 
568 ////////////////////////////////////////////////////////////////////////////////
569 /// Get the variables values from its title.
570 
571 Double_t* TParallelCoord::GetVariable(const char* vartitle)
572 {
573  TIter next(fVarList);
574  TParallelCoordVar* var = 0;
575  while(((var = (TParallelCoordVar*)next()) != 0) && (var->GetTitle() != vartitle)) { }
576  if(!var) return 0;
577  else return var->GetValues();
578 }
579 
580 ////////////////////////////////////////////////////////////////////////////////
581 /// Get the variables values from its index.
582 
584 {
585  if(i<0 || (UInt_t)i>fNvar) return 0;
586  else return ((TParallelCoordVar*)fVarList->At(i))->GetValues();
587 }
588 
589 ////////////////////////////////////////////////////////////////////////////////
590 /// Initialise the data members of TParallelCoord.
591 
593 {
594  fNentries = 0;
595  fVarList = 0;
596  fSelectList = 0;
604  fTree = 0;
605  fCurrentEntries = 0;
606  fInitEntries = 0;
607  fCurrentSelection = 0;
608  fNvar = 0;
609  fDotsSpacing = 0;
610  fCurrentFirst = 0;
611  fCurrentN = 0;
612  fCandleAxis = 0;
613  fWeightCut = 0;
614  fLineWidth = 1;
615  fLineColor = kGreen-8;
616  fTreeName = "";
617  fTreeFileName = "";
618 }
619 
620 ////////////////////////////////////////////////////////////////////////////////
621 /// Paint the parallel coordinates graph.
622 
624 {
625  if (!GetTree()) return;
626  gPad->Range(0,0,1,1);
627  TFrame *frame = gPad->GetFrame();
628  frame->SetLineColor(gPad->GetFillColor());
629  SetAxesPosition();
630  if(TestBit(kPaintEntries)){
631  PaintEntries(0);
632  TIter next(fSelectList);
634  while((sel = (TParallelCoordSelect*)next())) {
635  if(sel->GetSize()>0 && sel->TestBit(TParallelCoordSelect::kActivated)) {
636  PaintEntries(sel);
637  }
638  }
639  }
640  gPad->RangeAxis(0,0,1,1);
641 }
642 
643 ////////////////////////////////////////////////////////////////////////////////
644 /// Loop over the entries and paint them.
645 
647 {
648  if (fVarList->GetSize() < 2) return;
649  Int_t i=0;
650  Long64_t n=0;
651 
652  Double_t *x = new Double_t[fNvar];
653  Double_t *y = new Double_t[fNvar];
654 
655  TGraph *gr = 0;
656  TPolyLine *pl = 0;
657  TAttLine *evline = 0;
658 
659  if (TestBit (kCurveDisplay)) {gr = new TGraph(fNvar); evline = (TAttLine*)gr;}
660  else {pl = new TPolyLine(fNvar); evline = (TAttLine*)pl;}
661 
662  if (fDotsSpacing == 0) evline->SetLineStyle(1);
663  else evline->SetLineStyle(11);
664  if (!sel){
665  evline->SetLineWidth(GetLineWidth());
666  evline->SetLineColor(GetLineColor());
667  } else {
668  evline->SetLineWidth(sel->GetLineWidth());
669  evline->SetLineColor(sel->GetLineColor());
670  }
671  TParallelCoordVar *var;
672 
673  TFrame *frame = gPad->GetFrame();
674  Double_t lx = ((frame->GetX2() - frame->GetX1())/(fNvar-1));
675  Double_t ly = ((frame->GetY2() - frame->GetY1())/(fNvar-1));
676  Double_t a,b;
677  TRandom r;
678 
679  for (n=fCurrentFirst; n<fCurrentFirst+fCurrentN; ++n) {
680  TListIter next(fVarList);
681  Bool_t inrange = kTRUE;
682  // Loop to check whenever the entry must be painted.
683  if (sel) {
684  while ((var = (TParallelCoordVar*)next())){
685  if (!var->Eval(n,sel)) inrange = kFALSE;
686  }
687  }
688  if (fWeightCut > 0) {
689  next.Reset();
690  Int_t entryweight = 0;
691  while ((var = (TParallelCoordVar*)next())) entryweight+=var->GetEntryWeight(n);
692  if (entryweight/(Int_t)fNvar < fWeightCut) inrange = kFALSE;
693  }
694  if(!inrange) continue;
695  i = 0;
696  next.Reset();
697  // Loop to set the polyline points.
698  while ((var = (TParallelCoordVar*)next())) {
699  var->GetEntryXY(n,x[i],y[i]);
700  ++i;
701  }
702  // beginning to paint the first point at a random distance
703  // to avoid artefacts when increasing the dots spacing.
704  if (fDotsSpacing != 0) {
705  if (TestBit(kVertDisplay)) {
706  a = (y[1]-y[0])/(x[1]-x[0]);
707  b = y[0]-a*x[0];
708  x[0] = x[0]+lx*r.Rndm();
709  y[0] = a*x[0]+b;
710  } else {
711  a = (x[1]-x[0])/(y[1]-y[0]);
712  b = x[0]-a*y[0];
713  y[0] = y[0]+ly*r.Rndm();
714  x[0] = a*y[0]+b;
715  }
716  }
717  if (pl) pl->PaintPolyLine(fNvar,x,y);
718  else gr->PaintGraph(fNvar,x,y,"C");
719  }
720 
721  if (pl) delete pl;
722  if (gr) delete gr;
723  delete [] x;
724  delete [] y;
725 }
726 
727 ////////////////////////////////////////////////////////////////////////////////
728 /// Delete a variable from the graph.
729 
731 {
732  fVarList->Remove(var);
733  fNvar = fVarList->GetSize();
734  SetAxesPosition();
735 }
736 
737 ////////////////////////////////////////////////////////////////////////////////
738 /// Delete the variable "vartitle" from the graph.
739 
741 {
742  TIter next(fVarList);
743  TParallelCoordVar* var=0;
744  while((var = (TParallelCoordVar*)next())) {
745  if (!strcmp(var->GetTitle(),vartitle)) break;
746  }
747  if(!var) Error("RemoveVariable","\"%s\" not a variable",vartitle);
748  fVarList->Remove(var);
749  fNvar = fVarList->GetSize();
750  SetAxesPosition();
751  var->DeleteVariable();
752  return var;
753 }
754 
755 ////////////////////////////////////////////////////////////////////////////////
756 /// Reset the tree entry list to the initial one..
757 
759 {
760  if(!fTree) return;
764  fCurrentFirst = 0;
766  TString varexp = "";
767  TIter next(fVarList);
768  TParallelCoordVar* var;
769  while ((var = (TParallelCoordVar*)next())) varexp.Append(Form(":%s",var->GetTitle()));
770  varexp.Remove(TString::kLeading,':');
771  fTree->Draw(varexp.Data(),"","goff");
772  next.Reset();
773  TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)fTree->GetPlayer())->GetSelector();
774  Int_t i = 0;
775  while ((var = (TParallelCoordVar*)next())) {
776  var->SetValues(fNentries, selector->GetVal(i));
777  ++i;
778  }
779  if (fSelectList) { // FIXME It would be better to update the selections by deleting
780  fSelectList->Delete(); // the meaningless ranges (selecting everything or nothing for example)
781  fCurrentSelection = 0; // after applying a new entrylist to the tree.
782  }
783  gPad->Modified();
784  gPad->Update();
785 }
786 
787 ////////////////////////////////////////////////////////////////////////////////
788 /// Save the entry lists in a root file "filename.root".
789 
790 void TParallelCoord::SaveEntryLists(const char* filename, Bool_t overwrite)
791 {
792  TString sfile = filename;
793  if (sfile == "") sfile = Form("%s_parallelcoord_entries.root",fTree->GetName());
794 
795  TFile* f = TFile::Open(sfile.Data());
796  if (f) {
797  Warning("SaveEntryLists","%s already exists.", sfile.Data());
798  if (!overwrite) return;
799  else Warning("SaveEntryLists","Overwriting.");
800  f = new TFile(sfile.Data(),"RECREATE");
801  } else {
802  f = new TFile(sfile.Data(),"CREATE");
803  }
804  gDirectory = f;
805  fInitEntries->Write("initentries");
806  fCurrentEntries->Write("currententries");
807  Info("SaveEntryLists","File \"%s\" written.",sfile.Data());
808 }
809 
810 ////////////////////////////////////////////////////////////////////////////////
811 /// Save the TParallelCoord in a macro.
812 
813 void TParallelCoord::SavePrimitive(std::ostream & out, Option_t* options)
814 {
815  TString opt = options;
816  opt.ToLower();
817  //Bool_t overwrite = opt.Contains("overwrite"); // Is there a way to specify "options" when saving ?
818  // Save the entrylists.
819  const char* filename = Form("%s_parallelcoord_entries.root",fTree->GetName());
820  SaveEntryLists(filename,kTRUE); // FIXME overwriting by default.
821  SaveTree(fTreeFileName,kTRUE); // FIXME overwriting by default.
822  out<<" // Create a TParallelCoord."<<std::endl;
823  out<<" TFile *f = TFile::Open(\""<<fTreeFileName.Data()<<"\");"<<std::endl;
824  out<<" TTree* tree = (TTree*)f->Get(\""<<fTreeName.Data()<<"\");"<<std::endl;
825  out<<" TParallelCoord* para = new TParallelCoord(tree,"<<fNentries<<");"<<std::endl;
826  out<<" // Load the entrylists."<<std::endl;
827  out<<" TFile *entries = TFile::Open(\""<<filename<<"\");"<<std::endl;
828  out<<" TEntryList *currententries = (TEntryList*)entries->Get(\"currententries\");"<<std::endl;
829  out<<" tree->SetEntryList(currententries);"<<std::endl;
830  out<<" para->SetInitEntries((TEntryList*)entries->Get(\"initentries\"));"<<std::endl;
831  out<<" para->SetCurrentEntries(currententries);"<<std::endl;
832  TIter next(fSelectList);
834  out<<" TParallelCoordSelect* sel;"<<std::endl;
835  out<<" para->GetSelectList()->Delete();"<<std::endl;
836  while ((sel = (TParallelCoordSelect*)next())) {
837  out<<" para->AddSelection(\""<<sel->GetTitle()<<"\");"<<std::endl;
838  out<<" sel = (TParallelCoordSelect*)para->GetSelectList()->Last();"<<std::endl;
839  out<<" sel->SetLineColor("<<sel->GetLineColor()<<");"<<std::endl;
840  out<<" sel->SetLineWidth("<<sel->GetLineWidth()<<");"<<std::endl;
841  }
842  TIter nextbis(fVarList);
843  TParallelCoordVar* var;
844  TString varexp = "";
845  while ((var = (TParallelCoordVar*)nextbis())) varexp.Append(Form(":%s",var->GetTitle()));
846  varexp.Remove(TString::kLeading,':');
847  out<<" tree->Draw(\""<<varexp.Data()<<"\",\"\",\"goff\");"<<std::endl;
848  out<<" TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)tree->GetPlayer())->GetSelector();"<<std::endl;
849  nextbis.Reset();
850  Int_t i=0;
851  out<<" TParallelCoordVar* var;"<<std::endl;
852  while ((var = (TParallelCoordVar*)nextbis())) {
853  out<<" //***************************************"<<std::endl;
854  out<<" // Create the axis \""<<var->GetTitle()<<"\"."<<std::endl;
855  out<<" para->AddVariable(selector->GetVal("<<i<<"),\""<<var->GetTitle()<<"\");"<<std::endl;
856  out<<" var = (TParallelCoordVar*)para->GetVarList()->Last();"<<std::endl;
857  var->SavePrimitive(out,"pcalled");
858  ++i;
859  }
860  out<<" //***************************************"<<std::endl;
861  out<<" // Set the TParallelCoord parameters."<<std::endl;
862  out<<" para->SetCurrentFirst("<<fCurrentFirst<<");"<<std::endl;
863  out<<" para->SetCurrentN("<<fCurrentN<<");"<<std::endl;
864  out<<" para->SetWeightCut("<<fWeightCut<<");"<<std::endl;
865  out<<" para->SetDotsSpacing("<<fDotsSpacing<<");"<<std::endl;
866  out<<" para->SetLineColor("<<GetLineColor()<<");"<<std::endl;
867  out<<" para->SetLineWidth("<<GetLineWidth()<<");"<<std::endl;
868  out<<" para->SetBit(TParallelCoord::kVertDisplay,"<<TestBit(kVertDisplay)<<");"<<std::endl;
869  out<<" para->SetBit(TParallelCoord::kCurveDisplay,"<<TestBit(kCurveDisplay)<<");"<<std::endl;
870  out<<" para->SetBit(TParallelCoord::kPaintEntries,"<<TestBit(kPaintEntries)<<");"<<std::endl;
871  out<<" para->SetBit(TParallelCoord::kLiveUpdate,"<<TestBit(kLiveUpdate)<<");"<<std::endl;
872  out<<" para->SetBit(TParallelCoord::kGlobalLogScale,"<<TestBit(kGlobalLogScale)<<");"<<std::endl;
873  if (TestBit(kGlobalScale)) out<<" para->SetGlobalScale(kTRUE);"<<std::endl;
874  if (TestBit(kCandleChart)) out<<" para->SetCandleChart(kTRUE);"<<std::endl;
875  if (TestBit(kGlobalLogScale)) out<<" para->SetGlobalLogScale(kTRUE);"<<std::endl;
876  out<<std::endl<<" para->Draw();"<<std::endl;
877 }
878 
879 ////////////////////////////////////////////////////////////////////////////////
880 /// Save the tree in a file if fTreeFileName == "".
881 
882 void TParallelCoord::SaveTree(const char* filename, Bool_t overwrite)
883 {
884  if (!(fTreeFileName=="")) return;
885  TString sfile = filename;
886  if (sfile == "") sfile = Form("%s.root",fTree->GetName());
887 
888  TFile* f = TFile::Open(sfile.Data());
889  if (f) {
890  Warning("SaveTree","%s already exists.", sfile.Data());
891  if (!overwrite) return;
892  else Warning("SaveTree","Overwriting.");
893  f = new TFile(sfile.Data(),"RECREATE");
894  } else {
895  f = new TFile(sfile.Data(),"CREATE");
896  }
897  gDirectory = f;
899  fTreeFileName = sfile;
900  Info("SaveTree","File \"%s\" written.",sfile.Data());
901 }
902 
903 ////////////////////////////////////////////////////////////////////////////////
904 /// Update the position of the axes.
905 
907 {
908  if(!gPad) return;
909  Bool_t vert = TestBit (kVertDisplay);
910  TFrame *frame = gPad->GetFrame();
911  if (fVarList->GetSize() > 1) {
912  if (vert) {
913  frame->SetX1(1.0/((Double_t)fVarList->GetSize()+1));
914  frame->SetX2(1-frame->GetX1());
915  frame->SetY1(0.1);
916  frame->SetY2(0.9);
917  gPad->RangeAxis(1.0/((Double_t)fVarList->GetSize()+1),0.1,1-frame->GetX1(),0.9);
918  } else {
919  frame->SetX1(0.1);
920  frame->SetX2(0.9);
921  frame->SetY1(1.0/((Double_t)fVarList->GetSize()+1));
922  frame->SetY2(1-frame->GetY1());
923  gPad->RangeAxis(0.1,1.0/((Double_t)fVarList->GetSize()+1),0.9,1-frame->GetY1());
924  }
925 
926  Double_t horSpace = (frame->GetX2() - frame->GetX1())/(fNvar-1);
927  Double_t verSpace = (frame->GetY2() - frame->GetY1())/(fNvar-1);
928  Int_t i=0;
929  TIter next(fVarList);
930 
931  TParallelCoordVar* var;
932  while((var = (TParallelCoordVar*)next())){
933  if (vert) var->SetX(gPad->GetFrame()->GetX1() + i*horSpace,TestBit(kGlobalScale));
934  else var->SetY(gPad->GetFrame()->GetY1() + i*verSpace,TestBit(kGlobalScale));
935  ++i;
936  }
937  } else if (fVarList->GetSize()==1) {
938  frame->SetX1(0.1);
939  frame->SetX2(0.9);
940  frame->SetY1(0.1);
941  frame->SetY2(0.9);
942  if (vert) ((TParallelCoordVar*)fVarList->First())->SetX(0.5,TestBit(kGlobalScale));
943  else ((TParallelCoordVar*)fVarList->First())->SetY(0.5,TestBit(kGlobalScale));
944  }
945 }
946 
947 ////////////////////////////////////////////////////////////////////////////////
948 /// Set the same histogram axis binning for all axis.
949 
951 {
952  TIter next(fVarList);
953  TParallelCoordVar *var;
954  while((var = (TParallelCoordVar*)next())) var->SetHistogramBinning(n);
955 }
956 
957 ////////////////////////////////////////////////////////////////////////////////
958 /// Set the same histogram axis height for all axis.
959 
961 {
962  TIter next(fVarList);
963  TParallelCoordVar *var;
964  while((var = (TParallelCoordVar*)next())) var->SetHistogramHeight(h);
965 }
966 
967 ////////////////////////////////////////////////////////////////////////////////
968 /// All axes in log scale.
969 
971 {
972  if (lt == TestBit(kGlobalLogScale)) return;
974  TIter next(fVarList);
975  TParallelCoordVar* var;
976  while ((var = (TParallelCoordVar*)next())) var->SetLogScale(lt);
978 }
979 
980 ////////////////////////////////////////////////////////////////////////////////
981 /// Constraint all axes to the same scale.
982 
984 {
985  SetBit(kGlobalScale,gl);
986  if (fCandleAxis) {
987  delete fCandleAxis;
988  fCandleAxis = 0;
989  }
990  if (gl) {
991  Double_t min,max;
992  min = GetGlobalMin();
993  max = GetGlobalMax();
994  if (TestBit(kGlobalLogScale) && min<=0) min = 0.00001*max;
995  if (TestBit(kVertDisplay)) {
996  if (!TestBit(kGlobalLogScale)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,min,max);
997  else fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,min,max,510,"G");
998  } else {
999  if (!TestBit(kGlobalLogScale)) fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,min,max);
1000  else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,min,max,510,"G");
1001  }
1002  fCandleAxis->Draw();
1003  SetGlobalMin(min);
1004  SetGlobalMax(max);
1005  TIter next(fVarList);
1006  TParallelCoordVar* var;
1007  while ((var = (TParallelCoordVar*)next())) var->GetHistogram();
1008  }
1009  gPad->Modified();
1010  gPad->Update();
1011 }
1012 
1013 ////////////////////////////////////////////////////////////////////////////////
1014 /// Set the same histogram axis line width for all axis.
1015 
1017 {
1018  TIter next(fVarList);
1019  TParallelCoordVar *var;
1020  while((var = (TParallelCoordVar*)next())) var->SetHistogramLineWidth(lw);
1021 }
1022 
1023 ////////////////////////////////////////////////////////////////////////////////
1024 /// Set a candle chart display.
1025 
1027 {
1028  SetBit(kCandleChart,can);
1029  SetGlobalScale(can);
1030  TIter next(fVarList);
1031  TParallelCoordVar* var;
1032  while ((var = (TParallelCoordVar*)next())) {
1033  var->SetBoxPlot(can);
1034  var->SetHistogramLineWidth(0);
1035  }
1036  if (fCandleAxis) delete fCandleAxis;
1037  fCandleAxis = 0;
1038  SetBit(kPaintEntries,!can);
1039  if (can) {
1040  if (TestBit(kVertDisplay)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,GetGlobalMin(),GetGlobalMax());
1041  else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,GetGlobalMin(),GetGlobalMax());
1042  fCandleAxis->Draw();
1043  } else {
1044  if (fCandleAxis) {
1045  delete fCandleAxis;
1046  fCandleAxis = 0;
1047  }
1048  }
1049  gPad->Modified();
1050  gPad->Update();
1051 }
1052 
1053 ////////////////////////////////////////////////////////////////////////////////
1054 /// Set the first entry to be displayed.
1055 
1057 {
1058  if(f<0 || f>fNentries) return;
1059  fCurrentFirst = f;
1060  if(fCurrentFirst + fCurrentN > fNentries) fCurrentN = fNentries-fCurrentFirst;
1061  TIter next(fVarList);
1062  TParallelCoordVar* var;
1063  while ((var = (TParallelCoordVar*)next())) {
1064  var->GetMinMaxMean();
1065  var->GetHistogram();
1067  }
1068 }
1069 
1070 ////////////////////////////////////////////////////////////////////////////////
1071 /// Set the number of entry to be displayed.
1072 
1074 {
1075  if(n<=0) return;
1077  else fCurrentN = n;
1078  TIter next(fVarList);
1079  TParallelCoordVar* var;
1080  while ((var = (TParallelCoordVar*)next())) {
1081  var->GetMinMaxMean();
1082  var->GetHistogram();
1084  }
1085 }
1086 
1087 ////////////////////////////////////////////////////////////////////////////////
1088 /// Set the selection being edited.
1089 
1091 {
1093  TIter next(fSelectList);
1094  TParallelCoordSelect* sel;
1095  while((sel = (TParallelCoordSelect*)next()) && strcmp(sel->GetTitle(),title))
1096  if (sel) fCurrentSelection = sel;
1097  return sel;
1098 }
1099 
1100 ////////////////////////////////////////////////////////////////////////////////
1101 /// Set the selection being edited.
1102 
1104 {
1105  if (fCurrentSelection == sel) return;
1106  fCurrentSelection = sel;
1107 }
1108 
1109 ////////////////////////////////////////////////////////////////////////////////
1110 /// Set dots spacing. Modify the line style 11.
1111 /// If the canvas support transparency dot spacing is ignored.
1112 
1114 {
1115  if (gPad->GetCanvas()->SupportAlpha()) return;
1116  if (s == fDotsSpacing) return;
1117  fDotsSpacing = s;
1118  gStyle->SetLineStyleString(11,Form("%d %d",4,s*8));
1119 }
1120 
1121 ////////////////////////////////////////////////////////////////////////////////
1122 /// Set the entry lists of "para".
1123 
1125 {
1126  para->SetCurrentEntries(enlist);
1127  para->SetInitEntries(enlist);
1128 }
1129 
1130 ////////////////////////////////////////////////////////////////////////////////
1131 /// Force all variables to adopt the same max.
1132 
1134 {
1135  TIter next(fVarList);
1136  TParallelCoordVar* var;
1137  while ((var = (TParallelCoordVar*)next())) {
1138  var->SetCurrentMax(max);
1139  }
1140 }
1141 
1142 ////////////////////////////////////////////////////////////////////////////////
1143 /// Force all variables to adopt the same min.
1144 
1146 {
1147  TIter next(fVarList);
1148  TParallelCoordVar* var;
1149  while ((var = (TParallelCoordVar*)next())) {
1150  var->SetCurrentMin(min);
1151  }
1152 }
1153 
1154 ////////////////////////////////////////////////////////////////////////////////
1155 /// If true, the pad is updated while the motion of a dragged range.
1156 
1158 {
1159  SetBit(kLiveUpdate,on);
1160  TIter next(fVarList);
1161  TParallelCoordVar* var;
1162  while((var = (TParallelCoordVar*)next())) var->SetLiveRangesUpdate(on);
1163 }
1164 
1165 ////////////////////////////////////////////////////////////////////////////////
1166 /// Set the vertical or horizontal display.
1167 
1169 {
1170  if (vert == TestBit (kVertDisplay)) return;
1171  SetBit(kVertDisplay,vert);
1172  if (!gPad) return;
1173  TFrame* frame = gPad->GetFrame();
1174  if (!frame) return;
1175  UInt_t ui = 0;
1176  Double_t horaxisspace = (frame->GetX2() - frame->GetX1())/(fNvar-1);
1177  Double_t veraxisspace = (frame->GetY2() - frame->GetY1())/(fNvar-1);
1178  TIter next(fVarList);
1179  TParallelCoordVar* var;
1180  while ((var = (TParallelCoordVar*)next())) {
1181  if (vert) var->SetX(frame->GetX1() + ui*horaxisspace,TestBit(kGlobalScale));
1182  else var->SetY(frame->GetY1() + ui*veraxisspace,TestBit(kGlobalScale));
1183  ++ui;
1184  }
1185  if (TestBit(kCandleChart)) {
1186  if (fCandleAxis) delete fCandleAxis;
1187  if (TestBit(kVertDisplay)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,GetGlobalMin(),GetGlobalMax());
1188  else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,GetGlobalMin(),GetGlobalMax());
1189  fCandleAxis->Draw();
1190  }
1191  gPad->Modified();
1192  gPad->Update();
1193 }
1194 
1195 ////////////////////////////////////////////////////////////////////////////////
1196 /// Unzoom all variables.
1197 
1199 {
1200  TIter next(fVarList);
1201  TParallelCoordVar* var;
1202  while((var = (TParallelCoordVar*)next())) var->Unzoom();
1203 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:778
TEntryList * fInitEntries
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
void Init()
An axis used when displaying a candle chart.
Long64_t fNentries
void PaintEntries(TParallelCoordSelect *sel=NULL)
Loop over the entries and paint them.
A TParallelCoordSelect is a specialised TList to hold TParallelCoordRanges used by TParallelCoord...
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:409
void CleanUpSelections(TParallelCoordRange *range)
Clean up the selections from the ranges which could have been deleted when a variable has been delete...
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:847
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:234
TTreeFormula * GetVar(Int_t i) const
Return the TTreeFormula corresponding to the i-th component of the request formula (where the compone...
Double_t * GetValues()
TString fTreeFileName
long long Long64_t
Definition: RtypesCore.h:69
virtual Long64_t GetN() const
Definition: TEntryList.h:75
TParallelCoordSelect * GetCurrentSelection()
Return the selection currently being edited.
virtual Double_t * GetVal(Int_t i) const
Return the last values corresponding to the i-th component of the formula being processed (where the ...
void SetCurrentMax(Double_t max)
Set the current maximum of the axis.
Double_t GetX2() const
Definition: TBox.h:53
void PaintGraph(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
Draw the (x,y) as a graph.
Definition: TGraph.cxx:1945
static void BuildParallelCoord(TSelectorDraw *selector, Bool_t candle)
Call constructor and add the variables.
TParallelCoordSelect * GetSelection(const char *title)
Get a selection from its title.
virtual void SetBorderMode(Short_t bordermode)
Definition: TWbox.h:49
const char Option_t
Definition: RtypesCore.h:62
Long64_t fCurrentFirst
void SetAxisHistogramHeight(Double_t h=0.5)
Set the same histogram axis height for all axis.
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:640
R__EXTERN TStyle * gStyle
Definition: TStyle.h:402
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:159
TH1 * h
Definition: legend2.C:5
void SetLogScale(Bool_t log)
Set the axis in log scale.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
void SetCurrentMin(Double_t min)
Set the current minimum of the axis.
void SetAxisHistogramLineWidth(Int_t lw=2)
Set the same histogram axis line width for all axis.
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:585
See TView3D.
Definition: TView.h:25
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
Definition: TPaveText.cxx:183
virtual void Draw(Option_t *options="")
Draw the parallel coordinates graph.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
void SetLiveRangesUpdate(Bool_t)
If true, the pad is updated while the motion of a dragged range.
#define gROOT
Definition: TROOT.h:375
Basic string class.
Definition: TString.h:129
A TParallelCoordRange is a range used for parallel coordinates plots.
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
void SetValues(Long64_t length, Double_t *val)
Set the variable values.
int Int_t
Definition: RtypesCore.h:41
void ResetTree()
Reset the tree entry list to the initial one..
bool Bool_t
Definition: RtypesCore.h:59
Double_t GetY2() const
Definition: TBox.h:55
TArc * a
Definition: textangle.C:12
void SetCurrentFirst(Long64_t)
Set the first entry to be displayed.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:202
void SetVertDisplay(Bool_t vert=kTRUE)
Set the vertical or horizontal display.
virtual void SetX1(Double_t x1)
Definition: TBox.h:63
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
TH1F * GetHistogram()
Create or recreate the histogram.
Definition: Rtypes.h:56
void SetCurrentN(Long64_t)
Set the number of entry to be displayed.
Bool_t Contains(const char *name) const
Definition: TCollection.h:78
void SetBoxPlot(Bool_t box)
Set the axis to display a candle.
virtual void SetX2(Double_t x2)
Definition: TBox.h:64
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition: TTree.cxx:5968
Color_t fLineColor
virtual Int_t GetDimension() const
Definition: TSelectorDraw.h:80
void SetLineStyleString(Int_t i, const char *text)
Set line style string using the PostScript convention.
Definition: TStyle.cxx:1112
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:35
Double_t GetGlobalMin()
return the global minimum.
void Reset()
Definition: TCollection.h:156
Iterator of linked list.
Definition: TList.h:183
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:687
if object in a list can be deleted
Definition: TObject.h:58
TParallelCoordSelect * fCurrentSelection
void GetEntryXY(Long64_t n, Double_t &x, Double_t &y)
Get the position of the variable on the graph for the n&#39;th entry.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3909
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:112
TParallelCoord axes.
void SetAxisHistogramBinning(Int_t n=100)
Set the same histogram axis binning for all axis.
void SetX(Double_t x, Bool_t gl)
Set the X position of the axis in the case of a vertical axis.
Double_t GetCurrentMin() const
static const double x2[5]
TEntryList * fCurrentEntries
Color_t GetLineColor()
Double_t x[n]
Definition: legend1.C:17
Int_t GetNbins()
get the binning of the histograms.
void Class()
Definition: Class.C:29
void ApplySelectionToTree()
Apply the current selection to the tree.
void SetY(Double_t y, Bool_t gl)
Set the Y position of the axis in the case of a horizontal axis.
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
clip to the frame boundary
Definition: TGraph.h:70
REAL estimate(int elen, REAL *e)
Definition: triangle.c:5087
void DeleteVariable()
Delete variables.
void SetInitEntries(TEntryList *entries)
TString & Append(const char *cs)
Definition: TString.h:497
void SetLiveRangesUpdate(Bool_t on)
If true, the pad is updated while the motion of a dragged range.
virtual void Draw(Option_t *option="")
Draw this frame with its current attributes.
Definition: TFrame.cxx:69
Double_t GetCurrentMax() const
void GetMinMaxMean()
Get mean, min and max of those variable.
void SetCurrentEntries(TEntryList *entries)
virtual void SetBorderSize(Short_t bordersize)
Definition: TWbox.h:50
virtual void Paint(Option_t *options="")
Paint the parallel coordinates graph.
void SaveTree(const char *filename="", Bool_t overwrite=kFALSE)
Save the tree in a file if fTreeFileName == "".
Int_t GetEntryWeight(Long64_t evtidx)
Get the entry weight: The weight of an entry for a given variable is the bin content of the histogram...
void SetGlobalMax(Double_t max)
Force all variables to adopt the same max.
A doubly linked list.
Definition: TList.h:43
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:512
Long64_t fCurrentN
void RemoveVariable(TParallelCoordVar *var)
Delete a variable from the graph.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
TTreeFormula * GetSelect() const
Definition: TSelectorDraw.h:86
static void SetEntryList(TParallelCoord *para, TEntryList *enlist)
Set the entry lists of "para".
Double_t GetGlobalMax()
return the global maximum.
void SetCandleChart(Bool_t can)
Set a candle chart display.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TTree.cxx:9163
TParallelCoord()
Default constructor.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:561
void AddSelection(const char *title)
Add a selection.
TRandom2 r(17)
void SetGlobalScale(Bool_t gl)
Constraint all axes to the same scale.
TString fTreeName
Pointer to the TTree.
virtual void ExecuteEvent(Int_t entry, Int_t px, Int_t py)
Execute the corresponding entry.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:679
void SetGlobalLogScale(Bool_t)
All axes in log scale.
void SetHistogramBinning(Int_t n=100)
Set the histogram binning.
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
TFile * GetCurrentFile() const
Return pointer to the current file.
Definition: TTree.cxx:5163
char * Form(const char *fmt,...)
virtual Long64_t GetEntry(Int_t index)
Return the number of the entry #index of this TEntryList in the TTree or TChain See also Next()...
Definition: TEntryList.cxx:657
TGaxis * fCandleAxis
Current Selection being edited.
TTree * GetTree()
return the tree if fTree is defined.
void SetGlobalMin(Double_t min)
Force all variables to adopt the same min.
The axis painter class.
Definition: TGaxis.h:24
virtual Long64_t GetEstimate() const
Definition: TTree.h:385
virtual void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates.
Definition: TPolyLine.cxx:548
~TParallelCoord()
Destructor.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:315
const char * GetTitle() const
Returns title of object.
void AddVariable(Double_t *val, const char *title="")
Add a variable.
Width_t GetLineWidth()
TTree * GetTree() const
Definition: TSelectorDraw.h:88
TGraphErrors * gr
Definition: legend1.C:25
Define a Frame.
Definition: TFrame.h:19
A specialized TSelector for TTree::Draw.
Definition: TSelectorDraw.h:31
void UnzoomAll()
Unzoom all variables.
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
virtual void SetY2(Double_t y2)
Definition: TBox.h:66
TString & Remove(Ssiz_t pos)
Definition: TString.h:621
void GetQuantiles()
Get the box plot values (quantiles).
The Canvas class.
Definition: TCanvas.h:31
void SetHistogramHeight(Double_t h=0)
Set the height of the bar histogram.
Width_t fLineWidth
static const double x1[5]
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
#define ClassImp(name)
Definition: Rtypes.h:336
double f(double x)
Bool_t IsZombie() const
Definition: TObject.h:122
Double_t GetX1() const
Definition: TBox.h:52
virtual void SetEntryList(TEntryList *list, Option_t *opt="")
Set an EntryList.
Definition: TTree.cxx:8516
virtual void Draw(Option_t *option="")
Draw the axis.
double Double_t
Definition: RtypesCore.h:55
TParallelCoordSelect * SetCurrentSelection(const char *title)
Set the selection being edited.
void SavePrimitive(std::ostream &out, Option_t *options)
Save the TParallelCoordVar as a macro.
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TTree.h:355
int nentries
Definition: THbookFile.cxx:89
Double_t y[n]
Definition: legend1.C:17
virtual Int_t GetNfill() const
Definition: TSelectorDraw.h:84
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:572
void SetDotsSpacing(Int_t s=0)
Set dots spacing.
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry #entry to the list.
Definition: TEntryList.cxx:562
virtual void SetObject(TObject *obj)
Definition: TSelector.h:67
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
void DeleteSelection(TParallelCoordSelect *sel)
Delete a selection.
void SavePrimitive(std::ostream &out, Option_t *options)
Save the TParallelCoord in a macro.
Parallel Coordinates class.
void SetAxesPosition()
Update the position of the axes.
void SetHistogramLineWidth(Int_t lw=2)
Double_t * GetVariable(const char *var)
Get the variables values from its title.
virtual void Add(TObject *obj)
Definition: TList.h:77
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Defined by an array on N points in a 2-D space.
Definition: TPolyLine.h:23
TList * fSelectList
#define gPad
Definition: TVirtualPad.h:284
void Reset()
Reset list iterator.
Definition: TList.cxx:981
Double_t GetY1() const
Definition: TBox.h:54
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:78
#define gDirectory
Definition: TDirectory.h:211
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute the distance from the TParallelCoord.
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition: TTreePlayer.h:37
virtual Int_t GetSize() const
Definition: TCollection.h:89
double exp(double)
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
virtual void SetY1(Double_t y1)
Definition: TBox.h:65
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:25
const Bool_t kTRUE
Definition: RtypesCore.h:91
TEntryList * GetEntryList(Bool_t sel=kTRUE)
Get the whole entry list or one for a selection.
const Int_t n
Definition: legend1.C:16
Line Attributes class.
Definition: TAttLine.h:18
virtual Double_t * GetV1()
Definition: TTree.h:450
Bool_t Eval(Long64_t evtidx, TParallelCoordSelect *select)
Check if the entry is within the range(s) of "select".
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:859
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
const char * Data() const
Definition: TString.h:347
void SaveEntryLists(const char *filename="", Bool_t overwrite=kFALSE)
Save the entry lists in a root file "filename.root".