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