]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: geometry | |
3 | // | |
7005154f | 4 | // Author: I. Hrivnacova |
5 | // | |
6 | // Class AliMoreModulesConstruction | |
7 | // -------------------------------- | |
676fb573 | 8 | // See the class description in the header file. |
9 | ||
10 | #include "AliMoreModulesConstruction.h" | |
11 | #include "AliSingleModuleConstruction.h" | |
676fb573 | 12 | #include "AliModule.h" |
676fb573 | 13 | #include "AliGlobals.h" |
e4868b5c | 14 | #include "AliFiles.h" |
676fb573 | 15 | |
16 | #include "TG4GeometryManager.h" | |
17 | ||
676fb573 | 18 | #include <G4LogicalVolume.hh> |
19 | #include <G4LogicalVolumeStore.hh> | |
20 | ||
74d081a0 | 21 | //_____________________________________________________________________________ |
676fb573 | 22 | AliMoreModulesConstruction::AliMoreModulesConstruction() { |
23 | // | |
676fb573 | 24 | } |
25 | ||
74d081a0 | 26 | //_____________________________________________________________________________ |
676fb573 | 27 | AliMoreModulesConstruction::AliMoreModulesConstruction( |
28 | const AliMoreModulesConstruction& right) | |
29 | { | |
58c0119e | 30 | // copy stuff |
31 | *this = right; | |
676fb573 | 32 | } |
33 | ||
34 | ||
74d081a0 | 35 | //_____________________________________________________________________________ |
676fb573 | 36 | AliMoreModulesConstruction::~AliMoreModulesConstruction() |
37 | { | |
38 | // delete module constructions | |
39 | fModuleConstructionVector.erase( | |
40 | fModuleConstructionVector.begin(), fModuleConstructionVector.end()); | |
41 | } | |
42 | ||
43 | // operators | |
44 | ||
74d081a0 | 45 | //_____________________________________________________________________________ |
676fb573 | 46 | AliMoreModulesConstruction& |
47 | AliMoreModulesConstruction::operator=(const AliMoreModulesConstruction& right) | |
48 | { | |
49 | // check assignement to self | |
50 | if (this == &right) return *this; | |
51 | ||
52 | // delete current module constructions | |
53 | fModuleConstructionVector.erase( | |
54 | fModuleConstructionVector.begin(), fModuleConstructionVector.end()); | |
55 | ||
56 | // create new module constructions | |
57 | G4int nofModules = right.fModuleConstructionVector.size(); | |
58 | for (G4int i=0; i<nofModules; i++) { | |
59 | G4String name = right.fModuleConstructionVector[i]->GetDetName(); | |
60 | G4int version = right.fModuleConstructionVector[i]->GetVersion(); | |
61 | AliModuleType type = right.fModuleConstructionVector[i]->GetType(); | |
62 | AddModule(name, version, type); | |
63 | } | |
58c0119e | 64 | |
676fb573 | 65 | return *this; |
66 | } | |
67 | ||
676fb573 | 68 | // public methods |
69 | ||
74d081a0 | 70 | //_____________________________________________________________________________ |
676fb573 | 71 | void AliMoreModulesConstruction::AddModule(G4String moduleName, G4int version, |
72 | AliModuleType moduleType) | |
73 | { | |
74 | // Adds module specified by name, version and type. | |
75 | // --- | |
76 | ||
77 | // create module construction | |
78 | AliSingleModuleConstruction* moduleConstruction | |
79 | = new AliSingleModuleConstruction(moduleName, version, moduleType); | |
80 | ||
81 | // add module, module construction to vectors | |
82 | fModuleConstructionVector.push_back(moduleConstruction); | |
83 | } | |
84 | ||
74d081a0 | 85 | //_____________________________________________________________________________ |
e4868b5c | 86 | void AliMoreModulesConstruction::Configure(const AliFiles& files) |
62022fa8 | 87 | { |
88 | // Executes the detectors setup Root macros | |
89 | // (extracted from AliRoot Config.C) and | |
90 | // G4 macros. | |
91 | // --- | |
92 | ||
93 | // number of modules | |
94 | G4int nofModules = fModuleConstructionVector.size(); | |
95 | ||
96 | if (nofModules == 0) { | |
97 | AliGlobals::Warning( | |
98 | "AliMoreModulesConstruction::Construct(): No modules are defined."); | |
99 | } | |
100 | else | |
101 | for (G4int i=0; i<nofModules; i++) | |
e4868b5c | 102 | fModuleConstructionVector[i]->Configure(files); |
62022fa8 | 103 | } |
104 | ||
74d081a0 | 105 | //_____________________________________________________________________________ |
676fb573 | 106 | void AliMoreModulesConstruction::Construct() |
107 | { | |
108 | // Constructs geometry. | |
109 | // G3 tables are process for all modules alltogether. | |
110 | // -- | |
111 | ||
112 | // number of modules | |
113 | G4int nofModules = fModuleConstructionVector.size(); | |
114 | ||
115 | if (nofModules == 0) { | |
116 | AliGlobals::Warning( | |
117 | "AliMoreModulesConstruction::Construct(): No modules are defined."); | |
118 | } | |
119 | else { | |
120 | // get geometry manager | |
121 | TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance(); | |
122 | ||
676fb573 | 123 | G4int i; |
124 | for (i=0; i<nofModules; i++) { | |
125 | ||
e4868b5c | 126 | // fModuleConstructionVector[i]->Configure(files); |
676fb573 | 127 | |
128 | // register module name in the name map | |
129 | AliModule* module = fModuleConstructionVector[i]->GetAliModule(); | |
130 | pGeometryManager->SetMapSecond(module->GetName()); | |
131 | ||
132 | G4bool readGeometry = fModuleConstructionVector[i]->GetReadGeometry(); | |
133 | G4bool writeGeometry = fModuleConstructionVector[i]->GetWriteGeometry(); | |
134 | G4String dataFilePath = fModuleConstructionVector[i]->GetDataFilePath(); | |
135 | ||
136 | if (readGeometry) { | |
871f5582 | 137 | // TG4GeometryManager uses g3tog4 methods for reading |
138 | // g3calls.dat files - as these methods do not fill name map | |
139 | // they cannot be used for constructing more modules | |
140 | // together | |
141 | // | |
142 | // pGeometryManager->SetWriteGeometry(false); | |
143 | // pGeometryManager->ReadG3Geometry(dataFilePath); | |
144 | ||
145 | G4String text = "AliMoreModulesConstruction::Construct - Limitation:\n"; | |
146 | text = text + " Reading g3calls.dat is not implemented."; | |
147 | AliGlobals::Exception(text); | |
676fb573 | 148 | } |
149 | else { | |
150 | // set geometry output stream for this module | |
151 | pGeometryManager->SetWriteGeometry(writeGeometry); | |
152 | if (writeGeometry) | |
153 | pGeometryManager->OpenOutFile(dataFilePath); | |
154 | ||
155 | // create geometry from AliRoot | |
156 | ||
157 | // construct materials | |
158 | module->CreateMaterials(); | |
159 | ||
160 | // construct G3 geometry | |
161 | module->CreateGeometry(); | |
62022fa8 | 162 | |
871f5582 | 163 | if (writeGeometry) |
164 | pGeometryManager->CloseOutFile(); | |
676fb573 | 165 | } |
676fb573 | 166 | } |
167 | ||
168 | // construct G4 geometry | |
169 | pGeometryManager->CreateG4Geometry(); | |
170 | ||
171 | // print name map | |
172 | // pGeometryManager->PrintNameMap(); | |
74d081a0 | 173 | |
676fb573 | 174 | for (i=0; i<nofModules; i++) { |
175 | // set the detector frame (envelope) | |
176 | // (without warning output if enevelope is not defined) | |
177 | fModuleConstructionVector[i]->SetDetFrame(false); | |
178 | ||
e88c18bd | 179 | // construct geometry for display |
180 | fModuleConstructionVector[i]->GetAliModule()->BuildGeometry(); | |
74d081a0 | 181 | } |
676fb573 | 182 | |
183 | // reset TG4GeometryManager | |
184 | pGeometryManager->ClearG3Tables(); | |
676fb573 | 185 | |
186 | #ifdef ALICE_VISUALIZE | |
187 | // set visualization attributes | |
188 | for (i=0; i<nofModules; i++) { | |
189 | if (fModuleConstructionVector[i]->GetDetFrame()) { | |
190 | fModuleConstructionVector[i]->SetDetVisibility(true); | |
191 | fModuleConstructionVector[i]->SetDetColour("Yellow"); | |
192 | } | |
193 | } | |
194 | #endif | |
195 | } | |
196 | } |