Skip to content

Commit 518663a

Browse files
committed
Changed naming conventions and Events.rst file
Signed-off-by: Deepanshu <deepanshu2017@gmail.com>
1 parent 98ae7ac commit 518663a

4 files changed

Lines changed: 169 additions & 164 deletions

File tree

docs/Events.rst

Lines changed: 101 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
Events Class
44
##############
55

6+
The Event class is a container class that holds the information corresponding to generated events.
7+
The Event class will not store the mother particle and store the N particle tuples with the
8+
element 0 storing the weight and rest of the elements storing the ``Vector4R`` of each particle.
69
There are two types of Events one that runs on ``host`` and ``device``. Events
7-
container currently supports up to (N=10) particles in any number of Events.
10+
container currently supports up to (N=10) particles in final state with any number of Events.
811
Both Host and Device Event classes add number (1 to 10) as their
912
suffix to create Event for that number of particles and the type
1013
(host or device) is added as their prefix.
@@ -26,24 +29,24 @@ to instantiate the Events class:
2629
2730
import HydraPython as hp
2831
29-
h_events_5 = hp.hostEvents5() # construc host Event with 5 particles and 0 Events
32+
h_events_5 = hp.host_events_5() # construct host Event with 5 particles and 0 Events
3033
print (h_events_5.size()) # 0
3134
32-
h_events_7_100 = hp.hostEvents7(100)
35+
h_events_7_100 = hp.host_events_7(100)
3336
print (h_events_7_100.size()) # 100
3437
3538
36-
The ``hostEventsN`` object can be copy constructed with the ``hostEventsN``
37-
or ``deviceEventsN`` object.
39+
The ``host_events_N`` object can be copy constructed with the ``host_events_N``
40+
or ``device_events_N`` object.
3841

3942
.. code-block:: python
4043
4144
import HydraPython as hp
42-
h_events_3 = hp.hostEvents3(4)
45+
h_events_3 = hp.host_events_3(4)
4346
print (list(h_events_3.Flags())) # [False, False, False, False]
4447
4548
h_events_3.setFlag(1, True)
46-
h_events_3_copy = hp.hostEvents3(h_events_3)
49+
h_events_3_copy = hp.host_events_3(h_events_3)
4750
print(list(h_events_3_copy.Flags())) # [False, True, False, False]
4851
4952
The ``setFlags`` method as demonstrated above can be used to set the
@@ -52,7 +55,7 @@ particular flag value with the index.
5255

5356
.. code-block:: python
5457
55-
h_event = hp.hostEvents5(8)
58+
h_event = hp.host_events_5(8)
5659
h_event.setFlag(1, True)
5760
print (h_event.getFlag(1)) # True
5861
@@ -61,23 +64,24 @@ object. This is a very useful method to avoid the nasty bugs for example:
6164

