Skip to content

Commit eb5b243

Browse files
committed
Reformatted PhaseSpace code with arguments naming
Signed-off-by: Deepanshu <deepanshu2017@gmail.com>
1 parent 99e7445 commit eb5b243

File tree

4 files changed

+52
-49
lines changed

4 files changed

+52
-49
lines changed

include/PyEvents.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*---------------------------------------------------------------------------*/
2323

2424
/*
25-
* PyRandom.h
25+
* PyEvents.h
2626
*
2727
* Created on: 4 August 2017
2828
* Author: Deepanshu

include/PyPhaseSpace.h

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
/*----------------------------------------------------------------------------
32
*
4-
* Copyright (C) 2017 Deepanshu Thakur
3+
* Copyright (C) 2017 Antonio Augusto Alves Junior
54
*
65
*
76
* This file is part of Hydra.Python Analysis Framework.
@@ -22,9 +21,9 @@
2221
*---------------------------------------------------------------------------*/
2322

2423
/*
25-
* Vector.cpp
24+
* PyPhaseSpace.h
2625
*
27-
* Created on: Aug 4, 2017
26+
* Created on: Aug 12, 2017
2827
* Author: Deepanshu Thakur
2928
*/
3029

@@ -38,6 +37,7 @@
3837
* @todo
3938
*
4039
*/
40+
4141
#ifndef PYPHASESPACE_H_
4242
#define PYPHASESPACE_H_
4343
#include <hydra/device/System.h>
@@ -96,37 +96,38 @@ namespace hydra_python {
9696
data[0], data[1], data[2], data[3], data[4], data[5], data[6], \
9797
data[7], data[8], data[9], data[10]
9898

99+
99100
#define GENERATE_ON_EVENT(N, RNG, BACKEND) \
100101
.def("GenerateOn" #BACKEND, \
101102
[](hydra::PhaseSpace<N, RNG>& p, hydra::Vector4R& mother, \
102103
hydra::Events<N, hydra::BACKEND::sys_t>& event_container) { \
103104
p.Generate(mother, event_container.begin(), \
104105
event_container.end()); \
105-
}) \
106-
.def( \
107-
"GenerateOn" #BACKEND, \
108-
[](hydra::PhaseSpace<N, RNG>& p, \
109-
hypy::BACKEND##_vector_float4& mothers, \
110-
hydra::Events<N, hydra::BACKEND::sys_t>& event_container) { \
111-
p.Generate(mothers.begin(), mothers.end(), \
112-
event_container.begin()); \
113-
})
106+
}, "mother"_a, "event_container"_a, "Generate the " #N " particle phasespace with given mother particle and store it in passed events container" ) \
107+
.def("GenerateOn" #BACKEND, \
108+
[](hydra::PhaseSpace<N, RNG>& p, \
109+
hypy::BACKEND##_vector_float4& mothers, \
110+
hydra::Events<N, hydra::BACKEND::sys_t>& event_container) { \
111+
p.Generate(mothers.begin(), mothers.end(), \
112+
event_container.begin()); \
113+
}, "mothers"_a, "event_container"_a, "Generate the " #N " particle phasespace with given mother particles list and store it in passed events container" )
114+
114115

115116
#define GENERATE_ON_DECAY(N, RNG, BACKEND) \
116117
.def("GenerateOn" #BACKEND, \
117118
[](hydra::PhaseSpace<N, RNG>& p, hydra::Vector4R& mother, \
118119
hypy::BACKEND##_decays_##N& decays_container) { \
119120
p.Generate(mother, decays_container.begin(), \
120121
decays_container.end()); \
121-
}) \
122-
.def( \
123-
"GenerateOn" #BACKEND, \
124-
[](hydra::PhaseSpace<N, RNG>& p, \
125-
hypy::BACKEND##_vector_float4& mothers, \
126-
hypy::BACKEND##_decays_##N& decays_container) { \
127-
p.Generate(mothers.begin(), mothers.end(), \
128-
decays_container.begin()); \
129-
})
122+
}, "mother"_a, "decays_container"_a, "Generate the " #N " particle phasespace with given mother particle and store it in passed decays container" ) \
123+
.def("GenerateOn" #BACKEND, \
124+
[](hydra::PhaseSpace<N, RNG>& p, \
125+
hypy::BACKEND##_vector_float4& mothers, \
126+
hypy::BACKEND##_decays_##N& decays_container) { \
127+
p.Generate(mothers.begin(), mothers.end(), \
128+
decays_container.begin()); \
129+
}, "mothers"_a, "decays_container"_a, "Generate the " #N " particle phasespace with given mother particles list and store it in passed decays container" )
130+
130131

131132
#define AVERAGE_ON_EVENT(N, RNG, BACKEND) \
132133
.def("AverageOn" #BACKEND, \
@@ -135,15 +136,16 @@ namespace hydra_python {
135136
ADD_FUNCTOR(ADD##N) \
136137
return p.AverageOn(hydra::BACKEND::sys, mother, wfunctor, \
137138
nentries); \
138-
}) \
139+
}, "mother"_a, "funct"_a, "nentries"_a, "Get the mean and sqrt(variance) with the passed function and a single mother particle.")\
139140
.def("AverageOn" #BACKEND, \
140-
[](hydra::PhaseSpace<N, RNG>& p, \
141-
hypy::BACKEND##_vector_float4& mothers, \
142-
py::function& funct) { \
143-
ADD_FUNCTOR(ADDAVG##N) \
144-
return p.AverageOn(mothers.begin(), mothers.end(), \
145-
wfunctor); \
146-
})
141+
[](hydra::PhaseSpace<N, RNG>& p, \
142+
hypy::BACKEND##_vector_float4& mothers, \
143+
py::function& funct) { \
144+
ADD_FUNCTOR(ADDAVG##N) \
145+
return p.AverageOn(mothers.begin(), mothers.end(), \
146+
wfunctor); \
147+
}, "mothers"_a, "funct"_a, "Get the mean and sqrt(variance) with the passed function and a list mother particles.")
148+
147149

148150
#define EVALUATE_ON_EVENT(N, RNG, BACKEND) \
149151
.def("EvaluateOn" #BACKEND, \
@@ -153,7 +155,7 @@ namespace hydra_python {
153155
ADD_FUNCTOR(ADD5) \
154156
return p.Evaluate(mother, container.begin(), \
155157
container.end(), wfunctor); \
156-
}) \
158+
}, "mother"_a, "container"_a, "funct"_a, "Evaluate a function with a single mother particle.")\
157159
.def("EvaluateOn" #BACKEND, \
158160
[](hydra::PhaseSpace<N, RNG>& p, \
159161
hypy::BACKEND##_vector_float4& mothers, \
@@ -162,12 +164,12 @@ namespace hydra_python {
162164
ADD_FUNCTOR(ADD5) \
163165
p.Evaluate(mothers.begin(), mothers.end(), \
164166
container.begin(), wfunctor); \
165-
})
167+
}, "mothers"_a, "container"_a, "funct"_a, "Evaluate a function with a list mother particles.")
166168

