TEntryList intersection and operators

Why the intersection betweent two TEntryList is not implemented? For example if I have 2 selections and I want to know the number of events that pass all the selection?

Now in python I’m doing

def intersection(a,b):
   c = TEntryList(a)
   aa = TEntryList(a)
   aa.Subtract(b)
   c.Subtract(aa)
   return c

c is the intersection of a and b. a and b are not modified.

Can you implement the operator+, operator- in the TEntryList class? so I can write something like this:

TEntryList a,b,c;
a.Enter(1); a.Enter(2); a.Enter(3);
b.Enter(3); b.Enter(4); b.Enter(6);

c = a+b;  // c contains 1 2 3 4 5 6
c = a-b;  // c contains  1 2 
c = a.Intersection(b)  //why modify a?  or better
c = a*b   // c contains 3

see functions Add, Subtract and Merge.
See examples in $ROOTSYS/test/stressEntryList.cxx

Rene

[quote=“brun”]see functions Add, Subtract and Merge.
See examples in $ROOTSYS/test/stressEntryList.cxx

Rene[/quote]

There is not intersection. From ther documentation:

Intersection? Simmetric difference? And I think it’s more clear do: c = a+b, instead a.Add(b); c = a; // a is modified, I don’t want this!

Could you provide these missing operators and functions? you seem to have a test case.

Rene

[quote=“brun”]Could you provide these missing operators and functions? you seem to have a test case.

Rene[/quote]

You can implement:

const TEntryList TEntryList:operator+(const TEntryList &other) const
// return a TEntryList with the events in that are in *this OR in other
const TEntryList TEntryList:operator-(const TEntryList &other) const
// return a TEntryList with the events in that are in *this BUT NOT in other
const TEntryList TEntryList:operator*(const TEntryList &other) const
// return a TEntryList with the events in that are in *this AND in other

my work is:

  1. get a tree with signal events and a tree with backgroud events
  2. consider only a subset of these trees identified by a TCut subset (for example only triggered events, but it’s more complicated)
  3. do a lot of selections on this events (each selections is a TCut), compute efficienties on signal and on backgroud, compute S/N
  4. graph the selected events (signal and BK) for all the selections

I prefer a load and shoot approach: first I compute what events pass a selections, for every selection, and I compute what events pass the subset condition. I compute an array of TEntryList, one for each selections TCut, and one TEntryList for the subset Cut.

Then I must do the insersection between the selection TCut and the subset TCut.

Then I print the numbers of events, efficienties, S/N in a tabular form. These values are calculated from EntryList[n].GetN()

Then I draw the istogram using the TEventList previously computed (tree.SetEventList(EntryList[n]); tree.Draw(“branch”) for every n)

you can say: you can use

entries = tree.Draw("branch",selectionCut[n] && subsetCut) for every n

but I prefer to separate the drawing from the computing of the events that pass the selection, because my program is more complicated than this, for example, I want to calculate the efficienties of my selection varing the cuts. Maybe I don’t want to Draw the istogram… so I’m using a simple function that convert a TCut to an TEntryList, but this TEntryList must be insersecated with the subsetEntryList.

Hi,

[quote]const TEntryList TEntryList:operator+(const TEntryList &other) const
// return a TEntryList with the events in that are in *this OR in other
const TEntryList TEntryList:operator-(const TEntryList &other) const
// return a TEntryList with the events in that are in this BUT NOT in other
const TEntryList TEntryList:operator
(const TEntryList &other) const
// return a TEntryList with the events in that are in *this AND in other[/quote]

This is a new request and to improve the system and get those implemented sooner, maybe you can propose a complete (and tested) implementation for those?

Thanks,
Philippe.