Skip to content

How to apply two cut with in .arrays? #510

Discussion options

You must be logged in to vote

You can write cut = "(GEN_deltaR_MAX4Q>1.2) & (GEN_deltaR_MIN4Q<0.8)" (with parentheses!), but also, there's no strong reason to put the cut in this string. You can cut the arrays after the .arrays call just as easily:

ttree = uproot.open("M250.root:Events")
one_branch = ttree["GEN_deltaR_MIN4Q"]
GEN_deltaR_MAX4Q = one_branch.array(library ="np")
GEN_deltaR_MAX4Q_cut = GEN_deltaR_MAX4Q[(GEN_deltaR_MAX4Q>1.2) & (GEN_deltaR_MIN4Q<0.8)]

The cut argument does nothing more than put the string you give it into square brackets, which is how you cut in NumPy.

Also, calling .arrays without specifying any expressions or filter_branches reads all branches from disk. Putting ["GEN_deltaR_MIN4Q"] afte…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ZhenxuanZhang-Jensen
Comment options

@jpivarski
Comment options

Answer selected by ZhenxuanZhang-Jensen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants