N3PDF / vegasflow

VegasFlow: accelerating Monte Carlo simulation across multiple hardware platforms
https://vegasflow.readthedocs.io
Apache License 2.0
34 stars 9 forks source link

Add a conditions generator #60

Closed scarlehoff closed 4 years ago

scarlehoff commented 4 years ago

This adds an auxiliary function that can be used to generate cuts: generate_condition_function

For instance, the following code will create a function f_cond that upon being called with three conditions returns a boolean mask of the three conditions (as requested by the keyword condition) and the indices in which these are True which is often useful.

from vegasflow.utils import generate_condition_function
f_cond = generate_condition_function(3, condition = ['and', 'or'])
t_1 = pt_jet1 > 15
t_2 = pt_jet2 > 15
t_3 = rapidity_jet_1 < 4
full_mask, indices = f_cond(t_1, t_2, t_3)

This PR is pointing to PR #56

I'll add the docs directly in #58 though

scarrazza commented 4 years ago

Thanks, seems to work well, and the numbers I get for the pineappl example are similar to the plain MC python example.

scarlehoff commented 4 years ago

Good, merge to the main pineappl branch then when you want.