| 1 | //=//////////////////////////////////////////////////////////////////////
|
|---|
| 2 | //=
|
|---|
| 3 | //= moments
|
|---|
| 4 | //=
|
|---|
| 5 | //= @file moments.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: moments.h,v $
|
|---|
| 21 | //= $Revision: 1.2 $
|
|---|
| 22 | //= $Author: moralejo $
|
|---|
| 23 | //= $Date: 2004-09-17 14:48:21 $
|
|---|
| 24 | //=
|
|---|
| 25 | //=//////////////////////////////////////////////////////////////////////
|
|---|
| 26 |
|
|---|
| 27 | // @T \newpage
|
|---|
| 28 |
|
|---|
| 29 | //!@section Source code of |moments.h|.
|
|---|
| 30 |
|
|---|
| 31 | /*!@"
|
|---|
| 32 |
|
|---|
| 33 | In this section you can find the source code for the file
|
|---|
| 34 | |moments.h|. This file is mainly needed by |moments.cxx|.
|
|---|
| 35 |
|
|---|
| 36 | @"*/
|
|---|
| 37 |
|
|---|
| 38 | //!@{
|
|---|
| 39 |
|
|---|
| 40 | #ifndef _moments_
|
|---|
| 41 | #define _moments_
|
|---|
| 42 |
|
|---|
| 43 | #ifndef _this_
|
|---|
| 44 | #define _this_ moments
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | //!@}
|
|---|
| 48 |
|
|---|
| 49 | //!@subsection Include files.
|
|---|
| 50 |
|
|---|
| 51 | //!@{
|
|---|
| 52 |
|
|---|
| 53 | #include <iostream>
|
|---|
| 54 | #include <fstream>
|
|---|
| 55 | #include <string>
|
|---|
| 56 |
|
|---|
| 57 | #include <stdlib.h>
|
|---|
| 58 | #include <math.h>
|
|---|
| 59 | #include <float.h>
|
|---|
| 60 | #include <stdio.h>
|
|---|
| 61 |
|
|---|
| 62 | #include "jcmacros.h"
|
|---|
| 63 | #include "jcdebug.h"
|
|---|
| 64 |
|
|---|
| 65 | #include "camera-v.h"
|
|---|
| 66 |
|
|---|
| 67 | //!@}
|
|---|
| 68 |
|
|---|
| 69 | //!@subsection Macro-definitions, and constants.
|
|---|
| 70 |
|
|---|
| 71 | //!@{
|
|---|
| 72 |
|
|---|
| 73 | typedef struct {
|
|---|
| 74 |
|
|---|
| 75 | // moments
|
|---|
| 76 | float m1x, m1y; // first moments (mean)
|
|---|
| 77 | float m2xx, m2xy, m2yy; // second moments (around origin)
|
|---|
| 78 | float m2cxx, m2cxy, m2cyy; // second moments (around mean)
|
|---|
| 79 | float m3xxx, m3xxy, m3xyy, m3yyy; // third moments (around origin)
|
|---|
| 80 | float m3cxxx, m3cxxy, m3cxyy, m3cyyy; // third moments (around mean)
|
|---|
| 81 |
|
|---|
| 82 | // charges
|
|---|
| 83 | float charge; // total charge in the image
|
|---|
| 84 | float xmax, ymax; // position of the maximum
|
|---|
| 85 | float smax; // charge of the block of maximum
|
|---|
| 86 | float maxs[10]; // charges of the first 10 max.
|
|---|
| 87 | int nmaxs[10]; // number of pixels of 10 max.
|
|---|
| 88 |
|
|---|
| 89 | // parameters of the image
|
|---|
| 90 | float length, width, dist, xdist, azw, miss, alpha, conc[9];
|
|---|
| 91 | float phi, asymx, asymy;
|
|---|
| 92 |
|
|---|
| 93 | } Moments_Info;
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | typedef struct {
|
|---|
| 97 | float *fi;
|
|---|
| 98 | int *isl, *islands;
|
|---|
| 99 | float *vislands;
|
|---|
| 100 | int numisl;
|
|---|
| 101 | } Islands_Info;
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 | typedef struct {
|
|---|
| 105 | float length1, length2;
|
|---|
| 106 | float width1, width2;
|
|---|
| 107 | } LenWid_Info;
|
|---|
| 108 |
|
|---|
| 109 | //!@}
|
|---|
| 110 |
|
|---|
| 111 | //!@subsection Prototypes of functions.
|
|---|
| 112 |
|
|---|
| 113 | //!@{
|
|---|
| 114 |
|
|---|
| 115 | //++
|
|---|
| 116 | // prototypes
|
|---|
| 117 | //--
|
|---|
| 118 |
|
|---|
| 119 | Moments_Info * moments( int n, float *image, float **pix,
|
|---|
| 120 | float plateScale, int flag);
|
|---|
| 121 | Islands_Info * islands( int n, float *f, int **pixneig, int *npixneig,
|
|---|
| 122 | int cleanning, int ipixcut );
|
|---|
| 123 | LenWid_Info * lenwid( int n, float *image, float **pix,
|
|---|
| 124 | float plateScale, float max_distance);
|
|---|
| 125 |
|
|---|
| 126 | void crosspt( float ax, float ay,
|
|---|
| 127 | float bx, float by,
|
|---|
| 128 | float cx, float cy,
|
|---|
| 129 | float dx, float dy,
|
|---|
| 130 | float * pcrossx, float * pcrossy);
|
|---|
| 131 |
|
|---|
| 132 | //!@}
|
|---|
| 133 |
|
|---|
| 134 | //!@{
|
|---|
| 135 |
|
|---|
| 136 | #endif // ! _moments_
|
|---|
| 137 |
|
|---|
| 138 | //!@}
|
|---|
| 139 |
|
|---|
| 140 | //=------------------------------------------------------------
|
|---|
| 141 | //!@subsection Log of this file.
|
|---|
| 142 |
|
|---|
| 143 | //!@{
|
|---|
| 144 |
|
|---|
| 145 | /*
|
|---|
| 146 | *$Log: not supported by cvs2svn $
|
|---|
| 147 | *Revision 1.1.1.1 1999/11/05 11:59:33 harald
|
|---|
| 148 | *This the starting point for CVS controlled further developments of the
|
|---|
| 149 | *camera program. The program was originally written by Jose Carlos.
|
|---|
| 150 | *But here you can find a "rootified" version to the program. This means
|
|---|
| 151 | *that there is no hbook stuff in it now. Also the output of the
|
|---|
| 152 | *program changed to the MagicRawDataFormat.
|
|---|
| 153 | *
|
|---|
| 154 | *The "rootification" was done by Dirk Petry and Harald Kornmayer.
|
|---|
| 155 | *
|
|---|
| 156 | *In the following you can see the README file of that version:
|
|---|
| 157 | *
|
|---|
| 158 | *==================================================
|
|---|
| 159 | *
|
|---|
| 160 | *Fri Oct 22 1999 D.P.
|
|---|
| 161 | *
|
|---|
| 162 | *The MAGIC Monte Carlo System
|
|---|
| 163 | *
|
|---|
| 164 | *Camera Simulation Programme
|
|---|
| 165 | *---------------------------
|
|---|
| 166 | *
|
|---|
| 167 | *1) Description
|
|---|
| 168 | *
|
|---|
| 169 | *This version is the result of the fusion of H.K.'s
|
|---|
| 170 | *root_camera which is described below (section 2)
|
|---|
| 171 | *and another version by D.P. which had a few additional
|
|---|
| 172 | *useful features.
|
|---|
| 173 | *
|
|---|
| 174 | *The version compiles under Linux with ROOT 2.22 installed
|
|---|
| 175 | *(variable ROOTSYS has to be set).
|
|---|
| 176 | *
|
|---|
| 177 | *Compile as before simply using "make" in the root_camera
|
|---|
| 178 | *directory.
|
|---|
| 179 | *
|
|---|
| 180 | *All features of H.K.'s root_camera were retained.
|
|---|
| 181 | *
|
|---|
| 182 | *Additional features of this version are:
|
|---|
| 183 | *
|
|---|
| 184 | * a) HBOOK is no longer used and all references are removed.
|
|---|
| 185 | *
|
|---|
| 186 | * b) Instead of HBOOK, the user is given now the possibility of
|
|---|
| 187 | * having Diagnostic data in ROOT format as a complement
|
|---|
| 188 | * to the ROOT Raw data.
|
|---|
| 189 | *
|
|---|
| 190 | * This data is written to the file which is determined by
|
|---|
| 191 | * the new input parameter "diag_file" in the camera parameter
|
|---|
| 192 | * file.
|
|---|
| 193 | *
|
|---|
| 194 | * All source code file belonging to this part have filenames
|
|---|
| 195 | * starting with "MDiag".
|
|---|
| 196 | *
|
|---|
| 197 | * The user can read the output file using the following commands
|
|---|
| 198 | * in an interactive ROOT session:
|
|---|
| 199 | *
|
|---|
| 200 | * root [0] .L MDiag.so
|
|---|
| 201 | * root [1] new TFile("diag.root");
|
|---|
| 202 | * root [2] new TTreeViewer("T");
|
|---|
| 203 | *
|
|---|
| 204 | * This brings up a viewer from which all variables of the
|
|---|
| 205 | * TTree can be accessed and histogrammed. This example
|
|---|
| 206 | * assumes that you have named the file "diag.root", that
|
|---|
| 207 | * you are using ROOT version 2.22 or later and that you have
|
|---|
| 208 | * the shared object library "MDiag.so" which is produced
|
|---|
| 209 | * by the Makefile along with the executable "camera".
|
|---|
| 210 | *
|
|---|
| 211 | * ! The contents of the so-called diag file is not yet fixed.
|
|---|
| 212 | * ! At the moment it is what J.C.G. used to put into the HBOOK
|
|---|
| 213 | * ! ntuple. In future versions the moments calculation can be
|
|---|
| 214 | * ! removed and the parameter list be modified correspondingly.
|
|---|
| 215 | *
|
|---|
| 216 | * c) Now concatenated reflector files can be read. This is useful
|
|---|
| 217 | * if you have run the reflector with different parameters but
|
|---|
| 218 | * you want to continue the analysis with all reflector data
|
|---|
| 219 | * going into ONE ROOT outputfile.
|
|---|
| 220 | *
|
|---|
| 221 | * The previous camera version contained a bug which made reading
|
|---|
| 222 | * of two or more concatenated reflector files impossible.
|
|---|
| 223 | *
|
|---|
| 224 | * d) The reflector output format was changed. It is now version
|
|---|
| 225 | * 0.4 .
|
|---|
| 226 | * The change solely consists in a shortening of the flag
|
|---|
| 227 | * definition in the file
|
|---|
| 228 | *
|
|---|
| 229 | * include-MC/MCCphoton.hxx
|
|---|
| 230 | *
|
|---|
| 231 | * ! IF YOU WANT TO READ REFLECTOR FORMAT 0.3, you can easily
|
|---|
| 232 | * ! do so by recompiling camera with the previous version of
|
|---|
| 233 | * ! include-MC/MCCphoton.hxx.
|
|---|
| 234 | *
|
|---|
| 235 | * The change was necessary for saving space and better
|
|---|
| 236 | * debugging. From now on, this format can be frozen.
|
|---|
| 237 | *
|
|---|
| 238 | * ! For producing reflector output in the new format, you
|
|---|
| 239 | * ! of course have to recompile your reflector with the
|
|---|
| 240 | * ! new include-MC/MCCphoton.hxx .
|
|---|
| 241 | *
|
|---|
| 242 | * e) A first version of the pixelization with the larger
|
|---|
| 243 | * outer pixels is implemented. THIS IS NOT YET FULLY
|
|---|
| 244 | * TESTED, but first rough tests show that it works
|
|---|
| 245 | * at least to a good approximation.
|
|---|
| 246 | *
|
|---|
| 247 | * The present version implements the camera outline
|
|---|
| 248 | * with 18 "gap-pixels" and 595 pixels in total as
|
|---|
| 249 | * shown in
|
|---|
| 250 | *
|
|---|
| 251 | * http://sarastro.ifae.es/internal/home/hardware/camera/numbering.ps
|
|---|
| 252 | *
|
|---|
| 253 | * This change involved
|
|---|
| 254 | *
|
|---|
| 255 | * (i) The file pixels.dat is no longer needed. Instead
|
|---|
| 256 | * the coordinates are generated by the program itself
|
|---|
| 257 | * (takes maybe 1 second). In the file
|
|---|
| 258 | *
|
|---|
| 259 | * pixel-coords.txt
|
|---|
| 260 | *
|
|---|
| 261 | * in the same directory as this README, you find a list
|
|---|
| 262 | * of the coordinates generated by this new routine. It
|
|---|
| 263 | * has the format
|
|---|
| 264 | *
|
|---|
| 265 | * number i j x y size-factor
|
|---|
| 266 | *
|
|---|
| 267 | * where i and j are J.C.G.'s so called biaxis hexagonal
|
|---|
| 268 | * coordinates (for internal use) and x and y are the
|
|---|
| 269 | * coordinates of the pixel centers in the standard camera
|
|---|
| 270 | * coordinate system in units of centimeters. The value
|
|---|
| 271 | * of "size-factor" determines the linear size of the pixel
|
|---|
| 272 | * relative to the central pixels.
|
|---|
| 273 | *
|
|---|
| 274 | * (ii) The magic.def file has two additional parameters
|
|---|
| 275 | * which give the number of central pixels and the
|
|---|
| 276 | * number of gap pixels
|
|---|
| 277 | *
|
|---|
| 278 | * (iii) In camera.h and camera.cxx several changes were
|
|---|
| 279 | * necessary, among them the introduction of several
|
|---|
| 280 | * new functions
|
|---|
| 281 | *
|
|---|
| 282 | * The newly suggested outline with asymmetric Winston cones
|
|---|
| 283 | * will be implemented in a later version.
|
|---|
| 284 | *
|
|---|
| 285 | * f) phe files can no longer be read since this contradicts
|
|---|
| 286 | * our philosophy that the analysis should be done with other
|
|---|
| 287 | * programs like e.g. EVITA and not with "camera" itself.
|
|---|
| 288 | * This possibility was removed.
|
|---|
| 289 | *
|
|---|
| 290 | * g) ROOT is no longer invoked with an interactive interface.
|
|---|
| 291 | * In this way, camera can better be run as a batch program and
|
|---|
| 292 | * it uses less memory.
|
|---|
| 293 | *
|
|---|
| 294 | * h) small changes concerning the variable "t_chan" were necessary in
|
|---|
| 295 | * order to avoid segmentation faults: The variable is used as an
|
|---|
| 296 | * index and it went sometimes outside the limits when camera
|
|---|
| 297 | * was reading proton data. This is because the reflector files
|
|---|
| 298 | * don't contain the photons in a chronological order and also
|
|---|
| 299 | * the timespread can be considerably longer that the foreseen
|
|---|
| 300 | * digitisation timespan. Please see the source code of camera.cxx
|
|---|
| 301 | * round about line 1090.
|
|---|
| 302 | *
|
|---|
| 303 | * j) several unused variables were removed, a few warning messages
|
|---|
| 304 | * occur when you compile camera.cxx but these can be ignored at
|
|---|
| 305 | * the moment.
|
|---|
| 306 | *
|
|---|
| 307 | *In general the program is of course not finished. It still needs
|
|---|
| 308 | *debugging, proper trigger simulation, simulation of the asymmetric
|
|---|
| 309 | *version of the outer pixels, proper NSB simulation, adaption of
|
|---|
| 310 | *the diag "ntuple" contents to our need and others small improvements.
|
|---|
| 311 | *
|
|---|
| 312 | *In the directory rfl-files there is now a file in reflector format 0.4
|
|---|
| 313 | *containing a single event produced by the starfiled adder. It has
|
|---|
| 314 | *a duration of 30 ns and represents the region around the Crab Nebula.
|
|---|
| 315 | *Using the enclosed input parameter file, camera should process this
|
|---|
| 316 | *file without problems.
|
|---|
| 317 | *
|
|---|
| 318 | *2) The README for the previous version of root_camera
|
|---|
| 319 | *
|
|---|
| 320 | *README for a preliminary version of the
|
|---|
| 321 | *root_camera program.
|
|---|
| 322 | *
|
|---|
| 323 | *root_camera is based on the program "camera"of Jose Carlos
|
|---|
| 324 | *Gonzalez. It was changed in the way that only the pixelisation
|
|---|
| 325 | *and the distibution of the phe to the FADCs works in a
|
|---|
| 326 | *first version.
|
|---|
| 327 | *
|
|---|
| 328 | *Using the #undef command most possibilities of the orignal
|
|---|
| 329 | *program are switched of.
|
|---|
| 330 | *
|
|---|
| 331 | *The new parts are signed by
|
|---|
| 332 | *
|
|---|
| 333 | *- ROOT or __ROOT__
|
|---|
| 334 | * nearly all important codelines for ROOT output are enclosed
|
|---|
| 335 | * in structures like
|
|---|
| 336 | * #ifdef __ROOT__
|
|---|
| 337 | *
|
|---|
| 338 | * code
|
|---|
| 339 | *
|
|---|
| 340 | * #endif __ROOT__
|
|---|
| 341 | *
|
|---|
| 342 | * In same case the new lines are signed by a comment with the word
|
|---|
| 343 | * ROOT in it.
|
|---|
| 344 | *
|
|---|
| 345 | * For timing of the pulse some variable names are changed.
|
|---|
| 346 | * (t0, t1, t --> t_ini, t_fin, t_1st, t_chan,...)
|
|---|
| 347 | * Look also for this changes.
|
|---|
| 348 | *
|
|---|
| 349 | * For the new root-file is also a change in readparm-files
|
|---|
| 350 | *
|
|---|
| 351 | *
|
|---|
| 352 | *- __DETAIL_TRIGGER__
|
|---|
| 353 | *
|
|---|
| 354 | * This is for the implementation of the current work on trigger
|
|---|
| 355 | * studies. Because the class MTrigger is not well documented it
|
|---|
| 356 | * isn´t a part of this tar file. Only a dummy File exists.
|
|---|
| 357 | *
|
|---|
| 358 | *
|
|---|
| 359 | *
|
|---|
| 360 | *With all files in the archive, the root_camera program should run.
|
|---|
| 361 | *
|
|---|
| 362 | *A reflector file is in the directory rfl-files
|
|---|
| 363 | *
|
|---|
| 364 | *==================================================
|
|---|
| 365 | *
|
|---|
| 366 | *From now on, use CVS for development!!!!
|
|---|
| 367 | *
|
|---|
| 368 | *
|
|---|
| 369 | *
|
|---|
| 370 | *Revision 1.1.1.1 1999/10/21 16:35:10 petry
|
|---|
| 371 | *first synthesised version
|
|---|
| 372 | *
|
|---|
| 373 | * Revision 1.4 1999/03/15 14:59:10 gonzalez
|
|---|
| 374 | * camera-1_1
|
|---|
| 375 | *
|
|---|
| 376 | * Revision 1.3 1999/03/02 09:56:15 gonzalez
|
|---|
| 377 | * *** empty log message ***
|
|---|
| 378 | *
|
|---|
| 379 | */
|
|---|
| 380 |
|
|---|
| 381 | //!@}
|
|---|
| 382 | //=EOF
|
|---|