zfit / phasespace

Phase space generation implemented in TensorFlow
https://phasespace.rtfd.io
BSD 3-Clause "New" or "Revised" License
24 stars 9 forks source link

[Feature] expose weight calculation of events as method #20

Open jonas-eschle opened 5 years ago

jonas-eschle commented 5 years ago

It could be useful to have a method that returns the event weights, or more direct, that tells whether something is inside or outside the phasespace (as @abhijitm08 asked for). I think it goes well into the scope of phasespace, most of all since the Particle knows everything it has to know.

My idea: extract the pdk function, expose it (https://github.com/zfit/phasespace/blob/master/phasespace/phasespace.py#L343). Make sure it returns something negative (or 0) if it is not allowed. The selection (a tf.where(weights > 0, ...) itself may be done on the user site and does not have to be part of Particle.

What do you think, @apuignav?

apuignav commented 5 years ago

It's interesting, but I'm not sure exposing PDK is the correct way. PDK is internal, and doesn't give a full answer to things directly. Maybe it's better to add a method in Particle, something like inside_phasespace?

jonas-eschle commented 5 years ago

Not the pdk itself, but the recursively called. Because the generation of the events and the weights are actually independent, knowing the masses is enough, right?

But yes, we can also have this directly, even inside. We can also use this then to create advanced Space in zfit

apuignav commented 5 years ago

I am not sure how to implement inside, but I think it'd be a killer feature. Would masses be enough or do we need 4-momenta? If I understand correctly, what we want is that given a certain input (masses or 4-momenta, not sure yet) the GenParticle can tell us if that particular input is possible given the decay, is that right?

abhijitm08 commented 5 years ago

I think given the 4-mom of all the final state particle, P_i, that are all calculated in the mother rest frame. We just need to ensure sum{Pi} = P{mother} = (Mass_{mother}, 0, 0, 0).

apuignav commented 5 years ago

Yup, that would be nice because it would open the door to doing nice things with Dalitz. But for example, in the Dalitz it's enough to have the masses, so I'm not sure how I would deal with that...

abhijitm08 commented 5 years ago

For Dalitz, if you want to just uses masses then you can ensure they are within phase space using Eq48.23a and 48.23b: http://pdg.lbl.gov/2017/reviews/rpp2017-rev-kinematics.pdf

And you can also build the 4-mom of the final state particles in the mother rest frame. Here you can calculate the mag of particle 3-mom in mother rest frame using 48.21b for all final states and since it is Dalitz where oreintation does not matter you can set the angle between each of the particles in the mother rest frame to be 120 degrees.