]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: geometry | |
3 | // | |
ad42298e | 4 | // Author: I. Hrivnacova |
5 | // | |
6 | // Class AliModulesComposition | |
7 | // --------------------------- | |
676fb573 | 8 | // See the class description in the header file. |
9 | ||
10 | #include "AliModulesComposition.h" | |
80ed9a99 | 11 | #include "AliModuleConstruction.h" |
676fb573 | 12 | #include "AliMagneticField.h" |
13 | #include "AliGlobals.h" | |
55ebdd9f | 14 | #include "AliFiles.h" |
80ed9a99 | 15 | #include "AliModule.h" |
676fb573 | 16 | |
93debb41 | 17 | #include "TG4GeometryManager.h" |
7b34522f | 18 | |
7b34522f | 19 | #include <G4Material.hh> |
676fb573 | 20 | |
93debb41 | 21 | //_____________________________________________________________________________ |
676fb573 | 22 | AliModulesComposition::AliModulesComposition() |
e980662a | 23 | : AliVerbose("modulesComposition"), |
24 | fReadGeometry(false), | |
9b0f6db2 | 25 | fWriteGeometry(false), |
ad42298e | 26 | fMagneticField(0), |
80ed9a99 | 27 | fMessenger(this) { |
676fb573 | 28 | // |
676fb573 | 29 | } |
30 | ||
93debb41 | 31 | //_____________________________________________________________________________ |
676fb573 | 32 | AliModulesComposition::AliModulesComposition(const AliModulesComposition& right) |
e980662a | 33 | : AliVerbose("modulesComposition"), |
34 | fMessenger(this) | |
676fb573 | 35 | { |
36 | // | |
37 | AliGlobals::Exception("AliModulesComposition is protected from copying."); | |
38 | } | |
39 | ||
93debb41 | 40 | //_____________________________________________________________________________ |
676fb573 | 41 | AliModulesComposition::~AliModulesComposition() { |
42 | // | |
676fb573 | 43 | delete fMagneticField; |
676fb573 | 44 | } |
45 | ||
46 | // operators | |
47 | ||
93debb41 | 48 | //_____________________________________________________________________________ |
676fb573 | 49 | AliModulesComposition& |
50 | AliModulesComposition::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 | ||
80ed9a99 | 60 | // |
61 | // private methods | |
62 | // | |
676fb573 | 63 | |
93debb41 | 64 | //_____________________________________________________________________________ |
80ed9a99 | 65 | void AliModulesComposition::Configure() |
66 | { | |
67 | // Executes the detectors setup Root macros | |
68 | // (extracted from AliRoot Config.C) and | |
69 | // G4 macros. | |
676fb573 | 70 | // --- |
80ed9a99 | 71 | |
72 | // number of modules | |
73 | G4int nofModules = fModuleConstructionVector.size(); | |
676fb573 | 74 | |
80ed9a99 | 75 | if (nofModules == 0) { |
76 | AliGlobals::Warning( | |
77 | "AliModulesComposition::Configure: No modules are defined."); | |
78 | return; | |
79 | } | |
676fb573 | 80 | |
80ed9a99 | 81 | for (G4int i=0; i<nofModules; i++) |
82 | fModuleConstructionVector[i]->Configure(); | |
83 | } | |
676fb573 | 84 | |
676fb573 | 85 | |
93debb41 | 86 | //_____________________________________________________________________________ |
80ed9a99 | 87 | void AliModulesComposition::CreateG4Geometry() |
88 | { | |
89 | // Constructs geometry. | |
90 | // G3 tables are process for all modules alltogether. | |
91 | // -- | |
676fb573 | 92 | |
80ed9a99 | 93 | // number of modules |
94 | G4int nofModules = fModuleConstructionVector.size(); | |
95 | ||
96 | if (nofModules == 0) { | |
97 | AliGlobals::Warning( | |
98 | "AliModulesComposition::CreateG4Geometry: No modules are defined."); | |
99 | return; | |
100 | } | |
101 | ||
102 | // get geometry manager | |
103 | TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance(); | |
104 | ||
105 | G4int i; | |
106 | for (i=0; i<nofModules; i++) { | |
107 | ||
108 | // fModuleConstructionVector[i]->Configure(files); | |
676fb573 | 109 | |
80ed9a99 | 110 | // register module name in the name map |
111 | AliModule* module = fModuleConstructionVector[i]->GetAliModule(); | |
112 | pGeometryManager->SetMapSecond(module->GetName()); | |
113 | ||
114 | G4bool readGeometry = fModuleConstructionVector[i]->GetReadGeometry(); | |
115 | G4bool writeGeometry = fModuleConstructionVector[i]->GetWriteGeometry(); | |
116 | G4String dataFilePath = fModuleConstructionVector[i]->GetDataFilePath(); | |
117 | ||
118 | if (readGeometry) { | |
119 | // TG4GeometryManager uses g3tog4 methods for reading | |
120 | // g3calls.dat files - as these methods do not fill name map | |
121 | // they cannot be used for constructing more modules | |
122 | // together | |
123 | // | |
124 | // pGeometryManager->SetWriteGeometry(false); | |
125 | // pGeometryManager->ReadG3Geometry(dataFilePath); | |
126 | ||
127 | G4String text = "AliModulesComposition::Construct - Limitation:\n"; | |
128 | text = text + " Reading g3calls.dat is not implemented."; | |
129 | AliGlobals::Exception(text); | |
130 | } | |
131 | else { | |
132 | // set geometry output stream for this module | |
133 | pGeometryManager->SetWriteGeometry(writeGeometry); | |
134 | if (writeGeometry) | |
135 | pGeometryManager->OpenOutFile(dataFilePath); | |
136 | ||
137 | // create geometry from AliRoot | |
138 | ||
139 | // construct materials | |
140 | module->CreateMaterials(); | |
141 | ||
142 | // construct G3 geometry | |
143 | module->CreateGeometry(); | |
144 | ||
145 | if (writeGeometry) | |
146 | pGeometryManager->CloseOutFile(); | |
147 | } | |
676fb573 | 148 | } |
80ed9a99 | 149 | |
150 | // construct G4 geometry | |
151 | pGeometryManager->CreateG4Geometry(); | |
676fb573 | 152 | |
80ed9a99 | 153 | // print name map |
154 | // pGeometryManager->PrintNameMap(); | |
7fe075c8 | 155 | |
80ed9a99 | 156 | for (i=0; i<nofModules; i++) { |
ad42298e | 157 | |
80ed9a99 | 158 | // construct geometry for display |
159 | fModuleConstructionVector[i]->GetAliModule()->BuildGeometry(); | |
160 | } | |
161 | ||
162 | // reset TG4GeometryManager | |
163 | pGeometryManager->ClearG3Tables(); | |
164 | } | |
7fe075c8 | 165 | |
93debb41 | 166 | //_____________________________________________________________________________ |
676fb573 | 167 | void AliModulesComposition::SetReadGeometryToModules(G4bool readGeometry) |
168 | { | |
169 | // Sets readGeometry control to all modules. | |
170 | // --- | |
171 | ||
80ed9a99 | 172 | for (G4int i=0; i<fModuleConstructionVector.size(); i++) |
173 | fModuleConstructionVector[i]->SetReadGeometry(readGeometry); | |
676fb573 | 174 | } |
175 | ||
93debb41 | 176 | //_____________________________________________________________________________ |
676fb573 | 177 | void AliModulesComposition::SetWriteGeometryToModules(G4bool writeGeometry) |
178 | { | |
179 | // Sets writeGeometry control to all modules. | |
180 | // --- | |
181 | ||
80ed9a99 | 182 | for (G4int i=0; i<fModuleConstructionVector.size(); i++) |
183 | fModuleConstructionVector[i]->SetWriteGeometry(writeGeometry); | |
676fb573 | 184 | } |
185 | ||
80ed9a99 | 186 | // |
187 | // protected methods | |
188 | // | |
676fb573 | 189 | |
93debb41 | 190 | //_____________________________________________________________________________ |
80ed9a99 | 191 | void AliModulesComposition::AddModule(const G4String& name, |
192 | G4int version, | |
193 | AliModuleType moduleType) | |
194 | { | |
195 | // Adds module to the module construction vector. | |
676fb573 | 196 | // --- |
197 | ||
80ed9a99 | 198 | AliModuleConstruction* moduleConstruction |
199 | = new AliModuleConstruction(name, version, moduleType); | |
676fb573 | 200 | |
80ed9a99 | 201 | fModuleConstructionVector.push_back(moduleConstruction); |
202 | } | |
203 | ||
93debb41 | 204 | //_____________________________________________________________________________ |
80ed9a99 | 205 | void AliModulesComposition::ConstructModules() |
206 | { | |
207 | // Construct geometry of all modules (both standalone and dependent.) | |
676fb573 | 208 | // --- |
209 | ||
80ed9a99 | 210 | // set common options |
211 | SetReadGeometryToModules(fReadGeometry); | |
212 | SetWriteGeometryToModules(fWriteGeometry); | |
213 | ||
214 | // configure modules | |
215 | Configure(); | |
676fb573 | 216 | |
80ed9a99 | 217 | // construct dependent modules |
218 | CreateG4Geometry(); | |
219 | } | |
676fb573 | 220 | |
93debb41 | 221 | //_____________________________________________________________________________ |
80ed9a99 | 222 | void AliModulesComposition::SetProcessConfigToModules(G4bool processConfig) |
223 | { | |
224 | // Sets processConfig control to all modules. | |
676fb573 | 225 | // --- |
226 | ||
80ed9a99 | 227 | for (G4int i=0; i<fModuleConstructionVector.size(); i++) |
228 | fModuleConstructionVector[i]->SetProcessConfig(processConfig); | |
229 | } | |
676fb573 | 230 | |
80ed9a99 | 231 | // |
232 | // public methods | |
233 | // | |
676fb573 | 234 | |
93debb41 | 235 | //_____________________________________________________________________________ |
7b34522f | 236 | void AliModulesComposition::PrintMaterials() const |
237 | { | |
238 | // Prints all materials. | |
239 | // --- | |
240 | ||
241 | const G4MaterialTable* matTable = G4Material::GetMaterialTable(); | |
242 | G4cout << *matTable; | |
243 | } | |
244 | ||
93debb41 | 245 | //_____________________________________________________________________________ |
676fb573 | 246 | void AliModulesComposition::SetMagField(G4double fieldValue) |
247 | { | |
248 | // Sets uniform magnetic field to specified value. | |
249 | // --- | |
9b0f6db2 | 250 | |
251 | // create fields if it does not exist | |
252 | if (!fMagneticField) fMagneticField = new AliMagneticField(); | |
253 | ||
254 | // set value | |
255 | fMagneticField->SetFieldValue(fieldValue); | |
676fb573 | 256 | } |
257 |