56{
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 TH1* h0 = NULL;
84
85 if (option == LENGTH) {
86 h0 = new TH1D("total", NULL, 160, 2.0, 10.0);
87 }
88
89 if (option == ENERGY) {
90 h0 = new TH1D("total", NULL, 24, 2.0, 10.0);
91 }
92
93 NOTICE(
"Setting up radiation tables... " << flush);
94
97
98 ntuple radiation;
99
100 const JRadiation hydrogen (JSeaWater::H .Z, JSeaWater::H .A, 40, 0.01, 0.1, 0.1);
101 const JRadiation oxygen (JSeaWater::O .Z, JSeaWater::O .A, 40, 0.01, 0.1, 0.1);
102 const JRadiation chlorine (JSeaWater::Cl.Z, JSeaWater::Cl.A, 40, 0.01, 0.1, 0.1);
103 const JRadiation sodium (JSeaWater::Na.Z, JSeaWater::Na.A, 40, 0.01, 0.1, 0.1);
104
105 shared_ptr<JRadiation> Hydrogen (make_shared<JRadiationFunction>(hydrogen, 300, 0.2, 1.0e11));
106 shared_ptr<JRadiation> Oxygen (make_shared<JRadiationFunction>(oxygen, 300, 0.2, 1.0e11));
107 shared_ptr<JRadiation> Chlorine (make_shared<JRadiationFunction>(chlorine, 300, 0.2, 1.0e11));
108 shared_ptr<JRadiation> Sodium (make_shared<JRadiationFunction>(sodium, 300, 0.2, 1.0e11));
109
110 radiation.push_back(tuple(make_shared<JRadiationSource>(11, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), JRadiation::EErad_t), clone(h0, "[eerad O]" )));
111 radiation.push_back(tuple(make_shared<JRadiationSource>(12, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), JRadiation::EErad_t), clone(h0, "[eerad Cl]")));
112 radiation.push_back(tuple(make_shared<JRadiationSource>(13, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), JRadiation::EErad_t), clone(h0, "[eerad H]" )));
113 radiation.push_back(tuple(make_shared<JRadiationSource>(14, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), JRadiation::EErad_t), clone(h0, "[eerad Na]")));
114
115 radiation.push_back(tuple(make_shared<JRadiationSource>(21, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), JRadiation::Brems_t), clone(h0, "[Brems O]" )));
116 radiation.push_back(tuple(make_shared<JRadiationSource>(22, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), JRadiation::Brems_t), clone(h0, "[Brems Cl]")));
117 radiation.push_back(tuple(make_shared<JRadiationSource>(23, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), JRadiation::Brems_t), clone(h0, "[Brems H]" )));
118 radiation.push_back(tuple(make_shared<JRadiationSource>(24, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), JRadiation::Brems_t), clone(h0, "[Brems Na]")));
119
120 radiation.push_back(tuple(make_shared<JRadiationSource>(31, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), JRadiation::GNrad_t), clone(h0, "[gnrad O]" )));
121 radiation.push_back(tuple(make_shared<JRadiationSource>(32, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), JRadiation::GNrad_t), clone(h0, "[gnrad Cl]")));
122 radiation.push_back(tuple(make_shared<JRadiationSource>(33, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), JRadiation::GNrad_t), clone(h0, "[gnrad H]" )));
123 radiation.push_back(tuple(make_shared<JRadiationSource>(34, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), JRadiation::GNrad_t), clone(h0, "[gnrad Na]")));
124
126
127
128 if (option == LENGTH) {
129
130 for (int i = 1; i <= h0->GetNbinsX(); ++i) {
131
132 const double x = h0->GetBinCenter(i);
133 const double E =
pow(10.0, x);
134
136
137 for (ntuple::iterator p = radiation.begin(); p != radiation.end(); ++p) {
138
139 const double li = p->first->getInverseInteractionLength(E);
140
141 p->second->Fill(x, 1.0/li);
142 }
143 }
145 }
146
147
148 if (option == ENERGY) {
149
150 for (int i = 1; i <= h0->GetNbinsX(); ++i) {
151
152 const double x = h0->GetBinCenter(i);
153 const double E =
pow(10.0, x);
154
156
157 for (ntuple::iterator p = radiation.begin(); p != radiation.end(); ++p) {
158
160
162 Q.
put(p->first->getEnergyOfShower(E));
163 }
164
165 p->second->SetBinContent(i, Q.
getMean());
166
167 }
168 }
170 }
171
172
173 if (option == RANGE) {
174
175 TH1D* Ra = new TH1D("R[analytical]", NULL, 12, 2.0, 8.0);
176 TH1D* Rb = new TH1D("R[numerical]", NULL, 12, 2.0, 8.0);
177
178 for (int i = 1; i <= Ra->GetNbinsX(); ++i) {
179
180 const double x = Ra->GetBinCenter(i);
181 const double E0 =
pow(10.0, x);
182 const double Z = gWater(E0);
183
184 Ra->SetBinContent(i, Z*1e-3);
185 }
186
187 for (
int j = 1;
j <= Rb->GetNbinsX(); ++
j) {
188
189 const double x = Rb->GetBinCenter(j);
190 const double E0 =
pow(10.0, x);
191
193
195
197
198 double E = E0;
199 double z = 0.0;
200
201 while (E >= 0.5) {
202
203 const int N = radiation.size();
204
205 double li[N];
207
208 for (int i = 0; i != N; ++i) {
209 ls += li[i] = radiation[i].first->getInverseInteractionLength(E);
210 }
211
212 double dz = min(gRandom->Exp(1.0) /
ls, gWater(E));
213
214 E -= gWater.getA() * dz;
215
216 double Es = 0.0;
217 double y = gRandom->Uniform(
ls);
218
219 for (int i = 0; i != N; ++i) {
220
222
223 if (y < 0.0) {
224 Es = radiation[i].first->getEnergyOfShower(E);
225 break;
226 }
227 }
228
229 z += dz;
230 E -= Es;
231 }
232
234 }
235
236 Rb->SetBinContent(j, Q.
getMean() * 1e-3);
237
238 }
240 }
241
242
243 if (option == ELOSS) {
244
245 TH1D* hb = new TH1D("hb", NULL, 12, 2.0, 8.0);
246
247 for (
int j = 1;
j <= hb->GetNbinsX(); ++
j) {
248
249 const double x = hb->GetBinCenter(j);
250 const double E =
pow(10.0, x);
251
253
255
256 const int N = radiation.size();
257
258 double li[N];
260
261 for (int i = 0; i != N; ++i) {
262 ls += li[i] = radiation[i].first->getInverseInteractionLength(E);
263 }
264
266
267 double Es = 0.0;
268 double y = gRandom->Uniform(
ls);
269
270 for (int i = 0; i != N; ++i) {
271
273
274 if (y < 0.0) {
275 Es = radiation[i].first->getEnergyOfShower(E);
276 break;
277 }
278 }
279
281 }
282
283 hb->SetBinContent(j, Q.
getMean());
284
285 }
287 }
288
289 delete h0;
290
291 out.Write();
292 out.Close();
293}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
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.