Skip to content

Commit 99e7445

Browse files
committed
Added the documentation of PhaseSpace
Signed-off-by: Deepanshu <deepanshu2017@gmail.com>
1 parent 92c640d commit 99e7445

File tree

3 files changed

+103
-60
lines changed

3 files changed

+103
-60
lines changed

docs/Events.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ device object of particle 7 you will do something like this,
230230
- iterator = event.Daughters(i) # event can be of the host or device type and then can be used to iterator over the values.
231231
For example ``for daughter in iterator: print(daughter)`` Will print out the ith particle state in all the events.
232232
233+
- ``getDaughters`` This method returns the daughter particles at given index.
234+
235+
- vector_float4 = event.getDaughters(i)
236+
233237
- ``Events`` This method returns the iterator of events. Syntax:
234238
235239
- iterator = event.Events() # event can be of the host or device type and then can be used to iterator over the values.

docs/PhaseSpace.rst

Lines changed: 96 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ to instantiate the PhaseSpace class:
1616

1717
.. code-block:: python
1818
19-
import HydraPython as hp
19+
import HydraPython as hypy
2020
21-
vec4 = hp.Vector4R(5.2795, 0.0, 0.0, 0.0)
22-
p = hp.PhaseSpace4(vec4.mass(), [3.096916, 0.493677, 0.13957018, 0.0195018])
21+
vec4 = hypy.Vector4R(5.2795, 0.0, 0.0, 0.0)
22+
p = hypy.PhaseSpace4(vec4.mass(), [3.096916, 0.493677, 0.13957018, 0.0195018])
2323
# This will construct the PhaseSpace object with the mass provided by the vector4R
2424
# class and the exactly 4 daughter masses in the list.
2525
@@ -29,23 +29,45 @@ or a phase-space given a range of mother particles and an output range.
2929

3030
.. code-block:: python
3131
32-
vec4 = hp.Vector4R(5.2795, 0.0, 0.0, 0.0)
33-
ps = hp.PhaseSpace4(vec4.mass(), [3.096916, 0.493677, 0.13957018, 0.0195018])
34-
e_host = hp.hostEvents4(3)
35-
e_device = hp.deviceEvents4(3)
36-
ps.Generatehost(vec4, e_host) # Generate particle on host
37-
ps.Generatedevice(vec, e_device) # Generate particle on device
32+
# The below example generates and fills 3 states of 4 particle host events
33+
vec4 = hypy.Vector4R(5.2795, 0.0, 0.0, 0.0)
34+
ps = hypy.PhaseSpace4(vec4.mass(), [3.096916, 0.493677, 0.13957018, 0.0195018])
35+
e_host = hypy.host_events_4(3)
36+
e_device = hypy.device_events_4(3)
37+
ps.GenerateOnhost(vec4, e_host) # Generate particle on host
38+
ps.GenerateOndevice(vec, e_device) # Generate particle on device
3839
39-
####### ADD EXAMPLE OF given a range of mother particles and an output range
4040
41+
We can also generate the decay from list of mother particles instead of one mother particle.
4142

42-
The ``AverageOn`` method by PhaseSpace classes calculate the ``mean`` and ``sqrt(variance)``
43-
of a functor over the phase-space with n-samples or of a functor over the phase-space given a
44-
list of mother particles.
43+
.. code-block:: python
44+
45+
46+
B0_mass = 5.27955
47+
B0 = hypy.Vector4R(B0_mass, 0.0, 0.0, 0.0)
48+
49+
mothers = hypy.host_vector_float4(5)
50+
# Fill mother with some particles
51+
mothers[0] = (3.326536152819228, -0.7376241292510032, 0.9527533342879685, 0.15239715864543849)
52+
mothers[1] = (3.3327060111834546, -0.44741166640978447, 1.012640505284964, -0.5390007001803998)
53+
mothers[2] = (3.4673036097962844, 0.6781637974979919, -1.4020213115136253, -0.0763859825560801)
54+
mothers[3] = (3.5042443315560945, 1.5383404921780213, -0.1442073504412384, -0.5492280905481964)
55+
mothers[4] = (3.4406218104833015, -0.16339927010014546, 1.363729549941791, 0.6005257912194031)
56+
57+
phsp2 = hypy.PhaseSpace2(3.0969, [0.1056583745, 0.1056583745])
58+
container = hypy.host_events_2(5)
59+
phsp2.GenerateOnhost(mothers, grand_daughter)
60+
61+
for i in grand_daughter: print(i)
62+
63+
64+
The ``AverageOnhost`` and ``AverageOndevice`` method by PhaseSpace classes calculate the
65+
``mean`` and ``sqrt(variance)`` of a functor over the phase-space with n-samples or
66+
of a functor over the phase-space given a list of mother particles.
4567

