Logo ROOT   6.18/05
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
15A list of entries and subentries in a TTree or TChain.
16
17TEntryListArray is an extension of TEntryList, used to hold selected entries and
18subentries (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~~~
32Its main purpose is to improve the performance of a code that needs to apply
33complex cuts on TTree::Draw multiple times. After the first call above to
34TTree::Draw, a TEntryListArray is created and filled with the entries and the
35indices of the arrays that satisfied the selection cut (x > 0). In the subsequent
36calls to TTree::Draw, only these entries / subentries are used to fill histograms.
37
38## About the class
39
40The class derives from TEntryList and can be used basically in the same way.
41This same class is used to keep entries and subentries, so there are two types of
42TEntryListArray's:
43
441. The ones that only hold subentries
45 - fEntry is set to the entry# for which the subentries correspond
46 - fSubLists must be 0
472. 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
541. 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)
602. Public methods:
61 - Contains, Enter and Remove with subentry as argument
62 - GetSubListForEntry: to return the sublist corresponding to the given entry
633. 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;
88 fSubListIter = 0;
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// Default c-tor
93
94TEntryListArray::TEntryListArray() : TEntryList(), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
95{
96}
97
98////////////////////////////////////////////////////////////////////////////////
99/// c-tor with name and title
100
101TEntryListArray::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
108TEntryListArray::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
115TEntryListArray::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
122TEntryListArray::TEntryListArray(const TTree *tree) : TEntryList(tree), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
123{
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Copy c-tor
128
129TEntryListArray::TEntryListArray(const TEntryListArray &elist) : TEntryList(), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
130{
131 fEntry = elist.fEntry;
132 Add(&elist);
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// c-tor, from TEntryList
137
138TEntryListArray::TEntryListArray(const TEntryList& elist) : TEntryList(elist), fSubLists(0), fEntry(-1), fLastSubListQueried(0), fSubListIter(0)
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
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) {
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///
266/// entry is recomputed from the treeoffset information of the chain
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
271{
272
273
274 if (tree) {
275 Long64_t localentry = tree->LoadTree(entry);
276 SetTree(tree->GetTree());
277 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
278 if (currentArray) {
279 return currentArray->Contains(localentry, 0, subentry);
280 }
281 return 0;
282 }
283 // tree = 0
284 Int_t result = TEntryList::Contains(entry);
285 if (result && fSubLists) {
287 if (t) {
288 result = t->TEntryList::Contains(subentry);
289 }
290 }
291 return result;
292}
293
294////////////////////////////////////////////////////////////////////////////////
295/// Create a TEntryListArray based on the given TEntryList
296/// Called by SetTree when the given list is added to fLists
297/// Replace it by a TEntryListArray and delete the given list
298
300{
301 // TODO: Keep the blocks and the number of entries to transfer without copying?
302 // TObjArray *blocks = e->fBlocks;
303 // Int_t NBlocks = e->fNBlocks;
304 // Long64_t N = e->fN;
305 // e->fBlocks = 0;
306 // e->fNBlocks = 0;
307 // e->fN = 0;
308
309 TEntryListArray *earray = new TEntryListArray(*e);
310// earray->fBlocks = blocks;
311// earray->fNBlocks = NBlocks;
312// earray->fN = N;
313
314 if (e == fCurrent) {
315 fCurrent = earray;
316 }
317 // If the list has just been splitted, earray will be the first one
318 // and must keep the current sublists
319 if (fSubLists) {
320 earray->fSubLists = fSubLists;
321 fSubLists = 0;
322 }
323 if (e == fLists->First()) {
324 fLists->AddFirst(earray);
325 } else {
326 fLists->Add(earray);
327 }
328 fLists->Remove(e);
329 delete e;
330 e = 0;
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Add entry \#entry (, \#subentry) to the list
335/// - When tree = 0, adds to the current list
336/// - When tree != 0, finds the list corresponding to this tree (or add a new one)
337/// - When tree is a chain, the entry is assumed to be global index and the local
338/// entry is recomputed from the treeoffset information of the chain
339
341{
342 //When subentry = -1, add all subentries (remove the sublist if it exists)
343 //When subentry != -1 and the entry is not present,
344 //add only the given subentry, creating a TEntryListArray to hold the subentries for the given entry
345 //Return true only if the entry is new (not the subentry)
346
347 Bool_t result = 0;
348
349 if (tree) {
350 Long64_t localentry = tree->LoadTree(entry);
351 SetTree(tree->GetTree());
352 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
353 if (currentArray) {
354 if ((result = currentArray->Enter(localentry, 0, subentry)))
355 if (fLists) ++fN;
356 }
357 return result;
358 }
359 if (fLists) {
361 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
362 if (currentArray && (result = currentArray->Enter(entry, 0, subentry))) {
363 ++fN;
364 }
365 return result;
366 }
367 // tree = 0 && !fLists
368 // Sub entries were already present ?
370 if (t) { // Sub entries were already present
371 if (subentry != -1) {
372 t->TEntryList::Enter(subentry);
373 } else { // remove the sub entries
374 RemoveSubList(t);
375 }
376 } else {
377 result = TEntryList::Enter(entry);
378 if (subentry != -1 && result) { // a sub entry was given and the entry was not present
379 t = SetEntry(entry);
380 if (t) t->TEntryList::Enter(subentry);
381 }
382 }
383 return result;
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// Return the list holding the subentries for the given entry or 0
388
390{
391 if (tree) {
392 Long64_t localentry = tree->LoadTree(entry);
393 SetTree(tree->GetTree());
394 if (fCurrent) {
395 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
396 if (currentArray) {
397 return currentArray->GetSubListForEntry(localentry);
398 }
399 }
400 return 0;
401 }
402 // tree = 0
403
404 if (!fSubLists || !fSubLists->GetEntries()) {
405 return 0;
406 }
407
408 if (!fSubListIter) {
411 }
412 else if (!fLastSubListQueried || entry < fLastSubListQueried->fEntry) {
413 // Restart the loop: fLastSubListQueried should point to the newest entry
414 // or where we stoped the last search
415 // (it is 0 only if we reached the end of the loop)
418 }
419
420 if (entry == fLastSubListQueried->fEntry) {
421 return fLastSubListQueried;
422 }
423
425 if (fLastSubListQueried->fEntry == entry) {
426 return fLastSubListQueried;
427 }
428 if (fLastSubListQueried->fEntry > entry) {
429 break;
430 }
431 }
432 return 0;
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Print this list
437/// - option = "" - default - print the name of the tree and file
438/// - option = "all" - print all the entry numbers
439/// - option = "subentries" - print all the entry numbers and associated subentries
440
441void TEntryListArray::Print(const Option_t* option) const
442{
443 TString opt = option;
444 opt.ToUpper();
445 Bool_t new_line = !opt.Contains("EOL");
446
447 if (!opt.Contains("S") && new_line) {
448 TEntryList::Print(option);
449 return;
450 }
451
452 if (fLists) {
453 TIter next(fLists);
454 TEntryListArray *e = 0;
455 while ((e = (TEntryListArray*)next())) {
456 std::cout << e->fTreeName << ":" << std::endl;
457 e->Print(option);
458 }
459 return;
460 }
461
462 // Print all subentries
463 TEntryListArray *tmp = const_cast<TEntryListArray *>(this);
464 TIter next(fSubLists);
466 for (Int_t i = 0; i < tmp->fN; ++i) {
467 Long64_t entry = tmp->GetEntry(i);
468 std::cout << entry << " ";
469 if (fSubLists) {
470 std::cout << " : ";
471 }
472 if (e && e->fEntry == entry) {
473 e->Print("all,EOL");
474 e = (TEntryListArray*)next();
475 }
476 if (new_line) {
477 std::cout << std::endl;
478 }
479 }
480}
481
482////////////////////////////////////////////////////////////////////////////////
483/// Remove entry \#entry (, \#subentry) from the list
484/// - When tree = 0, removes from the current list
485/// - When tree != 0, finds the list, corresponding to this tree
486/// - When tree is a chain, the entry is assumed to be global index and the local
487/// entry is recomputed from the treeoffset information of the chain
488///
489/// If subentry != -1, only the given subentry is removed
490
492{
493 Bool_t result = 0;
494
495 if (tree) {
496 Long64_t localentry = tree->LoadTree(entry);
497 SetTree(tree->GetTree());
498 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
499 if (currentArray && (result = currentArray->Remove(localentry, 0, subentry))) {
500 if (fLists) {
501 --fN;
502 }
503 }
504 return result;
505 }
506 if (fLists) {
508 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
509 if (currentArray && (result = currentArray->Remove(entry, 0, subentry)) && fLists) {
510 --fN;
511 }
512 return result;
513 }
514
515 // tree = 0 && !fLists
517 if (e) {
518 if (subentry != -1) {
519 e->TEntryList::Remove(subentry);
520 }
521 if (subentry == -1 || !e->GetN()) {
523 return TEntryList::Remove(entry);
524 }
525 } else if (subentry == -1) {
526 return TEntryList::Remove(entry);
527 }
528 return 0;
529}
530
531////////////////////////////////////////////////////////////////////////////////
532/// Remove the given sublist and return true if succeeded
533
535{
536 if (!e) return 0;
537 if (tree) {
538 SetTree(tree->GetTree());
539 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
540 if (currentArray) {
541 return currentArray->RemoveSubList(e);
542 }
543 }
544
545 if (!fSubLists->Remove(e)) {
546 return 0;
547 }
548 // fSubLists->Sort(); --> for TObjArray
549 delete e;
550 e = 0;
551 if (!fSubLists->GetEntries()) {
552 delete fSubLists;
553 fSubLists = 0;
554 }
555 return 1;
556}
557
558////////////////////////////////////////////////////////////////////////////////
559/// Remove the sublists for the given entry --> not being used...
560
562{
563 if (tree) {
564 Long64_t localentry = tree->LoadTree(entry);
565 SetTree(tree->GetTree());
566 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
567 if (currentArray) {
568 return currentArray->RemoveSubListForEntry(localentry);
569 }
570 }
571 return RemoveSubList(GetSubListForEntry(entry));
572}
573
574////////////////////////////////////////////////////////////////////////////////
575/// Reset all entries and remove all sublists
576
578{
580 if (fSubLists) {
581 if (!((TEntryListArray*)fSubLists->First())->GetDirectory()) {
582 fSubLists->Delete();
583 }
584 delete fSubLists;
585 }
586 delete fSubListIter;
587 Init();
588}
589
590////////////////////////////////////////////////////////////////////////////////
591/// Create a sublist for the given entry and returns it --> should be called
592/// after calling GetSubListForEntry
593
595{
596 if (entry < 0) return 0;
597
598 // If tree is given, switch to the list that contains tree
599 if (tree) {
600 Long64_t localentry = tree->LoadTree(entry);
601 SetTree(tree->GetTree());
602 TEntryListArray *currentArray = dynamic_cast<TEntryListArray*>(fCurrent);
603 if (currentArray) {
604 return currentArray->SetEntry(localentry);
605 }
606 return 0;
607 }
608 // tree = 0
609 if (!fSubLists) {
610 fSubLists = new TList();
611 }
612 TEntryListArray *newlist = new TEntryListArray();
613 newlist->fEntry = entry;
616 fSubListIter->Reset(); // Reset the iterator to avoid missing the entry next to the new one (bug in TIter?)
617 } else {
618 fSubLists->AddLast(newlist);
619 }
620 fLastSubListQueried = newlist;
621 return newlist;
622}
623
624////////////////////////////////////////////////////////////////////////////////
625/// Remove all the entries (and subentries) of this entry list that are contained
626/// in elist.
627/// If for a given entry present in both lists, one has subentries and the other
628/// does not, the whole entry is removed
629
631{
632 if (!elist) return;
633
634 if (fLists) { // This list is splitted
635 TEntryListArray* e = 0;
636 TIter next(fLists);
637 fN = 0; // reset fN to set it to the sum of fN in each list
638 while ((e = (TEntryListArray*) next())) {
639 e->Subtract(elist);
640 fN += e->GetN();
641 }
642 } else if (elist->GetLists()) { // The other list is splitted
643 TIter next(elist->GetLists());
644 TEntryList *e = 0;
645 while ((e = (TEntryList*) next())) {
646 Subtract(e);
647 }
648 } else { // None of the lists are splitted
649 if (strcmp(elist->GetTreeName(), fTreeName.Data()) || strcmp(elist->GetFileName(), fFileName.Data()))
650 return; // Lists are for different trees
651 const TEntryListArray *elist_array = dynamic_cast< const TEntryListArray *>(elist);
652 if (!fSubLists || !elist_array || !elist_array->GetSubLists()) { // there are no sublists in one of the lists
654 if (fSubLists) {
655 TEntryListArray *e = 0;
656 TIter next(fSubLists);
657 while ((e = (TEntryListArray*) next())) {
658 if (!Contains(e->fEntry))
660 }
661 }
662 } else { // Both lists have subentries, will have to loop over them
663 TEntryListArray *el1, *el2;
664 TIter next1(fSubLists);
665 TIter next2(elist_array->GetSubLists());
666 el1 = (TEntryListArray*) next1();
667 el2 = (TEntryListArray*) next2();
668
669 Long64_t n2 = elist->GetN();
670 Long64_t entry;
671 for (Int_t i = 0; i < n2; ++i) {
672 entry = (const_cast<TEntryList*>(elist))->GetEntry(i);
673 // Try to find the sublist for this entry in list
674 while (el1 && el1->fEntry < entry) { // && el2
675 el1 = (TEntryListArray*) next1();
676 }
677 while (el2 && el2->fEntry < entry) { // && el1
678 el2 = (TEntryListArray*) next2();
679 }
680
681 if (el1 && el2 && entry == el1->fEntry && entry == el2->fEntry) { // both lists have sublists for this entry
682 el1->Subtract(el2);
683 if (!el1->fN) {
684 Remove(entry);
685 }
686 } else {
687 Remove(entry);
688 }
689 }
690 }
691 }
692}
693
694////////////////////////////////////////////////////////////////////////////////
695/// If a list for a tree with such name and filename exists, sets it as the current sublist
696/// If not, creates this list and sets it as the current sublist
697
698void TEntryListArray::SetTree(const char *treename, const char *filename)
699{
700 // ! the filename is taken as provided, no extensions to full path or url !
701
702 // 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
703
704 Int_t nLists = -1;
705 if (fLists) {
706 nLists = fLists->GetEntries();
707 }
708 TEntryList::SetTree(treename, filename);
709 if (fLists && fLists->GetEntries() != nLists) { // fList was created and/or has new additions
710 if (nLists == -1) {
711 // The list has just been splitted (fList was created)
712 // There should be two TEntryLists in fLists:
713 // must convert both to TEntryListArray
714 // and transfer the sublists to the first one
716 }
718 }
719}
#define e(i)
Definition: RSha256.hxx:103
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
Collection abstract base class.
Definition: TCollection.h:63
virtual Int_t GetEntries() const
Definition: TCollection.h:177
A list of entries and subentries in a TTree or TChain.
virtual Bool_t RemoveSubListForEntry(Long64_t entry, TTree *tree=0)
Remove the sublists for the given entry --> not being used...
virtual ~TEntryListArray()
d-tor
virtual void Reset()
Reset all entries and remove all sublists.
void Init()
Initialize data members, called by Reset.
virtual Bool_t Remove(Long64_t entry, TTree *tree, Long64_t subentry)
Remove entry #entry (, #subentry) from the list.
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,...
TEntryListArray * fLastSubListQueried
! last sublist checked by GetSubListForEntry
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 Bool_t RemoveSubList(TEntryListArray *e, TTree *tree=0)
Remove the given sublist and return true if succeeded.
TEntryListArray()
Default c-tor.
virtual void Add(const TEntryList *elist)
Add 2 entry lists.
virtual void ConvertToTEntryListArray(TEntryList *e)
Create a TEntryListArray based on the given TEntryList Called by SetTree when the given list is added...
virtual void Print(const Option_t *option="") const
Print this list.
Long64_t fEntry
the entry number, when the list is used for subentries
virtual TList * GetSubLists() const
virtual Int_t Contains(Long64_t entry, TTree *tree, Long64_t subentry)
virtual Bool_t Enter(Long64_t entry, TTree *tree, Long64_t subentry)
Add entry #entry (, #subentry) to the list.
TList * fSubLists
a list of underlying entry lists for each event of a TEntryList
virtual void AddEntriesAndSubLists(const TEntryList *elist)
The method that really adds two entry lists with sublists If lists are splitted (fLists !...
TIter * fSubListIter
! to iterate over fSubLists and keep last one checked
virtual void Subtract(const TEntryList *elist)
Remove all the entries (and subentries) of this entry list that are contained in elist.
virtual TEntryListArray * GetSubListForEntry(Long64_t entry, TTree *tree=0)
Return the list holding the subentries for the given entry or 0.
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:26
TString fFileName
name of the file, where the tree is
Definition: TEntryList.h:39
virtual TList * GetLists() const
Definition: TEntryList.h:73
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,...
virtual Int_t Contains(Long64_t entry, TTree *tree=0)
Definition: TEntryList.cxx:517
Long64_t fN
number of entries in the list
Definition: TEntryList.h:36
virtual void Reset()
Reset this list.
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry #entry to the list.
Definition: TEntryList.cxx:558
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 const char * GetTreeName() const
Definition: TEntryList.h:76
TEntryList * fCurrent
! currently filled entry list
Definition: TEntryList.h:32
virtual void Print(const Option_t *option="") const
Print this list.
Definition: TEntryList.cxx:997
virtual Bool_t Remove(Long64_t entry, TTree *tree=0)
Remove entry #entry from the list.
Definition: TEntryList.cxx:613
TList * fLists
a list of underlying entry lists for each tree of a chain
Definition: TEntryList.h:31
TString fTreeName
name of the tree
Definition: TEntryList.h:38
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:766
virtual void Subtract(const TEntryList *elist)
Remove all the entries of this entry list, that are contained in elist.
virtual void Add(const TEntryList *elist)
Add 2 entry lists.
Definition: TEntryList.cxx:343
virtual Long64_t GetN() const
Definition: TEntryList.h:75
TObject * Next()
Definition: TCollection.h:249
void Reset()
Definition: TCollection.h:252
A doubly linked list.
Definition: TList.h:44
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:819
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
Definition: TList.cxx:97
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:690
virtual void AddBefore(const TObject *before, TObject *obj)
Insert object before object before in the list.
Definition: TList.cxx:193
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:656
virtual void AddLast(TObject *obj)
Add object at the end of the list.
Definition: TList.cxx:149
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1138
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
A TTree represents a columnar dataset.
Definition: TTree.h:71
Definition: tree.py:1