]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: geometry | |
3 | // | |
4ecb3cfd | 4 | // Author: I. Hrivnacova |
5 | // | |
6 | // Class AliModuleConstruction | |
7 | // --------------------------- | |
676fb573 | 8 | // See the class description in the header file. |
9 | ||
10 | #include "AliModuleConstruction.h" | |
11 | #include "AliGlobals.h" | |
12 | #include "AliLVStructure.h" | |
c97337f9 | 13 | #include "AliModule.h" |
676fb573 | 14 | #ifdef ALICE_VISUALIZE |
15 | #include "AliColourStore.h" | |
4ecb3cfd | 16 | #endif |
17 | ||
18 | #include "TG4GeometryServices.h" | |
676fb573 | 19 | |
676fb573 | 20 | #include <G4LogicalVolumeStore.hh> |
21 | #include <G4LogicalVolume.hh> | |
4ecb3cfd | 22 | #ifdef ALICE_VISUALIZE |
23 | #include <G4Colour.hh> | |
24 | #include <G4VisAttributes.hh> | |
25 | #endif | |
676fb573 | 26 | |
78ca1e9c | 27 | //_____________________________________________________________________________ |
4ecb3cfd | 28 | AliModuleConstruction::AliModuleConstruction(const G4String& moduleName) |
676fb573 | 29 | : fModuleName(moduleName), |
30 | fModuleFrameName(moduleName), | |
31 | fModuleFrameLV(0), | |
32 | fAliModule(0), | |
33 | fReadGeometry(false), | |
34 | fWriteGeometry(false), | |
4ecb3cfd | 35 | fDataFilePath(""), |
36 | fMessenger(this, moduleName) { | |
676fb573 | 37 | // |
676fb573 | 38 | } |
39 | ||
78ca1e9c | 40 | //_____________________________________________________________________________ |
676fb573 | 41 | AliModuleConstruction::AliModuleConstruction(const AliModuleConstruction& right) |
4ecb3cfd | 42 | : fMessenger(this, right.fModuleName) |
676fb573 | 43 | { |
44 | // | |
58c0119e | 45 | // copy stuff |
46 | *this = right; | |
676fb573 | 47 | } |
48 | ||
78ca1e9c | 49 | //_____________________________________________________________________________ |
676fb573 | 50 | AliModuleConstruction::AliModuleConstruction() |
51 | : fModuleName(""), | |
52 | fModuleFrameName(""), | |
53 | fModuleFrameLV(0), | |
676fb573 | 54 | fAliModule(0), |
55 | fReadGeometry(false), | |
56 | fWriteGeometry(false), | |
4ecb3cfd | 57 | fDataFilePath(""), |
58 | fMessenger(this, "") { | |
676fb573 | 59 | // |
60 | } | |
61 | ||
78ca1e9c | 62 | //_____________________________________________________________________________ |
676fb573 | 63 | AliModuleConstruction::~AliModuleConstruction() |
64 | { | |
65 | // | |
676fb573 | 66 | delete fAliModule; |
67 | } | |
68 | ||
69 | // operators | |
70 | ||
78ca1e9c | 71 | //_____________________________________________________________________________ |
676fb573 | 72 | AliModuleConstruction& |
73 | AliModuleConstruction::operator=(const AliModuleConstruction& right) | |
74 | { | |
75 | // check assignement to self | |
76 | if (this == &right) return *this; | |
77 | ||
78 | fModuleName = right.fModuleName; | |
79 | fModuleFrameName = right.fModuleFrameName; | |
80 | fModuleFrameLV = right.fModuleFrameLV; | |
81 | fAliModule = right.fAliModule; | |
82 | fReadGeometry = right.fReadGeometry; | |
83 | fWriteGeometry = right.fWriteGeometry; | |
84 | fDataFilePath = right.fDataFilePath; | |
4ecb3cfd | 85 | //fMessenger = right.fMessenger; |
58c0119e | 86 | |
676fb573 | 87 | return *this; |
88 | } | |
89 | ||
78ca1e9c | 90 | //_____________________________________________________________________________ |
676fb573 | 91 | G4int |
92 | AliModuleConstruction::operator==(const AliModuleConstruction& right) const | |
93 | { | |
94 | // | |
95 | return 0; | |
96 | } | |
97 | ||
78ca1e9c | 98 | //_____________________________________________________________________________ |
676fb573 | 99 | G4int |
100 | AliModuleConstruction::operator!=(const AliModuleConstruction& right) const | |
101 | { | |
102 | // | |
103 | G4int returnValue = 1; | |
104 | if (*this == right) returnValue = 0; | |
105 | ||
106 | return returnValue; | |
107 | } | |
108 | ||
109 | // protected methods | |
110 | ||
78ca1e9c | 111 | //_____________________________________________________________________________ |
676fb573 | 112 | void AliModuleConstruction::RegisterLogicalVolume(G4LogicalVolume* lv, |
113 | G4String path, AliLVStructure& lvStructure) | |
114 | { | |
115 | // Registers logical volume lv in the structure. | |
116 | // --- | |
117 | ||
118 | G4String lvName = lv->GetName(); | |
119 | lvStructure.AddNewVolume(lv, path); | |
120 | ||
121 | // register daughters | |
122 | G4int nofDaughters = lv->GetNoDaughters(); | |
123 | if (nofDaughters>0) { | |
124 | G4String previousName = ""; | |
125 | for (G4int i=0; i<nofDaughters; i++) { | |
126 | G4LogicalVolume* lvd = lv->GetDaughter(i)->GetLogicalVolume(); | |
127 | G4String currentName = lvd->GetName(); | |
128 | if (currentName != lvName && currentName != previousName) { | |
129 | G4String newPath = path + lvName +"/"; | |
130 | RegisterLogicalVolume(lvd, newPath, lvStructure); | |
131 | previousName = currentName; | |
132 | } | |
133 | } | |
134 | } | |
135 | } | |
136 | ||
137 | // public methods | |
138 | ||
78ca1e9c | 139 | //_____________________________________________________________________________ |
676fb573 | 140 | void AliModuleConstruction::SetDetFrame(G4bool warn) |
141 | { | |
142 | // The logical volume with name identical with | |
143 | // fModuleName is retrieved from G4LogicalVolumeStore. | |
144 | // --- | |
145 | ||
4ecb3cfd | 146 | fModuleFrameLV |
147 | = TG4GeometryServices::Instance()->FindLogicalVolume(fModuleFrameName, true); | |
676fb573 | 148 | |
149 | if (fModuleFrameLV == 0 && warn) { | |
150 | G4String text = "AliModuleConstruction: Detector frame for "; | |
151 | text = text + fModuleFrameName + " has not been found."; | |
152 | AliGlobals::Warning(text); | |
153 | } | |
154 | } | |
155 | ||
78ca1e9c | 156 | //_____________________________________________________________________________ |
676fb573 | 157 | void AliModuleConstruction::SetDetFrame(G4String frameName, G4bool warn) |
158 | { | |
159 | // The logical volume with frameName | |
160 | // is retrieved from G4LogicalVolumeStore. | |
161 | // --- | |
162 | ||
163 | fModuleFrameName = frameName; | |
164 | SetDetFrame(warn); | |
165 | } | |
166 | ||
78ca1e9c | 167 | //_____________________________________________________________________________ |
676fb573 | 168 | void AliModuleConstruction::ListAllLVTree() |
169 | { | |
170 | // Lists all logical volumes tree if the frame logical volume | |
171 | // is defined. | |
172 | // ---- | |
173 | ||
174 | if (fModuleFrameLV) | |
175 | ListLVTree(fModuleFrameLV->GetName()); | |
176 | else { | |
177 | G4String text = "AliModuleConstruction::ListAllLVTree:\n"; | |
178 | text = text + " Detector frame is not defined."; | |
179 | AliGlobals::Warning(text); | |
180 | } | |
181 | } | |
182 | ||
78ca1e9c | 183 | //_____________________________________________________________________________ |
676fb573 | 184 | void AliModuleConstruction::ListAllLVTreeLong() |
185 | { | |
186 | // Lists all logical volume tree if the frame logical volume | |
187 | // is defined with numbers of daughters (physical volumes). | |
188 | // ---- | |
189 | ||
190 | if (fModuleFrameLV) | |
191 | ListLVTreeLong(fModuleFrameLV->GetName()); | |
192 | else { | |
193 | G4String text = "AliModuleConstruction::ListAllLVTreeLong:\n"; | |
194 | text = text + " Detector frame is not defined."; | |
195 | AliGlobals::Warning(text); | |
196 | } | |
197 | } | |
198 | ||
78ca1e9c | 199 | //_____________________________________________________________________________ |
676fb573 | 200 | void AliModuleConstruction::ListLVTree(G4String lvName) |
201 | { | |
202 | // Lists logical volumes tree (daughters) of the logical volume | |
203 | // with specified lvName. | |
204 | // ---- | |
205 | ||
4ecb3cfd | 206 | G4LogicalVolume* lv |
207 | = TG4GeometryServices::Instance()->FindLogicalVolume(lvName); | |
208 | ||
676fb573 | 209 | if (lv) |
210 | { | |
211 | G4String path = ""; | |
212 | AliLVStructure lvStructure(path); | |
213 | RegisterLogicalVolume(lv, path, lvStructure); | |
214 | lvStructure.ListTree(); | |
215 | } | |
216 | } | |
217 | ||
78ca1e9c | 218 | //_____________________________________________________________________________ |
676fb573 | 219 | void AliModuleConstruction::ListLVTreeLong(G4String lvName) |
220 | { | |
221 | // Lists logical volumes tree (daughters) of the logical volume | |
222 | // with specified lvName with numbers of daughters (physical volumes). | |
223 | // ---- | |
224 | ||
4ecb3cfd | 225 | G4LogicalVolume* lv |
226 | = TG4GeometryServices::Instance()->FindLogicalVolume(lvName); | |
227 | ||
676fb573 | 228 | if (lv) { |
229 | G4String path = ""; | |
230 | AliLVStructure lvStructure(path); | |
231 | RegisterLogicalVolume(lv, path, lvStructure); | |
232 | lvStructure.ListTreeLong(); | |
233 | } | |
234 | } | |
235 | ||
676fb573 | 236 | #ifdef ALICE_VISUALIZE |
237 | ||
78ca1e9c | 238 | //_____________________________________________________________________________ |
676fb573 | 239 | void AliModuleConstruction::SetDetVisibility(G4bool visibility) |
240 | { | |
241 | // Sets visibility to all detector logical volumes if | |
242 | // frame logical volume is defined. | |
243 | // --- | |
244 | ||
245 | if (fModuleFrameLV) | |
246 | SetLVTreeVisibility(fModuleFrameLV, visibility); | |
247 | else { | |
248 | G4String text = "AliModuleConstruction::SetDetVisibility:\n"; | |
249 | text = text + " Detector frame is not defined."; | |
250 | AliGlobals::Warning(text); | |
251 | } | |
252 | } | |
253 | ||
254 | ||
78ca1e9c | 255 | //_____________________________________________________________________________ |
676fb573 | 256 | void AliModuleConstruction::SetLVTreeVisibility(G4LogicalVolume* lv, |
257 | G4bool visibility) | |
258 | { | |
259 | // Sets visibility to the logical volumes tree (daughters) of | |
260 | // the logical volume lv. | |
261 | // --- | |
262 | ||
263 | if (lv) { | |
264 | G4String path = ""; | |
265 | AliLVStructure lvStructure(path); | |
266 | RegisterLogicalVolume(lv, path, lvStructure); | |
267 | lvStructure.SetTreeVisibility(visibility); | |
268 | } | |
269 | } | |
270 | ||
78ca1e9c | 271 | //_____________________________________________________________________________ |
676fb573 | 272 | void AliModuleConstruction::SetVolumeVisibility(G4LogicalVolume* lv, |
273 | G4bool visibility) | |
274 | { | |
275 | // Sets visibility to the specified logical volume. | |
276 | // --- | |
277 | ||
278 | if (lv) { | |
279 | const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes (); | |
30a3cbee | 280 | G4VisAttributes* newVisAttributes; |
281 | if (kpVisAttributes) { | |
282 | G4Colour oldColour = kpVisAttributes->GetColour(); | |
283 | newVisAttributes = new G4VisAttributes(oldColour); | |
284 | } | |
285 | else | |
286 | newVisAttributes = new G4VisAttributes(); | |
676fb573 | 287 | delete kpVisAttributes; |
288 | ||
289 | newVisAttributes->SetVisibility(visibility); | |
290 | ||
291 | lv->SetVisAttributes(newVisAttributes); | |
292 | } | |
293 | } | |
294 | ||
78ca1e9c | 295 | //_____________________________________________________________________________ |
676fb573 | 296 | void AliModuleConstruction::SetDetColour(G4String colName) |
297 | { | |
298 | // Sets colour to all detector logical volumes if | |
299 | // frame logical volume is defined. | |
300 | // --- | |
301 | ||
302 | if (fModuleFrameLV) | |
303 | SetLVTreeColour(fModuleFrameLV, colName); | |
304 | else { | |
305 | G4String text = "AliModuleConstruction::SetDetColour:\n"; | |
306 | text = text + " Detector frame is not defined."; | |
307 | AliGlobals::Warning(text); | |
308 | } | |
309 | } | |
310 | ||
78ca1e9c | 311 | //_____________________________________________________________________________ |
676fb573 | 312 | void AliModuleConstruction::SetLVTreeColour(G4LogicalVolume* lv, |
313 | G4String colName) | |
314 | { | |
315 | // Sets colour to the logical volumes tree (daughters) of | |
316 | // the logical volume lv. | |
317 | // --- | |
318 | ||
319 | if (lv) { | |
320 | G4String path = ""; | |
321 | AliLVStructure lvStructure(path); | |
322 | RegisterLogicalVolume(lv, path, lvStructure); | |
323 | lvStructure.SetTreeVisibility(true); | |
324 | lvStructure.SetTreeColour(colName); | |
325 | } | |
326 | } | |
327 | ||
78ca1e9c | 328 | //_____________________________________________________________________________ |
676fb573 | 329 | void AliModuleConstruction::SetVolumeColour(G4LogicalVolume* lv, |
330 | G4String colName) | |
331 | { | |
332 | // Sets colour to the specified logical volume. | |
333 | // --- | |
334 | ||
335 | if (lv) { | |
336 | const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes (); | |
676fb573 | 337 | delete kpVisAttributes; |
338 | ||
590fb121 | 339 | G4VisAttributes* newVisAttributes = new G4VisAttributes(); |
340 | ||
676fb573 | 341 | AliColourStore* pColours = AliColourStore::Instance(); |
342 | const G4Colour kColour = pColours->GetColour(colName); | |
343 | newVisAttributes->SetVisibility(true); | |
344 | newVisAttributes->SetColour(kColour); | |
345 | ||
346 | lv->SetVisAttributes(newVisAttributes); | |
347 | } | |
348 | } | |
349 | ||
350 | #endif //ALICE_VISUALIZE | |
351 |