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