5 #include "../src/event.h"
10 #include "../src/nucleus.h"
11 #include "../src/random.h"
13 using namespace trento;
19 auto pplus = .5 + .49*random::canonical<>();
20 auto pminus = -.5 + .49*random::canonical<>();
21 for (
auto p : {0., pplus, pminus }) {
23 auto norm = 1. + .5*random::canonical<>();
24 auto xsec = 4. + 3.*random::canonical<>();
25 auto nucleon_width = .5 + .2*random::canonical<>();
33 auto grid_nsteps = 60;
36 {
"normalization",
norm},
37 {
"reduced-thickness",
p},
38 {
"grid-max", grid_max},
39 {
"grid-step", grid_step},
40 {
"fluctuation", fluct},
41 {
"cross-section", xsec},
42 {
"nucleon-width", nucleon_width},
48 CHECK(
event.reduced_thickness_grid().num_dimensions() == 2 );
49 CHECK( static_cast<int>(
event.reduced_thickness_grid().shape()[0]) == grid_nsteps );
50 CHECK( static_cast<int>(
event.reduced_thickness_grid().shape()[1]) == grid_nsteps );
56 auto b = 4.*std::sqrt(random::canonical<>());
57 nucleusA->sample_nucleons(+.5*
b);
58 nucleusB->sample_nucleons(-.5*
b);
60 for (
auto&&
A : *nucleusA)
61 for (
auto&& B : *nucleusB)
65 event.compute(*nucleusA, *nucleusB,
profile);
68 auto count_part = [](
const Nucleus& nucleus) {
70 for (
const auto&
n : nucleus)
71 if (
n.is_participant())
75 auto npart = count_part(*nucleusA) + count_part(*nucleusB);
79 boost::multi_array<double, 2> TR{boost::extents[grid_nsteps][grid_nsteps]};
83 for (
const auto&
n : nucleus) {
84 if (
n.is_participant()) {
93 auto gen_mean = [
p](
double a,
double b) {
94 if (std::abs(
p) < 1
e-12)
95 return std::sqrt(a*
b);
96 else if (
p < 0. && (a < 1
e-12 || b < 1
e-12))
99 return std::pow(.5*(std::pow(a,
p) + std::pow(b,
p)), 1./
p);
102 for (
auto iy = 0; iy < grid_nsteps; ++iy) {
103 for (
auto ix = 0; ix < grid_nsteps; ++ix) {
104 auto x = (ix + .5) * 2 * grid_max/grid_nsteps - grid_max;
105 auto y = (iy + .5) * 2 * grid_max/grid_nsteps - grid_max;
108 TR[iy][ix] =
norm * gen_mean(TA, TB);
113 auto mult = std::pow(2*grid_max/grid_nsteps, 2) *
114 std::accumulate(TR.origin(), TR.origin() + TR.num_elements(), 0.);
115 CHECK( mult == Approx(
event.multiplicity()) );
118 auto all_correct =
true;
119 for (
const auto*
t1 = TR.origin(),
120 *
t2 =
event.reduced_thickness_grid().origin();
121 t1 != TR.origin() + TR.num_elements();
123 if (*
t1 != Approx(*t2).epsilon(1
e-5)) {
125 WARN(
"TR mismatch: " << *
t1 <<
" != " << *
t2 );
129 CHECK( all_correct );
132 auto sum = 0., xcm = 0., ycm = 0.;
133 for (
auto iy = 0; iy < grid_nsteps; ++iy) {
134 for (
auto ix = 0; ix < grid_nsteps; ++ix) {
135 auto&
t = TR[iy][ix];
144 for (
auto n = 2;
n <= 5; ++
n) {
145 auto real = 0., imag = 0., weight = 0.;
146 for (
auto iy = 0; iy < grid_nsteps; ++iy) {
147 for (
auto ix = 0; ix < grid_nsteps; ++ix) {
150 auto w = TR[iy][ix] * std::pow(x*x +
y*
y, .5*
n);
152 auto phi = std::atan2(y, x);
154 imag += w*std::sin(
n*phi);
158 auto ecc = std::sqrt(
real*
real + imag*imag) / weight;
159 CHECK( ecc == Approx(
event.eccentricity().at(
n)).epsilon(1
e-6).margin(1
e-6) );
165 {
"normalization", 1.},
166 {
"reduced-thickness", 0.},
171 Event event{var_map};
173 CHECK(
event.reduced_thickness_grid().num_dimensions() == 2 );
174 CHECK(
event.reduced_thickness_grid().shape()[0] == 67 );
175 CHECK(
event.reduced_thickness_grid().shape()[1] == 67 );