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 <cfloat>
17#include <iostream>
18
19#include "TROOT.h"
20#include "TVirtualPad.h"
21#include "TPolyLine.h"
22#include "TGraph.h"
23#include "TPaveText.h"
24#include "TStyle.h"
25#include "TEntryList.h"
26#include "TFrame.h"
27#include "TTree.h"
28#include "TTreePlayer.h"
29#include "TSelectorDraw.h"
30#include "TTreeFormula.h"
31#include "TView.h"
32#include "TRandom.h"
33#include "TCanvas.h"
34#include "TGaxis.h"
35#include "TFile.h"
36
38
39/** \class TParallelCoord
40Parallel Coordinates class.
41
42The multidimensional system of Parallel coordinates is a common way of studying
43high-dimensional geometry and visualizing multivariate problems. It has first
44been proposed by A. Inselberg in 1981.
45
46To show a set of points in an n-dimensional space, a backdrop is drawn
47consisting of n parallel lines. A point in n-dimensional space is represented as
48a polyline with vertices on the parallel axes; the position of the vertex on the
49i-th axis corresponds to the i-th coordinate of the point.
50
51This tool comes with a rather large gui in the editor. It is necessary to use
52this editor in order to explore a data set, as explained below.
53
54### Reduce cluttering:
55
56The main issue for parallel coordinates is the very high cluttering of the
57output when dealing with large data set. Two techniques have been implemented to
58bypass that so far:
59
60 - Draw doted lines instead of plain lines with an adjustable dots spacing. A
61 slider to adjust the dots spacing is available in the editor.
62 - Sort the entries to display with a "weight cut". On each axis is drawn a
63 histogram describing the distribution of the data on the corresponding
64 variable. The "weight" of an entry is the sum of the bin content of each bin
65 the entry is going through. An entry going through the histograms peaks will
66 have a big weight wether an entry going randomly through the histograms will
67 have a rather small weight. Setting a cut on this weight allows to draw only
68 the most representative entries. A slider set the cut is also available in
69 the gui.
70
71## Selections:
72
73Selections of specific entries can be defined over the data se using parallel
74coordinates. With that representation, a selection is an ensemble of ranges
75defined on the axes. Ranges defined on the same axis are conjugated with OR
76(an entry must be in one or the other ranges to be selected). Ranges on
77different axes are are conjugated with AND (an entry must be in all the ranges
78to be selected). Several selections can be defined with different colors. It is
79possible to generate an entry list from a given selection and apply it to the
80tree using the editor ("Apply to tree" button).
81
82## Axes:
83
84Options can be defined each axis separately using the right mouse click. These
85options can be applied to every axes using the editor.
86
87 - Axis width: If set to 0, the axis is simply a line. If higher, a color
88 histogram is drawn on the axis.
89 - Axis histogram height: If not 0, a usual bar histogram is drawn on the plot.
90
91The order in which the variables are drawn is essential to see the clusters. The
92axes can be dragged to change their position. A zoom is also available. The
93logarithm scale is also available by right clicking on the axis.
94
95## Candle chart:
96
97TParallelCoord can also be used to display a candle chart. In that mode, every
98variable is drawn in the same scale. The candle chart can be combined with the
99parallel coordinates mode, drawing the candle sticks over the axes.
100
101~~~ {.cpp}
102{
103 TCanvas *c1 = new TCanvas("c1");
104 TFile *f = TFile::Open("cernstaff.root");
105 TTree *T = (TTree*)f->Get("T");
106 T->Draw("Age:Grade:Step:Cost:Division:Nation","","para");
107 TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
108 TParallelCoordVar* grade = (TParallelCoordVar*)para->GetVarList()->FindObject("Grade");
109 grade->AddRange(new TParallelCoordRange(grade,11.5,14));
110 para->AddSelection("less30");
111 para->GetCurrentSelection()->SetLineColor(kViolet);
112 TParallelCoordVar* age = (TParallelCoordVar*)para->GetVarList()->FindObject("Age");
113 age->AddRange(new TParallelCoordRange(age,21,30));
114}
115~~~
116
117### Some references:
118
119 - Alfred Inselberg's Homepage <http://www.math.tau.ac.il/~aiisreal>, with
120 Visual Tutorial, History, Selected Publications and Applications.
121 - Almir Olivette Artero, Maria Cristina Ferreira de Oliveira, Haim Levkowitz,
122 "Uncovering Clusters in Crowded Parallel Coordinates Visualizations,"
123 infovis, pp. 81-88, IEEE Symposium on Information Visualization
124 (INFOVIS'04), 2004.
125*/
126
127////////////////////////////////////////////////////////////////////////////////
128/// Default constructor.
129
131 :TNamed()
132{
133 Init();
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Constructor without a reference to a tree,
138/// the datas must be added afterwards with
139/// TParallelCoord::AddVariable(Double_t*,const char*).
140
142{
143 Init();
146 fVarList = new TList();
147 fSelectList = new TList();
150}
151
152////////////////////////////////////////////////////////////////////////////////
153/// Normal constructor, the datas must be added afterwards
154/// with TParallelCoord::AddVariable(Double_t*,const char*).
155
157 :TNamed("ParaCoord","ParaCoord")
158{
159 Init();
160 Int_t estimate = tree->GetEstimate();
161 if (nentries>estimate) {
162 Warning("TParallelCoord","Call tree->SetEstimate(tree->GetEntries()) to display all the tree variables");
164 } else {
166 }
168 fTree = tree;
171 else fTreeFileName = "";
172 fVarList = new TList();
173 fSelectList = new TList();
176}
177
178////////////////////////////////////////////////////////////////////////////////
179/// Destructor.
180
182{
184 if (fVarList) {
185 fVarList->Delete();
186 delete fVarList;
187 }
188 if (fSelectList) {
190 delete fSelectList;
191 }
192 if (fCandleAxis) delete fCandleAxis;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Add a variable.
198
199void TParallelCoord::AddVariable(Double_t* val, const char* title)
200{
201 ++fNvar;
202 fVarList->Add(new TParallelCoordVar(val,title,fVarList->GetSize(),this));
204}
205
206////////////////////////////////////////////////////////////////////////////////
207/// Add a variable from an expression.
208
209void TParallelCoord::AddVariable(const char* varexp)
210{
211 if(!fTree) return; // The tree from which one will get the data must be defined.
212
213 // Select in the only the entries of this TParallelCoord.
215 fTree->SetEntryList(list);
216
217 // ensure that there is only one variable given:
218
219 TString exp = varexp;
220
221 if (exp.Contains(':') || exp.Contains(">>") || exp.Contains("<<")) {
222 Warning("AddVariable","Only a single variable can be added at a time.");
223 return;
224 }
225 if (exp == ""){
226 Warning("AddVariable","Nothing to add");
227 return;
228 }
229
230 Long64_t en = fTree->Draw(varexp,"","goff");
231 if (en<0) {
232 Warning("AddVariable","%s could not be evaluated",varexp);
233 return;
234 }
235
236 AddVariable(fTree->GetV1(),varexp);
237}
238
239////////////////////////////////////////////////////////////////////////////////
240/// Add a selection.
241
242void TParallelCoord::AddSelection(const char* title)
243{
245 fSelectList->Add(sel);
246 fCurrentSelection = sel;
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Apply the current selection to the tree.
251
253{
254 if(!fTree) return;
255 if(fSelectList) {
256 if(fSelectList->GetSize() == 0) return;
258 }
261 fCurrentFirst = 0;
264 TString varexp = "";
265 TIter next(fVarList);
267 while ((var = (TParallelCoordVar*)next())) varexp.Append(Form(":%s",var->GetTitle()));
268 varexp.Remove(TString::kLeading,':');
269 TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)fTree->GetPlayer())->GetSelector();
270 fTree->Draw(varexp.Data(),"","goff");
271 next.Reset();
272 Int_t i = 0;
273 while ((var = (TParallelCoordVar*)next())) {
274 var->SetValues(fNentries, selector->GetVal(i));
275 ++i;
276 }
277 if (fSelectList) { // FIXME It would be better to update the selections by deleting
278 fSelectList->Delete(); // the meaningless ranges (selecting everything or nothing for example)
279 fCurrentSelection = 0; // after applying a new entrylist to the tree.
280 }
281 gPad->Modified();
282 gPad->Update();
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Call constructor and add the variables.
287
289{
290 TParallelCoord* pc = new TParallelCoord(selector->GetTree(),selector->GetNfill());
291 pc->SetBit(kCanDelete);
292 selector->SetObject(pc);
293 TString varexp = "";
294 for(Int_t i=0;i<selector->GetDimension();++i) {
295 if (selector->GetVal(i)) {
296 if (selector->GetVar(i)) {
297 pc->AddVariable(selector->GetVal(i),selector->GetVar(i)->GetTitle());
298 varexp.Append(Form(":%s",selector->GetVar(i)->GetTitle()));
299 }
300 }
301 }
302 varexp.Remove(TString::kLeading,':');
303 if (selector->GetSelect()) varexp.Append(Form("{%s}",selector->GetSelect()->GetTitle()));
304 pc->SetTitle(varexp.Data());
305 if (!candle) pc->Draw();
306 else pc->Draw("candle");
307}
308
309////////////////////////////////////////////////////////////////////////////////
310/// Clean up the selections from the ranges which could have been deleted
311/// when a variable has been deleted.
312
314{
315 TIter next(fSelectList);
316 TParallelCoordSelect* select;
317 while ((select = (TParallelCoordSelect*)next())){
318 if(select->Contains(range)) select->Remove(range);
319 }
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Delete a selection.
324
326{
327 fSelectList->Remove(sel);
328 delete sel;
329 if(fSelectList->GetSize() == 0) fCurrentSelection = 0;
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Compute the distance from the TParallelCoord.
335
337{
338 if(!gPad) return 9999;
339
340 TFrame *frame = gPad->GetFrame();
341
342 Double_t x1,x2,y1,y2,xx,yy;
343
344 x1 = frame->GetX1()+0.01;
345 x2 = frame->GetX2()-0.01;
346 y2 = frame->GetY2()-0.01;
347 y1 = frame->GetY1()+0.01;
348
349 xx = gPad->AbsPixeltoX(px);
350 yy = gPad->AbsPixeltoY(py);
351
352 if(xx>x1 && xx<x2 && yy>y1 && yy<y2) return 0;
353 else return 9999;
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Draw the parallel coordinates graph.
358
360{
361 if (!GetTree()) return;
363 Bool_t optcandle = kFALSE;
364 TString opt = option;
365 opt.ToLower();
366 if(opt.Contains("candle")) {
367 optcandle = kTRUE;
368 opt.ReplaceAll("candle","");
369 }
370 if(optcandle) {
374 }
375
376 if (gPad) {
377 if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
378 } else gROOT->MakeDefCanvas();
379 TView *view = gPad->GetView();
380 if(view){
381 delete view;
382 gPad->SetView(0);
383 }
384 gPad->Clear();
385 if (!optcandle) {
386 if (gPad && gPad->IsA() == TCanvas::Class()
387 && !((TCanvas*)gPad)->GetShowEditor()) {
388 ((TCanvas*)gPad)->ToggleEditor();
389 ((TCanvas*)gPad)->ToggleEventStatus();
390 }
391 }
392
394
395 TFrame *frame = new TFrame(0.1,0.1,0.9,0.9);
396 frame->SetBorderSize(0);
397 frame->SetBorderMode(0);
398 frame->SetFillStyle(0);
399 frame->SetLineColor(gPad->GetFillColor());
400 frame->Draw();
401 AppendPad(option);
402 TPaveText *title = new TPaveText(0.05,0.95,0.35,1);
403 title->AddText(GetTitle());
404 title->Draw();
406 TIter next(fVarList);
408 while ((var = (TParallelCoordVar*)next())) {
409 if(optcandle) {
410 var->SetBoxPlot(kTRUE);
411 var->SetHistogramHeight(0.5);
412 var->SetHistogramLineWidth(0);
413 }
414 }
415
416 if (optcandle) {
417 if (TestBit(kVertDisplay)) fCandleAxis = new TGaxis(0.05,0.1,0.05,0.9,GetGlobalMin(),GetGlobalMax());
418 else fCandleAxis = new TGaxis(0.1,0.05,0.9,0.05,GetGlobalMin(),GetGlobalMax());
419 fCandleAxis->Draw();
420 }
421
422 if (gPad && gPad->IsA() == TCanvas::Class())
423 ((TCanvas*)gPad)->Selected(gPad,this,1);
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Execute the corresponding entry.
428
429void TParallelCoord::ExecuteEvent(Int_t /*entry*/, Int_t /*px*/, Int_t /*py*/)
430{
431 if (!gPad) return;
432 gPad->SetCursor(kHand);
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Return the selection currently being edited.
437
439{
440 if (!fSelectList) return 0;
441 if (!fCurrentSelection) {
443 }
444 return fCurrentSelection;
445}
446
447////////////////////////////////////////////////////////////////////////////////
448/// Get the whole entry list or one for a selection.
449
451{
452 if(!sel || fCurrentSelection->GetSize() == 0){ // If no selection is specified, return the entry list of all the entries.
453 return fInitEntries;
454 } else { // return the entry list corresponding to the current selection.
455 TEntryList *enlist = new TEntryList(fTree);
456 TIter next(fVarList);
457 for (Long64_t li=0;li<fNentries;++li) {
458 next.Reset();
459 Bool_t inrange=kTRUE;
461 while((var = (TParallelCoordVar*)next())){
462 if(!var->Eval(li,fCurrentSelection)) inrange = kFALSE;
463 }
464 if(!inrange) continue;
465 enlist->Enter(fCurrentEntries->GetEntry(li));
466 }
467 return enlist;
468 }
469}
470
471////////////////////////////////////////////////////////////////////////////////
472/// return the global maximum.
473
475{
476 Double_t gmax=-DBL_MAX;
477 TIter next(fVarList);
479 while ((var = (TParallelCoordVar*)next())) {
480 if (gmax < var->GetCurrentMax()) gmax = var->GetCurrentMax();
481 }
482 return gmax;
483}
484
485////////////////////////////////////////////////////////////////////////////////
486/// return the global minimum.
487
489{
490 Double_t gmin=DBL_MAX;
491 TIter next(fVarList);
493 while ((var = (TParallelCoordVar*)next())) {
494 if (gmin > var->GetCurrentMin()) gmin = var->GetCurrentMin();
495 }
496 return gmin;
497}
498
499////////////////////////////////////////////////////////////////////////////////
500/// get the binning of the histograms.
501
503{
504 return ((TParallelCoordVar*)fVarList->First())->GetNbins();
505}
506
507////////////////////////////////////////////////////////////////////////////////
508/// Get a selection from its title.
509
511{
512 TIter next(fSelectList);
514 while ((sel = (TParallelCoordSelect*)next()) && strcmp(title,sel->GetTitle())) { }
515 return sel;
516}
517
518////////////////////////////////////////////////////////////////////////////////
519/// return the tree if fTree is defined. If not, the method try to load the tree
520/// from fTreeFileName.
521
523{
524 if (fTree) return fTree;
525 if (fTreeFileName=="" || fTreeName=="") {
526 Error("GetTree","Cannot load the tree: no tree defined!");
527 return 0;
528 }
530 if (!f) {
531 Error("GetTree","Tree file name : \"%s\" does not exist (Are you in the correct directory?).",fTreeFileName.Data());
532 return 0;
533 } else if (f->IsZombie()) {
534 Error("GetTree","while opening \"%s\".",fTreeFileName.Data());
535 return 0;
536 } else {
537 fTree = (TTree*)f->Get(fTreeName.Data());
538 if (!fTree) {
539 Error("GetTree","\"%s\" not found in \"%s\".", fTreeName.Data(), fTreeFileName.Data());
540 return 0;
541 } else {
543 TString varexp = "";
544 TIter next(fVarList);
546 while ((var = (TParallelCoordVar*)next())) varexp.Append(Form(":%s",var->GetTitle()));
547 varexp.Remove(TString::kLeading,':');
548 fTree->Draw(varexp.Data(),"","goff");
549 TSelectorDraw* selector = (TSelectorDraw*)((TTreePlayer*)fTree->GetPlayer())->GetSelector();
550 next.Reset();
551 Int_t i = 0;
552 while ((var = (TParallelCoordVar*)next())) {
553 var->SetValues(fNentries, selector->GetVal(i));
554 ++i;
555 }
556 return fTree;
557 }
558 }
559}
560
561////////////////////////////////////////////////////////////////////////////////
562/// Get the variables values from its title.
563
565{
566 TIter next(fVarList);
567 TParallelCoordVar* var = 0;
568 while(((var = (TParallelCoordVar*)next()) != 0) && (var->GetTitle() != vartitle)) { }
569 if(!var) return 0;
570 else return var->GetValues();
571}
572
573////////////////////////////////////////////////////////////////////////////////
574/// Get the variables values from its index.
575
577{
578 if(i<0 || (UInt_t)i>fNvar) return 0;
579 else return ((TParallelCoordVar*)fVarList->At(i))->GetValues();
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Initialise the data members of TParallelCoord.
584
586{
587 fNentries = 0;
588 fVarList = 0;
589 fSelectList = 0;
597 fTree = 0;
598 fCurrentEntries = 0;
599 fInitEntries = 0;
601 fNvar = 0;
602 fDotsSpacing = 0;
603 fCurrentFirst = 0;
604 fCurrentN = 0;
605 fCandleAxis = 0;
606 fWeightCut = 0;
607 fLineWidth = 1;
608 fLineColor = kGreen-8;
609 fTreeName = "";
610 fTreeFileName = "";
611}
612
613////////////////////////////////////////////////////////////////////////////////
614/// Paint the parallel coordinates graph.
615
617{
618 if (!GetTree()) return;
619 gPad->Range(0,0,1,1);
620 TFrame *frame = gPad->GetFrame();
621 frame->SetLineColor(gPad->GetFillColor());
624 PaintEntries(0);
625 TIter next(fSelectList);
627 while((sel = (TParallelCoordSelect*)next())) {
628 if(sel->GetSize()>0 && sel->TestBit(TParallelCoordSelect::kActivated)) {
629 PaintEntries(sel);
630 }
631 }
632 }
633 gPad->RangeAxis(0,0,1,1);
634
635 TIter nextVar(fVarList);
636 TParallelCoordVar* var=0;
637 while((var = (TParallelCoordVar*)nextVar())) {
638 var->Paint();
639 }
640}
641
642////////////////////////////////////////////////////////////////////////////////
643/// Loop over the entries and paint them.
644
646{
647 if (fVarList->GetSize() < 2) return;
648 Int_t i=0;
649 Long64_t n=0;
650
651 Double_t *x = new Double_t[fNvar];
652 Double_t *y = new Double_t[fNvar];
653
654 TGraph *gr = 0;
655 TPolyLine *pl = 0;
656 TAttLine *evline = 0;
657
658 if (TestBit (kCurveDisplay)) {gr = new TGraph(fNvar); evline = (TAttLine*)gr;}
659 else {pl = new TPolyLine(fNvar); evline = (TAttLine*)pl;}
660
661 if (fDotsSpacing == 0) evline->SetLineStyle(1);
662 else evline->SetLineStyle(11);
663 if (!sel){
664 evline->SetLineWidth(GetLineWidth());
665 evline->SetLineColor(GetLineColor());
666 } else {
667 evline->SetLineWidth(sel->GetLineWidth());
668 evline->SetLineColor(sel->GetLineColor());
669 }
671
672 TFrame *frame = gPad->GetFrame();
673 Double_t lx = ((frame->GetX2() - frame->GetX1())/(fNvar-1));
674 Double_t ly = ((frame->GetY2() - frame->GetY1())/(fNvar-1));
675 Double_t a,b;
676 TRandom r;
677
679 TListIter next(fVarList);
680 Bool_t inrange = kTRUE;
681 // Loop to check whenever the entry must be painted.
682 if (sel) {
683 while ((var = (TParallelCoordVar*)next())){
684 if (!var->Eval(n,sel)) inrange = kFALSE;
685 }
686 }
687 if (fWeightCut > 0) {
688 next.Reset();
689 Int_t entryweight = 0;
690 while ((var = (TParallelCoordVar*)next())) entryweight+=var->GetEntryWeight(n);
691 if (entryweight/(Int_t)fNvar < fWeightCut) inrange = kFALSE;
692 }
693 if(!inrange) continue;
694 i = 0;
695 next.Reset();
696 // Loop to set the polyline points.
697 while ((var = (TParallelCoordVar*)next())) {
698 var->GetEntryXY(n,x[i],y[i]);
699 ++i;
700 }
701 // beginning to paint the first point at a random distance
702 // to avoid artefacts when increasing the dots spacing.
703 if (fDotsSpacing != 0) {
704 if (TestBit(kVertDisplay)) {
705 a = (y[1]-y[0])/(x[1]-x[0]);
706 b = y[0]-a*x[0];
707 x[0] = x[0]+lx*r.Rndm();
708 y[0] = a*x[0]+b;
709 } else {
710 a = (x[1]-x[0])/(y[1]-y[0]);
711 b = x[0]-a*y[0];
712 y[0] = y[0]+ly*r.Rndm();
713 x[0] = a*y[0]+b;
714 }
715 }
716 if (pl) pl->PaintPolyLine(fNvar,x,y);
717 else gr->PaintGraph(fNvar,x,y,"C");
718 }
719
720 if (pl) delete pl;
721 if (gr) delete gr;
722 delete [] x;
723 delete [] y;
724}
725
726////////////////////////////////////////////////////////////////////////////////
727/// Delete a variable from the graph.
728
730{
731 fVarList->Remove(var);
734}
735
736////////////////////////////////////////////////////////////////////////////////
737/// Delete the variable "vartitle" from the graph.
738
740{
741 TIter next(fVarList);
742 TParallelCoordVar* var=0;
743 while((var = (TParallelCoordVar*)next())) {
744 if (!strcmp(var->GetTitle(),vartitle)) break;
745 }
746 if(!var) {
747 Error("RemoveVariable","\"%s\" not a variable",vartitle);
748 return kFALSE;
749 } else {
750 RemoveVariable(var);
751 delete var;
752 return kTRUE;
753 }
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);
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
791void 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
814void 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);
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
883void 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
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);
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);
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);
977 while ((var = (TParallelCoordVar*)next())) var->SetLogScale(lt);
979}
980
981////////////////////////////////////////////////////////////////////////////////
982/// Constraint all axes to the same scale.
983
985{
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;
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);
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}
int Int_t
Definition: CPyCppyy.h:43
unsigned int UInt_t
Definition: CPyCppyy.h:44
void Class()
Definition: Class.C:29
@ kHand
Definition: GuiTypes.h:374
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:101
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:364
@ kGreen
Definition: Rtypes.h:66
#define gDirectory
Definition: TDirectory.h:327
int nentries
Definition: THbookFile.cxx:91
double exp(double)
#define gROOT
Definition: TROOT.h:404
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
#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:50
virtual void SetY2(Double_t y2)
Definition: TBox.h:64
Double_t GetX2() const
Definition: TBox.h:51
Double_t GetY1() const
Definition: TBox.h:52
virtual void SetX1(Double_t x1)
Definition: TBox.h:61
Double_t GetY2() const
Definition: TBox.h:53
virtual void SetX2(Double_t x2)
Definition: TBox.h:62
virtual void SetY1(Double_t y1)
Definition: TBox.h:63
The Canvas class.
Definition: TCanvas.h:23
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:625
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:722
virtual Long64_t GetN() const
Definition: TEntryList.h:76
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
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:4011
Define a Frame.
Definition: TFrame.h:19
virtual void Draw(Option_t *option="")
Draw this frame with its current attributes.
Definition: TFrame.cxx:67
The axis painter class.
Definition: TGaxis.h:23
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:71
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:2053
void Reset()
Definition: TCollection.h:252
Iterator of linked list.
Definition: TList.h:200
void Reset()
Reset list iterator.
Definition: TList.cxx:1159
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:822
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:357
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:470
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:659
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
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:798
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:879
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:107
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:197
@ 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:867
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.
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.
Double_t * GetValues()
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
-> Selected entries when TParallelCoord first initialized.
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
-> Current selected entries in the tree.
void SetGlobalLogScale(Bool_t)
All axes in log scale.
TParallelCoordSelect * fCurrentSelection
! Current Selection being edited.
TParallelCoordSelect * GetCurrentSelection()
Return the selection currently being edited.
Double_t GetGlobalMin()
return the global minimum.
void Init()
Initialise the data members of TParallelCoord.
virtual ~TParallelCoord()
Destructor.
Int_t fDotsSpacing
Spacing between dots to draw the entries.
Int_t fWeightCut
Specify a cut on the entries from their weight (see TParallelCoordVar::GetEvtWeight(Long64_t))
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
List of selections over the variables.
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
Name of the tree.
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.
TTree * fTree
! Pointer to the TTree.
Width_t fLineWidth
entries line width.
TString fTreeFileName
Name of the file containing the tree.
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
First entry to display.
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
Number of entries to display.
void PaintEntries(TParallelCoordSelect *sel=NULL)
Loop over the entries and paint them.
Long64_t fNentries
Number of entries;.
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.
UInt_t fNvar
Number of variables.
void SaveEntryLists(const char *filename="", Bool_t overwrite=kFALSE)
Save the entry lists in a root file "filename.root".
Color_t fLineColor
entries line color.
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".
@ kCurveDisplay
If the polylines are replaced by interpolated curves.
@ kGlobalScale
Every variable is on the same scale.
@ kVertDisplay
If the axes are drawn vertically, false if horizontally.
@ kGlobalLogScale
Every variable in log scale.
@ kPaintEntries
To paint all TParallelCoord entries.
@ kLiveUpdate
To paint the entries when being modified.
@ kCandleChart
To produce a candle chart.
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
! An axis used when displaying a candle chart.
TList * fVarList
List of the variables.
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:183
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:234
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:33
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:82
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:90
TTreeFormula * GetSelect() const
Definition: TSelectorDraw.h:88
virtual Int_t GetNfill() const
Definition: TSelectorDraw.h:86
virtual void SetObject(TObject *obj)
Definition: TSelector.h:65
Basic string class.
Definition: TString.h:136
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1150
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
@ kLeading
Definition: TString.h:267
const char * Data() const
Definition: TString.h:369
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
TString & Append(const char *cs)
Definition: TString.h:564
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
void SetLineStyleString(Int_t i, const char *text)
Set line style string using the PostScript convention.
Definition: TStyle.cxx:1431
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:79
TFile * GetCurrentFile() const
Return pointer to the current file.
Definition: TTree.cxx:5422
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition: TTree.cxx:6248
virtual void SetEntryList(TEntryList *list, Option_t *opt="")
Set an EntryList.
Definition: TTree.cxx:8933
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TTree.h:427
virtual Double_t * GetV1()
Definition: TTree.h:531
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:9635
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
long long Long64_t
Definition: cpp_cppyy.h:13
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:5088