1 | //=//////////////////////////////////////////////////////////////////////
|
---|
2 | //=
|
---|
3 | //= camera
|
---|
4 | //=
|
---|
5 | //= @file camera.h
|
---|
6 | //= @desc Header file
|
---|
7 | //= @author J C Gonzalez
|
---|
8 | //= @email gonzalez@mppmu.mpg.de
|
---|
9 | //= @date Thu May 7 16:24:22 1998
|
---|
10 | //=
|
---|
11 | //=----------------------------------------------------------------------
|
---|
12 | //=
|
---|
13 | //= Created: Thu May 7 16:24:22 1998
|
---|
14 | //= Author: Jose Carlos Gonzalez
|
---|
15 | //= Purpose: Program for reflector simulation
|
---|
16 | //= Notes: See files README for details
|
---|
17 | //=
|
---|
18 | //=----------------------------------------------------------------------
|
---|
19 | //=
|
---|
20 | //= $RCSfile: camera.h,v $
|
---|
21 | //= $Revision: 1.22 $
|
---|
22 | //= $Author: moralejo $
|
---|
23 | //= $Date: 2004-09-17 14:48:21 $
|
---|
24 | //=
|
---|
25 | //=//////////////////////////////////////////////////////////////////////
|
---|
26 |
|
---|
27 | // @T \newpage
|
---|
28 |
|
---|
29 | //!@section Source code of |camera.h|.
|
---|
30 |
|
---|
31 | /*!@"
|
---|
32 |
|
---|
33 | This section shows the include file |camera.h|
|
---|
34 |
|
---|
35 | @"*/
|
---|
36 |
|
---|
37 | //=-----------------------------------------------------------
|
---|
38 | //!@subsection Include files.
|
---|
39 |
|
---|
40 | //!@{
|
---|
41 |
|
---|
42 | #include <iostream>
|
---|
43 | #include <fstream>
|
---|
44 | #include <stdlib.h>
|
---|
45 | #include <stdio.h>
|
---|
46 | #include <string>
|
---|
47 | #include <stdarg.h>
|
---|
48 | #include <math.h>
|
---|
49 | #include <sys/types.h>
|
---|
50 | #include <dirent.h>
|
---|
51 | #include <unistd.h>
|
---|
52 | #include <libgen.h>
|
---|
53 | #include <time.h>
|
---|
54 |
|
---|
55 | #include "camera-v.h"
|
---|
56 |
|
---|
57 | #include "jcmacros.h"
|
---|
58 | #include "jcdebug.h"
|
---|
59 |
|
---|
60 | #include "creadparam.h"
|
---|
61 | #include "moments.h"
|
---|
62 |
|
---|
63 | #include "MCRunHeader.hxx"
|
---|
64 | #include "MCEventHeader.hxx"
|
---|
65 | #include "MCEventHeader_2.hxx"
|
---|
66 | #include "MMcConfigRunHeader.h"
|
---|
67 | #include "MCCphoton.hxx"
|
---|
68 | #include "MTrigger.hxx"
|
---|
69 |
|
---|
70 | #include "MParContainer.h"
|
---|
71 | #include "MArray.h"
|
---|
72 |
|
---|
73 | // command line options available
|
---|
74 |
|
---|
75 | #define COMMAND_LINE_OPTIONS "f:h"
|
---|
76 |
|
---|
77 | /*@'
|
---|
78 |
|
---|
79 | This is C++, but RANLIB routines are written in pure ANSI C.
|
---|
80 | In order to read easily these routines, we must include
|
---|
81 | the following directive
|
---|
82 |
|
---|
83 | */
|
---|
84 |
|
---|
85 | extern "C" {
|
---|
86 | #include "ranlib.h"
|
---|
87 | }
|
---|
88 |
|
---|
89 | // version of the reflector program that can read
|
---|
90 |
|
---|
91 | #define REFL_PROGRAM reflector
|
---|
92 | #define REFL_VERSION_A 0.4
|
---|
93 | #define REFL_VERSION_B 0.5
|
---|
94 | #define REFL_VERSION_C 0.6
|
---|
95 |
|
---|
96 | const char REFL_SIGNATURE_A[] = GLUE_postp( REFL_PROGRAM, REFL_VERSION_A );
|
---|
97 | const char REFL_SIGNATURE_B[] = GLUE_postp( REFL_PROGRAM, REFL_VERSION_B );
|
---|
98 | const char REFL_SIGNATURE_C[] = GLUE_postp( REFL_PROGRAM, REFL_VERSION_C );
|
---|
99 |
|
---|
100 | //!@}
|
---|
101 |
|
---|
102 | //=------------------------------------------------------------
|
---|
103 | //!@subsection Macro-definitions, and constants.
|
---|
104 |
|
---|
105 | //!@{
|
---|
106 |
|
---|
107 | #define EMI_NSB 0.78
|
---|
108 | #define EMICOAT_NSB 1.0
|
---|
109 | #define HPD_NSB 2.70
|
---|
110 |
|
---|
111 | #define SLICES 19
|
---|
112 | #define WIDTH_TIMESLICE 3.3
|
---|
113 |
|
---|
114 | #define NOTIME 9e+10
|
---|
115 |
|
---|
116 | #define SIN60 0.866025403784439
|
---|
117 | #define COS60 0.500000000000000
|
---|
118 |
|
---|
119 | #define RandomNumber drand48()
|
---|
120 |
|
---|
121 | #define iMAXNUMPIX 3500 // total maximum possible number of pixels in the camera
|
---|
122 |
|
---|
123 | #define iMAXNUMPHE 50000 // maximum total number of photoelectrons in one event
|
---|
124 |
|
---|
125 | #define iNUMNSBPRODCALLS 1 // in order to average over the QE simulation, call the
|
---|
126 | // phe production function for the NSB iNUMNSBPRODCALLS times
|
---|
127 |
|
---|
128 | #define iNUMWAVEBANDS 5 // number of wavebands for the NSB simulation
|
---|
129 |
|
---|
130 | #define WAVEBANDBOUND1 290. // iNUMWAVEBANDS+1 boundaries for waveband definitions (nm)
|
---|
131 | #define WAVEBANDBOUND2 310. // for the NSB generation
|
---|
132 | #define WAVEBANDBOUND3 400.
|
---|
133 | #define WAVEBANDBOUND4 500.
|
---|
134 | #define WAVEBANDBOUND5 600.
|
---|
135 | #define WAVEBANDBOUND6 800.
|
---|
136 |
|
---|
137 | #define EXTWAVEBAND1 3.715 // iNUMWAVEBANDS extinction values in magnitudes per airmass
|
---|
138 | #define EXTWAVEBAND2 0.642 // - these values were taken from D.L. King, Isaac Newton Group
|
---|
139 | #define EXTWAVEBAND3 0.209 // Tech Note No. 31, they are for a clear night at the ORM,
|
---|
140 | #define EXTWAVEBAND4 0.107 // La Palma. The values were averaged in the given wavebands
|
---|
141 | #define EXTWAVEBAND5 0.053
|
---|
142 |
|
---|
143 | #define SIMTIMEOFFSET_NS 5 // determines how many ns before the first and after the last
|
---|
144 | // shower photoelectron, there should be NSB photoelectrons
|
---|
145 |
|
---|
146 | #define MAX_NUMBER_OF_CTS 20 // Maximum number of CTs allowed for running
|
---|
147 | // on multitelescope systems. If this maximum
|
---|
148 | // is set too large, program may crash!
|
---|
149 |
|
---|
150 |
|
---|
151 | //@ now we define the list CT_ITEM_LIST of possible items in the CT def. file
|
---|
152 | #define CT_ITEM_LIST /* LIST OF ITEMS IN THE CT DEFINITION FILE */ \
|
---|
153 | T(type), /* type of definition file */ \
|
---|
154 | T(focal_distance), /* std(focal distance) */ \
|
---|
155 | T(focal_std), /* focal distance */ \
|
---|
156 | T(point_spread), /* std(point spread) */ \
|
---|
157 | T(point_std), /* point spread */ \
|
---|
158 | T(adjustment_dev), /* std of adjustment deviation */ \
|
---|
159 | T(black_spot), /* radius of the black spot in center of mirror */ \
|
---|
160 | T(n_mirrors), /* number of mirrors */ \
|
---|
161 | T(r_mirror), /* radius of one mirror */ \
|
---|
162 | T(camera_width), /* camera width */ \
|
---|
163 | T(n_pixels), /* total number of pixels in the camera */ \
|
---|
164 | T(n_centralpixels), /* number of central pixels in the camera */ \
|
---|
165 | T(n_gappixels), /* number of gap pixels in the camera */ \
|
---|
166 | T(pixel_width), /* pixel width */ \
|
---|
167 | T(define_mirrors) /* this entry is followed by the def. of pixels */
|
---|
168 |
|
---|
169 | #define T(x) x //@< define T() as the name as it is
|
---|
170 |
|
---|
171 | enum CT_ITEM_TYPE {
|
---|
172 | CT_ITEM_LIST
|
---|
173 | };
|
---|
174 |
|
---|
175 | #undef T
|
---|
176 |
|
---|
177 | #define T(x) #x //@< define T() as the string of x
|
---|
178 |
|
---|
179 | const char *const CT_ITEM_NAMES[] = {
|
---|
180 | CT_ITEM_LIST
|
---|
181 | };
|
---|
182 |
|
---|
183 | #undef T
|
---|
184 |
|
---|
185 |
|
---|
186 | // TYPE=0 (CT1)
|
---|
187 | // i s rho theta x y z thetan phin xn yn zn
|
---|
188 | //
|
---|
189 | // i : number of the mirror
|
---|
190 | // s : arc length [cm]
|
---|
191 | // rho : polar rho of the position of the center of the mirror [cm]
|
---|
192 | // theta : polar angle of the position of the center of the mirror [cm]
|
---|
193 | // x : x coordinate of the center of the mirror [cm]
|
---|
194 | // y : y coordinate of the center of the mirror [cm]
|
---|
195 | // z : z coordinate of the center of the mirror [cm]
|
---|
196 | // thetan : polar theta angle of the direction where the mirror points to
|
---|
197 | // phin : polar phi angle of the direction where the mirror points to
|
---|
198 | // xn : xn coordinate of the normal vector in the center (normalized)
|
---|
199 | // yn : yn coordinate of the normal vector in the center (normalized)
|
---|
200 | // zn : zn coordinate of the normal vector in the center (normalized)
|
---|
201 | //
|
---|
202 | // TYPE=1 (MAGIC)
|
---|
203 | // i f sx sy x y z thetan phin
|
---|
204 | //
|
---|
205 | // i : number of the mirror
|
---|
206 | // f : focal distance of that mirror
|
---|
207 | // sx : curvilinear coordinate of mirror's center in X[cm]
|
---|
208 | // sy : curvilinear coordinate of mirror's center in X[cm]
|
---|
209 | // x : x coordinate of the center of the mirror [cm]
|
---|
210 | // y : y coordinate of the center of the mirror [cm]
|
---|
211 | // z : z coordinate of the center of the mirror [cm]
|
---|
212 | // thetan : polar theta angle of the direction where the mirror points to
|
---|
213 | // phin : polar phi angle of the direction where the mirror points to
|
---|
214 | // xn : xn coordinate of the normal vector in the center (normalized)
|
---|
215 | // yn : yn coordinate of the normal vector in the center (normalized)
|
---|
216 | // zn : zn coordinate of the normal vector in the center (normalized)
|
---|
217 |
|
---|
218 | #define CT_I 0
|
---|
219 |
|
---|
220 | #define CT_S 1
|
---|
221 | #define CT_RHO 2
|
---|
222 | #define CT_THETA 3
|
---|
223 |
|
---|
224 | #define CT_FOCAL 1
|
---|
225 | #define CT_SX 2
|
---|
226 | #define CT_SY 3
|
---|
227 |
|
---|
228 | #define CT_X 4
|
---|
229 | #define CT_Y 5
|
---|
230 | #define CT_Z 6
|
---|
231 | #define CT_THETAN 7
|
---|
232 | #define CT_PHIN 8
|
---|
233 | #define CT_XN 9
|
---|
234 | #define CT_YN 10
|
---|
235 | #define CT_ZN 11
|
---|
236 |
|
---|
237 | #define CT_NDATA 12
|
---|
238 |
|
---|
239 | //!@}
|
---|
240 |
|
---|
241 | //=------------------------------------------------------------
|
---|
242 | //!@subsection data types
|
---|
243 |
|
---|
244 | struct camera { /* camera parameters for imaging */
|
---|
245 | int inumpixels;
|
---|
246 | int inumcentralpixels;
|
---|
247 | int inumgappixels;
|
---|
248 | int inumbigpixels;
|
---|
249 | double dpixdiameter_cm; /* diameter of the central and gap pixels in centimeters */
|
---|
250 | double dpixsizefactor[iMAXNUMPIX]; /* size of the pixel relative to dpixdiameter_deg */
|
---|
251 | double dxc[iMAXNUMPIX]; /* Pixel coordinates in camera coordinate system (x points from pixel 1 to 2). */
|
---|
252 | double dyc[iMAXNUMPIX]; /* The numbering of the pixels in these arrays starts at 0! */
|
---|
253 | double dxpointcorr_deg; /* correction of the pixel coordinates; to be added to dxc[] to get correct value */
|
---|
254 | double dypointcorr_deg; /* correction of the pixel coordinates; to be added to dxc[] to get correct value */
|
---|
255 |
|
---|
256 | };
|
---|
257 |
|
---|
258 | //=------------------------------------------------------------
|
---|
259 | //!@subsection Pre-defined file names.
|
---|
260 |
|
---|
261 | //!@{
|
---|
262 |
|
---|
263 | #define QE_FILE "../Data/qe.dat"
|
---|
264 | #define WC_FILE "../Data/LightCollection.dat"
|
---|
265 |
|
---|
266 | //!@}
|
---|
267 |
|
---|
268 | //=------------------------------------------------------------
|
---|
269 | //!@subsection Prototypes of functions.
|
---|
270 |
|
---|
271 | //!@{
|
---|
272 |
|
---|
273 | //++
|
---|
274 | // prototypes
|
---|
275 | //--
|
---|
276 |
|
---|
277 | #define ONoff(x) ((x==TRUE) ? "[ ON ]" : "[ off]")
|
---|
278 |
|
---|
279 | // Under Linux, the nint function does not exist, so we have to define it.
|
---|
280 | #define nint(x) ((int)floor((x)+0.5))
|
---|
281 |
|
---|
282 | void present(void);
|
---|
283 | void usage(void);
|
---|
284 | void clean(void);
|
---|
285 | void log(const char *funct, char *fmt, ...);
|
---|
286 | void error(const char *funct, char *fmt, ...);
|
---|
287 | int isA( char * s1, const char * flag );
|
---|
288 | void read_ct_file(void);
|
---|
289 | int igen_pixel_coordinates(struct camera *cam);
|
---|
290 | void read_pixels(struct camera *cam);
|
---|
291 | void read_QE(char fname[256], int ict);
|
---|
292 | void read_WC(void);
|
---|
293 | void read_ascii( FILE *sp, // the input file
|
---|
294 | MMcConfigRunHeader *config
|
---|
295 | );
|
---|
296 | int pixels_are_neig(int pix1, int pix2);
|
---|
297 | int bpoint_is_in_pix(double dx, double dy, int ipixnum,
|
---|
298 | MGeomCam *pcamgeom);
|
---|
299 | float dist_r_P(float a, float b, float c,
|
---|
300 | float l, float m, float n,
|
---|
301 | float x, float y, float z);
|
---|
302 | int check_reflector_file(FILE *infile);
|
---|
303 | float lin_interpol(float x1, float y1, float x2, float y2, float x);
|
---|
304 | int produce_phes( FILE *sp, // the input file
|
---|
305 | class MGeomCam *camgeom, // the camera layout
|
---|
306 | float minwl_nm, // the minimum accepted wavelength
|
---|
307 | float maxwl_nm, // the maximum accepted wavelength
|
---|
308 | class MTrigger *trigger,
|
---|
309 | class MFadc *fadc,
|
---|
310 | int *itotnphe, // total number of produced photoelectrons
|
---|
311 | float *nphe, // number of photoelectrons in each pixel
|
---|
312 | int *incph, // total number of cph read
|
---|
313 | float *tmin_ns, // minimum arrival time of all phes
|
---|
314 | float *tmax_ns, // maximum arrival time of all phes
|
---|
315 | int telescope, // Telescope that is being analised to get the right QE.
|
---|
316 | float mirror_fraction // Fraction of working mirror
|
---|
317 | );
|
---|
318 |
|
---|
319 | int produce_nsbrates( char *inname,
|
---|
320 | MGeomCam *camgeom,
|
---|
321 | float **nsbrate,
|
---|
322 | int ict,
|
---|
323 | float mirror_fraction
|
---|
324 | );
|
---|
325 |
|
---|
326 | int produce_nsb_phes( float *atmin_ns,
|
---|
327 | float *atmax_ns,
|
---|
328 | float theta_rad,
|
---|
329 | struct camera *cam,
|
---|
330 | float **nsbr_phepns,
|
---|
331 | float dnsb_phepns[iMAXNUMPIX],
|
---|
332 | float extinction[iNUMWAVEBANDS],
|
---|
333 | float fnpx[iMAXNUMPIX],
|
---|
334 | class MTrigger *trigger,
|
---|
335 | class MFadc *fadc,
|
---|
336 | int *inphe,
|
---|
337 | float base_mv[iMAXNUMPIX]);
|
---|
338 |
|
---|
339 | int size_rotated ( float *rotated,
|
---|
340 | float nsb[iMAXNUMPIX],
|
---|
341 | float ro);
|
---|
342 |
|
---|
343 | //!@}
|
---|
344 |
|
---|
345 | //=------------------------------------------------------------
|
---|
346 | //!@subsection Log of this file.
|
---|
347 |
|
---|
348 | //!@{
|
---|
349 |
|
---|
350 | /*
|
---|
351 | *$Log: not supported by cvs2svn $
|
---|
352 | *Revision 1.21 2004/09/16 15:24:53 moralejo
|
---|
353 | *Updated on CVS after long time...
|
---|
354 | *
|
---|
355 | *
|
---|
356 | *Revision 1.19 2003/10/17 19:39:30 blanch
|
---|
357 | *Factor used for the NSB scaling for several qe files is defined.
|
---|
358 | *
|
---|
359 | *Revision 1.18 2003/09/15 10:06:47 blanch
|
---|
360 | *Header file for camera 1.58
|
---|
361 | *Number of CT is passed in some subroutines.
|
---|
362 | *MGeomCam is passed instead of MGeomCam magic to allow diferent camera
|
---|
363 | *geometries.
|
---|
364 | *
|
---|
365 | *Revision 1.17 2003/07/17 18:03:03 blanch
|
---|
366 | *Header file for camera 1.57
|
---|
367 | *
|
---|
368 | *Revision 1.15 2003/01/07 16:34:09 blanch
|
---|
369 | *Header file for camera.cxx version 1.50.
|
---|
370 | *
|
---|
371 | *Revision 1.14 2002/12/12 17:41:13 blanch
|
---|
372 | **** empty log message ***
|
---|
373 | *
|
---|
374 | *Revision 1.13 2002/12/10 17:20:32 blanch
|
---|
375 | **** empty log message ***
|
---|
376 | *
|
---|
377 | *Revision 1.12 2002/10/29 17:16:28 blanch
|
---|
378 | *Header file for camera.cxx version 1.45
|
---|
379 | *
|
---|
380 | *Revision 1.11 2002/10/18 16:53:30 blanch
|
---|
381 | *Modification to read several reflector version files.
|
---|
382 | *
|
---|
383 | *Revision 1.10 2002/09/09 16:01:12 blanch
|
---|
384 | *Header file of camera.cxx 1.42.
|
---|
385 | *
|
---|
386 | *Revision 1.9 2002/09/04 09:59:07 blanch
|
---|
387 | *Modifications to use MGeomCam from MARS.
|
---|
388 | *
|
---|
389 | *Revision 1.8 2002/07/16 16:20:23 blanch
|
---|
390 | *Modifications done for the camera.cxx version, where a first implementation
|
---|
391 | *of the Star Field Rotation has been introduced.
|
---|
392 | *
|
---|
393 | *Revision 1.7 2002/03/15 16:06:53 blanch
|
---|
394 | *Library time.h has been added.
|
---|
395 | *
|
---|
396 | *Revision 1.6 2001/04/09 14:39:47 magicsol
|
---|
397 | *Flag that indicates version of reflector format to read: REFL_VERSION has
|
---|
398 | *changed from 0.3 to 0.4.
|
---|
399 | *
|
---|
400 | *Revision 1.5 2000/05/11 13:58:42 blanch
|
---|
401 | *This version of camera.h owns to the version 1.8 of camera.cxx.
|
---|
402 | *
|
---|
403 | *Revision 1.4 2000/02/18 17:42:39 petry
|
---|
404 | *This version includes drastic changes and belongs to camera.cxx 1.5.
|
---|
405 | *It is not yet finished and not immediately useful because the
|
---|
406 | *trigger simulation is not yet re-implemented. I had to take it
|
---|
407 | *out together with some other stuff in order to tidy the whole
|
---|
408 | *program up. This is not meant as an insult to anyone. I needed
|
---|
409 | *to do this in order to be able to work on it.
|
---|
410 | *
|
---|
411 | *This version has been put in the repository in order to be
|
---|
412 | *able to share the further development with others.
|
---|
413 | *
|
---|
414 | *If you need something working, wait or take an earlier one.
|
---|
415 | *See file README.
|
---|
416 | *
|
---|
417 | *Revision 1.3 1999/11/11 20:29:29 harald
|
---|
418 | *Small changes to run the new version on a linux machine.
|
---|
419 | *
|
---|
420 | *Revision 1.2 1999/11/10 07:42:41 harald
|
---|
421 | *Small change to read the right data files in.
|
---|
422 | *
|
---|
423 | *Revision 1.1.1.1 1999/11/05 11:59:31 harald
|
---|
424 | *This the starting point for CVS controlled further developments of the
|
---|
425 | *camera program. The program was originally written by Jose Carlos.
|
---|
426 | *But here you can find a "rootified" version to the program. This means
|
---|
427 | *that there is no hbook stuff in it now. Also the output of the
|
---|
428 | *program changed to the MagicRawDataFormat.
|
---|
429 | *
|
---|
430 | *The "rootification" was done by Dirk Petry and Harald Kornmayer.
|
---|
431 | *
|
---|
432 | *Revision 1.3 1999/10/22 15:32:56 petry
|
---|
433 | *tidied-up version, really sent to H.K. and N.M., 22-10-99
|
---|
434 | *
|
---|
435 | *Revision 1.2 1999/10/22 15:01:28 petry
|
---|
436 | *version sent to H.K. and N.M. on Fri Oct 22 1999
|
---|
437 | *
|
---|
438 | *Revision 1.1.1.1 1999/10/21 16:35:10 petry
|
---|
439 | *first synthesised version
|
---|
440 | *
|
---|
441 | * Revision 1.8 1999/03/15 14:59:06 gonzalez
|
---|
442 | * camera-1_1
|
---|
443 | *
|
---|
444 | * Revision 1.7 1999/03/02 09:56:11 gonzalez
|
---|
445 | * *** empty log message ***
|
---|
446 | *
|
---|
447 | * Revision 1.6 1999/01/14 17:32:40 gonzalez
|
---|
448 | * Added to camera the STDIN input option (data_from_input)
|
---|
449 | *
|
---|
450 | */
|
---|
451 |
|
---|
452 | //!@}
|
---|
453 | //=EOF
|
---|