Changeset 1614
- Timestamp:
- 11/14/02 21:39:04 (22 years ago)
- Location:
- trunk/MagicSoft/Simulation/Detector/ReflectorII
- Files:
-
- 14 added
- 3 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/ReflectorII/Makefile
r1535 r1614 19 19 # 20 20 # $RCSfile: Makefile,v $ 21 # $Revision: 1. 4$21 # $Revision: 1.5 $ 22 22 # $Author: bigongia $ 23 # $Date: 2002-1 0-09 18:15:27$23 # $Date: 2002-11-14 21:39:01 $ 24 24 # 25 25 ################################################################## -
trunk/MagicSoft/Simulation/Detector/ReflectorII/atm.c
r1431 r1614 9 9 #define RandomNumber ranf() 10 10 11 /* Local declarations*/12 static int atmModel=0; /* current atm. model*/11 /* AM Nov 2002: atmModel is now an external variable: */ 12 int atmModel=0; /* current atm. model */ 13 13 14 14 /* Function declarations */ -
trunk/MagicSoft/Simulation/Detector/ReflectorII/config.mk.linux
r1535 r1614 18 18 #--------------------------------------------------------------- 19 19 # $RCSfile: config.mk.linux,v $ 20 # $Revision: 1. 2$20 # $Revision: 1.3 $ 21 21 # $Author: bigongia $ 22 # $Date: 2002-1 0-09 18:15:27$22 # $Date: 2002-11-14 21:39:01 $ 23 23 ################################################################## 24 24 # @maintitle -
trunk/MagicSoft/Simulation/Detector/ReflectorII/geometry.c
r1535 r1614 24 24 float *Reflectivity[2]; /* reflectivity table */ 25 25 float *AxisDeviation[2]; /* axis deviation table */ 26 float *ct_Focal; /* focal length table */27 26 28 27 /* Prototypes */ … … 30 29 static void ReadReflectivity(char *datname); 31 30 static void ReadAxisDev(char *datname); 32 static void ReadFocals(void);33 31 34 32 static void ReadMirrorTable(FILE *geofile) … … 50 48 &ct_data[i].xn, &ct_data[i].yn, &ct_data[i].zn)) 51 49 break; 50 52 51 } 53 52 if (i < ct_NMirrors) … … 121 120 } /* end of ReadAxisDev */ 122 121 123 static void ReadFocals(void)124 { int loop;125 126 if ((ct_Focal = (float *) malloc(sizeof(float) * ct_NMirrors)) == NULL)127 FatalError(FOCL_FEW___FTL, ct_NMirrors);128 129 for (loop=0; loop<ct_NMirrors; loop++)130 ct_Focal[loop] = ct_data[loop].f;131 } /* end of ReadFocals */132 133 122 void GeometrySwitch(FILE *geofile) 134 123 { char *value_ptr = NULL; /* ptr at parm value */ … … 218 207 219 208 220 ReadFocals();221 209 } /* end of GeometrySwitch */ 222 210 -
trunk/MagicSoft/Simulation/Detector/ReflectorII/header.h
r1535 r1614 2 2 #define __RFL_HEADER__ 3 3 4 /* RUNH from cerfile. See CORSIKA manual for explanations */ 4 /* RUNH for reflector file. Identical to Corsika's Run Header (see CORSIKA 5 * manual for explanations), plus some other info like the wobble mode 6 * which has been used. We have put this in the unused variables. 7 */ 5 8 typedef struct 6 9 { char RUNH[4]; … … 21 24 /* Physical constants and interaction flags (see CORSIKA manual): */ 22 25 float C[50]; 23 float dummy1[20]; /* not used */ 26 float wobble_mode; /* Indicates wobble mode with which 27 reflector has been run */ 28 float atmospheric_model; /* Indicates atmospheric model used in 29 absorption simulation. 0 = no atmosphere, 30 1 = atm_90percent, 2 = atm_isothermal, 31 3 = atm_corsika. 32 */ 33 float dummy1[18]; /* not used */ 24 34 float CKA[40]; 25 35 float CETA[5]; … … 30 40 float CATM[5]; 31 41 float NFL[4]; 32 } CerRunHeader; 33 42 } RflRunHeader; 34 43 35 44 /* EVTH from cerfile. See CORSIKA manual for explanations */ … … 239 248 float OutOfChamPhs; /* Photons outside the camera */ 240 249 float CPhotons; /* Photons reaching the camera */ 241 242 float dummy[10]; /* not used */ 250 251 /* Now follow the fraction of photons reaching the camera produced by 252 * electrons, muons and other particles respectively: 253 */ 254 float elec_cph_fraction; 255 float muon_cph_fraction; 256 float other_cph_fraction; 257 258 float dummy[7]; /* not used */ 259 243 260 } RflEventHeader; 244 261 -
trunk/MagicSoft/Simulation/Detector/ReflectorII/init.c
r1431 r1614 23 23 float Telescope_x = 0.; 24 24 float Telescope_y = 0.; /* Telescope coordinates (cm) */ 25 26 int wobble_position = 0; 25 27 26 28 int is_Random_Pointing=FALSE; /* random pointing? */ -
trunk/MagicSoft/Simulation/Detector/ReflectorII/init.h
r1535 r1614 43 43 extern float Telescope_x, Telescope_y; /* Telescope coordinates (cm) */ 44 44 45 extern int wobble_position; 46 45 47 extern int is_Random_Pointing; /* random pointing? */ 46 48 extern float Random_Pointing_MaxDist; /* in metres */ … … 72 74 extern float *Reflectivity[]; /* ptr to refl. table */ 73 75 extern float *AxisDeviation[]; /* ptr to axisdev. table */ 74 extern float *ct_Focal; /* ptr to focal data */75 76 76 77 /* Photon structures */ -
trunk/MagicSoft/Simulation/Detector/ReflectorII/input.card
r1432 r1614 1 reflector 0. 51 reflector 0.6 2 2 # 3 3 # Sample parameters file … … 10 10 telescope_position 0. 0. 11 11 # 12 wobble_mode 0 12 13 max_events 1000000000 13 14 #energy_cuts 800. 1000. 14 15 # 15 ct_file ../Data/magic.def16 ct_file mypath/Data/magic.def 16 17 # 17 #reflectivity_file /mypath/Data/reflectivity.dat18 reflectivity_file /mypath/Data/reflectivity.dat 18 19 # 19 #axisdev_file /mypath/Data/axisdev.dat20 axisdev_file /mypath/Data/axisdev.dat 20 21 # 21 22 output_file /myout/my.rfl -
trunk/MagicSoft/Simulation/Detector/ReflectorII/parms.c
r1535 r1614 128 128 Message(MAX__EVTS__MSG, max_Events=atol(value_ptr)); 129 129 break; 130 131 /* AM, Nov 2002, added wobble option: */ 132 case wobble_mode: 133 wobble_position = (int) atoi(value_ptr); 134 if ( (wobble_position > 1 || wobble_position < -1) && 135 wobble_position != 3) 136 { 137 Message(WOBBLE_POS_ERR); 138 exit(-1); 139 } 140 else 141 { 142 Message(WOBBLE_POS_MSG, wobble_position); 143 break; 144 } 130 145 case energy_cuts: 131 146 low_Ecut = (float) atof(value_ptr); -
trunk/MagicSoft/Simulation/Detector/ReflectorII/parms.h
r1431 r1614 13 13 T(telescope_position),/* position towards which CT is pointing */ \ 14 14 T(max_events), /* maximum number of event to read */ \ 15 T(wobble_mode), /* wobble mode option */ \ 15 16 T(energy_cuts), /* lowest/highest energy allowed */ \ 16 17 T(seeds), /* seeds for random number generation */ \ … … 47 48 #define MAX__EVTS__MSG /* max. nr. of evts. */ \ 48 49 "Processing at most %ld events.\n" 50 51 #define WOBBLE_POS_ERR "wobble mode can only be -1, 0, 1 or 3\n" 52 #define WOBBLE_POS_MSG "Using wobble position %d\n" 53 49 54 #define ENRG_LIMIT_ERR /* no parms */ \ 50 55 "Error while parsing \"energy_cuts\" fields.\n" \ … … 64 69 "No specified input file could be opened.\n" \ 65 70 " *** Please specify some *valid* filename after the cer_files directive.\n" 66 67 68 71 extern char axisdev_filename[256], reflectivity_filename[256]; 69 72 -
trunk/MagicSoft/Simulation/Detector/ReflectorII/ph2cph.c
r1535 r1614 118 118 r[0] = ph->u; 119 119 r[1] = ph->v; 120 r[2] = (float) sqrt(1.0 - r[0]*r[0] - r[1]*r[1]); 120 121 // AM 11/2002: fixed line below: u v are the direction cosines of the 122 // *downgoing* photon. Hence, third component must be negative! 123 // This was a serious bug affecting all versions before 0.6 (see TDAS 124 // note on Reflector program 0.6). 125 126 r[2] = (float) -sqrt(1.0 - r[0]*r[0] - r[1]*r[1]); 121 127 122 128 /* get photon time and production height */ … … 494 500 /* 495 501 if we still have the photon, we continue with the reflexion; 496 we calculate normal vector in this point 497 (and normalize, with the sign changed) 502 we calculate normal vector in this point and normalize: 498 503 */ 499 504 500 505 rnor[0] = 2.0f*xcut[0]; 501 506 rnor[1] = 2.0f*xcut[1]; 502 rnor[2] = (float) (2.0*(xcut[2] - 2.0*ct_ Focal[i_mirror]));507 rnor[2] = (float) (2.0*(xcut[2] - 2.0*ct_data[i_mirror].f)); 503 508 504 509 /* CBC */ … … 506 511 /* CBC */ 507 512 508 rnorm = -NORM( rnor ); 513 // Changed AM, 11/2002: now we use the normal vector going "outwards" 514 // from inside the sphere (=removed minus sign in normalization below). 515 // It is easier to do so, since now the vector rm indicating the 516 // photon direction also goes from the front to the back of the mirror. 517 518 rnorm = NORM( rnor ); 509 519 rnor[0] /= rnorm; 510 520 rnor[1] /= rnorm; … … 525 535 */ 526 536 527 calpha = (float) fabs(rnor[0]*rm[0] + rnor[1]*rm[1] + rnor[2]*rm[2]); 537 // AM 11/2002: removed absolute value in scalar 538 // product below (it is now unnecessary): 539 540 calpha = (float) (rnor[0]*rm[0] + rnor[1]*rm[1] + rnor[2]*rm[2]); 528 541 529 542 /* CBC */ … … 532 545 533 546 /* finally!!! we have the reflected trajectory of the photon */ 547 534 548 535 549 rrefl[0] = (float) (2.0*rnor[0]*calpha - rm[0]); … … 633 647 calculate angle of incidence between tray. and camera plane 634 648 the camera plane is 635 0 y + 0 y + z - ct_Focal = 0 => (A,B,C,D) = (0,0,1,-ct_Focal)649 0 x + 0 y + z - ct_Focal_mean = 0 => (A,B,C,D) = (0,0,1,-ct_Focal_mean) 636 650 from Table 3.20 "Tasch. der Math." 637 651 */ … … 679 693 /* Output */ 680 694 681 /* cph->w = wl; */ 682 cph->x = xcam[0]; 683 cph->y = xcam[1]; 695 /* AM Nov 2002: Added one further change of coordinates so that the camera 696 * images have the "right" orientation: they will appear as seen by an 697 * observer on ground, standing behind the mirror dish and looking towards 698 * the camera. Formerly cph->x and cph->y were simply xcam[0] and xcam[1]. 699 */ 700 701 cph->x = -xcam[1]; 702 cph->y = -xcam[0]; 703 684 704 cph->u = r[0]; 685 705 cph->v = r[1]; -
trunk/MagicSoft/Simulation/Detector/ReflectorII/reflector.c
r1535 r1614 120 120 extern void makeOmegaI(float theta, float phi); 121 121 122 extern int wobble_position; 122 123 123 124 /* Various counters: phs = absphs + refphs[0..3] + cphs */ … … 127 128 cphs; /* Number of cphotons */ 128 129 130 /* AM, Nov 2002 */ 131 /* Counters of the number of cphs produced by different particle types: */ 132 long 133 mu_cphs, /* by muons */ 134 el_cphs, /* by electrons */ 135 other_cphs; /* by other particles */ 136 137 138 int parent_id; /* Id of the particle producing the C-photon */ 139 129 140 FILE *tmpf=NULL; /* Temp fp to handle o/f */ 130 141 size_t read; /* items read: != 1 on error */ … … 140 151 theta; /* photon zenith angle */ 141 152 153 float tel_theta, tel_phi; /* Indicate telescope orientation, following 154 * Corsika's criterium: theta is the zenith 155 * angle, but phi is the azimuth of the vector 156 * along the telescope axis going from the 157 * camera to the dish, measured from north, 158 * anticlockwise (0-2pi). 159 */ 160 142 161 /* Reset counters and set fileptr */ 143 162 phs= absphs= refphs[0]= refphs[1]= refphs[2]= refphs[3]= cphs= 0; … … 147 166 TranslateHeader(rheadp, cheadp); 148 167 149 /* Calculate OmegaCT matrices */150 168 if (is_Fixed_Target) 151 { makeOmega(fixed_Theta, fixed_Phi); 152 makeOmegaI(fixed_Theta, fixed_Phi); } 153 else 154 { makeOmega(cheadp->Theta, cheadp->Phi); 155 makeOmegaI(cheadp->Theta, cheadp->Phi); } 169 { 170 tel_theta = fixed_Theta; 171 tel_phi = fixed_Phi; 172 } 173 else /* Use the direction of the primary if no telescope 174 * orientation is given: */ 175 { 176 tel_theta = cheadp->Theta; 177 tel_phi = cheadp->Phi; 178 } 179 180 /* AM, Nov 2002: added wobble mode option. It refers 181 * to wobble position +-1, 3 defined in TDAS 01-05 */ 182 183 switch (wobble_position) 184 { 185 case 1: 186 tel_theta = acos(cos(tel_theta)/1.000024369); 187 tel_phi -= atan(0.006981317/sin(tel_theta)); 188 break; 189 case -1: 190 tel_theta = acos(cos(tel_theta)/1.000024369); 191 tel_phi += atan(0.006981317/sin(tel_theta)); 192 break; 193 case 3: 194 tel_theta += 0.006981317; /* 0.4 degrees */ 195 break; 196 default: 197 break; 198 } 199 200 /* Calculate OmegaCT matrices */ 201 /* AM 11/2002 : added PI to 2nd argument in makeOmega, to take 202 * into account that theta and phi from Corsika indicate the 203 * direction of the momentum (hence, downgoing) of the primary 204 * particle, phi measured from positive x axis, anticlockwise, and 205 * theta measured from negative z axis (see Corsika manual). In the 206 * call to makeOmega, the second argument must be the azimuth of the 207 * telescope up-going pointing direction. 208 */ 209 210 makeOmega(tel_theta, tel_phi+M_PI); 211 makeOmegaI(tel_theta, tel_phi+M_PI); 212 156 213 memcpy( OmegaCT, Omega, 9*sizeof(float) ); 157 214 memcpy( OmegaICT, OmegaI, 9*sizeof(float) ); … … 175 232 rheadp->CorePos[1][0] += Telescope_y; 176 233 234 /* Initialize cphoton counters: */ 235 el_cphs = mu_cphs = other_cphs = 0; 236 177 237 /* Loop on data blocks */ 178 238 … … 214 274 215 275 CPhotons[cphs].w = Photons[ph].w; 276 277 /* AM Nov 2002: now we read the type of particle which produced 278 * the Cherenkov photon : 279 */ 280 parent_id = (int)Photons[ph].w/100000; 216 281 Photons[ph].w = wlen = (float) fmod(Photons[ph].w, 1000.); 217 282 218 283 /* AM Nov 2001: we found that sometimes the value 219 284 stored in Photons[ph].w is not correct, and can result in a … … 244 309 /* Increment number of photons */ 245 310 phs++; 246 311 247 312 /* Calculate some quantities */ 248 313 theta = (float) acos(sqrt( … … 269 334 CPhotons[cphs].y); 270 335 336 /* AM Nov 2002: We now count for every event how many 337 * photons were produced by each type. 338 */ 339 340 switch (parent_id) 341 { 342 case 2: 343 el_cphs ++; 344 break; 345 case 3: 346 el_cphs ++; 347 break; 348 case 5: 349 mu_cphs ++; 350 break; 351 case 6: 352 mu_cphs ++; 353 break; 354 default: 355 other_cphs++; 356 } 271 357 272 358 /* Update first/last arrival times */ … … 314 400 rheadp->OutOfChamPhs = refphs[3]; 315 401 rheadp->CPhotons = (long) overflow * NR_OF_CPHOTONS + cphs; 402 403 if (rheadp->CPhotons > 0.) 404 { 405 /* Fill in relative fraction of each particle type producing 406 * Cherenkov light in this even: 407 */ 408 rheadp->elec_cph_fraction = (float)el_cphs/(float)rheadp->CPhotons; 409 rheadp->muon_cph_fraction = (float)mu_cphs/(float)rheadp->CPhotons; 410 rheadp->other_cph_fraction = (float)other_cphs/(float)rheadp->CPhotons; 411 } 412 else 413 { 414 rheadp->elec_cph_fraction = 0.; 415 rheadp->muon_cph_fraction = 0.; 416 rheadp->other_cph_fraction = 0.; 417 } 418 316 419 fwrite(rheadp, sizeof(RflEventHeader), 1, rflfile); 317 420 … … 363 466 static int newFile = TRUE; /* if TRUE, check if cerfile is valid */ 364 467 365 CerRunHeader cRunHead; 366 468 RflRunHeader RflRunHead; 469 470 extern int atmModel; /* current atm. model */ 471 367 472 do 368 473 { … … 384 489 { 385 490 /* Write Reflector "run header" (one per cer file!): */ 386 memcpy(&cRunHead, cheadp, sizeof(CerEventHeader)); 387 fwrite(&cRunHead, sizeof(CerRunHeader), 1, rflfile); 491 memcpy(&RflRunHead, cheadp, sizeof(RflRunHead)); 492 RflRunHead.wobble_mode = wobble_position; 493 RflRunHead.atmospheric_model = atmModel; 494 fwrite(&RflRunHead, sizeof(RflRunHead), 1, rflfile); 388 495 } 389 496 … … 503 610 { free(AxisDeviation[1]); Log(VECT_FREE__LOG, "AxisDeviation[1]"); } 504 611 505 if (ct_Focal)506 { free(ct_Focal); Log(VECT_FREE__LOG, "ct_Focal"); }507 508 612 if (CPhotons) 509 613 { free(CPhotons); Log(VECT_FREE__LOG, "CPhotons"); }
Note:
See TracChangeset
for help on using the changeset viewer.