57{
59
62 string option;
64
65 try {
66
67 JParser<> zap(
"Example program to histogram radiation cross sections, shower energy, range and b(E).");
68
71 zap[
'O'] =
make_field(option) = LENGTH, ENERGY, RANGE, ELOSS;
73
74 zap(argc, argv);
75 }
76 catch(const exception &error) {
77 FATAL(error.what() << endl);
78 }
79
80
82
83
85
86 TH1* h0 = NULL;
87
88 if (option == LENGTH) {
89 h0 = new TH1D("total", NULL, 160, 2.0, 10.0);
90 }
91
92 if (option == ENERGY) {
93 h0 = new TH1D("total", NULL, 24, 2.0, 10.0);
94 }
95
96 NOTICE(
"Setting up radiation tables... " << flush);
97
100
101 ntuple radiation;
102
103 const JRadiation hydrogen ( 1.0, 1.0, 40, 0.01, 0.1, 0.1);
104 const JRadiation oxygen ( 8.0, 16.0, 40, 0.01, 0.1, 0.1);
105 const JRadiation chlorine (17.0, 35.0, 40, 0.01, 0.1, 0.1);
106 const JRadiation sodium (11.0, 23.0, 40, 0.01, 0.1, 0.1);
107
112
113 radiation.push_back(tuple(
new JRadiationSource(11, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), EErad_t), clone(h0,
"[eerad O]" )));
114 radiation.push_back(tuple(
new JRadiationSource(12, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), EErad_t), clone(h0,
"[eerad Cl]")));
115 radiation.push_back(tuple(
new JRadiationSource(13, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), EErad_t), clone(h0,
"[eerad H]" )));
116 radiation.push_back(tuple(
new JRadiationSource(14, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), EErad_t), clone(h0,
"[eerad Na]" )));
117
118 radiation.push_back(tuple(
new JRadiationSource(21, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), Brems_t), clone(h0,
"[Brems O]" )));
119 radiation.push_back(tuple(
new JRadiationSource(22, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), Brems_t), clone(h0,
"[Brems Cl]")));
120 radiation.push_back(tuple(
new JRadiationSource(23, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), Brems_t), clone(h0,
"[Brems H]" )));
121 radiation.push_back(tuple(
new JRadiationSource(24, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), Brems_t), clone(h0,
"[Brems Na]" )));
122
123 radiation.push_back(tuple(
new JRadiationSource(31, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), GNrad_t), clone(h0,
"[gnrad O]" )));
124 radiation.push_back(tuple(
new JRadiationSource(32, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), GNrad_t), clone(h0,
"[gnrad Cl]")));
125 radiation.push_back(tuple(
new JRadiationSource(33, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), GNrad_t), clone(h0,
"[gnrad H]" )));
126 radiation.push_back(tuple(
new JRadiationSource(34, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), GNrad_t), clone(h0,
"[gnrad Na]" )));
127
129
130
131 if (option == LENGTH) {
132
133 for (int i = 1; i <= h0->GetNbinsX(); ++i) {
134
135 const double x = h0->GetBinCenter(i);
136 const double E =
pow(10.0, x);
137
139
140 for (ntuple::iterator p = radiation.begin(); p != radiation.end(); ++p) {
141
142 const double li = p->first->getInverseInteractionLength(E);
143
144 p->second->Fill(x, 1.0/li);
145 }
146 }
148 }
149
150
151 if (option == ENERGY) {
152
153 for (int i = 1; i <= h0->GetNbinsX(); ++i) {
154
155 const double x = h0->GetBinCenter(i);
156 const double E =
pow(10.0, x);
157
159
160 for (ntuple::iterator p = radiation.begin(); p != radiation.end(); ++p) {
161
163
165 Q.
put(p->first->getEnergyOfShower(E));
166 }
167
168 p->second->SetBinContent(i, Q.
getMean());
169
170 }
171 }
173 }
174
175
176 if (option == RANGE) {
177
178 TH1D* Ra = new TH1D("R[analytical]", NULL, 12, 2.0, 8.0);
179 TH1D* Rb = new TH1D("R[numerical]", NULL, 12, 2.0, 8.0);
180
181 for (int i = 1; i <= Ra->GetNbinsX(); ++i) {
182
183 const double x = Ra->GetBinCenter(i);
184 const double E0 =
pow(10.0, x);
185 const double Z = gWater(E0);
186
187 Ra->SetBinContent(i, Z*1e-3);
188 }
189
190 for (
int j = 1;
j <= Rb->GetNbinsX(); ++
j) {
191
192 const double x = Rb->GetBinCenter(j);
193 const double E0 =
pow(10.0, x);
194
196
198
200
201 double E = E0;
202 double z = 0.0;
203
204 while (E >= 0.5) {
205
206 const int N = radiation.size();
207
208 double li[N];
210
211 for (int i = 0; i != N; ++i) {
212 ls += li[i] = radiation[i].first->getInverseInteractionLength(E);
213 }
214
215 double dz = min(gRandom->Exp(1.0) /
ls, gWater(E));
216
217 E -= gWater.getA() * dz;
218
219 double Es = 0.0;
220 double y = gRandom->Uniform(
ls);
221
222 for (int i = 0; i != N; ++i) {
223
225
226 if (y < 0.0) {
227 Es = radiation[i].first->getEnergyOfShower(E);
228 break;
229 }
230 }
231
232 z += dz;
233 E -= Es;
234 }
235
237 }
238
239 Rb->SetBinContent(j, Q.
getMean() * 1e-3);
240
241 }
243 }
244
245
246 if (option == ELOSS) {
247
248 TH1D* hb = new TH1D("hb", NULL, 12, 2.0, 8.0);
249
250 for (
int j = 1;
j <= hb->GetNbinsX(); ++
j) {
251
252 const double x = hb->GetBinCenter(j);
253 const double E =
pow(10.0, x);
254
256
258
259 const int N = radiation.size();
260
261 double li[N];
263
264 for (int i = 0; i != N; ++i) {
265 ls += li[i] = radiation[i].first->getInverseInteractionLength(E);
266 }
267
269
270 double Es = 0.0;
271 double y = gRandom->Uniform(
ls);
272
273 for (int i = 0; i != N; ++i) {
274
276
277 if (y < 0.0) {
278 Es = radiation[i].first->getEnergyOfShower(E);
279 break;
280 }
281 }
282
284 }
285
286 hb->SetBinContent(j, Q.
getMean());
287
288 }
290 }
291
292 delete h0;
293
294 out.Write();
295 out.Close();
296}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
The template JSharedPointer class can be used to share a pointer to an object.
Utility class to parse command line options.
Fast implementation of class JRadiation.
Implementation for calculation of inverse interaction length and shower energy.
Auxiliary class for the calculation of the muon radiative cross sections.
T pow(const T &x, const double y)
Power .
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure to list files in directory.
Auxiliary data structure for floating point format specification.