IAP GITLAB

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

Max's comments, and a bug...

parent 8d07b2b5
No related branches found
No related tags found
No related merge requests found
...@@ -59,13 +59,9 @@ namespace corsika { ...@@ -59,13 +59,9 @@ namespace corsika {
corsika::setup::Stack::particle_type const& particle, corsika::setup::Stack::particle_type const& particle,
corsika::setup::Trajectory const& trajectory) { corsika::setup::Trajectory const& trajectory) {
auto const& volumeNode = particle.getNode();
typedef typename std::remove_const_t<
std::remove_reference_t<decltype(volumeNode->getModelProperties())>>
medium_type;
Intersections const intersection = Intersections const intersection =
setup::Tracking::intersect<corsika::setup::Stack::particle_type, medium_type>( setup::Tracking::intersect<corsika::setup::Stack::particle_type>(particle,
particle, plane_, volumeNode->getModelProperties()); plane_);
TimeType const timeOfIntersection = intersection.getEntry(); TimeType const timeOfIntersection = intersection.getEntry();
CORSIKA_LOG_TRACE("particle={}, pos={}, dir={}, plane={}, timeOfIntersection={}", CORSIKA_LOG_TRACE("particle={}, pos={}, dir={}, plane={}, timeOfIntersection={}",
particle.asString(), particle.getPosition(), particle.asString(), particle.getPosition(),
......
...@@ -38,7 +38,7 @@ namespace corsika { ...@@ -38,7 +38,7 @@ namespace corsika {
// first check, where we leave the current volume // first check, where we leave the current volume
// this assumes our convention, that all Volume primitives must be convex // this assumes our convention, that all Volume primitives must be convex
// thus, the last entry is always the exit point // thus, the last entry is always the exit point
const Intersections time_intersections_curr = Intersections const time_intersections_curr =
TDerived::intersect(particle, volumeNode); TDerived::intersect(particle, volumeNode);
CORSIKA_LOG_TRACE("curr node {}, parent node {}, hasIntersections={} ", CORSIKA_LOG_TRACE("curr node {}, parent node {}, hasIntersections={} ",
fmt::ptr(&volumeNode), fmt::ptr(volumeNode.getParent()), fmt::ptr(&volumeNode), fmt::ptr(volumeNode.getParent()),
...@@ -56,16 +56,16 @@ namespace corsika { ...@@ -56,16 +56,16 @@ namespace corsika {
// where do we collide with any of the next-tree-level volumes // where do we collide with any of the next-tree-level volumes
// entirely contained by currentLogicalVolumeNode // entirely contained by currentLogicalVolumeNode
for (const auto& node : volumeNode.getChildNodes()) { for (auto const& node : volumeNode.getChildNodes()) {
const Intersections time_intersections = TDerived::intersect(particle, *node); Intersections const time_intersections = TDerived::intersect(particle, *node);
if (!time_intersections.hasIntersections()) { continue; } if (!time_intersections.hasIntersections()) { continue; }
CORSIKA_LOG_DEBUG("intersection times with child volume {} : enter {} s, exit {} s", CORSIKA_LOG_DEBUG("intersection times with child volume {} : enter {} s, exit {} s",
fmt::ptr(node), time_intersections.getEntry() / 1_s, fmt::ptr(node), time_intersections.getEntry() / 1_s,
time_intersections.getExit() / 1_s); time_intersections.getExit() / 1_s);
const auto t_entry = time_intersections.getEntry(); auto const t_entry = time_intersections.getEntry();
const auto t_exit = time_intersections.getExit(); auto const t_exit = time_intersections.getExit();
CORSIKA_LOG_TRACE("children t-entry: {}, t-exit: {}, smaller? {} ", t_entry, t_exit, CORSIKA_LOG_TRACE("children t-entry: {}, t-exit: {}, smaller? {} ", t_entry, t_exit,
t_entry <= minTime); t_entry <= minTime);
// note, theoretically t can even be smaller than 0 since we // note, theoretically t can even be smaller than 0 since we
...@@ -86,14 +86,14 @@ namespace corsika { ...@@ -86,14 +86,14 @@ namespace corsika {
// current volume // current volume
for (node_type* node : volumeNode.getExcludedNodes()) { for (node_type* node : volumeNode.getExcludedNodes()) {
const Intersections time_intersections = TDerived::intersect(particle, *node); Intersections const time_intersections = TDerived::intersect(particle, *node);
if (!time_intersections.hasIntersections()) { continue; } if (!time_intersections.hasIntersections()) { continue; }
CORSIKA_LOG_DEBUG( CORSIKA_LOG_DEBUG(
"intersection times with exclusion volume {} : enter {} s, exit {} s", "intersection times with exclusion volume {} : enter {} s, exit {} s",
fmt::ptr(node), time_intersections.getEntry() / 1_s, fmt::ptr(node), time_intersections.getEntry() / 1_s,
time_intersections.getExit() / 1_s); time_intersections.getExit() / 1_s);
const auto t_entry = time_intersections.getEntry(); auto const t_entry = time_intersections.getEntry();
const auto t_exit = time_intersections.getExit(); auto const t_exit = time_intersections.getExit();
CORSIKA_LOG_TRACE("children t-entry: {}, t-exit: {}, smaller? {} ", t_entry, t_exit, CORSIKA_LOG_TRACE("children t-entry: {}, t-exit: {}, smaller? {} ", t_entry, t_exit,
t_entry <= minTime); t_entry <= minTime);
// note, theoretically t can even be smaller than 0 since we // note, theoretically t can even be smaller than 0 since we
......
...@@ -103,9 +103,9 @@ namespace corsika { ...@@ -103,9 +103,9 @@ namespace corsika {
LengthType const gyroradius = LengthType const gyroradius =
(pAlongB_delta * 1_V / (constants::c * abs(chargeNumber) * magnitudeB * 1_eV)); (pAlongB_delta * 1_V / (constants::c * abs(chargeNumber) * magnitudeB * 1_eV));
const double maxRadians = 0.01; double const maxRadians = 0.01;
const LengthType steplimit = 2 * cos(maxRadians) * sin(maxRadians) * gyroradius; LengthType const steplimit = 2 * cos(maxRadians) * sin(maxRadians) * gyroradius;
const TimeType steplimit_time = steplimit / initialVelocity.getNorm(); TimeType const steplimit_time = steplimit / initialVelocity.getNorm();
CORSIKA_LOG_DEBUG("gyroradius {}, steplimit: {} = {}", gyroradius, steplimit, CORSIKA_LOG_DEBUG("gyroradius {}, steplimit: {} = {}", gyroradius, steplimit,
steplimit_time); steplimit_time);
...@@ -113,7 +113,7 @@ namespace corsika { ...@@ -113,7 +113,7 @@ namespace corsika {
// intersection // intersection
auto [minTime, minNode] = nextIntersect(particle, steplimit_time); auto [minTime, minNode] = nextIntersect(particle, steplimit_time);
const auto k = auto const k =
chargeNumber * constants::cSquared * 1_eV / (particle.getEnergy() * 1_V); chargeNumber * constants::cSquared * 1_eV / (particle.getEnergy() * 1_V);
return std::make_tuple( return std::make_tuple(
LeapFrogTrajectory(position, initialVelocity, magneticfield, k, LeapFrogTrajectory(position, initialVelocity, magneticfield, k,
...@@ -121,10 +121,9 @@ namespace corsika { ...@@ -121,10 +121,9 @@ namespace corsika {
minNode); // next volume node minNode); // next volume node
} }
template <typename TParticle, typename TMedium> template <typename TParticle>
inline Intersections Tracking::intersect(const TParticle& particle, inline Intersections Tracking::intersect(TParticle const& particle,
const Sphere& sphere, Sphere const& sphere) {
const TMedium& medium) {
if (sphere.getRadius() == 1_km * std::numeric_limits<double>::infinity()) { if (sphere.getRadius() == 1_km * std::numeric_limits<double>::infinity()) {
return Intersections(); return Intersections();
...@@ -132,7 +131,9 @@ namespace corsika { ...@@ -132,7 +131,9 @@ namespace corsika {
int const chargeNumber = particle.getChargeNumber(); int const chargeNumber = particle.getChargeNumber();
auto const& position = particle.getPosition(); auto const& position = particle.getPosition();
MagneticFieldVector const& magneticfield = medium.getMagneticField(position); auto const* currentLogicalVolumeNode = particle.getNode();
MagneticFieldVector const& magneticfield =
currentLogicalVolumeNode->getModelProperties().getMagneticField(position);
VelocityVector const velocity = VelocityVector const velocity =
particle.getMomentum() / particle.getEnergy() * constants::c; particle.getMomentum() / particle.getEnergy() * constants::c;
...@@ -144,26 +145,23 @@ namespace corsika { ...@@ -144,26 +145,23 @@ namespace corsika {
bool const isParallel = (projectedDirectionSqrNorm == 0 * square(1_T)); bool const isParallel = (projectedDirectionSqrNorm == 0 * square(1_T));
if (chargeNumber == 0 || magneticfield.getNorm() == 0_T || isParallel) { if (chargeNumber == 0 || magneticfield.getNorm() == 0_T || isParallel) {
return tracking_line::Tracking::intersect<TParticle, TMedium>(particle, sphere, return tracking_line::Tracking::intersect<TParticle>(particle, sphere);
medium);
} }
bool const numericallyInside = sphere.contains(particle.getPosition()); bool const numericallyInside = sphere.contains(particle.getPosition());
const auto absVelocity = velocity.getNorm(); auto const absVelocity = velocity.getNorm();
auto energy = particle.getEnergy(); auto energy = particle.getEnergy();
auto k = chargeNumber * constants::cSquared * 1_eV / (absVelocity * energy * 1_V); auto k = chargeNumber * constants::cSquared * 1_eV / (absVelocity * energy * 1_V);
auto const denom = (directionBefore.cross(magneticfield)).getSquaredNorm() * k * k; auto const direction_B_perp = directionBefore.cross(magneticfield);
const double a = auto const denom = direction_B_perp.getSquaredNorm() * k * k;
((directionBefore.cross(magneticfield)).dot(position - sphere.getCenter()) * k + Vector<length_d> const deltaPos = position - sphere.getCenter();
1) * double const a = (direction_B_perp.dot(deltaPos) * k + 1) * 4 / (1_m * 1_m * denom);
4 / (1_m * 1_m * denom); double const b = directionBefore.dot(deltaPos) * 8 / (denom * 1_m * 1_m * 1_m);
const double b = directionBefore.dot(position - sphere.getCenter()) * 8 / double const c =
(denom * 1_m * 1_m * 1_m); (deltaPos.getSquaredNorm() - (sphere.getRadius() * sphere.getRadius())) * 4 /
const double c = ((position - sphere.getCenter()).getSquaredNorm() - (denom * 1_m * 1_m * 1_m * 1_m);
(sphere.getRadius() * sphere.getRadius())) *
4 / (denom * 1_m * 1_m * 1_m * 1_m);
CORSIKA_LOG_TRACE("denom={}, a={}, b={}, c={}", denom, a, b, c); CORSIKA_LOG_TRACE("denom={}, a={}, b={}, c={}", denom, a, b, c);
std::complex<double>* solutions = quartic_solver::solve_quartic(0, a, b, c); std::complex<double>* solutions = quartic_solver::solve_quartic(0, a, b, c);
LengthType d_enter, d_exit; LengthType d_enter, d_exit;
...@@ -225,9 +223,9 @@ namespace corsika { ...@@ -225,9 +223,9 @@ namespace corsika {
return Intersections(d_enter / absVelocity, d_exit / absVelocity); return Intersections(d_enter / absVelocity, d_exit / absVelocity);
} }
template <typename TParticle, typename TMedium> template <typename TParticle>
inline Intersections Tracking::intersect(TParticle const& particle, inline Intersections Tracking::intersect(TParticle const& particle,
Plane const& plane, TMedium const& medium) { Plane const& plane) {
int chargeNumber; int chargeNumber;
if (is_nucleus(particle.getPID())) { if (is_nucleus(particle.getPID())) {
...@@ -236,9 +234,6 @@ namespace corsika { ...@@ -236,9 +234,6 @@ namespace corsika {
chargeNumber = get_charge_number(particle.getPID()); chargeNumber = get_charge_number(particle.getPID());
} }
auto const* currentLogicalVolumeNode = particle.getNode(); auto const* currentLogicalVolumeNode = particle.getNode();
auto magneticfield =
currentLogicalVolumeNode->getModelProperties().getMagneticField(
particle.getPosition());
VelocityVector const velocity = VelocityVector const velocity =
particle.getMomentum() / particle.getEnergy() * constants::c; particle.getMomentum() / particle.getEnergy() * constants::c;
auto const absVelocity = velocity.getNorm(); auto const absVelocity = velocity.getNorm();
...@@ -246,70 +241,68 @@ namespace corsika { ...@@ -246,70 +241,68 @@ namespace corsika {
velocity.normalized(); // determine steplength to next volume velocity.normalized(); // determine steplength to next volume
Point const position = particle.getPosition(); Point const position = particle.getPosition();
if (chargeNumber != 0 && auto const magneticfield =
abs(plane.getNormal().dot(velocity.cross(magneticfield))) * 1_s / 1_m / 1_T > currentLogicalVolumeNode->getModelProperties().getMagneticField(position);
1e-6) {
if (chargeNumber != 0 && abs(plane.getNormal().dot(velocity.cross(magneticfield))) >
1e-6_T * 1_m / 1_s) {
auto const* currentLogicalVolumeNode = particle.getNode(); auto const* currentLogicalVolumeNode = particle.getNode();
auto magneticfield = auto const magneticfield =
currentLogicalVolumeNode->getModelProperties().getMagneticField( currentLogicalVolumeNode->getModelProperties().getMagneticField(position);
particle.getPosition()); auto const k =
auto k = chargeNumber * (constants::c * 1_eV / 1_V) / particle.getMomentum().getNorm();
chargeNumber * constants::c * 1_eV / (particle.getMomentum().getNorm() * 1_V);
auto const direction_B_perp = direction.cross(magneticfield);
if (direction.dot(plane.getNormal()) * direction.dot(plane.getNormal()) - auto const denom = plane.getNormal().dot(direction_B_perp) * k;
(plane.getNormal().dot(position - plane.getCenter()) * auto const sqrtArg =
plane.getNormal().dot(direction.cross(magneticfield)) * 2 * k) < direction.dot(plane.getNormal()) * direction.dot(plane.getNormal()) -
0) { (plane.getNormal().dot(position - plane.getCenter()) * denom * 2);
if (sqrtArg < 0) {
return Intersections(std::numeric_limits<double>::infinity() * 1_s); return Intersections(std::numeric_limits<double>::infinity() * 1_s);
} }
double const sqrSqrtArg = sqrt(sqrtArg);
auto const norm_projected =
direction.dot(plane.getNormal()) / direction.getNorm();
LengthType const MaxStepLength1 = (sqrSqrtArg - norm_projected) / denom;
LengthType const MaxStepLength2 = (-sqrSqrtArg - norm_projected) / denom;
LengthType const MaxStepLength1 = // check: both intersections in past
(sqrt(direction.dot(plane.getNormal()) * direction.dot(plane.getNormal()) -
(plane.getNormal().dot(position - plane.getCenter()) *
plane.getNormal().dot(direction.cross(magneticfield)) * 2 * k)) -
direction.dot(plane.getNormal()) / direction.getNorm()) /
(plane.getNormal().dot(direction.cross(magneticfield)) * k);
LengthType const MaxStepLength2 =
(-sqrt(direction.dot(plane.getNormal()) * direction.dot(plane.getNormal()) -
(plane.getNormal().dot(position - plane.getCenter()) *
plane.getNormal().dot(direction.cross(magneticfield)) * 2 * k)) -
direction.dot(plane.getNormal()) / direction.getNorm()) /
(plane.getNormal().dot(direction.cross(magneticfield)) * k);
if (MaxStepLength1 <= 0_m && MaxStepLength2 <= 0_m) { if (MaxStepLength1 <= 0_m && MaxStepLength2 <= 0_m) {
return Intersections(std::numeric_limits<double>::infinity() * 1_s); return Intersections(std::numeric_limits<double>::infinity() * 1_s);
// check: next intersection is MaxStepLength2
} else if (MaxStepLength1 <= 0_m || MaxStepLength2 < MaxStepLength1) { } else if (MaxStepLength1 <= 0_m || MaxStepLength2 < MaxStepLength1) {
CORSIKA_LOG_TRACE(" steplength to obs plane 2: {} ", MaxStepLength2); CORSIKA_LOG_TRACE(" steplength to obs plane 2: {} ", MaxStepLength2);
return Intersections( return Intersections(
MaxStepLength2 * MaxStepLength2 *
(direction + direction.cross(magneticfield) * MaxStepLength2 * k / 2) (direction + direction_B_perp * MaxStepLength2 * k / 2).getNorm() /
.getNorm() /
absVelocity); absVelocity);
// check: next intersections is MaxStepLength1
} else if (MaxStepLength2 <= 0_m || MaxStepLength1 < MaxStepLength2) { } else if (MaxStepLength2 <= 0_m || MaxStepLength1 < MaxStepLength2) {
CORSIKA_LOG_TRACE(" steplength to obs plane 2: {} ", MaxStepLength1); CORSIKA_LOG_TRACE(" steplength to obs plane 2: {} ", MaxStepLength1);
return Intersections( return Intersections(
MaxStepLength1 * MaxStepLength1 *
(direction + direction.cross(magneticfield) * MaxStepLength2 * k / 2) (direction + direction_B_perp * MaxStepLength1 * k / 2).getNorm() /
.getNorm() /
absVelocity); absVelocity);
} }
CORSIKA_LOG_WARN("Particle wasn't tracked with curved trajectory -> straight"); CORSIKA_LOG_WARN(
"Particle wasn't tracked with curved trajectory -> straight (is this an "
"ERROR?)");
} // end if curved-tracking } // end if curved-tracking
return tracking_line::Tracking::intersect(particle, plane, medium); return tracking_line::Tracking::intersect(particle, plane);
} }
template <typename TParticle, typename TBaseNodeType> template <typename TParticle, typename TBaseNodeType>
inline Intersections Tracking::intersect(const TParticle& particle, inline Intersections Tracking::intersect(TParticle const& particle,
const TBaseNodeType& volumeNode) { TBaseNodeType const& volumeNode) {
const Sphere* sphere = dynamic_cast<const Sphere*>(&volumeNode.getVolume()); Sphere const* sphere = dynamic_cast<Sphere const*>(&volumeNode.getVolume());
if (sphere) { if (sphere) { return intersect(particle, *sphere); }
return intersect(particle, *sphere, volumeNode.getModelProperties());
}
throw std::runtime_error( throw std::runtime_error(
"The Volume type provided is not supported in intersect(particle, node)"); "The Volume type provided is not supported in intersect(particle, node)");
} }
......
...@@ -28,7 +28,7 @@ namespace corsika { ...@@ -28,7 +28,7 @@ namespace corsika {
VelocityVector initialVelocity = VelocityVector initialVelocity =
particle.getMomentum() / particle.getEnergy() * constants::c; particle.getMomentum() / particle.getEnergy() * constants::c;
const Point initialPosition = particle.getPosition(); Point const initialPosition = particle.getPosition();
CORSIKA_LOG_DEBUG( CORSIKA_LOG_DEBUG(
"TrackingB pid: {}" "TrackingB pid: {}"
" , E = {} GeV", " , E = {} GeV",
...@@ -53,17 +53,17 @@ namespace corsika { ...@@ -53,17 +53,17 @@ namespace corsika {
const int chargeNumber = particle.getChargeNumber(); const int chargeNumber = particle.getChargeNumber();
auto magneticfield = auto magneticfield =
volumeNode->getModelProperties().getMagneticField(initialPosition); volumeNode->getModelProperties().getMagneticField(initialPosition);
const auto magnitudeB = magneticfield.getNorm(); auto const magnitudeB = magneticfield.getNorm();
CORSIKA_LOG_DEBUG("field={} uT, chargeNumber={}, magnitudeB={} uT", CORSIKA_LOG_DEBUG("field={} uT, chargeNumber={}, magnitudeB={} uT",
magneticfield.getComponents() / 1_uT, chargeNumber, magneticfield.getComponents() / 1_uT, chargeNumber,
magnitudeB / 1_T); magnitudeB / 1_T);
bool const no_deflection = chargeNumber == 0 || magnitudeB == 0_T; bool const no_deflection = chargeNumber == 0 || magnitudeB == 0_T;
// check, where the first halve-step direction has geometric intersections // check, where the first halve-step direction has geometric intersections
const auto [initialTrack, initialTrackNextVolume] = auto const [initialTrack, initialTrackNextVolume] =
tracking_line::Tracking::getTrack(particle); tracking_line::Tracking::getTrack(particle);
{ [[maybe_unused]] auto& initialTrackNextVolume_dum = initialTrackNextVolume; } { [[maybe_unused]] auto& initialTrackNextVolume_dum = initialTrackNextVolume; }
const auto initialTrackLength = initialTrack.getLength(1); auto const initialTrackLength = initialTrack.getLength(1);
CORSIKA_LOG_DEBUG("initialTrack(0)={}, initialTrack(1)={}, initialTrackLength={}", CORSIKA_LOG_DEBUG("initialTrack(0)={}, initialTrack(1)={}, initialTrackLength={}",
initialTrack.getPosition(0).getCoordinates(), initialTrack.getPosition(0).getCoordinates(),
...@@ -94,8 +94,8 @@ namespace corsika { ...@@ -94,8 +94,8 @@ namespace corsika {
// need to follow strongly curved trajectories segment-wise, // need to follow strongly curved trajectories segment-wise,
// at least if we don't employ concepts as "Helix // at least if we don't employ concepts as "Helix
// Trajectories" or similar // Trajectories" or similar
const double maxRadians = 0.01; double const maxRadians = 0.01;
const LengthType steplimit = 2 * cos(maxRadians) * sin(maxRadians) * gyroradius; LengthType const steplimit = 2 * cos(maxRadians) * sin(maxRadians) * gyroradius;
CORSIKA_LOG_DEBUG("gyroradius {}, Steplimit: {}", gyroradius, steplimit); CORSIKA_LOG_DEBUG("gyroradius {}, Steplimit: {}", gyroradius, steplimit);
// calculate first halve step for "steplimit" // calculate first halve step for "steplimit"
...@@ -110,12 +110,12 @@ namespace corsika { ...@@ -110,12 +110,12 @@ namespace corsika {
CORSIKA_LOG_DEBUG("first halve step length {}, steplimit={}, initialTrackLength={}", CORSIKA_LOG_DEBUG("first halve step length {}, steplimit={}, initialTrackLength={}",
firstHalveSteplength, steplimit, initialTrackLength); firstHalveSteplength, steplimit, initialTrackLength);
// perform the first halve-step // perform the first halve-step
const Point position_mid = initialPosition + direction * firstHalveSteplength; Point const position_mid = initialPosition + direction * firstHalveSteplength;
const auto k = auto const k =
chargeNumber * constants::c * 1_eV / (particle.getMomentum().getNorm() * 1_V); chargeNumber * (constants::c * 1_eV / 1_V) / particle.getMomentum().getNorm();
const auto new_direction = auto const new_direction =
direction + direction.cross(magneticfield) * firstHalveSteplength * 2 * k; direction + direction.cross(magneticfield) * firstHalveSteplength * 2 * k;
const auto new_direction_norm = new_direction.getNorm(); // by design this is >1 auto const new_direction_norm = new_direction.getNorm(); // by design this is >1
CORSIKA_LOG_DEBUG( CORSIKA_LOG_DEBUG(
"position_mid={}, new_direction={}, (new_direction_norm)={}, deflection={}", "position_mid={}, new_direction={}, (new_direction_norm)={}, deflection={}",
position_mid.getCoordinates(), new_direction.getComponents(), position_mid.getCoordinates(), new_direction.getComponents(),
...@@ -126,7 +126,7 @@ namespace corsika { ...@@ -126,7 +126,7 @@ namespace corsika {
// check, where the second halve-step direction has geometric intersections // check, where the second halve-step direction has geometric intersections
particle.setPosition(position_mid); particle.setPosition(position_mid);
particle.setMomentum(new_direction * absMomentum); particle.setMomentum(new_direction * absMomentum);
const auto [finalTrack, finalTrackNextVolume] = auto const [finalTrack, finalTrackNextVolume] =
tracking_line::Tracking::getTrack(particle); tracking_line::Tracking::getTrack(particle);
particle.setPosition(initialPosition); // this is not nice... particle.setPosition(initialPosition); // this is not nice...
particle.setMomentum(initialMomentum); // this is not nice... particle.setMomentum(initialMomentum); // this is not nice...
...@@ -160,12 +160,12 @@ namespace corsika { ...@@ -160,12 +160,12 @@ namespace corsika {
// perform the second halve-step // perform the second halve-step
auto const new_direction_normalized = new_direction.normalized(); auto const new_direction_normalized = new_direction.normalized();
const Point finalPosition = Point const finalPosition =
position_mid + new_direction_normalized * secondHalveStepLength; position_mid + new_direction_normalized * secondHalveStepLength;
const LengthType totalStep = firstHalveSteplength + secondHalveStepLength; LengthType const totalStep = firstHalveSteplength + secondHalveStepLength;
const auto delta_pos = finalPosition - initialPosition; auto const delta_pos = finalPosition - initialPosition;
const auto distance = delta_pos.getNorm(); auto const distance = delta_pos.getNorm();
return std::make_tuple( return std::make_tuple(
StraightTrajectory( StraightTrajectory(
......
...@@ -48,9 +48,9 @@ namespace corsika::tracking_line { ...@@ -48,9 +48,9 @@ namespace corsika::tracking_line {
minNode); // next volume node minNode); // next volume node
} }
template <typename TParticle, typename TMedium> template <typename TParticle>
inline Intersections Tracking::intersect(TParticle const& particle, inline Intersections Tracking::intersect(TParticle const& particle,
Sphere const& sphere, TMedium const&) { Sphere const& sphere) {
auto const delta = particle.getPosition() - sphere.getCenter(); auto const delta = particle.getPosition() - sphere.getCenter();
auto const velocity = particle.getMomentum() / particle.getEnergy() * constants::c; auto const velocity = particle.getMomentum() / particle.getEnergy() * constants::c;
auto const vSqNorm = velocity.getSquaredNorm(); auto const vSqNorm = velocity.getSquaredNorm();
...@@ -73,20 +73,14 @@ namespace corsika::tracking_line { ...@@ -73,20 +73,14 @@ namespace corsika::tracking_line {
inline Intersections Tracking::intersect(TParticle const& particle, inline Intersections Tracking::intersect(TParticle const& particle,
TBaseNodeType const& volumeNode) { TBaseNodeType const& volumeNode) {
Sphere const* sphere = dynamic_cast<Sphere const*>(&volumeNode.getVolume()); Sphere const* sphere = dynamic_cast<Sphere const*>(&volumeNode.getVolume());
if (sphere) { if (sphere) { return Tracking::intersect<TParticle>(particle, *sphere); }
typedef typename std::remove_const_t<
std::remove_reference_t<decltype(volumeNode.getModelProperties())>>
medium_type;
return Tracking::intersect<TParticle, medium_type>(particle, *sphere,
volumeNode.getModelProperties());
}
throw std::runtime_error( throw std::runtime_error(
"The Volume type provided is not supported in Intersect(particle, node)"); "The Volume type provided is not supported in Intersect(particle, node)");
} }
template <typename TParticle, typename TMedium> template <typename TParticle>
inline Intersections Tracking::intersect(TParticle const& particle, Plane const& plane, inline Intersections Tracking::intersect(TParticle const& particle,
TMedium const&) { Plane const& plane) {
auto const delta = plane.getCenter() - particle.getPosition(); auto const delta = plane.getCenter() - particle.getPosition();
auto const velocity = particle.getMomentum() / particle.getEnergy() * constants::c; auto const velocity = particle.getMomentum() / particle.getEnergy() * constants::c;
auto const n = plane.getNormal(); auto const n = plane.getNormal();
......
...@@ -60,17 +60,18 @@ namespace corsika { ...@@ -60,17 +60,18 @@ namespace corsika {
template <typename TParticle> template <typename TParticle>
auto getTrack(TParticle const& particle); auto getTrack(TParticle const& particle);
template <typename TParticle, typename TMedium> //! find intersection of Sphere with Track
static Intersections intersect(TParticle const& particle, Sphere const& sphere, template <typename TParticle>
TMedium const& medium); static Intersections intersect(TParticle const& particle, Sphere const& sphere);
//! find intersection of Volume node with Track of particle
template <typename TParticle, typename TBaseNodeType> template <typename TParticle, typename TBaseNodeType>
static Intersections intersect(TParticle const& particle, static Intersections intersect(TParticle const& particle,
TBaseNodeType const& volumeNode); TBaseNodeType const& node);
template <typename TParticle, typename TMedium> //! find intersection of Plane with Track
static Intersections intersect(TParticle const& particle, Plane const& plane, template <typename TParticle>
TMedium const& medium); static Intersections intersect(TParticle const& particle, Plane const& plane);
protected: protected:
/** /**
......
...@@ -41,19 +41,16 @@ namespace corsika::tracking_line { ...@@ -41,19 +41,16 @@ namespace corsika::tracking_line {
auto getTrack(TParticle const& particle); auto getTrack(TParticle const& particle);
//! find intersection of Sphere with Track //! find intersection of Sphere with Track
template <typename TParticle, typename TMedium> template <typename TParticle>
static Intersections intersect(TParticle const& particle, Sphere const& sphere, static Intersections intersect(TParticle const& particle, Sphere const& sphere);
TMedium const&);
//! find intersection of Volume with Track //! find intersection of Volume node with Track of particle
template <typename TParticle, typename TBaseNodeType> template <typename TParticle, typename TBaseNodeType>
static Intersections intersect(TParticle const& particle, static Intersections intersect(TParticle const& particle, TBaseNodeType const& node);
TBaseNodeType const& volumeNode);
//! find intersection of Plane with Track //! find intersection of Plane with Track
template <typename TParticle, typename TMedium> template <typename TParticle>
static Intersections intersect(TParticle const& particle, Plane const& plane, static Intersections intersect(TParticle const& particle, Plane const& plane);
TMedium const&);
}; };
} // namespace corsika::tracking_line } // namespace corsika::tracking_line
......
...@@ -83,6 +83,7 @@ cmd += " -style=file" ...@@ -83,6 +83,7 @@ cmd += " -style=file"
version = subp.check_output(cmd.split() + ["--version"]).decode("utf-8") version = subp.check_output(cmd.split() + ["--version"]).decode("utf-8")
print (version) print (version)
print ("Note: the clang-format version has an impact on the result. Make sure you are consistent with current CI. Consider \'--docker\' option.")
if args.apply: if args.apply:
for filename in filelist: for filename in filelist:
......
...@@ -93,7 +93,7 @@ def read_qgsjetII_codes(filename, particle_db): ...@@ -93,7 +93,7 @@ def read_qgsjetII_codes(filename, particle_db):
if len(line)==0 or line[0] == '#': if len(line)==0 or line[0] == '#':
continue continue
line = line.split('#')[0] line = line.split('#')[0]
print (line) print ('QGSJetII codes: ', line)
identifier, model_code, xsType = line.split() identifier, model_code, xsType = line.split()
try: try:
particle_db[identifier]["qgsjetII_code"] = int(model_code) particle_db[identifier]["qgsjetII_code"] = int(model_code)
...@@ -202,7 +202,7 @@ if __name__ == "__main__": ...@@ -202,7 +202,7 @@ if __name__ == "__main__":
particle_db = load_particledb(sys.argv[1]) particle_db = load_particledb(sys.argv[1])
read_qgsjetII_codes(sys.argv[2], particle_db) read_qgsjetII_codes(sys.argv[2], particle_db)
set_default_qgsjetII_definition(particle_db) set_default_qgsjetII_definition(particle_db)
with open("Generated.inc", "w") as f: with open("Generated.inc", "w") as f:
print("// this file is automatically generated\n// edit at your own risk!\n", file=f) print("// this file is automatically generated\n// edit at your own risk!\n", file=f)
print(generate_qgsjetII_start(), file=f) print(generate_qgsjetII_start(), file=f)
......
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