xcoll 0.4.0__py3-none-any.whl → 0.5.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 (324) hide show
  1. xcoll/__init__.py +2 -1
  2. xcoll/beam_elements/__init__.py +9 -2
  3. xcoll/beam_elements/absorber.py +2 -2
  4. xcoll/beam_elements/base.py +105 -67
  5. xcoll/beam_elements/blowup.py +198 -0
  6. xcoll/beam_elements/{collimators_src → elements_src}/black_absorber.h +21 -3
  7. xcoll/beam_elements/{collimators_src → elements_src}/black_crystal.h +20 -2
  8. xcoll/beam_elements/elements_src/blowup.h +42 -0
  9. xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
  10. xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +19 -2
  11. xcoll/beam_elements/{collimators_src → elements_src}/everest_collimator.h +19 -3
  12. xcoll/beam_elements/{collimators_src → elements_src}/everest_crystal.h +30 -9
  13. xcoll/beam_elements/everest.py +5 -6
  14. xcoll/beam_elements/monitor.py +428 -0
  15. xcoll/colldb.py +103 -74
  16. xcoll/general.py +4 -4
  17. xcoll/initial_distribution.py +18 -6
  18. xcoll/install.py +3 -1
  19. xcoll/interaction_record/interaction_record.py +127 -81
  20. xcoll/interaction_record/interaction_record_src/interaction_record.h +43 -43
  21. xcoll/line_tools.py +8 -9
  22. xcoll/lossmap.py +48 -38
  23. xcoll/scattering_routines/everest/amorphous.h +4 -11
  24. xcoll/scattering_routines/everest/channeling.h +3 -8
  25. xcoll/scattering_routines/everest/everest.h +4 -1
  26. xcoll/scattering_routines/everest/jaw.h +4 -3
  27. xcoll/scattering_routines/everest/materials.py +35 -15
  28. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  29. xcoll/scattering_routines/everest/nuclear_interaction.h +1 -1
  30. xcoll/scattering_routines/everest/properties.h +6 -1
  31. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
  32. xcoll/scattering_routines/geant4/collimasim/.git +1 -0
  33. xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
  34. xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
  35. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
  36. xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
  37. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
  38. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
  39. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
  40. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
  41. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
  42. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
  43. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
  44. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
  45. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
  46. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
  47. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
  48. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
  49. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
  50. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
  51. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
  52. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
  53. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
  54. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
  55. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
  275. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
  276. xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
  277. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
  278. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
  279. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
  280. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
  281. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
  282. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
  283. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
  284. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
  285. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
  286. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
  287. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
  288. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
  289. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
  290. xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
  291. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
  292. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
  293. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
  294. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
  295. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
  296. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
  297. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
  298. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
  299. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
  300. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
  301. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
  302. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
  303. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
  304. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
  305. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
  306. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
  307. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
  308. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
  309. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
  310. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
  311. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
  312. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
  313. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
  314. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
  315. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
  316. xcoll/scattering_routines/geometry/collimator_geometry.h +9 -10
  317. xcoll/scattering_routines/geometry/crystal_geometry.h +9 -6
  318. {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/METADATA +1 -1
  319. xcoll-0.5.1.dist-info/RECORD +413 -0
  320. xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
  321. xcoll-0.4.0.dist-info/RECORD +0 -126
  322. {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/LICENSE +0 -0
  323. {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/NOTICE +0 -0
  324. {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/WHEEL +0 -0
@@ -18,34 +18,35 @@ class InteractionRecord(xt.BeamElement):
18
18
  '_index': xt.RecordIndex,
19
19
  'at_element': xo.Int64[:],
20
20
  'at_turn': xo.Int64[:],
21
- 'ds': xo.Float64[:],
22
21
  '_inter': xo.Int64[:],
23
- 'parent_id': xo.Int64[:],
24
- 'parent_x': xo.Float64[:],
25
- 'parent_px': xo.Float64[:],
26
- 'parent_y': xo.Float64[:],
27
- 'parent_py': xo.Float64[:],
28
- 'parent_zeta': xo.Float64[:],
29
- 'parent_delta': xo.Float64[:],
30
- 'parent_energy': xo.Float64[:],
31
- 'parent_mass': xo.Float64[:],
32
- 'parent_charge': xo.Int64[:],
33
- 'parent_z': xo.Int64[:],
34
- 'parent_a': xo.Int64[:],
35
- 'parent_pdgid': xo.Int64[:],
36
- 'child_id': xo.Int64[:],
37
- 'child_x': xo.Float64[:],
38
- 'child_px': xo.Float64[:],
39
- 'child_y': xo.Float64[:],
40
- 'child_py': xo.Float64[:],
41
- 'child_zeta': xo.Float64[:],
42
- 'child_delta': xo.Float64[:],
43
- 'child_energy': xo.Float64[:],
44
- 'child_mass': xo.Float64[:],
45
- 'child_charge': xo.Int64[:],
46
- 'child_z': xo.Int64[:],
47
- 'child_a': xo.Int64[:],
48
- 'child_pdgid': xo.Int64[:],
22
+ 'id_before': xo.Int64[:],
23
+ 's_before': xo.Float64[:],
24
+ 'x_before': xo.Float64[:],
25
+ 'px_before': xo.Float64[:],
26
+ 'y_before': xo.Float64[:],
27
+ 'py_before': xo.Float64[:],
28
+ 'zeta_before': xo.Float64[:],
29
+ 'delta_before': xo.Float64[:],
30
+ 'energy_before': xo.Float64[:],
31
+ 'mass_before': xo.Float64[:],
32
+ 'charge_before': xo.Int64[:],
33
+ 'z_before': xo.Int64[:],
34
+ 'a_before': xo.Int64[:],
35
+ 'pdgid_before': xo.Int64[:],
36
+ 'id_after': xo.Int64[:],
37
+ 's_after': xo.Float64[:],
38
+ 'x_after': xo.Float64[:],
39
+ 'px_after': xo.Float64[:],
40
+ 'y_after': xo.Float64[:],
41
+ 'py_after': xo.Float64[:],
42
+ 'zeta_after': xo.Float64[:],
43
+ 'delta_after': xo.Float64[:],
44
+ 'energy_after': xo.Float64[:],
45
+ 'mass_after': xo.Float64[:],
46
+ 'charge_after': xo.Int64[:],
47
+ 'z_after': xo.Int64[:],
48
+ 'a_after': xo.Int64[:],
49
+ 'pdgid_after': xo.Int64[:],
49
50
  }
50
51
 
51
52
  allow_track = False
@@ -58,45 +59,69 @@ class InteractionRecord(xt.BeamElement):
58
59
 
59
60
 
60
61
  @classmethod
61
- def start(cls, line, names=None, *, record_touches=None, record_scatterings=None, capacity=1e6, io_buffer=None):
62
- names = _get_xcoll_elements(line, names)
62
+ def start(cls, *, line=None, elements=None, names=None, record_impacts=None, record_exits=None,
63
+ record_scatterings=None, capacity=1e6, io_buffer=None, coll_ids=None):
64
+ elements, names = _get_xcoll_elements(line, elements, names)
63
65
  if len(names) == 0:
64
66
  return
65
- elements = [line[name] for name in names]
66
67
  capacity = int(capacity)
67
- if io_buffer is None:
68
- io_buffer = xt.new_io_buffer(capacity=capacity)
69
- if record_touches is None and record_scatterings is None:
70
- record_touches = True
68
+
69
+ if getattr(line, 'tracker', None) is None \
70
+ or getattr(line.tracker, 'io_buffer', None) is None:
71
+ if io_buffer is None:
72
+ io_buffer = xt.new_io_buffer(capacity=capacity)
73
+ elif io_buffer is not None:
74
+ raise ValueError("Cannot provide io_buffer when tracker already built!")
75
+ else:
76
+ io_buffer = line.tracker.io_buffer
77
+ if capacity > io_buffer.capacity:
78
+ io_buffer.grow(capacity - io_buffer.capacity)
79
+ if record_impacts is None and record_scatterings is None:
80
+ record_impacts = True
71
81
  record_scatterings = True
72
- elif record_touches is None:
73
- record_touches = not record_scatterings
82
+ elif record_impacts is None:
83
+ record_impacts = not record_scatterings
74
84
  elif record_scatterings is None:
75
- record_scatterings = not record_touches
76
- assert record_touches is True or record_touches is False
85
+ record_scatterings = not record_impacts
86
+ if record_exits is None:
87
+ # record_exits defaults to True only if the other two are True
88
+ record_exits = record_impacts and record_scatterings
89
+ assert record_impacts is True or record_impacts is False
90
+ assert record_exits is True or record_exits is False
77
91
  assert record_scatterings is True or record_scatterings is False
78
92
  for el in elements:
79
- if not el.record_touches and not el.record_scatterings:
80
- el.record_touches = record_touches
93
+ if not el.record_impacts and not el.record_exits and not el.record_scatterings:
94
+ el.record_impacts = record_impacts
95
+ el.record_exits = record_exits
81
96
  el.record_scatterings = record_scatterings
82
97
  record = xt.start_internal_logging(io_buffer=io_buffer, capacity=capacity, \
83
98
  elements=elements)
84
99
  record._line = line
85
100
  record._io_buffer = io_buffer
86
- record._recording_elements = names
87
- record._coll_ids = {name: line.element_names.index(name) for name in names}
88
- record._coll_names = {vv: kk for kk, vv in record._coll_ids.items()}
101
+ recording_elements = names if len(names) > 0 else elements
102
+ record._recording_elements = recording_elements
103
+ if coll_ids is None:
104
+ if line is None:
105
+ if len(names) > 0:
106
+ record._coll_ids = {name: idx for idx, name in enumerate(names)}
107
+ else:
108
+ record._coll_ids = {name: line.element_names.index(name) for name in names}
109
+ else:
110
+ assert len(coll_ids) == len(names)
111
+ record._coll_ids = {name: idx for name, idx in zip(names, coll_ids)}
112
+ if hasattr(record, '_coll_ids'):
113
+ record._coll_names = {vv: kk for kk, vv in record._coll_ids.items()}
89
114
  return record
90
115
 
91
- def stop(self, names=None):
116
+ def stop(self, *, elements=False, names=False):
92
117
  self.assert_class_init()
93
- names = _get_xcoll_elements(self.line, names)
94
- elements = [self.line[name] for name in names]
95
- if self.line.tracker is not None:
118
+ elements, names = _get_xcoll_elements(self.line, elements, names)
119
+ if self.line is not None and self.line.tracker is not None:
96
120
  self.line.tracker._check_invalidated()
97
121
  xt.stop_internal_logging(elements=elements)
98
122
  # Removed the stopped collimators from list of logged elements
99
- self._recording_elements = list(set(self._recording_elements) - set(names))
123
+ stopping_elements = names if len(names) > 0 else elements
124
+ self._recording_elements = list(set(self._recording_elements) - set(stopping_elements))
100
125
 
101
126
 
102
127
  def assert_class_init(self):
@@ -145,10 +170,10 @@ class InteractionRecord(xt.BeamElement):
145
170
  val = []
146
171
  record_start = _get_xcoll_elements(self.line, val)
147
172
  self.stop(set(self.recording_elements) - set(record_start))
148
- elements = [line[name] for name in record_start]
149
- for el in elements:
150
- if not el.record_touches and not el.record_scatterings:
151
- el.record_touches = True
173
+ elements = [self.line[name] for name in record_start]
174
+ for el in elements: # TODO: this should be smarter
175
+ if not el.record_impacts and not el.record_scatterings:
176
+ el.record_impacts = True
152
177
  el.record_scatterings = True
153
178
  xt.start_internal_logging(io_buffer=self.io_buffer, capacity=self.capacity, \
154
179
  record=self, elements=elements)
@@ -172,25 +197,29 @@ class InteractionRecord(xt.BeamElement):
172
197
 
173
198
  def _collimator_id(self, element_name):
174
199
  if not hasattr(self, '_coll_ids'):
175
- return element_id
200
+ return element_name
176
201
  elif element_name not in self._coll_ids:
177
202
  raise ValueError(f"Element {element_name} not found in list of collimators of this record table! "
178
203
  + f"Did the line change without updating the list in the table?")
179
204
  else:
180
205
  return self._coll_ids[element_name]
181
206
 
182
- def to_pandas(self):
207
+ def to_pandas(self, frame=None):
208
+ if frame is None:
209
+ frame = 'jaw'
210
+ frame = frame.lower()
211
+ if frame not in ['jaw', 'collimator', 'lab']:
212
+ raise ValueError(f"Invalid frame {frame}. Must be 'jaw', 'collimator', or 'lab'!")
183
213
  n_rows = self._index.num_recorded
184
214
  coll_header = 'collimator' if hasattr(self, '_coll_names') else 'collimator_id'
185
215
  df = pd.DataFrame({
186
216
  'turn': self.at_turn[:n_rows],
187
217
  coll_header: [self._collimator_name(element_id) for element_id in self.at_element[:n_rows]],
188
218
  'interaction_type': [interactions[inter] for inter in self._inter[:n_rows]],
189
- 'ds': self.ds[:n_rows],
190
219
  **{
191
- f'{p}_{val}': getattr(self, f'{p}_{val}')[:n_rows]
192
- for p in ['parent', 'child']
193
- for val in ['id', 'x', 'px', 'y', 'py', 'zeta', 'delta', 'energy', 'mass', 'charge', 'z', 'a', 'pdgid']
220
+ f'{val}_{p}': getattr(self, f'{val}_{p}')[:n_rows]
221
+ for p in ['before', 'after']
222
+ for val in ['id', 's', 'x', 'px', 'y', 'py', 'zeta', 'delta', 'energy', 'mass', 'charge', 'z', 'a', 'pdgid']
194
223
  }
195
224
  })
196
225
  return df
@@ -207,46 +236,63 @@ class InteractionRecord(xt.BeamElement):
207
236
  mask = mask & (self.at_turn == turn)
208
237
  df = pd.DataFrame({
209
238
  'int': [shortcuts[inter] for inter in self._inter[mask]],
210
- 'pid': self.parent_id[mask]
239
+ 'pid': self.id_before[mask]
211
240
  })
212
241
  return df.groupby('pid', sort=False)['int'].agg(list)
213
242
  else:
214
243
  df = pd.DataFrame({
215
244
  'int': [shortcuts[inter] for inter in self._inter[mask]],
216
245
  'turn': self.at_turn[mask],
217
- 'pid': self.parent_id[mask]
246
+ 'pid': self.id_before[mask]
218
247
  })
219
248
  return df.groupby(['pid', 'turn'], sort=False)['int'].apply(list)
220
249
 
221
- def first_touch_per_turn(self):
250
+ def first_touch_per_turn(self, frame=None):
222
251
  n_rows = self._index.num_recorded
223
- df = pd.DataFrame({'parent_id': self.parent_id[:n_rows],
252
+ df = pd.DataFrame({'id_before': self.id_before[:n_rows],
224
253
  'at_turn': self.at_turn[:n_rows],
225
254
  'at_element': self.at_element[:n_rows]})
226
255
  mask = np.char.startswith(self.interaction_type[:n_rows], 'Enter Jaw')
227
- idx_first = [group.at_element.idxmin() for _, group in df[mask].groupby(['at_turn', 'parent_id'], sort=False)]
228
- df_first = self.to_pandas().loc[idx_first]
256
+ idx_first = [group.at_element.idxmin() for _, group in df[mask].groupby(['at_turn', 'id_before'], sort=False)]
257
+ df_first = self.to_pandas(frame=frame).loc[idx_first]
229
258
  df_first.insert(2, "jaw", df_first.interaction_type.astype(str).str[-1])
230
- to_drop = ['ds', 'interaction_type',
231
- *[col for col in df_first.columns if col.startswith('child_')]]
232
- to_rename = {col: col.replace('parent_', '') for col in df_first.columns if col.startswith('parent_')}
259
+ to_drop = ['interaction_type',
260
+ *[col for col in df_first.columns if col.endswith('_after')]]
261
+ to_rename = {col: col.replace('_before', '') for col in df_first.columns if col.endswith('before')}
262
+ to_rename['id_before'] = 'pid'
233
263
  return df_first.drop(columns=to_drop).rename(columns=to_rename)
234
264
 
235
265
 
236
- def _get_xcoll_elements(line, names):
237
- from xcoll import element_classes
238
- if names is None or names is True:
239
- names = line.get_elements_of_type(element_classes)[1]
240
- if len(names) == 0:
241
- raise ValueError("No Xcoll elements in line!")
242
- if names is False:
243
- names = []
244
- if not hasattr(names, '__iter__') or isinstance(names, str):
266
+ def _get_xcoll_elements(line=None, elements=None, names=None):
267
+ from xcoll.beam_elements import block_classes
268
+ if names is not None and names is not False and \
269
+ (not hasattr(names, '__iter__') or isinstance(names, str)):
245
270
  names = [names]
246
- for name in names:
247
- if name not in line.element_names:
248
- raise ValueError(f"Element {name} not found in line!")
249
- if not isinstance(line[name], element_classes):
271
+ if elements is not None and elements is not False and \
272
+ (not hasattr(elements, '__iter__') or isinstance(elements, str)):
273
+ elements = [elements]
274
+ if line is None:
275
+ if elements is None:
276
+ raise ValueError("No line nor elements provided!")
277
+ else:
278
+ if elements is not None and elements is not False:
279
+ raise ValueError("Cannot provide both line and elements!")
280
+ if names is None or names is True:
281
+ elements, names = line.get_elements_of_type(block_classes)
282
+ if len(names) == 0:
283
+ raise ValueError("No Xcoll elements in line!")
284
+ elif names is False:
285
+ names = []
286
+ elements = []
287
+ else:
288
+ assert elements is not False
289
+ for name in names:
290
+ if name not in line.element_names:
291
+ raise ValueError(f"Element {name} not found in line!")
292
+ elements = [line[name] for name in names]
293
+ for idx, element in enumerate(elements):
294
+ if not isinstance(element, block_classes):
295
+ name = name[idx] if names is not None else element.__class__.__name__
250
296
  raise ValueError(f"Element {name} not an Xcoll element!")
251
- return names
297
+ return elements, names
252
298
 
@@ -24,7 +24,6 @@ int64_t InteractionRecordData_log(InteractionRecordData record, RecordIndex reco
24
24
  if (i_slot>=0){
25
25
  InteractionRecordData_set_at_element(record, i_slot, LocalParticle_get_at_element(parent));
26
26
  InteractionRecordData_set_at_turn(record, i_slot, LocalParticle_get_at_turn(parent));
27
- InteractionRecordData_set_ds(record, i_slot, 0);
28
27
  InteractionRecordData_set__inter(record, i_slot, interaction);
29
28
 
30
29
  double charge_ratio = LocalParticle_get_charge_ratio(parent);
@@ -33,35 +32,37 @@ int64_t InteractionRecordData_log(InteractionRecordData record, RecordIndex reco
33
32
  ) * mass_ratio * LocalParticle_get_p0c(parent);
34
33
  // All fields have to be written, or the arrays will not have the same length
35
34
  // TODO: maybe this is not true, as we are setting by slot index? Don't the arrays come pre-initialised?
36
- InteractionRecordData_set_parent_id(record, i_slot, LocalParticle_get_particle_id(parent));
37
- InteractionRecordData_set_parent_x(record, i_slot, LocalParticle_get_x(parent));
38
- InteractionRecordData_set_parent_px(record, i_slot, LocalParticle_get_px(parent));
39
- InteractionRecordData_set_parent_y(record, i_slot, LocalParticle_get_y(parent));
40
- InteractionRecordData_set_parent_py(record, i_slot, LocalParticle_get_py(parent));
41
- InteractionRecordData_set_parent_zeta(record, i_slot, LocalParticle_get_zeta(parent));
42
- InteractionRecordData_set_parent_delta(record, i_slot, LocalParticle_get_delta(parent));
43
- InteractionRecordData_set_parent_energy(record, i_slot, energy);
44
- InteractionRecordData_set_parent_mass(record, i_slot, mass_ratio*LocalParticle_get_mass0(parent));
45
- InteractionRecordData_set_parent_charge(record, i_slot, charge_ratio*LocalParticle_get_q0(parent));
35
+ InteractionRecordData_set_id_before(record, i_slot, LocalParticle_get_particle_id(parent));
36
+ InteractionRecordData_set_s_before(record, i_slot, LocalParticle_get_s(parent));
37
+ InteractionRecordData_set_x_before(record, i_slot, LocalParticle_get_x(parent));
38
+ InteractionRecordData_set_px_before(record, i_slot, LocalParticle_get_px(parent));
39
+ InteractionRecordData_set_y_before(record, i_slot, LocalParticle_get_y(parent));
40
+ InteractionRecordData_set_py_before(record, i_slot, LocalParticle_get_py(parent));
41
+ InteractionRecordData_set_zeta_before(record, i_slot, LocalParticle_get_zeta(parent));
42
+ InteractionRecordData_set_delta_before(record, i_slot, LocalParticle_get_delta(parent));
43
+ InteractionRecordData_set_energy_before(record, i_slot, energy);
44
+ InteractionRecordData_set_mass_before(record, i_slot, mass_ratio*LocalParticle_get_mass0(parent));
45
+ InteractionRecordData_set_charge_before(record, i_slot, charge_ratio*LocalParticle_get_q0(parent));
46
46
  // TODO: particle info
47
- InteractionRecordData_set_parent_z(record, i_slot, -1);
48
- InteractionRecordData_set_parent_a(record, i_slot, -1);
49
- InteractionRecordData_set_parent_pdgid(record, i_slot, -1);
47
+ InteractionRecordData_set_z_before(record, i_slot, -1);
48
+ InteractionRecordData_set_a_before(record, i_slot, -1);
49
+ InteractionRecordData_set_pdgid_before(record, i_slot, -1);
50
50
 
51
51
  // TODO: maybe this is not needed
52
- InteractionRecordData_set_child_id(record, i_slot, -1);
53
- InteractionRecordData_set_child_x(record, i_slot, -1);
54
- InteractionRecordData_set_child_px(record, i_slot, -1);
55
- InteractionRecordData_set_child_y(record, i_slot, -1);
56
- InteractionRecordData_set_child_py(record, i_slot, -1);
57
- InteractionRecordData_set_child_zeta(record, i_slot, -1);
58
- InteractionRecordData_set_child_delta(record, i_slot, -1);
59
- InteractionRecordData_set_child_energy(record, i_slot, -1);
60
- InteractionRecordData_set_child_mass(record, i_slot, -1);
61
- InteractionRecordData_set_child_charge(record, i_slot, -1);
62
- InteractionRecordData_set_child_z(record, i_slot, -1);
63
- InteractionRecordData_set_child_a(record, i_slot, -1);
64
- InteractionRecordData_set_child_pdgid(record, i_slot, -1);
52
+ InteractionRecordData_set_id_after(record, i_slot, -1);
53
+ InteractionRecordData_set_s_after(record, i_slot, -1);
54
+ InteractionRecordData_set_x_after(record, i_slot, -1);
55
+ InteractionRecordData_set_px_after(record, i_slot, -1);
56
+ InteractionRecordData_set_y_after(record, i_slot, -1);
57
+ InteractionRecordData_set_py_after(record, i_slot, -1);
58
+ InteractionRecordData_set_zeta_after(record, i_slot, -1);
59
+ InteractionRecordData_set_delta_after(record, i_slot, -1);
60
+ InteractionRecordData_set_energy_after(record, i_slot, -1);
61
+ InteractionRecordData_set_mass_after(record, i_slot, -1);
62
+ InteractionRecordData_set_charge_after(record, i_slot, -1);
63
+ InteractionRecordData_set_z_after(record, i_slot, -1);
64
+ InteractionRecordData_set_a_after(record, i_slot, -1);
65
+ InteractionRecordData_set_pdgid_after(record, i_slot, -1);
65
66
  }
66
67
  }
67
68
  // printf("Logging %i in slot %i\n", interaction, i_slot);
@@ -69,28 +70,27 @@ int64_t InteractionRecordData_log(InteractionRecordData record, RecordIndex reco
69
70
  }
70
71
 
71
72
  /*gpufun*/
72
- void InteractionRecordData_log_child(InteractionRecordData record, int64_t i_slot, LocalParticle* child, double ds){
73
+ void InteractionRecordData_log_child(InteractionRecordData record, int64_t i_slot, LocalParticle* child){
73
74
  if (record && i_slot>=0){
74
- InteractionRecordData_set_ds(record, i_slot, ds);
75
-
76
75
  double charge_ratio = LocalParticle_get_charge_ratio(child);
77
76
  double mass_ratio = charge_ratio / LocalParticle_get_chi(child);
78
77
  double energy = ( LocalParticle_get_ptau(child) + 1 / LocalParticle_get_beta0(child)
79
78
  ) * mass_ratio * LocalParticle_get_p0c(child);
80
- InteractionRecordData_set_child_id(record, i_slot, LocalParticle_get_particle_id(child));
81
- InteractionRecordData_set_child_x(record, i_slot, LocalParticle_get_x(child));
82
- InteractionRecordData_set_child_px(record, i_slot, LocalParticle_get_px(child));
83
- InteractionRecordData_set_child_y(record, i_slot, LocalParticle_get_y(child));
84
- InteractionRecordData_set_child_py(record, i_slot, LocalParticle_get_py(child));
85
- InteractionRecordData_set_child_zeta(record, i_slot, LocalParticle_get_zeta(child));
86
- InteractionRecordData_set_child_delta(record, i_slot, LocalParticle_get_delta(child));
87
- InteractionRecordData_set_child_energy(record, i_slot, energy);
88
- InteractionRecordData_set_child_mass(record, i_slot, mass_ratio*LocalParticle_get_mass0(child));
89
- InteractionRecordData_set_child_charge(record, i_slot, charge_ratio*LocalParticle_get_q0(child));
79
+ InteractionRecordData_set_id_after(record, i_slot, LocalParticle_get_particle_id(child));
80
+ InteractionRecordData_set_s_after(record, i_slot, LocalParticle_get_s(child));
81
+ InteractionRecordData_set_x_after(record, i_slot, LocalParticle_get_x(child));
82
+ InteractionRecordData_set_px_after(record, i_slot, LocalParticle_get_px(child));
83
+ InteractionRecordData_set_y_after(record, i_slot, LocalParticle_get_y(child));
84
+ InteractionRecordData_set_py_after(record, i_slot, LocalParticle_get_py(child));
85
+ InteractionRecordData_set_zeta_after(record, i_slot, LocalParticle_get_zeta(child));
86
+ InteractionRecordData_set_delta_after(record, i_slot, LocalParticle_get_delta(child));
87
+ InteractionRecordData_set_energy_after(record, i_slot, energy);
88
+ InteractionRecordData_set_mass_after(record, i_slot, mass_ratio*LocalParticle_get_mass0(child));
89
+ InteractionRecordData_set_charge_after(record, i_slot, charge_ratio*LocalParticle_get_q0(child));
90
90
  // TODO: particle info
91
- InteractionRecordData_set_child_z(record, i_slot, -1);
92
- InteractionRecordData_set_child_a(record, i_slot, -1);
93
- InteractionRecordData_set_child_pdgid(record, i_slot, -1);
91
+ InteractionRecordData_set_z_after(record, i_slot, -1);
92
+ InteractionRecordData_set_a_after(record, i_slot, -1);
93
+ InteractionRecordData_set_pdgid_after(record, i_slot, -1);
94
94
  // printf("Slot %i: length %f\n", i_slot, ds);
95
95
  }
96
96
  }
xcoll/line_tools.py CHANGED
@@ -6,17 +6,16 @@
6
6
  import numpy as np
7
7
  import xtrack as xt
8
8
 
9
- from .beam_elements import element_classes, collimator_classes
9
+ from .beam_elements import element_classes, _all_collimator_classes
10
10
 
11
11
 
12
12
  def assign_optics_to_collimators(line, nemitt_x=None, nemitt_y=None, twiss=None):
13
13
  if not line._has_valid_tracker():
14
14
  raise Exception("Please build tracker before setting the openings!")
15
- names = line.get_elements_of_type(collimator_classes)[1]
15
+ names = line.get_elements_of_type(_all_collimator_classes)[1]
16
16
  tw_upstream, tw_downstream = get_optics_at(names, twiss=twiss, line=line)
17
17
  beta_gamma_rel = line.particle_ref._xobject.gamma0[0]*line.particle_ref._xobject.beta0[0]
18
18
  for coll in names:
19
- print(coll)
20
19
  line[coll].assign_optics(name=coll, nemitt_x=nemitt_x, nemitt_y=nemitt_x, twiss_upstream=tw_upstream,
21
20
  twiss_downstream=tw_downstream, beta_gamma_rel=beta_gamma_rel)
22
21
 
@@ -36,7 +35,7 @@ def get_optics_at(names, *, twiss=None, line=None):
36
35
 
37
36
  def open_collimators(line, names=None):
38
37
  if names is None:
39
- names = line.get_elements_of_type(collimator_classes)[1]
38
+ names = line.get_elements_of_type(_all_collimator_classes)[1]
40
39
  if len(names) == 0:
41
40
  print("No collimators found in line.")
42
41
  else:
@@ -46,7 +45,7 @@ def open_collimators(line, names=None):
46
45
 
47
46
  def send_to_parking(line, names=None):
48
47
  if names is None:
49
- names = line.get_elements_of_type(collimator_classes)[1]
48
+ names = line.get_elements_of_type(_all_collimator_classes)[1]
50
49
  if len(names) == 0:
51
50
  print("No collimators found in line.")
52
51
  else:
@@ -70,9 +69,8 @@ def enable_scattering(line):
70
69
  or not np.isclose(el.nemitt_x, nemitt_x):
71
70
  raise ValueError("Not all collimators have the same "
72
71
  + "emittance. This is not supported.")
73
- el.enable_scattering()
74
- # self.line.tracker.io_buffer = self._io_buffer
75
- # self._set_record_interaction_record()
72
+ if hasattr(el, 'enable_scattering'):
73
+ el.enable_scattering()
76
74
 
77
75
  def disable_scattering(line):
78
76
  elements = line.get_elements_of_type(element_classes)[0]
@@ -80,4 +78,5 @@ def disable_scattering(line):
80
78
  print("No xcoll elements found in line.")
81
79
  else:
82
80
  for el in elements:
83
- el.disable_scattering()
81
+ if hasattr(el, 'disable_scattering'):
82
+ el.disable_scattering()
xcoll/lossmap.py CHANGED
@@ -12,13 +12,13 @@ import xtrack as xt
12
12
  import xpart as xp
13
13
  import xobjects as xo
14
14
 
15
- from .beam_elements import collimator_classes
15
+ from .beam_elements import _all_collimator_classes, _all_crystal_classes
16
16
 
17
17
 
18
18
  class LossMap:
19
19
 
20
20
  def __init__(self, line, part, *, line_is_reversed, interpolation=0.1,
21
- weights=None, weight_function=None):
21
+ weights=None, weight_function=None, verbose=True):
22
22
  self._line = line
23
23
  self._line_is_reversed = line_is_reversed
24
24
  self._machine_length = line.get_length()
@@ -34,26 +34,31 @@ class LossMap:
34
34
  raise ValueError("Use either 'weights' or 'weight_function', not both!")
35
35
  self._weights = part.sort(interleave_lost_particles=True)
36
36
 
37
- # loss location refinement
37
+ # Correct particles that are lost in aperture directly after collimator -> should be absorbed
38
+ self._correct_absorbed(verbose=verbose)
39
+
40
+ # Loss location refinement
38
41
  if interpolation is not None:
39
42
  self._interpolate()
40
43
 
41
44
  self._make_coll_summary()
42
45
  coll_summary = self._summary[self._summary.nabs > 0].to_dict('list')
43
- aper_s, aper_names, aper_nabs = self._get_aperture_losses()
46
+ aper_s, aper_names, aper_nabs, aper_energy = self._get_aperture_losses()
44
47
 
45
48
  self._lossmap = {
46
49
  'collimator': {
47
50
  's': coll_summary['s'],
48
51
  'name': coll_summary['collname'],
49
52
  'length': coll_summary['length'],
50
- 'n': coll_summary['nabs']
53
+ 'n': coll_summary['nabs'],
54
+ # 'e': coll_summary['energy']
51
55
  }
52
56
  ,
53
57
  'aperture': {
54
58
  's': aper_s,
55
59
  'name': aper_names,
56
- 'n': aper_nabs
60
+ 'n': aper_nabs,
61
+ # 'e': aper_energy
57
62
  }
58
63
  ,
59
64
  'machine_length': self._machine_length
@@ -106,35 +111,37 @@ class LossMap:
106
111
  return self._weights
107
112
 
108
113
 
109
- def _interpolate(self):
110
- new_state = self._part.state.copy()
111
- new_elem = self._part.at_element.copy()
112
-
114
+ def _correct_absorbed(self, verbose=True):
113
115
  # Correct particles that are at an aperture directly after a collimator
114
- for idx, elem in enumerate(self._part.at_element):
115
- if (self._part.state[idx] == 0 and elem > 0
116
- and self._line.element_names[elem-1] in
117
- self._line.get_elements_of_type(collimator_classes)[1]):
118
- print(f"Found at {self._line.element_names[elem]}, "
119
- + f"should be {self._line.element_names[elem-1]}")
120
- new_elem[idx] = elem - 1
121
- what_type = self._line[elem-1].__class__.__name__
122
- if what_type == 'EverestCollimator':
123
- new_state[idx] = -331
124
- elif what_type == 'EverestCrystal':
125
- new_state[idx] = -332
126
- elif what_type == 'FlukaCollimator':
127
- new_state[idx] = -334 # TODO: what if crystal?
128
- elif what_type == 'Geant4Collimator':
129
- new_state[idx] = -337 # TODO: what if crystal?
130
- elif what_type == 'BlackAbsorber':
131
- new_state[idx] = -340
116
+ part = self._part
117
+ coll_classes = list(set(_all_collimator_classes) - set(_all_crystal_classes))
118
+ coll_elements = self._line.get_elements_of_type(coll_classes)[1]
119
+ for idx, elem in enumerate(part.at_element):
120
+ if part.state[idx] == 0:
121
+ if elem == 0:
122
+ prev_elem = len(self._line.element_names) - 1
132
123
  else:
133
- raise ValueError(f"Unknown collimator type {what_type}")
134
- self._part.state = new_state
135
- self._part.at_element = new_elem
124
+ prev_elem = elem - 1
125
+ if self._line.element_names[prev_elem] in coll_elements:
126
+ if verbose:
127
+ print(f"Found at {self._line.element_names[elem]}, "
128
+ + f"moved to {self._line.element_names[elem-1]}")
129
+ part.at_element[idx] = elem - 1
130
+ what_type = self._line[elem-1].__class__.__name__
131
+ if what_type == 'EverestCollimator':
132
+ part.state[idx] = -331
133
+ elif what_type == 'EverestCrystal':
134
+ part.state[idx] = -332
135
+ elif what_type == 'FlukaCollimator':
136
+ part.state[idx] = -334 # TODO: what if crystal?
137
+ elif what_type == 'Geant4Collimator':
138
+ part.state[idx] = -337 # TODO: what if crystal?
139
+ elif what_type == 'BlackAbsorber':
140
+ part.state[idx] = -340
141
+ else:
142
+ raise ValueError(f"Unknown collimator type {what_type}")
136
143
 
137
- # do the interpolation
144
+ def _interpolate(self):
138
145
  aper_s = list(self._part.s[self._part.state==0])
139
146
  if len(aper_s) > 0:
140
147
  print("Performing the aperture losses refinement.")
@@ -149,7 +156,7 @@ class LossMap:
149
156
 
150
157
 
151
158
  def _make_coll_summary(self):
152
- collimator_names = self._line.get_elements_of_type(collimator_classes)[1]
159
+ collimator_names = self._line.get_elements_of_type(_all_collimator_classes)[1]
153
160
  coll_mask = (self._part.state <= -330) & (self._part.state >= -340)
154
161
  coll_losses = np.array([self._line.element_names[i]
155
162
  for i in self._part.at_element[coll_mask]])
@@ -157,7 +164,7 @@ class LossMap:
157
164
  coll_pos = [(self._line.get_s_position(i) + self._line[i].length/2)
158
165
  for i in collimator_names]
159
166
 
160
- if self._line is reversed:
167
+ if self._line_is_reversed:
161
168
  coll_pos = [self._machine_length - s for s in coll_pos]
162
169
 
163
170
  coll_types = [self._line[i].__class__.__name__ for i in collimator_names]
@@ -165,10 +172,11 @@ class LossMap:
165
172
  nabs = [coll_weights[coll_losses == j].sum() for j in collimator_names]
166
173
 
167
174
  self._summary = pd.DataFrame({
168
- 'collname': collimator_names,
175
+ 'collname': collimator_names,
169
176
  'nabs': nabs, # of particles lost on collimators
177
+ # 'energy': energy,
170
178
  'length': coll_lengths,
171
- 's': coll_pos,
179
+ 's': coll_pos,
172
180
  'type': coll_types
173
181
  })
174
182
 
@@ -179,7 +187,7 @@ class LossMap:
179
187
  aper_s = list(self._part.s[aper_mask])
180
188
 
181
189
  if len(aper_s) == 0:
182
- return [], [], []
190
+ return [], [], [], []
183
191
  if self._line_is_reversed:
184
192
  aper_s = [ self._machine_length - s for s in aper_s ]
185
193
 
@@ -193,7 +201,9 @@ class LossMap:
193
201
  aper_nabs = [aper_weights[aper_s == j].sum() for j in aper_pos]
194
202
  aper_names = [name_dict[ss] for ss in aper_pos]
195
203
 
196
- return aper_pos, aper_names, aper_nabs
204
+ aper_energy = 0
205
+
206
+ return aper_pos, aper_names, aper_nabs, aper_energy
197
207
 
198
208
 
199
209
  def _create_weights_from_initial_state(part, function):