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

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