Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSpider.cxx
Go to the documentation of this file.
1// @(#)root/treeviewer:$Id: 2bb6def14de16b049d4c979e73ad2b08d0936520 $
2// Author: Bastien Dalla Piazza 20/07/07
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 "TSpider.h"
13#include "TAttFill.h"
14#include "TAttText.h"
15#include "TAttLine.h"
16#include "TGraphPolargram.h"
17#include "TPolyLine.h"
18#include "TNtuple.h"
19#include "TBranch.h"
20#include "TTreeFormula.h"
21#include "TTreeFormulaManager.h"
22#include "TList.h"
23#include "TSelectorDraw.h"
24#include "TROOT.h"
25#include "TEntryList.h"
26#include "TLatex.h"
27#include "TVirtualPad.h"
28#include "TMath.h"
29#include "TCanvas.h"
30#include "TArc.h"
31#include "float.h"
32#include "TEnv.h"
33
35
36/** \class TSpider
37Spider class.
38
39A spider view is a handy way to visualize a set of data stored in a TTree.
40It draws as many polar axes as selected data members. For each of them, it draws
41on the axis the position of the present event between the min and max of the
42data member. Two modes are available:
43
44 - The spider view: With each points on the axes is drawn a polyline.
45 - The segment view: For each data member is drawn an arc segment with the
46 radius corresponding to the event.
47
48The spider plot is available from the treeviewer called by
49"atree->StartViewer()", or simply by calling its constructor and defining the
50variables to display.
51
52Begin_Macro(source)
53{
54 TCanvas *c1 = new TCanvas("c1","TSpider example",200,10,700,700);
55 TFile *f = new TFile("$(ROOTSYS)/tutorials/hsimple.root");
56 if (!f || f->IsZombie()) {
57 printf("Please run <ROOT location>/tutorials/hsimple.C before.");
58 return;
59 }
60 TNtuple* ntuple = (TNtuple*)f->Get("ntuple");
61 TString varexp = "px:py:pz:random:sin(px):log(px/py):log(pz)";
62 TString selectStr = "px>0 && py>0 && pz>0";
63 TString options = "average";
64 TSpider *spider = new TSpider(ntuple,varexp.Data(),selectStr.Data(),options.Data());
65 spider->Draw();
66 c1->ToggleEditor();
67 c1->Selected(c1,spider,1);
68 return c1;
69}
70End_Macro
71*/
72
73////////////////////////////////////////////////////////////////////////////////
74/// Default constructor.
75
77{
80 fPolargram=NULL;
81 fInput=NULL;
82 fManager=NULL;
83 fNcols=0;
84 fNx=3;
85 fNy=4;
86 fPolyList=NULL;
87 fSelect=NULL;
88 fSelector=NULL;
89 fTree=NULL;
90 fMax=NULL;
91 fMin=NULL;
92 fAve=NULL;
93 fCanvas=NULL;
94 fAveragePoly=NULL;
95 fEntry=0;
96 fSuperposed=NULL;
99 fAverageSlices=NULL;
101 fNentries=0;
102 fFirstEntry=0;
103 fArraySize=0;
104 fCurrentEntries = NULL;
105 fFormulas = NULL;
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Normal constructor. Options are:
110/// - "average"
111/// - "showrange"
112/// - "segment"
113
114TSpider::TSpider(TTree* tree ,const char *varexp, const char *selection,
115 Option_t *option, Long64_t nentries, Long64_t firstentry)
116 : TAttFill(2,3003), TAttLine(1,1,1)
117{
118 UInt_t ui=0;
119
120 fArraySize = 16;
121 fTree=tree;
123 fFormulas= new TList();
124 fInput= new TList();
125 fInput->Add(new TNamed("varexp",""));
126 fInput->Add(new TNamed("selection",""));
128 gROOT->GetListOfCleanups()->Add(this);
129 fNx=2;
130 fNy=2;
132 fSelect=NULL;
133 fManager=NULL;
134 fCanvas=NULL;
135 fAveragePoly=NULL;
137 fSuperposed=NULL;
141 fAverageSlices=NULL;
143 if (firstentry < 0 || firstentry > tree->GetEstimate()) firstentry = 0;
144 fFirstEntry = firstentry;
145 if (nentries>0) fNentries = nentries;
146 else fNentries = nentries = tree->GetEstimate()-firstentry;
147
149
150 fPolargram=NULL;
151 fPolyList=NULL;
152
155 for(ui=0;ui<fNx*fNy;++ui) fCurrentEntries[ui]=0;
156
157 TString opt = option;
158
159 if (opt.Contains("average")) fDisplayAverage=kTRUE;
160 if (opt.Contains("showrange")) fShowRange=kTRUE;
161 if (opt.Contains("segment")) fSegmentDisplay=kTRUE;
162
163 fNcols=8;
164
166 SetSelectionExpression(selection);
167 SyncFormulas();
168 InitVariables(firstentry,nentries);
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Destructor.
173
175{
176 delete [] fCurrentEntries;
177 if(fPolyList){
178 fPolyList->Delete();
179 delete fPolyList;
180 }
182 delete [] fAverageSlices;
183 if(fFormulas){
184 fFormulas->Delete();
185 delete fFormulas;
186 }
187 if(fSelect) delete fSelect;
188 if(fSelector) delete fSelector;
189 if(fInput){
190 fInput->Delete();
191 delete fInput;
192 }
193 if(fMax) delete [] fMax;
194 if(fMin) delete [] fMin;
195 if(fAve) delete [] fAve;
196 if(fSuperposed){
198 delete fSuperposed;
199 }
200 if (fCanvas) fCanvas->cd(0);
201}
202
203////////////////////////////////////////////////////////////////////////////////
204/// Allow to superpose several spider views.
205
207{
208 if(!fSuperposed) fSuperposed=new TList();
209 fSuperposed->Add(sp);
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Add a variable to the plot from its expression.
214
215void TSpider::AddVariable(const char* varexp)
216{
217 if(!varexp[0]) return;
218 TTreeFormula *fvar = new TTreeFormula("Var1",varexp,fTree);
219 if(fvar->GetNdim() <= 0) return;
220
222
223 InitArrays(fNcols + 1);
224 ++fNcols;
225 SyncFormulas();
226
227 UInt_t ui=0;
228 Long64_t notSkipped=0;
229 Int_t tnumber=-1;
230 Long64_t entryNumber;
231 Long64_t entry = fFirstEntry;
232 Int_t entriesToDisplay = fNentries;
233 while(entriesToDisplay!=0){
234 entryNumber = fTree->GetEntryNumber(entry);
235 if(entryNumber < 0) break;
236 Long64_t localEntry = fTree->LoadTree(entryNumber);
237 if(localEntry < 0) break;
238 if(tnumber != fTree->GetTreeNumber()) {
239 tnumber = fTree->GetTreeNumber();
241 else {
242 for(Int_t i=0;i<=fFormulas->LastIndex();++i)
243 ((TTreeFormula*)fFormulas->At(i))->UpdateFormulaLeaves();
244 }
245 }
246 Int_t ndata=1;
247 if(fForceDim){
248 if(fManager)
249 ndata = fManager->GetNdata(kTRUE);
250 else {
251 for(ui=0;ui<fNcols;++ui){
252 if(ndata<((TTreeFormula*)fFormulas->At(ui))->GetNdata())
253 ndata = ((TTreeFormula*)fFormulas->At(ui))->GetNdata();
254 }
255 if(fSelect && fSelect->GetNdata() == 0)
256 ndata = 0;
257 }
258 }
259
260 Bool_t loaded = kFALSE;
261 Bool_t skip = kFALSE;
262 // Loop over the instances of the selection condition
263 for(Int_t inst=0;inst<ndata;++inst){
264 if(fSelect){
265 if(fSelect->EvalInstance(inst) == 0){
266 skip = kTRUE;
267 ++entry;
268 }
269 }
270 if (!loaded) {
271 // EvalInstance(0) always needs to be called so that
272 // the proper branches are loaded.
273 ((TTreeFormula*)fFormulas->At(fNcols-1))->EvalInstance(0);
274 loaded = kTRUE;
275 } else if (inst == 0) {
276 loaded = kTRUE;
277 }
278 }
279 if(!skip){
280 fTree->LoadTree(entryNumber);
282 if(var->EvalInstance()>fMax[fNcols-1]) fMax[fNcols-1]=var->EvalInstance();
283 if(var->EvalInstance()<fMin[fNcols-1]) fMin[fNcols-1]=var->EvalInstance();
284 fAve[fNcols-1]+=var->EvalInstance();
285 ++notSkipped;
286 --entriesToDisplay;
287 ++entry;
288 }
289 }
290 if (notSkipped) fAve[fNcols-1]/=notSkipped;
291
292 Color_t lc;
293 Style_t lt;
294 Width_t lw;
295 Color_t fc;
296 Style_t fs;
297
298 if(fAverageSlices){
299 lc = fAverageSlices[0]->GetLineColor();
300 lt = fAverageSlices[0]->GetLineStyle();
301 lw = fAverageSlices[0]->GetLineWidth();
303 fs = fAverageSlices[0]->GetFillStyle();
304 } else {
310 }
311
312 delete fPolargram;
313 fPolargram = NULL;
314
315 if(fSegmentDisplay){
316 for(ui=0;ui<fNx*fNy;++ui) ((TList*)fPolyList->At(ui))->Delete();
317 if (fAverageSlices) for(ui=0;ui<fNcols-1;++ui) delete fAverageSlices[ui];
318 }
319 fPolyList->Delete();
320 delete fPolyList;
321 fPolyList = NULL;
322 delete [] fAverageSlices;
323 fAverageSlices = NULL;
324 delete fAveragePoly;
325 fAveragePoly = NULL;
326
327 if (fCanvas) {
328 fCanvas->Clear();
330 }
331 Draw("");
332
333 if(fAverageSlices){
334 for(ui = 0;ui<fNcols;++ui){
340 }
341 } else {
347 }
348}
349
350////////////////////////////////////////////////////////////////////////////////
351/// Delete a variable from its expression.
352
353void TSpider::DeleteVariable(const char* varexp)
354{
355 Int_t var=-1;
356 UInt_t ui=0;
357
358 if(fNcols == 2) return;
359 for(ui=0; ui<fNcols;++ui){
360 if(!strcmp(varexp,((TTreeFormula*)fFormulas->At(ui))->GetTitle())) var = ui;
361 }
362 if(var<0) return;
363
365 SyncFormulas();
366
367 for(ui=var+1;ui<fNcols;++ui){
368 fMin[ui-1] = fMin[ui];
369 fMax[ui-1] = fMax[ui];
370 fAve[ui-1] = fAve[ui];
371 }
372 fMin[fNcols-1] = DBL_MAX;
373 fMax[fNcols-1] = -DBL_MAX;
374 fAve[fNcols-1] = 0;
375 --fNcols;
376
377 Color_t lc;
378 Style_t lt;
379 Width_t lw;
380 Color_t fc;
381 Style_t fs;
382
383 if(fAverageSlices){
384 lc = fAverageSlices[0]->GetLineColor();
385 lt = fAverageSlices[0]->GetLineStyle();
386 lw = fAverageSlices[0]->GetLineWidth();
388 fs = fAverageSlices[0]->GetFillStyle();
389 } else {
395 }
396
397 delete fPolargram;
398 fPolargram = NULL;
399
400 if(fSegmentDisplay){
401 for(ui=0;ui<fNx*fNy;++ui) ((TList*)fPolyList->At(ui))->Delete();
402 if (fAverageSlices) for(ui=0;ui<=fNcols;++ui) delete fAverageSlices[ui];
403 }
404 fPolyList->Delete();
405 delete fPolyList;
406 fPolyList = NULL;
407 delete [] fAverageSlices;
408 fAverageSlices = NULL;
409 delete fAveragePoly;
410 fAveragePoly = NULL;
411
412 if (fCanvas) {
413 fCanvas->Clear();
415 }
416 Draw("");
418
419 if(fAverageSlices){
420 for(ui = 0;ui<fNcols;++ui){
426 }
427 } else {
433 }
434}
435
436////////////////////////////////////////////////////////////////////////////////
437/// Compute the distance to the spider.
438
440{
441 if(!gPad) return 9999;
442 Double_t xx,yy,r2;
443 xx=gPad->AbsPixeltoX(px);
444 yy=gPad->AbsPixeltoY(py);
445 r2 = xx*xx + yy*yy;
446 if(r2>1 && r2<1.5)
447 return 0;
448 else return 9999;
449}
450
451////////////////////////////////////////////////////////////////////////////////
452/// Draw the spider.
453
455{
456 UInt_t ui=0;
457
458 gEnv->SetValue("Canvas.ShowEditor",1);
459 if(!gPad && !fCanvas){
460 fCanvas = new TCanvas("screen","Spider Plot",fNx*256,fNy*256);
462 } else if(!fCanvas){
463 fCanvas = (TCanvas*)gPad;
465 }
466 if(fPolargram) delete fPolargram;
467 fPolargram=new TGraphPolargram("fPolargram");
470 if (fCanvas) fCanvas->cd();
472 AppendPad(options);
473 for(ui=0;ui<fNx*fNy;++ui){
474 if (fCanvas) fCanvas->cd(ui+1);
475 fPolargram->Draw("pn");
477 if(fSegmentDisplay){
479 DrawSlices("");
480 } else {
482 DrawPoly("");
483 }
484 AppendPad();
485 }
486 if (fCanvas) fCanvas->Selected(fCanvas,this,1);
487}
488
489////////////////////////////////////////////////////////////////////////////////
490/// Paint the Polygon representing the average value of the variables.
491
493{
494 Int_t linecolor=4;
495 Int_t fillstyle=0;
496 Int_t fillcolor=linecolor;
497 Int_t linewidth=1;
498 Int_t linestyle=1;
499
500 UInt_t ui=0;
501 Double_t slice = 2*TMath::Pi()/fNcols;
502 Double_t *x = new Double_t[fNcols+1];
503 Double_t *y = new Double_t[fNcols+1];
504
505 for(ui=0;ui<fNcols;++ui){
506 x[ui]=(fAve[ui]-fMin[ui])/(fMax[ui]-fMin[ui])*TMath::Cos(ui*slice);
507 y[ui]=(fAve[ui]-fMin[ui])/(fMax[ui]-fMin[ui])*TMath::Sin(ui*slice);
508 }
509 x[fNcols]=(fAve[0]-fMin[0])/(fMax[0]-fMin[0]);
510 y[fNcols]=0;
511
512 if(!fAveragePoly){
514 fAveragePoly->SetLineColor(linecolor);
515 fAveragePoly->SetLineWidth(linewidth);
516 fAveragePoly->SetLineStyle(linestyle);
517 fAveragePoly->SetFillStyle(fillstyle);
518 fAveragePoly->SetFillColor(fillcolor);
519 }
521 fAveragePoly->Draw("f");
522
523 delete [] x;
524 delete [] y;
525}
526
527////////////////////////////////////////////////////////////////////////////////
528/// Paint the polygon representing the current entry.
529
530void TSpider::DrawPoly(Option_t* /*options*/)
531{
532 if(!fPolyList) fPolyList = new TList();
533 Double_t *x = new Double_t[fNcols+1];
534 Double_t *y = new Double_t[fNcols+1];
535
536 Double_t slice = 2*TMath::Pi()/fNcols;
537 for(UInt_t i=0;i<fNcols;++i){
538 x[i]=(((TTreeFormula*)fFormulas->At(i))->EvalInstance()-fMin[i])/(fMax[i]-fMin[i])*TMath::Cos(i*slice);
539 y[i]=(((TTreeFormula*)fFormulas->At(i))->EvalInstance()-fMin[i])/(fMax[i]-fMin[i])*TMath::Sin(i*slice);
540 }
541 x[fNcols]=(((TTreeFormula*)fFormulas->At(0))->EvalInstance()-fMin[0])/(fMax[0]-fMin[0]);
542 y[fNcols]=0;
543
544 TPolyLine* poly= new TPolyLine(fNcols+1,x,y);
545 poly->SetFillColor(GetFillColor());
546 poly->SetFillStyle(GetFillStyle());
547 poly->SetLineWidth(GetLineWidth());
548 poly->SetLineColor(GetLineColor());
549 poly->SetLineStyle(GetLineStyle());
550 poly->Draw("f");
551 poly->Draw();
552 fPolyList->Add(poly);
553 delete [] x;
554 delete [] y;
555}
556
557////////////////////////////////////////////////////////////////////////////////
558/// Draw the slices of the segment plot.
559
561{
562 UInt_t ui=0;
563
564 Double_t angle = 2*TMath::Pi()/fNcols;
565 Double_t conv = 180.0/TMath::Pi();
566
567 if(!fPolyList) fPolyList = new TList;
568 TList* li = new TList();
569 for(ui=0;ui<fNcols;++ui){
570 Double_t r = (((TTreeFormula*)fFormulas->At(ui))->EvalInstance()-fMin[ui])/(fMax[ui]-fMin[ui]);
571 TArc* slice = new TArc(0,0,r,(ui-0.25)*angle*conv,(ui+0.25)*angle*conv);
572 slice->SetFillColor(GetFillColor());
573 slice->SetFillStyle(GetFillStyle());
574 slice->SetLineWidth(GetLineWidth());
575 slice->SetLineColor(GetLineColor());
576 slice->SetLineStyle(GetLineStyle());
577 li->Add(slice);
578 slice->Draw(options);
579 }
580 fPolyList->Add(li);
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Draw the slices representing the average for the segment plot.
585
587{
588 UInt_t ui=0;
589
590 Int_t fillstyle=3002;
591 Int_t linecolor=4;
592 Int_t fillcolor=linecolor;
593 Int_t linewidth=1;
594 Int_t linestyle=1;
595
596 Double_t angle = 2*TMath::Pi()/fNcols;
597 Double_t conv = 180.0/TMath::Pi();
598
599 if(!fAverageSlices){
600 fAverageSlices = new TArc*[fNcols];
601 for(ui=0;ui<fNcols;++ui){
602 Double_t r = (fAve[ui]-fMin[ui])/(fMax[ui]-fMin[ui]);
603 fAverageSlices[ui] = new TArc(0,0,r,(ui-0.5)*angle*conv,(ui+0.5)*angle*conv);
604 fAverageSlices[ui]->SetFillColor(fillcolor);
605 fAverageSlices[ui]->SetFillStyle(fillstyle);
606 fAverageSlices[ui]->SetLineWidth(linewidth);
607 fAverageSlices[ui]->SetLineColor(linecolor);
608 fAverageSlices[ui]->SetLineStyle(linestyle);
609 }
610 }
611 for(ui=0;ui<fNcols;++ui) fAverageSlices[ui]->Draw();
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// Get the LineStyle of the average.
616
618{
620 else if(fAveragePoly) return fAveragePoly->GetLineStyle();
621 else return 0;
622}
623
624////////////////////////////////////////////////////////////////////////////////
625/// Get the LineColor of the average.
626
628{
630 else if(fAveragePoly) return fAveragePoly->GetLineColor();
631 else return 0;
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Get the LineWidth of the average.
636
638{
640 else if(fAveragePoly) return fAveragePoly->GetLineWidth();
641 else return 0;
642}
643
644////////////////////////////////////////////////////////////////////////////////
645/// Get the Fill Color of the average.
646
648{
650 else if(fAveragePoly) return fAveragePoly->GetFillColor();
651 else return 0;
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// Get the FillStyle of the average.
656
658{
660 else if(fAveragePoly) return fAveragePoly->GetFillStyle();
661 else return 0;
662}
663
664////////////////////////////////////////////////////////////////////////////////
665/// Execute the corresponding event.
666
667void TSpider::ExecuteEvent(Int_t /*event*/,Int_t /*px*/, Int_t /*py*/)
668{
669 if (!gPad) return;
670 gPad->SetCursor(kHand);
671}
672
673////////////////////////////////////////////////////////////////////////////////
674/// Find the alignement rule to apply for TText::SetTextAlign(Short_t).
675
677{
678 Double_t pi = TMath::Pi();
679
680 while(angle < 0 || angle > 2*pi){
681 if(angle < 0) angle+=2*pi;
682 if(angle > 2*pi) angle-=2*pi;
683 }
684 if(!fAngularLabels){
685 if(angle > 0 && angle < pi/2) return 11;
686 else if(angle > pi/2 && angle < pi) return 31;
687 else if(angle > pi && angle < 3*pi/2) return 33;
688 else if(angle > 3*pi/2 && angle < 2*pi) return 13;
689 else if(angle == 0 || angle == 2*pi) return 12;
690 else if(angle == pi/2) return 21;
691 else if(angle == pi) return 32;
692 else if(angle == 3*pi/2) return 23;
693 else return 0;
694 }
695 else{
696 if(angle >= 0 && angle < pi) return 21;
697 else if(angle >=pi && angle <= 2*pi) return 23;
698 else return 0;
699 }
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// Determine the orientation of the polar labels according to their angle.
704
706{
707 Double_t pi = TMath::Pi();
708 Double_t convraddeg = 180.0/pi;
709
710 while(angle < 0 || angle > 2*pi){
711 if(angle < 0) angle+=2*pi;
712 if(angle > 2*pi) angle-=2*pi;
713 }
714
715 if(angle >= 0 && angle <= pi/2) return angle*convraddeg - 90;
716 else if(angle > pi/2 && angle <= pi) return (angle + pi)*convraddeg + 90;
717 else if(angle > pi && angle <= 3*pi/2) return (angle - pi)*convraddeg - 90;
718 else if(angle > 3*pi/2 && angle <= 2*pi) return angle*convraddeg + 90;
719 else return 0;
720}
721
722////////////////////////////////////////////////////////////////////////////////
723/// return the number of entries to be processed
724/// this function checks that nentries is not bigger than the number
725/// of entries in the Tree or in the associated TEventlist
726
728{
729 Long64_t lastentry = firstentry + nentries - 1;
730 if (lastentry > fTree->GetEntriesFriend()-1) {
731 lastentry = fTree->GetEntriesFriend() - 1;
732 nentries = lastentry - firstentry + 1;
733 }
734 //TEventList *elist = fTree->GetEventList();
735 //if (elist && elist->GetN() < nentries) nentries = elist->GetN();
736 TEntryList *elist = fTree->GetEntryList();
737 if (elist && elist->GetN() < nentries) nentries = elist->GetN();
738 return nentries;
739}
740
741////////////////////////////////////////////////////////////////////////////////
742/// Go to a specified entry.
743
745{
746 if(e<fFirstEntry || e+fTree->GetScanField()>=fFirstEntry + fNentries) return;
747 fEntry = e;
749}
750
751////////////////////////////////////////////////////////////////////////////////
752/// Go to the next entries.
753
755{
759}
760
761////////////////////////////////////////////////////////////////////////////////
762/// Go to the previous entries.
763
765{
767 else fEntry -= fTree->GetScanField();
769}
770
771////////////////////////////////////////////////////////////////////////////////
772/// Go to the next entry.
773
775{
776 if(fEntry + fTree->GetScanField() >= fFirstEntry + fNentries) return;
777 ++fEntry;
779}
780
781////////////////////////////////////////////////////////////////////////////////
782/// Go to the last entry.
783
785{
786 if(fEntry - 1 < fFirstEntry) return;
787 --fEntry;
789}
790
791////////////////////////////////////////////////////////////////////////////////
792/// Check if the arrays size is enough and reallocate them if not.
793
795{
796 if(newsize>fArraySize){
797
798 Int_t i;
799 Int_t old = fArraySize;
800
801 while(fArraySize<newsize) fArraySize*=2;
802
803 Double_t *memmax = new Double_t[fArraySize];
804 Double_t *memmin = new Double_t[fArraySize];
805 Double_t *memave = new Double_t[fArraySize];
806
807 for(i=0;i<fArraySize;++i){
808 if(i<old){
809 memmax[i] = fMax[i];
810 memmin[i] = fMin[i];
811 memave[i] = fAve[i];
812 } else {
813 memmax[i] = -DBL_MAX;
814 memmin[i] = DBL_MAX;
815 memave[i] = 0;
816 }
817 }
818
819 delete [] fMax;
820 delete [] fMin;
821 delete [] fAve;
822
823 fMax = memmax;
824 fMin = memmin;
825 fAve = memave;
826 }
827}
828
829////////////////////////////////////////////////////////////////////////////////
830/// Browse the tree to set the min, max and average value of each variable of fVar.
831
833{
834 UInt_t ui=0;
835 Int_t i;
836
837 fMax = new Double_t [fArraySize];
838 fMin= new Double_t [fArraySize];
839 fAve= new Double_t [fArraySize];
840
841 for(i=0;i<fArraySize;++i){
842 fMax[i]= -DBL_MAX;
843 fMin[i]= DBL_MAX;
844 fAve[i]=0;
845 }
846
847 Long64_t notSkipped=0;
848 Int_t tnumber=-1;
849 Long64_t entryNumber;
850 Long64_t entry = firstentry;
851 Int_t entriesToDisplay = nentries;
852 while(entriesToDisplay!=0){
853 entryNumber = fTree->GetEntryNumber(entry);
854 if(entryNumber < 0) break;
855 Long64_t localEntry = fTree->LoadTree(entryNumber);
856 if(localEntry < 0) break;
857 if(tnumber != fTree->GetTreeNumber()) {
858 tnumber = fTree->GetTreeNumber();
860 else {
861 for(i=0;i<=fFormulas->LastIndex();++i)
862 ((TTreeFormula*)fFormulas->At(i))->UpdateFormulaLeaves();
863 }
864 }
865 Int_t ndata=1;
866 if(fForceDim){
867 if(fManager)
868 ndata = fManager->GetNdata(kTRUE);
869 else {
870 for(ui=0;ui<fNcols;++ui){
871 if(ndata<((TTreeFormula*)fFormulas->At(ui))->GetNdata())
872 ndata = ((TTreeFormula*)fFormulas->At(ui))->GetNdata();
873 }
874 if(fSelect && fSelect->GetNdata() == 0)
875 ndata = 0;
876 }
877 }
878 Bool_t loaded = kFALSE;
879 Bool_t skip = kFALSE;
880 // Loop over the instances of the selection condition
881 for(Int_t inst=0;inst<ndata;++inst){
882 if(fSelect){
883 if(fSelect->EvalInstance(inst) == 0){
884 skip = kTRUE;
885 ++entry;
886 }
887 }
888 if (!loaded) {
889 // EvalInstance(0) always needs to be called so that
890 // the proper branches are loaded.
891 for (ui=0;ui<fNcols;ui++) {
892 ((TTreeFormula*)fFormulas->At(ui))->EvalInstance(0);
893 }
894 loaded = kTRUE;
895 } else if (inst == 0) {
896 loaded = kTRUE;
897 }
898 }
899 if(!skip){
900 fTree->LoadTree(entryNumber);
901 for(ui=0;ui<fNcols;++ui){
902 Double_t inst = ((TTreeFormula*)fFormulas->At(ui))->EvalInstance();
903 if(inst > fMax[ui]) fMax[ui] = inst;
904 if(inst < fMin[ui]) fMin[ui] = inst;
905 fAve[ui] += inst;
906 }
907 ++notSkipped;
908 --entriesToDisplay;
909 ++entry;
910 }
911 }
912 if (notSkipped) {for(ui=0;ui<fNcols;++ui) fAve[ui]/=notSkipped;}
913}
914
915////////////////////////////////////////////////////////////////////////////////
916/// Paint the spider.
917
919{
920 UInt_t ui=0;
921 TString opt = options;
922
923 if(opt.Contains("n")) return;
924
925 Double_t slice = 2*TMath::Pi()/fNcols;
926 Double_t offset(1.0);
927 if (!fCanvas) {
928 if (gPad) fCanvas = gPad->GetCanvas();
929 else return;
930 }
931
932 TLatex *txt = new TLatex();
933 for(ui=0;ui<fNx*fNy;++ui){
934 txt->SetTextAlign(13);
935 if (fCanvas) fCanvas->cd(ui+1);
936 if (fCurrentEntries) {
937 txt->PaintLatex(-1.2,1.2,0,0.08,Form("#%d",(int)fCurrentEntries[ui]));
938 }
939 txt->SetTextSize(0.035);
940 for(UInt_t var=0;var<fNcols;++var){ // Print labels.
941 if(ui==0){
942 txt->SetTextAlign(FindTextAlign(var*slice));
943 offset = 1.09 + txt->GetTextSize();
944 txt->PaintLatex(offset*TMath::Cos(var*slice),offset*TMath::Sin(var*slice),
945 FindTextAngle(var*slice),0.035,fFormulas->At(var)->GetTitle());
946 offset= 1.03;
947 txt->PaintLatex(offset*TMath::Cos(var*slice),offset*TMath::Sin(var*slice),
948 FindTextAngle(var*slice),0.035,Form("[%5.3f,%5.3f]",fMin[var],fMax[var]));
949 }
950 else {
951 txt->SetTextAlign(FindTextAlign(var*slice));
952 if(var*slice >=0 && var*slice <= TMath::Pi()) offset =1.13 + txt->GetTextSize();
953 else offset = 1.09 + txt->GetTextSize();
954 txt->PaintLatex(offset*TMath::Cos(var*slice),offset*TMath::Sin(var*slice),
955 FindTextAngle(var*slice),0.035,fFormulas->At(var)->GetTitle());
956 }
957 }
958 }
959 delete txt;
960}
961
962////////////////////////////////////////////////////////////////////////////////
963/// Set the LineStyle of the average.
964
966{
967 UInt_t ui=0;
968
969 if(fAverageSlices){
970 for(ui=0;ui<fNcols;++ui) fAverageSlices[ui]->SetLineStyle(sty);
971 } else if(fAveragePoly) fAveragePoly->SetLineStyle(sty);
972}
973
974////////////////////////////////////////////////////////////////////////////////
975/// Set the LineColor of the average.
976
978{
979 UInt_t ui=0;
980
981 if(fAverageSlices){
982 for(ui=0;ui<fNcols;++ui) fAverageSlices[ui]->SetLineColor(col);
983 } else if(fAveragePoly) fAveragePoly->SetLineColor(col);
984}
985
986////////////////////////////////////////////////////////////////////////////////
987/// Set the LineWidth of the average.
988
990{
991 UInt_t ui=0;
992
993 if(fAverageSlices){
994 for(ui=0;ui<fNcols;++ui) fAverageSlices[ui]->SetLineWidth(wid);
995 } else if(fAveragePoly) fAveragePoly->SetLineWidth(wid);
996}
997
998////////////////////////////////////////////////////////////////////////////////
999/// Set the Fill Color of the average.
1000
1002{
1003 UInt_t ui=0;
1004
1005 if(fAverageSlices){
1006 for(ui=0;ui<fNcols;++ui) fAverageSlices[ui]->SetFillColor(col);
1007 } else if(fAveragePoly) fAveragePoly->SetFillColor(col);
1008}
1009
1010////////////////////////////////////////////////////////////////////////////////
1011/// Set the FillStyle of the average.
1012
1014{
1015 UInt_t ui=0;
1016
1017 if(fAverageSlices){
1018 for(ui=0;ui<fNcols;++ui) fAverageSlices[ui]->SetFillStyle(sty);
1019 } else if(fAveragePoly) fAveragePoly->SetFillStyle(sty);
1020}
1021
1022////////////////////////////////////////////////////////////////////////////////
1023/// Display or not the average.
1024
1026{
1027 if(disp == fDisplayAverage) return;
1028
1029 UInt_t ui=0;
1030
1031 fDisplayAverage = disp;
1032 delete fAveragePoly;
1033 fAveragePoly = NULL;
1034 if(fAverageSlices){
1035 for(ui = 0;ui<fNcols;++ui) delete fAverageSlices[ui];
1036 }
1037 delete [] fAverageSlices;
1038 fAverageSlices = NULL;
1039
1040 for(ui=0;ui<fNx*fNy;++ui){
1041 if (fCanvas) fCanvas->cd(ui+1);
1042 gPad->Clear();
1043 }
1044
1045 for(ui = 0; ui < fNx*fNy; ++ui){
1046 if (fCanvas) fCanvas->cd(ui+1);
1047 fPolargram->Draw("pn");
1049 if(fSegmentDisplay){
1050 if(disp) DrawSlicesAverage("");
1051 DrawSlices("");
1052 } else {
1053 if(disp) DrawPolyAverage("");
1054 DrawPoly("");
1055 }
1056 AppendPad();
1057 }
1058 if (fCanvas) {
1059 fCanvas->Modified();
1060 fCanvas->Update();
1061 }
1062}
1063
1064////////////////////////////////////////////////////////////////////////////////
1065/// Set the current selected entries.
1066
1068{
1069 Int_t i;
1070 UInt_t ui=0;
1071 Int_t tnumber=-1;
1072 Long64_t entryNumber;
1073 Long64_t entry = fEntry;
1074 Int_t entriesToDisplay = fTree->GetScanField();
1075
1077
1078 while(entriesToDisplay!=0){
1079 entryNumber = fTree->GetEntryNumber(entry);
1080 if(entryNumber < 0) break;
1081 Long64_t localEntry = fTree->LoadTree(entryNumber);
1082 if(localEntry < 0) break;
1083 if(tnumber != fTree->GetTreeNumber()) {
1084 tnumber = fTree->GetTreeNumber();
1086 else {
1087 for(i=0;i<=fFormulas->LastIndex();++i)
1088 ((TTreeFormula*)fFormulas->At(i))->UpdateFormulaLeaves();
1089 }
1090 }
1091 Int_t ndata=1;
1092 if(fForceDim){
1093 if(fManager)
1094 ndata = fManager->GetNdata(kTRUE);
1095 else {
1096 for(ui=0;ui<fNcols;++ui){
1097 if(ndata < ((TTreeFormula*)fFormulas->At(ui))->GetNdata())
1098 ndata = ((TTreeFormula*)fFormulas->At(ui))->GetNdata();
1099 }
1100 if(fSelect && fSelect->GetNdata() == 0)
1101 ndata = 0;
1102 }
1103 }
1104 Bool_t loaded = kFALSE;
1105 Bool_t skip = kFALSE;
1106 // Loop over the instances of the selection condition
1107 for(Int_t inst=0;inst<ndata;++inst){
1108 if(fSelect){
1109 if(fSelect->EvalInstance(inst) == 0){
1110 skip = kTRUE;
1111 ++entry;
1112 }
1113 }
1114 if (!loaded) {
1115 // EvalInstance(0) always needs to be called so that
1116 // the proper branches are loaded.
1117 for (ui=0;ui<fNcols;ui++) {
1118 ((TTreeFormula*)fFormulas->At(ui))->EvalInstance(0);
1119 }
1120 loaded = kTRUE;
1121 } else if (inst == 0) {
1122 loaded = kTRUE;
1123 }
1124 }
1125 if(!skip){
1126 fCurrentEntries[fTree->GetScanField()-entriesToDisplay] = entryNumber;
1127 --entriesToDisplay;
1128 ++entry;
1129 }
1130 }
1131 if(fPolyList) UpdateView();
1132}
1133
1134////////////////////////////////////////////////////////////////////////////////
1135/// Set line style.
1136
1138{
1139 UInt_t ui=0;
1140
1142 for(ui=0; ui<fNx*fNy;++ui){
1143 if(fSegmentDisplay){
1144 TList *li = (TList*)fPolyList->At(ui);
1145 for(UInt_t var=0;var<fNcols;++var) ((TArc*)li->At(var))->SetLineStyle(sty);
1146 } else ((TPolyLine*)fPolyList->At(ui))->SetLineStyle(sty);
1147 }
1148}
1149
1150////////////////////////////////////////////////////////////////////////////////
1151/// Set lin color.
1152
1154{
1155 UInt_t ui=0;
1156
1158 for(ui=0; ui<fNx*fNy;++ui){
1159 if(fSegmentDisplay){
1160 TList *li = (TList*)fPolyList->At(ui);
1161 for(UInt_t var=0;var<fNcols;++var) ((TArc*)li->At(var))->SetLineColor(col);
1162 } else ((TPolyLine*)fPolyList->At(ui))->SetLineColor(col);
1163 }
1164}
1165
1166////////////////////////////////////////////////////////////////////////////////
1167///Set line width.
1168
1170{
1171 UInt_t ui=0;
1172
1174 for(ui=0; ui<fNx*fNy;++ui){
1175 if(fSegmentDisplay){
1176 TList *li = (TList*)fPolyList->At(ui);
1177 for(UInt_t var=0;var<fNcols;++var) ((TArc*)li->At(var))->SetLineWidth(wid);
1178 } else ((TPolyLine*)fPolyList->At(ui))->SetLineWidth(wid);
1179 }
1180}
1181
1182////////////////////////////////////////////////////////////////////////////////
1183/// Set fill color.
1184
1186{
1187 UInt_t ui=0;
1188
1190 for(ui=0; ui<fNx*fNy;++ui){
1191 if(fSegmentDisplay){
1192 TList *li = (TList*)fPolyList->At(ui);
1193 for(UInt_t var=0;var<fNcols;++var) ((TArc*)li->At(var))->SetFillColor(col);
1194 } else ((TPolyLine*)fPolyList->At(ui))->SetFillColor(col);
1195 }
1196}
1197
1198////////////////////////////////////////////////////////////////////////////////
1199/// Set fill style.
1200
1202{
1203 UInt_t ui=0;
1204
1206 for(ui=0; ui<fNx*fNy;++ui){
1207 if(fSegmentDisplay){
1208 TList *li = (TList*)fPolyList->At(ui);
1209 for(UInt_t var=0;var<fNcols;++var) ((TArc*)li->At(var))->SetFillStyle(sty);
1210 } else ((TPolyLine*)fPolyList->At(ui))->SetFillStyle(sty);
1211 }
1212}
1213
1214////////////////////////////////////////////////////////////////////////////////
1215/// Set number of radial divisions.
1216
1218{
1219 if(fPolargram->GetNdivRadial() == ndiv) return;
1221}
1222
1223////////////////////////////////////////////////////////////////////////////////
1224/// Set the X number of sub pads.
1225
1227{
1228 if(fNx == nx || nx <= 0) return;
1230
1231 UInt_t ui=0;
1232 Color_t lc;
1233 Style_t lt;
1234 Width_t lw;
1235 Color_t fc;
1236 Style_t fs;
1237 if(fAverageSlices){
1238 lc = fAverageSlices[0]->GetLineColor();
1239 lt = fAverageSlices[0]->GetLineStyle();
1240 lw = fAverageSlices[0]->GetLineWidth();
1242 fs = fAverageSlices[0]->GetFillStyle();
1243 } else {
1244 lc = fAveragePoly->GetLineColor();
1245 lt = fAveragePoly->GetLineStyle();
1246 lw = fAveragePoly->GetLineWidth();
1248 fs = fAveragePoly->GetFillStyle();
1249 }
1250
1251 if(fSegmentDisplay){
1252 for(ui=0; ui<fNx*fNy;++ui) ((TList*)fPolyList->At(ui))->Delete();
1253 }
1254 fPolyList->Delete();
1255 delete fPolyList;
1256 fPolyList = NULL;
1257 delete [] fCurrentEntries;
1258 fCurrentEntries = NULL;
1259
1260 fNx = nx;
1261
1264 if (fCanvas) {
1265 fCanvas->Clear();
1267 }
1268
1269 for(ui=0; ui < fNx*fNy;++ui){
1270 if (fCanvas) fCanvas->cd(ui+1);
1271 fPolargram->Draw("pn");
1273 if(fSegmentDisplay){
1275 DrawSlices("");
1276 } else {
1278 DrawPoly("");
1279 }
1280 AppendPad();
1281 }
1282
1283 if(fAverageSlices){
1284 for(ui = 0;ui<fNcols;++ui){
1290 }
1291 } else {
1297 }
1298}
1299
1300////////////////////////////////////////////////////////////////////////////////
1301/// Set the Y number of sub pads.
1302
1304{
1305 if(fNy == ny || ny <= 0) return;
1307
1308 UInt_t ui=0;
1309 Color_t lc;
1310 Style_t lt;
1311 Width_t lw;
1312 Color_t fc;
1313 Style_t fs;
1314 if(fAverageSlices){
1315 lc = fAverageSlices[0]->GetLineColor();
1316 lt = fAverageSlices[0]->GetLineStyle();
1317 lw = fAverageSlices[0]->GetLineWidth();
1319 fs = fAverageSlices[0]->GetFillStyle();
1320 } else {
1321 lc = fAveragePoly->GetLineColor();
1322 lt = fAveragePoly->GetLineStyle();
1323 lw = fAveragePoly->GetLineWidth();
1325 fs = fAveragePoly->GetFillStyle();
1326 }
1327
1328 if(fSegmentDisplay){
1329 for(ui=0; ui<fNx*fNy;++ui) ((TList*)fPolyList->At(ui))->Delete();
1330 }
1331 fPolyList->Delete();
1332 delete fPolyList;
1333 fPolyList = NULL;
1334 delete [] fCurrentEntries;
1335 fCurrentEntries = NULL;
1336
1337 fNy = ny;
1338
1341 if (fCanvas) {
1342 fCanvas->Clear();
1344 }
1345
1346 for(ui=0; ui < fNx*fNy;++ui){
1347 if (fCanvas) fCanvas->cd(ui+1);
1348 fPolargram->Draw("pn");
1350 if(fSegmentDisplay){
1352 DrawSlices("");
1353 } else {
1355 DrawPoly("");
1356 }
1357 AppendPad();
1358 }
1359
1360 if(fAverageSlices){
1361 for(ui = 0;ui<fNcols;++ui){
1367 }
1368 } else {
1374 }
1375}
1376
1377////////////////////////////////////////////////////////////////////////////////
1378/// Set the segment display or not.
1379
1381{
1382 if(seg == fSegmentDisplay) return;
1383
1384 UInt_t ui=0;
1385
1386 if(fSegmentDisplay){
1387 for(ui=0;ui<fNx*fNy;++ui){
1388 ((TList*)fPolyList->At(ui))->Delete();
1389 }
1390 }
1391 fPolyList->Delete();
1392
1393 Color_t lc = 1;
1394 Style_t lt = 1;
1395 Width_t lw = 1;
1396 Color_t fc = 1;
1397 Style_t fs = 0;
1398 if(fAverageSlices){
1399 lc = fAverageSlices[0]->GetLineColor();
1400 lt = fAverageSlices[0]->GetLineStyle();
1401 lw = fAverageSlices[0]->GetLineWidth();
1403 fs = fAverageSlices[0]->GetFillStyle();
1404 } else {
1405 if (fAveragePoly) {
1406 lc = fAveragePoly->GetLineColor();
1407 lt = fAveragePoly->GetLineStyle();
1408 lw = fAveragePoly->GetLineWidth();
1410 fs = fAveragePoly->GetFillStyle();
1411 }
1412 }
1413
1414 delete fPolyList;
1415 fPolyList = NULL;
1416 if(fAverageSlices){
1417 for(ui=0;ui<fNcols;++ui) delete fAverageSlices[ui];
1418 }
1419 delete [] fAverageSlices;
1420 fAverageSlices = NULL;
1421 delete fAveragePoly;
1422 fAveragePoly = NULL;
1423
1424 for(ui=0;ui<fNx*fNy;++ui){
1425 if (fCanvas) fCanvas->cd(ui+1);
1426 gPad->Clear();
1427 }
1428
1429 fSegmentDisplay = seg;
1430
1431 for(ui=0; ui < fNx*fNy;++ui){
1432 if (fCanvas) fCanvas->cd(ui+1);
1433 fPolargram->Draw("pn");
1435 if(fSegmentDisplay){
1437 DrawSlices("");
1438 } else {
1440 DrawPoly("");
1441 }
1442 AppendPad();
1443 }
1444
1445 if(fAverageSlices){
1446 for(ui=0;ui<fNcols;++ui){
1452 }
1453 } else {
1454 if (fAveragePoly) {
1460 }
1461 }
1462 if (fCanvas) {
1463 fCanvas->Modified();
1464 fCanvas->Update();
1465 }
1466}
1467
1468////////////////////////////////////////////////////////////////////////////////
1469/// Compile selection expression if there is one.
1470
1471void TSpider::SetSelectionExpression(const char* selection)
1472{
1473 if (selection && strlen(selection)) {
1474 fSelect = new TTreeFormula("Selection",selection,fTree);
1475 // if (!fSelect) return -1;
1476 // if (!fSelect->GetNdim()) { delete fSelect; return -1; }
1478 }
1479}
1480
1481////////////////////////////////////////////////////////////////////////////////
1482/// Compile the variables expression from the given string varexp.
1483
1484void TSpider::SetVariablesExpression(const char* varexp)
1485{
1486 Int_t nch;
1487 fNcols=8;
1488
1489 if (!varexp) return;
1490 TObjArray *leaves = fTree->GetListOfLeaves();
1491 UInt_t nleaves = leaves->GetEntriesFast();
1492 if (nleaves < fNcols) fNcols = nleaves;
1493 nch = strlen(varexp);
1494
1495 // if varexp is empty, take first 8 columns by default
1496 Int_t allvar = 0;
1497 std::vector<TString> cnames;
1498 if (!strcmp(varexp, "*")) { fNcols = nleaves; allvar = 1; }
1499 if (nch == 0 || allvar) {
1500 UInt_t ncs = fNcols;
1501 fNcols = 0;
1502 for (UInt_t ui=0;ui<ncs;++ui) {
1503 TLeaf *lf = (TLeaf*)leaves->At(ui);
1504 if (lf->GetBranch()->GetListOfBranches()->GetEntries() > 0) continue;
1505 cnames.push_back(lf->GetName());
1506 fNcols++;
1507 }
1508 // otherwise select only the specified columns
1509 } else {
1510 fNcols = fSelector->SplitNames(varexp,cnames);
1511 }
1512
1513 // Create the TreeFormula objects corresponding to each column
1514 for (UInt_t ui=0;ui<fNcols;ui++) {
1515 fFormulas->Add(new TTreeFormula("Var1",cnames[ui].Data(),fTree));
1516 }
1517}
1518
1519////////////////////////////////////////////////////////////////////////////////
1520/// Create a TreeFormulaManager to coordinate the formulas.
1521
1523{
1524 Int_t i;
1525 if (fFormulas->LastIndex()>=0) {
1526 if (fSelect) {
1527 if (fSelect->GetManager()->GetMultiplicity() > 0 ) {
1529 for(i=0;i<=fFormulas->LastIndex();i++) {
1531 }
1532 fManager->Sync();
1533 }
1534 }
1535 for(i=0;i<=fFormulas->LastIndex();i++) {
1536 TTreeFormula *form = ((TTreeFormula*)fFormulas->At(i));
1537 switch( form->GetManager()->GetMultiplicity() ) {
1538 case 1:
1539 case 2:
1540 case -1:
1541 fForceDim = kTRUE;
1542 break;
1543 case 0:
1544 break;
1545 }
1546
1547 }
1548 }
1549}
1550
1551////////////////////////////////////////////////////////////////////////////////
1552/// Update the polylines or the arcs for the current entries.
1553
1555{
1556 Double_t slice = 2*TMath::Pi()/fNcols;
1557
1558 Double_t x,y,r;
1559
1560 for(UInt_t pad=1;pad <= fNx*fNy;++pad){
1562 for(UInt_t i=0;i<fNcols;++i){
1563 r = (((TTreeFormula*)fFormulas->At(i))->EvalInstance()-fMin[i])/(fMax[i]-fMin[i]);
1564 x=r*TMath::Cos(i*slice);
1565 y=r*TMath::Sin(i*slice);
1566 if(!fSegmentDisplay) ((TPolyLine*)fPolyList->At(pad-1))->SetPoint(i,x,y);
1567 else {
1568 ((TArc*)((TList*)fPolyList->At(pad-1))->At(i))->SetR1(r);
1569 ((TArc*)((TList*)fPolyList->At(pad-1))->At(i))->SetR2(r);
1570 }
1571 }
1572 x=(((TTreeFormula*)fFormulas->At(0))->EvalInstance()-fMin[0])/(fMax[0]-fMin[0]);
1573 y=0;
1574 if(!fSegmentDisplay) ((TPolyLine*)fPolyList->At(pad-1))->SetPoint(fNcols,x,y);
1575 }
1576}
@ kHand
Definition GuiTypes.h:374
ROOT::R::TRInterface & r
Definition Object.C:4
#define e(i)
Definition RSha256.hxx:103
const Bool_t kFALSE
Definition RtypesCore.h:101
short Width_t
Definition RtypesCore.h:91
double Double_t
Definition RtypesCore.h:59
short Color_t
Definition RtypesCore.h:92
long long Long64_t
Definition RtypesCore.h:80
short Style_t
Definition RtypesCore.h:89
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
int nentries
#define gROOT
Definition TROOT.h:404
char * Form(const char *fmt,...)
#define gPad
static struct mg_connection * fc(struct mg_context *ctx)
Definition civetweb.c:3728
virtual Int_t GetNdim() const
Definition TFormula.h:237
Create an Arc.
Definition TArc.h:26
Fill Area Attributes class.
Definition TAttFill.h:19
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:30
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:31
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
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
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:34
virtual Float_t GetTextSize() const
Return the text size.
Definition TAttText.h:36
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:42
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:47
TObjArray * GetListOfBranches()
Definition TBranch.h:242
The Canvas class.
Definition TCanvas.h:23
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:725
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:706
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition TCanvas.cxx:1639
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2502
virtual void Draw(Option_t *option="")
Draw this ellipse with its current attributes.
Definition TEllipse.cxx:168
A List of entry numbers in a TTree or TChain.
Definition TEntryList.h:26
virtual Long64_t GetN() const
Definition TEntryList.h:77
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
Definition TEnv.cxx:736
To draw polar axis.
void SetNdivPolar(Int_t Ndiv=508)
Set the number of Polar divisions: enter a number ij with 0<i<99 and 0<j<99.
void Draw(Option_t *options="")
Draw Polargram.
void SetNdivRadial(Int_t Ndiv=508)
Set the number of radial divisions: enter a number ij with 0<i<99 and 0<j<99.
To draw Mathematical Formula.
Definition TLatex.h:18
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
Definition TLatex.cxx:2066
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition TLeaf.h:57
TBranch * GetBranch() const
Definition TLeaf.h:116
A doubly linked list.
Definition TList.h:38
virtual void Add(TObject *obj)
Definition TList.h:81
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 AddAfter(const TObject *after, TObject *obj)
Insert object after object after in the list.
Definition TList.cxx:250
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:470
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
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
Int_t GetEntries() const
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const
Definition TObjArray.h:164
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:177
virtual void Delete(Option_t *option="")
Delete this object.
Definition TObject.cxx:241
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:473
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
Definition TPad.cxx:1178
void Modified(Bool_t flag=1) override
Definition TPad.h:413
TCanvas * GetCanvas() const override
Definition TPad.h:256
Defined by an array on N points in a 2-D space.
Definition TPolyLine.h:23
virtual void Draw(Option_t *option="")
Draw this polyline with its current attributes.
A specialized TSelector for TTree::Draw.
virtual UInt_t SplitNames(const TString &varexp, std::vector< TString > &names)
Build Index array for names in varexp.
virtual void SetInputList(TList *input)
Definition TSelector.h:66
Int_t LastIndex() const
Spider class.
Definition TSpider.h:40
void SetAverageLineStyle(Style_t sty)
Set the LineStyle of the average.
Definition TSpider.cxx:965
TPolyLine * fAveragePoly
Polygon representing the average variables value.
Definition TSpider.h:55
void SetAverageFillColor(Color_t col)
Set the Fill Color of the average.
Definition TSpider.cxx:1001
virtual void SetFillColor(Color_t col)
Set fill color.
Definition TSpider.cxx:1185
UInt_t fNy
Number of vertical spider plots.
Definition TSpider.h:43
~TSpider()
Destructor.
Definition TSpider.cxx:174
virtual void SetLineStyle(Style_t sty)
Set line style.
Definition TSpider.cxx:1137
Bool_t fShowRange
Show range of variables or not.
Definition TSpider.h:69
TList * fInput
Used for fSelector.
Definition TSpider.h:59
void SetNx(UInt_t nx)
Set the X number of sub pads.
Definition TSpider.cxx:1226
Double_t * fAve
[fNcols] Average value of each variable.
Definition TSpider.h:50
Style_t GetAverageLineStyle() const
Get the LineStyle of the average.
Definition TSpider.cxx:617
void GotoPrevious()
Go to the previous entries.
Definition TSpider.cxx:764
virtual void SetFillStyle(Style_t sty)
Set fill style.
Definition TSpider.cxx:1201
TList * fSuperposed
Superposed spider plots.
Definition TSpider.h:53
virtual void SetLineColor(Color_t col)
Set lin color.
Definition TSpider.cxx:1153
virtual void Paint(Option_t *options)
Paint the spider.
Definition TSpider.cxx:918
void DrawSlices(Option_t *options)
Draw the slices of the segment plot.
Definition TSpider.cxx:560
Long64_t fFirstEntry
First entry.
Definition TSpider.h:48
void UpdateView()
Update the polylines or the arcs for the current entries.
Definition TSpider.cxx:1554
TTree * fTree
Pointer to the TTree to represent.
Definition TSpider.h:54
void SetNdivRadial(Int_t div)
Set number of radial divisions.
Definition TSpider.cxx:1217
void SetCurrentEntries()
Set the current selected entries.
Definition TSpider.cxx:1067
void AddVariable(const char *varexp)
Add a variable to the plot from its expression.
Definition TSpider.cxx:215
UInt_t fNcols
Number of variables.
Definition TSpider.h:44
void DrawPoly(Option_t *options)
Paint the polygon representing the current entry.
Definition TSpider.cxx:530
void DrawSlicesAverage(Option_t *options)
Draw the slices representing the average for the segment plot.
Definition TSpider.cxx:586
void GotoEntry(Long64_t e)
Go to a specified entry.
Definition TSpider.cxx:744
TCanvas * fCanvas
! Pointer to the mother pad.
Definition TSpider.h:57
Int_t fArraySize
Actual size of the arrays.
Definition TSpider.h:45
void SetAverageLineColor(Color_t col)
Set the LineColor of the average.
Definition TSpider.cxx:977
TArc ** fAverageSlices
! Average slices.
Definition TSpider.h:56
void SetSelectionExpression(const char *selexp)
Compile selection expression if there is one.
Definition TSpider.cxx:1471
Long64_t fEntry
Present entry number in fTree.
Definition TSpider.h:46
void DeleteVariable(const char *varexp)
Delete a variable from its expression.
Definition TSpider.cxx:353
void SetAverageLineWidth(Width_t wid)
Set the LineWidth of the average.
Definition TSpider.cxx:989
TTreeFormulaManager * fManager
Coordinator for the formulas.
Definition TSpider.h:60
Width_t GetAverageLineWidth() const
Get the LineWidth of the average.
Definition TSpider.cxx:637
TList * fFormulas
List of all formulas to represent.
Definition TSpider.h:58
Color_t GetAverageLineColor() const
Get the LineColor of the average.
Definition TSpider.cxx:627
TTreeFormula * fSelect
Selection condition.
Definition TSpider.h:63
void InitVariables(Long64_t firstentry, Long64_t nentries)
Browse the tree to set the min, max and average value of each variable of fVar.
Definition TSpider.cxx:832
void SetDisplayAverage(Bool_t disp)
Display or not the average.
Definition TSpider.cxx:1025
Int_t FindTextAlign(Double_t theta)
Find the alignement rule to apply for TText::SetTextAlign(Short_t).
Definition TSpider.cxx:676
void SetVariablesExpression(const char *varexp)
Compile the variables expression from the given string varexp.
Definition TSpider.cxx:1484
void SetAverageFillStyle(Style_t sty)
Set the FillStyle of the average.
Definition TSpider.cxx:1013
TSelectorDraw * fSelector
! Selector.
Definition TSpider.h:64
TSpider()
Default constructor.
Definition TSpider.cxx:76
Double_t FindTextAngle(Double_t theta)
Determine the orientation of the polar labels according to their angle.
Definition TSpider.cxx:705
void SetSegmentDisplay(Bool_t seg)
Set the segment display or not.
Definition TSpider.cxx:1380
Color_t GetAverageFillColor() const
Get the Fill Color of the average.
Definition TSpider.cxx:647
void SyncFormulas()
Create a TreeFormulaManager to coordinate the formulas.
Definition TSpider.cxx:1522
void AddSuperposed(TSpider *sp)
Allow to superpose several spider views.
Definition TSpider.cxx:206
Double_t * fMax
[fNcols] Maximum value of the variables.
Definition TSpider.h:51
Double_t * fMin
[fNcols] Minimum value of the variables.
Definition TSpider.h:52
UInt_t fNx
Number of horizontal spider plots.
Definition TSpider.h:42
void SetNy(UInt_t ny)
Set the Y number of sub pads.
Definition TSpider.cxx:1303
Bool_t fSegmentDisplay
True if displaying a segment plot.
Definition TSpider.h:68
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute the distance to the spider.
Definition TSpider.cxx:439
Bool_t fAngularLabels
True if the labels are oriented according to their axis.
Definition TSpider.h:65
virtual void SetLineWidth(Width_t wid)
Set line width.
Definition TSpider.cxx:1169
Bool_t fForceDim
Force dimension.
Definition TSpider.h:67
void InitArrays(Int_t newsize)
Check if the arrays size is enough and reallocate them if not.
Definition TSpider.cxx:794
virtual void Draw(Option_t *options="")
Draw the spider.
Definition TSpider.cxx:454
Long64_t fNentries
Number of entries.
Definition TSpider.h:47
Style_t GetAverageFillStyle() const
Get the FillStyle of the average.
Definition TSpider.cxx:657
TGraphPolargram * fPolargram
Polar graph.
Definition TSpider.h:61
void GotoNext()
Go to the next entries.
Definition TSpider.cxx:754
void DrawPolyAverage(Option_t *options)
Paint the Polygon representing the average value of the variables.
Definition TSpider.cxx:492
Long64_t * fCurrentEntries
![fNx*fNy] current selected entries;
Definition TSpider.h:49
Bool_t fDisplayAverage
Display or not the average.
Definition TSpider.h:66
TList * fPolyList
Polygons representing the variables.
Definition TSpider.h:62
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute the corresponding event.
Definition TSpider.cxx:667
void GotoPreceding()
Go to the last entry.
Definition TSpider.cxx:784
Long64_t GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const
return the number of entries to be processed this function checks that nentries is not bigger than th...
Definition TSpider.cxx:727
void GotoFollowing()
Go to the next entry.
Definition TSpider.cxx:774
Basic string class.
Definition TString.h:136
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:624
Used to coordinate one or more TTreeFormula objects.
virtual void UpdateFormulaLeaves()
This function could be called TTreePlayer::UpdateFormulaLeaves, itself called by TChain::LoadTree whe...
virtual Int_t GetNdata(Bool_t forceLoadDim=kFALSE)
Return number of available instances in the formulas.
virtual Bool_t Sync()
Synchronize all the formulae.
virtual void Add(TTreeFormula *)
Add a new formula to the list of formulas managed The manager of the formula will be changed and the ...
virtual Int_t GetMultiplicity() const
Used to pass a selection expression to the Tree drawing routine.
TTreeFormulaManager * GetManager() const
T EvalInstance(Int_t i=0, const char *stringStack[]=0)
Evaluate this treeformula.
virtual Int_t GetNdata()
Return number of available instances in the formula.
A TTree represents a columnar dataset.
Definition TTree.h:79
virtual Int_t GetScanField() const
Definition TTree.h:508
virtual TObjArray * GetListOfLeaves()
Definition TTree.h:486
virtual TEntryList * GetEntryList()
Returns the entry list assigned to this tree.
Definition TTree.cxx:5838
virtual Long64_t GetEntryNumber(Long64_t entry) const
Return entry number corresponding to entry.
Definition TTree.cxx:5849
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition TTree.cxx:6457
virtual Long64_t GetEntriesFriend() const
Return pointer to the 1st Leaf named name in any Branch of this Tree or any branch in the list of fri...
Definition TTree.cxx:5496
virtual Int_t GetTreeNumber() const
Definition TTree.h:516
virtual void SetScanField(Int_t n=50)
Definition TTree.h:640
void Clear(Option_t *option="") override=0
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Double_t Cos(Double_t)
Definition TMath.h:593
constexpr Double_t Pi()
Definition TMath.h:37
Double_t Sin(Double_t)
Definition TMath.h:589
Definition tree.py:1
th1 Draw()