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

Looking for an example of using `boost_to` in `generate`? #102

Closed mattbellis closed 6 months ago

mattbellis commented 8 months ago

Hi Maintainers!

I'm trying to use phasespace for a small study and I need to boost the initial particle in some direction. I'm trying to write stuff like

Z_MASS = 91000.00
MUON_MASS = 105.11

weights, particles = phasespace.nbody_decay(Z_MASS,
                                            [MUON_MASS, MUON_MASS]).generate(n_events=1, boost_to=np.array([10000,0,0, 9000000]))

and obviously I'm not getting it. I'm not really sure what to pass in for the boost_to option. Do you have any examples? Thanks!

jonas-eschle commented 8 months ago

Hi Matt, thanks for reaching out! An example is listed here (pointing to the tests): https://phasespace.readthedocs.io/en/latest/usage.html#boosting-the-particles (it's a bit tiny the docs here, I agree!)

What exactly does not work? The syntax of your example should be fine and it runs for me. Or did you expect a different result?

mattbellis commented 8 months ago

Thanks for responding so promptly!

I think you are right, it is working for me. Those numbers I have in that example were a result of me trying many things to see if I understood it properly. Because I had such a huge 4th component, the decay products appeared to come out back-to-back, as if everything was at rest. When I put more reasonable values in there, I see now I get non-back-to-back particles, as expected. Sigh....let this issue linger as a testament to my ignorance. :)

Just to clarify, when I pass in 4 values for boost_to per parent particle, are the entries

(px, py, pz, E)

or

(px, py, pz, rest mass)

?

Thanks so much for writing this package!

eduardo-rodrigues commented 8 months ago

Hi @jonas-eschle, I think a plain example would be good to have Something independent of RapidSim. You could input a tensor for boost_to or do it via a vector from the Vector package. That would be handy, I reckon.

jonas-eschle commented 8 months ago

Fully agree, also connecting with the vector package would be useful, had this idea in mind since a while!

@mattbellis it's (px, py, pz, E), I'll add an example and extend the docstring on it (and make vectors accepted)

mattbellis commented 8 months ago

Rockin'. Thank you so much!

jonas-eschle commented 6 months ago

This has been added in #108 and a new release is out, have fun!