1 | // $Id: erandom.c 1152 2004-10-09 22:33:51Z thea $ |
---|
2 | // A.Thea, created Sep, 24 2004 |
---|
3 | |
---|
4 | /***************************************************************************** |
---|
5 | * ESAF: Euso Simulation and Analysis Framework * |
---|
6 | * * |
---|
7 | * Id: erandom * |
---|
8 | * Package: Externals * |
---|
9 | * Coordinator: * |
---|
10 | * * |
---|
11 | *****************************************************************************/ |
---|
12 | |
---|
13 | //_____________________________________________________________________________ |
---|
14 | // |
---|
15 | // Euso Random fortran interface |
---|
16 | // |
---|
17 | // Function names follow the convention |
---|
18 | // |
---|
19 | // esaf[TRandom method][typeid]_(...) |
---|
20 | // |
---|
21 | |
---|
22 | #include "EsafRandom.hh" |
---|
23 | |
---|
24 | extern "C" int esafbinomial_(int& ntot, double& prob); |
---|
25 | extern "C" double esafbreitwigner_(double& mean, double& gamma); |
---|
26 | extern "C" double esafexp_( double& tau); |
---|
27 | extern "C" double esafgaus_( double& mean, double& sigma); |
---|
28 | extern "C" int esafinteger_( unsigned int& imax); |
---|
29 | extern "C" double esaflandau_( double& mpv, double& sigma); |
---|
30 | extern "C" int esafpoisson_( double& mean); |
---|
31 | extern "C" double esafpoissond_( double& mean); |
---|
32 | extern "C" void esafrannordbl_( double&, double& ); |
---|
33 | extern "C" void esafrannorreal_( float&, float& ); |
---|
34 | extern "C" double esafrndm_(); |
---|
35 | extern "C" void esafrndmarraydbl_( int&, double*); |
---|
36 | extern "C" void esafrndmarrayreal_( int&, float*); |
---|
37 | extern "C" double esafuniform_( double& ); |
---|
38 | extern "C" double esafuniform2_( double&, double&); |
---|
39 | |
---|
40 | //______________________________________________________________________________ |
---|
41 | int esafbinomial_( int& ntot, double& prob){ |
---|
42 | // |
---|
43 | // C wrap for TRandom::Binomial() |
---|
44 | // |
---|
45 | |
---|
46 | return EsafRandom::Get()->Binomial(ntot, prob); |
---|
47 | } |
---|
48 | //______________________________________________________________________________ |
---|
49 | double esafbreitwigner_(double& mean, double& gamma){ |
---|
50 | // |
---|
51 | // C wrap for TRandom::BreitWigner( Double_t, Double_t ) |
---|
52 | // |
---|
53 | |
---|
54 | return EsafRandom::Get()->BreitWigner(mean, gamma); |
---|
55 | } |
---|
56 | |
---|
57 | //______________________________________________________________________________ |
---|
58 | double esafexp_(double& tau) { |
---|
59 | // |
---|
60 | // C wrap for TRandom::Exp( Double_t ) |
---|
61 | // |
---|
62 | |
---|
63 | return EsafRandom::Get()->Exp(tau); |
---|
64 | } |
---|
65 | |
---|
66 | //______________________________________________________________________________ |
---|
67 | double esafgaus_( double& mean, double& sigma) { |
---|
68 | // |
---|
69 | // C wrap for TRandom::Gaus(Double_t, Double_t) |
---|
70 | // |
---|
71 | |
---|
72 | return EsafRandom::Get()->Gaus(mean, sigma); |
---|
73 | } |
---|
74 | |
---|
75 | //______________________________________________________________________________ |
---|
76 | int esafinteger_( unsigned int& imax){ |
---|
77 | // |
---|
78 | // C wrap for TRandom::Integer( Int_t imax ) |
---|
79 | // |
---|
80 | |
---|
81 | return EsafRandom::Get()->Integer(imax); |
---|
82 | } |
---|
83 | |
---|
84 | //______________________________________________________________________________ |
---|
85 | double esaflandau_( double& mpv, double& sigma ) { |
---|
86 | // |
---|
87 | // C wrap for TRandom::Landau(Double_t, Double_t) |
---|
88 | // |
---|
89 | |
---|
90 | return EsafRandom::Get()->Landau(mpv,sigma); |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | //______________________________________________________________________________ |
---|
95 | int esafpoisson_(double& mean){ |
---|
96 | // |
---|
97 | // C wrap for TRandom::Poisson(Double_t mean) |
---|
98 | // |
---|
99 | |
---|
100 | return EsafRandom::Get()->Poisson(mean); |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | //______________________________________________________________________________ |
---|
105 | double esafpoissond_(double& mean){ |
---|
106 | // |
---|
107 | // C wrap for TRandom::PoissonD(Double_t mean) |
---|
108 | // |
---|
109 | |
---|
110 | return EsafRandom::Get()->PoissonD(mean); |
---|
111 | } |
---|
112 | |
---|
113 | //______________________________________________________________________________ |
---|
114 | void esafrannordbl_( double& a, double& b) { |
---|
115 | // |
---|
116 | // C wrap for TRandom::Rannor( Double_t, Double_t ) |
---|
117 | // |
---|
118 | |
---|
119 | EsafRandom::Get()->Rannor(a,b); |
---|
120 | } |
---|
121 | |
---|
122 | //______________________________________________________________________________ |
---|
123 | void esafrannorreal_( float& a, float& b) { |
---|
124 | // |
---|
125 | // C wrap for TRandom::Rannor( Float_t, Float_t ) |
---|
126 | // |
---|
127 | |
---|
128 | EsafRandom::Get()->Rannor(a,b); |
---|
129 | } |
---|
130 | |
---|
131 | //______________________________________________________________________________ |
---|
132 | double esafrndm_(){ |
---|
133 | // |
---|
134 | // C wrap for TRandom::Rndm() |
---|
135 | // |
---|
136 | |
---|
137 | return EsafRandom::Get()->Rndm(); |
---|
138 | } |
---|
139 | |
---|
140 | //______________________________________________________________________________ |
---|
141 | void esafrndmarraydbl_( int& n, double* array) { |
---|
142 | // |
---|
143 | // C wrap for TRandom::RndmArray(Int_t, Double_t*) |
---|
144 | // |
---|
145 | |
---|
146 | EsafRandom::Get()->RndmArray(n, array); |
---|
147 | |
---|
148 | // Printf("RndmArrayDbl"); |
---|
149 | // for(Int_t i(0); i<*n; i++) |
---|
150 | // Printf("%d %g", i, array[i]); |
---|
151 | } |
---|
152 | |
---|
153 | //______________________________________________________________________________ |
---|
154 | void esafrndmarrayreal_( int& n, float* array) { |
---|
155 | // |
---|
156 | // C wrap for TRandom::RndmArray(Int_t, Float_t*) |
---|
157 | // |
---|
158 | |
---|
159 | EsafRandom::Get()->RndmArray(n, array); |
---|
160 | |
---|
161 | // Printf("RndmArrayReal"); |
---|
162 | // for(Int_t i(0); i<*n; i++) |
---|
163 | // Printf("%d %g", i, array[i]); |
---|
164 | } |
---|
165 | |
---|
166 | //______________________________________________________________________________ |
---|
167 | double esafuniform_( double& x ) { |
---|
168 | // |
---|
169 | // C wrap for TRandom::Uniform(Double_t) |
---|
170 | // |
---|
171 | |
---|
172 | return EsafRandom::Get()->Uniform( x ); |
---|
173 | } |
---|
174 | |
---|
175 | //______________________________________________________________________________ |
---|
176 | double esafuniform2_( double& x1, double& x2) { |
---|
177 | // |
---|
178 | // C wrap for TRandom::Uniform(Double_t, Double_t) |
---|
179 | // |
---|
180 | |
---|
181 | return EsafRandom::Get()->Uniform(x1,x2); |
---|
182 | } |
---|
183 | |
---|