ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TEntryListArray.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Bruno Lenzi 12/07/2011
3 
4 /*************************************************************************
5 * Copyright (C) 1995-2006, 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 TEntryListArray
13 A list of entries and subentries in a TTree or TChain.
14 
15 TEntryListArray is an extension of TEntryList, used to hold selected entries and
16 subentries (sublists) for when the user has a TTree with containers (vectors, arrays, ...).
17 
18 ## Usage with TTree::Draw to select entries and subentries
19 
20 ### To fill a list elist
21 ~~~ {.cpp}
22  tree->Draw(">> elist", "x > 0", "entrylistarray");`
23 ~~~
24 ### To use a list to select entries and subentries
25 ~~~ {.cpp}
26  tree->SetEntryList(elist);
27  tree->Draw("y");
28  tree->Draw("z");
29 ~~~
30 Its main purpose is to improve the performance of a code that needs to apply
31 complex cuts on TTree::Draw multiple times. After the first call above to
32 TTree::Draw, a TEntryListArray is created and filled with the entries and the
33 indices of the arrays that satisfied the selection cut (x > 0). In the subsequent
34 calls to TTree::Draw, only these entries / subentries are used to fill histograms.
35 
36 ## About the class
37 
38 The class derives from TEntryList and can be used basically in the same way.
39 This same class is used to keep entries and subentries, so there are two types of
40 TEntryListArray's:
41 
42 1. The ones that only hold subentries
43  - fEntry is set to the entry# for which the subentries correspond
44  - fSubLists must be 0
45 2. The ones that hold entries and eventually lists with subentries in fSubLists.
46  - fEntry = -1 for those
47  - If there are no sublists for a given entry, all the subentries will be used
48  in the selection
49 
50 ## Additions with respect to TEntryList
51 
52 1. Data members:
53  - fSubLists: a container to hold the sublists
54  - fEntry: the entry number if the list is used to hold subentries
55  - fLastSubListQueried and fSubListIter: a pointer to the last sublist queried
56  and an iterator to resume the loop from the last sublist queried (to speed up
57  selection and insertion in TTree::Draw)
58 2. Public methods:
59  - Contains, Enter and Remove with subentry as argument
60  - GetSubListForEntry: to return the sublist corresponding to the given entry
61 3. Protected methods:
62  - AddEntriesAndSubLists: called by Add when adding two TEntryList arrays with sublists
63  - ConvertToTEntryListArray: convert TEntryList to TEntryListArray
64  - RemoveSubList: to remove the given sublist
65  - RemoveSubListForEntry: to remove the sublist corresponding to the given entry
66  - SetEntry: to get / set a sublist for the given entry
67 */
68 
69 #include "TEntryListArray.h"
70 #include "TEntryListBlock.h"
71 #include "TTree.h"
72 #include "TFile.h"
73 #include "TSystem.h"
74 #include <iostream>
75 
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Initialize data members, called by Reset
80 
82 {
83  fSubLists = 0;
84  fEntry = -1;
85  fLastSubListQueried = 0;
86  fSubListIter = 0;
87 }
88 
89 ////////////////////////////////////////////////////////////////////////////////
90 /// Default c-tor
91 
92 TEntryListArray::TEntryListArray() : TEntryList(), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
93 {
94 }
95 
96 ////////////////////////////////////////////////////////////////////////////////
97 /// c-tor with name and title
98 
99 TEntryListArray::TEntryListArray(const char *name, const char *title): TEntryList(name, title), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
100 {
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 ///constructor with name and title, which also sets the tree
105 
106 TEntryListArray::TEntryListArray(const char *name, const char *title, const TTree *tree): TEntryList(name, title, tree), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
107 {
108 }
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 /// c-tor with name and title, which also sets the treename and the filename
112 
113 TEntryListArray::TEntryListArray(const char *name, const char *title, const char *treename, const char *filename): TEntryList(name, title, treename, filename), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
114 {
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// c-tor, which sets the tree
119 
120 TEntryListArray::TEntryListArray(const TTree *tree) : TEntryList(tree), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
121 {
122 }
123 
124 ////////////////////////////////////////////////////////////////////////////////
125 /// Copy c-tor
126 
127 TEntryListArray::TEntryListArray(const TEntryListArray &elist) : TEntryList(), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
128 {
129  fEntry = elist.fEntry;
130  Add(&elist);
131 }
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 /// c-tor, from TEntryList
135 
136 TEntryListArray::TEntryListArray(const TEntryList& elist) : TEntryList(elist), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
137 {
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// d-tor
142 
144 {
145  if (fSubLists) {
146  fSubLists->Delete();
147  delete fSubLists;
148  }
149  fSubLists = 0;
150  delete fSubListIter;
151  fSubListIter = 0;
152 }
153 
154 ////////////////////////////////////////////////////////////////////////////////
155 /// Add 2 entry lists
156 
158 {
159  if (!elist) return;
160 
161  if (fEntry != -1) {
162  TEntryList::Add(elist);
163  return;
164  }
165 
166  // Include in this list all the trees present in elist, so the sublists can be added
167  // This would happen in any case when calling TEntryList::Add
168  if (elist->GetLists()) { // the other list has lists to hold mutiple trees, add one by one
169  TIter next(elist->GetLists());
170  const TEntryList *e = 0;
171  while ((e = (const TEntryList*)next())) {
172  SetTree(e->GetTreeName(), e->GetFileName());
173  }
174  } else {
175  SetTree(elist->GetTreeName(), elist->GetFileName());
176  }
177 
178  AddEntriesAndSubLists(elist);
179 }
180 
181 ////////////////////////////////////////////////////////////////////////////////
182 /// The method that really adds two entry lists with sublists
183 /// If lists are splitted (fLists != 0), look for the ones whose trees match and call the method for those lists.
184 /// Add first the sublists, and then use TEntryList::Add to deal with the entries
185 
187 {
188  // WARNING: cannot call TEntryList::Add in the beginning:
189  // - Need to know which entries are present in each list when adding the sublists
190  // - TEL::Add is recursive, so it will call this guy after the first iteration
191 
192  // Add to the entries and sublists of this list, the ones from the other list
193  if (!elist) return;
194 
195  if (fLists) { // This list is splitted
196  TEntryListArray* e = 0;
197  TIter next(fLists);
198  fN = 0; // reset fN to set it to the sum of fN in each list
199  // Only need to do it here and the next condition will be called only from here
200  while ((e = (TEntryListArray*) next())) {
201  e->AddEntriesAndSubLists(elist);
202  fN += e->GetN();
203  }
204  } else if (elist->GetLists()) { // The other list is splitted --> will be called only from the previous if
205  TIter next(elist->GetLists());
206  TEntryList *e = 0;
207  while ((e = (TEntryList*) next())) {
209  }
210  } else { // None of the lists are splitted
211  if (strcmp(elist->GetTreeName(), fTreeName.Data()) || strcmp(elist->GetFileName(), fFileName.Data()))
212  return; // Lists are for different trees
213  const TEntryListArray *elist_array = dynamic_cast< const TEntryListArray *>(elist);
214  if (!fSubLists && (!elist_array || !elist_array->GetSubLists())) { // no sublists in neither
215  TEntryList::Add(elist);
216  return;
217  }
218  // Deal with the sublists: Loop over both fSubLists
219  // - If the sublists are for the same entry, Add the sublists
220  // - For sublists only in this list, check if entry is in elist, and remove the sublist if so
221  // - For sublists only in the other list, insert them in fSubLists
222  if (!fSubLists && elist_array->GetSubLists()) {
223  fSubLists = new TList();
224  }
225  TEntryListArray *el1;
226  const TEntryListArray *el2;
227  TCollection *other_sublists = 0;
228  if (elist_array) {
229  other_sublists = elist_array->GetSubLists();
230  }
231  TIter next1(fSubLists);
232  TIter next2(other_sublists); // should work even if elist->fSubLists is null
233 
234  for (el1 = (TEntryListArray*) next1(), el2 = (const TEntryListArray*) next2(); el1 || el2;) {
235  if (el1 && el2 && el1->fEntry == el2->fEntry) { // sublists for the same entry, Add them
236  el1->TEntryList::Add(el2);
237  el1 = (TEntryListArray*) next1();
238  el2 = (const TEntryListArray*) next2();
239  } else if (el1 && (!el2 || el1->fEntry < el2->fEntry)) { // el1->fEntry is not in elist->fSubLists
240  if ((const_cast<TEntryList*>(elist))->Contains(el1->fEntry)) {
241  RemoveSubList(el1);
242  }
243  el1 = (TEntryListArray*) next1();
244  } else { // el2->fEntry is not in fSubLists --> make a copy and add it
245  if (!Contains(el2->fEntry)) {
246  if (!el1) {
247  fSubLists->AddLast(new TEntryListArray(*el2));
248  } else {
249  fSubLists->AddBefore(el1, new TEntryListArray(*el2));
250  }
251  }
252  el2 = (const TEntryListArray*) next2();
253  }
254  }
255  TEntryList::Add(elist);
256  }
257 }
258 
259 ////////////////////////////////////////////////////////////////////////////////
260 /// - When tree = 0, returns from the current list
261 /// - When tree != 0, finds the list corresponding to this tree
262 /// - When tree is a chain, the entry is assumed to be global index and the local
263 /// entry is recomputed from the treeoffset information of the chain
264 
266 {
267  //When subentry != -1, return true if the enter is present and not splitted
268  //or if the subentry list is found and contains #subentry
269 
270  if (tree) {
271  Long64_t localentry = tree->LoadTree(entry);
272  SetTree(tree->GetTree());
273  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
274  if (currentArray) {
275  return currentArray->Contains(localentry, 0, subentry);
276  }
277  return 0;
278  }
279  // tree = 0
281  if (result && fSubLists) {
283  if (t) {
284  result = t->TEntryList::Contains(subentry);
285  }
286  }
287  return result;
288 }
289 
290 ////////////////////////////////////////////////////////////////////////////////
291 /// Create a TEntryListArray based on the given TEntryList
292 /// Called by SetTree when the given list is added to fLists
293 /// Replace it by a TEntryListArray and delete the given list
294 
296 {
297  // TODO: Keep the blocks and the number of entries to transfer without copying?
298  // TObjArray *blocks = e->fBlocks;
299  // Int_t NBlocks = e->fNBlocks;
300  // Long64_t N = e->fN;
301  // e->fBlocks = 0;
302  // e->fNBlocks = 0;
303  // e->fN = 0;
304 
305  TEntryListArray *earray = new TEntryListArray(*e);
306 // earray->fBlocks = blocks;
307 // earray->fNBlocks = NBlocks;
308 // earray->fN = N;
309 
310  if (e == fCurrent) {
311  fCurrent = earray;
312  }
313  // If the list has just been splitted, earray will be the first one
314  // and must keep the current sublists
315  if (fSubLists) {
316  earray->fSubLists = fSubLists;
317  fSubLists = 0;
318  }
319  if (e == fLists->First()) {
320  fLists->AddFirst(earray);
321  } else {
322  fLists->Add(earray);
323  }
324  fLists->Remove(e);
325  delete e;
326  e = 0;
327 }
328 
329 ////////////////////////////////////////////////////////////////////////////////
330 /// Add entry #entry (, #subentry) to the list
331 /// - When tree = 0, adds to the current list
332 /// - When tree != 0, finds the list corresponding to this tree (or add a new one)
333 /// - When tree is a chain, the entry is assumed to be global index and the local
334 /// entry is recomputed from the treeoffset information of the chain
335 
337 {
338  //When subentry = -1, add all subentries (remove the sublist if it exists)
339  //When subentry != -1 and the entry is not present,
340  //add only the given subentry, creating a TEntryListArray to hold the subentries for the given entry
341  //Return true only if the entry is new (not the subentry)
342 
343  Bool_t result = 0;
344 
345  if (tree) {
346  Long64_t localentry = tree->LoadTree(entry);
347  SetTree(tree->GetTree());
348  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
349  if (currentArray) {
350  if ((result = currentArray->Enter(localentry, 0, subentry)))
351  if (fLists) ++fN;
352  }
353  return result;
354  }
355  if (fLists) {
356  if (!fCurrent) fCurrent = (TEntryList*)fLists->First();
357  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
358  if (currentArray && (result = currentArray->Enter(entry, 0, subentry))) {
359  ++fN;
360  }
361  return result;
362  }
363  // tree = 0 && !fLists
364  // Sub entries were already present ?
366  if (t) { // Sub entries were already present
367  if (subentry != -1) {
368  t->TEntryList::Enter(subentry);
369  } else { // remove the sub entries
370  RemoveSubList(t);
371  }
372  } else {
373  result = TEntryList::Enter(entry);
374  if (subentry != -1 && result) { // a sub entry was given and the entry was not present
375  t = SetEntry(entry);
376  if (t) t->TEntryList::Enter(subentry);
377  }
378  }
379  return result;
380 }
381 
382 ////////////////////////////////////////////////////////////////////////////////
383 /// Return the list holding the subentries for the given entry or 0
384 
386 {
387  if (tree) {
388  Long64_t localentry = tree->LoadTree(entry);
389  SetTree(tree->GetTree());
390  if (fCurrent) {
391  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
392  if (currentArray) {
393  return currentArray->GetSubListForEntry(localentry);
394  }
395  }
396  return 0;
397  }
398  // tree = 0
399 
400  if (!fSubLists || !fSubLists->GetEntries()) {
401  return 0;
402  }
403 
404  if (!fSubListIter) {
407  }
408  else if (!fLastSubListQueried || entry < fLastSubListQueried->fEntry) {
409  // Restart the loop: fLastSubListQueried should point to the newest entry
410  // or where we stoped the last search
411  // (it is 0 only if we reached the end of the loop)
412  fSubListIter->Reset();
414  }
415 
416  if (entry == fLastSubListQueried->fEntry) {
417  return fLastSubListQueried;
418  }
419 
421  if (fLastSubListQueried->fEntry == entry) {
422  return fLastSubListQueried;
423  }
424  if (fLastSubListQueried->fEntry > entry) {
425  break;
426  }
427  }
428  return 0;
429 }
430 
431 ////////////////////////////////////////////////////////////////////////////////
432 /// Print this list
433 /// - option = "" - default - print the name of the tree and file
434 /// - option = "all" - print all the entry numbers
435 /// - option = "subentries" - print all the entry numbers and associated subentries
436 
437 void TEntryListArray::Print(const Option_t* option) const
438 {
439  TString opt = option;
440  opt.ToUpper();
441  Bool_t new_line = !opt.Contains("EOL");
442 
443  if (!opt.Contains("S") && new_line) {
444  TEntryList::Print(option);
445  return;
446  }
447 
448  if (fLists) {
449  TIter next(fLists);
450  TEntryListArray *e = 0;
451  while ((e = (TEntryListArray*)next())) {
452  std::cout << e->fTreeName << ":" << std::endl;
453  e->Print(option);
454  }
455  return;
456  }
457 
458  // Print all subentries
459  TEntryListArray *tmp = const_cast<TEntryListArray *>(this);
462  for (Int_t i = 0; i < tmp->fN; ++i) {
463  Long64_t entry = tmp->GetEntry(i);
464  std::cout << entry << " ";
465  if (fSubLists) {
466  std::cout << " : ";
467  }
468  if (e && e->fEntry == entry) {
469  e->Print("all,EOL");
470  e = (TEntryListArray*)next();
471  }
472  if (new_line) {
473  std::cout << std::endl;
474  }
475  }
476 }
477 
478 ////////////////////////////////////////////////////////////////////////////////
479 /// Remove entry #entry (, #subentry) from the list
480 /// - When tree = 0, removes from the current list
481 /// - When tree != 0, finds the list, corresponding to this tree
482 /// - When tree is a chain, the entry is assumed to be global index and the local
483 /// entry is recomputed from the treeoffset information of the chain
484 ///
485 /// If subentry != -1, only the given subentry is removed
486 
488 {
489  Bool_t result = 0;
490 
491  if (tree) {
492  Long64_t localentry = tree->LoadTree(entry);
493  SetTree(tree->GetTree());
494  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
495  if (currentArray && (result = currentArray->Remove(localentry, 0, subentry))) {
496  if (fLists) {
497  --fN;
498  }
499  }
500  return result;
501  }
502  if (fLists) {
503  if (!fCurrent) fCurrent = (TEntryList*)fLists->First();
504  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
505  if (currentArray && (result = currentArray->Remove(entry, 0, subentry)) && fLists) {
506  --fN;
507  }
508  return result;
509  }
510 
511  // tree = 0 && !fLists
513  if (e) {
514  if (subentry != -1) {
515  e->TEntryList::Remove(subentry);
516  }
517  if (subentry == -1 || !e->GetN()) {
518  RemoveSubList(e, tree);
519  return TEntryList::Remove(entry);
520  }
521  } else if (subentry == -1) {
522  return TEntryList::Remove(entry);
523  }
524  return 0;
525 }
526 
527 ////////////////////////////////////////////////////////////////////////////////
528 /// Remove the given sublist and return true if succeeded
529 
531 {
532  if (!e) return 0;
533  if (tree) {
534  SetTree(tree->GetTree());
535  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
536  if (currentArray) {
537  return currentArray->RemoveSubList(e);
538  }
539  }
540 
541  if (!fSubLists->Remove(e)) {
542  return 0;
543  }
544  // fSubLists->Sort(); --> for TObjArray
545  delete e;
546  e = 0;
547  if (!fSubLists->GetEntries()) {
548  delete fSubLists;
549  fSubLists = 0;
550  }
551  return 1;
552 }
553 
554 ////////////////////////////////////////////////////////////////////////////////
555 /// Remove the sublists for the given entry --> not being used...
556 
558 {
559  if (tree) {
560  Long64_t localentry = tree->LoadTree(entry);
561  SetTree(tree->GetTree());
562  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
563  if (currentArray) {
564  return currentArray->RemoveSubListForEntry(localentry);
565  }
566  }
567  return RemoveSubList(GetSubListForEntry(entry));
568 }
569 
570 ////////////////////////////////////////////////////////////////////////////////
571 /// Reset all entries and remove all sublists
572 
574 {
576  if (fSubLists) {
577  if (!((TEntryListArray*)fSubLists->First())->GetDirectory()) {
578  fSubLists->Delete();
579  }
580  delete fSubLists;
581  }
582  delete fSubListIter;
583  Init();
584 }
585 
586 ////////////////////////////////////////////////////////////////////////////////
587 /// Create a sublist for the given entry and returns it --> should be called
588 /// after calling GetSubListForEntry
589 
591 {
592  if (entry < 0) return 0;
593 
594  // If tree is given, switch to the list that contains tree
595  if (tree) {
596  Long64_t localentry = tree->LoadTree(entry);
597  SetTree(tree->GetTree());
598  TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
599  if (currentArray) {
600  return currentArray->SetEntry(localentry);
601  }
602  return 0;
603  }
604  // tree = 0
605  if (!fSubLists) {
606  fSubLists = new TList();
607  }
608  TEntryListArray *newlist = new TEntryListArray();
609  newlist->fEntry = entry;
610  if (fLastSubListQueried) {
612  fSubListIter->Reset(); // Reset the iterator to avoid missing the entry next to the new one (bug in TIter?)
613  } else {
614  fSubLists->AddLast(newlist);
615  }
616  fLastSubListQueried = newlist;
617  return newlist;
618 }
619 
620 ////////////////////////////////////////////////////////////////////////////////
621 /// Remove all the entries (and subentries) of this entry list that are contained
622 /// in elist.
623 /// If for a given entry present in both lists, one has subentries and the other
624 /// does not, the whole entry is removed
625 
627 {
628  if (!elist) return;
629 
630  if (fLists) { // This list is splitted
631  TEntryListArray* e = 0;
632  TIter next(fLists);
633  fN = 0; // reset fN to set it to the sum of fN in each list
634  while ((e = (TEntryListArray*) next())) {
635  e->Subtract(elist);
636  fN += e->GetN();
637  }
638  } else if (elist->GetLists()) { // The other list is splitted
639  TIter next(elist->GetLists());
640  TEntryList *e = 0;
641  while ((e = (TEntryList*) next())) {
642  Subtract(e);
643  }
644  } else { // None of the lists are splitted
645  if (strcmp(elist->GetTreeName(), fTreeName.Data()) || strcmp(elist->GetFileName(), fFileName.Data()))
646  return; // Lists are for different trees
647  const TEntryListArray *elist_array = dynamic_cast< const TEntryListArray *>(elist);
648  if (!fSubLists || !elist_array || !elist_array->GetSubLists()) { // there are no sublists in one of the lists
649  TEntryList::Subtract(elist);
650  if (fSubLists) {
651  TEntryListArray *e = 0;
653  while ((e = (TEntryListArray*) next())) {
654  if (!Contains(e->fEntry))
655  RemoveSubList(e);
656  }
657  }
658  } else { // Both lists have subentries, will have to loop over them
659  TEntryListArray *el1, *el2;
660  TIter next1(fSubLists);
661  TIter next2(elist_array->GetSubLists());
662  el1 = (TEntryListArray*) next1();
663  el2 = (TEntryListArray*) next2();
664 
665  Long64_t n2 = elist->GetN();
666  Long64_t entry;
667  for (Int_t i = 0; i < n2; ++i) {
668  entry = (const_cast<TEntryList*>(elist))->GetEntry(i);
669  // Try to find the sublist for this entry in list
670  while (el1 && el1->fEntry < entry) { // && el2
671  el1 = (TEntryListArray*) next1();
672  }
673  while (el2 && el2->fEntry < entry) { // && el1
674  el2 = (TEntryListArray*) next2();
675  }
676 
677  if (el1 && el2 && entry == el1->fEntry && entry == el2->fEntry) { // both lists have sublists for this entry
678  el1->Subtract(el2);
679  if (!el1->fN) {
680  Remove(entry);
681  }
682  } else {
683  Remove(entry);
684  }
685  }
686  }
687  }
688 }
689 
690 ////////////////////////////////////////////////////////////////////////////////
691 /// If a list for a tree with such name and filename exists, sets it as the current sublist
692 /// If not, creates this list and sets it as the current sublist
693 
694 void TEntryListArray::SetTree(const char *treename, const char *filename)
695 {
696  // ! the filename is taken as provided, no extensions to full path or url !
697 
698  // Uses the method from the base class: if the tree is new, the a new TEntryList will be created (and stored in fLists) and needs to be converted to a TEntryListArray
699 
700  Int_t nLists = -1;
701  if (fLists) {
702  nLists = fLists->GetEntries();
703  }
704  TEntryList::SetTree(treename, filename);
705  if (fLists && fLists->GetEntries() != nLists) { // fList was created and/or has new additions
706  if (nLists == -1) {
707  // The list has just been splitted (fList was created)
708  // There should be two TEntryLists in fLists:
709  // must convert both to TEntryListArray
710  // and transfer the sublists to the first one
712  }
714  }
715 }
virtual void AddEntriesAndSubLists(const TEntryList *elist)
The method that really adds two entry lists with sublists If lists are splitted (fLists != 0)...
virtual Int_t GetEntries() const
Definition: TCollection.h:92
virtual TEntryListArray * SetEntry(Long64_t entry, TTree *tree=0)
Create a sublist for the given entry and returns it –> should be called after calling GetSubListForEn...
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:405
long long Long64_t
Definition: RtypesCore.h:69
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
A list of entries and subentries in a TTree or TChain.
const char Option_t
Definition: RtypesCore.h:62
virtual void Print(const Option_t *option="") const
Print this list.
virtual Bool_t Enter(Long64_t entry, TTree *tree, Long64_t subentry)
Add entry entry (, #subentry) to the list.
virtual Int_t Contains(Long64_t entry, TTree *tree, Long64_t subentry)
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
Definition: TList.cxx:93
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1088
static const char * filename()
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void SetTree(const char *treename, const char *filename)
If a list for a tree with such name and filename exists, sets it as the current sublist If not...
TList * fLists
Definition: TEntryList.h:33
virtual void SetTree(const TTree *tree)
If a list for a tree with such name and filename exists, sets it as the current sublist If not...
void Reset()
Definition: TCollection.h:161
virtual void AddLast(TObject *obj)
Add object at the end of the list.
Definition: TList.cxx:137
void Init()
to iterate over fSubLists and keep last one checked
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
ClassImp(TEntryListArray) void TEntryListArray
Initialize data members, called by Reset.
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition: TTree.cxx:5785
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:118
virtual Bool_t RemoveSubList(TEntryListArray *e, TTree *tree=0)
Remove the given sublist and return true if succeeded.
virtual TList * GetSubLists() const
TEntryListArray()
Default c-tor.
A doubly linked list.
Definition: TList.h:47
virtual void Add(const TEntryList *elist)
Add 2 entry lists.
Definition: TEntryList.cxx:343
TString fTreeName
Definition: TEntryList.h:40
TEntryListArray * fLastSubListQueried
TThread * t[5]
Definition: threadsh1.C:13
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
TEntryList * fCurrent
Definition: TEntryList.h:34
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:675
TObject * Next()
Definition: TCollection.h:158
Collection abstract base class.
Definition: TCollection.h:48
virtual void Reset()
Reset all entries and remove all sublists.
virtual Long64_t GetEntry(Int_t index)
Return the number of the entry #index of this TEntryList in the TTree or TChain See also Next()...
Definition: TEntryList.cxx:653
virtual Bool_t Remove(Long64_t entry, TTree *tree, Long64_t subentry)
Remove entry entry (, #subentry) from the list.
Long64_t entry
virtual void AddBefore(const TObject *before, TObject *obj)
Insert object before object before in the list.
Definition: TList.cxx:173
virtual Int_t Contains(Long64_t entry, TTree *tree=0)
Definition: TEntryList.cxx:517
void GetFileName(const char *filename, TString &fn, Bool_t *=0)
To be able to re-localize the entry-list we identify the file by just the name and the anchor...
Definition: TEntryList.cxx:758
Long64_t fN
Definition: TEntryList.h:38
virtual void Subtract(const TEntryList *elist)
Remove all the entries (and subentries) of this entry list that are contained in elist.
virtual const char * GetTreeName() const
Definition: TEntryList.h:78
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:581
tuple tree
Definition: tree.py:24
TIter * fSubListIter
last sublist checked by GetSubListForEntry
virtual TTree * GetTree() const
Definition: TTree.h:436
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry entry to the list.
Definition: TEntryList.cxx:558
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual Long64_t GetN() const
Definition: TEntryList.h:77
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:557
typedef void((*Func_t)())
virtual TDirectory * GetDirectory() const
Definition: TEntryList.h:76
virtual void Add(TObject *obj)
Definition: TList.h:81
virtual ~TEntryListArray()
d-tor
virtual void Reset()
Reset this list.
virtual Bool_t Remove(Long64_t entry, TTree *tree=0)
Remove entry entry from the list.
Definition: TEntryList.cxx:613
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
A TTree object has a header with a name and a title.
Definition: TTree.h:98
double result[121]
TString fFileName
Definition: TEntryList.h:41
virtual void Print(const Option_t *option="") const
Print this list.
Definition: TEntryList.cxx:989
virtual void ConvertToTEntryListArray(TEntryList *e)
Create a TEntryListArray based on the given TEntryList Called by SetTree when the given list is added...
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:27
virtual void Subtract(const TEntryList *elist)
Remove all the entries of this entry list, that are contained in elist.
virtual Bool_t RemoveSubListForEntry(Long64_t entry, TTree *tree=0)
Remove the sublists for the given entry –> not being used...
virtual TList * GetLists() const
Definition: TEntryList.h:75
virtual void Add(const TEntryList *elist)
Add 2 entry lists.