colapy 0.0.1__tar.gz
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.
- colapy-0.0.1/.gitignore +18 -0
- colapy-0.0.1/CMakeLists.txt +57 -0
- colapy-0.0.1/LICENSE +21 -0
- colapy-0.0.1/MANIFEST.in +4 -0
- colapy-0.0.1/PKG-INFO +20 -0
- colapy-0.0.1/README.md +1 -0
- colapy-0.0.1/pyproject.toml +50 -0
- colapy-0.0.1/src/COLA.hh +311 -0
- colapy-0.0.1/src/LorentzVector.hh +199 -0
- colapy-0.0.1/src/bindings.cpp +134 -0
- colapy-0.0.1/src/colapy/__init__.py +29 -0
- colapy-0.0.1/src/colapy/__init__.pyi +111 -0
colapy-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
CMakeLists.txt.user
|
|
2
|
+
CMakeCache.txt
|
|
3
|
+
CMakeFiles
|
|
4
|
+
CMakeScripts
|
|
5
|
+
Testing
|
|
6
|
+
Makefile
|
|
7
|
+
cmake_install.cmake
|
|
8
|
+
install_manifest.txt
|
|
9
|
+
compile_commands.json
|
|
10
|
+
CTestTestfile.cmake
|
|
11
|
+
_deps
|
|
12
|
+
CMakeUserPresets.json
|
|
13
|
+
|
|
14
|
+
build/
|
|
15
|
+
.cache/
|
|
16
|
+
*.egg-info
|
|
17
|
+
__pycache__
|
|
18
|
+
.vscode/
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15)
|
|
2
|
+
project(
|
|
3
|
+
${SKBUILD_PROJECT_NAME}
|
|
4
|
+
VERSION ${SKBUILD_PROJECT_VERSION}
|
|
5
|
+
LANGUAGES CXX
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
find_package(COLA)
|
|
9
|
+
|
|
10
|
+
if (NOT COLA_FOUND)
|
|
11
|
+
include(FetchContent)
|
|
12
|
+
FetchContent_Declare(
|
|
13
|
+
COLA
|
|
14
|
+
GIT_REPOSITORY https://github.com/Spectator-matter-group-INR-RAS/COLA.git
|
|
15
|
+
GIT_TAG master
|
|
16
|
+
)
|
|
17
|
+
FetchContent_MakeAvailable(COLA)
|
|
18
|
+
endif()
|
|
19
|
+
|
|
20
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
21
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
22
|
+
|
|
23
|
+
# Python and pybind11 setup
|
|
24
|
+
find_package(pybind11 CONFIG REQUIRED)
|
|
25
|
+
|
|
26
|
+
# Create Python module
|
|
27
|
+
pybind11_add_module(
|
|
28
|
+
_cola_impl
|
|
29
|
+
src/bindings.cpp
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Include directories
|
|
33
|
+
# target_include_directories(_cola_impl PRIVATE src/cpp)
|
|
34
|
+
target_link_libraries(_cola_impl PUBLIC COLA)
|
|
35
|
+
|
|
36
|
+
target_compile_definitions(_cola_impl PRIVATE VERSION_INFO=${PROJECT_VERSION})
|
|
37
|
+
|
|
38
|
+
# Install configuration
|
|
39
|
+
install(TARGETS _cola_impl DESTINATION colapy)
|
|
40
|
+
|
|
41
|
+
# Installation for Python package
|
|
42
|
+
install(
|
|
43
|
+
DIRECTORY src/python/colapy/
|
|
44
|
+
DESTINATION .
|
|
45
|
+
FILES_MATCHING PATTERN "*.py"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Testing
|
|
49
|
+
# find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
|
|
50
|
+
# enable_testing()
|
|
51
|
+
# if(Python_FOUND)
|
|
52
|
+
# add_test(
|
|
53
|
+
# NAME python_tests
|
|
54
|
+
# COMMAND ${Python_EXECUTABLE} -m pytest tests/
|
|
55
|
+
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
56
|
+
# )
|
|
57
|
+
# endif()
|
colapy-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Novikov Artemii
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
colapy-0.0.1/MANIFEST.in
ADDED
colapy-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: colapy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A sample C++ library with Python bindings
|
|
5
|
+
Keywords: cpp,bindings
|
|
6
|
+
Author-Email: Artemii Novikov <artyasen@yandex.ru>
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: C++
|
|
16
|
+
Project-URL: Repository, https://github.com/ZakayZ/COLA-PY
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# COLA-PY
|
colapy-0.0.1/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# COLA-PY
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "colapy"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "A sample C++ library with Python bindings"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = {text = "MIT"}
|
|
7
|
+
authors = [
|
|
8
|
+
{name = "Artemii Novikov", email = "artyasen@yandex.ru"}
|
|
9
|
+
]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.8",
|
|
15
|
+
"Programming Language :: Python :: 3.9",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: C++"
|
|
19
|
+
]
|
|
20
|
+
keywords = ["cpp", "bindings"]
|
|
21
|
+
dependencies = [
|
|
22
|
+
]
|
|
23
|
+
requires-python = ">=3.8"
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
# Homepage = "https://github.com/ZakayZ/COLA-PY"
|
|
27
|
+
Repository = "https://github.com/ZakayZ/COLA-PY"
|
|
28
|
+
# Documentation = "https://github.com/yourusername/my-library"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
[build-system]
|
|
32
|
+
# Указываем, что для сборки нужны scikit-build-core и pybind11 (для CMake find_package)
|
|
33
|
+
requires = [
|
|
34
|
+
"scikit-build-core>=0.5",
|
|
35
|
+
"cmake>=3.15",
|
|
36
|
+
"pybind11",
|
|
37
|
+
]
|
|
38
|
+
build-backend = "scikit_build_core.build"
|
|
39
|
+
|
|
40
|
+
[tool.scikit-build]
|
|
41
|
+
# Указываем, где лежит корневой CMakeLists.txt
|
|
42
|
+
cmake.source-dir = "."
|
|
43
|
+
# Указываем, куда scikit-build-core должен установить готовый модуль,
|
|
44
|
+
# чтобы он попал в wheel-пакет под правильным именем.
|
|
45
|
+
# В нашем случае имя модуля 'my_python_module' совпадает с именем таргета в CMake.
|
|
46
|
+
# Если бы у вас были еще и чисто Python-файлы, вы бы указали их здесь:
|
|
47
|
+
wheel.packages = [
|
|
48
|
+
"src/colapy"
|
|
49
|
+
]
|
|
50
|
+
|
colapy-0.0.1/src/COLA.hh
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
#ifndef COLA_COLA_HH
|
|
2
|
+
#define COLA_COLA_HH
|
|
3
|
+
|
|
4
|
+
#include <cmath>
|
|
5
|
+
#include <iostream>
|
|
6
|
+
#include <map>
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <queue>
|
|
9
|
+
#include <vector>
|
|
10
|
+
|
|
11
|
+
#include "LorentzVector.hh"
|
|
12
|
+
|
|
13
|
+
namespace cola {
|
|
14
|
+
using LorentzVector = LorentzVectorImpl<double>;
|
|
15
|
+
|
|
16
|
+
/** A typedef representing mass and charge of a nucleon.
|
|
17
|
+
*/
|
|
18
|
+
using AZ = std::pair<unsigned short, unsigned short>;
|
|
19
|
+
|
|
20
|
+
/** PDG code to AZ converter.
|
|
21
|
+
* **WARNING:** this function is intended to process heavy ions PDG codes.
|
|
22
|
+
* @param pdgCode PDG code of the ion.
|
|
23
|
+
* @return AZ of the ion.
|
|
24
|
+
*/
|
|
25
|
+
AZ pdgToAZ(int pdgCode);
|
|
26
|
+
|
|
27
|
+
/** AZ to PDG code convverter.
|
|
28
|
+
* @param data AZ of the ion.
|
|
29
|
+
* @return PDG code of the ion
|
|
30
|
+
*/
|
|
31
|
+
int AZToPdg(AZ data);
|
|
32
|
+
|
|
33
|
+
/** \defgroup Data Data Classes and supporting methods.
|
|
34
|
+
* @{
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/** Particle class by generator output.
|
|
38
|
+
* This enum represents various outcomes of a generator event for every particle.
|
|
39
|
+
*/
|
|
40
|
+
enum class ParticleClass: char {
|
|
41
|
+
produced, /**< A particle that was not present in the starting nuclei. */
|
|
42
|
+
elasticA, /**< A particle that was present in the projectile nucleus and has experienced only elastic interactions. */
|
|
43
|
+
elasticB, /**< A particle that was present in the target nucleus and has experienced only elastic interactions. */
|
|
44
|
+
nonelasticA, /**< A particle that was present in the projectile nucleus and has experienced at least one non-elastic interaction. */
|
|
45
|
+
nonelasticB, /**< A particle that was present in the target nucleus and has experienced at least one non-elastic interaction. */
|
|
46
|
+
spectatorA, /**< A particle that was present in the projectile nucleus and hasn't experienced any interactions. */
|
|
47
|
+
spectatorB /**< A particle that was present in the projectile nucleus and hasn't experienced any interactions. */
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Particle data.
|
|
51
|
+
* A structure representing data about a single particle
|
|
52
|
+
*/
|
|
53
|
+
struct Particle {
|
|
54
|
+
AZ getAZ() const;
|
|
55
|
+
|
|
56
|
+
LorentzVector position; /**< Position <t, x, y, z> vector. */
|
|
57
|
+
|
|
58
|
+
LorentzVector momentum; /**< Momentum <e, x, y, z> vector. */
|
|
59
|
+
|
|
60
|
+
int pdgCode; /**< PDG code of the particle. */
|
|
61
|
+
ParticleClass pClass; /**< Data about particle origin. See ParticleClass for more info.*/
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Convenient typedef for Particle vector.
|
|
66
|
+
*/
|
|
67
|
+
using EventParticles = std::vector<Particle>;
|
|
68
|
+
|
|
69
|
+
/** Initial state data.
|
|
70
|
+
* This structure contains data about initial state of any given event.
|
|
71
|
+
*/
|
|
72
|
+
struct EventIniState {
|
|
73
|
+
int pdgCodeA; /**< PDF code of the projectile. */
|
|
74
|
+
int pdgCodeB; /**< PDF code of the target. */
|
|
75
|
+
|
|
76
|
+
double pZA; /** Axial momentum of the projectile */
|
|
77
|
+
double pZB; /** Axial momentum of the target */
|
|
78
|
+
double energy; /** Incidental energy of the event. Depending on pZB being zero, this is either \f$E/A\f$ of target or \f$\sqrt{s_{NN}}\f$. */
|
|
79
|
+
|
|
80
|
+
float sectNN; /** Nucleon-Nucleon cross section from generator. */
|
|
81
|
+
float b; /** Impact parameter of the event. */
|
|
82
|
+
|
|
83
|
+
int nColl; /** Diagnostic. Total number of collisions. */
|
|
84
|
+
int nCollPP; /** Diagnostic. Number of proton-proton. */
|
|
85
|
+
int nCollPN; /** Diagnostic. Number of proton-neutron collisions. */
|
|
86
|
+
int nCollNN; /** Diagnostic. Number of neutron-neutron collisions. */
|
|
87
|
+
int nPart; /** Diagnostic. Total number of participants. */
|
|
88
|
+
int nPartA; /** Diagnostic. Number of participants from the projectile nucleus. */
|
|
89
|
+
int nPartB; /** Diagnostic. Number of participants from the target nucleus. */
|
|
90
|
+
|
|
91
|
+
float phiRotA; /** Diagnostic. Polar angle \f$\phi\f$ of rotation of the projectile nucleon. */
|
|
92
|
+
float thetaRotA; /** Diagnostic. Polar angle \f&\Theta\f$ of rotation of the projectile nucleon. */
|
|
93
|
+
float phiRotB; /** Diagnostic. Polar angle \f$\phi\f$ of rotation of the target nucleon. */
|
|
94
|
+
float thetaRotB; /** Diagnostic. Polar angle \f$\Theta\f$ of rotation of the target nucleon. */
|
|
95
|
+
|
|
96
|
+
EventParticles iniStateParticles; /** The array of all Particles just before the event. */
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** A structure combining EventIniState and EventParticles of the event.
|
|
100
|
+
*/
|
|
101
|
+
struct EventData {
|
|
102
|
+
EventIniState iniState;
|
|
103
|
+
EventParticles particles;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/** @}
|
|
107
|
+
* \defgroup Interface Pure abstract classes used for dependency injection.
|
|
108
|
+
* @{
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/** A common abstract parent class representing any model in the pipeline.
|
|
112
|
+
* A single model in the COLA-driven pipeline is named a Filter.
|
|
113
|
+
*/
|
|
114
|
+
class VFilter {
|
|
115
|
+
public:
|
|
116
|
+
VFilter() = default;
|
|
117
|
+
VFilter (const VFilter&) = delete;
|
|
118
|
+
VFilter (VFilter&&) = delete;
|
|
119
|
+
VFilter& operator=(const VFilter&) = delete;
|
|
120
|
+
VFilter& operator=(VFilter&&) = delete;
|
|
121
|
+
virtual ~VFilter() = 0;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
inline VFilter::~VFilter() = default;
|
|
125
|
+
|
|
126
|
+
/** Generator abstract class.
|
|
127
|
+
* This is a generator interface. Generators are the first step of the MC simulation: they take data from existing
|
|
128
|
+
* files or encapsulate nucleus-nucleus collision generators.
|
|
129
|
+
*/
|
|
130
|
+
class VGenerator : public VFilter {
|
|
131
|
+
public:
|
|
132
|
+
VGenerator() = default;
|
|
133
|
+
VGenerator (const VGenerator&) = delete;
|
|
134
|
+
VGenerator (VGenerator&&) = delete;
|
|
135
|
+
VGenerator& operator=(const VGenerator&) = delete;
|
|
136
|
+
VGenerator& operator=(VGenerator&&) = delete;
|
|
137
|
+
~VGenerator() override = 0;
|
|
138
|
+
|
|
139
|
+
/** A method to request one event from the generator.
|
|
140
|
+
* Users are supposed to override this method to provide a single event from the generator model.
|
|
141
|
+
* @return A pointer to the EventData of the produced event.
|
|
142
|
+
*/
|
|
143
|
+
virtual std::unique_ptr<EventData> operator()() = 0;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
inline VGenerator::~VGenerator() = default;
|
|
147
|
+
|
|
148
|
+
/** Converter abstract class.
|
|
149
|
+
* This is a converter interface. It is inherited by all filters that are in the middle of MC simulation.
|
|
150
|
+
* Converters are intended to transform data from previous steps.
|
|
151
|
+
*/
|
|
152
|
+
class VConverter : public VFilter {
|
|
153
|
+
public:
|
|
154
|
+
VConverter() = default;
|
|
155
|
+
VConverter (const VConverter&) = delete;
|
|
156
|
+
VConverter (VConverter&&) = delete;
|
|
157
|
+
VConverter& operator=(const VConverter&) = delete;
|
|
158
|
+
VConverter& operator=(VConverter&&) = delete;
|
|
159
|
+
~VConverter() override = 0;
|
|
160
|
+
|
|
161
|
+
/** A method to process one event by the converter model.
|
|
162
|
+
* Users are supposed to override this method to process a single event by the converter model.
|
|
163
|
+
* @param data A pointer to the EventData to be processed.
|
|
164
|
+
* @return A pointer to the EventData of the processed event.
|
|
165
|
+
*/
|
|
166
|
+
virtual std::unique_ptr<EventData> operator()(std::unique_ptr<EventData>&& data) = 0;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
inline VConverter::~VConverter() = default;
|
|
170
|
+
|
|
171
|
+
/** Writer abstract class.
|
|
172
|
+
* This is a writer interface. Writers are what the name suggests - they implement writing results into different
|
|
173
|
+
* data formats. Note, that it isn't necessary to *only* write events to memory with this class. If you need to
|
|
174
|
+
* process data in a way that the EventData is incompatible with the output (for example, you want to model a
|
|
175
|
+
* detector response to the generated event) you can encapsulate these calculations in a writer class.
|
|
176
|
+
*/
|
|
177
|
+
class VWriter : public VFilter {
|
|
178
|
+
public:
|
|
179
|
+
VWriter() = default;
|
|
180
|
+
VWriter (const VWriter&) = delete;
|
|
181
|
+
VWriter (VWriter&&) = delete;
|
|
182
|
+
VWriter& operator=(const VWriter&) = delete;
|
|
183
|
+
VWriter& operator=(VWriter&&) = delete;
|
|
184
|
+
~VWriter() override = 0;
|
|
185
|
+
|
|
186
|
+
/** A method to save one event by the writer.
|
|
187
|
+
* Users are supposed to override this method to save a single event. Note, that the implementation is left
|
|
188
|
+
* to the user: you can save events to buffer with this method and write them to the filesystem in batches if
|
|
189
|
+
* you please so.
|
|
190
|
+
* @param data A pointer to the EventData to be saved.
|
|
191
|
+
*/
|
|
192
|
+
virtual void operator()(std::unique_ptr<EventData>&& data) = 0;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
inline VWriter::~VWriter() = default;
|
|
196
|
+
|
|
197
|
+
/** Factory abstract class.
|
|
198
|
+
* This is a factory interface. It generates a Filter with its VFactory::create method. DI in COLA works via using the
|
|
199
|
+
* factory classes, which are registered in a MetaProcessor instance.
|
|
200
|
+
*/
|
|
201
|
+
class VFactory {
|
|
202
|
+
public:
|
|
203
|
+
VFactory() = default;
|
|
204
|
+
VFactory (const VFactory&) = delete;
|
|
205
|
+
VFactory (VFactory&&) = delete;
|
|
206
|
+
VFactory& operator=(const VFactory&) = delete;
|
|
207
|
+
VFactory& operator=(VFactory&&) = delete;
|
|
208
|
+
virtual ~VFactory() = default;
|
|
209
|
+
|
|
210
|
+
/** The method for constructing filters.
|
|
211
|
+
* This method is intended to be called in MetaProcessor with key-value pairs obtained from a XML-file.
|
|
212
|
+
* @param metaData A dictionary with key-value pairs needed for configuring a model.
|
|
213
|
+
* @return A configured class that is a VFilter child.
|
|
214
|
+
*/
|
|
215
|
+
virtual VFilter* create(const std::map<std::string, std::string>& metaData) = 0;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
std::unique_ptr<EventData> operator|(const std::unique_ptr<VGenerator>&, const std::unique_ptr<VConverter>&);
|
|
220
|
+
std::unique_ptr<EventData> operator|(std::unique_ptr<EventData>&&, const std::unique_ptr<VConverter>&);
|
|
221
|
+
void operator|(std::unique_ptr<EventData>&&, const std::unique_ptr<VWriter>&);
|
|
222
|
+
|
|
223
|
+
/** An enum for marking Filter types.
|
|
224
|
+
*/
|
|
225
|
+
enum class FilterType: char {
|
|
226
|
+
generator,
|
|
227
|
+
converter,
|
|
228
|
+
writer
|
|
229
|
+
};
|
|
230
|
+
/** @}
|
|
231
|
+
* \defgroup Metadata Classes for constructing and running a model.
|
|
232
|
+
* @{
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
/** A structure representing the model pipeline.
|
|
236
|
+
*/
|
|
237
|
+
struct FilterEnsemble {
|
|
238
|
+
std::unique_ptr<VGenerator> generator; /**< Event generator. */
|
|
239
|
+
std::vector<std::unique_ptr<VConverter>> converters; /**< Vector of converters, applied step-by-step. */
|
|
240
|
+
std::unique_ptr<VWriter> writer; /**< Writer to save the results. */
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/** A class for processing meta information.
|
|
244
|
+
* This class stores data about all available Filters and corresponding factory classes and uses it to create the
|
|
245
|
+
* pipeline using its MetaProcessor:parse method to read all needed information from an XML-file.
|
|
246
|
+
*/
|
|
247
|
+
class MetaProcessor {
|
|
248
|
+
public:
|
|
249
|
+
|
|
250
|
+
/** Default constructor.
|
|
251
|
+
*/
|
|
252
|
+
MetaProcessor() = default;
|
|
253
|
+
|
|
254
|
+
/** Constructor with immediate factories registration.
|
|
255
|
+
* Note that unique pointers in the dictionary are invalidated.
|
|
256
|
+
* @param filterMap A dictionary with all relevant information. Note that unique pointers in the dictionary are invalidated.
|
|
257
|
+
*/
|
|
258
|
+
explicit MetaProcessor(std::map<std::string, std::pair<std::unique_ptr<VFactory>, FilterType>>& filterMap);
|
|
259
|
+
|
|
260
|
+
~MetaProcessor() = default;
|
|
261
|
+
|
|
262
|
+
/** A method for registering new Filters.
|
|
263
|
+
* @param factory A rvalue-reference to the Filter factory pointer
|
|
264
|
+
* @param name The name of the Filter.
|
|
265
|
+
* @param type The type of the Filter. See FilterType.
|
|
266
|
+
*/
|
|
267
|
+
void reg(std::unique_ptr<VFactory>&& factory, const std::string& name, FilterType type);
|
|
268
|
+
|
|
269
|
+
/** A method to parse a XML-file to set up a configured FilterEnsemble.
|
|
270
|
+
* This method opens an XML-file @param fName to get the information to set up the model.
|
|
271
|
+
* Inside the root element should be one <generator> element followed by any number of <converter> elements
|
|
272
|
+
* (none is possible) and, finally, a <writer> element. Each element must have "name" attribute followed by
|
|
273
|
+
* any number of additional attributes. These attributes are then passed to the corresponding factory's VFactory::create
|
|
274
|
+
* method as a dictionary with keys being attribute names and values - attribute values.
|
|
275
|
+
* This method throws an error if a relevant factory isn't found or XML-file is malformed.
|
|
276
|
+
* @param fName Name with the configuration XML-file.
|
|
277
|
+
* @return A configured FilterEnsemble.
|
|
278
|
+
*/
|
|
279
|
+
FilterEnsemble parse(const std::string& fName) const;
|
|
280
|
+
|
|
281
|
+
private:
|
|
282
|
+
std::map<std::string, std::unique_ptr<VFactory>> generatorMap;
|
|
283
|
+
std::map<std::string, std::unique_ptr<VFactory>> converterMap;
|
|
284
|
+
std::map<std::string, std::unique_ptr<VFactory>> writerMap;
|
|
285
|
+
|
|
286
|
+
void regGen(std::unique_ptr<VFactory>&& factory, const std::string& name){ generatorMap.emplace(name, std::move(factory)); }
|
|
287
|
+
void regConv(std::unique_ptr<VFactory>&& factory, const std::string& name){ converterMap.emplace(name, std::move(factory)); }
|
|
288
|
+
void regWrite(std::unique_ptr<VFactory>&& factory, const std::string& name){ writerMap.emplace(name, std::move(factory)); }
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
/** Manager class.
|
|
292
|
+
* Currently more of a boilerplate, but potentially useful to incorporate parallel computing.
|
|
293
|
+
*/
|
|
294
|
+
class ColaRunManager {
|
|
295
|
+
public:
|
|
296
|
+
ColaRunManager() = delete;
|
|
297
|
+
/** A constructor that moves the configured FilterEnsemble into the manager.
|
|
298
|
+
* @param ensemble Configured model.
|
|
299
|
+
*/
|
|
300
|
+
explicit ColaRunManager(FilterEnsemble&& ensemble) : filterEnsemble(std::move(ensemble)) {}
|
|
301
|
+
~ColaRunManager() = default;
|
|
302
|
+
/** A method to run the resulting model @param n times.
|
|
303
|
+
* @param n Number of runs.
|
|
304
|
+
*/
|
|
305
|
+
void run(int n = 1) const;
|
|
306
|
+
private:
|
|
307
|
+
FilterEnsemble filterEnsemble;
|
|
308
|
+
};
|
|
309
|
+
} // cola
|
|
310
|
+
|
|
311
|
+
#endif //COLA_COLA_HH
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#ifndef COLA_LORENTZVECTOR_HH
|
|
2
|
+
#define COLA_LORENTZVECTOR_HH
|
|
3
|
+
|
|
4
|
+
#include <array>
|
|
5
|
+
#include <cmath>
|
|
6
|
+
#include <iostream>
|
|
7
|
+
|
|
8
|
+
namespace cola {
|
|
9
|
+
|
|
10
|
+
template <typename Type = double>
|
|
11
|
+
struct Vector3 {
|
|
12
|
+
Type x, y, z;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
template <typename Type = double>
|
|
16
|
+
class LorentzVectorImpl {
|
|
17
|
+
public:
|
|
18
|
+
union {
|
|
19
|
+
Type e;
|
|
20
|
+
Type t;
|
|
21
|
+
};
|
|
22
|
+
Type x;
|
|
23
|
+
Type y;
|
|
24
|
+
Type z;
|
|
25
|
+
|
|
26
|
+
private:
|
|
27
|
+
using FieldPtr = Type LorentzVectorImpl::*;
|
|
28
|
+
|
|
29
|
+
static inline constexpr std::array<FieldPtr, 4> Fields_ = {
|
|
30
|
+
&LorentzVectorImpl::e,
|
|
31
|
+
&LorentzVectorImpl::x,
|
|
32
|
+
&LorentzVectorImpl::y,
|
|
33
|
+
&LorentzVectorImpl::z
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
const Type& operator[](int i) const { return this->*Fields_[i]; }
|
|
38
|
+
Type& operator[](int i) { return this->*Fields_[i]; }
|
|
39
|
+
|
|
40
|
+
LorentzVectorImpl& operator+=(const LorentzVectorImpl& other) {
|
|
41
|
+
for (size_t i = 0; i < Fields_.size(); ++i) {
|
|
42
|
+
this->*Fields_[i] += other.*Fields_[i];
|
|
43
|
+
}
|
|
44
|
+
return *this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
LorentzVectorImpl& operator-=(const LorentzVectorImpl& other) {
|
|
48
|
+
for (size_t i = 0; i < Fields_.size(); ++i) {
|
|
49
|
+
this->*Fields_[i] -= other.*Fields_[i];
|
|
50
|
+
}
|
|
51
|
+
return *this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
LorentzVectorImpl& operator*=(Type scalar) {
|
|
55
|
+
for (size_t i = 0; i < Fields_.size(); ++i) {
|
|
56
|
+
this->*Fields_[i] *= scalar;
|
|
57
|
+
}
|
|
58
|
+
return *this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
LorentzVectorImpl& operator/=(Type scalar) {
|
|
62
|
+
for (size_t i = 0; i < Fields_.size(); ++i) {
|
|
63
|
+
this->*Fields_[i] /= scalar;
|
|
64
|
+
}
|
|
65
|
+
return *this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// bx by and bz are projections of beta
|
|
69
|
+
LorentzVectorImpl& boost(Type bx, Type by, Type bz) {
|
|
70
|
+
|
|
71
|
+
Type b2 = bx * bx + by * by + bz * bz;
|
|
72
|
+
|
|
73
|
+
if (b2 >= 1)
|
|
74
|
+
throw std::runtime_error("Boost faster than speed of light.");
|
|
75
|
+
if (b2 <= .95 or not isSpaceLike()) {
|
|
76
|
+
Type ggamma = 1.0 / std::sqrt(1.0 - b2);
|
|
77
|
+
Type bp = bx * x + by * y + bz * z;
|
|
78
|
+
Type gamma2 = b2 > 0 ? (ggamma - 1.0) / b2 : 0.0;
|
|
79
|
+
|
|
80
|
+
x = x + gamma2 * bp * bx + ggamma * bx * t;
|
|
81
|
+
y = y + gamma2 * bp * by + ggamma * by * t;
|
|
82
|
+
z = z + gamma2 * bp * bz + ggamma * bz * t;
|
|
83
|
+
t = ggamma * (t + bp);
|
|
84
|
+
|
|
85
|
+
// for big betas use rapidities instead (B = R^-1B'R, where B' is axis boost (Oz here) and R is Rotation matrix for spatial part)
|
|
86
|
+
} else {
|
|
87
|
+
// calculate direction vector coordinates
|
|
88
|
+
Type b1 = std::sqrt(b2);
|
|
89
|
+
Vector3<Type> rVec{bx / b1, by / b1, bz / b1};
|
|
90
|
+
Vector3<Type> rBack = rotateUz({0, 0, 1}, rVec);
|
|
91
|
+
|
|
92
|
+
// rotate space vector so that boost direction is {0, 0, 1} in new coordinates
|
|
93
|
+
auto newCoord = rotateUz({x, y, z}, rVec);
|
|
94
|
+
x = newCoord.x, y = newCoord.y, z = newCoord.z;
|
|
95
|
+
|
|
96
|
+
boostAxisRapidity(std::atanh(b1)); // boost along Oz
|
|
97
|
+
// rotate back
|
|
98
|
+
newCoord = rotateUz({x, y, z}, rBack);
|
|
99
|
+
x = newCoord.x, y = newCoord.y, z = newCoord.z;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return *this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// axis from 1 to 3 correspond to x-y-z. Note: this gives correct results only if other axes components are zero. TODO: Throw an error otherwise
|
|
106
|
+
LorentzVectorImpl& boostAxisRapidity(Type rapidity, uint axis=3u) {
|
|
107
|
+
if (axis > 3 or axis < 1)
|
|
108
|
+
throw std::runtime_error("Wrong axis in boostAxis. 1 for x, 2 for y, 3 for z.");
|
|
109
|
+
if (not isSpaceLike()) {
|
|
110
|
+
throw std::runtime_error("Rapidity calculation only viable for space-like 4-vectors. Use boost() instead");
|
|
111
|
+
}
|
|
112
|
+
Type inv = std::sqrt(e*e - this->*Fields_[axis]*this->*Fields_[axis]);
|
|
113
|
+
Type rRapidity = rapidity + .5 * (std::log(e + this->*Fields_[axis]) - std::log(e - this->*Fields_[axis]));
|
|
114
|
+
e = inv * std::cosh(rRapidity);
|
|
115
|
+
this->*Fields_[axis] = inv * std::sinh(rRapidity);
|
|
116
|
+
|
|
117
|
+
return *this;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Type mag2() const { return t*t - (x*x + y*y + z*z); }
|
|
121
|
+
Type mag() const { return std::sqrt(mag2()); }
|
|
122
|
+
|
|
123
|
+
bool isSpaceLike() const { return mag2() > 0; }
|
|
124
|
+
bool isLightLike() const { return mag2() == 0; }
|
|
125
|
+
bool isTimeLike() const { return mag2() < 0; }
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
template <typename Type>
|
|
129
|
+
LorentzVectorImpl<Type> operator+(const LorentzVectorImpl<Type>& a, const LorentzVectorImpl<Type>& b) {
|
|
130
|
+
auto res = a;
|
|
131
|
+
res += b;
|
|
132
|
+
return res;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
template <typename Type>
|
|
136
|
+
LorentzVectorImpl<Type> operator-(const LorentzVectorImpl<Type>& a, const LorentzVectorImpl<Type>& b) {
|
|
137
|
+
auto res = a;
|
|
138
|
+
res -= b;
|
|
139
|
+
return res;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
template <typename Type, typename Scalar>
|
|
143
|
+
LorentzVectorImpl<Type> operator*(const LorentzVectorImpl<Type>& vec, Scalar scalar) {
|
|
144
|
+
auto res = vec;
|
|
145
|
+
res *= scalar;
|
|
146
|
+
return res;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
template <typename Type, typename Scalar>
|
|
150
|
+
LorentzVectorImpl<Type> operator*(Scalar scalar, const LorentzVectorImpl<Type>& vec) {
|
|
151
|
+
return vec * scalar;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
template <typename Type, typename Scalar>
|
|
155
|
+
LorentzVectorImpl<Type> operator/(const LorentzVectorImpl<Type>& vec, Scalar scalar) {
|
|
156
|
+
auto res = vec;
|
|
157
|
+
res /= scalar;
|
|
158
|
+
return res;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
template <typename Type>
|
|
162
|
+
bool operator==(const LorentzVectorImpl<Type>& a, const LorentzVectorImpl<Type>& b) {
|
|
163
|
+
return a.e == b.e && a.x == b.x && a.y == b.y && a.z == b.z;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
template <typename Type>
|
|
167
|
+
bool operator!=(const LorentzVectorImpl<Type>& a, const LorentzVectorImpl<Type>& b) {
|
|
168
|
+
return !(a == b);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
template <typename Type>
|
|
172
|
+
std::ostream& operator<<(std::ostream& out, const LorentzVectorImpl<Type>& vec) {
|
|
173
|
+
out << "(" << vec.e << ", " << vec.x << ", " << vec.y << ", " << vec.z << ")";
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
template <typename Type>
|
|
178
|
+
Vector3<Type> rotateUz(const Vector3<Type> stVec, const Vector3<Type> uzVec) {
|
|
179
|
+
// NewUzVector must be normalized !
|
|
180
|
+
|
|
181
|
+
Vector3<Type> resVec;
|
|
182
|
+
double up = uzVec.x*uzVec.x + uzVec.y*uzVec.y;
|
|
183
|
+
|
|
184
|
+
if (up > 0) {
|
|
185
|
+
up = std::sqrt(up);
|
|
186
|
+
resVec.x = (uzVec.x * uzVec.z * stVec.x - uzVec.y * stVec.y) / up + uzVec.x * stVec.z;
|
|
187
|
+
resVec.y = (uzVec.y * uzVec.z * stVec.x + uzVec.x * stVec.y) / up + uzVec.y * stVec.z;
|
|
188
|
+
resVec.z = -up * stVec.x + uzVec.z * stVec.z;
|
|
189
|
+
} else if (uzVec.z < 0.) {
|
|
190
|
+
resVec.x = -stVec.x;
|
|
191
|
+
resVec.y = stVec.y;
|
|
192
|
+
resVec.z = -stVec.z;
|
|
193
|
+
} // phi=0 teta=pi
|
|
194
|
+
|
|
195
|
+
return resVec;
|
|
196
|
+
}
|
|
197
|
+
} // namespace cola
|
|
198
|
+
|
|
199
|
+
#endif // COLA_LORENTZVECTOR_HH
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#include <pybind11/pybind11.h>
|
|
2
|
+
#include <pybind11/stl.h>
|
|
3
|
+
#include <pybind11/functional.h>
|
|
4
|
+
#include <pybind11/operators.h>
|
|
5
|
+
#include <pybind11/attr.h>
|
|
6
|
+
#include <pybind11/native_enum.h>
|
|
7
|
+
|
|
8
|
+
#include <COLA.hh>
|
|
9
|
+
|
|
10
|
+
#include <sstream>
|
|
11
|
+
#include <memory>
|
|
12
|
+
|
|
13
|
+
#define STRINGIFY(x) #x
|
|
14
|
+
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
|
15
|
+
|
|
16
|
+
namespace py = pybind11;
|
|
17
|
+
using namespace pybind11::literals;
|
|
18
|
+
|
|
19
|
+
PYBIND11_MODULE(_cola_impl, m) {
|
|
20
|
+
m.doc() = "COLA wrapper library";
|
|
21
|
+
|
|
22
|
+
#ifdef VERSION_INFO
|
|
23
|
+
m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO);
|
|
24
|
+
#else
|
|
25
|
+
m.attr("__version__") = "dev";
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
py::native_enum<cola::ParticleClass>(m, "ParticleClass", "enum.Enum")
|
|
29
|
+
.value("PRODUCED", cola::ParticleClass::produced)
|
|
30
|
+
.value("ELASTIC_A", cola::ParticleClass::elasticA)
|
|
31
|
+
.value("ELASTIC_B", cola::ParticleClass::elasticB)
|
|
32
|
+
.value("NON_ELASTIC_A", cola::ParticleClass::nonelasticA)
|
|
33
|
+
.value("NON_ELASTIC_B", cola::ParticleClass::nonelasticB)
|
|
34
|
+
.value("SPECTATOR_A", cola::ParticleClass::spectatorA)
|
|
35
|
+
.value("SPECTATOR_B", cola::ParticleClass::spectatorB)
|
|
36
|
+
.export_values()
|
|
37
|
+
.finalize()
|
|
38
|
+
;
|
|
39
|
+
|
|
40
|
+
py::class_<cola::LorentzVector>(m, "LorentzVector")
|
|
41
|
+
.def(py::init<double, double, double, double>(), "e"_a = 0., "x"_a = 0., "y"_a = 0., "z"_a = 0.)
|
|
42
|
+
.def(py::init<cola::LorentzVector>())
|
|
43
|
+
.def_readwrite("x", &cola::LorentzVector::x, "x vector component")
|
|
44
|
+
.def_readwrite("y", &cola::LorentzVector::y, "y vector component")
|
|
45
|
+
.def_readwrite("z", &cola::LorentzVector::z, "z vector component")
|
|
46
|
+
.def_readwrite("e", &cola::LorentzVector::e, "e vector component")
|
|
47
|
+
.def_readwrite("t", &cola::LorentzVector::t, "t vector component")
|
|
48
|
+
.def(py::self + py::self)
|
|
49
|
+
.def(py::self - py::self)
|
|
50
|
+
.def(py::self += py::self)
|
|
51
|
+
.def(py::self -= py::self)
|
|
52
|
+
.def(py::self *= double())
|
|
53
|
+
.def(py::self /= double())
|
|
54
|
+
.def(double() * py::self)
|
|
55
|
+
.def(py::self * double())
|
|
56
|
+
.def(py::self / double())
|
|
57
|
+
.def(py::self == py::self)
|
|
58
|
+
// .def(-py::self)
|
|
59
|
+
.def("__copy__", [](const cola::LorentzVector& vec) {
|
|
60
|
+
return vec;
|
|
61
|
+
})
|
|
62
|
+
.def("__deepcopy__", [](const cola::LorentzVector& vec, py::dict) {
|
|
63
|
+
return vec;
|
|
64
|
+
}, "memo"_a)
|
|
65
|
+
.def("__repr__", [](const cola::LorentzVector& p) -> std::string {
|
|
66
|
+
auto ss = std::stringstream();
|
|
67
|
+
ss << p;
|
|
68
|
+
return std::move(ss).str();
|
|
69
|
+
})
|
|
70
|
+
;
|
|
71
|
+
|
|
72
|
+
py::class_<cola::Particle>(m, "Particle")
|
|
73
|
+
.def(py::init<cola::LorentzVector, cola::LorentzVector, int, cola::ParticleClass>(),
|
|
74
|
+
"position"_a, "momentum"_a, "pdg_code"_a, "p_class"_a)
|
|
75
|
+
.def(py::init<cola::Particle>())
|
|
76
|
+
.def_readwrite("position", &cola::Particle::position)
|
|
77
|
+
.def_readwrite("momentum", &cola::Particle::momentum)
|
|
78
|
+
.def_readwrite("pdg_code", &cola::Particle::pdgCode)
|
|
79
|
+
.def_readwrite("p_class", &cola::Particle::pClass)
|
|
80
|
+
.def("get_az", [](const cola::Particle& p) -> std::pair<int, int> { return p.getAZ(); })
|
|
81
|
+
.def("__repr__", [](const cola::Particle& p) -> std::string {
|
|
82
|
+
auto ss = std::stringstream();
|
|
83
|
+
ss << "Particle(pdg=" << p.pdgCode << ", class=" << static_cast<int>(p.pClass) << ")";
|
|
84
|
+
return std::move(ss).str();
|
|
85
|
+
})
|
|
86
|
+
;
|
|
87
|
+
|
|
88
|
+
py::class_<cola::EventIniState>(m, "EventInitialState")
|
|
89
|
+
.def(py::init<>())
|
|
90
|
+
.def_readwrite("pdg_code_a", &cola::EventIniState::pdgCodeA,
|
|
91
|
+
"PDG code of the projectile")
|
|
92
|
+
.def_readwrite("pdg_code_b", &cola::EventIniState::pdgCodeB,
|
|
93
|
+
"PDG code of the target")
|
|
94
|
+
.def_readwrite("pz_a", &cola::EventIniState::pZA,
|
|
95
|
+
"Axial momentum of the projectile")
|
|
96
|
+
.def_readwrite("pz_b", &cola::EventIniState::pZB,
|
|
97
|
+
"Axial momentum of the target")
|
|
98
|
+
.def_readwrite("energy", &cola::EventIniState::energy,
|
|
99
|
+
"Incident energy of the event")
|
|
100
|
+
.def_readwrite("sect_nn", &cola::EventIniState::sectNN,
|
|
101
|
+
"Nucleon-Nucleon cross section from generator")
|
|
102
|
+
.def_readwrite("b", &cola::EventIniState::b,
|
|
103
|
+
"Impact parameter of the event")
|
|
104
|
+
.def_readwrite("n_coll", &cola::EventIniState::nColl,
|
|
105
|
+
"Total number of collisions")
|
|
106
|
+
.def_readwrite("n_coll_pp", &cola::EventIniState::nCollPP,
|
|
107
|
+
"Number of proton-proton collisions")
|
|
108
|
+
.def_readwrite("n_coll_pn", &cola::EventIniState::nCollPN,
|
|
109
|
+
"Number of proton-neutron collisions")
|
|
110
|
+
.def_readwrite("n_coll_nn", &cola::EventIniState::nCollNN,
|
|
111
|
+
"Number of neutron-neutron collisions")
|
|
112
|
+
.def_readwrite("n_part", &cola::EventIniState::nPart,
|
|
113
|
+
"Total number of participants")
|
|
114
|
+
.def_readwrite("n_part_a", &cola::EventIniState::nPartA,
|
|
115
|
+
"Number of participants from projectile nucleus")
|
|
116
|
+
.def_readwrite("n_part_b", &cola::EventIniState::nPartB,
|
|
117
|
+
"Number of participants from target nucleus")
|
|
118
|
+
.def_readwrite("phi_rot_a", &cola::EventIniState::phiRotA,
|
|
119
|
+
"Polar angle φ of rotation of projectile nucleon")
|
|
120
|
+
.def_readwrite("theta_rot_a", &cola::EventIniState::thetaRotA,
|
|
121
|
+
"Polar angle Θ of rotation of projectile nucleon")
|
|
122
|
+
.def_readwrite("phi_rot_b", &cola::EventIniState::phiRotB,
|
|
123
|
+
"Polar angle φ of rotation of target nucleon")
|
|
124
|
+
.def_readwrite("theta_rot_b", &cola::EventIniState::thetaRotB,
|
|
125
|
+
"Polar angle Θ of rotation of target nucleon")
|
|
126
|
+
.def_readwrite("initial_particles", &cola::EventIniState::iniStateParticles,
|
|
127
|
+
"Array of all particles just before the event")
|
|
128
|
+
;
|
|
129
|
+
|
|
130
|
+
py::class_<cola::EventData>(m, "EventData")
|
|
131
|
+
.def(py::init<>())
|
|
132
|
+
.def_readwrite("initial_state", &cola::EventData::iniState)
|
|
133
|
+
.def_readwrite("particles", &cola::EventData::particles);
|
|
134
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import typing as tp
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from ._cola_impl import (
|
|
5
|
+
__doc__,
|
|
6
|
+
__version__,
|
|
7
|
+
LorentzVector,
|
|
8
|
+
Particle,
|
|
9
|
+
ParticleClass,
|
|
10
|
+
EventInitialState,
|
|
11
|
+
EventData,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AZ(tp.NamedTuple):
|
|
16
|
+
A: int
|
|
17
|
+
Z: int
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
'__doc__',
|
|
22
|
+
'__version__',
|
|
23
|
+
'AZ',
|
|
24
|
+
'LorentzVector',
|
|
25
|
+
'Particle',
|
|
26
|
+
'ParticleClass',
|
|
27
|
+
'EventInitialState',
|
|
28
|
+
'EventData',
|
|
29
|
+
]
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import typing as tp
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
from . import AZ
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
EventParticles: tp.TypeAlias = tp.List[Particle]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class LorentzVector:
|
|
12
|
+
x: float
|
|
13
|
+
y: float
|
|
14
|
+
z: float
|
|
15
|
+
e: float
|
|
16
|
+
t: float
|
|
17
|
+
|
|
18
|
+
@tp.overload
|
|
19
|
+
def __init__(self, other: 'LorentzVector') -> None: ...
|
|
20
|
+
|
|
21
|
+
@tp.overload
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
e: float = 0.0,
|
|
25
|
+
x: float = 0.0,
|
|
26
|
+
y: float = 0.0,
|
|
27
|
+
z: float = 0.0,
|
|
28
|
+
) -> None: ...
|
|
29
|
+
|
|
30
|
+
def __add__(self, other: 'LorentzVector') -> 'LorentzVector': ...
|
|
31
|
+
def __sub__(self, other: 'LorentzVector') -> 'LorentzVector': ...
|
|
32
|
+
def __iadd__(self, other: 'LorentzVector') -> 'LorentzVector': ...
|
|
33
|
+
def __isub__(self, other: 'LorentzVector') -> 'LorentzVector': ...
|
|
34
|
+
|
|
35
|
+
def __mul__(self, scalar: float) -> 'LorentzVector': ...
|
|
36
|
+
def __rmul__(self, scalar: float) -> 'LorentzVector': ...
|
|
37
|
+
def __truediv__(self, scalar: float) -> 'LorentzVector': ...
|
|
38
|
+
def __imul__(self, scalar: float) -> 'LorentzVector': ...
|
|
39
|
+
def __itruediv__(self, scalar: float) -> 'LorentzVector': ...
|
|
40
|
+
|
|
41
|
+
def __eq__(self, other: object) -> bool: ...
|
|
42
|
+
|
|
43
|
+
def __copy__(self) -> 'LorentzVector': ...
|
|
44
|
+
def __deepcopy__(self, memo: object) -> 'LorentzVector': ...
|
|
45
|
+
|
|
46
|
+
def __repr__(self) -> str: ...
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ParticleClass(enum.Enum):
|
|
50
|
+
PRODUCED: int
|
|
51
|
+
ELASTIC_A: int
|
|
52
|
+
ELASTIC_B: int
|
|
53
|
+
NON_ELASTIC_A: int
|
|
54
|
+
NON_ELASTIC_B: int
|
|
55
|
+
SPECTATOR_A: int
|
|
56
|
+
SPECTATOR_B: int
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class Particle:
|
|
60
|
+
position: LorentzVector
|
|
61
|
+
momentum: LorentzVector
|
|
62
|
+
pdg_code: int
|
|
63
|
+
p_class: ParticleClass
|
|
64
|
+
|
|
65
|
+
@tp.overload
|
|
66
|
+
def __init__(self, other: 'Particle') -> None: ...
|
|
67
|
+
|
|
68
|
+
@tp.overload
|
|
69
|
+
def __init__(
|
|
70
|
+
self,
|
|
71
|
+
position: LorentzVector = ...,
|
|
72
|
+
momentum: LorentzVector = ...,
|
|
73
|
+
pdg_code: int = ...,
|
|
74
|
+
p_class: ParticleClass = ...,
|
|
75
|
+
) -> None: ...
|
|
76
|
+
def get_az(self) -> AZ: ...
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class EventInitialState:
|
|
80
|
+
pdg_code_a: int
|
|
81
|
+
pdg_code_b: int
|
|
82
|
+
pz_a: float
|
|
83
|
+
pz_b: float
|
|
84
|
+
energy: float
|
|
85
|
+
sect_nn: float
|
|
86
|
+
b: float
|
|
87
|
+
n_coll: int
|
|
88
|
+
n_coll_pp: int
|
|
89
|
+
n_coll_pn: int
|
|
90
|
+
n_coll_nn: int
|
|
91
|
+
n_part: int
|
|
92
|
+
n_part_a: int
|
|
93
|
+
n_part_b: int
|
|
94
|
+
phi_rot_a: float
|
|
95
|
+
theta_rot_a: float
|
|
96
|
+
phi_rot_b: float
|
|
97
|
+
theta_rot_b: float
|
|
98
|
+
initial_particles: EventParticles
|
|
99
|
+
|
|
100
|
+
def __init__(self) -> None: ...
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class EventData:
|
|
104
|
+
initial_state: EventInitialState
|
|
105
|
+
particles: EventParticles
|
|
106
|
+
|
|
107
|
+
def __init__(self) -> None: ...
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def pdg_to_az(pdg_code: int) -> AZ: ...
|
|
111
|
+
def az_to_pdg(az: AZ) -> int: ...
|