]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliModulesComposition.cxx
removed obsolete comments only
[u/mrichter/AliRoot.git] / AliGeant4 / AliModulesComposition.cxx
CommitLineData
676fb573 1// $Id$
2// Category: geometry
3//
4// See the class description in the header file.
5
6#include "AliModulesComposition.h"
7#include "AliModulesCompositionMessenger.h"
8#include "AliSingleModuleConstruction.h"
9#include "AliMoreModulesConstruction.h"
10#include "AliMagneticField.h"
11#include "AliGlobals.h"
12
13#include <G4UniformMagField.hh>
14#include <G4FieldManager.hh>
15#include <G4TransportationManager.hh>
16
17AliModulesComposition::AliModulesComposition()
18 : fAllLVSensitive(false),
19 fReadGeometry(false),
20 fWriteGeometry(false)
21{
22//
23 fMoreModulesConstruction = new AliMoreModulesConstruction();
24 fMagneticField = new AliMagneticField();
25 fMessenger = new AliModulesCompositionMessenger(this);
26}
27
28AliModulesComposition::AliModulesComposition(const AliModulesComposition& right)
29{
30//
31 AliGlobals::Exception("AliModulesComposition is protected from copying.");
32}
33
34AliModulesComposition::~AliModulesComposition() {
35//
36 delete fMoreModulesConstruction;
37 delete fMagneticField;
38 delete fMessenger;
39
40 // destroy det switch vector
41 fDetSwitchVector.clearAndDestroy();
42
43 // destroy det construction vector
44 fModuleConstructionVector.clearAndDestroy();
45}
46
47// operators
48
49AliModulesComposition&
50AliModulesComposition::operator=(const AliModulesComposition& right)
51{
52 // check assignement to self
53 if (this == &right) return *this;
54
55 AliGlobals::Exception("AliModulesComposition is protected from assigning.");
56
57 return *this;
58}
59
60// protected methods
61
62void AliModulesComposition::AddDetSwitch(AliDetSwitch* detSwitch)
63{
64// Adds detSwitch to the detSwitch vector.
65// ---
66
67 fDetSwitchVector.insert(detSwitch);
68 fMessenger->SetCandidates();
69}
70
71void AliModulesComposition::AddSingleModuleConstruction(G4String moduleName,
72 G4int version, AliModuleType moduleType)
73{
74// Adds SingleModuleConstruction.
75// ---
76
77 AliSingleModuleConstruction* moduleConstruction
78 = new AliSingleModuleConstruction(moduleName, version, moduleType);
79 fModuleConstructionVector.insert(moduleConstruction);
80}
81
82void AliModulesComposition::AddMoreModuleConstruction(G4String moduleName,
83 G4int version, AliModuleType moduleType)
84{
85// Adds module to MoreModulesConstruction (construction of dependent
86// modules.)
87// ---
88
89 fMoreModulesConstruction->AddModule(moduleName, version, moduleType);
90}
91
92void AliModulesComposition::ConstructModules()
93{
94// Construct geometry of all modules (both standalone and dependent.)
95// ---
96
97 // set common options
98 SetReadGeometryToModules(fReadGeometry);
99 SetWriteGeometryToModules(fWriteGeometry);
100 SetAllLVSensitiveToModules(fAllLVSensitive);
101 // common setAllLVSensitive is overridden by Config.in
102 // macro
103
104 // one module constructions
105 G4int nofDets = fModuleConstructionVector.entries();
106 for (G4int i=0; i<nofDets; i++) {
107 G4cout << "Module " << fModuleConstructionVector[i]->GetDetName()
108 << " will be constructed now." << endl;
109 fModuleConstructionVector[i]->Construct();
110 }
111
112 // more modules construction
113 G4int nofModules = fMoreModulesConstruction->GetNofModules();
114 if (nofModules>0) {
115 G4cout << "Dependent modules will be constructed now." << endl;
116 fMoreModulesConstruction->Construct();
117 }
118}
119
120void AliModulesComposition::SetReadGeometryToModules(G4bool readGeometry)
121{
122// Sets readGeometry control to all modules.
123// ---
124
125 // single module constructions
126 G4int nofDets = fModuleConstructionVector.entries();
127 G4int i;
128 for (i=0; i<nofDets; i++)
129 fModuleConstructionVector[i]->SetReadGeometry(readGeometry);
130
131 // more modules construction
132 nofDets = fMoreModulesConstruction->GetNofModules();
133 for (i=0; i<nofDets; i++) {
134 AliSingleModuleConstruction* moduleConstruction
135 = fMoreModulesConstruction->GetModuleConstruction(i);
136 moduleConstruction->SetReadGeometry(readGeometry);
137 }
138}
139
140void AliModulesComposition::SetWriteGeometryToModules(G4bool writeGeometry)
141{
142// Sets writeGeometry control to all modules.
143// ---
144
145 // single module constructions
146 G4int nofDets = fModuleConstructionVector.entries();
147 G4int i;
148 for (i=0; i<nofDets; i++)
149 fModuleConstructionVector[i]->SetWriteGeometry(writeGeometry);
150
151 // more modules construction
152 nofDets = fMoreModulesConstruction->GetNofModules();
153 for (i=0; i<nofDets; i++) {
154 AliSingleModuleConstruction* moduleConstruction
155 = fMoreModulesConstruction->GetModuleConstruction(i);
156 moduleConstruction->SetWriteGeometry(writeGeometry);
157 }
158}
159
160void AliModulesComposition::SetAllLVSensitiveToModules(G4bool allSensitive)
161{
162// Sets setAllSensitive control to all modules.
163// ---
164
165 // single module constructions
166 G4int nofDets = fModuleConstructionVector.entries();
167 G4int i;
168 for (i=0; i<nofDets; i++) {
169 AliSingleModuleConstruction* moduleConstruction
170 = dynamic_cast<AliSingleModuleConstruction*>(fModuleConstructionVector[i]);
171 if (!moduleConstruction) {
172 G4String text = "AliModulesComposition::SetProcessConfig: \n";
173 text = text + " Unknown module construction type.";
174 AliGlobals::Exception(text);
175 }
176 moduleConstruction->SetAllLVSensitive(allSensitive);
177 }
178
179 // more modules construction
180 nofDets = fMoreModulesConstruction->GetNofModules();
181 for (i=0; i<nofDets; i++) {
182 AliSingleModuleConstruction* moduleConstruction
183 = fMoreModulesConstruction->GetModuleConstruction(i);
184 moduleConstruction->SetAllLVSensitive(allSensitive);
185 }
186}
187
188void AliModulesComposition::SetProcessConfigToModules(G4bool processConfig)
189{
190// Sets processConfig control to all modules.
191// ---
192
193 // single module constructions
194 G4int nofDets = fModuleConstructionVector.entries();
195 G4int i;
196 for (i=0; i<nofDets; i++) {
197 AliSingleModuleConstruction* moduleConstruction
198 = dynamic_cast<AliSingleModuleConstruction*>(fModuleConstructionVector[i]);
199 if (!moduleConstruction) {
200 G4String text = "AliModulesComposition::SetProcessConfig: \n";
201 text = text + " Unknown module construction type.";
202 AliGlobals::Exception(text);
203 }
204 moduleConstruction->SetProcessConfig(processConfig);
205 }
206
207 // more modules construction
208 nofDets = fMoreModulesConstruction->GetNofModules();
209 for (i=0; i<nofDets; i++) {
210 AliSingleModuleConstruction* moduleConstruction
211 = fMoreModulesConstruction->GetModuleConstruction(i);
212 moduleConstruction->SetProcessConfig(processConfig);
213 }
214}
215
216// public methods
217
218void AliModulesComposition::SwitchDetOn(G4String moduleNameVer)
219{
220// Switchs on module specified by name and version.
221// ---
222
223 G4int nofDets = fDetSwitchVector.entries();
224 if (moduleNameVer == "ALL") {
225 for (G4int id=0; id<nofDets; id++) {
226 G4int defaultVersion = fDetSwitchVector[id]->GetDefaultVersion();
227 fDetSwitchVector[id]->SwitchOn(defaultVersion);
228 }
229 }
230 else if (moduleNameVer == "NONE") {
231 for (G4int id=0; id<nofDets; id++)
232 fDetSwitchVector[id]->SwitchOff();
233 }
234 else {
235 // get version number
236 G4int len = moduleNameVer.length();
237 G4String moduleName = moduleNameVer(0, len-1);
238 G4String version = moduleNameVer(len-1, 1);
239 G4int iVersion = AliGlobals::StringToInt(version);
240
241 if (iVersion < 0) {
242 // in case the version number is not provided
243 // the default one is set
244 SwitchDetOnDefault(moduleNameVer);
245 }
246 else
247 SwitchDetOn(moduleName, iVersion);
248 }
249}
250
251void AliModulesComposition::SwitchDetOn(G4String moduleName, G4int version)
252{
253// Switchs on module specified by name and version.
254// ---
255
256 G4int nofDets = fDetSwitchVector.entries();
257 for (G4int id=0; id<nofDets; id++) {
258 G4String iDetName = fDetSwitchVector[id]->GetDetName();
259 if (iDetName == moduleName) {
260 fDetSwitchVector[id]->SwitchOn(version);
261 return;
262 }
263 }
264 AliGlobals::Exception(
265 "AliModulesComposition: Wrong detector name for " + moduleName + ".");
266}
267
268void AliModulesComposition::SwitchDetOnDefault(G4String moduleName)
269{
270// Switchs on module specified by name with default version.
271// ---
272
273 G4int nofDets = fDetSwitchVector.entries();
274 for (G4int id=0; id<nofDets; id++) {
275 G4String iDetName = fDetSwitchVector[id]->GetDetName();
276 if (iDetName == moduleName) {
277 fDetSwitchVector[id]->SwitchOnDefault();
278 return;
279 }
280 }
281 AliGlobals::Exception(
282 "AliModulesComposition: Wrong detector name for " + moduleName + ".");
283}
284
285void AliModulesComposition::SwitchDetOff(G4String moduleName)
286{
287// Switchs off module specified by name.
288// ---
289
290 G4int nofDets = fDetSwitchVector.entries();
291 if (moduleName == "ALL") {
292 for (G4int id=0; id<nofDets; id++)
293 fDetSwitchVector[id]->SwitchOff();
294 }
295 else {
296 for (G4int id=0; id<nofDets; id++) {
297 G4String iDetName = fDetSwitchVector[id]->GetDetName();
298 if (iDetName == moduleName) {
299 fDetSwitchVector[id]->SwitchOff();
300 return;
301 }
302 }
303 }
304 AliGlobals::Exception(
305 "AliModulesComposition: Wrong detector name for " + moduleName + ".");
306}
307
308void AliModulesComposition::PrintSwitchedDets() const
309{
310// Lists switched detectors.
311// ---
312
313 G4String svList = GetSwitchedDetsList();
314
315 G4cout << "Switched Alice detectors: " << endl;
316 G4cout << "--------------------------" << endl;
317 G4cout << svList << endl;
318}
319
320void AliModulesComposition::PrintAvailableDets() const
321{
322// Lists available detectors.
323// ---
324
325 G4String avList = GetAvailableDetsList();
326
327 G4cout << "Available Alice detectors: " << endl;
328 G4cout << "---------------------------" << endl;
329 G4cout << avList << endl;
330}
331
332G4String AliModulesComposition::GetSwitchedDetsList() const
333{
334// Returns list of switched detectors.
335// ---
336
337 G4String svList = "";
338
339 G4int nofDets = fDetSwitchVector.entries();
340 G4int nofSwitchedDets = 0;
341 for (G4int id=0; id<nofDets; id++) {
342 G4int iVersion = fDetSwitchVector[id]->GetSwitchedVersion();
343 if (iVersion > -1) {
344 nofSwitchedDets++;
345 G4String moduleNameVer = fDetSwitchVector[id]->GetDetName();
346 AliGlobals::AppendNumberToString(moduleNameVer, iVersion);
347 svList += moduleNameVer;
348 svList += " ";
349 }
350 }
351
352 if (nofSwitchedDets == nofDets) svList = "ALL: " + svList;
353 if (nofSwitchedDets == 0) svList = "NONE";
354
355 return svList;
356}
357
358const G4RWTPtrOrderedVector<AliDetSwitch>&
359AliModulesComposition::GetDetSwitchVector() const
360{
361// Returns detSwitch vector.
362// ---
363
364 //const AliDetSwitchVector& vector = fDetSwitchVector;
365 const G4RWTPtrOrderedVector<AliDetSwitch>& vector = fDetSwitchVector;
366 return vector;
367}
368
369G4String AliModulesComposition::GetAvailableDetsList() const
370{
371// Returns list of available detectors.
372// ---
373
374 G4String svList = "";
375
376 G4int nofDets = fDetSwitchVector.entries();
377 for (G4int id=0; id<nofDets; id++) {
378 G4int nofVersions = fDetSwitchVector[id]->GetNofVersions();
379 for (G4int iv=0; iv<nofVersions; iv++) {
380 G4String moduleNameVer = fDetSwitchVector[id]->GetDetName();
381 AliGlobals::AppendNumberToString(moduleNameVer, iv);
382 svList += moduleNameVer;
383 svList += " ";
384 }
385 }
386
387 return svList;
388}
389
390G4String AliModulesComposition::GetAvailableDetsListWithCommas() const
391{
392// Returns list of available detectors with commas.
393// ---
394
395 G4String svList = "";
396
397 G4int nofDets = fDetSwitchVector.entries();
398 for (G4int id=0; id<nofDets; id++) {
399 G4int nofVersions = fDetSwitchVector[id]->GetNofVersions();
400 for (G4int iv=0; iv<nofVersions; iv++) {
401 G4String moduleNameVer = fDetSwitchVector[id]->GetDetName();
402 AliGlobals::AppendNumberToString(moduleNameVer, iv);
403 svList += moduleNameVer;
404 if (iv<nofVersions-1) svList += "/";
405 else if (id < nofDets-1) svList += ", ";
406 }
407 }
408
409 return svList;
410}
411
412G4String AliModulesComposition::GetDetNamesList() const
413{
414// Returns list of detector names.
415// ---
416
417 G4String svList = "";
418
419 G4int nofDets = fDetSwitchVector.entries();
420 for (G4int id=0; id<nofDets; id++) {
421 svList += fDetSwitchVector[id]->GetDetName();
422 svList += " ";
423 }
424
425 return svList;
426}
427
428G4String AliModulesComposition::GetDetNamesListWithCommas() const
429{
430// Returns list of detector names with commas.
431// ---
432
433 G4String svList = "";
434
435 G4int nofDets = fDetSwitchVector.entries();
436 for (G4int id=0; id<nofDets; id++) {
437 svList += fDetSwitchVector[id]->GetDetName();
438 if (id < nofDets-1) svList += ", ";
439 }
440
441 return svList;
442}
443
444void AliModulesComposition::SetMagField(G4double fieldValue)
445{
446// Sets uniform magnetic field to specified value.
447// ---
71b66096 448 if (fMagneticField)
449 fMagneticField->SetFieldValue(fieldValue);
676fb573 450}
451