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

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