madspace 0.3.1__cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.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.
Files changed (75) hide show
  1. madspace/__init__.py +1 -0
  2. madspace/_madspace_py.cpython-311-x86_64-linux-gnu.so +0 -0
  3. madspace/_madspace_py.pyi +2189 -0
  4. madspace/_madspace_py_loader.py +111 -0
  5. madspace/include/madspace/constants.h +17 -0
  6. madspace/include/madspace/madcode/function.h +102 -0
  7. madspace/include/madspace/madcode/function_builder_mixin.h +591 -0
  8. madspace/include/madspace/madcode/instruction.h +208 -0
  9. madspace/include/madspace/madcode/opcode_mixin.h +134 -0
  10. madspace/include/madspace/madcode/optimizer.h +31 -0
  11. madspace/include/madspace/madcode/type.h +203 -0
  12. madspace/include/madspace/madcode.h +6 -0
  13. madspace/include/madspace/phasespace/base.h +74 -0
  14. madspace/include/madspace/phasespace/channel_weight_network.h +46 -0
  15. madspace/include/madspace/phasespace/channel_weights.h +51 -0
  16. madspace/include/madspace/phasespace/chili.h +32 -0
  17. madspace/include/madspace/phasespace/cross_section.h +47 -0
  18. madspace/include/madspace/phasespace/cuts.h +34 -0
  19. madspace/include/madspace/phasespace/discrete_flow.h +44 -0
  20. madspace/include/madspace/phasespace/discrete_sampler.h +53 -0
  21. madspace/include/madspace/phasespace/flow.h +53 -0
  22. madspace/include/madspace/phasespace/histograms.h +26 -0
  23. madspace/include/madspace/phasespace/integrand.h +204 -0
  24. madspace/include/madspace/phasespace/invariants.h +26 -0
  25. madspace/include/madspace/phasespace/luminosity.h +41 -0
  26. madspace/include/madspace/phasespace/matrix_element.h +70 -0
  27. madspace/include/madspace/phasespace/mlp.h +37 -0
  28. madspace/include/madspace/phasespace/multichannel.h +49 -0
  29. madspace/include/madspace/phasespace/observable.h +85 -0
  30. madspace/include/madspace/phasespace/pdf.h +78 -0
  31. madspace/include/madspace/phasespace/phasespace.h +67 -0
  32. madspace/include/madspace/phasespace/rambo.h +26 -0
  33. madspace/include/madspace/phasespace/scale.h +52 -0
  34. madspace/include/madspace/phasespace/t_propagator_mapping.h +34 -0
  35. madspace/include/madspace/phasespace/three_particle.h +68 -0
  36. madspace/include/madspace/phasespace/topology.h +116 -0
  37. madspace/include/madspace/phasespace/two_particle.h +63 -0
  38. madspace/include/madspace/phasespace/vegas.h +53 -0
  39. madspace/include/madspace/phasespace.h +27 -0
  40. madspace/include/madspace/runtime/context.h +147 -0
  41. madspace/include/madspace/runtime/discrete_optimizer.h +24 -0
  42. madspace/include/madspace/runtime/event_generator.h +257 -0
  43. madspace/include/madspace/runtime/format.h +68 -0
  44. madspace/include/madspace/runtime/io.h +343 -0
  45. madspace/include/madspace/runtime/lhe_output.h +132 -0
  46. madspace/include/madspace/runtime/logger.h +46 -0
  47. madspace/include/madspace/runtime/runtime_base.h +39 -0
  48. madspace/include/madspace/runtime/tensor.h +603 -0
  49. madspace/include/madspace/runtime/thread_pool.h +101 -0
  50. madspace/include/madspace/runtime/vegas_optimizer.h +26 -0
  51. madspace/include/madspace/runtime.h +12 -0
  52. madspace/include/madspace/umami.h +202 -0
  53. madspace/include/madspace/util.h +142 -0
  54. madspace/lib/libmadspace.so +0 -0
  55. madspace/lib/libmadspace_cpu.so +0 -0
  56. madspace/lib/libmadspace_cpu_avx2.so +0 -0
  57. madspace/lib/libmadspace_cpu_avx512.so +0 -0
  58. madspace/lib/libmadspace_cuda.so +0 -0
  59. madspace/lib/libmadspace_hip.so +0 -0
  60. madspace/madnis/__init__.py +44 -0
  61. madspace/madnis/buffer.py +167 -0
  62. madspace/madnis/channel_grouping.py +85 -0
  63. madspace/madnis/distribution.py +103 -0
  64. madspace/madnis/integrand.py +175 -0
  65. madspace/madnis/integrator.py +973 -0
  66. madspace/madnis/interface.py +191 -0
  67. madspace/madnis/losses.py +186 -0
  68. madspace/torch.py +82 -0
  69. madspace-0.3.1.dist-info/METADATA +71 -0
  70. madspace-0.3.1.dist-info/RECORD +75 -0
  71. madspace-0.3.1.dist-info/WHEEL +6 -0
  72. madspace-0.3.1.dist-info/licenses/LICENSE +21 -0
  73. madspace.libs/libgfortran-83c28eba.so.5.0.0 +0 -0
  74. madspace.libs/libopenblas-r0-11edc3fa.3.15.so +0 -0
  75. madspace.libs/libquadmath-2284e583.so.0.0.0 +0 -0
