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