Line | |
---|
1 | // Include header files
|
---|
2 |
|
---|
3 | #ifndef _STARFIELD_H_
|
---|
4 | #define _STARFIELD_H_
|
---|
5 |
|
---|
6 | #include <iostream.h>
|
---|
7 | #include <fstream.h>
|
---|
8 | #include <stdlib.h>
|
---|
9 | #include <stdio.h>
|
---|
10 | #include <string.h>
|
---|
11 | #include <math.h>
|
---|
12 | #include <sys/types.h>
|
---|
13 | #include <dirent.h>
|
---|
14 | #include <unistd.h>
|
---|
15 |
|
---|
16 | // Include header files from the project.
|
---|
17 |
|
---|
18 | #include "convertcorsika.h"
|
---|
19 |
|
---|
20 | //#include "rand_time.h"
|
---|
21 |
|
---|
22 | //#include "rand_coord.h"
|
---|
23 |
|
---|
24 | #include "star.hxx"
|
---|
25 |
|
---|
26 | #include "photon.hxx"
|
---|
27 |
|
---|
28 | #include "jcmacros.h"
|
---|
29 |
|
---|
30 | #include "parameters.h"
|
---|
31 |
|
---|
32 | // Global constants.
|
---|
33 |
|
---|
34 |
|
---|
35 | // Maximum number of stars and maximum number of photons for
|
---|
36 | // memory allocation
|
---|
37 |
|
---|
38 |
|
---|
39 | #ifndef iMAXSTARS
|
---|
40 | #define iMAXSTARS 5000
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #ifndef iMAXPHOT
|
---|
44 | #define iMAXPHOT 250000
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | #ifndef PI
|
---|
48 | #define PI 3.1415927
|
---|
49 | #endif
|
---|
50 |
|
---|
51 |
|
---|
52 | //Seed for the random generators.
|
---|
53 |
|
---|
54 | long int idum=-1;
|
---|
55 |
|
---|
56 |
|
---|
57 | //Function definitions
|
---|
58 |
|
---|
59 |
|
---|
60 | //Random generator functions.
|
---|
61 |
|
---|
62 | float rand_un_gen(long *idum);
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 | inline float rand_coord(float radius){
|
---|
67 | // generate a coordinate on the floor for every photon arriving from the star.
|
---|
68 |
|
---|
69 | float p_m;
|
---|
70 | float randc;
|
---|
71 |
|
---|
72 | randc=rand_un_gen(&idum);
|
---|
73 |
|
---|
74 | p_m= 2.0*radius * randc - radius;
|
---|
75 |
|
---|
76 | return (p_m);
|
---|
77 | }
|
---|
78 |
|
---|
79 | // generate for every photon a random arrival time within a time window
|
---|
80 | // defined by the intgreation time.
|
---|
81 |
|
---|
82 | inline float rand_time(float inttime_s){
|
---|
83 |
|
---|
84 | float randt;
|
---|
85 |
|
---|
86 | randt= inttime_s * rand_un_gen(&idum);
|
---|
87 |
|
---|
88 | return(randt);
|
---|
89 | }
|
---|
90 |
|
---|
91 | // The rand_lambda function will generate for every photon a random wavelength
|
---|
92 | // in the given waveband
|
---|
93 |
|
---|
94 | inline float rand_lambda(float lmin, float lmax){
|
---|
95 |
|
---|
96 | float randt;
|
---|
97 |
|
---|
98 | randt=(lmax - lmin) * rand_un_gen(&idum) + lmin ;
|
---|
99 |
|
---|
100 | return(randt);
|
---|
101 | }
|
---|
102 |
|
---|
103 |
|
---|
104 | #endif
|
---|
105 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.