How to apply two cut with in .arrays? #510
-
|
Hello everyone: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
You can write 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 Also, calling It might not be relevant on small files, but on big files, reading unnecessary branches can be slow or impossible of you don't have enough memory. |
Beta Was this translation helpful? Give feedback.
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.arrayscall just as easily:The
cutargument does nothing more than put the string you give it into square brackets, which is how you cut in NumPy.Also, calling
.arrayswithout specifying anyexpressionsorfilter_branchesreads all branches from disk. Putting["GEN_deltaR_MIN4Q"]afte…