Skip to content

Commit

Permalink
Add TsaiUrbanDistribution test
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent R. Pascuzzi committed May 24, 2021
1 parent 10ab4b5 commit 1e8fd0f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ celeritas_add_test(physics/em/LivermorePE.test.cc)
celeritas_add_test(physics/em/MollerBhabha.test.cc)
celeritas_add_test(physics/em/Rayleigh.test.cc)
celeritas_add_test(physics/em/SeltzerBerger.test.cc)
celeritas_add_test(physics/em/TsaiUrbanDistribution.test.cc)

celeritas_add_test(physics/em/ImportedProcesses.test.cc ${_needs_root}
${_optional_geant4}
Expand Down
54 changes: 54 additions & 0 deletions test/physics/em/TsaiUrbanDistribution.test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2020 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file TsaiUrbanDistribution.test.cc
//---------------------------------------------------------------------------//
#include "physics/em/detail/TsaiUrbanDistribution.hh"

#include <random>
#include "base/Constants.hh"
#include "base/Units.hh"
#include "celeritas_test.hh"

using celeritas::detail::TsaiUrbanDistribution;

//---------------------------------------------------------------------------//
// TEST HARNESS
//---------------------------------------------------------------------------//

class TsaiUrbanDistributionTest : public celeritas::Test
{
protected:
void SetUp() override {}

std::mt19937 rng;
};

//---------------------------------------------------------------------------//
// TESTS
//---------------------------------------------------------------------------//

TEST_F(TsaiUrbanDistributionTest, bin)
{
using namespace celeritas::constants;
using namespace celeritas::units;

std::vector<float> angles;
// Loop over various electron energies
for (double inc_e : {1.0, 10.0, 20.0, 50.0, 100.0})
{
TsaiUrbanDistribution sample_angle(MevEnergy{inc_e},
MevMass{electron_mass});
double angle = sample_angle(rng);
angles.push_back(angle);
}

const float expected_angles[] = {0.3245577893213,
-0.02649751911085,
0.6002972458021,
0.9822511633688,
0.1573926944923};
EXPECT_VEC_EQ(expected_angles, angles);
}

0 comments on commit 1e8fd0f

Please sign in to comment.