Logo ROOT   6.07/09
Reference Guide
TSelectorDraw.cxx
Go to the documentation of this file.
1 // @(#)root/treeplayer:$Id$
2 // Author: Rene Brun 08/01/2003
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 /** \class TSelectorDraw
13 A specialized TSelector for TTree::Draw.
14 */
15 
16 #include "TSelectorDraw.h"
17 #include "TROOT.h"
18 #include "TH2.h"
19 #include "TH3.h"
20 #include "TView.h"
21 #include "TGraph.h"
22 #include "TPolyMarker3D.h"
23 #include "TDirectory.h"
24 #include "TVirtualPad.h"
25 #include "TProfile.h"
26 #include "TProfile2D.h"
27 #include "TTreeFormulaManager.h"
28 #include "TEnv.h"
29 #include "TTree.h"
30 #include "TCut.h"
31 #include "TEntryList.h"
32 #include "TEventList.h"
33 #include "TEntryListArray.h"
34 #include "THLimitsFinder.h"
35 #include "TStyle.h"
36 #include "TClass.h"
37 #include "TColor.h"
38 
40 
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Default selector constructor.
45 
47 {
48  fTree = 0;
49  fW = 0;
50  fValSize = 4;
51  fVal = new Double_t*[fValSize];
52  fVmin = new Double_t[fValSize];
53  fVmax = new Double_t[fValSize];
54  fNbins = new Int_t[fValSize];
55  fVarMultiple = new Bool_t[fValSize];
56  fVar = new TTreeFormula*[fValSize];
57  for (Int_t i = 0; i < fValSize; ++i) {
58  fVal[i] = 0;
59  fVar[i] = 0;
60  }
61  fManager = 0;
62  fMultiplicity = 0;
63  fSelect = 0;
64  fSelectedRows = 0;
65  fDraw = 0;
66  fObject = 0;
67  fOldHistogram = 0;
68  fObjEval = kFALSE;
69  fSelectMultiple = kFALSE;
70  fCleanElist = kFALSE;
71  fTreeElist = 0;
72  fAction = 0;
73  fNfill = 0;
74  fDimension = 0;
75  fOldEstimate = 0;
76  fForceRead = 0;
77  fWeight = 1;
78  fCurrentSubEntry = -1;
79  fTreeElistArray = 0;
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Selector destructor.
84 
86 {
87  ClearFormula();
88  delete [] fVar;
89  if (fVal) {
90  for (Int_t i = 0; i < fValSize; ++i)
91  delete [] fVal[i];
92  delete [] fVal;
93  }
94  if (fVmin) delete [] fVmin;
95  if (fVmax) delete [] fVmax;
96  if (fNbins) delete [] fNbins;
97  if (fVarMultiple) delete [] fVarMultiple;
98  if (fW) delete [] fW;
99 }
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 /// Called every time a loop on the tree(s) starts.
103 
105 {
106  SetStatus(0);
107  ResetAbort();
109  fSelectedRows = 0;
110  fTree = tree;
111  fDimension = 0;
112  fAction = 0;
113 
114  TObject *obj = fInput->FindObject("varexp");
115  const char *varexp0 = obj ? obj->GetTitle() : "";
116  obj = fInput->FindObject("selection");
117  const char *selection = obj ? obj->GetTitle() : "";
118  const char *option = GetOption();
119 
120  TString opt, abrt;
121  char *hdefault = (char *)"htemp";
122  char *varexp = nullptr;
123  Int_t i, j, hkeep;
124  opt = option;
125  opt.ToLower();
126  fOldHistogram = 0;
127  TEntryList *enlist = 0;
128  TEventList *evlist = 0;
129  TString htitle;
130  Bool_t profile = kFALSE;
131  Bool_t optSame = kFALSE;
132  Bool_t optEnlist = kFALSE;
133  Bool_t optEnlistArray = kFALSE;
134  Bool_t optpara = kFALSE;
135  Bool_t optcandle = kFALSE;
136  Bool_t opt5d = kFALSE;
137  if (opt.Contains("same")) {
138  optSame = kTRUE;
139  opt.ReplaceAll("same", "");
140  }
141  if (opt.Contains("entrylist")) {
142  optEnlist = kTRUE;
143  if (opt.Contains("entrylistarray")) {
144  optEnlistArray = kTRUE;
145  opt.ReplaceAll("entrylistarray", "");
146  } else {
147  opt.ReplaceAll("entrylist", "");
148  }
149  }
150  if (opt.Contains("para")) {
151  optpara = kTRUE;
152  opt.ReplaceAll("para", "");
153  }
154  if (opt.Contains("candle")) {
155  optcandle = kTRUE;
156  opt.ReplaceAll("candle", "");
157  }
158  if (opt.Contains("gl5d")) {
159  opt5d = kTRUE;
160  opt.ReplaceAll("gl5d", "");
161  }
162  TCut realSelection(selection);
163  //input list - only TEntryList
164  TEntryList *inElist = fTree->GetEntryList();
165  evlist = fTree->GetEventList();
166  if (evlist && inElist) {
167  //this is needed because the input entry list was created
168  //by the fTree from the input TEventList and is owned by the fTree.
169  //Calling GetEntryList function changes ownership and here
170  //we want fTree to still delete this entry list
171 
172  inElist->SetBit(kCanDelete, kTRUE);
173  }
175  fTreeElist = inElist;
176 
177  fTreeElistArray = inElist ? dynamic_cast<TEntryListArray*>(fTreeElist) : 0;
178 
179 
180  if (inElist && inElist->GetReapplyCut()) {
181  realSelection *= inElist->GetTitle();
182  }
183 
184  // what each variable should contain:
185  // varexp0 - original expression eg "a:b>>htest"
186  // hname - name of new or old histogram
187  // hkeep - flag if to keep new histogram
188  // hnameplus - flag if to add to current histo
189  // i - length of variable expression stipped of everything after ">>"
190  // varexp - variable expression stipped of everything after ">>"
191  // fOldHistogram - pointer to hist hname
192  // elist - pointer to selection list of hname
193 
194  Bool_t canExtend = kTRUE;
195  if (optSame) canExtend = kFALSE;
196 
197  Int_t nbinsx = 0, nbinsy = 0, nbinsz = 0;
198  Double_t xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0;
199 
200  fObject = 0;
201  char *hname = 0;
202  char *hnamealloc = 0;
203  i = 0;
204  if (varexp0 && strlen(varexp0)) {
205  for (UInt_t k = strlen(varexp0) - 1; k > 0; k--) {
206  if (varexp0[k] == '>' && varexp0[k-1] == '>') {
207  i = (int)(&(varexp0[k-1]) - varexp0); // length of varexp0 before ">>"
208  hnamealloc = new char[strlen(&(varexp0[k+1])) + 1];
209  hname = hnamealloc;
210  strcpy(hname, &(varexp0[k+1]));
211  break;
212  }
213  }
214  }
215  // char *hname = (char*)strstr(varexp0,">>");
216  if (hname) {
217  hkeep = 1;
218  varexp = new char[i+1];
219  varexp[0] = 0; //necessary if i=0
220  Bool_t hnameplus = kFALSE;
221  while (*hname == ' ') hname++;
222  if (*hname == '+') {
223  hnameplus = kTRUE;
224  hname++;
225  while (*hname == ' ') hname++; //skip ' '
226  }
227  j = strlen(hname) - 1; // skip ' ' at the end
228  while (j) {
229  if (hname[j] != ' ') break;
230  hname[j] = 0;
231  j--;
232  }
233 
234  if (i) {
235  strlcpy(varexp,varexp0,i+1);
236 
237  Int_t mustdelete = 0;
239 
240  // parse things that follow the name of the histo between '(' and ')'.
241  // At this point hname contains the name of the specified histogram.
242  // Now the syntax is extended to handle an hname of the following format
243  // hname(nBIN [[,[xlow]][,xhigh]],...)
244  // so enclosed in brackets is the binning information, xlow, xhigh, and
245  // the same for the other dimensions
246 
247  char *pstart; // pointer to '('
248  char *pend; // pointer to ')'
249  char *cdummy; // dummy pointer
250  int ncomma; // number of commas between '(' and ')', later number of arguments
251  int ncols; // number of columns in varexpr
252  Double_t value; // parsed value (by sscanf)
253 
254  const Int_t maxvalues = 9;
255 
256  pstart = strchr(hname, '(');
257  pend = strchr(hname, ')');
258  if (pstart != 0) { // found the bracket
259 
260  mustdelete = 1;
261 
262  // check that there is only one open and close bracket
263  if (pstart == strrchr(hname, '(') && pend == strrchr(hname, ')')) {
264 
265  // count number of ',' between '(' and ')'
266  ncomma = 0;
267  cdummy = pstart;
268  cdummy = strchr(&cdummy[1], ',');
269  while (cdummy != 0) {
270  cdummy = strchr(&cdummy[1], ',');
271  ncomma++;
272  }
273 
274  if (ncomma + 1 > maxvalues) {
275  Error("DrawSelect", "ncomma+1>maxvalues, ncomma=%d, maxvalues=%d", ncomma, maxvalues);
276  ncomma = maxvalues - 1;
277  }
278 
279  ncomma++; // number of arguments
280  cdummy = pstart;
281 
282  // number of columns
283  ncols = 1;
284  for (j = 0; j < i; j++) {
285  if (varexp[j] == ':'
286  && !((j > 0 && varexp[j-1] == ':') || varexp[j+1] == ':')
287  ) {
288  ncols++;
289  }
290  }
291  if (ncols > 3) { // max 3 columns
292  Error("DrawSelect", "ncols > 3, ncols=%d", ncols);
293  ncols = 0;
294  }
295 
296  // check dimensions before and after ">>"
297  if (ncols * 3 < ncomma) {
298  Error("DrawSelect", "ncols*3 < ncomma ncols=%d, ncomma=%d", ncols, ncomma);
299  ncomma = ncols * 3;
300  }
301 
302  // scan the values one after the other
303  for (j = 0; j < ncomma; j++) {
304  cdummy++; // skip '(' or ','
305  if (sscanf(cdummy, " %lf ", &value) == 1) {
306  cdummy = strchr(&cdummy[1], ',');
307 
308  switch (j) { // do certain settings depending on position of argument
309  case 0: // binning x-axis
310  nbinsx = (Int_t)value;
311  if (ncols < 2) {
312  gEnv->SetValue("Hist.Binning.1D.x", nbinsx);
313  } else if (ncols < 3) {
314  gEnv->SetValue("Hist.Binning.2D.x", nbinsx);
315  gEnv->SetValue("Hist.Binning.2D.Prof", nbinsx);
316  } else {
317  gEnv->SetValue("Hist.Binning.3D.x", nbinsx);
318  gEnv->SetValue("Hist.Binning.3D.Profx", nbinsx);
319  }
320 
321  break;
322  case 1: // lower limit x-axis
323  xmin = value;
324  break;
325  case 2: // upper limit x-axis
326  xmax = value;
327  break;
328  case 3: // binning y-axis
329  nbinsy = (Int_t)value;
330  if (ncols < 3) gEnv->SetValue("Hist.Binning.2D.y", nbinsy);
331  else {
332  gEnv->SetValue("Hist.Binning.3D.y", nbinsy);
333  gEnv->SetValue("Hist.Binning.3D.Profy", nbinsy);
334  }
335  break;
336  case 4: // lower limit y-axis
337  ymin = value;
338  break;
339  case 5: // upper limit y-axis
340  ymax = value;
341  break;
342  case 6: // binning z-axis
343  nbinsz = (Int_t)value;
344  gEnv->SetValue("Hist.Binning.3D.z", nbinsz);
345  break;
346  case 7: // lower limit z-axis
347  zmin = value;
348  break;
349  case 8: // upper limit z-axis
350  zmax = value;
351  break;
352  default:
353  Error("DrawSelect", "j>8");
354  break;
355  }
356  } // if sscanf == 1
357  } // for j=0;j<ncomma;j++
358  } else {
359  Error("Begin", "Two open or close brackets found, hname=%s", hname);
360  }
361 
362  // fix up hname
363  pstart[0] = '\0'; // removes things after (and including) '('
364  } // if '(' is found
365 
366  j = strlen(hname) - 1; // skip ' ' at the end
367  while (j > 0) {
368  if (hname[j] != ' ') break; // skip ' ' at the end
369  hname[j] = 0;
370  j--;
371  }
372 
373  TObject *oldObject = gDirectory->Get(hname); // if hname contains '(...)' the return values is NULL, which is what we want
374  fOldHistogram = oldObject ? dynamic_cast<TH1*>(oldObject) : 0;
375 
376  if (!fOldHistogram && oldObject && !oldObject->InheritsFrom(TH1::Class())) {
377  abrt.Form("An object of type '%s' has the same name as the requested histo (%s)", oldObject->IsA()->GetName(), hname);
378  Abort(abrt);
379  return;
380  }
381  if (fOldHistogram && !hnameplus) fOldHistogram->Reset(); // reset unless adding is wanted
382 
383  if (mustdelete) {
384  if (gDebug) {
385  Warning("Begin", "Deleting old histogram, since (possibly new) limits and binnings have been given");
386  }
387  delete fOldHistogram; fOldHistogram=0;
388  }
389 
390  } else {
391  // make selection list (i.e. varexp0 starts with ">>")
392  TObject *oldObject = gDirectory->Get(hname);
393  if (optEnlist) {
394  //write into a TEntryList
395  enlist = oldObject ? dynamic_cast<TEntryList*>(oldObject) : 0;
396 
397  if (!enlist && oldObject) {
398  abrt.Form("An object of type '%s' has the same name as the requested event list (%s)",
399  oldObject->IsA()->GetName(), hname);
400  Abort(abrt);
401  return;
402  }
403  if (!enlist) {
404  if (optEnlistArray) {
405  enlist = new TEntryListArray(hname, realSelection.GetTitle());
406  } else {
407  enlist = new TEntryList(hname, realSelection.GetTitle());
408  }
409  }
410  if (enlist) {
411  if (!hnameplus) {
412  if (enlist == inElist) {
413  // We have been asked to reset the input list!!
414  // Let's set it aside for now ...
415  if (optEnlistArray) {
416  inElist = new TEntryListArray(*enlist);
417  } else {
418  inElist = new TEntryList(*enlist);
419  }
420  fCleanElist = kTRUE;
421  fTree->SetEntryList(inElist);
422  }
423  enlist->Reset();
424  enlist->SetTitle(realSelection.GetTitle());
425  } else {
426  TCut old = enlist->GetTitle();
427  TCut upd = old || realSelection.GetTitle();
428  enlist->SetTitle(upd.GetTitle());
429  }
430  }
431  } else {
432  //write into a TEventList
433  evlist = oldObject ? dynamic_cast<TEventList*>(oldObject) : 0;
434 
435  if (!evlist && oldObject) {
436  abrt.Form("An object of type '%s' has the same name as the requested event list (%s)",
437  oldObject->IsA()->GetName(), hname);
438  Abort(abrt);
439  return;
440  }
441  if (!evlist) {
442  evlist = new TEventList(hname, realSelection.GetTitle(), 1000, 0);
443  }
444  if (evlist) {
445  if (!hnameplus) {
446  if (evlist == fTree->GetEventList()) {
447  // We have been asked to reset the input list!!
448  // Let's set it aside for now ...
449  Abort("Input and output lists are the same!");
450  delete [] varexp;
451  return;
452  }
453  evlist->Reset();
454  evlist->SetTitle(realSelection.GetTitle());
455  } else {
456  TCut old = evlist->GetTitle();
457  TCut upd = old || realSelection.GetTitle();
458  evlist->SetTitle(upd.GetTitle());
459  }
460  }
461  }
462 
463  } // if (i)
464  } else { // if (hname)
465  hname = hdefault;
466  hkeep = 0;
467  const size_t varexpLen = strlen(varexp0) + 1;
468  varexp = new char[varexpLen];
469  strlcpy(varexp, varexp0, varexpLen);
470  if (gDirectory) {
471  fOldHistogram = (TH1*)gDirectory->Get(hname);
473  }
474  }
475 
476  // Decode varexp and selection
477  if (!CompileVariables(varexp, realSelection.GetTitle())) {
478  abrt.Form("Variable compilation failed: {%s,%s}", varexp, realSelection.GetTitle());
479  Abort(abrt);
480  delete [] varexp;
481  return;
482  }
483  if (fDimension > 4 && !(optpara || optcandle || opt5d || opt.Contains("goff"))) {
484  Abort("Too many variables. Use the option \"para\", \"gl5d\" or \"candle\" to display more than 4 variables.");
485  delete [] varexp;
486  return;
487  }
488  if (fDimension < 2 && (optpara || optcandle)) {
489  Abort("The options \"para\" and \"candle\" require at least 2 variables.");
490  delete [] varexp;
491  return;
492  }
493 
494  // In case fOldHistogram exists, check dimensionality
495  Int_t nsel = strlen(selection);
496  if (nsel > 1) {
497  htitle.Form("%s {%s}", varexp, selection);
498  } else {
499  htitle = varexp;
500  }
501  if (fOldHistogram) {
502  Int_t olddim = fOldHistogram->GetDimension();
503  Int_t mustdelete = 0;
505  profile = kTRUE;
506  olddim = 2;
507  }
509  profile = kTRUE;
510  olddim = 3;
511  }
512  if (opt.Contains("prof") && fDimension > 1) {
513  // ignore "prof" for 1D.
514  if (!profile || olddim != fDimension) mustdelete = 1;
515  } else if (opt.Contains("col") && fDimension>2) {
516  if (olddim+1 != fDimension) mustdelete = 1;
517  } else {
518  if (olddim != fDimension) mustdelete = 1;
519  }
520  if (mustdelete) {
521  Warning("Begin", "Deleting old histogram with different dimensions");
522  delete fOldHistogram;
523  fOldHistogram = 0;
524  }
525  }
526 
527  // Create a default canvas if none exists
528  fDraw = 0;
529  if (!gPad && !opt.Contains("goff") && fDimension > 0) {
530  gROOT->MakeDefCanvas();
531  if (!gPad) {
532  Abort("Creation of default canvas failed");
533  return;
534  }
535  }
536 
537  // 1-D distribution
538  TH1 *hist;
539  if (fDimension == 1) {
540  fAction = 1;
541  if (!fOldHistogram) {
542  fNbins[0] = gEnv->GetValue("Hist.Binning.1D.x", 100);
543  if (gPad && optSame) {
544  TListIter np(gPad->GetListOfPrimitives());
545  TObject *op;
546  TH1 *oldhtemp = 0;
547  while ((op = np()) && !oldhtemp) {
548  if (op->InheritsFrom(TH1::Class())) oldhtemp = (TH1 *)op;
549  }
550  if (oldhtemp) {
551  fNbins[0] = oldhtemp->GetXaxis()->GetNbins();
552  fVmin[0] = oldhtemp->GetXaxis()->GetXmin();
553  fVmax[0] = oldhtemp->GetXaxis()->GetXmax();
554  } else {
555  fVmin[0] = gPad->GetUxmin();
556  fVmax[0] = gPad->GetUxmax();
557  }
558  } else {
559  fAction = -1;
560  fVmin[0] = xmin;
561  fVmax[0] = xmax;
562  if (xmin < xmax) canExtend = kFALSE;
563  }
564  }
565  if (fOldHistogram) {
566  hist = fOldHistogram;
567  fNbins[0] = hist->GetXaxis()->GetNbins();
568  } else {
569  hist = new TH1F(hname, htitle.Data(), fNbins[0], fVmin[0], fVmax[0]);
570  hist->SetLineColor(fTree->GetLineColor());
571  hist->SetLineWidth(fTree->GetLineWidth());
572  hist->SetLineStyle(fTree->GetLineStyle());
573  hist->SetFillColor(fTree->GetFillColor());
574  hist->SetFillStyle(fTree->GetFillStyle());
578  if (canExtend) hist->SetCanExtend(TH1::kAllAxes);
579  if (!hkeep) {
580  hist->GetXaxis()->SetTitle(fVar[0]->GetTitle());
581  hist->SetBit(kCanDelete);
582  if (!opt.Contains("goff")) hist->SetDirectory(0);
583  }
584  if (opt.Length() && opt.Contains("e")) hist->Sumw2();
585  }
586  fVar[0]->SetAxis(hist->GetXaxis());
587  fObject = hist;
588 
589  // 2-D distribution
590  } else if (fDimension == 2 && !(optpara || optcandle)) {
591  fAction = 2;
592  if (!fOldHistogram || !optSame) {
593  fNbins[0] = gEnv->GetValue("Hist.Binning.2D.y", 40);
594  fNbins[1] = gEnv->GetValue("Hist.Binning.2D.x", 40);
595  if (opt.Contains("prof")) fNbins[1] = gEnv->GetValue("Hist.Binning.2D.Prof", 100);
596  if (optSame) {
597  TH1 *oldhtemp = (TH1*)gPad->FindObject(hdefault);
598  if (oldhtemp) {
599  fNbins[1] = oldhtemp->GetXaxis()->GetNbins();
600  fVmin[1] = oldhtemp->GetXaxis()->GetXmin();
601  fVmax[1] = oldhtemp->GetXaxis()->GetXmax();
602  fNbins[0] = oldhtemp->GetYaxis()->GetNbins();
603  fVmin[0] = oldhtemp->GetYaxis()->GetXmin();
604  fVmax[0] = oldhtemp->GetYaxis()->GetXmax();
605  } else {
606  fNbins[1] = gEnv->GetValue("Hist.Binning.2D.x", 40);
607  fVmin[1] = gPad->GetUxmin();
608  fVmax[1] = gPad->GetUxmax();
609  fNbins[0] = gEnv->GetValue("Hist.Binning.2D.y", 40);
610  fVmin[0] = gPad->GetUymin();
611  fVmax[0] = gPad->GetUymax();
612  }
613  } else {
614  if (!fOldHistogram) fAction = -2;
615  fVmin[1] = xmin;
616  fVmax[1] = xmax;
617  fVmin[0] = ymin;
618  fVmax[0] = ymax;
619  if (xmin < xmax && ymin < ymax) canExtend = kFALSE;
620  }
621  }
622  if (profile || opt.Contains("prof")) {
623  TProfile *hp;
624  if (fOldHistogram) {
625  fAction = 4;
626  hp = (TProfile*)fOldHistogram;
627  } else {
628  if (fAction < 0) {
629  fAction = -4;
630  fVmin[1] = xmin;
631  fVmax[1] = xmax;
632  if (xmin < xmax) canExtend = kFALSE;
633  }
634  if (fAction == 2) {
635  //we come here when option = "same prof"
636  fAction = -4;
637  TH1 *oldhtemp = (TH1*)gPad->FindObject(hdefault);
638  if (oldhtemp) {
639  fNbins[1] = oldhtemp->GetXaxis()->GetNbins();
640  fVmin[1] = oldhtemp->GetXaxis()->GetXmin();
641  fVmax[1] = oldhtemp->GetXaxis()->GetXmax();
642  }
643  }
644  if (opt.Contains("profs")) {
645  hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], "s");
646  } else if (opt.Contains("profi")) {
647  hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], "i");
648  } else if (opt.Contains("profg")) {
649  hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], "g");
650  } else {
651  hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], "");
652  }
653  if (!hkeep) {
654  hp->SetBit(kCanDelete);
655  if (!opt.Contains("goff")) hp->SetDirectory(0);
656  }
665  if (canExtend) hp->SetCanExtend(TH1::kAllAxes);
666  }
667  fVar[1]->SetAxis(hp->GetXaxis());
668  fObject = hp;
669 
670  } else {
671  TH2F *h2;
672  if (fOldHistogram) {
673  h2 = (TH2F*)fOldHistogram;
674  } else {
675  h2 = new TH2F(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]);
684  if (canExtend) h2->SetCanExtend(TH1::kAllAxes);
685  if (!hkeep) {
686  h2->GetXaxis()->SetTitle(fVar[1]->GetTitle());
687  h2->GetYaxis()->SetTitle(fVar[0]->GetTitle());
688  h2->SetBit(TH1::kNoStats);
689  h2->SetBit(kCanDelete);
690  if (!opt.Contains("goff")) h2->SetDirectory(0);
691  }
692  }
693  fVar[0]->SetAxis(h2->GetYaxis());
694  fVar[1]->SetAxis(h2->GetXaxis());
695  Bool_t graph = kFALSE;
696  Int_t l = opt.Length();
697  if (l == 0 || optSame) graph = kTRUE;
698  if (opt.Contains("p") || opt.Contains("*") || opt.Contains("l")) graph = kTRUE;
699  if (opt.Contains("surf") || opt.Contains("lego") || opt.Contains("cont")) graph = kFALSE;
700  if (opt.Contains("col") || opt.Contains("hist") || opt.Contains("scat")) graph = kFALSE;
701  if (opt.Contains("box")) graph = kFALSE;
702  fObject = h2;
703  if (graph) {
704  fAction = 12;
705  if (!fOldHistogram && !optSame) fAction = -12;
706  }
707  }
708 
709  // 3-D distribution
710  } else if ((fDimension == 3 || fDimension == 4) && !(optpara || optcandle)) {
711  fAction = 3;
712  if (fDimension == 4) fAction = 40;
713  if (!fOldHistogram || !optSame) {
714  fNbins[0] = gEnv->GetValue("Hist.Binning.3D.z", 20);
715  fNbins[1] = gEnv->GetValue("Hist.Binning.3D.y", 20);
716  fNbins[2] = gEnv->GetValue("Hist.Binning.3D.x", 20);
717  if (fDimension == 3 && opt.Contains("prof")) {
718  fNbins[1] = gEnv->GetValue("Hist.Binning.3D.Profy", 20);
719  fNbins[2] = gEnv->GetValue("Hist.Binning.3D.Profx", 20);
720  }
721  if (fDimension == 3 && opt.Contains("col")) {
722  fNbins[0] = gEnv->GetValue("Hist.Binning.2D.y", 40);
723  fNbins[1] = gEnv->GetValue("Hist.Binning.2D.x", 40);
724  }
725  if (optSame) {
726  TH1 *oldhtemp = (TH1*)gPad->FindObject(hdefault);
727  if (oldhtemp) {
728  fNbins[2] = oldhtemp->GetXaxis()->GetNbins();
729  fVmin[2] = oldhtemp->GetXaxis()->GetXmin();
730  fVmax[2] = oldhtemp->GetXaxis()->GetXmax();
731  fNbins[1] = oldhtemp->GetYaxis()->GetNbins();
732  fVmin[1] = oldhtemp->GetYaxis()->GetXmin();
733  fVmax[1] = oldhtemp->GetYaxis()->GetXmax();
734  fNbins[0] = oldhtemp->GetZaxis()->GetNbins();
735  fVmin[0] = oldhtemp->GetZaxis()->GetXmin();
736  fVmax[0] = oldhtemp->GetZaxis()->GetXmax();
737  } else {
738  TView *view = gPad->GetView();
739  if (!view) {
740  Error("Begin", "You cannot use option same when no 3D view exists");
741  fVmin[0] = fVmin[1] = fVmin[2] = -1;
742  fVmax[0] = fVmax[1] = fVmax[2] = 1;
743  view = TView::CreateView(1, fVmin, fVmax);
744  }
745  Double_t *rmin = view->GetRmin();
746  Double_t *rmax = view->GetRmax();
747  fNbins[2] = gEnv->GetValue("Hist.Binning.3D.z", 20);
748  fVmin[2] = rmin[0];
749  fVmax[2] = rmax[0];
750  fNbins[1] = gEnv->GetValue("Hist.Binning.3D.y", 20);
751  fVmin[1] = rmin[1];
752  fVmax[1] = rmax[1];
753  fNbins[0] = gEnv->GetValue("Hist.Binning.3D.x", 20);
754  fVmin[0] = rmin[2];
755  fVmax[0] = rmax[2];
756  }
757  } else {
758  if (!fOldHistogram && fDimension == 3) fAction = -3;
759  fVmin[2] = xmin;
760  fVmax[2] = xmax;
761  fVmin[1] = ymin;
762  fVmax[1] = ymax;
763  fVmin[0] = zmin;
764  fVmax[0] = zmax;
765  if (xmin < xmax && ymin < ymax && zmin < zmax) canExtend = kFALSE;
766  }
767  }
768  if ((fDimension == 3) && (profile || opt.Contains("prof"))) {
769  TProfile2D *hp;
770  if (fOldHistogram) {
771  fAction = 23;
772  hp = (TProfile2D*)fOldHistogram;
773  } else {
774  if (fAction < 0) {
775  fAction = -23;
776  fVmin[2] = xmin;
777  fVmax[2] = xmax;
778  fVmin[1] = ymin;
779  fVmax[1] = ymax;
780  if (xmin < xmax && ymin < ymax) canExtend = kFALSE;
781  }
782  if (opt.Contains("profs")) {
783  hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], "s");
784  } else if (opt.Contains("profi")) {
785  hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], "i");
786  } else if (opt.Contains("profg")) {
787  hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], "g");
788  } else {
789  hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], "");
790  }
791  if (!hkeep) {
792  hp->SetBit(kCanDelete);
793  if (!opt.Contains("goff")) hp->SetDirectory(0);
794  }
803  if (canExtend) hp->SetCanExtend(TH1::kAllAxes);
804  }
805  fVar[1]->SetAxis(hp->GetYaxis());
806  fVar[2]->SetAxis(hp->GetXaxis());
807  fObject = hp;
808  } else if (fDimension == 3 && opt.Contains("col")) {
809  TH2F *h2;
810  if (fOldHistogram) {
811  h2 = (TH2F*)fOldHistogram;
812  } else {
813  h2 = new TH2F(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]);
822  if (canExtend) h2->SetCanExtend(TH1::kAllAxes);
823  if (!hkeep) {
824  h2->GetXaxis()->SetTitle(fVar[1]->GetTitle());
825  h2->GetYaxis()->SetTitle(fVar[0]->GetTitle());
826  h2->GetZaxis()->SetTitle(fVar[2]->GetTitle());
827  h2->SetBit(TH1::kNoStats);
828  h2->SetBit(kCanDelete);
829  if (!opt.Contains("goff")) h2->SetDirectory(0);
830  }
831  }
832  fVar[0]->SetAxis(h2->GetYaxis());
833  fVar[1]->SetAxis(h2->GetXaxis());
834  fObject = h2;
835  fAction = 33;
836  } else {
837  TH3F *h3;
838  if (fOldHistogram) {
839  h3 = (TH3F*)fOldHistogram;
840  } else {
841  h3 = new TH3F(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]);
850  if (canExtend) h3->SetCanExtend(TH1::kAllAxes);
851  if (!hkeep) {
852  //small correction for the title offsets in x,y to take into account the angles
853  Double_t xoffset = h3->GetXaxis()->GetTitleOffset();
854  Double_t yoffset = h3->GetYaxis()->GetTitleOffset();
855  h3->GetXaxis()->SetTitleOffset(1.2 * xoffset);
856  h3->GetYaxis()->SetTitleOffset(1.2 * yoffset);
857  h3->GetXaxis()->SetTitle(fVar[2]->GetTitle());
858  h3->GetYaxis()->SetTitle(fVar[1]->GetTitle());
859  h3->GetZaxis()->SetTitle(fVar[0]->GetTitle());
860  h3->SetBit(kCanDelete);
861  h3->SetBit(TH1::kNoStats);
862  if (!opt.Contains("goff")) h3->SetDirectory(0);
863  }
864  }
865  fVar[0]->SetAxis(h3->GetZaxis());
866  fVar[1]->SetAxis(h3->GetYaxis());
867  fVar[2]->SetAxis(h3->GetXaxis());
868  fObject = h3;
869  Int_t noscat = strlen(option);
870  if (optSame) noscat -= 4;
871  if (!noscat && fDimension == 3) {
872  fAction = 13;
873  if (!fOldHistogram && !optSame) fAction = -13;
874  }
875  }
876  // An Event List
877  } else if (enlist) {
878  fAction = 5;
880  fTree->SetEstimate(1);
881  fObject = enlist;
882  } else if (evlist) {
883  fAction = 5;
885  fTree->SetEstimate(1);
886  fObject = evlist;
887  } else if (optcandle || optpara || opt5d) {
888  if (optcandle) fAction = 7;
889  else if (opt5d) fAction = 8;
890  else fAction = 6;
891  }
892  if (varexp) delete [] varexp;
893  if (hnamealloc) delete [] hnamealloc;
894  for (i = 0; i < fValSize; ++i)
895  fVarMultiple[i] = kFALSE;
897  for (i = 0; i < fDimension; ++i) {
898  if (fVar[i] && fVar[i]->GetMultiplicity()) fVarMultiple[i] = kTRUE;
899  }
900 
902 
904  fWeight = fTree->GetWeight();
905  fNfill = 0;
906 
907  for (i = 0; i < fDimension; ++i) {
908  if (!fVal[i] && fVar[i]) {
909  fVal[i] = new Double_t[(Int_t)fTree->GetEstimate()];
910  }
911  }
912 
913  if (!fW) fW = new Double_t[(Int_t)fTree->GetEstimate()];
914 
915  for (i = 0; i < fValSize; ++i) {
916  fVmin[i] = DBL_MAX;
917  fVmax[i] = -DBL_MAX;
918  }
919 }
920 
921 ////////////////////////////////////////////////////////////////////////////////
922 /// Delete internal buffers.
923 
925 {
926  ResetBit(kWarn);
927  for (Int_t i = 0; i < fValSize; ++i) {
928  delete fVar[i];
929  fVar[i] = 0;
930  }
931  delete fSelect; fSelect = 0;
932  fManager = 0;
933  fMultiplicity = 0;
934 }
935 
936 ////////////////////////////////////////////////////////////////////////////////
937 /// Compile input variables and selection expression.
938 ///
939 /// varexp is an expression of the general form e1:e2:e3
940 /// where e1,etc is a formula referencing a combination of the columns
941 ///
942 /// Example:
943 ///
944 /// varexp = x simplest case: draw a 1-Dim distribution of column named x
945 /// = sqrt(x) : draw distribution of sqrt(x)
946 /// = x*y/z
947 /// = y:sqrt(x) 2-Dim distribution of y versus sqrt(x)
948 ///
949 /// selection is an expression with a combination of the columns
950 ///
951 /// Example:
952 ///
953 /// selection = "x<y && sqrt(z)>3.2"
954 ///
955 /// in a selection all the C++ operators are authorized
956 ///
957 /// Return kFALSE if any of the variable is not compilable.
958 
959 Bool_t TSelectorDraw::CompileVariables(const char *varexp, const char *selection)
960 {
961  Int_t i, nch, ncols;
962 
963  // Compile selection expression if there is one
964  fDimension = 0;
965  ClearFormula();
966  fMultiplicity = 0;
967  fObjEval = kFALSE;
968 
969  if (strlen(selection)) {
970  fSelect = new TTreeFormula("Selection", selection, fTree);
972  if (!fSelect->GetNdim()) {
973  delete fSelect;
974  fSelect = 0;
975  return kFALSE;
976  }
977  }
978 
979  // if varexp is empty, take first column by default
980  nch = strlen(varexp);
981  if (nch == 0) {
982  fDimension = 0;
983  if (fSelect) {
985  }
987 
988  if (fManager) {
989  fManager->Sync();
990 
993  }
994 
995  return kTRUE;
996  }
997 
998  // otherwise select only the specified columns
999  std::vector<TString> varnames;
1000  ncols = SplitNames(varexp, varnames);
1001 
1002  InitArrays(ncols);
1003 
1004  fManager = new TTreeFormulaManager();
1005  if (fSelect) fManager->Add(fSelect);
1007  for (i = 0; i < ncols; ++i) {
1008  fVar[i] = new TTreeFormula(TString::Format("Var%i", i + 1), varnames[i].Data(), fTree);
1009  fVar[i]->SetQuickLoad(kTRUE);
1010  if(!fVar[i]->GetNdim()) { ClearFormula(); return kFALSE; }
1011  fManager->Add(fVar[i]);
1012  }
1013  fManager->Sync();
1014 
1017 
1018  fDimension = ncols;
1019 
1020  if (ncols == 1) {
1021  TClass *cl = fVar[0]->EvalClass();
1022  if (cl) {
1023  fObjEval = kTRUE;
1024  }
1025  }
1026  return kTRUE;
1027 }
1028 
1029 ////////////////////////////////////////////////////////////////////////////////
1030 /// Return the last values corresponding to the i-th component
1031 /// of the formula being processed (where the component are ':' separated).
1032 /// The actual number of entries is:
1033 ///
1034 /// GetSelectedRows() % tree->GetEstimate()
1035 ///
1036 /// Note GetSelectedRows currently returns the actual number of values plotted
1037 /// and thus if the formula contains arrays, this number might be greater than
1038 /// the number of entries in the trees.
1039 ///
1040 /// By default TTree::Draw creates the arrays obtained
1041 /// with all GetVal and GetW with a length corresponding to the
1042 /// parameter fEstimate. By default fEstimate=10000 and can be modified
1043 /// via TTree::SetEstimate. A possible recipe is to do
1044 ///
1045 /// tree->SetEstimate(tree->GetEntries());
1046 ///
1047 /// You must call SetEstimate if the expected number of selected rows
1048 /// is greater than 10000.
1049 ///
1050 /// See TTree::Draw for additional details.
1051 
1053 {
1054  if (i < 0 || i >= fDimension)
1055  return 0;
1056  else
1057  return fVal[i];
1058 }
1059 
1060 ////////////////////////////////////////////////////////////////////////////////
1061 /// Return the TTreeFormula corresponding to the i-th component
1062 /// of the request formula (where the component are ':' separated).
1063 
1065 {
1066  if (i < 0 || i >= fDimension)
1067  return 0;
1068  else
1069  return fVar[i];
1070 }
1071 
1072 ////////////////////////////////////////////////////////////////////////////////
1073 /// Initialization of the primitive type arrays if the new size is bigger than the available space.
1074 
1076 {
1077  if (newsize > fValSize) {
1078  Int_t oldsize = fValSize;
1079  while (fValSize < newsize)
1080  fValSize *= 2; // Double the available space until it matches the new size.
1081  if (fNbins) delete [] fNbins;
1082  if (fVmin) delete [] fVmin;
1083  if (fVmax) delete [] fVmax;
1084  if (fVarMultiple) delete [] fVarMultiple;
1085 
1086  fNbins = new Int_t[fValSize];
1087  fVmin = new Double_t[fValSize];
1088  fVmax = new Double_t[fValSize];
1089  fVarMultiple = new Bool_t[fValSize];
1090 
1091  for (Int_t i = 0; i < oldsize; ++i)
1092  delete [] fVal[i];
1093  delete [] fVal;
1094  delete [] fVar;
1095  fVal = new Double_t*[fValSize];
1096  fVar = new TTreeFormula*[fValSize];
1097  for (Int_t i = 0; i < fValSize; ++i) {
1098  fVal[i] = 0;
1099  fVar[i] = 0;
1100  }
1101  }
1102 }
1103 
1104 ////////////////////////////////////////////////////////////////////////////////
1105 /// Build Index array for names in varexp.
1106 /// This will allocated a C style array of TString and Ints
1107 
1108 UInt_t TSelectorDraw::SplitNames(const TString &varexp, std::vector<TString> &names)
1109 {
1110  names.clear();
1111 
1112  Bool_t ternary = kFALSE;
1113  Int_t prev = 0;
1114  for (Int_t i = 0; i < varexp.Length(); i++) {
1115  if (varexp[i] == ':'
1116  && !((i > 0 && varexp[i-1] == ':') || varexp[i+1] == ':')
1117  ) {
1118  if (ternary) {
1119  ternary = kFALSE;
1120  } else {
1121  names.push_back(varexp(prev, i - prev));
1122  prev = i + 1;
1123  }
1124  }
1125  if (varexp[i] == '?') {
1126  ternary = kTRUE;
1127  }
1128  }
1129  names.push_back(varexp(prev, varexp.Length() - prev));
1130  return names.size();
1131 }
1132 
1133 
1134 ////////////////////////////////////////////////////////////////////////////////
1135 /// This function is called at the first entry of a new tree in a chain.
1136 
1138 {
1139  if (fTree) fWeight = fTree->GetWeight();
1140  if (fVar) {
1141  for (Int_t i = 0; i < fDimension; ++i) {
1142  if (fVar[i]) fVar[i]->UpdateFormulaLeaves();
1143  }
1144  }
1146  return kTRUE;
1147 }
1148 
1149 ////////////////////////////////////////////////////////////////////////////////
1150 /// Called in the entry loop for all entries accepted by Select.
1151 
1153 {
1154  if (fObjEval) {
1155  ProcessFillObject(entry);
1156  return;
1157  }
1158 
1159  if (fMultiplicity) {
1160  ProcessFillMultiple(entry);
1161  return;
1162  }
1163 
1164  // simple case with no multiplicity
1165  if (fForceRead && fManager->GetNdata() <= 0) return;
1166 
1167  if (fSelect) {
1169  if (!fW[fNfill]) return;
1170  } else fW[fNfill] = fWeight;
1171  if (fVal) {
1172  for (Int_t i = 0; i < fDimension; ++i) {
1173  if (fVar[i]) fVal[i][fNfill] = fVar[i]->EvalInstance(0);
1174  }
1175  }
1176  fNfill++;
1177  if (fNfill >= fTree->GetEstimate()) {
1178  TakeAction();
1179  fNfill = 0;
1180  }
1181 }
1182 
1183 ////////////////////////////////////////////////////////////////////////////////
1184 /// Called in the entry loop for all entries accepted by Select.
1185 /// Complex case with multiplicity.
1186 
1188 {
1189  // Grab the array size of the formulas for this entry
1191 
1192  // No data at all, let's move on to the next entry.
1193  if (!ndata) return;
1194 
1195  // If the entry list is a TEntryListArray, get the selected subentries for this entry
1196  TEntryList *subList = 0;
1197  if (fTreeElistArray) {
1198  subList = fTreeElistArray->GetSubListForEntry(entry, fTree->GetTree());
1199  }
1200 
1201  Int_t nfill0 = fNfill;
1202 
1203  // Calculate the first values
1204  if (fSelect) {
1205  // coverity[var_deref_model] fSelectMultiple==kTRUE => fSelect != 0
1207  if (!fW[fNfill] && !fSelectMultiple) return;
1208  } else fW[fNfill] = fWeight;
1209 
1210  // Always call EvalInstance(0) to insure the loading
1211  // of the branches.
1212  if (fW[fNfill] && (!subList || subList->Contains(0))) {
1213  if (fDimension == 0 && fSelectMultiple) fCurrentSubEntry = (Long64_t) 0; // to fill TEntryListArray
1214  for (Int_t i = 0; i < fDimension; ++i) {
1215  if (fVar[i]) fVal[i][fNfill] = fVar[i]->EvalInstance(0);
1216  }
1217  fNfill++;
1218  if (fNfill >= fTree->GetEstimate()) {
1219  TakeAction();
1220  fNfill = 0;
1221  }
1222  } else {
1223  for (Int_t i = 0; i < fDimension; ++i) {
1224  if (fVar[i]) fVar[i]->ResetLoading();
1225  }
1226  }
1227  Double_t ww = fW[nfill0];
1228 
1229  for (Int_t i = 1; i < ndata; i++) {
1230  if (subList && !subList->Contains(i)) continue;
1231  if (fSelectMultiple) {
1232  // coverity[var_deref_model] fSelectMultiple==kTRUE => fSelect != 0
1233  ww = fWeight * fSelect->EvalInstance(i);
1234  if (ww == 0) continue;
1235  if (fNfill == nfill0) {
1236  for (Int_t k = 0; k < fDimension; ++k) {
1237  if (!fVarMultiple[k]) fVal[k][fNfill] = fVar[k]->EvalInstance(0);
1238  }
1239  }
1240  if (fDimension == 0) fCurrentSubEntry = (Long64_t) i; // to fill TEntryListArray
1241  }
1242  for (Int_t k = 0; k < fDimension; ++k) {
1243  if (fVarMultiple[k]) fVal[k][fNfill] = fVar[k]->EvalInstance(i);
1244  else fVal[k][fNfill] = fVal[k][nfill0];
1245  }
1246  fW[fNfill] = ww;
1247 
1248  fNfill++;
1249  if (fNfill >= fTree->GetEstimate()) {
1250  TakeAction();
1251  fNfill = 0;
1252  }
1253  }
1254 }
1255 
1256 ////////////////////////////////////////////////////////////////////////////////
1257 /// Called in the entry loop for all entries accepted by Select.
1258 /// Case where the only variable returns an object (or pointer to).
1259 
1261 {
1262  // Complex case with multiplicity.
1263 
1264  // Grab the array size of the formulas for this entry
1266 
1267  // No data at all, let's move on to the next entry.
1268  if (!ndata) return;
1269 
1270  Int_t nfill0 = fNfill;
1271  Double_t ww = 0;
1272 
1273  for (Int_t i = 0; i < ndata; i++) {
1274  if (i == 0) {
1275  if (fSelect) {
1277  if (!fW[fNfill] && !fSelectMultiple) return;
1278  } else fW[fNfill] = fWeight;
1279  ww = fW[nfill0];
1280  } else if (fSelectMultiple) {
1281  ww = fWeight * fSelect->EvalInstance(i);
1282  if (ww == 0) continue;
1283  }
1284  if (fDimension >= 1 && fVar[0]) {
1285  TClass *cl = fVar[0]->EvalClass();
1286  if (cl == TBits::Class()) {
1287 
1288  void *obj = fVar[0]->EvalObject(i);
1289 
1290  if (obj) {
1291  TBits *bits = (TBits*)obj;
1292  Int_t nbits = bits->GetNbits();
1293 
1294  Int_t nextbit = -1;
1295  while (1) {
1296  nextbit = bits->FirstSetBit(nextbit + 1);
1297  if (nextbit >= nbits) break;
1298  fVal[0][fNfill] = nextbit;
1299  fW[fNfill] = ww;
1300  fNfill++;
1301  }
1302  }
1303 
1304  } else {
1305 
1306  if (!TestBit(kWarn)) {
1307  Warning("ProcessFillObject",
1308  "Not implemented for %s",
1309  cl ? cl->GetName() : "unknown class");
1310  SetBit(kWarn);
1311  }
1312 
1313  }
1314  }
1315  if (fNfill >= fTree->GetEstimate()) {
1316  TakeAction();
1317  fNfill = 0;
1318  }
1319  }
1320 
1321 }
1322 
1323 ////////////////////////////////////////////////////////////////////////////////
1324 /// Set number of entries to estimate variable limits.
1325 
1327 {
1328  if (fVal) {
1329  for (Int_t i = 0; i < fValSize; ++i) {
1330  delete [] fVal[i];
1331  fVal[i] = 0;
1332  }
1333  }
1334  delete [] fW; fW = 0;
1335 }
1336 
1337 ////////////////////////////////////////////////////////////////////////////////
1338 /// Execute action for object obj fNfill times.
1339 
1341 {
1342  Int_t i;
1343  //__________________________1-D histogram_______________________
1344  if (fAction == 1)((TH1*)fObject)->FillN(fNfill, fVal[0], fW);
1345  //__________________________2-D histogram_______________________
1346  else if (fAction == 2) {
1347  TH2 *h2 = (TH2*)fObject;
1348  for (i = 0; i < fNfill; i++) h2->Fill(fVal[1][i], fVal[0][i], fW[i]);
1349  }
1350  //__________________________Profile histogram_______________________
1351  else if (fAction == 4)((TProfile*)fObject)->FillN(fNfill, fVal[1], fVal[0], fW);
1352  //__________________________Event List______________________________
1353  else if (fAction == 5) {
1355  TEntryListArray *enlistarray = (TEntryListArray*)fObject;
1356  Long64_t enumb = fTree->GetTree()->GetReadEntry();
1357  enlistarray->Enter(enumb, 0, fCurrentSubEntry);
1358  } else if (fObject->InheritsFrom(TEntryList::Class())) {
1359  TEntryList *enlist = (TEntryList*)fObject;
1360  Long64_t enumb = fTree->GetTree()->GetReadEntry();
1361  enlist->Enter(enumb);
1362  } else {
1363  TEventList *evlist = (TEventList*)fObject;
1365  if (evlist->GetIndex(enumb) < 0) evlist->Enter(enumb);
1366  }
1367  }
1368  //__________________________2D scatter plot_______________________
1369  else if (fAction == 12) {
1370  TH2 *h2 = (TH2*)fObject;
1371  if (h2->CanExtendAllAxes() && h2->TestBit(kCanDelete)) {
1372  for (i = 0; i < fNfill; i++) {
1373  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1374  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1375  if (fVmin[1] > fVal[1][i]) fVmin[1] = fVal[1][i];
1376  if (fVmax[1] < fVal[1][i]) fVmax[1] = fVal[1][i];
1377  }
1379  }
1380  TGraph *pm = new TGraph(fNfill, fVal[1], fVal[0]);
1381  pm->SetEditable(kFALSE);
1382  pm->SetBit(kCanDelete);
1391 
1392  if (!fDraw && !strstr(fOption.Data(), "goff")) {
1393  if (fOption.Length() == 0 || strcasecmp(fOption.Data(), "same") == 0) pm->Draw("p");
1394  else pm->Draw(fOption.Data());
1395  }
1396  if (!h2->TestBit(kCanDelete)) {
1397  for (i = 0; i < fNfill; i++) h2->Fill(fVal[1][i], fVal[0][i], fW[i]);
1398  }
1399  }
1400  //__________________________3D scatter plot_______________________
1401  else if (fAction == 3) {
1402  TH3 *h3 = (TH3*)fObject;
1403  if (!h3->TestBit(kCanDelete)) {
1404  for (i = 0; i < fNfill; i++) h3->Fill(fVal[2][i], fVal[1][i], fVal[0][i], fW[i]);
1405  }
1406  } else if (fAction == 13) {
1407  TPolyMarker3D *pm3d = new TPolyMarker3D(fNfill);
1410  pm3d->SetMarkerSize(fTree->GetMarkerSize());
1411  for (i = 0; i < fNfill; i++) {
1412  pm3d->SetPoint(i, fVal[2][i], fVal[1][i], fVal[0][i]);
1413  }
1414  pm3d->Draw();
1415  TH3 *h3 = (TH3*)fObject;
1416  if (!h3->TestBit(kCanDelete)) {
1417  for (i = 0; i < fNfill; i++) h3->Fill(fVal[2][i], fVal[1][i], fVal[0][i], fW[i]);
1418  }
1419  }
1420  //__________________________3D scatter plot (3rd variable = col)__
1421  else if (fAction == 33) {
1422  TH2 *h2 = (TH2*)fObject;
1423  TakeEstimate();
1424  Int_t ncolors = gStyle->GetNumberOfColors();
1425  TObjArray *grs = (TObjArray*)h2->GetListOfFunctions()->FindObject("graphs");
1426  Int_t col;
1427  TGraph *gr;
1428  if (!grs) {
1429  grs = new TObjArray(ncolors);
1430  grs->SetOwner();
1431  grs->SetName("graphs");
1432  h2->GetListOfFunctions()->Add(grs, "P");
1433  for (col = 0; col < ncolors; col++) {
1434  gr = new TGraph();
1438  grs->AddAt(gr, col);
1439  }
1440  }
1441  h2->SetEntries(fNfill);
1442  h2->SetMinimum(fVmin[2]);
1443  h2->SetMaximum(fVmax[2]);
1444  // Fill the graphs according to the color
1445  for (i = 0; i < fNfill; i++) {
1446  col = Int_t(ncolors * ((fVal[2][i] - fVmin[2]) / (fVmax[2] - fVmin[2])));
1447  if (col < 0) col = 0;
1448  if (col > ncolors - 1) col = ncolors - 1;
1449  gr = (TGraph*)grs->UncheckedAt(col);
1450  if (gr) gr->SetPoint(gr->GetN(), fVal[1][i], fVal[0][i]);
1451  }
1452  // Remove potential empty graphs
1453  for (col = 0; col < ncolors; col++) {
1454  gr = (TGraph*)grs->At(col);
1455  if (gr && gr->GetN() <= 0) grs->Remove(gr);
1456  }
1457  }
1458  //__________________________2D Profile Histogram__________________
1459  else if (fAction == 23) {
1460  TProfile2D *hp2 = (TProfile2D*)fObject;
1461  for (i = 0; i < fNfill; i++) hp2->Fill(fVal[2][i], fVal[1][i], fVal[0][i], fW[i]);
1462  }
1463  //__________________________4D scatter plot_______________________
1464  else if (fAction == 40) {
1465  TakeEstimate();
1466  TH3 *h3 = (TH3*)fObject;
1467  Int_t ncolors = gStyle->GetNumberOfColors();
1468  if (ncolors == 0) {
1470  ncolors = gStyle->GetNumberOfColors();
1471  }
1472  TObjArray *pms = (TObjArray*)h3->GetListOfFunctions()->FindObject("polymarkers");
1473  Int_t col;
1474  TPolyMarker3D *pm3d;
1475  if (!pms) {
1476  pms = new TObjArray(ncolors);
1477  pms->SetOwner();
1478  pms->SetName("polymarkers");
1479  h3->GetListOfFunctions()->Add(pms);
1480  for (col = 0; col < ncolors; col++) {
1481  pm3d = new TPolyMarker3D();
1482  pm3d->SetMarkerColor(gStyle->GetColorPalette(col));
1484  pm3d->SetMarkerSize(fTree->GetMarkerSize());
1485  pms->AddAt(pm3d, col);
1486  }
1487  }
1488  h3->SetEntries(fNfill);
1489  h3->SetMinimum(fVmin[3]);
1490  h3->SetMaximum(fVmax[3]);
1491  for (i = 0; i < fNfill; i++) {
1492  col = Int_t(ncolors * ((fVal[3][i] - fVmin[3]) / (fVmax[3] - fVmin[3])));
1493  if (col > ncolors-1) col = ncolors-1;
1494  if (col < 0) col = 0;
1495  pm3d = (TPolyMarker3D*)pms->UncheckedAt(col);
1496  pm3d->SetPoint(pm3d->GetLastPoint() + 1, fVal[2][i], fVal[1][i], fVal[0][i]);
1497  }
1498  }
1499  //__________________________Parallel coordinates / candle chart_______________________
1500  else if (fAction == 6 || fAction == 7) {
1501  TakeEstimate();
1502  Bool_t candle = (fAction == 7);
1503  // Using CINT to avoid a dependency in TParallelCoord
1504  if (!fOption.Contains("goff"))
1505  gROOT->ProcessLine(TString::Format("TParallelCoord::BuildParallelCoord((TSelectorDraw*)0x%lx,0x%lx)",
1506  (ULong_t)this, (ULong_t)candle));
1507  } else if (fAction == 8) {
1508  //gROOT->ProcessLineFast(TString::Format("(new TGL5DDataSet((TTree *)0x%1x))->Draw(\"%s\");", fTree, fOption.Data()));
1509  }
1510  //__________________________something else_______________________
1511  else if (fAction < 0) {
1512  fAction = -fAction;
1513  TakeEstimate();
1514  }
1515 
1516  // Do we need to update screen?
1517  fSelectedRows += fNfill;
1518  if (!fTree->GetUpdate()) return;
1519  if (fSelectedRows > fDraw + fTree->GetUpdate()) {
1520  if (fDraw) gPad->Modified();
1521  else fObject->Draw(fOption.Data());
1522  gPad->Update();
1523  fDraw = fSelectedRows;
1524  }
1525 }
1526 
1527 ////////////////////////////////////////////////////////////////////////////////
1528 /// Estimate limits for 1-D, 2-D or 3-D objects.
1529 
1531 {
1532  Int_t i;
1533  Double_t rmin[3], rmax[3];
1534  Double_t vminOld[4], vmaxOld[4];
1535  for (i = 0; i < fValSize && i < 4; i++) {
1536  vminOld[i] = fVmin[i];
1537  vmaxOld[i] = fVmax[i];
1538  }
1539  for (i = 0; i < fValSize; ++i) {
1540  fVmin[i] = DBL_MAX;
1541  fVmax[i] = - DBL_MAX;
1542  }
1543  //__________________________1-D histogram_______________________
1544  if (fAction == 1) {
1545  TH1 *h1 = (TH1*)fObject;
1546  if (h1->CanExtendAllAxes()) {
1547  for (i = 0; i < fNfill; i++) {
1548  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1549  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1550  }
1552  }
1553  h1->FillN(fNfill, fVal[0], fW);
1554  //__________________________2-D histogram_______________________
1555  } else if (fAction == 2) {
1556  TH2 *h2 = (TH2*)fObject;
1557  if (h2->CanExtendAllAxes()) {
1558  for (i = 0; i < fNfill; i++) {
1559  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1560  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1561  if (fVmin[1] > fVal[1][i]) fVmin[1] = fVal[1][i];
1562  if (fVmax[1] < fVal[1][i]) fVmax[1] = fVal[1][i];
1563  }
1565  }
1566  for (i = 0; i < fNfill; i++) h2->Fill(fVal[1][i], fVal[0][i], fW[i]);
1567  //__________________________Profile histogram_______________________
1568  } else if (fAction == 4) {
1569  TProfile *hp = (TProfile*)fObject;
1570  if (hp->CanExtendAllAxes()) {
1571  for (i = 0; i < fNfill; i++) {
1572  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1573  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1574  if (fVmin[1] > fVal[1][i]) fVmin[1] = fVal[1][i];
1575  if (fVmax[1] < fVal[1][i]) fVmax[1] = fVal[1][i];
1576  }
1578  }
1579  hp->FillN(fNfill, fVal[1], fVal[0], fW);
1580  //__________________________2D scatter plot_______________________
1581  } else if (fAction == 12) {
1582  TH2 *h2 = (TH2*)fObject;
1583  if (h2->CanExtendAllAxes()) {
1584  for (i = 0; i < fNfill; i++) {
1585  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1586  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1587  if (fVmin[1] > fVal[1][i]) fVmin[1] = fVal[1][i];
1588  if (fVmax[1] < fVal[1][i]) fVmax[1] = fVal[1][i];
1589  }
1591  // In case the new lower limits of h2 axis are 0, it is better to set them to the minimum of
1592  // the data set (which should be >0) to avoid data cut when plotting in log scale.
1593  TAxis *aX = h2->GetXaxis();
1594  TAxis *aY = h2->GetYaxis();
1595  Double_t xmin = aX->GetXmin();
1596  Double_t ymin = aY->GetXmin();
1597  if (xmin == 0 || ymin == 0) {
1598  if (aX->GetBinUpEdge(aX->FindFixBin(0.01*aX->GetBinWidth(aX->GetFirst()))) > fVmin[1]) xmin = fVmin[1];
1599  if (aY->GetBinUpEdge(aY->FindFixBin(0.01*aY->GetBinWidth(aY->GetFirst()))) > fVmin[0]) ymin = fVmin[0];
1600  h2->SetBins(aX->GetNbins(), xmin, aX->GetXmax(), aY->GetNbins(), ymin, aY->GetXmax());
1601  }
1602  }
1603 
1604  if (!strstr(fOption.Data(), "same") && !strstr(fOption.Data(), "goff")) {
1605  if (!h2->TestBit(kCanDelete)) {
1606  // case like: T.Draw("y:x>>myhist")
1607  // we must draw a copy before filling the histogram h2=myhist
1608  // because h2 will be filled below and we do not want to show
1609  // the binned scatter-plot, the TGraph being better.
1610  TH1 *h2c = h2->DrawCopy(fOption.Data(),"");
1611  if (h2c) h2c->SetStats(kFALSE);
1612  } else {
1613  // case like: T.Draw("y:x")
1614  // h2 is a temporary histogram (htemp). This histogram
1615  // will be automatically deleted by TPad::Clear
1616  h2->Draw();
1617  }
1618  gPad->Update();
1619  }
1620  TGraph *pm = new TGraph(fNfill, fVal[1], fVal[0]);
1621  pm->SetEditable(kFALSE);
1622  pm->SetBit(kCanDelete);
1631  if (!fDraw && !strstr(fOption.Data(),"goff")) {
1632  if (fOption.Length() == 0 || strcasecmp(fOption.Data(),"same")==0) {
1633  pm->Draw("p");
1634  }
1635  else {
1636  TString opt = fOption;
1637  opt.ToLower();
1638  if (opt.Contains("a")) {
1639  TString temp(opt);
1640  temp.ReplaceAll("same","");
1641  if (temp.Contains("a")) {
1642  if (h2->TestBit(kCanDelete)) {
1643  // h2 will be deleted, the axis setting is delegated to only
1644  // the TGraph.
1645  h2 = 0;
1646  }
1647  }
1648  }
1649  pm->Draw(fOption.Data());
1650  }
1651  }
1652  if (h2 && !h2->TestBit(kCanDelete)) {
1653  for (i = 0; i < fNfill; i++) h2->Fill(fVal[1][i], fVal[0][i], fW[i]);
1654  }
1655  //__________________________3D scatter plot with option col_______________________
1656  } else if (fAction == 33) {
1657  TH2 *h2 = (TH2*)fObject;
1658  Bool_t process2 = kFALSE;
1659  if (h2->CanExtendAllAxes()) {
1660  if (vminOld[2] == DBL_MAX)
1661  process2 = kTRUE;
1662  for (i = 0; i < fValSize && i < 4; i++) {
1663  fVmin[i] = vminOld[i];
1664  fVmax[i] = vmaxOld[i];
1665  }
1666  for (i = 0; i < fNfill; i++) {
1667  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1668  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1669  if (fVmin[1] > fVal[1][i]) fVmin[1] = fVal[1][i];
1670  if (fVmax[1] < fVal[1][i]) fVmax[1] = fVal[1][i];
1671  if (process2) {
1672  if (fVmin[2] > fVal[2][i]) fVmin[2] = fVal[2][i];
1673  if (fVmax[2] < fVal[2][i]) fVmax[2] = fVal[2][i];
1674  }
1675  }
1677  // In case the new lower limits of h2 axis are 0, it is better to set them to the minimum of
1678  // the data set (which should be >0) to avoid data cut when plotting in log scale.
1679  TAxis *aX = h2->GetXaxis();
1680  TAxis *aY = h2->GetYaxis();
1681  Double_t xmin = aX->GetXmin();
1682  Double_t ymin = aY->GetXmin();
1683  if (xmin == 0 || ymin == 0) {
1684  if (aX->GetBinUpEdge(aX->FindFixBin(0.01*aX->GetBinWidth(aX->GetFirst()))) > fVmin[1]) xmin = fVmin[1];
1685  if (aY->GetBinUpEdge(aY->FindFixBin(0.01*aY->GetBinWidth(aY->GetFirst()))) > fVmin[0]) ymin = fVmin[0];
1686  h2->SetBins(aX->GetNbins(), xmin, aX->GetXmax(), aY->GetNbins(), ymin, aY->GetXmax());
1687  }
1688  } else {
1689  for (i = 0; i < fNfill; i++) {
1690  if (fVmin[2] > fVal[2][i]) fVmin[2] = fVal[2][i];
1691  if (fVmax[2] < fVal[2][i]) fVmax[2] = fVal[2][i];
1692  }
1693  }
1694  //__________________________3D scatter plot_______________________
1695  } else if (fAction == 3 || fAction == 13) {
1696  TH3 *h3 = (TH3*)fObject;
1697  if (h3->CanExtendAllAxes()) {
1698  for (i = 0; i < fNfill; i++) {
1699  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1700  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1701  if (fVmin[1] > fVal[1][i]) fVmin[1] = fVal[1][i];
1702  if (fVmax[1] < fVal[1][i]) fVmax[1] = fVal[1][i];
1703  if (fVmin[2] > fVal[2][i]) fVmin[2] = fVal[2][i];
1704  if (fVmax[2] < fVal[2][i]) fVmax[2] = fVal[2][i];
1705  }
1707  }
1708  if (fAction == 3) {
1709  for (i = 0; i < fNfill; i++) h3->Fill(fVal[2][i], fVal[1][i], fVal[0][i], fW[i]);
1710  return;
1711  }
1712  if (!strstr(fOption.Data(), "same") && !strstr(fOption.Data(), "goff")) {
1713  if (!h3->TestBit(kCanDelete)) {
1714  // case like: T.Draw("y:x>>myhist")
1715  // we must draw a copy before filling the histogram h3=myhist
1716  // because h3 will be filled below and we do not want to show
1717  // the binned scatter-plot, the TGraph being better.
1718  TH1 *h3c = h3->DrawCopy(fOption.Data(),"");
1719  if (h3c) h3c->SetStats(kFALSE);
1720  } else {
1721  // case like: T.Draw("y:x")
1722  // h3 is a temporary histogram (htemp). This histogram
1723  // will be automatically deleted by TPad::Clear
1724  h3->Draw(fOption.Data());
1725  }
1726  gPad->Update();
1727  } else {
1728  rmin[0] = fVmin[2]; rmin[1] = fVmin[1]; rmin[2] = fVmin[0];
1729  rmax[0] = fVmax[2]; rmax[1] = fVmax[1]; rmax[2] = fVmax[0];
1730  gPad->Clear();
1731  gPad->Range(-1, -1, 1, 1);
1732  TView::CreateView(1, rmin, rmax);
1733  }
1734  TPolyMarker3D *pm3d = new TPolyMarker3D(fNfill);
1737  pm3d->SetMarkerSize(fTree->GetMarkerSize());
1738  for (i = 0; i < fNfill; i++) {
1739  pm3d->SetPoint(i, fVal[2][i], fVal[1][i], fVal[0][i]);
1740  }
1741  if (!fDraw && !strstr(fOption.Data(), "goff")) pm3d->Draw();
1742  if (!h3->TestBit(kCanDelete)) {
1743  for (i = 0; i < fNfill; i++) h3->Fill(fVal[2][i], fVal[1][i], fVal[0][i], fW[i]);
1744  }
1745 
1746  //__________________________2D Profile Histogram__________________
1747  } else if (fAction == 23) {
1748  TProfile2D *hp = (TProfile2D*)fObject;
1749  if (hp->CanExtendAllAxes()) {
1750  for (i = 0; i < fNfill; i++) {
1751  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1752  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1753  if (fVmin[1] > fVal[1][i]) fVmin[1] = fVal[1][i];
1754  if (fVmax[1] < fVal[1][i]) fVmax[1] = fVal[1][i];
1755  if (fVmin[2] > fVal[2][i]) fVmin[2] = fVal[2][i];
1756  if (fVmax[2] < fVal[2][i]) fVmax[2] = fVal[2][i];
1757  }
1759  }
1760  for (i = 0; i < fNfill; i++) hp->Fill(fVal[2][i], fVal[1][i], fVal[0][i], fW[i]);
1761  //__________________________4D scatter plot_______________________
1762  } else if (fAction == 40) {
1763  TH3 *h3 = (TH3*)fObject;
1764  if (h3->CanExtendAllAxes()) {
1765  for (i = 0; i < fValSize && i < 4; i++) {
1766  fVmin[i] = vminOld[i];
1767  fVmax[i] = vmaxOld[i];
1768  }
1769  for (i = 0; i < fNfill; i++) {
1770  if (fVmin[0] > fVal[0][i]) fVmin[0] = fVal[0][i];
1771  if (fVmax[0] < fVal[0][i]) fVmax[0] = fVal[0][i];
1772  if (fVmin[1] > fVal[1][i]) fVmin[1] = fVal[1][i];
1773  if (fVmax[1] < fVal[1][i]) fVmax[1] = fVal[1][i];
1774  if (fVmin[2] > fVal[2][i]) fVmin[2] = fVal[2][i];
1775  if (fVmax[2] < fVal[2][i]) fVmax[2] = fVal[2][i];
1776  if (fVmin[3] > fVal[3][i]) fVmin[3] = fVal[3][i];
1777  if (fVmax[3] < fVal[3][i]) fVmax[3] = fVal[3][i];
1778  }
1780  } else {
1781  for (i = 0; i < fNfill; i++) {
1782  if (fVmin[3] > fVal[3][i]) fVmin[3] = fVal[3][i];
1783  if (fVmax[3] < fVal[3][i]) fVmax[3] = fVal[3][i];
1784  }
1785  }
1786  }
1787  //__________________________Parallel coordinates plot / candle chart_______________________
1788  else if (fAction == 6 || fAction == 7) {
1789  for (i = 0; i < fDimension; ++i) {
1790  for (Long64_t entry = 0; entry < fNfill; entry++) {
1791  if (fVmin[i] > fVal[i][entry]) fVmin[i] = fVal[i][entry];
1792  if (fVmax[i] < fVal[i][entry]) fVmax[i] = fVal[i][entry];
1793  }
1794  }
1795  }
1796 }
1797 
1798 ////////////////////////////////////////////////////////////////////////////////
1799 /// Called at the end of a loop on a TTree.
1800 
1802 {
1803  if (fNfill) TakeAction();
1804 
1805  if ((fSelectedRows == 0) && (TestBit(kCustomHistogram) == 0)) fDraw = 1; // do not draw
1806 
1808 }
const int ndata
virtual const char * GetOption() const
Definition: TSelector.h:65
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition: TAxis.cxx:444
virtual void InitArrays(Int_t newsize)
Initialization of the primitive type arrays if the new size is bigger than the available space...
virtual void Enter(Long64_t entry)
Enter element entry into the list.
Definition: TEventList.cxx:191
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title Offset is a correction factor with respect to the "s...
Definition: TAttAxis.cxx:262
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:40
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:36
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:49
TList * GetListOfFunctions() const
Definition: TH1.h:248
An array of TObjects.
Definition: TObjArray.h:39
virtual void Terminate()
Called at the end of a loop on a TTree.
float xmin
Definition: THbookFile.cxx:93
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 ...
long long Long64_t
Definition: RtypesCore.h:69
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:399
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:488
UInt_t GetNbits() const
Definition: TBits.h:141
Ssiz_t Length() const
Definition: TString.h:390
A list of entries and subentries in a TTree or TChain.
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
Definition: TH1.cxx:8008
tomato 3-D histogram with a float per channel (see TH1 documentation)}
Definition: TH3.h:271
virtual Double_t * GetRmax()=0
virtual Bool_t Sync()
Synchronize all the formulae.
TEventList * GetEventList() const
Definition: TTree.h:402
virtual void SetEstimate(Long64_t n)
Set number of entries to estimate variable limits.
Double_t ** fVal
Definition: TSelectorDraw.h:57
virtual Long64_t GetReadEntry() const
Definition: TTree.h:435
float ymin
Definition: THbookFile.cxx:93
TTreeFormulaManager * GetManager() const
Definition: TTreeFormula.h:185
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
TTreeFormula ** fVar
Definition: TSelectorDraw.h:39
TEntryListArray * fTreeElistArray
Definition: TSelectorDraw.h:43
TTreeFormula * GetVar(Int_t i) const
Return the TTreeFormula corresponding to the i-th component of the request formula (where the compone...
R__EXTERN TStyle * gStyle
Definition: TStyle.h:418
virtual Int_t GetDimension() const
Definition: TH1.h:287
virtual void ProcessFill(Long64_t entry)
Called in the entry loop for all entries accepted by Select.
virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax)
Redefine x axis parameters.
Definition: TH1.cxx:7838
virtual TEntryList * GetEntryList()
Returns the entry list, set to this tree.
Definition: TTree.cxx:5376
Int_t fAction
Pointer to previously used histogram.
Definition: TSelectorDraw.h:45
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:302
virtual Bool_t Enter(Long64_t entry, TTree *tree, Long64_t subentry)
Add entry #entry (, #subentry) to the list.
UInt_t FirstSetBit(UInt_t startBit=0) const
Return position of first non null bit (starting from position 0 and up)
Definition: TBits.cxx:345
Bool_t * fVarMultiple
[fSelectedRows]Local buffer for weights
Definition: TSelectorDraw.h:60
See TView3D.
Definition: TView.h:29
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:400
TTreeFormulaManager * fManager
Definition: TSelectorDraw.h:41
static THLimitsFinder * GetLimitsFinder()
Return pointer to the current finder.
#define gROOT
Definition: TROOT.h:364
virtual TObject * Remove(TObject *obj)
Remove object from array.
Definition: TObjArray.cxx:653
virtual void TakeAction()
Execute action for object obj fNfill times.
Basic string class.
Definition: TString.h:137
virtual TClass * EvalClass(Int_t oper) const
Evaluate the class of the operation oper.
virtual Int_t GetNdim() const
Definition: TFormula.h:243
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1089
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition: TAxis.cxx:526
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:255
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:44
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
Int_t * fNbins
Definition: TSelectorDraw.h:53
virtual void * EvalObject(Int_t i=0)
Evaluate this treeformula.
Profile Historam.
Definition: TProfile.h:34
const char * Class
Definition: TXMLSetup.cxx:64
virtual Long64_t GetEstimate() const
Definition: TTree.h:396
Long64_t fCurrentSubEntry
Definition: TSelectorDraw.h:64
virtual Int_t FindGoodLimits(TH1 *h, Double_t xmin, Double_t xmax)
compute the best axis limits for the X axis.
Int_t GetN() const
Definition: TGraph.h:133
TH1 * fOldHistogram
pointer to Tree Event list array
Definition: TSelectorDraw.h:44
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 void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:747
Iterator of linked list.
Definition: TList.h:187
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:739
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition: TH1.cxx:6375
virtual Long64_t GetChainOffset() const
Definition: TTree.h:386
if object in a list can be deleted
Definition: TObject.h:63
Int_t fValSize
[fSelectedRows][fDimension] Local buffer for the variables
Definition: TSelectorDraw.h:58
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
Definition: TEnv.cxx:751
virtual Int_t GetMultiplicity() const
virtual TEntryListArray * GetSubListForEntry(Long64_t entry, TTree *tree=0)
Return the list holding the subentries for the given entry or 0.
const char * Data() const
Definition: TString.h:349
Int_t Fill(const Double_t *v)
Definition: TProfile2D.h:54
Used to coordinate one or more TTreeFormula objects.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2335
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:43
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
Definition: TStyle.cxx:801
std::vector< std::vector< double > > Data
TString fOption
Option given to TTree::Process.
Definition: TSelector.h:47
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:925
Double_t fWeight
[fDimension] Maxima of varexp columns
Definition: TSelectorDraw.h:56
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition: TH1.cxx:2899
TH1F * h1
Definition: legend1.C:5
Double_t GetXmin() const
Definition: TAxis.h:139
TTreeFormula * fSelect
[fDimension] Array of pointers to variables formula
Definition: TSelectorDraw.h:40
The 3-D histogram classes derived from the 1-D histogram classes.
Definition: TH3.h:35
virtual Float_t GetTitleOffset() const
Definition: TAttAxis.h:47
Used to pass a selection expression to the Tree drawing routine.
Definition: TTreeFormula.h:64
A specialized string object used for TTree selections.
Definition: TCut.h:27
TObject * UncheckedAt(Int_t i) const
Definition: TObjArray.h:91
Int_t fMultiplicity
Total number of histogram fills.
Definition: TSelectorDraw.h:48
TObject * fObject
! Current object if processing object (vs. TTree)
Definition: TSelector.h:48
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:46
don&#39;t draw stats box
Definition: TH1.h:172
virtual void Delete(Option_t *option="")
Delete this object.
Definition: TObject.cxx:229
virtual void Begin(TTree *tree)
Called every time a loop on the tree(s) starts.
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition: TAttMarker.h:38
float ymax
Definition: THbookFile.cxx:93
virtual Bool_t Notify()
This function is called at the first entry of a new tree in a chain.
TObject * fTreeElist
Definition: TSelectorDraw.h:42
virtual void SetEstimate(Long64_t nentries=1000000)
Set number of entries to estimate variable limits.
Definition: TTree.cxx:8426
Service class for 2-Dim histogram classes.
Definition: TH2.h:36
Class to manage histogram axis.
Definition: TAxis.h:36
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2853
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:42
Int_t GetNbins() const
Definition: TAxis.h:127
virtual void SetStatus(Long64_t status)
Definition: TSelector.h:74
virtual void Abort(const char *why, EAbort what=kAbortProcess)
Abort processing.
Definition: TSelector.cxx:116
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:514
virtual ~TSelectorDraw()
Selector destructor.
tomato 2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:255
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:496
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:35
virtual Bool_t CompileVariables(const char *varexp="", const char *selection="")
Compile input variables and selection expression.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2322
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:159
Double_t * fVmin
[fDimension] Number of bins per dimension
Definition: TSelectorDraw.h:54
virtual void UpdateFormulaLeaves()
This function is called TTreePlayer::UpdateFormulaLeaves, itself called by TChain::LoadTree when a ne...
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:33
TLine * l
Definition: textangle.C:4
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:45
TAxis * GetYaxis()
Definition: TH1.h:325
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH3.cxx:280
float xmax
Definition: THbookFile.cxx:93
void SetName(const char *name)
Definition: TCollection.h:116
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:39
Definition: graph.py:1
virtual Int_t Contains(Long64_t entry, TTree *tree=0)
Definition: TEntryList.cxx:519
virtual void Draw(Option_t *option="")
Draws 3-D polymarker with its current attributes.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
Definition: TObjArray.cxx:239
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:46
virtual Double_t * GetRmin()=0
TGraphErrors * gr
Definition: legend1.C:25
Long64_t fDraw
Action type.
Definition: TSelectorDraw.h:46
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
Definition: TStyle.cxx:735
A specialized TSelector for TTree::Draw.
Definition: TSelectorDraw.h:33
const Int_t kCustomHistogram
Long64_t fSelectedRows
Definition: TSelectorDraw.h:50
void SetPoint(Int_t n, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
Bool_t fCleanElist
Definition: TSelectorDraw.h:62
#define ClassImp(name)
Definition: Rtypes.h:279
virtual void ResetAbort()
Definition: TSelector.h:81
virtual void SetEntryList(TEntryList *list, Option_t *opt="")
Set an EntryList.
Definition: TTree.cxx:8362
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:416
double Double_t
Definition: RtypesCore.h:55
Bool_t fSelectMultiple
[fDimension] true if fVar[i] has a variable index
Definition: TSelectorDraw.h:61
virtual Int_t GetUpdate() const
Definition: TTree.h:446
Double_t * fVmax
[fDimension] Minima of varexp columns
Definition: TSelectorDraw.h:55
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
virtual void ProcessFillMultiple(Long64_t entry)
Called in the entry loop for all entries accepted by Select.
unsigned long ULong_t
Definition: RtypesCore.h:51
Double_t GetXmax() const
Definition: TAxis.h:140
virtual void ProcessFillObject(Long64_t entry)
Called in the entry loop for all entries accepted by Select.
The TH1 histogram class.
Definition: TH1.h:80
virtual TTree * GetTree() const
Definition: TTree.h:443
Double_t * fW
Definition: TSelectorDraw.h:59
T EvalInstance(Int_t i=0, const char *stringStack[]=0)
Evaluate this treeformula.
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry #entry to the list.
Definition: TEntryList.cxx:560
Profile2D histograms are used to display the mean value of Z and its RMS for each cell in X...
Definition: TProfile2D.h:31
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:48
#define BIT(n)
Definition: Rtypes.h:120
static TView * CreateView(Int_t system=1, const Double_t *rmin=0, const Double_t *rmax=0)
Create a concrete default 3-d view via the plug-in manager.
Definition: TView.cxx:36
THist< 3, float, THistStatContent, THistStatUncertainty > TH3F
Definition: THist.hxx:314
TAxis * GetZaxis()
Definition: TH1.h:326
virtual UInt_t SetCanExtend(UInt_t extendBitMask)
Make the histogram axes extendable / not extendable according to the bit mask returns the previous bi...
Definition: TH1.cxx:5930
virtual Int_t GetIndex(Long64_t entry) const
Return index in the list of element with value entry array is supposed to be sorted prior to this cal...
Definition: TEventList.cxx:235
Mother of all ROOT objects.
Definition: TObject.h:44
Container of bits.
Definition: TBits.h:33
Long64_t fOldEstimate
Definition: TSelectorDraw.h:51
virtual void TakeEstimate()
Estimate limits for 1-D, 2-D or 3-D objects.
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition: TAttMarker.h:36
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition: TGraph.cxx:2150
A 3D polymarker.
Definition: TPolyMarker3D.h:40
TList * fInput
List of objects available during processing.
Definition: TSelector.h:49
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:405
void FillN(Int_t, const Double_t *, const Double_t *, Int_t)
Fill this histogram with an array x and weights w.
Definition: TProfile.h:64
virtual void Add(TObject *obj)
Definition: TList.h:81
virtual void Reset()
Reset this list.
virtual void FillN(Int_t ntimes, const Double_t *x, const Double_t *w, Int_t stride=1)
Fill this histogram with an array x and weights w.
Definition: TH1.cxx:3230
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition: TH1.cxx:8087
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
virtual Bool_t GetReapplyCut() const
Definition: TEntryList.h:81
Int_t fNfill
Last entry loop number when object was drawn.
Definition: TSelectorDraw.h:47
virtual Bool_t CanExtendAllAxes() const
Returns true if all axes are extendable.
Definition: TH1.cxx:5917
#define gPad
Definition: TVirtualPad.h:289
virtual void ClearFormula()
Delete internal buffers.
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
virtual UInt_t SplitNames(const TString &varexp, std::vector< TString > &names)
Build Index array for names in varexp.
Definition: tree.py:1
virtual void SetEntries(Double_t n)
Definition: TH1.h:387
A TTree object has a header with a name and a title.
Definition: TTree.h:98
#define gDirectory
Definition: TDirectory.h:221
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition: TColor.cxx:1048
void SetQuickLoad(Bool_t quick)
Definition: TTreeFormula.h:203
void ResetBit(UInt_t f)
Definition: TObject.h:158
virtual Double_t GetWeight() const
Definition: TTree.h:469
virtual Int_t GetNdata(Bool_t forceLoadDim=kFALSE)
Return number of available instances in the formulas.
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition: TAttMarker.h:37
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:292
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:41
virtual Int_t GetMultiplicity() const
Definition: TTreeFormula.h:187
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:460
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
THist< 2, float, THistStatContent, THistStatUncertainty > TH2F
Definition: THist.hxx:308
virtual void SetEditable(Bool_t editable=kTRUE)
if editable=kFALSE, the graph cannot be modified with the mouse by default a TGraph is editable ...
Definition: TGraph.cxx:2123
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:27
Int_t GetMultiplicity() const
Definition: TSelectorDraw.h:85
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8058
virtual void ResetLoading()
Tell the formula that we are going to request a new entry.
TAxis * GetXaxis()
Definition: TH1.h:324
virtual Int_t GetLastPoint() const
Definition: TPolyMarker3D.h:64
virtual void Reset(Option_t *option="")
Reset number of entries in event list.
Definition: TEventList.cxx:328
virtual void SetAxis(TAxis *axis=0)
Set the axis (in particular get the type).
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:911