CORSIKA add-on package IACT/ATMO:  Version 1.63 (November 2020)
mc_tel.h
Go to the documentation of this file.
1 /* ============================================================================
2 
3  Copyright (C) 1997, 2001, 2009, 2010, 2019 Konrad Bernloehr
4 
5  This file is part of the eventio/hessio library.
6 
7  The eventio/hessio library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with this library. If not, see <http://www.gnu.org/licenses/>.
19 
20 ============================================================================ */
21 
34 /* ========================================================= */
35 
36 #ifndef _MC_TEL_LOADED
37 
38 #define _MC_TEL_LOADED 2
39 
40 #ifndef _EVENTIO_BASIC_LOADED
41 # include "io_basic.h"
42 #endif
43 
44 #include "mc_atmprof.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /* Data types: */
51 
52 #ifdef DOUBLEPREC
53 typedef double real;
54 #else
55 typedef float real;
56 #endif
57 
58 typedef short INT16;
59 typedef unsigned short UINT16;
60 #ifdef OS_MSDOS
61 typedef long INT32;
62 typedef unsigned long UINT32;
63 #else
64 typedef int INT32;
65 typedef unsigned int UINT32;
66 #endif
67 
68 /* Data structures: */
75 struct bunch
76 {
77  float photons;
78  float x, y;
79  float cx, cy;
80  float ctime;
81  float zem;
82  float lambda;
83 };
84 
107 {
108  short photons;
109  short x, y;
110  short cx, cy;
111  short ctime;
112  short log_zem;
113  short lambda;
114 };
115 
119 {
120  int pixel;
121  int lambda;
122  double atime;
123  /* double amplitude; */
124 };
125 
129 {
130  char *text;
131  struct linked_string *next;
132 };
133 
140 {
141  long id;
142  int is_set;
145  double weight;
152  size_t niparam;
153  int *iparam;
155  size_t nfparam;
156  float *fparam;
157 };
159 
160 /* I/O item types: */
161 
162 /* Never change the following numbers after MC data is created: */
163 #define IO_TYPE_MC_BASE 1200
164 #define IO_TYPE_MC_RUNH (IO_TYPE_MC_BASE+0)
165 #define IO_TYPE_MC_TELPOS (IO_TYPE_MC_BASE+1)
166 #define IO_TYPE_MC_EVTH (IO_TYPE_MC_BASE+2)
167 #define IO_TYPE_MC_TELOFF (IO_TYPE_MC_BASE+3)
168 #define IO_TYPE_MC_TELARRAY (IO_TYPE_MC_BASE+4)
169 #define IO_TYPE_MC_PHOTONS (IO_TYPE_MC_BASE+5)
170 #define IO_TYPE_MC_LAYOUT (IO_TYPE_MC_BASE+6)
171 #define IO_TYPE_MC_TRIGTIME (IO_TYPE_MC_BASE+7)
172 #define IO_TYPE_MC_PE (IO_TYPE_MC_BASE+8)
173 #define IO_TYPE_MC_EVTE (IO_TYPE_MC_BASE+9)
174 #define IO_TYPE_MC_RUNE (IO_TYPE_MC_BASE+10)
175 #define IO_TYPE_MC_LONGI (IO_TYPE_MC_BASE+11)
176 #define IO_TYPE_MC_INPUTCFG (IO_TYPE_MC_BASE+12)
177 #define IO_TYPE_MC_TELARRAY_HEAD (IO_TYPE_MC_BASE+13)
178 #define IO_TYPE_MC_TELARRAY_END (IO_TYPE_MC_BASE+14)
179 #define IO_TYPE_MC_EXTRA_PARAM (IO_TYPE_MC_BASE+15)
180 #define IO_TYPE_MC_ATMPROF (IO_TYPE_MC_BASE+16)
181 
182 /* Function prototypes: */
183 
184 /* io_telescope.c */
185 int write_tel_block (IO_BUFFER *iobuf, int type, int num,
186  real *data, int len);
187 int read_tel_block (IO_BUFFER *iobuf, int type, real *data,
188  int maxlen);
189 int print_tel_block (IO_BUFFER *iobuf);
190 
191 int write_input_lines (IO_BUFFER *iobuf,
192  struct linked_string *list);
193 int read_input_lines (IO_BUFFER *iobuf,
194  struct linked_string *list);
195 
196 int write_tel_pos (IO_BUFFER *iobuf, int ntel, double *x,
197  double *y, double *z, double *r);
198 int read_tel_pos (IO_BUFFER *iobuf, int max_tel, int *ntel,
199  double *x, double *y, double *z, double *r);
200 int print_tel_pos (IO_BUFFER *iobuf);
201 
202 int write_tel_offset (IO_BUFFER *iobuf, int narray, double toff,
203  double *xoff, double *yoff);
204 int write_tel_offset_w (IO_BUFFER *iobuf, int narray, double toff,
205  double *xoff, double *yoff, double *weight);
206 int read_tel_offset (IO_BUFFER *iobuf, int max_array, int *narray,
207  double *toff, double *xoff, double *yoff);
208 int read_tel_offset_w (IO_BUFFER *iobuf, int max_array, int *narray,
209  double *toff, double *xoff, double *yoff, double *weight);
210 int print_tel_offset (IO_BUFFER *iobuf);
211 
212 int begin_write_tel_array (IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int array);
214 int begin_read_tel_array (IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int *array);
216 
217 int write_tel_array_head (IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int array);
218 int write_tel_array_end (IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int array);
219 int read_tel_array_head (IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int *array);
220 int read_tel_array_end (IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int *array);
221 
222 int write_tel_photons (IO_BUFFER *iobuf, int array, int tel,
223  double photons, struct bunch *bunches, int nbunches,
224  int ext_bunches, char *ext_fname);
225 int write_tel_compact_photons (IO_BUFFER *iobuf, int array, int tel,
226  double photons, struct compact_bunch *cbunches, int nbunches,
227  int ext_bunches, char *ext_fname);
228 int read_tel_photons (IO_BUFFER *iobuf, int max_bunches, int *array,
229  int *tel, double *photons, struct bunch *bunches, int *nbunches);
230 int print_tel_photons (IO_BUFFER *iobuf);
231 
232 int write_shower_longitudinal (IO_BUFFER *iobuf, int event, int type,
233  double *data, int ndim, int np, int nthick, double thickstep);
234 int read_shower_longitudinal (IO_BUFFER *iobuf, int *event,
235  int *type, double *data, int ndim, int *np, int *nthick,
236  double *thickstep, int max_np);
238 
239 int write_camera_layout (IO_BUFFER *iobuf, int itel, int type,
240  int pixels, double *xp, double *yp);
241 int read_camera_layout (IO_BUFFER *iobuf, int max_pixels, int *itel,
242  int *type, int *pixels, double *xp, double *yp);
243 int print_camera_layout (IO_BUFFER *iobuf);
244 
245 int write_photo_electrons (IO_BUFFER *iobuf, int array, int tel,
246  int npe, int pixels, int flags, int *pe_counts, int *tstart,
247  double *t, double *a, int *photon_counts);
248 int read_photo_electrons (IO_BUFFER *iobuf, int max_pixel,
249  int max_pe, int *array, int *tel, int *npe, int *pixels, int *flags,
250  int *pe_counts, int *tstart, double *t, double *a, int *photon_counts);
251 int print_photo_electrons (IO_BUFFER *iobuf);
252 
253 int write_shower_extra_parameters (IO_BUFFER *iobuf, ShowerExtraParam *ep);
254 int read_shower_extra_parameters (IO_BUFFER *iobuf, ShowerExtraParam *ep);
255 int print_shower_extra_parameters (IO_BUFFER *iobuf);
256 int init_shower_extra_parameters(ShowerExtraParam *ep, size_t ni_max, size_t nf_max);
258 ShowerExtraParam *get_shower_extra_parameters(void);
259 
260 void remember_corsika_atm_params(float *hlay, float *aatm, float *batm, float *catm);
261 int get_corsika_atm_params(double *hlay, double *aatm, double *batm, double *catm, double *datm);
262 
263 int write_atmprof (IO_BUFFER *iobuf, AtmProf *atmprof);
264 int read_atmprof (IO_BUFFER *iobuf, AtmProf *atmprof);
265 int print_atmprof (IO_BUFFER *iobuf);
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 
271 #endif
Photons collected in bunches of identical direction, position, time, and wavelength.
Definition: mc_tel.h:75
int write_tel_offset_w(IO_BUFFER *iobuf, int narray, double toff, double *xoff, double *yoff, double *weight)
Write offsets and weights of randomly scattered arrays with respect to shower core.
Definition: io_simtel.c:620
float zem
Height of emission point above sea level (cm)
Definition: mc_tel.h:81
int print_tel_block(IO_BUFFER *iobuf)
Print a CORSIKA header/trailer block of any type (see mc_tel.h)
Definition: io_simtel.c:149
int read_input_lines(IO_BUFFER *iobuf, struct linked_string *list)
Read a block with several character strings (normally containing the text of the CORSIKA inputs file)...
Definition: io_simtel.c:393
Atmospheric profile as stored in atmprof*.dat files - the actually used columns only.
Definition: mc_atmprof.h:49
int read_tel_offset(IO_BUFFER *iobuf, int max_array, int *narray, double *toff, double *xoff, double *yoff)
Read offsets of randomly scattered arrays with respect to shower core.
Definition: io_simtel.c:659
int clear_shower_extra_parameters(ShowerExtraParam *ep)
Similar to init_shower_extra_parameters() but without any attempts to re-allocate or resize buffers.
Definition: io_simtel.c:2422
size_t niparam
Number of extra integer parameters.
Definition: mc_tel.h:152
int read_tel_offset_w(IO_BUFFER *iobuf, int max_array, int *narray, double *toff, double *xoff, double *yoff, double *weight)
Read offsets and weights of randomly scattered arrays with respect to shower core.
Definition: io_simtel.c:680
int read_tel_block(IO_BUFFER *iobuf, int type, real *data, int maxlen)
Read a CORSIKA header/trailer block of given type (see mc_tel.h)
Definition: io_simtel.c:89
int init_shower_extra_parameters(ShowerExtraParam *ep, size_t ni_max, size_t nf_max)
Initialize, resize, clear shower extra parameters.
Definition: io_simtel.c:2354
int write_tel_array_end(IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int array)
End writing data for one array of telescopes/detectors.
Definition: io_simtel.c:917
int print_shower_longitudinal(IO_BUFFER *iobuf)
Print CORSIKA shower longitudinal distributions.
Definition: io_simtel.c:1607
int begin_read_tel_array(IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int *array)
Begin reading data for one array of telescopes/detectors.
Definition: io_simtel.c:850
int write_tel_compact_photons(IO_BUFFER *iobuf, int array, int tel, double photons, struct compact_bunch *cbunches, int nbunches, int ext_bunches, char *ext_fname)
Write all the photon bunches for one telescope to an I/O buffer.
Definition: io_simtel.c:1131
int pixel
The pixel that was hit.
Definition: mc_tel.h:120
static int ntel
Number of telescopes set up.
Definition: iact.c:334
A photo-electron produced by a photon hitting a pixel.
Definition: mc_tel.h:118
int read_camera_layout(IO_BUFFER *iobuf, int max_pixels, int *itel, int *type, int *pixels, double *xp, double *yp)
Read the layout (pixel positions) of a camera used for converting from photons to photo-electrons in ...
Definition: io_simtel.c:1724
int end_read_tel_array(IO_BUFFER *iobuf, IO_ITEM_HEADER *ih)
End reading data for one array of telescopes/detectors.
Definition: io_simtel.c:874
long id
May identify to the user what the parameters should mean.
Definition: mc_tel.h:141
An IO_ITEM_HEADER is to access header info for an I/O block and as a handle to the I/O buffer.
Definition: io_basic.h:71
float cy
Direction cosines of photon direction.
Definition: mc_tel.h:79
int print_tel_pos(IO_BUFFER *iobuf)
Print positions of telescopes/detectors within a system or array.
Definition: io_simtel.c:547
int print_atmprof(IO_BUFFER *iobuf)
Print the atmospheric profile table as used in CORSIKA.
Definition: io_simtel.c:2665
float y
Arrival position relative to telescope (cm)
Definition: mc_tel.h:78
int * iparam
Space for extra integer parameters, at least of size niparam.
Definition: mc_tel.h:153
int write_tel_block(IO_BUFFER *iobuf, int type, int num, real *data, int len)
Write a CORSIKA block as given type number (see mc_tel.h).
Definition: io_simtel.c:56
int is_set
May be reset after writing the parameter block and must thus be set to 1 for each shower for which th...
Definition: mc_tel.h:142
int end_write_tel_array(IO_BUFFER *iobuf, IO_ITEM_HEADER *ih)
End writing data for one array of telescopes/detectors.
Definition: io_simtel.c:828
int read_tel_pos(IO_BUFFER *iobuf, int max_tel, int *ntel, double *x, double *y, double *z, double *r)
Read positions of telescopes/detectors within a system or array.
Definition: io_simtel.c:491
int print_photo_electrons(IO_BUFFER *iobuf)
List the the photoelectrons registered in a Cherenkov telescope camera.
Definition: io_simtel.c:2079
int write_camera_layout(IO_BUFFER *iobuf, int itel, int type, int pixels, double *xp, double *yp)
Write the layout (pixel positions) of a camera used for converting from photons to photo-electrons in...
Definition: io_simtel.c:1688
The compact_bunch struct is equivalent to the bunch struct except that we try to use less memory.
Definition: mc_tel.h:106
Basic header file for eventio data format.
int read_atmprof(IO_BUFFER *iobuf, AtmProf *atmprof)
Read the atmospheric profile table as used in CORSIKA.
Definition: io_simtel.c:2544
int write_tel_offset(IO_BUFFER *iobuf, int narray, double toff, double *xoff, double *yoff)
Write offsets of randomly scattered arrays with respect to shower core.
Definition: io_simtel.c:591
double weight
To be used if the weight of a shower may change during processing, e.g.
Definition: mc_tel.h:145
short ctime
ctime*10 (0.1ns) after subtracting offset
Definition: mc_tel.h:111
int read_tel_photons(IO_BUFFER *iobuf, int max_bunches, int *array, int *tel, double *photons, struct bunch *bunches, int *nbunches)
Read bunches of Cherenkov photons for one telescope/detector.
Definition: io_simtel.c:1231
short y
x,y*10 (mm)
Definition: mc_tel.h:109
int write_tel_photons(IO_BUFFER *iobuf, int array, int tel, double photons, struct bunch *bunches, int nbunches, int ext_bunches, char *ext_fname)
Write all the photon bunches for one telescope to an I/O buffer.
Definition: io_simtel.c:1005
int write_shower_longitudinal(IO_BUFFER *iobuf, int event, int type, double *data, int ndim, int np, int nthick, double thickstep)
Write CORSIKA shower longitudinal distributions.
Definition: io_simtel.c:1503
int print_tel_offset(IO_BUFFER *iobuf)
Print offsets and weights of randomly scattered arrays with respect to shower core.
Definition: io_simtel.c:743
int write_tel_pos(IO_BUFFER *iobuf, int ntel, double *x, double *y, double *z, double *r)
Write positions of telescopes/detectors within a system or array.
Definition: io_simtel.c:454
A data structure shared between io_simtel.c and atmo.c - which is used by both sim_telarray and the C...
int read_shower_longitudinal(IO_BUFFER *iobuf, int *event, int *type, double *data, int ndim, int *np, int *nthick, double *thickstep, int max_np)
Read CORSIKA shower longitudinal distributions.
Definition: io_simtel.c:1546
int lambda
The wavelength of the photon.
Definition: mc_tel.h:121
size_t nfparam
Number of extra floating-point parameters.
Definition: mc_tel.h:155
int print_camera_layout(IO_BUFFER *iobuf)
Print the layout (pixel positions) of a camera used for converting from photons to photo-electrons in...
Definition: io_simtel.c:1763
int begin_write_tel_array(IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int array)
Begin writing data for one array of telescopes/detectors.
Definition: io_simtel.c:808
int write_input_lines(IO_BUFFER *iobuf, struct linked_string *list)
Write a linked list of character strings (normally containing the text of the CORSIKA inputs file) as...
Definition: io_simtel.c:340
int write_atmprof(IO_BUFFER *iobuf, AtmProf *atmprof)
Write the atmospheric profile table as used in CORSIKA with ATMEXT option and set up with 'ATMOSPHERE...
Definition: io_simtel.c:2478
float photons
Number of photons in bunch.
Definition: mc_tel.h:77
int read_tel_array_head(IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int *array)
Begin reading data for one array of telescopes/detectors.
Definition: io_simtel.c:943
double atime
The time [ns] when the photon hit the pixel.
Definition: mc_tel.h:122
int read_tel_array_end(IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int *array)
End reading data for one array of telescopes/detectors.
Definition: io_simtel.c:969
Extra shower parameters of unspecified nature.
Definition: mc_tel.h:139
The linked_string is mainly used to keep CORSIKA input.
Definition: mc_tel.h:128
float ctime
Arrival time (ns)
Definition: mc_tel.h:80
short log_zem
log10(zem)*1000
Definition: mc_tel.h:112
The IO_BUFFER structure contains all data needed the manage the stuff.
Definition: io_basic.h:86
int read_photo_electrons(IO_BUFFER *iobuf, int max_pixel, int max_pe, int *array, int *tel, int *npe, int *pixels, int *flags, int *pe_counts, int *tstart, double *t, double *a, int *photon_counts)
Read the photoelectrons registered in a Cherenkov telescope camera.
Definition: io_simtel.c:1936
int write_tel_array_head(IO_BUFFER *iobuf, IO_ITEM_HEADER *ih, int array)
Begin writing data for one array of telescopes/detectors.
Definition: io_simtel.c:896
short cy
cx,cy*30000
Definition: mc_tel.h:110
float lambda
Wavelength in nanometers or 0.
Definition: mc_tel.h:82
int write_photo_electrons(IO_BUFFER *iobuf, int array, int tel, int npe, int pixels, int flags, int *pe_counts, int *tstart, double *t, double *a, int *photon_counts)
Write the photo-electrons registered in a Cherenkov telescope camera.
Definition: io_simtel.c:1830
short lambda
(nm) or 0
Definition: mc_tel.h:113
short photons
ph*100
Definition: mc_tel.h:108
float * fparam
Space for extra floats, at least of size nfparam.
Definition: mc_tel.h:156