Skip to content

Commit

Permalink
rename cx_rad to ux and cy_rad to vy as it is defined in the CORSIKA …
Browse files Browse the repository at this point in the history
…7.56 manual
  • Loading branch information
relleums committed Feb 22, 2024
1 parent 8902353 commit 0329138
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 32 deletions.
14 changes: 6 additions & 8 deletions libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
51 changes: 47 additions & 4 deletions libs/mli_corsika/src/mli_corsika_CorsikaPhotonBunch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libs/mli_corsika/src/mli_corsika_EventIo.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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! */
Expand Down
8 changes: 4 additions & 4 deletions libs/mli_corsika/src/mli_corsika_EventIo_Event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions libs/mli_corsika/src/mli_corsika_EventTape_testing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
10 changes: 5 additions & 5 deletions libs/mli_corsika/src/mli_corsika_ray_voxel_overlap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions libs/mli_corsika/src/mli_corsika_test_photon_production.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libs/mli_corsika/src/mli_corsika_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0329138

Please sign in to comment.