source: trunk/MagicSoft/Simulation/Detector/Camera/camera.h@ 1684

Last change on this file since 1684 was 1684, checked in by blanch, 22 years ago
*** empty log message ***
File size: 13.2 KB
Line 
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.14 $
22//= $Author: blanch $
23//= $Date: 2002-12-12 17:41:13 $
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.h>
43#include <fstream.h>
44#include <stdlib.h>
45#include <stdio.h>
46#include <string.h>
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 "atm.h"
62#include "moments.h"
63
64#include "MCRunHeader.hxx"
65#include "MCEventHeader.hxx"
66#include "MCEventHeader_2.hxx"
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
85extern "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
96const char REFL_SIGNATURE_A[] = GLUE_postp( REFL_PROGRAM, REFL_VERSION_A );
97const char REFL_SIGNATURE_B[] = GLUE_postp( REFL_PROGRAM, REFL_VERSION_B );
98const 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 SLICES 19
108#define WIDTH_TIMESLICE 3.3
109
110#define NOTIME 9e+10
111
112#define SIN60 0.866025403784439
113#define COS60 0.500000000000000
114
115#define RandomNumber drand48()
116
117#define iMAXNUMPIX 595 // total maximum possible number of pixels in the camera
118
119#define iMAXNUMPHE 50000 // maximum total number of photoelectrons in one event
120
121#define iNUMNSBPRODCALLS 1 // in order to average over the QE simulation, call the
122 // phe production function for the NSB iNUMNSBPRODCALLS times
123
124#define iNUMWAVEBANDS 5 // number of wavebands for the NSB simulation
125
126#define WAVEBANDBOUND1 290. // iNUMWAVEBANDS+1 boundaries for waveband definitions (nm)
127#define WAVEBANDBOUND2 310. // for the NSB generation
128#define WAVEBANDBOUND3 400.
129#define WAVEBANDBOUND4 500.
130#define WAVEBANDBOUND5 600.
131#define WAVEBANDBOUND6 800.
132
133#define EXTWAVEBAND1 3.715 // iNUMWAVEBANDS extinction values in magnitudes per airmass
134#define EXTWAVEBAND2 0.642 // - these values were taken from D.L. King, Isaac Newton Group
135#define EXTWAVEBAND3 0.209 // Tech Note No. 31, they are for a clear night at the ORM,
136#define EXTWAVEBAND4 0.107 // La Palma. The values were averaged in the given wavebands
137#define EXTWAVEBAND5 0.053
138
139#define SIMTIMEOFFSET_NS 5 // determines how many ns before the first and after the last
140 // shower photoelectron, there should be NSB photoelectrons
141
142//@ now we define the list CT_ITEM_LIST of possible items in the CT def. file
143#define CT_ITEM_LIST /* LIST OF ITEMS IN THE CT DEFINITION FILE */ \
144T(type), /* type of definition file */ \
145T(focal_distance), /* std(focal distance) */ \
146T(focal_std), /* focal distance */ \
147T(point_spread), /* std(point spread) */ \
148T(point_std), /* point spread */ \
149T(adjustment_dev), /* std of adjustment deviation */ \
150T(black_spot), /* radius of the black spot in center of mirror */ \
151T(n_mirrors), /* number of mirrors */ \
152T(r_mirror), /* radius of one mirror */ \
153T(camera_width), /* camera width */ \
154T(n_pixels), /* total number of pixels in the camera */ \
155T(n_centralpixels), /* number of central pixels in the camera */ \
156T(n_gappixels), /* number of gap pixels in the camera */ \
157T(pixel_width), /* pixel width */ \
158T(define_mirrors) /* this entry is followed by the def. of pixels */
159
160#define T(x) x //@< define T() as the name as it is
161
162enum CT_ITEM_TYPE {
163 CT_ITEM_LIST
164};
165
166#undef T
167
168#define T(x) #x //@< define T() as the string of x
169
170const char *const CT_ITEM_NAMES[] = {
171 CT_ITEM_LIST
172};
173
174#undef T
175
176
177// TYPE=0 (CT1)
178// i s rho theta x y z thetan phin xn yn zn
179//
180// i : number of the mirror
181// s : arc length [cm]
182// rho : polar rho of the position of the center of the mirror [cm]
183// theta : polar angle of the position of the center of the mirror [cm]
184// x : x coordinate of the center of the mirror [cm]
185// y : y coordinate of the center of the mirror [cm]
186// z : z coordinate of the center of the mirror [cm]
187// thetan : polar theta angle of the direction where the mirror points to
188// phin : polar phi angle of the direction where the mirror points to
189// xn : xn coordinate of the normal vector in the center (normalized)
190// yn : yn coordinate of the normal vector in the center (normalized)
191// zn : zn coordinate of the normal vector in the center (normalized)
192//
193// TYPE=1 (MAGIC)
194// i f sx sy x y z thetan phin
195//
196// i : number of the mirror
197// f : focal distance of that mirror
198// sx : curvilinear coordinate of mirror's center in X[cm]
199// sy : curvilinear coordinate of mirror's center in X[cm]
200// x : x coordinate of the center of the mirror [cm]
201// y : y coordinate of the center of the mirror [cm]
202// z : z coordinate of the center of the mirror [cm]
203// thetan : polar theta angle of the direction where the mirror points to
204// phin : polar phi angle of the direction where the mirror points to
205// xn : xn coordinate of the normal vector in the center (normalized)
206// yn : yn coordinate of the normal vector in the center (normalized)
207// zn : zn coordinate of the normal vector in the center (normalized)
208
209#define CT_I 0
210
211#define CT_S 1
212#define CT_RHO 2
213#define CT_THETA 3
214
215#define CT_FOCAL 1
216#define CT_SX 2
217#define CT_SY 3
218
219#define CT_X 4
220#define CT_Y 5
221#define CT_Z 6
222#define CT_THETAN 7
223#define CT_PHIN 8
224#define CT_XN 9
225#define CT_YN 10
226#define CT_ZN 11
227
228#define CT_NDATA 12
229
230//!@}
231
232//=------------------------------------------------------------
233//!@subsection data types
234
235struct camera { /* camera parameters for imaging */
236 int inumpixels;
237 int inumcentralpixels;
238 int inumgappixels;
239 int inumbigpixels;
240 double dpixdiameter_cm; /* diameter of the central and gap pixels in centimeters */
241 double dpixsizefactor[iMAXNUMPIX]; /* size of the pixel relative to dpixdiameter_deg */
242 double dxc[iMAXNUMPIX]; /* Pixel coordinates in camera coordinate system (x points from pixel 1 to 2). */
243 double dyc[iMAXNUMPIX]; /* The numbering of the pixels in these arrays starts at 0! */
244 double dxpointcorr_deg; /* correction of the pixel coordinates; to be added to dxc[] to get correct value */
245 double dypointcorr_deg; /* correction of the pixel coordinates; to be added to dxc[] to get correct value */
246
247};
248
249//=------------------------------------------------------------
250//!@subsection Pre-defined file names.
251
252//!@{
253
254#define QE_FILE "../Data/qe.dat"
255#define WC_FILE "../Data/lightguides.dat"
256
257//!@}
258
259//=------------------------------------------------------------
260//!@subsection Prototypes of functions.
261
262//!@{
263
264//++
265// prototypes
266//--
267
268#define ONoff(x) ((x==TRUE) ? "[ ON ]" : "[ off]")
269
270// Under Linux, the nint function does not exist, so we have to define it.
271#define nint(x) ((int)floor((x)+0.5))
272
273void present(void);
274void usage(void);
275void clean(void);
276void log(const char *funct, char *fmt, ...);
277void error(const char *funct, char *fmt, ...);
278int isA( char * s1, const char * flag );
279void read_ct_file(void);
280int igen_pixel_coordinates(struct camera *cam);
281void read_pixels(struct camera *cam);
282void read_QE(void);
283void read_WC(void);
284void read_ascii( FILE *sp, // the input file
285 MMcConfigRunHeader *config
286 );
287int pixels_are_neig(int pix1, int pix2);
288int bpoint_is_in_pix(double dx, double dy, int ipixnum,
289 MGeomCamMagic *pcamgeom);
290float dist_r_P(float a, float b, float c,
291 float l, float m, float n,
292 float x, float y, float z);
293int check_reflector_file(FILE *infile);
294float lin_interpol(float x1, float y1, float x2, float y2, float x);
295int produce_phes( FILE *sp, // the input file
296 MGeomCamMagic *camgeom, // the camera layout
297 float minwl_nm, // the minimum accepted wavelength
298 float maxwl_nm, // the maximum accepted wavelength
299 class MTrigger *trigger,
300 class MFadc *fadc,
301 int *itotnphe, // total number of produced photoelectrons
302 float *nphe, // number of photoelectrons in each pixel
303 int *incph, // total number of cph read
304 float *tmin_ns, // minimum arrival time of all phes
305 float *tmax_ns, // maximum arrival time of all phes
306 int star // 0 if the photon provides the starfield -1 doesn't provide of the starfield
307 );
308
309int produce_nsbrates( char *inname,
310 MGeomCamMagic *camgeom,
311 float nsbrate[][iNUMWAVEBANDS]
312 );
313
314int produce_nsb_phes( float *atmin_ns,
315 float *atmax_ns,
316 float theta_rad,
317 struct camera *cam,
318 float nsbr_phepns[iMAXNUMPIX][iNUMWAVEBANDS],
319 float dnsb_phepns[iMAXNUMPIX],
320 float extinction[iNUMWAVEBANDS],
321 float fnpx[iMAXNUMPIX],
322 class MTrigger *trigger,
323 class MFadc *fadc,
324 int *inphe,
325 float base_mv[iMAXNUMPIX]);
326
327//!@}
328
329//=------------------------------------------------------------
330//!@subsection Log of this file.
331
332//!@{
333
334/*
335 *$Log: not supported by cvs2svn $
336 *Revision 1.13 2002/12/10 17:20:32 blanch
337 **** empty log message ***
338 *
339 *Revision 1.12 2002/10/29 17:16:28 blanch
340 *Header file for camera.cxx version 1.45
341 *
342 *Revision 1.11 2002/10/18 16:53:30 blanch
343 *Modification to read several reflector version files.
344 *
345 *Revision 1.10 2002/09/09 16:01:12 blanch
346 *Header file of camera.cxx 1.42.
347 *
348 *Revision 1.9 2002/09/04 09:59:07 blanch
349 *Modifications to use MGeomCam from MARS.
350 *
351 *Revision 1.8 2002/07/16 16:20:23 blanch
352 *Modifications done for the camera.cxx version, where a first implementation
353 *of the Star Field Rotation has been introduced.
354 *
355 *Revision 1.7 2002/03/15 16:06:53 blanch
356 *Library time.h has been added.
357 *
358 *Revision 1.6 2001/04/09 14:39:47 magicsol
359 *Flag that indicates version of reflector format to read: REFL_VERSION has
360 *changed from 0.3 to 0.4.
361 *
362 *Revision 1.5 2000/05/11 13:58:42 blanch
363 *This version of camera.h owns to the version 1.8 of camera.cxx.
364 *
365 *Revision 1.4 2000/02/18 17:42:39 petry
366 *This version includes drastic changes and belongs to camera.cxx 1.5.
367 *It is not yet finished and not immediately useful because the
368 *trigger simulation is not yet re-implemented. I had to take it
369 *out together with some other stuff in order to tidy the whole
370 *program up. This is not meant as an insult to anyone. I needed
371 *to do this in order to be able to work on it.
372 *
373 *This version has been put in the repository in order to be
374 *able to share the further development with others.
375 *
376 *If you need something working, wait or take an earlier one.
377 *See file README.
378 *
379 *Revision 1.3 1999/11/11 20:29:29 harald
380 *Small changes to run the new version on a linux machine.
381 *
382 *Revision 1.2 1999/11/10 07:42:41 harald
383 *Small change to read the right data files in.
384 *
385 *Revision 1.1.1.1 1999/11/05 11:59:31 harald
386 *This the starting point for CVS controlled further developments of the
387 *camera program. The program was originally written by Jose Carlos.
388 *But here you can find a "rootified" version to the program. This means
389 *that there is no hbook stuff in it now. Also the output of the
390 *program changed to the MagicRawDataFormat.
391 *
392 *The "rootification" was done by Dirk Petry and Harald Kornmayer.
393 *
394 *Revision 1.3 1999/10/22 15:32:56 petry
395 *tidied-up version, really sent to H.K. and N.M., 22-10-99
396 *
397 *Revision 1.2 1999/10/22 15:01:28 petry
398 *version sent to H.K. and N.M. on Fri Oct 22 1999
399 *
400 *Revision 1.1.1.1 1999/10/21 16:35:10 petry
401 *first synthesised version
402 *
403 * Revision 1.8 1999/03/15 14:59:06 gonzalez
404 * camera-1_1
405 *
406 * Revision 1.7 1999/03/02 09:56:11 gonzalez
407 * *** empty log message ***
408 *
409 * Revision 1.6 1999/01/14 17:32:40 gonzalez
410 * Added to camera the STDIN input option (data_from_input)
411 *
412 */
413
414//!@}
415//=EOF
416
Note: See TracBrowser for help on using the repository browser.