From 03291380e7ef944128a2bf430379fa21c3e5a0ae Mon Sep 17 00:00:00 2001 From: Sebastian Achim Mueller Date: Thu, 22 Feb 2024 19:47:29 +0100 Subject: [PATCH] rename cx_rad to ux and cy_rad to vy as it is defined in the CORSIKA 7.56 manual --- .../src/mli_corsika_CorsikaPhotonBunch.c | 14 +++-- .../src/mli_corsika_CorsikaPhotonBunch.h | 51 +++++++++++++++++-- .../src/mli_corsika_EventIo.test.c | 4 +- .../src/mli_corsika_EventIo_Event.c | 8 +-- .../src/mli_corsika_EventTape_testing.c | 4 +- .../src/mli_corsika_ray_voxel_overlap.c | 10 ++-- .../mli_corsika_test_photon_production.test.c | 10 ++-- libs/mli_corsika/src/mli_corsika_version.h | 4 +- 8 files changed, 73 insertions(+), 32 deletions(-) diff --git a/libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.c b/libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.c index 27df0acc..a8c34a90 100644 --- a/libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.c +++ b/libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.c @@ -13,8 +13,8 @@ void mliCorsikaPhotonBunch_set_from_raw( { bunch->x_cm = raw[0]; bunch->y_cm = raw[1]; - bunch->cx_rad = raw[2]; - bunch->cy_rad = raw[3]; + bunch->ux = raw[2]; + bunch->vy = raw[3]; bunch->time_ns = raw[4]; bunch->z_emission_cm = raw[5]; bunch->weight_photons = raw[6]; @@ -27,8 +27,8 @@ void mliCorsikaPhotonBunch_to_raw( { raw[0] = bunch->x_cm; raw[1] = bunch->y_cm; - raw[2] = bunch->cx_rad; - raw[3] = bunch->cy_rad; + raw[2] = bunch->ux; + raw[3] = bunch->vy; raw[4] = bunch->time_ns; raw[5] = bunch->z_emission_cm; raw[6] = bunch->weight_photons; @@ -135,10 +135,8 @@ struct mliVec mli_corsika_photon_direction_of_motion( It is the momentum of the Cherenkov-photon, which is pointing down towards the observation-plane. */ - const double cz_rad = - sqrt(1.0 - bunch.cx_rad * bunch.cx_rad - - bunch.cy_rad * bunch.cy_rad); - return mliVec_init(bunch.cx_rad, bunch.cy_rad, -cz_rad); + const double z = sqrt(1.0 - bunch.ux * bunch.ux - bunch.vy * bunch.vy); + return mliVec_init(bunch.ux, bunch.vy, -z); } struct mliVec mli_corsika_photon_support_on_observation_level( diff --git a/libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.h b/libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.h index 621ad82c..2412308c 100644 --- a/libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.h +++ b/libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.h @@ -11,17 +11,60 @@ struct mliCorsikaPhotonBunch { /* * x in cm * y in cm - * cx - * cy + * ux = sin(theta) * cos(phi) + * vy = sin(theta) * sin(phi) * time in nanoseconds since first interaction. * zem * photons * wavelength is in nanometer negative if scattered ?! + * + * KIT-CORSIKA coordinate-system + * /\ z-axis * + * | * + * |\ p * + * | \ a * + * | \ r * + * | \ t * + * | \ i * + * | \ c * + * | \ l * + * | \ e * + * | \ * + * | theta \ m * + * | ___\ o * + * |___---- \ m ___ * + * | \ e /| y-axis (west) * + * | \ n / * + * | \ t / * + * | \/u * + * | / \ m * + * | / \ * + * | / \ * + * | /__________\ * + * | / ___---/ * + * | / __--- / * + * | /__--- phi \ / * + * _______________|/--__________/______\ x-axis (north) * + * /| / * + * / | * + * / | * + * / * + * * + * * + * Extensive Air Shower Simulation with CORSIKA, Figure 1, page 114 + * (Version 7.6400 from December 27, 2017) + * + * Direction-cosines: + * ux = sin(theta) * cos(phi) + * vy = sin(theta) * sin(phi) + * The zenith-angle theta opens relative to the negative z-axis. + * It is the momentum of the Cherenkov-photon, which is pointing + * down towards the observation-plane. */ float x_cm; float y_cm; - float cx_rad; - float cy_rad; + float ux; + float vy; float time_ns; float z_emission_cm; float weight_photons; diff --git a/libs/mli_corsika/src/mli_corsika_EventIo.test.c b/libs/mli_corsika/src/mli_corsika_EventIo.test.c index fb1da563..1cafb86f 100644 --- a/libs/mli_corsika/src/mli_corsika_EventIo.test.c +++ b/libs/mli_corsika/src/mli_corsika_EventIo.test.c @@ -250,8 +250,8 @@ CASE("EventIoRun_telescope_dat__photon_bundle_values") CHECK_MARGIN(b.x_cm, some[j].x_cm, 1e-6); CHECK_MARGIN(b.y_cm, some[j].y_cm, 1e-6); - CHECK_MARGIN(b.cx_rad, some[j].cx_rad, 1e-6); - CHECK_MARGIN(b.cy_rad, some[j].cy_rad, 1e-6); + CHECK_MARGIN(b.ux, some[j].ux, 1e-6); + CHECK_MARGIN(b.vy, some[j].vy, 1e-6); CHECK_MARGIN(b.time_ns, some[j].time_ns, 1e-6); CHECK_MARGIN(b.z_emission_cm, some[j].z_emission_cm, 10.0); /* the height can sometimes be way off! */ diff --git a/libs/mli_corsika/src/mli_corsika_EventIo_Event.c b/libs/mli_corsika/src/mli_corsika_EventIo_Event.c index 8b0ad31d..c50fc16f 100644 --- a/libs/mli_corsika/src/mli_corsika_EventIo_Event.c +++ b/libs/mli_corsika/src/mli_corsika_EventIo_Event.c @@ -106,8 +106,8 @@ int mliEventIo_read_photon_bunches( bunches->array[row].x_cm = tmp[0] * 0.1; bunches->array[row].y_cm = tmp[1] * 0.1; - bunches->array[row].cx_rad = tmp[2] / 30000; - bunches->array[row].cy_rad = tmp[3] / 30000; + bunches->array[row].ux = tmp[2] / 30000; + bunches->array[row].vy = tmp[3] / 30000; bunches->array[row].time_ns = tmp[4] * 0.1; bunches->array[row].z_emission_cm = pow(10, tmp[5] * 0.001); @@ -120,8 +120,8 @@ int mliEventIo_read_photon_bunches( bunches->array[row].x_cm = tmp[0]; bunches->array[row].y_cm = tmp[1]; - bunches->array[row].cx_rad = tmp[2]; - bunches->array[row].cy_rad = tmp[3]; + bunches->array[row].ux = tmp[2]; + bunches->array[row].vy = tmp[3]; bunches->array[row].time_ns = tmp[4]; bunches->array[row].z_emission_cm = tmp[5]; bunches->array[row].weight_photons = tmp[6]; diff --git a/libs/mli_corsika/src/mli_corsika_EventTape_testing.c b/libs/mli_corsika/src/mli_corsika_EventTape_testing.c index b6733aa6..15112714 100644 --- a/libs/mli_corsika/src/mli_corsika_EventTape_testing.c +++ b/libs/mli_corsika/src/mli_corsika_EventTape_testing.c @@ -57,11 +57,11 @@ int mliEventTape_testing_bunches_are_equal(float *b1, float *b2) return 0; } if (b1[2] != b2[2]) { - fprintf(stderr, "Bunch missmatch cx_rad.\n"); + fprintf(stderr, "Bunch missmatch ux.\n"); return 0; } if (b1[3] != b2[3]) { - fprintf(stderr, "Bunch missmatch cy_rad.\n"); + fprintf(stderr, "Bunch missmatch vy.\n"); return 0; } if (b1[4] != b2[4]) { diff --git a/libs/mli_corsika/src/mli_corsika_ray_voxel_overlap.c b/libs/mli_corsika/src/mli_corsika_ray_voxel_overlap.c index b577f117..3509a807 100644 --- a/libs/mli_corsika/src/mli_corsika_ray_voxel_overlap.c +++ b/libs/mli_corsika/src/mli_corsika_ray_voxel_overlap.c @@ -263,6 +263,7 @@ void mli_corsika_overlap_of_ray_with_voxels( { double support[3]; double direction[3]; + struct mliVec _direction = {0}; unsigned int number_overlaps = 0u; unsigned int x_range[2]; @@ -273,11 +274,10 @@ void mli_corsika_overlap_of_ray_with_voxels( support[1] = bunch->y_cm; support[2] = 0.0; - direction[0] = bunch->cx_rad; - direction[1] = bunch->cy_rad; - direction[2] = - sqrt(1.0 - bunch->cx_rad * bunch->cx_rad - - bunch->cy_rad * bunch->cy_rad); + _direction = mli_corsika_photon_direction_of_motion(*bunch); + direction[0] = _direction.x; + direction[1] = _direction.y; + direction[2] = _direction.z; x_range[0] = 0u; x_range[1] = x_bin_edges->size - 1u; diff --git a/libs/mli_corsika/src/mli_corsika_test_photon_production.test.c b/libs/mli_corsika/src/mli_corsika_test_photon_production.test.c index 1b6e90d5..df3a92e3 100644 --- a/libs/mli_corsika/src/mli_corsika_test_photon_production.test.c +++ b/libs/mli_corsika/src/mli_corsika_test_photon_production.test.c @@ -19,16 +19,16 @@ CASE("EventIoPhotonFactoryTest: intersection_point_on_ground") int64_t id = 0; for (float x = -1e4; x < 1e4; x = x + 1495.0) { for (float y = -1e4; y < 1e4; y = y + 1495.0) { - for (float cx = -0.5; cx < 0.5; cx = cx + 0.11) { - for (float cy = -0.5; cy < 0.5; - cy = cy + 0.11) { + for (float ux = -0.5; ux < 0.5; ux = ux + 0.11) { + for (float vy = -0.5; vy < 0.5; + vy = vy + 0.11) { struct mliPhoton merlict_photon; struct mliCorsikaPhotonBunch corsika_photon; corsika_photon.x_cm = x; corsika_photon.y_cm = y; - corsika_photon.cx_rad = cx; - corsika_photon.cy_rad = cy; + corsika_photon.ux = ux; + corsika_photon.vy = vy; corsika_photon.time_ns = 0.0; corsika_photon.z_emission_cm = 1e5; corsika_photon.weight_photons = 1.0; diff --git a/libs/mli_corsika/src/mli_corsika_version.h b/libs/mli_corsika/src/mli_corsika_version.h index 83a25ede..d5fca9e5 100644 --- a/libs/mli_corsika/src/mli_corsika_version.h +++ b/libs/mli_corsika/src/mli_corsika_version.h @@ -3,7 +3,7 @@ #define MLI_CORSIKA_VERSION_H_ #define MLI_CORSIKA_VERSION_MAYOR 0 -#define MLI_CORSIKA_VERSION_MINOR 2 -#define MLI_CORSIKA_VERSION_PATCH 1 +#define MLI_CORSIKA_VERSION_MINOR 3 +#define MLI_CORSIKA_VERSION_PATCH 0 #endif