IAP GITLAB

Commit 8bf837b8 authored by Ralf Ulrich's avatar Ralf Ulrich

Max's comments, and a bug...

parent 8d07b2b5
Pipeline #3493 passed with stages
in 61 minutes and 16 seconds
...@@ -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
......
...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment