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

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