- Timestamp:
- 11/14/02 21:39:04 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.