6265
.. code-block:: python
6366
64-
h_event = hp.hostEvents5(10)
65-
h_event2 = hp.hostEvents5()
67+
h_event = hp.host_events_5(10)
68+
h_event2 = hp.host_events_5()
6669
6770
# Do things and later in the code ...
6871
h_event2.assign(h_event)
6972
# This will create the exact same copy of the h_event in h_event2
7073
7174
The host Events class also provides a method to set the Maximum weight of the
72-
Events. The method is useful to set the maximum weight. The complete method
73-
list provided by the Event classes can be found on [#f1]_.
75+
Events. The method is useful to set the maximum weight. The complete list of the classes
76+
in the Events container can be found on [#f1]_. The complete method
77+
list provided by the Event classes can be found on [#f2]_.
7478

7579
The Events classes also provide a pythonic way to access the events with the
7680
``[]`` operator. For example, an event value can be access like this.
7781

7882
.. code-block:: python
7983
80-
event = hp.hostEvents5(5)
84+
event = hp.host_events_5(5)
8185
print(event[1]) # (0.0, (0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0))
8286
8387
@@ -101,14 +105,95 @@ device object of particle 7 you will do something like this,
101105
.. code-block:: python
102106
103107
import HydraPython
104-
device_event_with_7_particle = HydraPython.deviceEvents7()
108+
device_event_with_7_particle = HydraPython.device_events_7()
105109
106110
# This will create a device Events with 0 states and 7 particles.
107111
108112
109-
The complete list of the classes in the Events container can be found on [#f2]_.
113+
.. [#f1] The list of Events classes
110114
111-
.. [#f1] The method list for Events classes
115+
- ``host_events_1`` Generate 1 particle Event. Syntax:
116+
117+
- h_event = hp.host_events_1(entries)
118+
119+
- ``host_events_2`` Generate 2 particle Event. Syntax:
120+
121+
- h_event = hp.host_events_2(entries)
122+
123+
- ``host_events_3`` Generate 3 particle Event. Syntax:
124+
125+
- h_event = hp.host_events_3(entries)
126+
127+
- ``host_events_4`` Generate 4 particle Event. Syntax:
128+
129+
- h_event = hp.host_events_4(entries)
130+
131+
- ``host_events_5`` Generate 5 particle Event. Syntax:
132+
133+
- h_event = hp.host_events_5(entries)
134+
135+
- ``host_events_6`` Generate 6 particle Event. Syntax:
136+
137+
- h_event = hp.host_events_6(entries)
138+
139+
- ``host_events_7`` Generate 7 particle Event. Syntax:
140+
141+
- h_event = hp.host_events_7(entries)
142+
143+
- ``host_events_8`` Generate 8 particle Event. Syntax:
144+
145+
- h_event = hp.host_events_8(entries)
146+
147+
- ``host_events_9`` Generate 9 particle Event. Syntax:
148+
149+
- h_event = hp.host_events_9(entries)
150+
151+
- ``host_events_10`` Generate 10 particle Event. Syntax:
152+
153+
- h_event = hp.host_events_10(entries)
154+
155+
- ``device_events_1`` Generate 1 particle Event. Syntax:
156+
157+
- d_event = hp.device_events_1(entries)
158+
159+
- ``device_events_2`` Generate 2 particle Event. Syntax:
160+
161+
- d_event = hp.device_events_2(entries)
162+
163+
- ``device_events_3`` Generate 3 particle Event. Syntax:
164+
165+
- d_event = hp.device_events_3(entries)
166+
167+
- ``device_events_4`` Generate 4 particle Event. Syntax:
168+
169+
- d_event = hp.device_events_4(entries)
170+
171+
- ``device_events_5`` Generate 5 particle Event. Syntax:
172+
173+
- d_event = hp.device_events_5(entries)
174+
175+
- ``device_events_6`` Generate 6 particle Event. Syntax:
176+
177+
- d_event = hp.device_events_6(entries)
178+
179+
- ``device_events_7`` Generate 7 particle Event. Syntax:
180+
181+
- d_event = hp.device_events_7(entries)
182+
183+
- ``device_events_8`` Generate 8 particle Event. Syntax:
184+
185+
- d_event = hp.device_events_8(entries)
186+
187+
- ``device_events_9`` Generate 9 particle Event. Syntax:
188+
189+
- d_event = hp.device_events_9(entries)
190+
191+
- ``device_events_10`` Generate 10 particle Event. Syntax:
192+
193+
- d_event = hp.device_events_10(entries)
194+
195+
196+
.. [#f2] The method list for Events classes
112197
113198
- ``assign`` Assigns one Events content to other Events. Syntax:
114199
@@ -181,87 +266,3 @@ The complete list of the classes in the Events container can be found on [#f2]_.
181266
- ``getWeight`` Gets the particular event's weight. Syntax:
182267
183268
- event.getWeight(idx)
184-
185-
186-
187-
.. [#f2] The list of Events classes
188-
189-
- ``hostEvents1`` Generate 1 particle Event. Syntax:
190-
191-
- h_event = hp.hostEvents1(entries)
192-
193-
- ``hostEvents2`` Generate 2 particle Event. Syntax:
194-
195-
- h_event = hp.hostEvents2(entries)
196-
197-
- ``hostEvents3`` Generate 3 particle Event. Syntax:
198-
199-
- h_event = hp.hostEvents3(entries)
200-
201-
- ``hostEvents4`` Generate 4 particle Event. Syntax:
202-
203-
- h_event = hp.hostEvents4(entries)
204-
205-
- ``hostEvents5`` Generate 5 particle Event. Syntax:
206-
207-
- h_event = hp.hostEvents5(entries)
208-
209-
- ``hostEvents6`` Generate 6 particle Event. Syntax:
210-
211-
- h_event = hp.hostEvents6(entries)
212-
213-
- ``hostEvents7`` Generate 7 particle Event. Syntax:
214-
215-
- h_event = hp.hostEvents7(entries)
216-
217-
- ``hostEvents8`` Generate 8 particle Event. Syntax:
218-
219-
- h_event = hp.hostEvents8(entries)
220-
221-
- ``hostEvents9`` Generate 9 particle Event. Syntax:
222-
223-
- h_event = hp.hostEvents9(entries)
224-
225-
- ``hostEvents10`` Generate 10 particle Event. Syntax:
226-
227-
- h_event = hp.hostEvents10(entries)
228-
229-
- ``deviceEvents1`` Generate 1 particle Event. Syntax:
230-
231-
- d_event = hp.hostEvents1(entries)
232-
233-
- ``deviceEvents2`` Generate 2 particle Event. Syntax:
234-
235-
- d_event = hp.hostEvents2(entries)
236-
237-
- ``deviceEvents3`` Generate 3 particle Event. Syntax:
238-
239-
- d_event = hp.hostEvents3(entries)
240-
241-
- ``deviceEvents4`` Generate 4 particle Event. Syntax:
242-
243-
- d_event = hp.hostEvents4(entries)
244-
245-
- ``deviceEvents5`` Generate 5 particle Event. Syntax:
246-
247-
- d_event = hp.hostEvents5(entries)
248-
249-
- ``deviceEvents6`` Generate 6 particle Event. Syntax:
250-
251-
- d_event = hp.hostEvents6(entries)
252-
253-
- ``deviceEvents7`` Generate 7 particle Event. Syntax:
254-
255-
- d_event = hp.hostEvents7(entries)
256-
257-
- ``deviceEvents8`` Generate 8 particle Event. Syntax:
258-
259-
- d_event = hp.hostEvents8(entries)
260-
261-
- ``deviceEvents9`` Generate 9 particle Event. Syntax:
262-
263-
- d_event = hp.hostEvents9(entries)
264-
265-
- ``devicevents10`` Generate 10 particle Event. Syntax:
266-
267-
- d_event = hp.hostEvents10(entries)

include/PyEvents.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
12
/*----------------------------------------------------------------------------
23
*
3-
* Copyright (C) 2017 Deepanshu Thakur
4+
* Copyright (C) 2017 Antonio Augusto Alves Junior
45
*
56
*
67
* This file is part of Hydra.Python Analysis Framework.
@@ -60,7 +61,7 @@ namespace hydra_python {
6061

6162
#define EVENTS_CLASS_BODY(N, BACKEND, BACKEND2) \
6263
py::class_<hydra::Events<N, hydra::BACKEND::sys_t>>( \
63-
m, #BACKEND "Events" #N) \
64+
m, #BACKEND "_events_" #N) \
6465
.def(py::init<>(), "Zero state Event object") \
6566
.def(py::init<hydra::GLong_t>(), #N " particle events object") \
6667
.def(py::init<hydra::Events<N, hydra::BACKEND::sys_t>>(), \
@@ -71,14 +72,14 @@ namespace hydra_python {
7172
[](hydra::Events<N, hydra::BACKEND::sys_t>& e, \
7273
const hydra::Events<N, hydra::BACKEND::sys_t>& other) { \
7374
e = other; \
74-
}, \
75+
}, #BACKEND "_events_"#N##_a, \
7576
"Assign one " #BACKEND " Event object into another " #BACKEND \
7677
" Event object.") \
7778
.def("assign", \
7879
[](hydra::Events<N, hydra::BACKEND::sys_t>& e, \
7980
hydra::Events<N, hydra::BACKEND2::sys_t>& other) { \
8081
e = other; \
81-
}, \
82+
}, #BACKEND2 "_events_"#N##_a, \
8283
"Assign " #BACKEND2 " Events object into " #BACKEND \
8384
" Event object.") \
8485
.def("GetMaxWeight", \
@@ -113,9 +114,9 @@ namespace hydra_python {
113114
py::return_value_policy::reference_internal, \
114115
iter_t, iter_t, typename iter_t::value_type>( \
115116
e.DaughtersBegin(idx), e.DaughtersEnd(idx)); \
116-
}, \
117+
}, "idx"_a, \
117118
"Daughter iterator. Iterate over the all N events of given " \
118-
"particle") \
119+
"particle idx.") \
119120
.def("Events", \
120121
[](const hydra::Events<N, hydra::BACKEND::sys_t>& e) { \
121122
typedef decltype(e.begin()) iter_t; \
@@ -135,9 +136,9 @@ namespace hydra_python {
135136
"list index out of range"); \
136137
return (hydra::Events< \
137138
N, hydra::BACKEND::sys_t>::value_type)e[idx]; \
138-
}) \
139+
}, "idx"_a) \
139140
.def("SetMaxWeight", \
140-
&hydra::Events<N, hydra::BACKEND::sys_t>::SetMaxWeight, \
141+
&hydra::Events<N, hydra::BACKEND::sys_t>::SetMaxWeight, "weight"_a, \
141142
"Set the maximum weight.") \
142143
.def("capacity", \
143144
&hydra::Events<N, hydra::BACKEND::sys_t>::capacity) \
@@ -155,7 +156,7 @@ namespace hydra_python {
155156
"list index out of range"); \
156157
auto start = e.FlagsBegin(); \
157158
start[idx] = value; \
158-
}, \
159+
}, "idx"_a, "flag"_a, \
159160
"Set the ith event flag.") \
160161
.def("setWeight", \
161162
[](hydra::Events<N, hydra::BACKEND::sys_t>& e, \
@@ -165,7 +166,7 @@ namespace hydra_python {
165166
"list index out of range"); \
166167
auto start = e.WeightsBegin(); \
167168
start[idx] = value; \
168-
}, \
169+
}, "idx"_a, "weight"_a, \
169170
"Set the ith event's weight.") \
170171
.def("getFlag", \
171172
[](hydra::Events<N, hydra::BACKEND::sys_t>& e, \
@@ -175,7 +176,7 @@ namespace hydra_python {
175176
"list index out of range"); \
176177
auto start = e.FlagsBegin(); \
177178
return (bool)start[idx]; \
178-
}, \
179+
}, "idx"_a, \
179180
"get the ith event's flag.") \
180181
.def("getWeight", \
181182
[](hydra::Events<N, hydra::BACKEND::sys_t>& e, \
@@ -185,11 +186,12 @@ namespace hydra_python {
185186
"list index out of range"); \
186187
auto start = e.WeightsBegin(); \
187188
return (hydra::GReal_t)start[idx]; \
188-
}, \
189+
}, "idx"_a, \
189190
"get the ith event's weight.");
190191

191192
template <>
192193
void add_object<hydra::Events<4, hydra::host::sys_t>>(pybind11::module& m) {
194+
using namespace pybind11::literals;
193195
EVENTS_CLASS_BODY(1, host, device);
194196
EVENTS_CLASS_BODY(2, host, device);
195197
EVENTS_CLASS_BODY(3, host, device);

0 commit comments

Comments
 (0)