@@ -0,0 +1,37 @@
1
+ #pragma once
2
+
3
+ #include "madspace/phasespace/base.h"
4
+ #include "madspace/runtime/context.h"
5
+
6
+ namespace madspace {
7
+
8
+ class MLP : public FunctionGenerator {
9
+ public:
10
+ enum Activation { relu, leaky_relu, elu, gelu, sigmoid, softplus, linear };
11
+ MLP(std::size_t input_dim,
12
+ std::size_t output_dim,
13
+ std::size_t hidden_dim = 32,
14
+ std::size_t layers = 3,
15
+ Activation activation = leaky_relu,
16
+ const std::string& prefix = "");
17
+
18
+ std::size_t input_dim() const { return _input_dim; }
19
+ std::size_t output_dim() const { return _output_dim; }
20
+ void initialize_globals(ContextPtr context) const;
21
+ std::string last_layer_bias_name() const {
22
+ return prefixed_name(_prefix, std::format("layer{}.bias", _layers));
23
+ }
24
+
25
+ private:
26
+ ValueVec
27
+ build_function_impl(FunctionBuilder& fb, const ValueVec& args) const override;
28
+
29
+ std::size_t _input_dim;
30
+ std::size_t _output_dim;
31
+ std::size_t _hidden_dim;
32
+ std::size_t _layers;
33
+ Activation _activation;
34
+ std::string _prefix;
35
+ };
36
+
37
+ } // namespace madspace
@@ -0,0 +1,49 @@
1
+ #pragma once
2
+
3
+ #include <format>
4
+ #include <vector>
5
+
6
+ #include "madspace/phasespace/base.h"
7
+ #include "madspace/phasespace/phasespace.h"
8
+
9
+ namespace madspace {
10
+
11
+ class MultiChannelMapping : public Mapping {
12
+ public:
13
+ MultiChannelMapping(const std::vector<std::shared_ptr<Mapping>>& mappings);
14
+
15
+ private:
16
+ Result build_impl(
17
+ FunctionBuilder& fb,
18
+ const ValueVec& inputs,
19
+ const ValueVec& conditions,
20
+ bool inverse
21
+ ) const;
22
+ Result build_forward_impl(
23
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
24
+ ) const override {
25
+ return build_impl(fb, inputs, conditions, false);
26
+ }
27
+ Result build_inverse_impl(
28
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
29
+ ) const override {
30
+ return build_impl(fb, inputs, conditions, true);
31
+ }
32
+
33
+ std::vector<std::shared_ptr<Mapping>> _mappings;
34
+ };
35
+
36
+ class MultiChannelFunction : public FunctionGenerator {
37
+ public:
38
+ MultiChannelFunction(
39
+ const std::vector<std::shared_ptr<FunctionGenerator>>& functions
40
+ );
41
+
42
+ private:
43
+ ValueVec
44
+ build_function_impl(FunctionBuilder& fb, const ValueVec& args) const override;
45
+
46
+ std::vector<std::shared_ptr<FunctionGenerator>> _functions;
47
+ };
48
+
49
+ } // namespace madspace
@@ -0,0 +1,85 @@
1
+ #pragma once
2
+
3
+ #include "madspace/madcode.h"
4
+ #include "madspace/phasespace/base.h"
5
+ #include "madspace/util.h"
6
+
7
+ #include <vector>
8
+
9
+ namespace madspace {
10
+
11
+ class Observable : public FunctionGenerator {
12
+ public:
13
+ static const std::vector<int> jet_pids;
14
+ static const std::vector<int> bottom_pids;
15
+ static const std::vector<int> lepton_pids;
16
+ static const std::vector<int> missing_pids;
17
+ static const std::vector<int> photon_pids;
18
+
19
+ enum ObservableOption {
20
+ obs_e,
21
+ obs_px,
22
+ obs_py,
23
+ obs_pz,
24
+ obs_mass,
25
+ obs_pt,
26
+ obs_p_mag,
27
+ obs_phi,
28
+ obs_theta,
29
+ obs_y,
30
+ obs_y_abs,
31
+ obs_eta,
32
+ obs_eta_abs,
33
+ obs_delta_eta,
34
+ obs_delta_phi,
35
+ obs_delta_r,
36
+ obs_sqrt_s
37
+ };
38
+
39
+ Observable(
40
+ const std::vector<int>& pids,
41
+ ObservableOption observable,
42
+ const nested_vector2<int>& select_pids,
43
+ bool sum_momenta = false,
44
+ bool sum_observable = false,
45
+ const std::optional<ObservableOption>& order_observable = std::nullopt,
46
+ const std::vector<int>& order_indices = {},
47
+ bool ignore_incoming = true,
48
+ const std::string& name = ""
49
+ );
50
+ ObservableOption observable() const { return _observable; }
51
+ std::vector<std::size_t> simple_observable_indices() const {
52
+ if (_sum_momenta || _sum_observable || _indices.size() != 1) {
53
+ return {};
54
+ } else {
55
+ return {_indices.at(0).begin(), _indices.at(0).end()};
56
+ }
57
+ }
58
+ std::string name() const { return _name; }
59
+ bool not_found() const;
60
+
61
+ private:
62
+ Observable(
63
+ std::tuple<nested_vector2<me_int_t>, nested_vector2<me_int_t>, Type>
64
+ indices_and_type,
65
+ const std::vector<int>& pids,
66
+ ObservableOption observable,
67
+ bool sum_momenta,
68
+ bool sum_observable,
69
+ const std::optional<ObservableOption>& order_observable,
70
+ bool ignore_incoming,
71
+ const std::string& name
72
+ );
73
+ ValueVec
74
+ build_function_impl(FunctionBuilder& fb, const ValueVec& args) const override;
75
+
76
+ ObservableOption _observable;
77
+ nested_vector2<me_int_t> _indices;
78
+ std::optional<ObservableOption> _order_observable;
79
+ nested_vector2<me_int_t> _order_indices;
80
+ bool _sum_momenta;
81
+ bool _sum_observable;
82
+ std::string _name;
83
+ };
84
+
85
+ } // namespace madspace
@@ -0,0 +1,78 @@
1
+ #pragma once
2
+
3
+ #include "madspace/phasespace/base.h"
4
+ #include "madspace/runtime/context.h"
5
+
6
+ namespace madspace {
7
+
8
+ struct PdfGrid {
9
+ std::vector<double> x;
10
+ std::vector<double> logx;
11
+ std::vector<double> q;
12
+ std::vector<double> logq2;
13
+ std::vector<int> pids;
14
+ std::vector<std::vector<double>> values;
15
+ std::vector<std::size_t> region_sizes;
16
+
17
+ PdfGrid(const std::string& file);
18
+ std::size_t grid_point_count() const;
19
+ std::size_t q_count() const;
20
+ void initialize_coefficients(Tensor tensor) const;
21
+ void initialize_logx(Tensor tensor) const;
22
+ void initialize_logq2(Tensor tensor) const;
23
+ std::vector<std::size_t> coefficients_shape(bool batch_dim = false) const;
24
+ std::vector<std::size_t> logx_shape(bool batch_dim = false) const;
25
+ std::vector<std::size_t> logq2_shape(bool batch_dim = false) const;
26
+ void initialize_globals(ContextPtr context, const std::string& prefix = "") const;
27
+ };
28
+
29
+ class PartonDensity : public FunctionGenerator {
30
+ public:
31
+ PartonDensity(
32
+ const PdfGrid& grid,
33
+ const std::vector<int>& pids,
34
+ bool dynamic_pid = false,
35
+ const std::string& prefix = ""
36
+ );
37
+
38
+ private:
39
+ ValueVec
40
+ build_function_impl(FunctionBuilder& fb, const ValueVec& args) const override;
41
+
42
+ std::vector<me_int_t> _pid_indices;
43
+ bool _dynamic_pid;
44
+ std::string _prefix;
45
+ std::vector<std::size_t> _logx_shape;
46
+ std::vector<std::size_t> _logq2_shape;
47
+ std::vector<std::size_t> _coeffs_shape;
48
+ };
49
+
50
+ struct AlphaSGrid {
51
+ std::vector<double> q;
52
+ std::vector<double> logq2;
53
+ std::vector<double> values;
54
+ std::vector<std::size_t> region_sizes;
55
+
56
+ AlphaSGrid(const std::string& file);
57
+ std::size_t q_count() const;
58
+ void initialize_coefficients(Tensor tensor) const;
59
+ void initialize_logq2(Tensor tensor) const;
60
+ std::vector<std::size_t> coefficients_shape(bool batch_dim = false) const;
61
+ std::vector<std::size_t> logq2_shape(bool batch_dim = false) const;
62
+ void initialize_globals(ContextPtr context, const std::string& prefix = "") const;
63
+ };
64
+
65
+ class RunningCoupling : public FunctionGenerator {
66
+ public:
67
+ RunningCoupling(const AlphaSGrid& grid, const std::string& prefix = "");
68
+
69
+ private:
70
+ ValueVec
71
+ build_function_impl(FunctionBuilder& fb, const ValueVec& args) const override;
72
+
73
+ std::string _prefix;
74
+ std::vector<std::size_t> _logq2_shape;
75
+ std::vector<std::size_t> _coeffs_shape;
76
+ };
77
+
78
+ } // namespace madspace
@@ -0,0 +1,67 @@
1
+ #pragma once
2
+
3
+ #include "madspace/phasespace/base.h"
4
+ #include "madspace/phasespace/chili.h"
5
+ #include "madspace/phasespace/cuts.h"
6
+ #include "madspace/phasespace/invariants.h"
7
+ #include "madspace/phasespace/luminosity.h"
8
+ #include "madspace/phasespace/rambo.h"
9
+ #include "madspace/phasespace/t_propagator_mapping.h"
10
+ #include "madspace/phasespace/three_particle.h"
11
+ #include "madspace/phasespace/topology.h"
12
+
13
+ namespace madspace {
14
+
15
+ class PhaseSpaceMapping : public Mapping {
16
+ public:
17
+ enum TChannelMode { propagator, rambo, chili };
18
+
19
+ PhaseSpaceMapping(
20
+ const Topology& topology,
21
+ double cm_energy,
22
+ bool leptonic = false,
23
+ double invariant_power = 0.8,
24
+ TChannelMode t_channel_mode = propagator,
25
+ const std::optional<Cuts>& cuts = std::nullopt,
26
+ const std::vector<std::vector<std::size_t>>& permutations = {}
27
+ );
28
+
29
+ PhaseSpaceMapping(
30
+ const std::vector<double>& external_masses,
31
+ double cm_energy,
32
+ bool leptonic = false,
33
+ double invariant_power = 0.8,
34
+ TChannelMode mode = rambo,
35
+ const std::optional<Cuts>& cuts = std::nullopt
36
+ );
37
+
38
+ std::size_t random_dim() const {
39
+ return 3 * _topology.outgoing_masses().size() - (_leptonic ? 4 : 2);
40
+ }
41
+ std::size_t particle_count() const {
42
+ return _topology.outgoing_masses().size() + 2;
43
+ }
44
+ std::size_t channel_count() const { return _permutations.size(); }
45
+
46
+ private:
47
+ Result build_forward_impl(
48
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
49
+ ) const override;
50
+ Result build_inverse_impl(
51
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
52
+ ) const override;
53
+
54
+ Topology _topology;
55
+ Cuts _cuts;
56
+ double _pi_factors;
57
+ double _sqrt_s_lab;
58
+ bool _leptonic;
59
+ bool _map_luminosity;
60
+ std::vector<Invariant> _s_invariants;
61
+ std::variant<TPropagatorMapping, FastRamboMapping, ChiliMapping, std::monostate>
62
+ _t_mapping;
63
+ std::vector<std::variant<TwoBodyDecay, ThreeBodyDecay, FastRamboMapping>> _s_decays;
64
+ nested_vector2<me_int_t> _permutations;
65
+ };
66
+
67
+ } // namespace madspace
@@ -0,0 +1,26 @@
1
+ #pragma once
2
+
3
+ #include "madspace/phasespace/base.h"
4
+
5
+ namespace madspace {
6
+
7
+ class FastRamboMapping : public Mapping {
8
+ public:
9
+ FastRamboMapping(std::size_t n_particles, bool massless, bool com = true);
10
+
11
+ std::size_t random_dim() const { return 3 * _n_particles - 4; }
12
+
13
+ private:
14
+ Result build_forward_impl(
15
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
16
+ ) const override;
17
+ Result build_inverse_impl(
18
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
19
+ ) const override;
20
+
21
+ std::size_t _n_particles;
22
+ bool _massless;
23
+ double _com;
24
+ };
25
+
26
+ } // namespace madspace
@@ -0,0 +1,52 @@
1
+ #pragma once
2
+
3
+ #include "madspace/phasespace/base.h"
4
+
5
+ namespace madspace {
6
+
7
+ class EnergyScale : public FunctionGenerator {
8
+ public:
9
+ enum DynamicalScaleType {
10
+ transverse_energy,
11
+ transverse_mass,
12
+ half_transverse_mass,
13
+ partonic_energy
14
+ };
15
+
16
+ EnergyScale(std::size_t particle_count) :
17
+ EnergyScale(particle_count, half_transverse_mass, false, false, 0., 0., 0.) {}
18
+ EnergyScale(std::size_t particle_count, DynamicalScaleType type) :
19
+ EnergyScale(particle_count, type, false, false, 0., 0., 0.) {}
20
+ EnergyScale(std::size_t particle_count, double fixed_scale) :
21
+ EnergyScale(
22
+ particle_count,
23
+ half_transverse_mass,
24
+ true,
25
+ true,
26
+ fixed_scale,
27
+ fixed_scale,
28
+ fixed_scale
29
+ ) {}
30
+ EnergyScale(
31
+ std::size_t particle_count,
32
+ DynamicalScaleType dynamical_scale_type,
33
+ bool ren_scale_fixed,
34
+ bool fact_scale_fixed,
35
+ double ren_scale,
36
+ double fact_scale1,
37
+ double fact_scale2
38
+ );
39
+
40
+ private:
41
+ ValueVec
42
+ build_function_impl(FunctionBuilder& fb, const ValueVec& args) const override;
43
+
44
+ DynamicalScaleType _dynamical_scale_type;
45
+ bool _ren_scale_fixed;
46
+ bool _fact_scale_fixed;
47
+ double _ren_scale;
48
+ double _fact_scale1;
49
+ double _fact_scale2;
50
+ };
51
+
52
+ } // namespace madspace
@@ -0,0 +1,34 @@
1
+ #pragma once
2
+
3
+ #include <vector>
4
+
5
+ #include "madspace/phasespace/base.h"
6
+ #include "madspace/phasespace/invariants.h"
7
+ #include "madspace/phasespace/topology.h"
8
+ #include "madspace/phasespace/two_particle.h"
9
+
10
+ namespace madspace {
11
+
12
+ class TPropagatorMapping : public Mapping {
13
+ public:
14
+ TPropagatorMapping(
15
+ const std::vector<std::size_t>& integration_order, double invariant_power = 0.8
16
+ );
17
+ std::size_t random_dim() const { return 3 * _integration_order.size() - 1; }
18
+
19
+ private:
20
+ Result build_forward_impl(
21
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
22
+ ) const override;
23
+ Result build_inverse_impl(
24
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
25
+ ) const override;
26
+
27
+ std::vector<std::size_t> _integration_order;
28
+ std::vector<bool> _sample_sides;
29
+ Invariant _uniform_invariant;
30
+ TwoToTwoParticleScattering _com_scattering;
31
+ TwoToTwoParticleScattering _lab_scattering;
32
+ };
33
+
34
+ } // namespace madspace
@@ -0,0 +1,68 @@
1
+ #pragma once
2
+
3
+ #include "madspace/phasespace/base.h"
4
+ #include "madspace/phasespace/invariants.h"
5
+
6
+ namespace madspace {
7
+
8
+ class ThreeBodyDecay : public Mapping {
9
+ public:
10
+ ThreeBodyDecay(bool com) :
11
+ Mapping(
12
+ "ThreeBodyDecay",
13
+ [&] {
14
+ TypeVec input_types(9, batch_float);
15
+ if (!com) {
16
+ input_types.push_back(batch_four_vec);
17
+ }
18
+ return input_types;
19
+ }(),
20
+ {batch_four_vec, batch_four_vec, batch_four_vec},
21
+ {}
22
+ ),
23
+ _com(com) {}
24
+ std::size_t random_dim() const { return 5; }
25
+
26
+ private:
27
+ Result build_forward_impl(
28
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
29
+ ) const override;
30
+ Result build_inverse_impl(
31
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
32
+ ) const override;
33
+
34
+ bool _com;
35
+ };
36
+
37
+ class TwoToThreeParticleScattering : public Mapping {
38
+ public:
39
+ TwoToThreeParticleScattering(
40
+ double t_invariant_power = 0,
41
+ double t_mass = 0,
42
+ double t_width = 0,
43
+ double s_invariant_power = 0,
44
+ double s_mass = 0,
45
+ double s_width = 0
46
+ ) :
47
+ Mapping(
48
+ "TwoToThreeParticleScattering",
49
+ {batch_float, batch_float, batch_float, batch_float, batch_float},
50
+ {batch_four_vec, batch_four_vec},
51
+ {batch_four_vec, batch_four_vec, batch_four_vec}
52
+ ),
53
+ _t_invariant(t_invariant_power, t_mass, t_width),
54
+ _s_invariant(s_invariant_power, s_mass, s_width) {}
55
+
56
+ private:
57
+ Result build_forward_impl(
58
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
59
+ ) const override;
60
+ Result build_inverse_impl(
61
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
62
+ ) const override;
63
+
64
+ Invariant _t_invariant;
65
+ Invariant _s_invariant;
66
+ };
67
+
68
+ } // namespace madspace
@@ -0,0 +1,116 @@
1
+ #pragma once
2
+
3
+ #include <array>
4
+ #include <ostream>
5
+ #include <string>
6
+ #include <vector>
7
+
8
+ namespace madspace {
9
+
10
+ struct Propagator {
11
+ double mass;
12
+ double width;
13
+ int integration_order;
14
+ double e_min;
15
+ double e_max;
16
+ int pdg_id;
17
+ };
18
+
19
+ class Diagram {
20
+ public:
21
+ enum LineType { incoming, outgoing, propagator };
22
+ class LineRef {
23
+ public:
24
+ LineRef(LineType type, std::size_t index) : _type(type), _index(index) {}
25
+ LineRef(std::string str);
26
+ LineType type() const { return _type; }
27
+ std::size_t index() const { return _index; }
28
+
29
+ private:
30
+ LineType _type;
31
+ std::size_t _index;
32
+ };
33
+ using Vertex = std::vector<LineRef>;
34
+
35
+ Diagram(
36
+ const std::vector<double>& incoming_masses,
37
+ const std::vector<double>& outgoing_masses,
38
+ const std::vector<Propagator>& propagators,
39
+ const std::vector<Vertex>& vertices
40
+ );
41
+
42
+ const std::vector<double>& incoming_masses() const { return _incoming_masses; }
43
+ const std::vector<double>& outgoing_masses() const { return _outgoing_masses; }
44
+ const std::vector<Propagator>& propagators() const { return _propagators; }
45
+ const std::vector<Vertex>& vertices() const { return _vertices; }
46
+ const std::array<int, 2>& incoming_vertices() const { return _incoming_vertices; };
47
+ const std::vector<int>& outgoing_vertices() const { return _outgoing_vertices; };
48
+ const std::vector<std::vector<std::size_t>>& propagator_vertices() const {
49
+ return _propagator_vertices;
50
+ }
51
+
52
+ private:
53
+ std::vector<double> _incoming_masses;
54
+ std::vector<double> _outgoing_masses;
55
+ std::vector<Propagator> _propagators;
56
+ std::vector<Vertex> _vertices;
57
+ std::array<int, 2> _incoming_vertices;
58
+ std::vector<int> _outgoing_vertices;
59
+ std::vector<std::vector<std::size_t>> _propagator_vertices;
60
+ };
61
+
62
+ std::ostream& operator<<(std::ostream& out, const Diagram::LineRef& value);
63
+
64
+ class Topology {
65
+ public:
66
+ struct Decay {
67
+ std::size_t index;
68
+ std::size_t parent_index;
69
+ std::vector<std::size_t> child_indices;
70
+ double mass;
71
+ double width;
72
+ double e_min;
73
+ double e_max;
74
+ int pdg_id;
75
+ bool on_shell;
76
+ };
77
+
78
+ static std::vector<Topology> topologies(const Diagram& diagram);
79
+ Topology(const Diagram& diagram);
80
+
81
+ std::size_t t_propagator_count() const { return _t_integration_order.size(); }
82
+ const std::vector<std::size_t>& t_integration_order() const {
83
+ return _t_integration_order;
84
+ }
85
+ const std::vector<double>& t_propagator_masses() const {
86
+ return _t_propagator_masses;
87
+ }
88
+ const std::vector<double>& t_propagator_widths() const {
89
+ return _t_propagator_widths;
90
+ }
91
+ const std::vector<Decay>& decays() const { return _decays; }
92
+ const std::vector<std::size_t>& decay_integration_order() const {
93
+ return _decay_integration_order;
94
+ }
95
+ const std::vector<std::size_t>& outgoing_indices() const {
96
+ return _outgoing_indices;
97
+ }
98
+ const std::vector<double>& incoming_masses() const { return _incoming_masses; }
99
+ const std::vector<double>& outgoing_masses() const { return _outgoing_masses; }
100
+ std::vector<std::tuple<std::vector<int>, double, double>>
101
+ propagator_momentum_terms(bool only_decays = false) const;
102
+
103
+ private:
104
+ Topology() = default;
105
+
106
+ std::vector<std::size_t> _t_integration_order;
107
+ std::vector<double> _t_propagator_masses;
108
+ std::vector<double> _t_propagator_widths;
109
+ std::vector<Decay> _decays;
110
+ std::vector<std::size_t> _decay_integration_order;
111
+ std::vector<std::size_t> _outgoing_indices;
112
+ std::vector<double> _incoming_masses;
113
+ std::vector<double> _outgoing_masses;
114
+ };
115
+
116
+ } // namespace madspace
@@ -0,0 +1,63 @@
1
+ #pragma once
2
+
3
+ #include "madspace/phasespace/base.h"
4
+ #include "madspace/phasespace/invariants.h"
5
+
6
+ namespace madspace {
7
+
8
+ class TwoBodyDecay : public Mapping {
9
+ public:
10
+ TwoBodyDecay(bool com) :
11
+ Mapping(
12
+ "TwoBodyDecay",
13
+ [&] {
14
+ TypeVec input_types(5, batch_float);
15
+ if (!com) {
16
+ input_types.push_back(batch_four_vec);
17
+ }
18
+ return input_types;
19
+ }(),
20
+ {batch_four_vec, batch_four_vec},
21
+ {}
22
+ ),
23
+ _com(com) {}
24
+ std::size_t random_dim() const { return 2; }
25
+
26
+ private:
27
+ Result build_forward_impl(
28
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
29
+ ) const override;
30
+ Result build_inverse_impl(
31
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
32
+ ) const override;
33
+
34
+ bool _com;
35
+ };
36
+
37
+ class TwoToTwoParticleScattering : public Mapping {
38
+ public:
39
+ TwoToTwoParticleScattering(
40
+ bool com, double invariant_power = 0, double mass = 0, double width = 0
41
+ ) :
42
+ Mapping(
43
+ "TwoToTwoParticleScattering",
44
+ {batch_float, batch_float, batch_float, batch_float},
45
+ {batch_four_vec, batch_four_vec},
46
+ {batch_four_vec, batch_four_vec}
47
+ ),
48
+ _com(com),
49
+ _invariant(invariant_power, mass, width) {}
50
+
51
+ private:
52
+ Result build_forward_impl(
53
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
54
+ ) const override;
55
+ Result build_inverse_impl(
56
+ FunctionBuilder& fb, const ValueVec& inputs, const ValueVec& conditions
57
+ ) const override;
58
+
59
+ bool _com;
60
+ Invariant _invariant;
61
+ };
62
+
63
+ } // namespace madspace