IAP GITLAB

Skip to content
Snippets Groups Projects
Commit b0f20e4b authored by ralfulrich's avatar ralfulrich
Browse files

clang

parent 8f9236bc
No related branches found
No related tags found
No related merge requests found
...@@ -67,7 +67,7 @@ namespace corsika::stack { ...@@ -67,7 +67,7 @@ namespace corsika::stack {
delete; ///< since Stack can be very big, we don't want to copy it delete; ///< since Stack can be very big, we don't want to copy it
public: public:
//Stack() { Init(); } // Stack() { Init(); }
/** /**
* if StackDataType is a reference member we *HAVE* to initialize * if StackDataType is a reference member we *HAVE* to initialize
...@@ -76,8 +76,8 @@ namespace corsika::stack { ...@@ -76,8 +76,8 @@ namespace corsika::stack {
template < template <
typename _StackDataType = StackDataType, typename _StackDataType = StackDataType,
typename = std::enable_if<std::is_same<StackDataType, _StackDataType>::value && typename = std::enable_if<std::is_same<StackDataType, _StackDataType>::value &&
std::is_reference<_StackDataType>::value, std::is_reference<_StackDataType>::value,
void>> void>>
Stack(StackDataType vD) Stack(StackDataType vD)
: fData(vD) {} : fData(vD) {}
...@@ -89,8 +89,8 @@ namespace corsika::stack { ...@@ -89,8 +89,8 @@ namespace corsika::stack {
template < template <
typename... Args, typename _StackDataType = StackDataType, typename... Args, typename _StackDataType = StackDataType,
typename = std::enable_if<std::is_same<StackDataType, _StackDataType>::value && typename = std::enable_if<std::is_same<StackDataType, _StackDataType>::value &&
!std::is_reference<_StackDataType>::value, !std::is_reference<_StackDataType>::value,
void >> void>>
Stack(Args... args) Stack(Args... args)
: fData(args...) {} : fData(args...) {}
......
...@@ -96,7 +96,8 @@ TEST_CASE("Stack", "[Stack]") { ...@@ -96,7 +96,8 @@ TEST_CASE("Stack", "[Stack]") {
StackTest s; StackTest s;
REQUIRE(s.GetSize() == 0); REQUIRE(s.GetSize() == 0);
auto iter = s.AddParticle(std::tuple{9.9}); auto iter = s.AddParticle(std::tuple{9.9});
StackTest::ParticleInterfaceType& p = *iter; // also this is valid to access particle data StackTest::ParticleInterfaceType& p =
*iter; // also this is valid to access particle data
REQUIRE(s.GetSize() == 1); REQUIRE(s.GetSize() == 1);
p.AddSecondary(std::tuple{4.4}); p.AddSecondary(std::tuple{4.4});
REQUIRE(s.GetSize() == 2); REQUIRE(s.GetSize() == 2);
......
...@@ -32,99 +32,98 @@ using corsika::units::constants::cSquared; ...@@ -32,99 +32,98 @@ using corsika::units::constants::cSquared;
double constexpr absMargin = 1e-6; double constexpr absMargin = 1e-6;
CoordinateSystem const& rootCS = CoordinateSystem const& rootCS =
RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
// helper function for energy-momentum
// relativistic energy
auto const energy = [](HEPMassType m, Vector<hepmomentum_d> const& p) {
return sqrt(m * m + p.squaredNorm());
};
// helper function for mandelstam-s // helper function for energy-momentum
auto const s = [](HEPEnergyType E, QuantityVector<hepmomentum_d> const& p) { // relativistic energy
return E * E - p.squaredNorm(); auto const energy = [](HEPMassType m, Vector<hepmomentum_d> const& p) {
}; return sqrt(m * m + p.squaredNorm());
};
// helper function for mandelstam-s
auto const s = [](HEPEnergyType E, QuantityVector<hepmomentum_d> const& p) {
return E * E - p.squaredNorm();
};
TEST_CASE("rotation") { TEST_CASE("rotation") {
// define projectile kinematics in lab frame // define projectile kinematics in lab frame
HEPMassType const projectileMass = 1_GeV; HEPMassType const projectileMass = 1_GeV;
HEPMassType const targetMass = 1.0e300_eV; HEPMassType const targetMass = 1.0e300_eV;
Vector<hepmomentum_d> pProjectileLab{rootCS, {0_GeV, 0_PeV, 1_GeV}}; Vector<hepmomentum_d> pProjectileLab{rootCS, {0_GeV, 0_PeV, 1_GeV}};
HEPEnergyType const eProjectileLab = energy(projectileMass, pProjectileLab); HEPEnergyType const eProjectileLab = energy(projectileMass, pProjectileLab);
const FourVector PprojLab(eProjectileLab, pProjectileLab); const FourVector PprojLab(eProjectileLab, pProjectileLab);
Eigen::Vector3d e1, e2, e3; Eigen::Vector3d e1, e2, e3;
e1 << 1, 0, 0; e1 << 1, 0, 0;
e2 << 0, 1, 0; e2 << 0, 1, 0;
e3 << 0, 0, 1; e3 << 0, 0, 1;
// define boost to com frame
SECTION("pos. z-axis") {
COMBoost boost({eProjectileLab, {rootCS, {0_GeV, 0_GeV, 1_GeV}}}, targetMass);
auto const& rot = boost.GetRotationMatrix();
CHECK((rot * e3 - e3).norm() == Approx(0).margin(absMargin));
CHECK((rot * e1).norm() == Approx(1));
CHECK((rot * e2).norm() == Approx(1));
CHECK((rot * e3).norm() == Approx(1));
CHECK(rot.determinant() == Approx(1));
}
// define boost to com frame SECTION("y-axis in upper half") {
SECTION("pos. z-axis") { COMBoost boost({eProjectileLab, {rootCS, {0_GeV, 1_GeV, 1_meV}}}, targetMass);
COMBoost boost({eProjectileLab, {rootCS, {0_GeV, 0_GeV, 1_GeV}}}, targetMass); auto const& rot = boost.GetRotationMatrix();
auto const& rot = boost.GetRotationMatrix();
CHECK((rot * e2 - e3).norm() == Approx(0).margin(absMargin));
CHECK((rot * e3 - e3).norm() == Approx(0).margin(absMargin)); CHECK((rot * e1).norm() == Approx(1));
CHECK((rot * e1).norm() == Approx(1)); CHECK((rot * e2).norm() == Approx(1));
CHECK((rot * e2).norm() == Approx(1)); CHECK((rot * e3).norm() == Approx(1));
CHECK((rot * e3).norm() == Approx(1)); CHECK(rot.determinant() == Approx(1));
CHECK(rot.determinant() == Approx(1)); }
}
SECTION("x-axis in upper half") {
SECTION("y-axis in upper half") { COMBoost boost({eProjectileLab, {rootCS, {1_GeV, 0_GeV, 1_meV}}}, targetMass);
COMBoost boost({eProjectileLab, {rootCS, {0_GeV, 1_GeV, 1_meV}}}, targetMass); auto const& rot = boost.GetRotationMatrix();
auto const& rot = boost.GetRotationMatrix();
CHECK((rot * e1 - e3).norm() == Approx(0).margin(absMargin));
CHECK((rot * e2 - e3).norm() == Approx(0).margin(absMargin)); CHECK((rot * e1).norm() == Approx(1));
CHECK((rot * e1).norm() == Approx(1)); CHECK((rot * e2).norm() == Approx(1));
CHECK((rot * e2).norm() == Approx(1)); CHECK((rot * e3).norm() == Approx(1));
CHECK((rot * e3).norm() == Approx(1)); CHECK(rot.determinant() == Approx(1));
CHECK(rot.determinant() == Approx(1)); }
}
SECTION("neg. z-axis") {
SECTION("x-axis in upper half") { COMBoost boost({eProjectileLab, {rootCS, {0_GeV, 0_GeV, -1_GeV}}}, targetMass);
COMBoost boost({eProjectileLab, {rootCS, {1_GeV, 0_GeV, 1_meV}}}, targetMass); auto const& rot = boost.GetRotationMatrix();
auto const& rot = boost.GetRotationMatrix();
CHECK((rot * (-e3) - e3).norm() == Approx(0).margin(absMargin));
CHECK((rot * e1 - e3).norm() == Approx(0).margin(absMargin)); CHECK((rot * e1).norm() == Approx(1));
CHECK((rot * e1).norm() == Approx(1)); CHECK((rot * e2).norm() == Approx(1));
CHECK((rot * e2).norm() == Approx(1)); CHECK((rot * e3).norm() == Approx(1));
CHECK((rot * e3).norm() == Approx(1)); CHECK(rot.determinant() == Approx(1));
CHECK(rot.determinant() == Approx(1)); }
}
SECTION("x-axis lower half") {
SECTION("neg. z-axis") { COMBoost boost({eProjectileLab, {rootCS, {1_GeV, 0_GeV, -1_meV}}}, targetMass);
COMBoost boost({eProjectileLab, {rootCS, {0_GeV, 0_GeV, -1_GeV}}}, targetMass); auto const& rot = boost.GetRotationMatrix();
auto const& rot = boost.GetRotationMatrix();
CHECK((rot * e1 - e3).norm() == Approx(0).margin(absMargin));
CHECK((rot * (-e3) - e3).norm() == Approx(0).margin(absMargin)); CHECK((rot * e1).norm() == Approx(1));
CHECK((rot * e1).norm() == Approx(1)); CHECK((rot * e2).norm() == Approx(1));
CHECK((rot * e2).norm() == Approx(1)); CHECK((rot * e3).norm() == Approx(1));
CHECK((rot * e3).norm() == Approx(1)); CHECK(rot.determinant() == Approx(1));
CHECK(rot.determinant() == Approx(1)); }
}
SECTION("y-axis lower half") {
SECTION("x-axis lower half") { COMBoost boost({eProjectileLab, {rootCS, {0_GeV, 1_GeV, -1_meV}}}, targetMass);
COMBoost boost({eProjectileLab, {rootCS, {1_GeV, 0_GeV, -1_meV}}}, targetMass); auto const& rot = boost.GetRotationMatrix();
auto const& rot = boost.GetRotationMatrix();
CHECK((rot * e2 - e3).norm() == Approx(0).margin(absMargin));
CHECK((rot * e1 - e3).norm() == Approx(0).margin(absMargin)); CHECK((rot * e1).norm() == Approx(1));
CHECK((rot * e1).norm() == Approx(1)); CHECK((rot * e2).norm() == Approx(1));
CHECK((rot * e2).norm() == Approx(1)); CHECK((rot * e3).norm() == Approx(1));
CHECK((rot * e3).norm() == Approx(1)); CHECK(rot.determinant() == Approx(1));
CHECK(rot.determinant() == Approx(1)); }
}
SECTION("y-axis lower half") {
COMBoost boost({eProjectileLab, {rootCS, {0_GeV, 1_GeV, -1_meV}}}, targetMass);
auto const& rot = boost.GetRotationMatrix();
CHECK((rot * e2 - e3).norm() == Approx(0).margin(absMargin));
CHECK((rot * e1).norm() == Approx(1));
CHECK((rot * e2).norm() == Approx(1));
CHECK((rot * e3).norm() == Approx(1));
CHECK(rot.determinant() == Approx(1));
}
} }
TEST_CASE("boosts") { TEST_CASE("boosts") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment