Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclusive jet constituents #137

Merged
merged 13 commits into from
Nov 9, 2022
Merged

Exclusive jet constituents #137

merged 13 commits into from
Nov 9, 2022

Conversation

rkansal47
Copy link
Collaborator

Adding the exclusive_jets_constituent_index and exclusive_jets_constituents (for a specified number of jets) functions, which retrieve particle constituents of exclusive jets similar to the constituents and constituent_index functions.

This partially solves #100, but future PRs may want to add the dcut arg and implementations for exclusive subjets as well.

),
behavior=self.data.behavior,
)
outputs_to_inputs = ak.Array(
Copy link
Collaborator

@jmduarte jmduarte Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up until this point, the basic code of exclusive_jets_constituents and exclusive_jets_constituent_index is the same. I wonder if exclusive_jets_constituents should call exclusive_jets_constituent_index or will this cause unnecessary overhead?

A similar situation applies to constituent_index and constituents. Clearly, in that case, it was chosen to do it this way. So, this approach is probably the right way to go.

If it turns out it is useful to minimize code duplication, we can deal with it more systematically in a follow-up PR.

@jmduarte jmduarte added the enhancement New feature or request label Nov 9, 2022
@jmduarte
Copy link
Collaborator

jmduarte commented Nov 9, 2022

@lgray @chrispap95 thumbs up if this PR looks fine to you. If there are no complaints, I will plan to merge it.

np_results = self._results[i].to_numpy_exclusive_njet_with_constituents(
njets
)
off = np.insert(np_results[-1], 0, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This numpy operation resembles the code that was causing problems with inclusive_jets(). The code was working fine but when tested at scale it was giving seg faults sporadically. In the end, we realized that the offset array needs to be len+1 in the C++ code and here we just get the array: off = np_results[-1]. Now, I realize that I didn't remove all those parts :/ I am fine with keeping this code as is but keep in mind this problem. And we might want to remove all those lines in the future (including the code outside of this PR).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be best to sanitize memory access before we merge this. @chrispap95 can you summarize a list of checks / fixes that should be addressed before we merge this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is to change the allocation size for the offsets array in C++ to {len+1} from {len} and simplify python code from off = np.insert(np_results[-1], 0, 0) to off = np_results[-1]. Also, it would be fantastic if this can be done as well for any methods that I forgot to patch. @rkansal47 let me know if you have trouble doing this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, all np.insert() need to go away.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I believe I've fixed all of them (needed to just insert the 0 in C++ as well).

@chrispap95
Copy link
Collaborator

I think there is a typo np.results ~> np_results

@rkansal47
Copy link
Collaborator Author

Indeed, I was just fixing that :), still some tests failing though.

@jmduarte jmduarte merged commit 339a6ed into scikit-hep:main Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants