1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // File name: RadmonGeneratorLayout.cc |
---|
28 | // Creation date: Oct 2005 |
---|
29 | // Main author: Riccardo Capra <capra@ge.infn.it> |
---|
30 | // |
---|
31 | // Id: $Id: RadmonGeneratorLayout.cc,v 1.1.2.2 2006/06/29 16:16:25 gunter Exp $ |
---|
32 | // Tag: $Name: geant4-09-01-patch-02 $ |
---|
33 | // |
---|
34 | |
---|
35 | // Include files |
---|
36 | #include "RadmonGeneratorLayout.hh" |
---|
37 | |
---|
38 | void RadmonGeneratorLayout :: InsertSource(const G4String & sourceLabel) |
---|
39 | { |
---|
40 | if (labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
41 | { |
---|
42 | G4cout << "RadmonGeneratorLayout::InsertSource: Source \"" << sourceLabel << "\" just exists." << G4endl; |
---|
43 | return; |
---|
44 | } |
---|
45 | |
---|
46 | RadmonGeneratorSourceLayout & source(labelledSourcesCollection.AppendItem()); |
---|
47 | source.SetLabel(sourceLabel); |
---|
48 | source.SetIntensity(1.); |
---|
49 | NotifyChange(); |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | void RadmonGeneratorLayout :: SetRelativeSourceIntensity(const G4String & sourceLabel, G4double relativeIntensity) |
---|
55 | { |
---|
56 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
57 | { |
---|
58 | G4cout << "RadmonGeneratorLayout::SetRelativeSourceIntensity: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
59 | return; |
---|
60 | } |
---|
61 | |
---|
62 | RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
63 | |
---|
64 | if (source.GetIntensity()!=relativeIntensity) |
---|
65 | { |
---|
66 | source.SetIntensity(relativeIntensity); |
---|
67 | NotifyChange(); |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | G4double RadmonGeneratorLayout :: GetRelativeSourceIntensity(const G4String & sourceLabel) const |
---|
74 | { |
---|
75 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
76 | { |
---|
77 | G4cout << "RadmonGeneratorLayout::GetRelativeSourceIntensity: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
78 | return 0.; |
---|
79 | } |
---|
80 | |
---|
81 | const RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
82 | |
---|
83 | return source.GetIntensity(); |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | void RadmonGeneratorLayout :: RemoveSource(const G4String & sourceLabel) |
---|
89 | { |
---|
90 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
91 | { |
---|
92 | G4cout << "RadmonGeneratorLayout::RemoveSource: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
93 | return; |
---|
94 | } |
---|
95 | |
---|
96 | labelledSourcesCollection.RemoveItemByLabel(sourceLabel); |
---|
97 | NotifyChange(); |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | |
---|
102 | G4int RadmonGeneratorLayout :: GetNSources(void) const |
---|
103 | { |
---|
104 | return labelledSourcesCollection.GetNItems(); |
---|
105 | } |
---|
106 | |
---|
107 | |
---|
108 | |
---|
109 | const G4String & RadmonGeneratorLayout :: GetSourceLabel(G4int index) const |
---|
110 | { |
---|
111 | return labelledSourcesCollection.GetItem(index).GetLabel(); |
---|
112 | } |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | void RadmonGeneratorLayout :: AppendSourceAlgorithm(const G4String & sourceLabel, const G4String & algorithmLabel) |
---|
117 | { |
---|
118 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
119 | { |
---|
120 | G4cout << "RadmonGeneratorLayout::AppendSourceAlgorithm: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
121 | return; |
---|
122 | } |
---|
123 | |
---|
124 | RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
125 | |
---|
126 | if (source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
127 | { |
---|
128 | G4cout << "RadmonGeneratorLayout::AppendSourceAlgorithm: Source \"" << algorithmLabel << "\" just exists in source \"" << sourceLabel << "\"." << G4endl; |
---|
129 | return; |
---|
130 | } |
---|
131 | |
---|
132 | RadmonGeneratorSourceAlgorithmLayout & algorithm(source.AppendAlgorithm()); |
---|
133 | algorithm.SetLabel(algorithmLabel); |
---|
134 | NotifyChange(); |
---|
135 | } |
---|
136 | |
---|
137 | |
---|
138 | |
---|
139 | void RadmonGeneratorLayout :: SetSourceAlgorithmType(const G4String & sourceLabel, const G4String & algorithmLabel, const G4String & typeName) |
---|
140 | { |
---|
141 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
142 | { |
---|
143 | G4cout << "RadmonGeneratorLayout::SetSourceAlgorithmType: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
144 | return; |
---|
145 | } |
---|
146 | |
---|
147 | RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
148 | |
---|
149 | if (! source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
150 | { |
---|
151 | G4cout << "RadmonGeneratorLayout::SetSourceAlgorithmType: Source \"" << algorithmLabel << "\" not found in source \"" << sourceLabel << "\"." << G4endl; |
---|
152 | return; |
---|
153 | } |
---|
154 | |
---|
155 | RadmonGeneratorSourceAlgorithmLayout & algorithm(source.FindAlgorithmByLabel(algorithmLabel)); |
---|
156 | if (algorithm.GetType()!=typeName) |
---|
157 | { |
---|
158 | algorithm.SetType(typeName); |
---|
159 | NotifyChange(); |
---|
160 | } |
---|
161 | } |
---|
162 | |
---|
163 | |
---|
164 | |
---|
165 | void RadmonGeneratorLayout :: RemoveSourceAlgorithm(const G4String & sourceLabel, const G4String & algorithmLabel) |
---|
166 | { |
---|
167 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
168 | { |
---|
169 | G4cout << "RadmonGeneratorLayout::RemoveSourceAlgorithm: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
170 | return; |
---|
171 | } |
---|
172 | |
---|
173 | RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
174 | |
---|
175 | if (! source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
176 | { |
---|
177 | G4cout << "RadmonGeneratorLayout::RemoveSourceAlgorithm: Source \"" << algorithmLabel << "\" not found in source \"" << sourceLabel << "\"." << G4endl; |
---|
178 | return; |
---|
179 | } |
---|
180 | |
---|
181 | source.RemoveAlgorithmByLabel(algorithmLabel); |
---|
182 | NotifyChange(); |
---|
183 | } |
---|
184 | |
---|
185 | |
---|
186 | |
---|
187 | G4int RadmonGeneratorLayout :: GetNSourceAlgorithms(const G4String & sourceLabel) const |
---|
188 | { |
---|
189 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
190 | { |
---|
191 | G4cout << "RadmonGeneratorLayout::GetNSourceAlgorithms: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
192 | return 0; |
---|
193 | } |
---|
194 | |
---|
195 | const RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
196 | |
---|
197 | return source.GetNAlgorithms(); |
---|
198 | } |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | const G4String & RadmonGeneratorLayout :: GetSourceAlgorithmLabel(const G4String & sourceLabel, G4int index) const |
---|
203 | { |
---|
204 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
205 | { |
---|
206 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmLabel: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
207 | return GetNullStr(); |
---|
208 | } |
---|
209 | |
---|
210 | const RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
211 | |
---|
212 | return source.GetAlgorithm(index).GetLabel(); |
---|
213 | } |
---|
214 | |
---|
215 | |
---|
216 | |
---|
217 | const G4String & RadmonGeneratorLayout :: GetSourceAlgorithmType(const G4String & sourceLabel, const G4String & algorithmLabel) const |
---|
218 | { |
---|
219 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
220 | { |
---|
221 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmType: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
222 | return GetNullStr(); |
---|
223 | } |
---|
224 | |
---|
225 | const RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
226 | |
---|
227 | if (! source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
228 | { |
---|
229 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmType: Source \"" << algorithmLabel << "\" not found in source \"" << sourceLabel << "\"." << G4endl; |
---|
230 | return GetNullStr(); |
---|
231 | } |
---|
232 | |
---|
233 | const RadmonGeneratorSourceAlgorithmLayout & algorithm(source.FindAlgorithmByLabel(algorithmLabel)); |
---|
234 | return algorithm.GetType(); |
---|
235 | } |
---|
236 | |
---|
237 | |
---|
238 | |
---|
239 | void RadmonGeneratorLayout :: SetSourceAlgorithmAttribute(const G4String & sourceLabel, const G4String & algorithmLabel, const G4String & attribute, const G4String & value) |
---|
240 | { |
---|
241 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
242 | { |
---|
243 | G4cout << "RadmonGeneratorLayout::SetSourceAlgorithmAttribute: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
244 | return; |
---|
245 | } |
---|
246 | |
---|
247 | RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
248 | |
---|
249 | if (! source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
250 | { |
---|
251 | G4cout << "RadmonGeneratorLayout::SetSourceAlgorithmAttribute: Source \"" << algorithmLabel << "\" not found in source \"" << sourceLabel << "\"." << G4endl; |
---|
252 | return; |
---|
253 | } |
---|
254 | |
---|
255 | RadmonGeneratorSourceAlgorithmLayout & algorithm(source.FindAlgorithmByLabel(algorithmLabel)); |
---|
256 | if (algorithm.GetAttribute(attribute, value+'#')!=value) |
---|
257 | { |
---|
258 | algorithm.SetAttribute(attribute, value); |
---|
259 | NotifyChange(); |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | |
---|
264 | |
---|
265 | void RadmonGeneratorLayout :: ClearSourceAlgorithmAttribute(const G4String & sourceLabel, const G4String & algorithmLabel, const G4String & attribute) |
---|
266 | { |
---|
267 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
268 | { |
---|
269 | G4cout << "RadmonGeneratorLayout::ClearSourceAlgorithmAttribute: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
270 | return; |
---|
271 | } |
---|
272 | |
---|
273 | RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
274 | |
---|
275 | if (! source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
276 | { |
---|
277 | G4cout << "RadmonGeneratorLayout::ClearSourceAlgorithmAttribute: Source \"" << algorithmLabel << "\" not found in source \"" << sourceLabel << "\"." << G4endl; |
---|
278 | return; |
---|
279 | } |
---|
280 | |
---|
281 | RadmonGeneratorSourceAlgorithmLayout & algorithm(source.FindAlgorithmByLabel(algorithmLabel)); |
---|
282 | if (algorithm.ExistsAttribute(attribute)) |
---|
283 | { |
---|
284 | algorithm.ClearAttribute(attribute); |
---|
285 | NotifyChange(); |
---|
286 | } |
---|
287 | } |
---|
288 | |
---|
289 | |
---|
290 | |
---|
291 | G4String RadmonGeneratorLayout :: GetSourceAlgorithmAttribute(const G4String & sourceLabel, const G4String & algorithmLabel, const G4String & attribute, const G4String & defaultValue) const |
---|
292 | { |
---|
293 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
294 | { |
---|
295 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmAttribute: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
296 | return G4String(); |
---|
297 | } |
---|
298 | |
---|
299 | const RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
300 | |
---|
301 | if (! source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
302 | { |
---|
303 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmAttribute: Source \"" << algorithmLabel << "\" not found in source \"" << sourceLabel << "\"." << G4endl; |
---|
304 | return G4String(); |
---|
305 | } |
---|
306 | |
---|
307 | const RadmonGeneratorSourceAlgorithmLayout & algorithm(source.FindAlgorithmByLabel(algorithmLabel)); |
---|
308 | return algorithm.GetAttribute(attribute, defaultValue); |
---|
309 | } |
---|
310 | |
---|
311 | |
---|
312 | |
---|
313 | G4int RadmonGeneratorLayout :: GetSourceAlgorithmNAttributes(const G4String & sourceLabel, const G4String & algorithmLabel) const |
---|
314 | { |
---|
315 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
316 | { |
---|
317 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmNAttributes: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
318 | return 0; |
---|
319 | } |
---|
320 | |
---|
321 | const RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
322 | |
---|
323 | if (! source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
324 | { |
---|
325 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmNAttributes: Source \"" << algorithmLabel << "\" not found in source \"" << sourceLabel << "\"." << G4endl; |
---|
326 | return 0; |
---|
327 | } |
---|
328 | |
---|
329 | const RadmonGeneratorSourceAlgorithmLayout & algorithm(source.FindAlgorithmByLabel(algorithmLabel)); |
---|
330 | return algorithm.GetNAttributes(); |
---|
331 | } |
---|
332 | |
---|
333 | |
---|
334 | |
---|
335 | const G4String & RadmonGeneratorLayout :: GetSourceAlgorithmAttributeName(const G4String & sourceLabel, const G4String & algorithmLabel, G4int index) const |
---|
336 | { |
---|
337 | if (! labelledSourcesCollection.ExistsItemByLabel(sourceLabel)) |
---|
338 | { |
---|
339 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmAttributeName: Source \"" << sourceLabel << "\" not found." << G4endl; |
---|
340 | return GetNullStr(); |
---|
341 | } |
---|
342 | |
---|
343 | const RadmonGeneratorSourceLayout & source(labelledSourcesCollection.FindItemByLabel(sourceLabel)); |
---|
344 | |
---|
345 | if (! source.ExistsAlgorithmByLabel(algorithmLabel)) |
---|
346 | { |
---|
347 | G4cout << "RadmonGeneratorLayout::GetSourceAlgorithmAttributeName: Source \"" << algorithmLabel << "\" not found in source \"" << sourceLabel << "\"." << G4endl; |
---|
348 | return GetNullStr(); |
---|
349 | } |
---|
350 | |
---|
351 | const RadmonGeneratorSourceAlgorithmLayout & algorithm(source.FindAlgorithmByLabel(algorithmLabel)); |
---|
352 | return algorithm.GetAttributeName(index); |
---|
353 | } |
---|
354 | |
---|
355 | |
---|
356 | |
---|
357 | G4bool RadmonGeneratorLayout :: Load(std::istream & /* in */) |
---|
358 | { |
---|
359 | // TO BE DONE |
---|
360 | G4cout << "RadmonGeneratorLayout::Load(): PLEASE CHECK" << G4endl; |
---|
361 | |
---|
362 | return false; |
---|
363 | } |
---|
364 | |
---|
365 | |
---|
366 | |
---|
367 | G4bool RadmonGeneratorLayout :: Save(std::ostream & /* out */) const |
---|
368 | { |
---|
369 | // TO BE DONE |
---|
370 | G4cout << "RadmonGeneratorLayout::Save(): PLEASE CHECK" << G4endl; |
---|
371 | |
---|
372 | return false; |
---|
373 | } |
---|
374 | |
---|
375 | |
---|
376 | |
---|
377 | void RadmonGeneratorLayout :: DumpLayout(std::ostream & out) const |
---|
378 | { |
---|
379 | out << "- Sources:\n"; |
---|
380 | const G4int n(labelledSourcesCollection.GetNItems()); |
---|
381 | |
---|
382 | if (n==0) |
---|
383 | { |
---|
384 | out << " - No sources defined.\n"; |
---|
385 | return; |
---|
386 | } |
---|
387 | |
---|
388 | const G4String indent(" - "); |
---|
389 | |
---|
390 | for(G4int i(0); i<n; i++) |
---|
391 | { |
---|
392 | out << " - Source # " << i << '\n'; |
---|
393 | |
---|
394 | labelledSourcesCollection.GetItem(i).DumpLayout(out, indent); |
---|
395 | } |
---|
396 | } |
---|
397 | |
---|
398 | |
---|
399 | |
---|
400 | |
---|
401 | |
---|
402 | inline G4String & RadmonGeneratorLayout :: GetNullStr() const |
---|
403 | { |
---|
404 | static G4String nullStr(""); |
---|
405 | |
---|
406 | return nullStr; |
---|
407 | } |
---|