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

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