167169
#define PHASESPACE_CLASS_BODY(N, RNG) \
168170
py::class_<hydra::PhaseSpace<N, RNG>>(m, "PhaseSpace" #N) \
169171
.def(py::init<hydra::GReal_t, \
170-
const std::array<hydra::GReal_t, N>&>()) \
172+
const std::array<hydra::GReal_t, N>&>(), "Construct a PhaseSpace"#N "Object with mother mass and " #N " daughter masses") \
171173
.def("GetSeed", &hydra::PhaseSpace<N, RNG>::GetSeed) \
172174
.def("SetSeed", &hydra::PhaseSpace<N, RNG>::SetSeed) \
173175
GENERATE_ON_EVENT(N, RNG, host) \
@@ -183,19 +185,20 @@ namespace hydra_python {
183185
GENERATE_ON_DECAY(N, RNG, device) \
184186
;
185187

186-
template <>
187-
void add_object<hydra::PhaseSpace<4, thrust::random::default_random_engine>>(
188-
pybind11::module& m) {
189-
//PHASESPACE_CLASS_BODY(1, thrust::random::default_random_engine);
190-
PHASESPACE_CLASS_BODY(2, thrust::random::default_random_engine);
191-
PHASESPACE_CLASS_BODY(3, thrust::random::default_random_engine);
192-
PHASESPACE_CLASS_BODY(4, thrust::random::default_random_engine);
193-
PHASESPACE_CLASS_BODY(5, thrust::random::default_random_engine);
194-
PHASESPACE_CLASS_BODY(6, thrust::random::default_random_engine);
195-
PHASESPACE_CLASS_BODY(7, thrust::random::default_random_engine);
196-
PHASESPACE_CLASS_BODY(8, thrust::random::default_random_engine);
197-
PHASESPACE_CLASS_BODY(9, thrust::random::default_random_engine);
198-
PHASESPACE_CLASS_BODY(10, thrust::random::default_random_engine);
188+
template <>
189+
void add_object<hydra::PhaseSpace<4, thrust::random::default_random_engine>>(
190+
pybind11::module& m) {
191+
using namespace pybind11::literals;
192+
//PHASESPACE_CLASS_BODY(1, thrust::random::default_random_engine);
193+
PHASESPACE_CLASS_BODY(2, thrust::random::default_random_engine);
194+
PHASESPACE_CLASS_BODY(3, thrust::random::default_random_engine);
195+
PHASESPACE_CLASS_BODY(4, thrust::random::default_random_engine);
196+
PHASESPACE_CLASS_BODY(5, thrust::random::default_random_engine);
197+
PHASESPACE_CLASS_BODY(6, thrust::random::default_random_engine);
198+
PHASESPACE_CLASS_BODY(7, thrust::random::default_random_engine);
199+
PHASESPACE_CLASS_BODY(8, thrust::random::default_random_engine);
200+
PHASESPACE_CLASS_BODY(9, thrust::random::default_random_engine);
201+
PHASESPACE_CLASS_BODY(10, thrust::random::default_random_engine);
199202
}
200203
}
201204
#endif /* PYPHASESPACE_H_ */

include/PyVector3R.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*---------------------------------------------------------------------------*/
2323

2424
/*
25-
* Vector.cpp
25+
* PyVector3R.h
2626
*
2727
* Created on: Jul 25, 2017
2828
* Author: Deepanshu Thakur

include/PyVector4R.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*---------------------------------------------------------------------------*/
2323

2424
/*
25-
* Vector.cpp
25+
* PyVector4R.h
2626
*
2727
* Created on: Jul 27, 2017
2828
* Author: Deepanshu Thakur

0 commit comments

Comments
 (0)