TTree::Draw selection

Hi, I’m trying the Draw method of tree for selection and I am doing simple selections, namely,

[code]1st example

tree.Draw(“nelec”, “nelec>=1 || nmuon>=1”)[/code]
which is equivalent to

and indeed I get the same number of events selected, 62313.

Now since I want to be able to do, “one muon wiht pt>20 OR one electron with pt>20”, I was trying to do it and found that

[code]2nd example

tree.Draw(“nelec”, “pt_muon[0]>0 || pt_elec[0]>0”)[/code]
does NOT select the same number of events, rather only 55994 is selected.

So I tried the Event List method and did

[code]3rd example

tree.Draw(">> List2", “pt_muon[0]>0”)
tree.Draw(">>+ List2", “pt_elec[0]>0”)
ist2=TEventList(gDirectory.Get(“List2”))
list2.Print()
EventList:List2/(pt_muon[0]>0)||(pt_elec[0]>0), number of entries =62313
[/code]
so from this, I actually get the same number as the first example.

Could you tell me the difference between the 2nd example and the rest in terms of selection? Thank you.

[code]2nd example

tree.Draw(“nelec”, “pt_muon[0]>0 || pt_elec[0]>0”)[/code]
selects the case where there is at least one muon and at least one elector and either has a pt greater than 0. When evaluating a formula, the formula is false (0) if any of it variables is not accessible.
Using a TEventList as you did works fine. To write this in one expression use the Alt$ special variable:

tree.Draw("nelec", "Alt$(pt_muon[0],0)>0 || Alt$(pt_elec[0],0)>0");

[quote]Now since I want to be able to do, “one muon wiht pt>20 OR one electron with pt>20”[/quote]I assume that you mean “any muon with pt>20 or any elector with pt>20”; TTree::Draw can not handle this case in one expression. If you did

This would plot nelec for each time (pt_muon[i]>20||pt_elector[i]>20) [i.e. possibly multiple time per event]. So you would need to do:

tree.Draw(">> List2", "pt_muon>20"); tree.Draw(">>+ List2", "pt_elec>20"); ist2=TEventList(gDirectory.Get("List2")); ist2.SetTitle(""); // Remove selection critirium to only keep the list of events. tree.SetEventList(ist2); tree.Draw("nelec");

Cheers,
Philippe.

Hi Philippe,

Thank you for your help. Much appreciated.

I was certainly not expecting this! Now it all make sense.

About the pt selection, I was assuming that particles are sorted in order of larger pt in which case Alt$(pt_elec[0]>20) shoud translate to “select events where there is one or more electron with pt > 20” but now I am not too sure if they are. Maybe I should take your suggestion.

Thanks
Akira