4668
.. code-block:: python
4769
48-
import HydraPython as hp
70+
import HydraPython as hypy
4971
import math
5072
def foo(*data):
5173
p1, p2, p3 = data[0], data[1], data[2]
@@ -59,86 +81,103 @@ list of mother particles.
5981
md2 = p2.mass2()
6082
return (pd * mq2 - pq * qd) / math.sqrt((pq * pq - mq2 * mp2) * (qd * qd - mq2 * md2))
6183
62-
vec4 = hp.Vector4R(5.2795, 0.0, 0.0, 0.0)
63-
p = hp.PhaseSpace4(vec4.mass(), [3.096916, 0.493677, 0.13957018, 0.0195018])
64-
tup1 = p.AverageONhost(vec4, foo, 10) # Average of host, currently passing functor to device will fail
84+
vec4 = hypy.Vector4R(5.2795, 0.0, 0.0, 0.0)
85+
p = hypy.PhaseSpace4(vec4.mass(), [3.096916, 0.493677, 0.13957018, 0.0195018])
86+
tup1 = p.AverageOnhost(vec4, foo, 10) # Average of host, currently passing functor to device will fail
6587
print (tup[0]) # Mean
6688
print (tup[1]) # sqrt of variance
6789
68-
####### ADD EXAMPLE of a functor over the phase-space given a list of mother particles.
6990
91+
Like generators, the Average on method also can accept the list of mother particle instead of one mother particle
92+
and calculate the ``mean`` and ``sqrt(variance)``.
7093

71-
#### TODO ####
72-
Add example and documentation of ``Evaluate`` methods.
94+
The ``EvaluateOnhost`` and ``EvaluateOndevice`` evaluates a functor over the passed one mother particle or the list
95+
of mother particles.
7396

