5 #include "../src/nucleon.h"
12 #include "../src/nucleus.h"
13 #include "../src/random.h"
15 using namespace trento;
18 auto fluct = 1. + .5*random::canonical<>();
19 auto xsec = 4. + 3.*random::canonical<>();
20 auto width = .5 + .2*random::canonical<>();
21 auto wsq = width*
width;
24 {
"fluctuation", fluct},
25 {
"cross-section", xsec},
26 {
"nucleon-width", width},
34 CHECK(
R == Approx(5*width) );
38 auto tzero =
profile.thickness(0.);
39 CHECK(
profile.thickness(wsq) == Approx(tzero*std::exp(-.5)) );
42 auto dsq = std::pow(
R*random::canonical<>(), 2);
43 CHECK(
profile.thickness(dsq) == Approx(tzero*std::exp(-.5*dsq/wsq)).epsilon(1
e-5).margin(1
e-5) );
46 dsq = std::pow(
R*(1+random::canonical<>()), 2);
53 for (
auto i = 0; i < static_cast<int>(
n); ++
i) {
55 total +=
profile.thickness(0.) * (2*M_PI*wsq);
59 CHECK(
mean == Approx(1.).epsilon(.003) );
65 A.sample_nucleons(0.);
66 B.sample_nucleons(0.);
67 auto& nA = *
A.begin();
68 auto& nB = *B.begin();
69 CHECK( nA.x() == 0. );
70 CHECK( nA.y() == 0. );
71 CHECK( nA.z() == 0. );
72 CHECK( !nA.is_participant() );
75 while (!
profile.participate(nA, nB)) {}
76 CHECK( nA.is_participant() );
77 CHECK( nB.is_participant() );
80 A.sample_nucleons(0.);
81 CHECK( !nA.is_participant() );
85 auto bmax =
profile.max_impact();
86 CHECK( bmax == Approx(6*width) );
90 for (
auto i = 0; i < static_cast<int>(nev); ++
i) {
91 auto b = bmax * std::sqrt(random::canonical<>());
92 A.sample_nucleons(.5*
b);
93 B.sample_nucleons(-.5*
b);
94 if (
profile.participate(nA, nB))
98 auto xsec_mc = M_PI*bmax*bmax *
static_cast<double>(
count)/nev;
101 CHECK( xsec_mc == Approx(xsec).epsilon(.02) );
104 auto b = bmax + random::canonical<>();
105 A.sample_nucleons(.5*
b);
106 B.sample_nucleons(-.5*
b);
111 {
"fluctuation", 1e12},
112 {
"cross-section", xsec},
113 {
"nucleon-width", width},
118 CHECK( no_fluct_profile.thickness(0) == Approx(1/(2*M_PI*wsq)) );
120 CHECK_THROWS_AS([]() {
124 {
"cross-section", 5.},
125 {
"nucleon-width", .1},