| 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.1.1.1 $
|
|---|
| 22 | //= $Author: harald $
|
|---|
| 23 | //= $Date: 1999-11-05 11:59:31 $
|
|---|
| 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 "lagrange.h"
|
|---|
| 64 |
|
|---|
| 65 | #include "MCEventHeader.hxx"
|
|---|
| 66 | #include "MCCphoton.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 |
|
|---|
| 80 | extern "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 |
|
|---|
| 89 | const 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 100
|
|---|
| 99 | #define WIDTH_TIMESLICE 3.3
|
|---|
| 100 |
|
|---|
| 101 | #define SIN60 0.866025403784439
|
|---|
| 102 | #define COS60 0.500000000000000
|
|---|
| 103 |
|
|---|
| 104 | #define RandomNumber drand48()
|
|---|
| 105 |
|
|---|
| 106 | #define PIX_ARRAY_SIDE 40
|
|---|
| 107 | #define PIX_ARRAY_HALF_SIDE 20
|
|---|
| 108 | #define PIXNUM 0
|
|---|
| 109 | #define PIXX 1
|
|---|
| 110 | #define PIXY 2
|
|---|
| 111 |
|
|---|
| 112 | #define iMAXNUMPIX 595 // total maximum possible number of pixels in the camera
|
|---|
| 113 |
|
|---|
| 114 | //@ the trigger threshold up to which the maximum passable threshold is tested
|
|---|
| 115 | #define iMAX_THRESHOLD_PHE 50
|
|---|
| 116 |
|
|---|
| 117 | //@ number of the 1st. pixel of a sector s in a ring r (central pixel: ring=0)
|
|---|
| 118 | #define FIRST_PIXEL(r,s) ( ((r)>0) ? (3*(r)*((r)-1) + (r)*(s) + 1) : 0 )
|
|---|
| 119 |
|
|---|
| 120 | //@ number of the pixels include in a camera of r pixels
|
|---|
| 121 | #define NUMBER_PIXELS(r) ( ((r)>0) ? FIRST_PIXEL((r)+1,0) : 1 )
|
|---|
| 122 |
|
|---|
| 123 | //@ now we define the list CT_ITEM_LIST of possible items in the CT def. file
|
|---|
| 124 | #define CT_ITEM_LIST /* LIST OF ITEMS IN THE CT DEFINITION FILE */ \
|
|---|
| 125 | T(type), /* type of definition file */ \
|
|---|
| 126 | T(focal_distance), /* std(focal distance) */ \
|
|---|
| 127 | T(focal_std), /* focal distance */ \
|
|---|
| 128 | T(point_spread), /* std(point spread) */ \
|
|---|
| 129 | T(point_std), /* point spread */ \
|
|---|
| 130 | T(adjustment_dev), /* std of adjustment deviation */ \
|
|---|
| 131 | T(black_spot), /* radius of the black spot in center of mirror */ \
|
|---|
| 132 | T(n_mirrors), /* number of mirrors */ \
|
|---|
| 133 | T(r_mirror), /* radius of one mirror */ \
|
|---|
| 134 | T(camera_width), /* camera width */ \
|
|---|
| 135 | T(n_pixels), /* total number of pixels in the camera */ \
|
|---|
| 136 | T(n_centralpixels), /* number of central pixels in the camera */ \
|
|---|
| 137 | T(n_gappixels), /* number of gap pixels in the camera */ \
|
|---|
| 138 | T(pixel_width), /* pixel width */ \
|
|---|
| 139 | T(define_mirrors) /* this entry is followed by the def. of pixels */
|
|---|
| 140 |
|
|---|
| 141 | #define T(x) x //@< define T() as the name as it is
|
|---|
| 142 |
|
|---|
| 143 | enum CT_ITEM_TYPE {
|
|---|
| 144 | CT_ITEM_LIST
|
|---|
| 145 | };
|
|---|
| 146 |
|
|---|
| 147 | #undef T
|
|---|
| 148 |
|
|---|
| 149 | #define T(x) #x //@< define T() as the string of x
|
|---|
| 150 |
|
|---|
| 151 | const char *const CT_ITEM_NAMES[] = {
|
|---|
| 152 | CT_ITEM_LIST
|
|---|
| 153 | };
|
|---|
| 154 |
|
|---|
| 155 | #undef T
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 | // TYPE=0 (CT1)
|
|---|
| 159 | // i s rho theta x y z thetan phin xn yn zn
|
|---|
| 160 | //
|
|---|
| 161 | // i : number of the mirror
|
|---|
| 162 | // s : arc length [cm]
|
|---|
| 163 | // rho : polar rho of the position of the center of the mirror [cm]
|
|---|
| 164 | // theta : polar angle of the position of the center of the mirror [cm]
|
|---|
| 165 | // x : x coordinate of the center of the mirror [cm]
|
|---|
| 166 | // y : y coordinate of the center of the mirror [cm]
|
|---|
| 167 | // z : z coordinate of the center of the mirror [cm]
|
|---|
| 168 | // thetan : polar theta angle of the direction where the mirror points to
|
|---|
| 169 | // phin : polar phi angle of the direction where the mirror points to
|
|---|
| 170 | // xn : xn coordinate of the normal vector in the center (normalized)
|
|---|
| 171 | // yn : yn coordinate of the normal vector in the center (normalized)
|
|---|
| 172 | // zn : zn coordinate of the normal vector in the center (normalized)
|
|---|
| 173 | //
|
|---|
| 174 | // TYPE=1 (MAGIC)
|
|---|
| 175 | // i f sx sy x y z thetan phin
|
|---|
| 176 | //
|
|---|
| 177 | // i : number of the mirror
|
|---|
| 178 | // f : focal distance of that mirror
|
|---|
| 179 | // sx : curvilinear coordinate of mirror's center in X[cm]
|
|---|
| 180 | // sy : curvilinear coordinate of mirror's center in X[cm]
|
|---|
| 181 | // x : x coordinate of the center of the mirror [cm]
|
|---|
| 182 | // y : y coordinate of the center of the mirror [cm]
|
|---|
| 183 | // z : z coordinate of the center of the mirror [cm]
|
|---|
| 184 | // thetan : polar theta angle of the direction where the mirror points to
|
|---|
| 185 | // phin : polar phi angle of the direction where the mirror points to
|
|---|
| 186 | // xn : xn coordinate of the normal vector in the center (normalized)
|
|---|
| 187 | // yn : yn coordinate of the normal vector in the center (normalized)
|
|---|
| 188 | // zn : zn coordinate of the normal vector in the center (normalized)
|
|---|
| 189 |
|
|---|
| 190 | #define CT_I 0
|
|---|
| 191 |
|
|---|
| 192 | #define CT_S 1
|
|---|
| 193 | #define CT_RHO 2
|
|---|
| 194 | #define CT_THETA 3
|
|---|
| 195 |
|
|---|
| 196 | #define CT_FOCAL 1
|
|---|
| 197 | #define CT_SX 2
|
|---|
| 198 | #define CT_SY 3
|
|---|
| 199 |
|
|---|
| 200 | #define CT_X 4
|
|---|
| 201 | #define CT_Y 5
|
|---|
| 202 | #define CT_Z 6
|
|---|
| 203 | #define CT_THETAN 7
|
|---|
| 204 | #define CT_PHIN 8
|
|---|
| 205 | #define CT_XN 9
|
|---|
| 206 | #define CT_YN 10
|
|---|
| 207 | #define CT_ZN 11
|
|---|
| 208 |
|
|---|
| 209 | #define CT_NDATA 12
|
|---|
| 210 |
|
|---|
| 211 | //!@}
|
|---|
| 212 |
|
|---|
| 213 | //=------------------------------------------------------------
|
|---|
| 214 | //!@subsection data types
|
|---|
| 215 |
|
|---|
| 216 | struct camera { /* camera parameters for imaging */
|
|---|
| 217 | int inumpixels;
|
|---|
| 218 | int inumcentralpixels;
|
|---|
| 219 | int inumgappixels;
|
|---|
| 220 | int inumbigpixels;
|
|---|
| 221 | double dpixdiameter_cm; /* diameter of the central and gap pixels in centimeters */
|
|---|
| 222 | double dpixsizefactor[iMAXNUMPIX]; /* size of the pixel relative to dpixdiameter_deg */
|
|---|
| 223 | double dxc[iMAXNUMPIX]; /* Pixel coordinates in camera coordinate system (x points from pixel 1 to 2). */
|
|---|
| 224 | double dyc[iMAXNUMPIX]; /* The numbering of the pixels in these arrays starts at 0! */
|
|---|
| 225 | double dxpointcorr_deg; /* correction of the pixel coordinates; to be added to dxc[] to get correct value */
|
|---|
| 226 | double dypointcorr_deg; /* correction of the pixel coordinates; to be added to dxc[] to get correct value */
|
|---|
| 227 | double di[iMAXNUMPIX]; /* i coordinate in JCs bi-axis hexagonal coordinate system */
|
|---|
| 228 | double dj[iMAXNUMPIX]; /* j coordinate in JCs bi-axis hexagonal coordinate system */
|
|---|
| 229 |
|
|---|
| 230 | };
|
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 | //=------------------------------------------------------------
|
|---|
| 234 | //!@subsection Pre-defined file names.
|
|---|
| 235 |
|
|---|
| 236 | //!@{
|
|---|
| 237 |
|
|---|
| 238 | #define QE_FILE "qe.dat"
|
|---|
| 239 |
|
|---|
| 240 | //!@}
|
|---|
| 241 |
|
|---|
| 242 | //=------------------------------------------------------------
|
|---|
| 243 | //!@subsection Prototypes of functions.
|
|---|
| 244 |
|
|---|
| 245 | //!@{
|
|---|
| 246 |
|
|---|
| 247 | //++
|
|---|
| 248 | // prototypes
|
|---|
| 249 | //--
|
|---|
| 250 |
|
|---|
| 251 | #define ONoff(x) ((x==TRUE) ? "[ ON ]" : "[ off]")
|
|---|
| 252 |
|
|---|
| 253 | // Under Linux, the nint function does not exist, so we have to define it.
|
|---|
| 254 | #define nint(x) ((int)floor((x)+0.5))
|
|---|
| 255 |
|
|---|
| 256 | void present(void);
|
|---|
| 257 | void usage(void);
|
|---|
| 258 | void clean(void);
|
|---|
| 259 | void log(const char *funct, char *fmt, ...);
|
|---|
| 260 | void error(const char *funct, char *fmt, ...);
|
|---|
| 261 | int isA( char * s1, const char * flag );
|
|---|
| 262 | void read_ct_file(void);
|
|---|
| 263 | int igen_pixel_coordinates(struct camera *cam);
|
|---|
| 264 | void read_pixels(struct camera *cam);
|
|---|
| 265 | int pixels_are_neig(int pix1, int pix2);
|
|---|
| 266 | int bpoint_is_in_pix(double dx, double dy, int ipixnum, struct camera *pcam);
|
|---|
| 267 | float dist_r_P(float a, float b, float c,
|
|---|
| 268 | float l, float m, float n,
|
|---|
| 269 | float x, float y, float z);
|
|---|
| 270 |
|
|---|
| 271 | //!@}
|
|---|
| 272 |
|
|---|
| 273 | //=------------------------------------------------------------
|
|---|
| 274 | //!@subsection Log of this file.
|
|---|
| 275 |
|
|---|
| 276 | //!@{
|
|---|
| 277 |
|
|---|
| 278 | /*
|
|---|
| 279 | *$Log: not supported by cvs2svn $
|
|---|
| 280 | *Revision 1.3 1999/10/22 15:32:56 petry
|
|---|
| 281 | *tidied-up version, really sent to H.K. and N.M., 22-10-99
|
|---|
| 282 | *
|
|---|
| 283 | *Revision 1.2 1999/10/22 15:01:28 petry
|
|---|
| 284 | *version sent to H.K. and N.M. on Fri Oct 22 1999
|
|---|
| 285 | *
|
|---|
| 286 | *Revision 1.1.1.1 1999/10/21 16:35:10 petry
|
|---|
| 287 | *first synthesised version
|
|---|
| 288 | *
|
|---|
| 289 | * Revision 1.8 1999/03/15 14:59:06 gonzalez
|
|---|
| 290 | * camera-1_1
|
|---|
| 291 | *
|
|---|
| 292 | * Revision 1.7 1999/03/02 09:56:11 gonzalez
|
|---|
| 293 | * *** empty log message ***
|
|---|
| 294 | *
|
|---|
| 295 | * Revision 1.6 1999/01/14 17:32:40 gonzalez
|
|---|
| 296 | * Added to camera the STDIN input option (data_from_input)
|
|---|
| 297 | *
|
|---|
| 298 | */
|
|---|
| 299 |
|
|---|
| 300 | //!@}
|
|---|
| 301 | //=EOF
|
|---|
| 302 |
|
|---|