74-
The complete method list supported by PhaseSpace Events classes can be found
75-
on [#f1]_.
7697

77-
The complete list of the classes in the PhaseSpace can be found on [#f2]_.
98+
The complete list of the classes in the PhaseSpace can be found on [#f1]_ and complete method list supported
99+
by PhaseSpace Events classes can be found on [#f2]_.
78100

79-
.. [#f1] The method list for PhaseSpace classes
80101

81-
- ``GetSeed`` Get the seed. Syntax:
102+
.. [#f1] The list of PhaseSpace classes
82103
83-
- p.GetSeed()
104+
- ``PhaseSpace2`` Generate the phase-space with 2 particles. Syntax:
84105
85-
- ``SetSeed`` Set seed. Syntax:
106+
- p = hypy.PhaseSpace2(mass, [2 daughter masses])
86107
87-
- p.SetSeed(seed)
108+
- ``PhaseSpace3`` Generate the phase-space with 3 particles. Syntax:
88109
89-
- ``generate`` Generate the phase-space. Syntax:
110+
- p = hypy.PhaseSpace3(mass, [3 daughter masses])
90111
91-
- p.generate(vector4R, event) # event1's content will be assigned to event2.
92-
- ### SECOND EXAMPLE
112+
- ``PhaseSpace4`` Generate the phase-space with 4 particles. Syntax:
93113
94-
- ``AverageON`` Get the mean and sqrt of variance. Syntax:
114+
- p = hypy.PhaseSpace4(mass, [4 daughter masses])
95115
96-
- p.AverageON(vector4R, functor, entires)
97-
- ### SECOND EXAMPLE
116+
- ``PhaseSpace5`` Generate the phase-space with 5 particles. Syntax:
98117
99-
- ``Evaluate`` dummy Syntax:
118+
- p = hypy.PhaseSpace5(mass, [5 daughter masses])
100119
101-
- dummy
120+
- ``PhaseSpace6`` Generate the phase-space with 6 particles. Syntax:
102121
122+
- p = hypy.PhaseSpace6(mass, [6 daughter masses])
103123
104-
.. [#f2] The list of PhaseSpace classes
124+
- ``PhaseSpace7`` Generate the phase-space with 7 particles. Syntax:
105125
106-
- ``PhaseSpace1`` Generate the phase-space with 1 particles. Syntax:
126+
- p = hypy.PhaseSpace7(mass, [7 daughter masses])
107127
108-
- p = hp.PhaseSpace1(mass, [1 daughter mass])
128+
- ``PhaseSpace8`` Generate the phase-space with 8 particles. Syntax:
109129
110-
- ``PhaseSpace2`` Generate the phase-space with 2 particles. Syntax:
130+
- p = hypy.PhaseSpace8(mass, [8 daughter masses])
111131
112-
- p = hp.PhaseSpace2(mass, [2 daughter masses])
132+
- ``PhaseSpace9`` Generate the phase-space with 9 particles. Syntax:
113133
114-
- ``PhaseSpace3`` Generate the phase-space with 3 particles. Syntax:
134+
- p = hypy.PhaseSpace9(mass, [9 daughter masses])
115135
116-
- p = hp.PhaseSpace3(mass, [3 daughter masses])
136+
- ``PhaseSpace10`` Generate the phase-space with 10 particles. Syntax:
117137
118-
- ``PhaseSpace4`` Generate the phase-space with 4 particles. Syntax:
138+
- p = hypy.PhaseSpace10(mass, [10 daughter masses])
119139
120-
- p = hp.PhaseSpace4(mass, [4 daughter masses])
121140
122-
- ``PhaseSpace5`` Generate the phase-space with 5 particles. Syntax:
141+
.. [#f2] The method list for PhaseSpace classes
123142
124-
- p = hp.PhaseSpace5(mass, [5 daughter masses])
143+
- ``GetSeed`` Get the seed. Syntax:
125144
126-
- ``PhaseSpace6`` Generate the phase-space with 6 particles. Syntax:
145+
- p.GetSeed()
127146
128-
- p = hp.PhaseSpace6(mass, [6 daughter masses])
147+
- ``SetSeed`` Set seed. Syntax:
129148
130-
- ``PhaseSpace7`` Generate the phase-space with 7 particles. Syntax:
149+
- p.SetSeed(seed)
131150
132-
- p = hp.PhaseSpace7(mass, [7 daughter masses])
151+
- ``GenerateOnhost`` Generate the phase-space. Syntax:
133152
134-
- ``PhaseSpace8`` Generate the phase-space with 8 particles. Syntax:
153+
- p.GenerateOnhost(vector4R, event)
154+
- p.GenerateOnhost(hypy.host_vector_float4& mothers, event)
155+
- p.GenerateOnhost(vector4R, decays)
156+
- p.GenerateOnhost(hypy.host_vector_float4& mothers, decays)
135157
136-
- p = hp.PhaseSpace8(mass, [8 daughter masses])
158+
- ``GenerateOndevice`` Generate the phase-space. Syntax:
137159
138-
- ``PhaseSpace9`` Generate the phase-space with 9 particles. Syntax:
160+
- p.GenerateOndevice(vector4R, event)
161+
- p.GenerateOndevice(hypy.device_vector_float4& mothers, event)
162+
- p.GenerateOndevice(vector4R, decays)
163+
- p.GenerateOndevice(hypy.device_vector_float4& mothers, decays)
139164
140-
- p = hp.PhaseSpace9(mass, [9 daughter masses])
165+
- ``AverageOnhost`` Get the mean and sqrt of variance. Syntax:
141166
142-
- ``PhaseSpace10`` Generate the phase-space with 10 particles. Syntax:
167+
- p.AverageOnhost(vector4R, functor, number_of_entires)
168+
- p.AverageOnhost(hypy.host_vector_float4& mothers, functor)
169+
170+
- ``AverageOndevice`` Get the mean and sqrt of variance. Syntax:
171+
172+
- p.AverageOndevice(vector4R, functor, number_of_entires)
173+
- p.AverageOndevice(hypy.device_vector_float4& mothers, functor)
174+
175+
- ``EvaluateOnhost`` Evaluate a function over the given particle or list of particles:
176+
177+
- p.EvaluateOnhost(vector4R, hypy.host_vector_float2& result, functor)
178+
- p.EvaluateOnhost(hypy.host_vector_float4& mothers, hypy.host_vector_float2& result, functor)
179+
180+
- ``EvaluateOndevice`` Evaluate a function over the given particle or list of particles:
143181
144-
- p = hp.PhaseSpace10(mass, [10 daughter masses])
182+
- p.EvaluateOndevice(vector4R, hypy.device_vector_float2& result, functor)
183+
- p.EvaluateOndevice(hypy.device_vector_float4& mothers, hypy.device_vector_float2& result, functor)

docs/PhaseSpaceExample.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ to contain or save the states of the particle generated by the ``Generate`` meth
4343

4444
.. code-block:: python
4545
46-
e_host = hp.hostEvents4(3)
46+
e_host = hp.host_events_4(3)
4747
4848
Above I have defined a host Event container with N=4 particle and number of
4949
states as 3. So this container will contain the 3 states of 4 particles each
5050
generated by the PhaseSpace.
5151

5252
.. code-block:: python
5353
54-
ps.Generatehost(mother_particle, e_host)
54+
ps.GenerateOnhost(mother_particle, e_host)
5555
5656
Above will generate the events or states of N particles using host and save the
5757
result in the passed ``e_host`` container.
@@ -112,7 +112,7 @@ For the sake of completeness, all the code showed in the doc is below.
112112
print()
113113
114114
ps = hp.PhaseSpace4(mother_particle.mass(), daughter_masses)
115-
e_host = hp.hostEvents4(3)
115+
e_host = hp.host_events_4(3)
116116
ps.Generatehost(mother_particle, e_host)
117117
118118
iterator = e_host.Events()

0 commit comments

Comments
 (0)