IAP GITLAB

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

further unit testing

parent d9beb8ae
No related branches found
No related tags found
No related merge requests found
......@@ -112,11 +112,13 @@ namespace corsika {
constants::c / (abs(charge) * magnitudeB);
if (gyroradius > 1e9_m) {
// this cannot be really unit-tested. It is hidden. LCOV_EXCL_START
CORSIKA_LOG_WARN(
"CurvedLeapFrog is not very stable for extremely high gyroradius steps. "
"Rg={} -> straight tracking.",
gyroradius);
return getLinearTrajectory(particle);
// LCOV_EXCL_STOP
}
double const maxRadians = 0.01; // maximally allowed deflection
......@@ -168,7 +170,8 @@ namespace corsika {
CORSIKA_LOG_TRACE("projectedDirectionSqrNorm={} T^2",
projectedDirectionSqrNorm / square(1_T));
if ((charge == 0 * constants::e) || magneticfield.getNorm() == 0_T || isParallel) {
if (isParallel) {
// particle moves parallel to field -> no deflection
return tracking_line::Tracking::intersect<TParticle>(particle, sphere);
}
......
......@@ -70,6 +70,8 @@ TEMPLATE_TEST_CASE("Tracking", "tracking", tracking_leapfrog_curved::Tracking,
const HEPEnergyType P0 = 10_GeV;
auto PID = GENERATE(as<Code>{}, Code::MuPlus, Code::MuPlus, Code::Photon);
// test also special case: movement parallel to field (along x)
auto isParallel = GENERATE(as<bool>{}, true, false);
// for algorithms that know magnetic deflections choose: +-50uT, 0uT
// otherwise just 0uT
auto Bfield = GENERATE(filter(
......@@ -79,25 +81,26 @@ TEMPLATE_TEST_CASE("Tracking", "tracking", tracking_leapfrog_curved::Tracking,
else
return true;
},
values<MagneticFluxType>({50_uT, 0_uT, -50_uT})));
values<MagneticFluxType>({50_uT, 0_uT, (isParallel ? 0 : -50_uT)})));
// particle --> (world) --> | --> (target)
// true: start inside "world" volume
// false: start inside "target" volume
auto outer = GENERATE(as<bool>{}, true, false);
SECTION(fmt::format("Tracking PID={}, Bfield={} uT, from outside={}", PID,
Bfield / 1_uT, outer)) {
SECTION(fmt::format("Tracking PID={}, Bfield={} uT, isParallel={}, from outside={}",
PID, Bfield / 1_uT, isParallel, outer)) {
CORSIKA_LOG_DEBUG(
"********************\n TEST algo={} section PID={}, "
"Bfield={} "
"uT, start_outside={}",
boost::typeindex::type_id<TestType>().pretty_name(), PID, Bfield / 1_uT, outer);
"uT, field is parallel={}, start_outside={}",
boost::typeindex::type_id<TestType>().pretty_name(), PID, Bfield / 1_uT,
isParallel, outer);
const int chargeNumber = get_charge_number(PID);
LengthType radius = 10_m;
int deflect = 0;
if (chargeNumber != 0 and Bfield != 0_T) {
if (chargeNumber != 0 && Bfield != 0_T && !isParallel) {
deflect = -sgn(chargeNumber) * sgn(Bfield / 1_T); // direction of deflection
LengthType const gyroradius = (convert_HEP_to_SI<MassType::dimension_type>(P0) *
constants::c / (abs(get_charge(PID)) * abs(Bfield)));
......
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