xcoll 0.5.12__py3-none-any.whl → 0.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xcoll might be problematic. Click here for more details.

Files changed (336) hide show
  1. xcoll/__init__.py +5 -18
  2. xcoll/__init__.py.orig +26 -0
  3. xcoll/beam_elements/__init__.py +1 -0
  4. xcoll/beam_elements/absorber.py +12 -2
  5. xcoll/beam_elements/base.py +162 -62
  6. xcoll/beam_elements/blowup.py +1 -0
  7. xcoll/beam_elements/elements_src/black_absorber.h +57 -58
  8. xcoll/beam_elements/elements_src/black_crystal.h +49 -50
  9. xcoll/beam_elements/elements_src/everest_block.h +21 -11
  10. xcoll/beam_elements/elements_src/everest_collimator.h +100 -91
  11. xcoll/beam_elements/elements_src/everest_crystal.h +145 -140
  12. xcoll/beam_elements/elements_src/transparent_collimator.h +126 -0
  13. xcoll/beam_elements/elements_src/transparent_crystal.h +118 -0
  14. xcoll/beam_elements/everest.py +16 -5
  15. xcoll/beam_elements/monitor.py +1 -0
  16. xcoll/beam_elements/transparent.py +83 -0
  17. xcoll/colldb.py +15 -6
  18. xcoll/general.py +1 -1
  19. xcoll/general.py.orig +20 -0
  20. xcoll/headers/particle_states.py +51 -0
  21. xcoll/initial_distribution.py +121 -91
  22. xcoll/initial_distribution.py.orig +256 -0
  23. xcoll/interaction_record/interaction_record.py +2 -1
  24. xcoll/interaction_record/interaction_types.py +2 -2
  25. xcoll/line_tools.py +163 -73
  26. xcoll/lossmap.py +519 -127
  27. xcoll/plot.py +109 -0
  28. xcoll/rf_sweep.py +6 -0
  29. xcoll/scattering_routines/engine.py +414 -217
  30. xcoll/scattering_routines/environment.py +297 -0
  31. xcoll/scattering_routines/everest/amorphous.h +95 -71
  32. xcoll/scattering_routines/everest/{channeling.h → channelling.h} +121 -112
  33. xcoll/scattering_routines/everest/constants.h +1 -1
  34. xcoll/scattering_routines/everest/crystal_parameters.h +9 -9
  35. xcoll/scattering_routines/everest/everest.h +8 -3
  36. xcoll/scattering_routines/everest/everest.py +2 -1
  37. xcoll/scattering_routines/everest/ionisation_loss.h +141 -0
  38. xcoll/scattering_routines/everest/jaw.h +19 -24
  39. xcoll/scattering_routines/everest/materials.py +2 -0
  40. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  41. xcoll/scattering_routines/everest/nuclear_interaction.h +35 -19
  42. xcoll/scattering_routines/everest/properties.h +3 -72
  43. xcoll/xaux.py +65 -109
  44. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/METADATA +5 -5
  45. xcoll-0.6.1.dist-info/RECORD +138 -0
  46. xcoll/_manager.py +0 -22
  47. xcoll/headers/particle_states.h +0 -25
  48. xcoll/install.py +0 -35
  49. xcoll/scattering_routines/geant4/collimasim/.git +0 -1
  50. xcoll/scattering_routines/geant4/collimasim/.gitignore +0 -12
  51. xcoll/scattering_routines/geant4/collimasim/.gitmodules +0 -3
  52. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +0 -26
  53. xcoll/scattering_routines/geant4/collimasim/README.md +0 -21
  54. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +0 -20
  55. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +0 -35
  56. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +0 -10
  57. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +0 -59
  58. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +0 -26
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +0 -37
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +0 -19
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +0 -65
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +0 -73
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +0 -1
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +0 -9
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +0 -386
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +0 -45
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +0 -8
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +0 -16
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +0 -8
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +0 -3
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +0 -19
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +0 -969
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +0 -84
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +0 -48
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +0 -16
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +0 -103
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +0 -45
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +0 -151
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +0 -3
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +0 -297
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +0 -29
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +0 -6
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +0 -180
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +0 -23
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +0 -192
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +0 -11
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +0 -81
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +0 -93
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +0 -310
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +0 -109
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +0 -43
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +0 -171
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +0 -251
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +0 -305
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +0 -1297
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +0 -262
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +0 -396
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +0 -568
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +0 -337
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +0 -13
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +0 -463
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +0 -286
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +0 -155
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +0 -174
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +0 -308
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +0 -91
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +0 -95
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +0 -2050
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +0 -542
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +0 -8
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +0 -648
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +0 -381
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +0 -343
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +0 -48
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +0 -105
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +0 -72
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +0 -427
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +0 -427
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +0 -130
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +0 -96
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +0 -8
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +0 -548
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +0 -605
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +0 -144
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +0 -1432
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +0 -213
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +0 -2
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +0 -65
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +0 -709
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +0 -1021
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +0 -104
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +0 -346
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +0 -467
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +0 -978
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +0 -55
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +0 -606
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +0 -284
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +0 -163
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +0 -121
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +0 -193
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +0 -275
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +0 -1741
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +0 -163
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +0 -65
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +0 -2497
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +0 -1879
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +0 -103
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +0 -375
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +0 -747
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +0 -88
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +0 -11
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +0 -52
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +0 -12
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +0 -6
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +0 -21
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +0 -482
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +0 -63
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +0 -41
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +0 -56
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +0 -155
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +0 -503
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +0 -208
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +0 -275
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +0 -73
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +0 -33
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +0 -279
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +0 -143
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +0 -85
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +0 -179
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +0 -151
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +0 -91
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +0 -85
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +0 -19
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +0 -12
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +0 -26
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +0 -25
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +0 -216
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +0 -163
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +0 -286
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +0 -536
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +0 -107
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +0 -248
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +0 -227
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +0 -202
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +0 -84
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +0 -210
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +0 -550
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +0 -473
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +0 -84
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +0 -21
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +0 -28
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +0 -39
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +0 -46
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +0 -6
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +0 -41
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +0 -35
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +0 -41
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +0 -10
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +0 -165
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +0 -53
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +0 -238
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +0 -126
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +0 -141
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +0 -117
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +0 -41
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +0 -50
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +0 -69
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +0 -42
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +0 -348
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +0 -771
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +0 -47
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +0 -22
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +0 -23
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +0 -326
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +0 -15
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +0 -148
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +0 -272
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +0 -119
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +0 -51
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +0 -5
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +0 -285
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +0 -12
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +0 -265
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +0 -397
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +0 -520
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +0 -49
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +0 -94
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +0 -125
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +0 -331
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +0 -153
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +0 -284
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +0 -107
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +0 -257
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +0 -412
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +0 -517
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +0 -102
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +0 -92
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +0 -233
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +0 -360
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +0 -472
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +0 -593
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +0 -524
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +0 -441
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +0 -103
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +0 -267
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +0 -73
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +0 -59
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +0 -235
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +0 -146
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +0 -189
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +0 -82
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +0 -560
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +0 -651
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +0 -500
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +0 -253
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +0 -452
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +0 -318
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +0 -342
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +0 -291
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +0 -131
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +0 -318
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +0 -144
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +0 -29
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +0 -66
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +0 -44
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +0 -22
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +0 -9
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +0 -510
  275. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +0 -408
  276. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +0 -140
  277. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +0 -117
  278. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +0 -70
  279. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +0 -86
  280. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +0 -257
  281. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +0 -44
  282. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +0 -23
  283. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +0 -39
  284. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +0 -64
  285. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +0 -402
  286. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +0 -233
  287. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +0 -276
  288. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +0 -214
  289. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +0 -3
  290. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +0 -65
  291. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +0 -41
  292. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +0 -8
  293. xcoll/scattering_routines/geant4/collimasim/setup.py +0 -144
  294. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +0 -403
  295. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +0 -100
  296. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +0 -763
  297. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +0 -118
  298. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +0 -8
  299. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +0 -63
  300. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +0 -142
  301. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +0 -556
  302. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +0 -6
  303. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +0 -24
  304. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +0 -1
  305. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +0 -1
  306. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +0 -1
  307. xcoll/scattering_routines/geant4/collimasim/tests/README.md +0 -25
  308. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +0 -25
  309. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +0 -18
  310. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +0 -68
  311. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +0 -15
  312. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +0 -110
  313. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +0 -7
  314. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +0 -3
  315. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +0 -54
  316. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +0 -3
  317. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +0 -3
  318. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +0 -5
  319. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +0 -51
  320. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +0 -65
  321. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +0 -59
  322. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +0 -102
  323. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +0 -75
  324. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +0 -74
  325. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +0 -84
  326. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +0 -159
  327. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +0 -99
  328. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +0 -78
  329. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +0 -88
  330. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +0 -80
  331. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +0 -97
  332. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +0 -96
  333. xcoll-0.5.12.dist-info/RECORD +0 -415
  334. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/LICENSE +0 -0
  335. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/NOTICE +0 -0
  336. {xcoll-0.5.12.dist-info → xcoll-0.6.1.dist-info}/WHEEL +0 -0
