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