TTree:SetEntryList

I’d like to add more than one entrylist to my TTree. For example, now I need to optimize a selection of events on a subset of my events. I have a TTree with all events, and a TCut cut_subset that select only the events of a special kind. On this subset I need to build a selection to select the good events. I’d like to do:

TTree t;
TCut cut_subset("select a subset of all events");
TCut cut_selection("select only the events that are good");
t.Draw(">>subset_entrylist",cut_subset,"entrylist");
TEntryList* subset_entrylist = (TEntryList*)gDirectory->Get(subset_entrylist);
t.AddEntryList(subset_entry_list); // now all algorithms consider only the subset events
t.Draw(">>selected",cut_selection,"entrylist");
TEntryList* selected_entrylist = (TEntryList*)gDirectory->Get(selected_entrylist);
t.AddEntryList(selected_entrylist);
t.Draw("mybrach"); // and it's draw only the events that pass the two cuts

this would be the same as:

TTree t;
TCut cut_subset("select a subset of all events");
TCut cut_selection("select only the events that are good");
cut_and = cut_subset && cut_selection;
t.Draw(">>entrylist",cut_and,"entrylist");
TEntryList* entrylist = (TEntryList*)gDirectory->Get(entrylist);
t.AddEntryList(entrylist);
t.Draw("mybrach"); // and it's draw only the events that pass the two cuts

the problem is that I have a lots of selection to try, but only one cut_subset.

Hi,

From your example I am not sure I understand how ‘adding’ the entry list is helping you. Your AddEntryList seems to be the same as SetEntryList especially since in your case selected_entrylist is a subset of subset_entry_list.

Also please note that you can do several operation (including addition and substraction) on the entry list themselves …

Cheers,
Philippe.

[quote=“pcanal”]Hi,

From your example I am not sure I understand how ‘adding’ the entry list is helping you. Your AddEntryList seems to be the same as SetEntryList especially since in your case selected_entrylist is a subset of subset_entry_list.

Also please note that you can do several operation (including addition and substraction) on the entry list themselves …

Cheers,
Philippe.[/quote]

I want to add more than one TEntryList on my TTree. The considered events will be the AND of the added TEntryList.

Hi,

Then you will need to create a TEntryList object which is the addition of your other TEntryList. (Yes it would be feasible to add a shortcut interface that does that for Addition … but there is other way of combining EntryList and one might argue that if one shortcut is provided why not all of them … and then we have a duplication of the interface).

Cheers,
Philippe.

[quote=“pcanal”]Hi,

Then you will need to create a TEntryList object which is the addition of your other TEntryList. (Yes it would be feasible to add a shortcut interface that does that for Addition … but there is other way of combining EntryList and one might argue that if one shortcut is provided why not all of them … and then we have a duplication of the interface).

Cheers,
Philippe.[/quote]

No, not the addition, the intersection of the two TEntryList.

Hi,

Currently intersection is not implemented directly however you can use TTree::Draw (without actually plotting any graphics) to generate one:

tree->Draw(">>newlist","mainlist && sublist","entrylist"); TEntryList *newlistptr = (TEntryList*)gDirectory->FindObject("newlist");

Cheers,
Philippe.