@@ -1,763 +0,0 @@
1
- #include "BDSXtrackInterface.hh"
2
- #include <cstring>
3
- #include <cmath>
4
- #include <BDSSamplerCustom.hh>
5
-
6
-
7
- BDSParticleDefinition* PrepareBDSParticleDefition(long long int pdgIDIn, double momentumIn,
8
- double kineticEnergyIn, double ionChargeIn)
9
- {
10
- G4int pdgID = (G4int) pdgIDIn;
11
-
12
- G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
13
- G4ParticleDefinition* particleDefGeant;
14
-
15
- // Wrap in our class that calculates momentum and kinetic energy.
16
- // Requires that one of E, Ek, P be non-zero (only one).
17
- BDSParticleDefinition* particleDefinition = nullptr;
18
- BDSIonDefinition* ionDef = nullptr;
19
-
20
- // PDG for ions = 10LZZZAAAI
21
- if (pdgID > 1000000000) // is an ion
22
- {
23
-
24
- G4IonTable* ionTable = particleTable->GetIonTable();
25
- particleDefGeant = ionTable->GetIon(pdgID);
26
- if (!particleDefGeant)
27
- {throw BDSException("BDSXtrackInterface> Ion \"" + std::to_string(pdgID) + "\" not found");}
28
-
29
- G4int ionCharge = ionChargeIn==0 ? particleDefGeant->GetAtomicNumber() : (G4int) ionChargeIn;
30
- ionDef = new BDSIonDefinition(particleDefGeant->GetAtomicMass(),
31
- particleDefGeant->GetAtomicNumber(),
32
- ionCharge);
33
-
34
- // correct the particle mass in the case of partially-stripped ions
35
- G4double mass = ionTable->GetIonMass(ionDef->Z(), ionDef->A());
36
- G4double charge = ionDef->Charge(); // correct even if overridden
37
- mass += ionDef->NElectrons()*G4Electron::Definition()->GetPDGMass();
38
- // The constructor with a custom name requires the bdsim name of the ion
39
- std::string bdsimPartName = "ion " + std::to_string(static_cast<int>(ionDef->A()))
40
- + " " + std::to_string(static_cast<int>(ionDef->Z()))
41
- + " " + std::to_string(static_cast<int>(charge));
42
-
43
- particleDefinition = new BDSParticleDefinition(bdsimPartName, mass, charge, 0,
44
- kineticEnergyIn, momentumIn, 1, ionDef, pdgID);
45
- }
46
- else
47
- {
48
- particleDefGeant = particleTable->FindParticle(pdgID);
49
- if (!particleDefGeant)
50
- {throw BDSException("BDSXtrackInterface> Particle \"" + std::to_string(pdgID) + "\" not found");}
51
- particleDefinition = new BDSParticleDefinition(particleDefGeant, 0, kineticEnergyIn, momentumIn, 1, nullptr);
52
- }
53
-
54
- return particleDefinition;
55
- }
56
-
57
-
58
- XtrackInterface::XtrackInterface(const std::string& bdsimConfigFile,
59
- long long int referencePdgIdIn,
60
- double referenceEkIn,
61
- double relativeEnergyCutIn,
62
- int seedIn,
63
- int referenceIonChargeIn,
64
- bool batchMode):
65
- relativeEnergyCut(relativeEnergyCutIn),
66
- seed(seedIn)
67
- {
68
- stp = new BDSBunchSixTrackLink();
69
- bds = new BDSIMLink(stp);
70
-
71
- std::string seedStr = std::to_string(seed);
72
- std::vector<std::string> arguments = {"--file=" + bdsimConfigFile,
73
- "--file=" + bdsimConfigFile,
74
- //"--vis_debug",
75
- "--output=none",
76
- "--seed=" + seedStr,
77
- "--outfile=output_" + seedStr};
78
-
79
- for(auto & argument : arguments)
80
- {
81
- argv.push_back(strdup(argument.c_str()));
82
- }
83
- if (batchMode)
84
- {
85
- std::string batch_flag = "--batch";
86
- argv.push_back(strdup(batch_flag.c_str()));
87
- }
88
- argv.push_back(nullptr);
89
-
90
- double referenceEk = referenceEkIn * CLHEP::GeV;
91
-
92
- double relEKCut = relativeEnergyCut;
93
- if (relEKCut < 1e-6) // defaults to 0 which means 0eV cut which is bad
94
- { relEKCut = 1.0; }
95
-
96
- double minimumEK = relEKCut * (referenceEk);
97
-
98
- G4cout << "Minimum kinetic energy " << minimumEK << " MeV" << G4endl;
99
- auto data = argv.data();
100
- try
101
- { bds->Initialise(argv.size() - 1, &argv[0], true, minimumEK / CLHEP::GeV, false); } // minimumEk in GeV
102
- catch (const std::exception &e)
103
- {
104
- std::cout << e.what() << std::endl;
105
- exit(1);
106
- }
107
-
108
- G4double ionCharge = (G4double) referenceIonChargeIn;
109
- refParticleDefinition = PrepareBDSParticleDefition(referencePdgIdIn, 0, referenceEk, ionCharge);
110
- }
111
-
112
-
113
- XtrackInterface::~XtrackInterface()
114
- {
115
- delete bds;
116
- delete stp;
117
-
118
- delete refParticleDefinition;
119
- }
120
-
121
-
122
- void XtrackInterface::addCollimator(const std::string& name,
123
- const std::string& material,
124
- double lengthIn,
125
- double apertureLeftIn,
126
- double apertureRightIn,
127
- double rotationIn,
128
- double xOffsetIn,
129
- double yOffsetIn,
130
- double jawTiltLeft,
131
- double jawTiltRight,
132
- int side)
133
- {
134
-
135
- bool buildLeft = side == 0 || side == 1;
136
- bool buildRight = side == 0 || side == 2;
137
-
138
- bool isACrystal = false;
139
-
140
- bds->AddLinkCollimatorJaw(name,
141
- material,
142
- lengthIn * CLHEP::m,
143
- apertureLeftIn * CLHEP::m,
144
- apertureRightIn * CLHEP::m,
145
- rotationIn * CLHEP::rad,
146
- xOffsetIn * CLHEP::m,
147
- yOffsetIn * CLHEP::m,
148
- jawTiltLeft * CLHEP::rad,
149
- jawTiltRight * CLHEP::rad,
150
- buildLeft,
151
- buildRight,
152
- isACrystal,
153
- 0);
154
- }
155
-
156
-
157
- void XtrackInterface::addParticle(double xIn,
158
- double yIn,
159
- double pxIn,
160
- double pyIn,
161
- double ctIn,
162
- double deltapIn,
163
- double chiIn,
164
- double chargeRatioIn,
165
- double sIn,
166
- int64_t pdgIDIn,
167
- int64_t trackidIn
168
- )
169
- {
170
-
171
- auto x = (G4double) xIn;
172
- auto y = (G4double) yIn;
173
- auto px = (G4double) pxIn;
174
- auto py = (G4double) pyIn;
175
- auto ct = (G4double) ctIn;
176
- auto deltap = (G4double) deltapIn;
177
- auto chi = (G4double) chiIn;
178
- auto charge_ratio = (G4double) chargeRatioIn;
179
- auto s = (G4double) sIn;
180
- auto trackid = (G4int) trackidIn;
181
- auto pdgid = (long long int) pdgIDIn;
182
-
183
- //G4double mass_ratio = charge_ratio / chi;
184
- G4double q = charge_ratio * refParticleDefinition->Charge();
185
- G4double mass_ratio = charge_ratio / chi;
186
- G4double p = refParticleDefinition->Momentum() * (deltap + 1) * mass_ratio;
187
-
188
- // If the pdg id for the particle is 0 (default), take the reference pdg id
189
- long long int pdgidPart = (pdgid==0) ? refParticleDefinition->PDGID() : pdgid;
190
- auto partDef = PrepareBDSParticleDefition(pdgidPart, p, 0, q);
191
-
192
- G4double t = - ct * CLHEP::m / (refParticleDefinition->Beta() * CLHEP::c_light); // this is time difference in ns
193
-
194
- G4double oneplusdelta = (1 + deltap) * mass_ratio;
195
- // G4double pz = std::sqrt(oneplusdelta*oneplusdelta - px*px - py*py);
196
- G4double xp = px / oneplusdelta;
197
- G4double yp = py / oneplusdelta;
198
-
199
- // Zp0 is 1 as here we assume no back-scatterd particles, e.g p>0
200
- G4double zp = BDSBunch::CalculateZp(xp, yp, 1);
201
-
202
- BDSParticleCoordsFull coords = BDSParticleCoordsFull(x * CLHEP::m,
203
- y * CLHEP::m,
204
- 0,
205
- xp,
206
- yp,
207
- zp,
208
- t,
209
- 0,
210
- partDef->TotalEnergy(),
211
- 1);
212
-
213
- stp->AddParticle(partDef, coords, trackid, trackid);
214
- }
215
-
216
-
217
- void XtrackInterface::addParticles(const py::list& coordinates)
218
- {
219
- //TODO get the charge and mass ratios
220
- // Obtain the arrays from the list and cast them to the correct array type
221
- py::array_t<double> x = py::cast<py::array>(coordinates[0]);
222
- py::array_t<double> y = py::cast<py::array>(coordinates[1]);
223
- py::array_t<double> px = py::cast<py::array>(coordinates[2]);
224
- py::array_t<double> py = py::cast<py::array>(coordinates[3]);
225
- py::array_t<double> zeta = py::cast<py::array>(coordinates[4]);
226
- py::array_t<double> delta = py::cast<py::array>(coordinates[5]);
227
- py::array_t<double> chi = py::cast<py::array>(coordinates[6]);
228
- py::array_t<double> charge_ratio = py::cast<py::array>(coordinates[7]);
229
- py::array_t<double> s = py::cast<py::array>(coordinates[8]);
230
- py::array_t<int64_t> pdgid = py::cast<py::array>(coordinates[9]);
231
- py::array_t<int64_t> trackid = py::cast<py::array>(coordinates[10]);
232
- py::array_t<int64_t> state = py::cast<py::array>(coordinates[11]);
233
- py::array_t<int64_t> at_element = py::cast<py::array>(coordinates[12]);
234
- py::array_t<int64_t> at_turn = py::cast<py::array>(coordinates[13]);
235
-
236
-
237
- // Obtain the buffers
238
- py::buffer_info x_buff = x.request();
239
- py::buffer_info y_buff = y.request();
240
- py::buffer_info px_buff = px.request();
241
- py::buffer_info py_buff = py.request();
242
- py::buffer_info zeta_buff = zeta.request();
243
- py::buffer_info delta_buff = delta.request();
244
- py::buffer_info chi_buff = chi.request();
245
- py::buffer_info charge_ratio_buff = charge_ratio.request();
246
- py::buffer_info s_buff = s.request();
247
- py::buffer_info pdgid_buff = pdgid.request();
248
- py::buffer_info id_buff = trackid.request();
249
- py::buffer_info state_buff = state.request();
250
- py::buffer_info at_element_buff = at_element.request();
251
- py::buffer_info at_turn_buff = at_turn.request();
252
-
253
- // Get the pointers for iteration
254
- auto x_ptr = static_cast<double *>(x_buff.ptr);
255
- auto y_ptr = static_cast<double *>(y_buff.ptr);
256
- auto px_ptr = static_cast<double *>(px_buff.ptr);
257
- auto py_ptr = static_cast<double *>(py_buff.ptr);
258
- auto zeta_ptr = static_cast<double *>(zeta_buff.ptr);
259
- auto delta_ptr = static_cast<double *>(delta_buff.ptr);
260
- auto chi_ptr = static_cast<double *>(chi_buff.ptr);
261
- auto charge_ratio_ptr = static_cast<double *>(charge_ratio_buff.ptr);
262
- auto s_ptr = static_cast<double *>(s_buff.ptr);
263
- auto pdgid_ptr = static_cast<int64_t *>(pdgid_buff.ptr);
264
- auto trackid_ptr = static_cast<int64_t *>(id_buff.ptr);
265
- auto state_ptr = static_cast<int64_t *>(state_buff.ptr);
266
- auto at_element_ptr = static_cast<int64_t *>(at_element_buff.ptr);
267
- auto at_turn_ptr = static_cast<int64_t *>(at_turn_buff.ptr);
268
-
269
- long n = 1; // Get the number of elements in the array, assume all arrays have the same number of elements
270
- for (auto r: x_buff.shape) {
271
- n *= r;
272
- }
273
-
274
- for(int i=0; i < n; i++)
275
- {
276
- auto x_part = x_ptr[i];
277
- auto y_part = y_ptr[i];
278
- auto px_part = px_ptr[i];
279
- auto py_part = py_ptr[i];
280
- auto zeta_part = zeta_ptr[i];
281
- auto delta_part = delta_ptr[i];
282
- auto chi_part = chi_ptr[i];
283
- auto charge_ratio_part = charge_ratio_ptr[i];
284
- auto s_part = s_ptr[i];
285
- auto pdgid_part = pdgid_ptr[i];
286
- auto trackid_part = trackid_ptr[i];
287
- auto state_part = state_ptr[i];
288
- auto at_element_part = at_element_ptr[i];
289
- auto at_turn_part = at_turn_ptr[i];
290
-
291
- // The particles with state=0 are inactive and should not be processed at all, but need to keep track of them
292
- // The internal processing in BDSIM does not feature an active state check, so this must be done at a higher
293
- // level here
294
-
295
- if (state_part == 1) // State == 1 means that the particle is active
296
- {
297
- particleActiveState.push_back(true);
298
- addParticle(x_part, y_part, px_part, py_part,
299
- zeta_part, delta_part, chi_part,
300
- charge_ratio_part, s_part, pdgid_part, trackid_part);
301
-
302
- maxParticleID = std::max(maxParticleID, trackid_part);
303
- bds->SetCurrentMaximumExternalParticleID(maxParticleID);
304
- }
305
- else
306
- {
307
- if (state_part == -999999999) // This is reserve memory for new particles, no need to process
308
- {
309
- break;
310
- }
311
- particleActiveState.push_back(false);
312
- }
313
-
314
- auto particle_coords = new XtrackCoordinates{x_part, y_part, px_part, py_part, zeta_part,
315
- delta_part, chi_part, charge_ratio_part, s_part,
316
- pdgid_part, trackid_part, state_part,
317
- at_element_part, at_turn_part};
318
- xtrackParticles.push_back(particle_coords);
319
- }
320
- }
321
-
322
-
323
- void XtrackInterface::collimate()
324
- {
325
- bds->BeamOn((G4int)stp->Size());
326
- }
327
-
328
-
329
- void XtrackInterface::selectCollimator(const std::string& collimatorName)
330
- {
331
- currentCollimatorName = collimatorName;
332
- // This doesn't throw an error if the element doesn't exist
333
- bds->SelectLinkElement(collimatorName);
334
-
335
- // Check if the element exists by querying the index: -1 means it doesn't exist
336
- if (bds->GetLinkIndex(collimatorName) == -1)
337
- {throw std::runtime_error("Element not found " + collimatorName);}
338
- }
339
-
340
-
341
- void XtrackInterface::clearData()
342
- {
343
- bds->ClearSamplerHits();
344
- // A malloc error about freeing a pointer not allocated is thrown if the run is terminated after
345
- // the bunch is manually cleared. Consider using an alternative to vector.clear() in the BDSIM bunch class:
346
- // vector<T>().swap(x); // clear x reallocating (https://www.cplusplus.com/reference/vector/vector/clear/)
347
- // to ensure the pointer is still allocated after clearing
348
- stp->ClearParticles();
349
-
350
- for (auto part : xtrackParticles)
351
- {
352
- delete part;
353
- }
354
-
355
- std::vector<XtrackCoordinates*>().swap(xtrackParticles);
356
- std::vector<bool>().swap(particleActiveState);
357
- currentCollimatorName.clear();
358
-
359
- maxParticleID = 0;
360
-
361
- }
362
-
363
-
364
- py::dict XtrackInterface::collimateReturn(const py::list& coordinates)
365
- {
366
- // Prepare the buffers for modifying the primary particle coordinates in place
367
-
368
- // Obtain the arrays from the list and cast them to the correct array type
369
- py::array_t<double> x = py::cast<py::array>(coordinates[0]);
370
- py::array_t<double> y = py::cast<py::array>(coordinates[1]);
371
- py::array_t<double> px = py::cast<py::array>(coordinates[2]);
372
- py::array_t<double> py = py::cast<py::array>(coordinates[3]);
373
- py::array_t<double> zeta = py::cast<py::array>(coordinates[4]);
374
- py::array_t<double> delta = py::cast<py::array>(coordinates[5]);
375
- py::array_t<double> chi = py::cast<py::array>(coordinates[6]);
376
- py::array_t<double> charge_ratio = py::cast<py::array>(coordinates[7]);
377
- py::array_t<double> s = py::cast<py::array>(coordinates[8]);
378
- py::array_t<int64_t> pdgid = py::cast<py::array>(coordinates[9]);
379
- py::array_t<int64_t> trackid = py::cast<py::array>(coordinates[10]);
380
- py::array_t<int64_t> state = py::cast<py::array>(coordinates[11]);
381
- py::array_t<int64_t> at_element = py::cast<py::array>(coordinates[12]);
382
- py::array_t<int64_t> at_turn = py::cast<py::array>(coordinates[13]);
383
-
384
- // Obtain the buffers
385
- py::buffer_info x_buff = x.request();
386
- py::buffer_info y_buff = y.request();
387
- py::buffer_info px_buff = px.request();
388
- py::buffer_info py_buff = py.request();
389
- py::buffer_info zeta_buff = zeta.request();
390
- py::buffer_info delta_buff = delta.request();
391
- py::buffer_info chi_buff = chi.request();
392
- py::buffer_info charge_ratio_buff = charge_ratio.request();
393
- py::buffer_info s_buff = s.request();
394
- py::buffer_info pdgid_buff = pdgid.request();
395
- py::buffer_info id_buff = trackid.request();
396
- py::buffer_info state_buff = state.request();
397
- py::buffer_info at_element_buff = at_element.request();
398
- py::buffer_info at_turn_buff = at_turn.request();
399
-
400
- // Get the pointers for iteration
401
- auto x_ptr = static_cast<double *>(x_buff.ptr);
402
- auto y_ptr = static_cast<double *>(y_buff.ptr);
403
- auto px_ptr = static_cast<double *>(px_buff.ptr);
404
- auto py_ptr = static_cast<double *>(py_buff.ptr);
405
- auto zeta_ptr = static_cast<double *>(zeta_buff.ptr);
406
- auto delta_ptr = static_cast<double *>(delta_buff.ptr);
407
- auto chi_ptr = static_cast<double *>(chi_buff.ptr);
408
- auto charge_ratio_ptr = static_cast<double *>(charge_ratio_buff.ptr);
409
- auto s_ptr = static_cast<double *>(s_buff.ptr);
410
- auto pdgid_ptr = static_cast<int64_t *>(pdgid_buff.ptr);
411
- auto trackid_ptr = static_cast<int64_t *>(id_buff.ptr);
412
- auto state_ptr = static_cast<int64_t *>(state_buff.ptr);
413
- auto at_element_ptr = static_cast<int64_t *>(at_element_buff.ptr);
414
- auto at_turn_ptr = static_cast<int64_t *>(at_turn_buff.ptr);
415
-
416
- // N.B book keeping needed
417
- // Note: Load and and transfer for surviving primaries
418
- // Secondaries inherit the element and turn of parent particle
419
- //auto at_element = static_cast<int64_t *>(at_element.ptr);
420
- //auto turn = static_cast<int64_t *>(turn.ptr);
421
-
422
-
423
- // Prepare the buffers for writing out the products
424
- // New numpy arrays are allocated for writing the products
425
-
426
- // Access the sampler hits - particles reaching the planes for transport back
427
- const BDSHitsCollectionSamplerLink* hits = bds->SamplerHits();
428
-
429
- //size_t hitsCount = hits ? hits->GetSize() : 0;
430
-
431
- size_t hitsCount = 0;
432
- if (hits)
433
- {
434
- hitsCount = hits->GetSize();
435
- }
436
- else
437
- {
438
- // There were no hits - check if there were any active particles at all coming in
439
- if (!stp->Size())
440
- {
441
- // A particle needs to be added to the bunch and the GetNextParticleLocal method
442
- // must be called to initialise the variables and ensure a safe deletion of the
443
- // underlying BDSBunch object. This will not be needed in the next release of BDSIM
444
- addParticle(0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0);
445
- // The dummy particle added is never used, as the collimateReturn method terminates
446
- // the processing
447
- stp->GetNextParticleLocal();
448
- }
449
- }
450
-
451
-
452
- // Count the number of secondary particles
453
- size_t secondaryCount = 0;
454
- for (size_t i = 0; i < hitsCount; i++)
455
- {
456
- auto hit = (*hits)[i];
457
- if (hit->externalParticleID != hit->externalParentID) { secondaryCount++; }
458
- }
459
-
460
- // The output arrays has slots for all primary particles, regardless if lost or not, and for secondary particles
461
- size_t output_size = secondaryCount;
462
-
463
- // TODO: this is mostly default buffers, so there are probably simpler constructors to use
464
- // Prepare the numpy array that will be returned
465
- auto x_out = py::array(py::buffer_info(
466
- nullptr, /* Pointer to data (nullptr -> ask NumPy to allocate!) */
467
- sizeof(double), /* Size of one item */
468
- py::format_descriptor<double>::value, /* Buffer format */
469
- 1, /* How many dimensions? */
470
- { output_size }, /* Number of elements for each dimension */
471
- { sizeof(double) } /* Strides for each dimension */
472
- ));
473
-
474
- auto y_out = py::array(py::buffer_info(
475
- nullptr,
476
- sizeof(double),
477
- py::format_descriptor<double>::value,
478
- 1,
479
- { output_size },
480
- { sizeof(double) }
481
- ));
482
-
483
- auto px_out = py::array(py::buffer_info(
484
- nullptr,
485
- sizeof(double),
486
- py::format_descriptor<double>::value,
487
- 1,
488
- { output_size },
489
- { sizeof(double) }
490
- ));
491
-
492
- auto py_out = py::array(py::buffer_info(
493
- nullptr,
494
- sizeof(double),
495
- py::format_descriptor<double>::value,
496
- 1,
497
- { output_size },
498
- { sizeof(double) }
499
- ));
500
-
501
- auto zeta_out = py::array(py::buffer_info(
502
- nullptr,
503
- sizeof(double),
504
- py::format_descriptor<double>::value,
505
- 1,
506
- { output_size },
507
- { sizeof(double) }
508
- ));
509
-
510
- auto delta_out = py::array(py::buffer_info(
511
- nullptr,
512
- sizeof(double),
513
- py::format_descriptor<double>::value,
514
- 1,
515
- { output_size },
516
- { sizeof(double) }
517
- ));
518
-
519
- auto s_out = py::array(py::buffer_info(
520
- nullptr,
521
- sizeof(double),
522
- py::format_descriptor<double>::value,
523
- 1,
524
- { output_size },
525
- { sizeof(double) }
526
- ));
527
-
528
- auto pdgid_out = py::array(py::buffer_info(
529
- nullptr,
530
- sizeof(int64_t),
531
- py::format_descriptor<int64_t>::value,
532
- 1,
533
- { output_size },
534
- { sizeof(int64_t) }
535
- ));
536
-
537
- auto trackid_out = py::array(py::buffer_info(
538
- nullptr,
539
- sizeof(int64_t),
540
- py::format_descriptor<int64_t>::value,
541
- 1,
542
- { output_size },
543
- { sizeof(int64_t) }
544
- ));
545
-
546
- auto state_out = py::array(py::buffer_info(
547
- nullptr,
548
- sizeof(int64_t),
549
- py::format_descriptor<int64_t>::value,
550
- 1,
551
- { output_size },
552
- { sizeof(int64_t) }
553
- ));
554
-
555
- auto at_element_out = py::array(py::buffer_info(
556
- nullptr,
557
- sizeof(int64_t),
558
- py::format_descriptor<int64_t>::value,
559
- 1,
560
- { output_size },
561
- { sizeof(int64_t) }
562
- ));
563
-
564
- auto at_turn_out = py::array(py::buffer_info(
565
- nullptr,
566
- sizeof(int64_t),
567
- py::format_descriptor<int64_t>::value,
568
- 1,
569
- { output_size },
570
- { sizeof(int64_t) }
571
- ));
572
-
573
- auto massratio_out = py::array(py::buffer_info(
574
- nullptr,
575
- sizeof(double),
576
- py::format_descriptor<double>::value,
577
- 1,
578
- { output_size },
579
- { sizeof(double) }
580
- ));
581
-
582
- auto chargeratio_out = py::array(py::buffer_info(
583
- nullptr,
584
- sizeof(double),
585
- py::format_descriptor<double>::value,
586
- 1,
587
- { output_size },
588
- { sizeof(double) }
589
- ));
590
-
591
- auto x_prod_buf = x_out.request();
592
- auto y_prod_buf = y_out.request();
593
- auto px_prod_buf = px_out.request();
594
- auto py_prod_buf = py_out.request();
595
- auto zeta_prod_buf = zeta_out.request();
596
- auto delta_prod_buf = delta_out.request();
597
- auto s_prod_buf = s_out.request();
598
- auto pdgid_prod_buf = pdgid_out.request();
599
- auto trackid_prod_buf = trackid_out.request();
600
- auto state_prod_buf = state_out.request();
601
- auto at_element_prod_buf = at_element_out.request();
602
- auto at_turn_prod_buf = at_turn_out.request();
603
- auto massratio_prod_buf = massratio_out.request();
604
- auto chargeratio_prod_buf = chargeratio_out.request();
605
-
606
- auto *x_prod_ptr = (double *) x_prod_buf.ptr;
607
- auto *y_prod_ptr = (double *) y_prod_buf.ptr;
608
- auto *px_prod_ptr = (double *) px_prod_buf.ptr;
609
- auto *py_prod_ptr = (double *) py_prod_buf.ptr;
610
- auto *zeta_prod_ptr = (double *) zeta_prod_buf.ptr;
611
- auto *delta_prod_ptr = (double *) delta_prod_buf.ptr;
612
- auto *s_prod_ptr = (double *) s_prod_buf.ptr;
613
- auto *pdgid_prod_ptr = (int64_t *) pdgid_prod_buf.ptr;
614
- auto *trackid_prod_ptr = (int64_t *) trackid_prod_buf.ptr;
615
- auto *state_prod_ptr = (int64_t *) state_prod_buf.ptr;
616
- auto *at_element_prod_ptr = (int64_t *) at_element_prod_buf.ptr;
617
- auto *at_turn_prod_ptr = (int64_t *) at_turn_prod_buf.ptr;
618
- auto *massratio_prod_ptr = (double *) massratio_prod_buf.ptr;
619
- auto *chargeratio_prod_ptr = (double *) chargeratio_prod_buf.ptr;
620
-
621
- // Loop through the particles in the *original* bunch - the primaries
622
- size_t hits_index = 0;
623
- bool prim_survied = false;
624
- // double sum_deltaplusone_sec = 0.0;
625
- double sum_secondary_energy = 0.0;
626
-
627
- size_t prod_write_index = 0;
628
-
629
- for (size_t i=0; i < particleActiveState.size(); i++){
630
- if (!particleActiveState.at(i)){
631
- continue; // This was an inactive particle that hasn't been processed, do not change it
632
- }
633
-
634
- auto xtrack_part = xtrackParticles.at(i); // Get the cached coordinates of the original xtrack particle
635
-
636
- auto part = stp->GetNextParticle(); // Advance through the bunch
637
- auto prim_part_id = stp->CurrentExternalParticleID(); // Get the ID of the primary particle
638
-
639
- // Now start looping over the hits - the particles to be returned to the tracker
640
- // These can be primary or secondary particles. Each primary can produce 0, 1, or 2+ products
641
- // The products need to be sorted to keep the array order - surviving primary particles are all
642
- // filled in first. If a primary didn't survive, keep the original coordinates and make it inactive.
643
- // The hits are ordered by primary event, so just need one loop.
644
- while (hits_index < hitsCount)
645
- {
646
- BDSHitSamplerLink* hit = (*hits)[hits_index];
647
-
648
- if (hit->externalParentID != prim_part_id) { // The hits corresponding to the current primary are exhausted
649
- break;
650
- }
651
-
652
- const BDSParticleCoordsFull &coords = hit->coords;
653
-
654
- double qratio = hit->charge / refParticleDefinition->Charge();
655
- double mratio = hit->mass / refParticleDefinition->Mass();
656
-
657
- double dp = (hit->momentum / mratio - refParticleDefinition->Momentum()) / refParticleDefinition->Momentum();
658
-
659
- double collLength = bds->GetArcLengthOfLinkElement(currentCollimatorName);
660
- /// Need to compensate for the geometry construction in BDSIM
661
- /// There is a safety margin that is added to the collimator legnth
662
- double collMargin = 2.5 * BDSSamplerCustom::ChordLength();
663
- double zt = refParticleDefinition->Beta() * CLHEP::c_light * ((collLength + collMargin) / (CLHEP::c_light * refParticleDefinition->Beta()) - coords.T);
664
-
665
- double oneplusdelta = (1 + dp) * mratio;
666
-
667
- auto track_id = hit->externalParticleID;
668
- auto parent_id = hit->externalParentID;
669
- auto pdg_id = hit->pdgID;
670
-
671
- if (track_id == parent_id){
672
- // This is a primary particle as its parent is itself
673
- prim_survied = true;
674
-
675
- x_ptr[i] = coords.x / CLHEP::m;
676
- y_ptr[i] = coords.y / CLHEP::m;
677
- px_ptr[i] = coords.xp * oneplusdelta; // convert back to px proper
678
- py_ptr[i] = coords.yp * oneplusdelta;
679
- zeta_ptr[i] = zt / CLHEP::m;
680
- delta_ptr[i] = dp;
681
- s_ptr[i] = xtrack_part->s + collLength / CLHEP::m;
682
- //trackid_ptr[i] = track_id; // Don't touch the primary particle id
683
- state_ptr[i] = 1; // active
684
- }
685
- else
686
- {
687
- // Secondary particles are populated in newly allocated arrays
688
- x_prod_ptr[prod_write_index] = coords.x / CLHEP::m;
689
- y_prod_ptr[prod_write_index] = coords.y / CLHEP::m;
690
- px_prod_ptr[prod_write_index] = coords.xp * oneplusdelta; // convert back to px proper
691
- py_prod_ptr[prod_write_index] = coords.yp * oneplusdelta; // convert back to py proper;
692
- zeta_prod_ptr[prod_write_index] = zt / CLHEP::m;
693
- delta_prod_ptr[prod_write_index] = dp;
694
- s_prod_ptr[prod_write_index] = xtrack_part->s + collLength / CLHEP::m;
695
- pdgid_prod_ptr[prod_write_index] = pdg_id;
696
- trackid_prod_ptr[prod_write_index] = parent_id;
697
- state_prod_ptr[prod_write_index] = 1; // active
698
- at_element_prod_ptr[prod_write_index] = xtrack_part->at_element; // active
699
- at_turn_prod_ptr[prod_write_index] = xtrack_part->at_turn; // active
700
- massratio_prod_ptr[prod_write_index] = mratio;
701
- chargeratio_prod_ptr[prod_write_index] = qratio;
702
-
703
- sum_secondary_energy += std::sqrt(std::pow(hit->momentum,2) + std::pow(hit->mass,2));
704
- prod_write_index++;
705
- }
706
-
707
- hits_index++;
708
- }
709
-
710
- if (!prim_survied) // Primary didn't survive - set inactive
711
- {
712
- state_ptr[i] = -333; // inactive
713
-
714
- // Correct the energy of the lost primary particle to account for the production of secondaries
715
- // The effective delta is such that the lost particle has the effective delta
716
- // which corresponds to the energy in - energy out for this primary
717
-
718
- // reconstruct the incoming primary particle energy
719
- G4double qprim = charge_ratio_ptr[i] * refParticleDefinition->Charge();
720
- G4double mass_ratio_prim = charge_ratio_ptr[i] / chi_ptr[i];
721
- G4double p_prim = refParticleDefinition->Momentum() * (delta_ptr[i] + 1) * mass_ratio_prim;
722
- G4double mass_prim = mass_ratio_prim * refParticleDefinition->Mass();
723
- G4double energy_prim = std::sqrt(std::pow(p_prim, 2) + std::pow(mass_prim, 2));
724
-
725
- // compute the effective delta
726
- G4double energy_diff = energy_prim - sum_secondary_energy;
727
- G4double p_eff;
728
- G4double squared_energy_mass_diff = std::pow(energy_diff, 2) - std::pow(mass_prim, 2);
729
- if (squared_energy_mass_diff < 0){
730
- // This means that the total energy escaping includes part of the rest mass of
731
- // the primary. Tolerate the error for now, as otherwise need to adjust also the
732
- // mass and PDG id of the lost primary particle
733
- p_eff = 0;
734
- }
735
- else
736
- {
737
- p_eff = std::sqrt(squared_energy_mass_diff);
738
- }
739
- G4double delta_eff = (p_eff / mass_ratio_prim - refParticleDefinition->Momentum()) / refParticleDefinition->Momentum();
740
- delta_ptr[i] = delta_eff;
741
- }
742
- prim_survied = false; // reset for next particle
743
- sum_secondary_energy = 0.0;
744
- }
745
-
746
- auto result = py::dict();
747
-
748
- result["s"] = s_out;
749
- result["x"] = x_out;
750
- result["px"] = px_out;
751
- result["y"] = y_out;
752
- result["py"] = py_out;
753
- result["zeta"] = zeta_out;
754
- result["delta"] = delta_out;
755
- result["pdg_id"] = pdgid_out;
756
- result["at_element"] = at_element_out;
757
- result["at_turn"] = at_turn_out;
758
- result["mass_ratio"] = massratio_out;
759
- result["charge_ratio"] = chargeratio_out;
760
- result["parent_particle_id"] = trackid_out;
761
-
762
- return result;
763
- }