Logo ROOT   6.08/07
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 Begin_Macro(source)
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  return c1;
119 }
120 End_Macro
121 
122  Some references:
123 
124  - Alfred Inselberg's Homepage <http://www.math.tau.ac.il/~aiisreal>, with
125  Visual Tutorial, History, Selected Publications and Applications.
126  - Almir Olivette Artero, Maria Cristina Ferreira de Oliveira, Haim Levkowitz,
127  "Uncovering Clusters in Crowded Parallel Coordinates Visualizations,"
128  infovis, pp. 81-88, IEEE Symposium on Information Visualization
129  (INFOVIS'04), 2004.
130 */
131 
132 ////////////////////////////////////////////////////////////////////////////////
133 /// Default constructor.
134 
136  :TNamed()
137 {
138  Init();
139 }
140 
141 ////////////////////////////////////////////////////////////////////////////////
142 /// Constructor without a reference to a tree,
143 /// the datas must be added afterwards with
144 /// TParallelCoord::AddVariable(Double_t*,const char*).
145 
147 {
148  Init();
151  fVarList = new TList();
152  fSelectList = new TList();
155 }
156 
157 ////////////////////////////////////////////////////////////////////////////////
158 /// Normal constructor, the datas must be added afterwards
159 /// with TParallelCoord::AddVariable(Double_t*,const char*).
160 
162  :TNamed("ParaCoord","ParaCoord")
163 {
164  Init();
165  Int_t estimate = tree->GetEstimate();
166  if (nentries>estimate) {
167  Warning("TParallelCoord","Call tree->SetEstimate(tree->GetEntries()) to display all the tree variables");
169  } else {
171  }
173  fTree = tree;
174  fTreeName = fTree->GetName();
176  else fTreeFileName = "";
177  fVarList = new TList();
178  fSelectList = new TList();
181 }
182 
183 ////////////////////////////////////////////////////////////////////////////////
184 /// Destructor.
185 
187 {
189  if (fVarList) {
190  fVarList->Delete();
191  delete fVarList;
192  }
193  if (fSelectList) {
194  fSelectList->Delete();
195  delete fSelectList;
196  }
197  if (fCandleAxis) delete fCandleAxis;
198  SetDotsSpacing(0);
199 }
200 
201 ////////////////////////////////////////////////////////////////////////////////
202 /// Add a variable.
203 
204 void TParallelCoord::AddVariable(Double_t* val, const char* title)
205 {
206  ++fNvar;
207  fVarList->Add(new TParallelCoordVar(val,title,fVarList->GetSize(),this));
208  SetAxesPosition();
209 }
210 
211 ////////////////////////////////////////////////////////////////////////////////
212 /// Add a variable from an expression.
213 
214 void TParallelCoord::AddVariable(const char* varexp)
215 {
216  if(!fTree) return; // The tree from which one will get the data must be defined.
217 
218  // Select in the only the entries of this TParallelCoord.
219  TEntryList *list = GetEntryList(kFALSE);
220  fTree->SetEntryList(list);
221 
222  // ensure that there is only one variable given:
223 
224  TString exp = varexp;
225 
226  if (exp.Contains(':') || exp.Contains(">>") || exp.Contains("<<")) {
227  Warning("AddVariable","Only a single variable can be added at a time.");
228  return;
229  }
230  if (exp == ""){
231  Warning("AddVariable","Nothing to add");
232  return;
233  }
234 
235  Long64_t en = fTree->Draw(varexp,"","goff");
236  if (en<0) {
237  Warning("AddVariable","%s could not be evaluated",varexp);
238  return;
239  }
240 
241  AddVariable(fTree->GetV1(),varexp);
243  var->Draw();
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 /// Add a selection.
248 
249 void TParallelCoord::AddSelection(const char* title)
250 {
251  TParallelCoordSelect *sel = new TParallelCoordSelect(title);
252  fSelectList->Add(sel);
253  fCurrentSelection = sel;
254 }
255 
256 ////////////////////////////////////////////////////////////////////////////////
257 /// Apply the current selection to the tree.
258 
260 {
261  if(!fTree) return;
262  if(fSelectList) {
263  if(fSelectList->GetSize() == 0) return;
265  }
268  fCurrentFirst = 0;
271  TString varexp = "";
272  TIter next(fVarList);
273  TParallelCoordVar* var;
274  while ((var = (TParallelCoordVar*)next())) varexp.Append(Form(":%s",var->GetTitle()));
275  varexp.Remove(TString::kLeading,':');
276  TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)fTree->GetPlayer())->GetSelector();
277  fTree->Draw(varexp.Data(),"","goff");
278  next.Reset();
279  Int_t i = 0;
280  while ((var = (TParallelCoordVar*)next())) {
281  var->SetValues(fNentries, selector->GetVal(i));
282  ++i;
283  }
284  if (fSelectList) { // FIXME It would be better to update the selections by deleting
285  fSelectList->Delete(); // the meaningless ranges (selecting everything or nothing for example)
286  fCurrentSelection = 0; // after applying a new entrylist to the tree.
287  }
288  gPad->Modified();
289  gPad->Update();
290 }
291 
292 ////////////////////////////////////////////////////////////////////////////////
293 /// Call constructor and add the variables.
294 
296 {
297  TParallelCoord* pc = new TParallelCoord(selector->GetTree(),selector->GetNfill());
298  pc->SetBit(kCanDelete);
299  selector->SetObject(pc);
300  TString varexp = "";
301  for(Int_t i=0;i<selector->GetDimension();++i) {
302  if (selector->GetVal(i)) {
303  if (selector->GetVar(i)) {
304  pc->AddVariable(selector->GetVal(i),selector->GetVar(i)->GetTitle());
305  varexp.Append(Form(":%s",selector->GetVar(i)->GetTitle()));
306  }
307  }
308  }
309  varexp.Remove(TString::kLeading,':');
310  if (selector->GetSelect()) varexp.Append(Form("{%s}",selector->GetSelect()->GetTitle()));
311  pc->SetTitle(varexp.Data());
312  if (!candle) pc->Draw();
313  else pc->Draw("candle");
314 }
315 
316 ////////////////////////////////////////////////////////////////////////////////
317 /// Clean up the selections from the ranges which could have been deleted
318 /// when a variable has been deleted.
319 
321 {
322  TIter next(fSelectList);
323  TParallelCoordSelect* select;
324  while ((select = (TParallelCoordSelect*)next())){
325  if(select->Contains(range)) select->Remove(range);
326  }
327 }
328 
329 ////////////////////////////////////////////////////////////////////////////////
330 /// Delete a selection.
331 
333 {
334  fSelectList->Remove(sel);
335  delete sel;
336  if(fSelectList->GetSize() == 0) fCurrentSelection = 0;
338 }
339 
340 ////////////////////////////////////////////////////////////////////////////////
341 /// Compute the distance from the TParallelCoord.
342 
344 {
345  if(!gPad) return 9999;
346 
347  TFrame *frame = gPad->GetFrame();
348 
349  Double_t x1,x2,y1,y2,xx,yy;
350 
351  x1 = frame->GetX1()+0.01;
352  x2 = frame->GetX2()-0.01;
353  y2 = frame->GetY2()-0.01;
354  y1 = frame->GetY1()+0.01;
355 
356  xx = gPad->AbsPixeltoX(px);
357  yy = gPad->AbsPixeltoY(py);
358 
359  if(xx>x1 && xx<x2 && yy>y1 && yy<y2) return 0;
360  else return 9999;
361 }
362 
363 ////////////////////////////////////////////////////////////////////////////////
364 /// Draw the parallel coordinates graph.
365 
367 {
368  if (!GetTree()) return;
370  Bool_t optcandle = kFALSE;
371  TString opt = option;
372  opt.ToLower();
373  if(opt.Contains("candle")) {
374  optcandle = kTRUE;
375  opt.ReplaceAll("candle","");
376  }
377  if(optcandle) {
381  }
382 
383  if (gPad) {
384  if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
385  } else gROOT->MakeDefCanvas();
386  TView *view = gPad->GetView();
387  if(view){
388  delete view;
389  gPad->SetView(0);
390  }
391  gPad->Clear();
392  if (!optcandle) {
393  if (gPad && gPad->IsA() == TCanvas::Class()
394  && !((TCanvas*)gPad)->GetShowEditor()) {
395  ((TCanvas*)gPad)->ToggleEditor();
396  ((TCanvas*)gPad)->ToggleEventStatus();
397  }
398  }
399 
400  gPad->SetBit(TGraph::kClipFrame,kTRUE);
401 
402  TFrame *frame = new TFrame(0.1,0.1,0.9,0.9);
403  frame->SetBorderSize(0);
404  frame->SetBorderMode(0);
405  frame->SetFillStyle(0);
406  frame->SetLineColor(gPad->GetFillColor());
407  frame->Draw();
408  AppendPad(option);
409  TPaveText *title = new TPaveText(0.05,0.95,0.35,1);
410  title->AddText(GetTitle());
411  title->Draw();
412  SetAxesPosition();
413  TIter next(fVarList);
414  TParallelCoordVar* var;
415  while ((var = (TParallelCoordVar*)next())) {
416  if(optcandle) {
417  var->SetBoxPlot(kTRUE);
418  var->SetHistogramHeight(0.5);
419  var->SetHistogramLineWidth(0);
420  }
421  var->Draw();
422  }
423 
424  if (optcandle) {
425  if (TestBit(kVertDisplay)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,GetGlobalMin(),GetGlobalMax());
426  else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,GetGlobalMin(),GetGlobalMax());
427  fCandleAxis->Draw();
428  }
429 
430  if (gPad && gPad->IsA() == TCanvas::Class())
431  ((TCanvas*)gPad)->Selected(gPad,this,1);
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// Execute the corresponding entry.
436 
437 void TParallelCoord::ExecuteEvent(Int_t /*entry*/, Int_t /*px*/, Int_t /*py*/)
438 {
439  if (!gPad) return;
440  gPad->SetCursor(kHand);
441 }
442 
443 ////////////////////////////////////////////////////////////////////////////////
444 /// Return the selection currently being edited.
445 
447 {
448  if (!fSelectList) return 0;
449  if (!fCurrentSelection) {
451  }
452  return fCurrentSelection;
453 }
454 
455 ////////////////////////////////////////////////////////////////////////////////
456 /// Get the whole entry list or one for a selection.
457 
459 {
460  if(!sel || fCurrentSelection->GetSize() == 0){ // If no selection is specified, return the entry list of all the entries.
461  return fInitEntries;
462  } else { // return the entry list corresponding to the current selection.
463  TEntryList *enlist = new TEntryList(fTree);
464  TIter next(fVarList);
465  for (Long64_t li=0;li<fNentries;++li) {
466  next.Reset();
467  Bool_t inrange=kTRUE;
468  TParallelCoordVar* var;
469  while((var = (TParallelCoordVar*)next())){
470  if(!var->Eval(li,fCurrentSelection)) inrange = kFALSE;
471  }
472  if(!inrange) continue;
473  enlist->Enter(fCurrentEntries->GetEntry(li));
474  }
475  return enlist;
476  }
477 }
478 
479 ////////////////////////////////////////////////////////////////////////////////
480 /// return the global maximum.
481 
483 {
484  Double_t gmax=-DBL_MAX;
485  TIter next(fVarList);
486  TParallelCoordVar* var;
487  while ((var = (TParallelCoordVar*)next())) {
488  if (gmax < var->GetCurrentMax()) gmax = var->GetCurrentMax();
489  }
490  return gmax;
491 }
492 
493 ////////////////////////////////////////////////////////////////////////////////
494 /// return the global minimum.
495 
497 {
498  Double_t gmin=DBL_MAX;
499  TIter next(fVarList);
500  TParallelCoordVar* var;
501  while ((var = (TParallelCoordVar*)next())) {
502  if (gmin > var->GetCurrentMin()) gmin = var->GetCurrentMin();
503  }
504  return gmin;
505 }
506 
507 ////////////////////////////////////////////////////////////////////////////////
508 /// get the binning of the histograms.
509 
511 {
512  return ((TParallelCoordVar*)fVarList->First())->GetNbins();
513 }
514 
515 ////////////////////////////////////////////////////////////////////////////////
516 /// Get a selection from its title.
517 
519 {
520  TIter next(fSelectList);
522  while ((sel = (TParallelCoordSelect*)next()) && strcmp(title,sel->GetTitle())) { }
523  return sel;
524 }
525 
526 ////////////////////////////////////////////////////////////////////////////////
527 /// return the tree if fTree is defined. If not, the method try to load the tree
528 /// from fTreeFileName.
529 
531 {
532  if (fTree) return fTree;
533  if (fTreeFileName=="" || fTreeName=="") {
534  Error("GetTree","Cannot load the tree: no tree defined!");
535  return 0;
536  }
538  if (!f) {
539  Error("GetTree","Tree file name : \"%s\" does not exist (Are you in the correct directory?).",fTreeFileName.Data());
540  return 0;
541  } else if (f->IsZombie()) {
542  Error("GetTree","while opening \"%s\".",fTreeFileName.Data());
543  return 0;
544  } else {
545  fTree = (TTree*)f->Get(fTreeName.Data());
546  if (!fTree) {
547  Error("GetTree","\"%s\" not found in \"%s\".", fTreeName.Data(), fTreeFileName.Data());
548  return 0;
549  } else {
551  TString varexp = "";
552  TIter next(fVarList);
553  TParallelCoordVar* var;
554  while ((var = (TParallelCoordVar*)next())) varexp.Append(Form(":%s",var->GetTitle()));
555  varexp.Remove(TString::kLeading,':');
556  fTree->Draw(varexp.Data(),"","goff");
557  TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)fTree->GetPlayer())->GetSelector();
558  next.Reset();
559  Int_t i = 0;
560  while ((var = (TParallelCoordVar*)next())) {
561  var->SetValues(fNentries, selector->GetVal(i));
562  ++i;
563  }
564  return fTree;
565  }
566  }
567 }
568 
569 ////////////////////////////////////////////////////////////////////////////////
570 /// Get the variables values from its title.
571 
572 Double_t* TParallelCoord::GetVariable(const char* vartitle)
573 {
574  TIter next(fVarList);
575  TParallelCoordVar* var = 0;
576  while(((var = (TParallelCoordVar*)next()) != 0) && (var->GetTitle() != vartitle)) { }
577  if(!var) return 0;
578  else return var->GetValues();
579 }
580 
581 ////////////////////////////////////////////////////////////////////////////////
582 /// Get the variables values from its index.
583 
585 {
586  if(i<0 || (UInt_t)i>fNvar) return 0;
587  else return ((TParallelCoordVar*)fVarList->At(i))->GetValues();
588 }
589 
590 ////////////////////////////////////////////////////////////////////////////////
591 /// Initialise the data members of TParallelCoord.
592 
594 {
595  fNentries = 0;
596  fVarList = 0;
597  fSelectList = 0;
605  fTree = 0;
606  fCurrentEntries = 0;
607  fInitEntries = 0;
608  fCurrentSelection = 0;
609  fNvar = 0;
610  fDotsSpacing = 0;
611  fCurrentFirst = 0;
612  fCurrentN = 0;
613  fCandleAxis = 0;
614  fWeightCut = 0;
615  fLineWidth = 1;
616  fLineColor = kGreen-8;
617  fTreeName = "";
618  fTreeFileName = "";
619 }
620 
621 ////////////////////////////////////////////////////////////////////////////////
622 /// Paint the parallel coordinates graph.
623 
625 {
626  if (!GetTree()) return;
627  gPad->Range(0,0,1,1);
628  TFrame *frame = gPad->GetFrame();
629  frame->SetLineColor(gPad->GetFillColor());
630  SetAxesPosition();
631  if(TestBit(kPaintEntries)){
632  PaintEntries(0);
633  TIter next(fSelectList);
635  while((sel = (TParallelCoordSelect*)next())) {
636  if(sel->GetSize()>0 && sel->TestBit(TParallelCoordSelect::kActivated)) {
637  PaintEntries(sel);
638  }
639  }
640  }
641  gPad->RangeAxis(0,0,1,1);
642 }
643 
644 ////////////////////////////////////////////////////////////////////////////////
645 /// Loop over the entries and paint them.
646 
648 {
649  if (fVarList->GetSize() < 2) return;
650  Int_t i=0;
651  Long64_t n=0;
652 
653  Double_t *x = new Double_t[fNvar];
654  Double_t *y = new Double_t[fNvar];
655 
656  TGraph *gr = 0;
657  TPolyLine *pl = 0;
658  TAttLine *evline = 0;
659 
660  if (TestBit (kCurveDisplay)) {gr = new TGraph(fNvar); evline = (TAttLine*)gr;}
661  else {pl = new TPolyLine(fNvar); evline = (TAttLine*)pl;}
662 
663  if (fDotsSpacing == 0) evline->SetLineStyle(1);
664  else evline->SetLineStyle(11);
665  if (!sel){
666  evline->SetLineWidth(GetLineWidth());
667  evline->SetLineColor(GetLineColor());
668  } else {
669  evline->SetLineWidth(sel->GetLineWidth());
670  evline->SetLineColor(sel->GetLineColor());
671  }
672  TParallelCoordVar *var;
673 
674  TFrame *frame = gPad->GetFrame();
675  Double_t lx = ((frame->GetX2() - frame->GetX1())/(fNvar-1));
676  Double_t ly = ((frame->GetY2() - frame->GetY1())/(fNvar-1));
677  Double_t a,b;
678  TRandom r;
679 
680  for (n=fCurrentFirst; n<fCurrentFirst+fCurrentN; ++n) {
681  TListIter next(fVarList);
682  Bool_t inrange = kTRUE;
683  // Loop to check whenever the entry must be painted.
684  if (sel) {
685  while ((var = (TParallelCoordVar*)next())){
686  if (!var->Eval(n,sel)) inrange = kFALSE;
687  }
688  }
689  if (fWeightCut > 0) {
690  next.Reset();
691  Int_t entryweight = 0;
692  while ((var = (TParallelCoordVar*)next())) entryweight+=var->GetEntryWeight(n);
693  if (entryweight/(Int_t)fNvar < fWeightCut) inrange = kFALSE;
694  }
695  if(!inrange) continue;
696  i = 0;
697  next.Reset();
698  // Loop to set the polyline points.
699  while ((var = (TParallelCoordVar*)next())) {
700  var->GetEntryXY(n,x[i],y[i]);
701  ++i;
702  }
703  // beginning to paint the first point at a random distance
704  // to avoid artefacts when increasing the dots spacing.
705  if (fDotsSpacing != 0) {
706  if (TestBit(kVertDisplay)) {
707  a = (y[1]-y[0])/(x[1]-x[0]);
708  b = y[0]-a*x[0];
709  x[0] = x[0]+lx*r.Rndm();
710  y[0] = a*x[0]+b;
711  } else {
712  a = (x[1]-x[0])/(y[1]-y[0]);
713  b = x[0]-a*y[0];
714  y[0] = y[0]+ly*r.Rndm();
715  x[0] = a*y[0]+b;
716  }
717  }
718  if (pl) pl->PaintPolyLine(fNvar,x,y);
719  else gr->PaintGraph(fNvar,x,y,"C");
720  }
721 
722  if (pl) delete pl;
723  if (gr) delete gr;
724  delete [] x;
725  delete [] y;
726 }
727 
728 ////////////////////////////////////////////////////////////////////////////////
729 /// Delete a variable from the graph.
730 
732 {
733  fVarList->Remove(var);
734  fNvar = fVarList->GetSize();
735  SetAxesPosition();
736 }
737 
738 ////////////////////////////////////////////////////////////////////////////////
739 /// Delete the variable "vartitle" from the graph.
740 
742 {
743  TIter next(fVarList);
744  TParallelCoordVar* var=0;
745  while((var = (TParallelCoordVar*)next())) {
746  if (!strcmp(var->GetTitle(),vartitle)) break;
747  }
748  if(!var) Error("RemoveVariable","\"%s\" not a variable",vartitle);
749  fVarList->Remove(var);
750  fNvar = fVarList->GetSize();
751  SetAxesPosition();
752  var->DeleteVariable();
753  return var;
754 }
755 
756 ////////////////////////////////////////////////////////////////////////////////
757 /// Reset the tree entry list to the initial one..
758 
760 {
761  if(!fTree) return;
765  fCurrentFirst = 0;
767  TString varexp = "";
768  TIter next(fVarList);
769  TParallelCoordVar* var;
770  while ((var = (TParallelCoordVar*)next())) varexp.Append(Form(":%s",var->GetTitle()));
771  varexp.Remove(TString::kLeading,':');
772  fTree->Draw(varexp.Data(),"","goff");
773  next.Reset();
774  TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)fTree->GetPlayer())->GetSelector();
775  Int_t i = 0;
776  while ((var = (TParallelCoordVar*)next())) {
777  var->SetValues(fNentries, selector->GetVal(i));
778  ++i;
779  }
780  if (fSelectList) { // FIXME It would be better to update the selections by deleting
781  fSelectList->Delete(); // the meaningless ranges (selecting everything or nothing for example)
782  fCurrentSelection = 0; // after applying a new entrylist to the tree.
783  }
784  gPad->Modified();
785  gPad->Update();
786 }
787 
788 ////////////////////////////////////////////////////////////////////////////////
789 /// Save the entry lists in a root file "filename.root".
790 
791 void TParallelCoord::SaveEntryLists(const char* filename, Bool_t overwrite)
792 {
793  TString sfile = filename;
794  if (sfile == "") sfile = Form("%s_parallelcoord_entries.root",fTree->GetName());
795 
796  TFile* f = TFile::Open(sfile.Data());
797  if (f) {
798  Warning("SaveEntryLists","%s already exists.", sfile.Data());
799  if (!overwrite) return;
800  else Warning("SaveEntryLists","Overwriting.");
801  f = new TFile(sfile.Data(),"RECREATE");
802  } else {
803  f = new TFile(sfile.Data(),"CREATE");
804  }
805  gDirectory = f;
806  fInitEntries->Write("initentries");
807  fCurrentEntries->Write("currententries");
808  Info("SaveEntryLists","File \"%s\" written.",sfile.Data());
809 }
810 
811 ////////////////////////////////////////////////////////////////////////////////
812 /// Save the TParallelCoord in a macro.
813 
814 void TParallelCoord::SavePrimitive(std::ostream & out, Option_t* options)
815 {
816  TString opt = options;
817  opt.ToLower();
818  //Bool_t overwrite = opt.Contains("overwrite"); // Is there a way to specify "options" when saving ?
819  // Save the entrylists.
820  const char* filename = Form("%s_parallelcoord_entries.root",fTree->GetName());
821  SaveEntryLists(filename,kTRUE); // FIXME overwriting by default.
822  SaveTree(fTreeFileName,kTRUE); // FIXME overwriting by default.
823  out<<" // Create a TParallelCoord."<<std::endl;
824  out<<" TFile *f = TFile::Open(\""<<fTreeFileName.Data()<<"\");"<<std::endl;
825  out<<" TTree* tree = (TTree*)f->Get(\""<<fTreeName.Data()<<"\");"<<std::endl;
826  out<<" TParallelCoord* para = new TParallelCoord(tree,"<<fNentries<<");"<<std::endl;
827  out<<" // Load the entrylists."<<std::endl;
828  out<<" TFile *entries = TFile::Open(\""<<filename<<"\");"<<std::endl;
829  out<<" TEntryList *currententries = (TEntryList*)entries->Get(\"currententries\");"<<std::endl;
830  out<<" tree->SetEntryList(currententries);"<<std::endl;
831  out<<" para->SetInitEntries((TEntryList*)entries->Get(\"initentries\"));"<<std::endl;
832  out<<" para->SetCurrentEntries(currententries);"<<std::endl;
833  TIter next(fSelectList);
835  out<<" TParallelCoordSelect* sel;"<<std::endl;
836  out<<" para->GetSelectList()->Delete();"<<std::endl;
837  while ((sel = (TParallelCoordSelect*)next())) {
838  out<<" para->AddSelection(\""<<sel->GetTitle()<<"\");"<<std::endl;
839  out<<" sel = (TParallelCoordSelect*)para->GetSelectList()->Last();"<<std::endl;
840  out<<" sel->SetLineColor("<<sel->GetLineColor()<<");"<<std::endl;
841  out<<" sel->SetLineWidth("<<sel->GetLineWidth()<<");"<<std::endl;
842  }
843  TIter nextbis(fVarList);
844  TParallelCoordVar* var;
845  TString varexp = "";
846  while ((var = (TParallelCoordVar*)nextbis())) varexp.Append(Form(":%s",var->GetTitle()));
847  varexp.Remove(TString::kLeading,':');
848  out<<" tree->Draw(\""<<varexp.Data()<<"\",\"\",\"goff\");"<<std::endl;
849  out<<" TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)tree->GetPlayer())->GetSelector();"<<std::endl;
850  nextbis.Reset();
851  Int_t i=0;
852  out<<" TParallelCoordVar* var;"<<std::endl;
853  while ((var = (TParallelCoordVar*)nextbis())) {
854  out<<" //***************************************"<<std::endl;
855  out<<" // Create the axis \""<<var->GetTitle()<<"\"."<<std::endl;
856  out<<" para->AddVariable(selector->GetVal("<<i<<"),\""<<var->GetTitle()<<"\");"<<std::endl;
857  out<<" var = (TParallelCoordVar*)para->GetVarList()->Last();"<<std::endl;
858  var->SavePrimitive(out,"pcalled");
859  ++i;
860  }
861  out<<" //***************************************"<<std::endl;
862  out<<" // Set the TParallelCoord parameters."<<std::endl;
863  out<<" para->SetCurrentFirst("<<fCurrentFirst<<");"<<std::endl;
864  out<<" para->SetCurrentN("<<fCurrentN<<");"<<std::endl;
865  out<<" para->SetWeightCut("<<fWeightCut<<");"<<std::endl;
866  out<<" para->SetDotsSpacing("<<fDotsSpacing<<");"<<std::endl;
867  out<<" para->SetLineColor("<<GetLineColor()<<");"<<std::endl;
868  out<<" para->SetLineWidth("<<GetLineWidth()<<");"<<std::endl;
869  out<<" para->SetBit(TParallelCoord::kVertDisplay,"<<TestBit(kVertDisplay)<<");"<<std::endl;
870  out<<" para->SetBit(TParallelCoord::kCurveDisplay,"<<TestBit(kCurveDisplay)<<");"<<std::endl;
871  out<<" para->SetBit(TParallelCoord::kPaintEntries,"<<TestBit(kPaintEntries)<<");"<<std::endl;
872  out<<" para->SetBit(TParallelCoord::kLiveUpdate,"<<TestBit(kLiveUpdate)<<");"<<std::endl;
873  out<<" para->SetBit(TParallelCoord::kGlobalLogScale,"<<TestBit(kGlobalLogScale)<<");"<<std::endl;
874  if (TestBit(kGlobalScale)) out<<" para->SetGlobalScale(kTRUE);"<<std::endl;
875  if (TestBit(kCandleChart)) out<<" para->SetCandleChart(kTRUE);"<<std::endl;
876  if (TestBit(kGlobalLogScale)) out<<" para->SetGlobalLogScale(kTRUE);"<<std::endl;
877  out<<std::endl<<" para->Draw();"<<std::endl;
878 }
879 
880 ////////////////////////////////////////////////////////////////////////////////
881 /// Save the tree in a file if fTreeFileName == "".
882 
883 void TParallelCoord::SaveTree(const char* filename, Bool_t overwrite)
884 {
885  if (!(fTreeFileName=="")) return;
886  TString sfile = filename;
887  if (sfile == "") sfile = Form("%s.root",fTree->GetName());
888 
889  TFile* f = TFile::Open(sfile.Data());
890  if (f) {
891  Warning("SaveTree","%s already exists.", sfile.Data());
892  if (!overwrite) return;
893  else Warning("SaveTree","Overwriting.");
894  f = new TFile(sfile.Data(),"RECREATE");
895  } else {
896  f = new TFile(sfile.Data(),"CREATE");
897  }
898  gDirectory = f;
900  fTreeFileName = sfile;
901  Info("SaveTree","File \"%s\" written.",sfile.Data());
902 }
903 
904 ////////////////////////////////////////////////////////////////////////////////
905 /// Update the position of the axes.
906 
908 {
909  if(!gPad) return;
910  Bool_t vert = TestBit (kVertDisplay);
911  TFrame *frame = gPad->GetFrame();
912  if (fVarList->GetSize() > 1) {
913  if (vert) {
914  frame->SetX1(1.0/((Double_t)fVarList->GetSize()+1));
915  frame->SetX2(1-frame->GetX1());
916  frame->SetY1(0.1);
917  frame->SetY2(0.9);
918  gPad->RangeAxis(1.0/((Double_t)fVarList->GetSize()+1),0.1,1-frame->GetX1(),0.9);
919  } else {
920  frame->SetX1(0.1);
921  frame->SetX2(0.9);
922  frame->SetY1(1.0/((Double_t)fVarList->GetSize()+1));
923  frame->SetY2(1-frame->GetY1());
924  gPad->RangeAxis(0.1,1.0/((Double_t)fVarList->GetSize()+1),0.9,1-frame->GetY1());
925  }
926 
927  Double_t horSpace = (frame->GetX2() - frame->GetX1())/(fNvar-1);
928  Double_t verSpace = (frame->GetY2() - frame->GetY1())/(fNvar-1);
929  Int_t i=0;
930  TIter next(fVarList);
931 
932  TParallelCoordVar* var;
933  while((var = (TParallelCoordVar*)next())){
934  if (vert) var->SetX(gPad->GetFrame()->GetX1() + i*horSpace,TestBit(kGlobalScale));
935  else var->SetY(gPad->GetFrame()->GetY1() + i*verSpace,TestBit(kGlobalScale));
936  ++i;
937  }
938  } else if (fVarList->GetSize()==1) {
939  frame->SetX1(0.1);
940  frame->SetX2(0.9);
941  frame->SetY1(0.1);
942  frame->SetY2(0.9);
943  if (vert) ((TParallelCoordVar*)fVarList->First())->SetX(0.5,TestBit(kGlobalScale));
944  else ((TParallelCoordVar*)fVarList->First())->SetY(0.5,TestBit(kGlobalScale));
945  }
946 }
947 
948 ////////////////////////////////////////////////////////////////////////////////
949 /// Set the same histogram axis binning for all axis.
950 
952 {
953  TIter next(fVarList);
954  TParallelCoordVar *var;
955  while((var = (TParallelCoordVar*)next())) var->SetHistogramBinning(n);
956 }
957 
958 ////////////////////////////////////////////////////////////////////////////////
959 /// Set the same histogram axis height for all axis.
960 
962 {
963  TIter next(fVarList);
964  TParallelCoordVar *var;
965  while((var = (TParallelCoordVar*)next())) var->SetHistogramHeight(h);
966 }
967 
968 ////////////////////////////////////////////////////////////////////////////////
969 /// All axes in log scale.
970 
972 {
973  if (lt == TestBit(kGlobalLogScale)) return;
975  TIter next(fVarList);
976  TParallelCoordVar* var;
977  while ((var = (TParallelCoordVar*)next())) var->SetLogScale(lt);
979 }
980 
981 ////////////////////////////////////////////////////////////////////////////////
982 /// Constraint all axes to the same scale.
983 
985 {
986  SetBit(kGlobalScale,gl);
987  if (fCandleAxis) {
988  delete fCandleAxis;
989  fCandleAxis = 0;
990  }
991  if (gl) {
992  Double_t min,max;
993  min = GetGlobalMin();
994  max = GetGlobalMax();
995  if (TestBit(kGlobalLogScale) && min<=0) min = 0.00001*max;
996  if (TestBit(kVertDisplay)) {
997  if (!TestBit(kGlobalLogScale)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,min,max);
998  else fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,min,max,510,"G");
999  } else {
1000  if (!TestBit(kGlobalLogScale)) fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,min,max);
1001  else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,min,max,510,"G");
1002  }
1003  fCandleAxis->Draw();
1004  SetGlobalMin(min);
1005  SetGlobalMax(max);
1006  TIter next(fVarList);
1007  TParallelCoordVar* var;
1008  while ((var = (TParallelCoordVar*)next())) var->GetHistogram();
1009  }
1010  gPad->Modified();
1011  gPad->Update();
1012 }
1013 
1014 ////////////////////////////////////////////////////////////////////////////////
1015 /// Set the same histogram axis line width for all axis.
1016 
1018 {
1019  TIter next(fVarList);
1020  TParallelCoordVar *var;
1021  while((var = (TParallelCoordVar*)next())) var->SetHistogramLineWidth(lw);
1022 }
1023 
1024 ////////////////////////////////////////////////////////////////////////////////
1025 /// Set a candle chart display.
1026 
1028 {
1029  SetBit(kCandleChart,can);
1030  SetGlobalScale(can);
1031  TIter next(fVarList);
1032  TParallelCoordVar* var;
1033  while ((var = (TParallelCoordVar*)next())) {
1034  var->SetBoxPlot(can);
1035  var->SetHistogramLineWidth(0);
1036  }
1037  if (fCandleAxis) delete fCandleAxis;
1038  fCandleAxis = 0;
1039  SetBit(kPaintEntries,!can);
1040  if (can) {
1041  if (TestBit(kVertDisplay)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,GetGlobalMin(),GetGlobalMax());
1042  else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,GetGlobalMin(),GetGlobalMax());
1043  fCandleAxis->Draw();
1044  } else {
1045  if (fCandleAxis) {
1046  delete fCandleAxis;
1047  fCandleAxis = 0;
1048  }
1049  }
1050  gPad->Modified();
1051  gPad->Update();
1052 }
1053 
1054 ////////////////////////////////////////////////////////////////////////////////
1055 /// Set the first entry to be displayed.
1056 
1058 {
1059  if(f<0 || f>fNentries) return;
1060  fCurrentFirst = f;
1061  if(fCurrentFirst + fCurrentN > fNentries) fCurrentN = fNentries-fCurrentFirst;
1062  TIter next(fVarList);
1063  TParallelCoordVar* var;
1064  while ((var = (TParallelCoordVar*)next())) {
1065  var->GetMinMaxMean();
1066  var->GetHistogram();
1068  }
1069 }
1070 
1071 ////////////////////////////////////////////////////////////////////////////////
1072 /// Set the number of entry to be displayed.
1073 
1075 {
1076  if(n<=0) return;
1078  else fCurrentN = n;
1079  TIter next(fVarList);
1080  TParallelCoordVar* var;
1081  while ((var = (TParallelCoordVar*)next())) {
1082  var->GetMinMaxMean();
1083  var->GetHistogram();
1085  }
1086 }
1087 
1088 ////////////////////////////////////////////////////////////////////////////////
1089 /// Set the selection being edited.
1090 
1092 {
1094  TIter next(fSelectList);
1095  TParallelCoordSelect* sel;
1096  while((sel = (TParallelCoordSelect*)next()) && strcmp(sel->GetTitle(),title))
1097  if (sel) fCurrentSelection = sel;
1098  return sel;
1099 }
1100 
1101 ////////////////////////////////////////////////////////////////////////////////
1102 /// Set the selection being edited.
1103 
1105 {
1106  if (fCurrentSelection == sel) return;
1107  fCurrentSelection = sel;
1108 }
1109 
1110 ////////////////////////////////////////////////////////////////////////////////
1111 /// Set dots spacing. Modify the line style 11.
1112 /// If the canvas support transparency dot spacing is ignored.
1113 
1115 {
1116  if (gPad->GetCanvas()->SupportAlpha()) return;
1117  if (s == fDotsSpacing) return;
1118  fDotsSpacing = s;
1119  gStyle->SetLineStyleString(11,Form("%d %d",4,s*8));
1120 }
1121 
1122 ////////////////////////////////////////////////////////////////////////////////
1123 /// Set the entry lists of "para".
1124 
1126 {
1127  para->SetCurrentEntries(enlist);
1128  para->SetInitEntries(enlist);
1129 }
1130 
1131 ////////////////////////////////////////////////////////////////////////////////
1132 /// Force all variables to adopt the same max.
1133 
1135 {
1136  TIter next(fVarList);
1137  TParallelCoordVar* var;
1138  while ((var = (TParallelCoordVar*)next())) {
1139  var->SetCurrentMax(max);
1140  }
1141 }
1142 
1143 ////////////////////////////////////////////////////////////////////////////////
1144 /// Force all variables to adopt the same min.
1145 
1147 {
1148  TIter next(fVarList);
1149  TParallelCoordVar* var;
1150  while ((var = (TParallelCoordVar*)next())) {
1151  var->SetCurrentMin(min);
1152  }
1153 }
1154 
1155 ////////////////////////////////////////////////////////////////////////////////
1156 /// If true, the pad is updated while the motion of a dragged range.
1157 
1159 {
1160  SetBit(kLiveUpdate,on);
1161  TIter next(fVarList);
1162  TParallelCoordVar* var;
1163  while((var = (TParallelCoordVar*)next())) var->SetLiveRangesUpdate(on);
1164 }
1165 
1166 ////////////////////////////////////////////////////////////////////////////////
1167 /// Set the vertical or horizontal display.
1168 
1170 {
1171  if (vert == TestBit (kVertDisplay)) return;
1172  SetBit(kVertDisplay,vert);
1173  if (!gPad) return;
1174  TFrame* frame = gPad->GetFrame();
1175  if (!frame) return;
1176  UInt_t ui = 0;
1177  Double_t horaxisspace = (frame->GetX2() - frame->GetX1())/(fNvar-1);
1178  Double_t veraxisspace = (frame->GetY2() - frame->GetY1())/(fNvar-1);
1179  TIter next(fVarList);
1180  TParallelCoordVar* var;
1181  while ((var = (TParallelCoordVar*)next())) {
1182  if (vert) var->SetX(frame->GetX1() + ui*horaxisspace,TestBit(kGlobalScale));
1183  else var->SetY(frame->GetY1() + ui*veraxisspace,TestBit(kGlobalScale));
1184  ++ui;
1185  }
1186  if (TestBit(kCandleChart)) {
1187  if (fCandleAxis) delete fCandleAxis;
1188  if (TestBit(kVertDisplay)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,GetGlobalMin(),GetGlobalMax());
1189  else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,GetGlobalMin(),GetGlobalMax());
1190  fCandleAxis->Draw();
1191  }
1192  gPad->Modified();
1193  gPad->Update();
1194 }
1195 
1196 ////////////////////////////////////////////////////////////////////////////////
1197 /// Unzoom all variables.
1198 
1200 {
1201  TIter next(fVarList);
1202  TParallelCoordVar* var;
1203  while((var = (TParallelCoordVar*)next())) var->Unzoom();
1204 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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:830
TEntryList * fInitEntries
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:49
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:405
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:899
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:211
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:77
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:65
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:1939
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:53
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:635
R__EXTERN TStyle * gStyle
Definition: TStyle.h:418
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:157
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:50
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:581
See TView3D.
Definition: TView.h:29
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:160
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:364
Basic string class.
Definition: TString.h:137
A TParallelCoordRange is a range used for parallel coordinates plots.
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1089
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:67
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
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:255
void SetVertDisplay(Bool_t vert=kTRUE)
Set the vertical or horizontal display.
virtual void SetX1(Double_t x1)
Definition: TBox.h:75
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:44
TH1F * GetHistogram()
Create or recreate the histogram.
Definition: Rtypes.h:61
void SetCurrentN(Long64_t)
Set the number of entry to be displayed.
Bool_t Contains(const char *name) const
Definition: TCollection.h:84
void SetBoxPlot(Bool_t box)
Set the axis to display a candle.
const char * Class
Definition: TXMLSetup.cxx:64
virtual void SetX2(Double_t x2)
Definition: TBox.h:76
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition: TTree.cxx:5859
Color_t fLineColor
virtual Int_t GetDimension() const
Definition: TSelectorDraw.h:82
void SetLineStyleString(Int_t i, const char *text)
Set line style string using the PostScript convention.
Definition: TStyle.cxx:1107
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:41
Double_t GetGlobalMin()
return the global minimum.
void Reset()
Definition: TCollection.h:161
Iterator of linked list.
Definition: TList.h:187
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:739
if object in a list can be deleted
Definition: TObject.h:56
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:3907
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:165
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 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:31
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
REAL estimate(int elen, REAL *e)
Definition: triangle.c:5087
void DeleteVariable()
Delete variables.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:119
void SetInitEntries(TEntryList *entries)
TString & Append(const char *cs)
Definition: TString.h:492
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:54
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:47
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:46
TTreeFormula * GetSelect() const
Definition: TSelectorDraw.h:88
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:9042
TParallelCoord()
Default constructor.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:557
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:675
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:925
TFile * GetCurrentFile() const
Return pointer to the current file.
Definition: TTree.cxx:5053
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:655
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:30
virtual Long64_t GetEstimate() const
Definition: TTree.h:397
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:311
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:90
TGraphErrors * gr
Definition: legend1.C:25
Define a Frame.
Definition: TFrame.h:21
A specialized TSelector for TTree::Draw.
Definition: TSelectorDraw.h:33
void UnzoomAll()
Unzoom all variables.
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:39
virtual void SetY2(Double_t y2)
Definition: TBox.h:78
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
void GetQuantiles()
Get the box plot values (quantiles).
The Canvas class.
Definition: TCanvas.h:41
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:27
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
Bool_t IsZombie() const
Definition: TObject.h:120
Double_t GetX1() const
Definition: TBox.h:64
virtual void SetEntryList(TEntryList *list, Option_t *opt="")
Set an EntryList.
Definition: TTree.cxx:8403
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:367
int nentries
Definition: THbookFile.cxx:89
Double_t y[n]
Definition: legend1.C:17
virtual Int_t GetNfill() const
Definition: TSelectorDraw.h:86
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
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:560
virtual void SetObject(TObject *obj)
Definition: TSelector.h:72
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:48
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:81
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
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:31
TList * fSelectList
#define gPad
Definition: TVirtualPad.h:289
void Reset()
Reset list iterator.
Definition: TList.cxx:977
Double_t GetY1() const
Definition: TBox.h:66
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:98
#define gDirectory
Definition: TDirectory.h:221
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:43
virtual Int_t GetSize() const
Definition: TCollection.h:95
double exp(double)
const Bool_t kTRUE
Definition: Rtypes.h:91
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:77
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:27
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:24
virtual Double_t * GetV1()
Definition: TTree.h:462
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:911
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
const char * Data() const
Definition: TString.h:349
void SaveEntryLists(const char *filename="", Bool_t overwrite=kFALSE)
Save the entry lists in a root file "filename.root".