Skip to content

Commit 1a2e3e1

Browse files
committed
Added some docstrings in examples
Signed-off-by: Deepanshu <deepanshu2017@gmail.com>
1 parent 1b7531b commit 1a2e3e1

File tree

10 files changed

+92
-34
lines changed

10 files changed

+92
-34
lines changed

examples/PhaseSpace/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
This file defines some color values to be shown on the Linux terminal.
3+
4+
Author: Deepanshu Thakur
5+
Date : Aug 22, 2017
6+
"""
17
RED = "\033[1;31m"
28
BLUE = "\033[1;34m"
39
CYAN = "\033[1;36m"

examples/PhaseSpace/phsp_averaging_functor.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Licensed under a GNU general public license, see LICENSE.
2+
"""
3+
This example shows how to use the Hydra's phase space Monte Carlo algorithms
4+
to calculate the average value and corresponding variance of a functor
5+
over the phase space of the decay B0 -> J/psi K pi.
6+
7+
This example is the python version of Hydra's
8+
https://github.com/AAAlvesJr/Hydra/blob/master/examples/phase_space/phsp_averaging_functor.cpp
9+
10+
Author: Deepanshu Thakur
11+
Date : Aug 21, 2017
12+
"""
13+
114
import HydraPython as hypy
215
import sys
316
import time
@@ -6,6 +19,11 @@
619

720

821
def functor(*four_vector):
22+
"""
23+
This function calculates the cosine of helicity angle Kpi
24+
:param list of four_vector:
25+
:return: cosine of helicity angle Kpi
26+
"""
927
p1 = four_vector[0]
1028
p2 = four_vector[1]
1129
p3 = four_vector[2]
@@ -24,22 +42,17 @@ def functor(*four_vector):
2442

2543

2644
def main():
27-
"""
28-
This example shows how to use the Hydra's
29-
phase space Monte Carlo algorithms to calculate the
30-
average value and corresponding variance of a functor
31-
over the phase space of the decay B0 -> J/psi K pi.
32-
"""
45+
3346
nentries = 1000000
34-
B0_mass = 5.27955
47+
B0_mass = 5.27955 # All masses are given in GeV/c^2
3548
Jpsi_mass = 3.0969
3649
K_mass = 0.493677
3750
pi_mass = 0.13957061
3851
if len(sys.argv) > 1:
3952
nentries = int(sys.argv[1])
4053

4154
B0 = hypy.Vector4R(B0_mass, 0.0, 0.0, 0.0)
42-
masses = [Jpsi_mass, K_mass, pi_mass]
55+
masses = [Jpsi_mass, K_mass, pi_mass] # List of final-state particles
4356
phsp = hypy.PhaseSpace3(B0_mass, masses)
4457

4558
# Device #

examples/PhaseSpace/phsp_basic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
This example shows how to use the Hydra's phase space Monte Carlo algorithms
44
to generate a sample of B0 -> J/psi K pi decays.
55
6+
This example is the python version of Hydra's
7+
https://github.com/AAAlvesJr/Hydra/blob/master/examples/phase_space/phsp_basic.cpp
8+
69
Author: Deepanshu Thakur
710
Date : Aug 21, 2017
811
"""
@@ -14,6 +17,7 @@
1417

1518

1619
def main():
20+
1721
nentries = 1000000
1822
B0_mass = 5.27955 # All masses are given in GeV/c^2
1923
Jpsi_mass = 3.0969

examples/PhaseSpace/phsp_chain.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1+
# Licensed under a GNU general public license, see LICENSE.
2+
"""
3+
This example shows how to use the Hydra's phase space Monte Carlo algorithms to
4+
generate a sample of B0 -> J/psi K pi and use the multiple daughters to generate the
5+
grand-daughters.
6+
7+
This example is the python version of Hydra's
8+
https://github.com/AAAlvesJr/Hydra/blob/master/examples/phase_space/phsp_chain.cpp
9+
10+
Author: Deepanshu Thakur
11+
Date : Aug 21, 2017
12+
"""
13+
114
import HydraPython as hypy
215
import sys
316
import time
417

518

619
def main():
7-
"""
8-
This example shows how to use the Hydra's
9-
phase space Monte Carlo algorithms to
10-
generate a sample of B0 -> J/psi K pi and
11-
use the multiple daughters to generate the
12-
grand-daughters.
13-
"""
20+
1421
nentries = 1000000
15-
B0_mass = 5.27955
22+
B0_mass = 5.27955 # All masses are given in GeV/c^2
1623
Jpsi_mass = 3.0969
1724
K_mass = 0.493677
1825
pi_mass = 0.13957061
@@ -21,8 +28,8 @@ def main():
2128
nentries = int(sys.argv[1])
2229

2330
B0 = hypy.Vector4R(B0_mass, 0.0, 0.0, 0.0)
24-
masses1 = [Jpsi_mass, K_mass, pi_mass]
25-
masses2 = [mu_mass, mu_mass]
31+
masses1 = [Jpsi_mass, K_mass, pi_mass] # List of daughter particles
32+
masses2 = [mu_mass, mu_mass] # List of grand-daughter particles
2633

2734
phsp1 = hypy.PhaseSpace3(B0_mass, masses1)
2835
phsp2 = hypy.PhaseSpace2(Jpsi_mass, masses2)

examples/PhaseSpace/phsp_evaluating_functor.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Licensed under a GNU general public license, see LICENSE.
2+
"""
3+
This example shows how to use the Hydra's phase space Monte Carlo algorithms to
4+
generate events of B0 -> J/psi K pi on fly and evaluate a set of functors.
5+
6+
This example is the python version of Hydra's
7+
https://github.com/AAAlvesJr/Hydra/blob/master/examples/phase_space/phsp_evaluating_functor.cpp
8+
9+
Author: Deepanshu Thakur
10+
Date : Aug 21, 2017
11+
"""
12+
113
import HydraPython as hypy
214
import sys
315
import time
@@ -6,6 +18,11 @@
618

