-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoast_user_lib.cpp
110 lines (95 loc) · 3.42 KB
/
coast_user_lib.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/** \file
* COAST interface definition file.
*
* Here you can change the behavior of the COAST interface inside the function
* inida_(...), cloda_(...), wrida_(...), interaction_(...) and track_(...).
*/
#include <interface/CorsikaInterface.h>
#include <crs/CInteraction.h>
#include <crs/CParticle.h>
#include <crs/CorsikaTypes.h>
#include <crs/TSubBlock.h>
#include "python/PythonInterface.h"
#include "python/CorsikaConfig.h"
/** Initialize the COAST interface. */
extern "C" void inida_ ([[maybe_unused]] const char * filename,
[[maybe_unused]] const bool & thinning,
[[maybe_unused]] const bool & curved,
[[maybe_unused]] const bool & slant,
[[maybe_unused]] const bool & stackinput,
[[maybe_unused]] const bool & preshower,
[[maybe_unused]] int str_length) {
#ifdef USE_PYTHON_INTERFACE
PythonInterface * pythonInterface = PythonInterface::instance();
CorsikaConfig config(filename, str_length, thinning, curved, slant,
stackinput, preshower);
pythonInterface->init(config);
#endif
}
/** Write a CORSIKA binary data-block.
*
* Data is one CORSIKA data-block consiting of 21 SubBlocks.
* A SubBlock can be:
* - thinned mode: 39 (Particles) * 8 (ENTRIES) * 4 (BYTES)
* - not-thinned mode: 39 (Particles) * 7 (ENTRIES) * 4 (BYTES)
*/
extern "C" void wrida_([[maybe_unused]] const CREAL * DataSubBlock) {
#ifdef USE_PYTHON_INTERFACE
PythonInterface * pythonInterface = PythonInterface::instance();
pythonInterface->write(DataSubBlock);
#endif
}
/** Close and finalize the COAST interface. */
extern "C" void cloda_() {
#ifdef USE_PYTHON_INTERFACE
PythonInterface * pythonInterface = PythonInterface::instance();
pythonInterface->close();
#endif
}
/** Handle particle interaction information.
*
* All interactions in the shower are available in this function!
* The information available in the CInteraction class are:
* - double x;
* - double y;
* - double z;
* - double etot; (lab energy)
* - double sigma; (cross-section of process)
* - double kela; (elasticity)
* - int projId; (projectile)
* - int targetId; (target)
*/
extern "C" void interaction_([[maybe_unused]] const crs::CInteraction & info) {
#ifdef USE_PYTHON_INTERFACE
PythonInterface * pythonInterface = PythonInterface::instance();
pythonInterface->interaction(info);
#endif
}
/** Handle particle track information.
*
* All particles in the shower are available in this function!
* The pre and post objecte are the two endpoints for one single track
* in the shower, where the information available in CParticle is:
* - double x;
* - double y;
* - double z;
* - double depth;
* - double time;
* - double energy;
* - double weight;
* - int particleId;
* - int hadronicGeneration;
*/
extern "C" void track_([[maybe_unused]] const crs::CParticle & pre,
[[maybe_unused]] const crs::CParticle & post) {
#ifdef USE_PYTHON_INTERFACE
PythonInterface * pythonInterface = PythonInterface::instance();
pythonInterface->track(pre, post);
#endif
}
// for special use only but should be defined because it is delcared in CORSIKA.F
extern "C" void tabularizedatmosphere_(
[[maybe_unused]] const int & nPoints,
[[maybe_unused]] const double * height,
[[maybe_unused]] const double * refractiveIndex) {
}