Skip to content

Commit b41106e

Browse files
committed
[treeplayer] Explicitly add TEventList/TEntryList to gDirectory.
The TTree::Draw documentation states that entry lists and event lists are added to gDirectory. To make this fact independent of ROOT 7 mode, explicitly add instances of these classes to gDirectory. Also add a warning when trying to append to an existing list that can't be found in the current directory.
1 parent 745729a commit b41106e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tree/treeplayer/src/TSelectorDraw.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,16 @@ void TSelectorDraw::Begin(TTree *tree)
405405
return;
406406
}
407407
if (!enlist) {
408+
if (hnameplus) {
409+
Warning("TSelectorDraw", "TTree::Draw was asked to append to TEntryList '%s', but it was not found in the current directory."
410+
"Did you forget to call entryList->SetDirectory(gDirectory) or similar? Creating a new list now.", hname);
411+
}
408412
if (optEnlistArray) {
409413
enlist = new TEntryListArray(hname, realSelection.GetTitle());
410414
} else {
411415
enlist = new TEntryList(hname, realSelection.GetTitle());
412416
}
417+
enlist->SetDirectory(gDirectory); // TTree::Draw documentation promises it shows up in gDirectory
413418
}
414419
if (enlist) {
415420
if (!hnameplus) {
@@ -421,6 +426,7 @@ void TSelectorDraw::Begin(TTree *tree)
421426
} else {
422427
inElist = new TEntryList(*enlist);
423428
}
429+
inElist->SetDirectory(gDirectory); // TTree::Draw documentation promises it shows up in gDirectory
424430
fCleanElist = true;
425431
fTree->SetEntryList(inElist);
426432
}
@@ -444,7 +450,12 @@ void TSelectorDraw::Begin(TTree *tree)
444450
return;
445451
}
446452
if (!evlist) {
453+
if (hnameplus) {
454+
Warning("TSelectorDraw", "TTree::Draw was asked to append to TEventList '%s', but it was not found in the current directory."
455+
"Did you forget to call eventList->SetDirectory(gDirectory) or similar? Creating a new list now.", hname);
456+
}
447457
evlist = new TEventList(hname, realSelection.GetTitle(), 1000, 0);
458+
evlist->SetDirectory(gDirectory); // TTree::Draw documentation promises it shows up in gDirectory
448459
}
449460
if (evlist) {
450461
if (!hnameplus) {

0 commit comments

Comments
 (0)