719

820
def functor(*four_vector):
21+
"""
22+
This function calculates the cosine of helicity angle Kpi
23+
:param list of four_vector:
24+
:return: cosine of helicity angle Kpi
25+
"""
926
p1 = four_vector[0]
1027
p2 = four_vector[1]
1128
p3 = four_vector[2]
@@ -24,22 +41,17 @@ def functor(*four_vector):
2441

2542

2643
def main():
27-
"""
28-
This example shows how to use the Hydra's
29-
phase space Monte Carlo algorithms to
30-
generate events of B0 -> J/psi K pi on fly and
31-
evaluate a set of functors.
32-
"""
44+
3345
nentries = 1000000
34-
B0_mass = 5.27955
46+
B0_mass = 5.27955 # All masses are given in GeV/c^2
3547
Jpsi_mass = 3.0969
3648
K_mass = 0.493677
3749
pi_mass = 0.13957061
3850
if len(sys.argv) > 1:
3951
nentries = int(sys.argv[1])
4052

4153
B0 = hypy.Vector4R(B0_mass, 0.0, 0.0, 0.0)
42-
masses = [Jpsi_mass, K_mass, pi_mass]
54+
masses = [Jpsi_mass, K_mass, pi_mass] # List of final-state particles
4355
phsp = hypy.PhaseSpace3(B0_mass, masses)
4456

4557
# Device #

src/PyBindings.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
12
/*----------------------------------------------------------------------------
23
*
34
* Copyright (C) 2017 Antonio Augusto Alves Junior
4-
*
55
*
6-
* This file is part of Hydra.Python Analysis Framework.
76
*
8-
* Hydra is free software: you can redistribute it and/or modify
7+
* This file is part of the Hydra.Python Analysis Framework.
8+
*
9+
* Hydra.Python is free software: you can redistribute it and/or modify
910
* it under the terms of the GNU General Public License as published by
1011
* the Free Software Foundation, either version 3 of the License, or
1112
* (at your option) any later version.
1213
*
13-
* Hydra is distributed in the hope that it will be useful,
14+
* Hydra.Python is distributed in the hope that it will be useful,
1415
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1516
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1617
* GNU General Public License for more details.
1718
*
1819
* You should have received a copy of the GNU General Public License
19-
* along with Hydra. If not, see <http://www.gnu.org/licenses/>.
20+
* along with Hydra.Python. If not, see <http://www.gnu.org/licenses/>.
2021
*
2122
*---------------------------------------------------------------------------*/
2223

tests/test_containers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Licensed under a GNU general public license, see LICENSE.
2+
"""
3+
Author: Deepanshu Thakur
4+
Date : Aug 21, 2017
5+
"""
26

37
# -----------------------------------------------------------------------------
48
# Import statements

tests/test_events.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Licensed under a GNU general public license, see LICENSE.
2+
"""
3+
Author: Deepanshu Thakur
4+
Date : Aug 21, 2017
5+
"""
26

37
# -----------------------------------------------------------------------------
48
# Import statements

tests/test_phasespace.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Licensed under a GNU general public license, see LICENSE.
2+
"""
3+
Author: Deepanshu Thakur
4+
Date : Aug 21, 2017
5+
"""
26

37
# -----------------------------------------------------------------------------
48
# Import statements
@@ -60,7 +64,7 @@ def test_default_constructor(self):
6064

6165
def test_N_PhaseSpace(self):
6266
vector_mass = 9629.140252
63-
# ps1 = hypy.PhaseSpace1(vector_mass, random_floats(0.1, 2.2, 1))
67+
ps1 = hypy.PhaseSpace1(vector_mass, random_floats(0.1, 2.2, 1))
6468
ps2 = hypy.PhaseSpace2(vector_mass, random_floats(0.1, 2.2, 2))
6569
ps3 = hypy.PhaseSpace3(vector_mass, random_floats(0.1, 2.2, 3))
6670
ps4 = hypy.PhaseSpace4(vector_mass, random_floats(0.1, 2.2, 4))
@@ -70,7 +74,7 @@ def test_N_PhaseSpace(self):
7074
ps8 = hypy.PhaseSpace8(vector_mass, random_floats(0.1, 2.2, 8))
7175
ps9 = hypy.PhaseSpace9(vector_mass, random_floats(0.1, 2.2, 9))
7276
ps10 = hypy.PhaseSpace10(vector_mass, random_floats(0.1, 2.2, 10))
73-
# self.assertIsInstance(ps1, hypy.PhaseSpace1, 'Failure: Not an instance of PhaseSpace1')
77+
self.assertIsInstance(ps1, hypy.PhaseSpace1, 'Failure: Not an instance of PhaseSpace1')
7478
self.assertIsInstance(ps2, hypy.PhaseSpace2, 'Failure: Not an instance of PhaseSpace2')
7579
self.assertIsInstance(ps3, hypy.PhaseSpace3, 'Failure: Not an instance of PhaseSpace3')
7680
self.assertIsInstance(ps4, hypy.PhaseSpace4, 'Failure: Not an instance of PhaseSpace4')

tests/test_vector.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Licensed under a GNU general public license, see LICENSE.
2-
2+
"""
3+
Author: Deepanshu Thakur
4+
Date : Aug 21, 2017
5+
"""
36
# -----------------------------------------------------------------------------
47
# Import statements
58
# -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)