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