]>
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 | //_____________________________________________________________________________ |
cbac26a9 | 112 | void AliModuleConstruction::RegisterLogicalVolume( |
113 | G4LogicalVolume* lv, const G4String& path, | |
114 | AliLVStructure& lvStructure) const | |
676fb573 | 115 | { |
116 | // Registers logical volume lv in the structure. | |
117 | // --- | |
118 | ||
119 | G4String lvName = lv->GetName(); | |
120 | lvStructure.AddNewVolume(lv, path); | |
121 | ||
122 | // register daughters | |
123 | G4int nofDaughters = lv->GetNoDaughters(); | |
124 | if (nofDaughters>0) { | |
125 | G4String previousName = ""; | |
126 | for (G4int i=0; i<nofDaughters; i++) { | |
127 | G4LogicalVolume* lvd = lv->GetDaughter(i)->GetLogicalVolume(); | |
128 | G4String currentName = lvd->GetName(); | |
129 | if (currentName != lvName && currentName != previousName) { | |
130 | G4String newPath = path + lvName +"/"; | |
131 | RegisterLogicalVolume(lvd, newPath, lvStructure); | |
132 | previousName = currentName; | |
133 | } | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | // public methods | |
139 | ||
78ca1e9c | 140 | //_____________________________________________________________________________ |
676fb573 | 141 | void AliModuleConstruction::SetDetFrame(G4bool warn) |
142 | { | |
143 | // The logical volume with name identical with | |
144 | // fModuleName is retrieved from G4LogicalVolumeStore. | |
145 | // --- | |
146 | ||
4ecb3cfd | 147 | fModuleFrameLV |
148 | = TG4GeometryServices::Instance()->FindLogicalVolume(fModuleFrameName, true); | |
676fb573 | 149 | |
150 | if (fModuleFrameLV == 0 && warn) { | |
151 | G4String text = "AliModuleConstruction: Detector frame for "; | |
152 | text = text + fModuleFrameName + " has not been found."; | |
153 | AliGlobals::Warning(text); | |
154 | } | |
155 | } | |
156 | ||
78ca1e9c | 157 | //_____________________________________________________________________________ |
cbac26a9 | 158 | void AliModuleConstruction::SetDetFrame(const G4String& frameName, G4bool warn) |
676fb573 | 159 | { |
160 | // The logical volume with frameName | |
161 | // is retrieved from G4LogicalVolumeStore. | |
162 | // --- | |
163 | ||
164 | fModuleFrameName = frameName; | |
165 | SetDetFrame(warn); | |
166 | } | |
167 | ||
78ca1e9c | 168 | //_____________________________________________________________________________ |
cbac26a9 | 169 | void AliModuleConstruction::ListAllLVTree() const |
676fb573 | 170 | { |
171 | // Lists all logical volumes tree if the frame logical volume | |
172 | // is defined. | |
173 | // ---- | |
174 | ||
175 | if (fModuleFrameLV) | |
176 | ListLVTree(fModuleFrameLV->GetName()); | |
177 | else { | |
178 | G4String text = "AliModuleConstruction::ListAllLVTree:\n"; | |
179 | text = text + " Detector frame is not defined."; | |
180 | AliGlobals::Warning(text); | |
181 | } | |
182 | } | |
183 | ||
78ca1e9c | 184 | //_____________________________________________________________________________ |
cbac26a9 | 185 | void AliModuleConstruction::ListAllLVTreeLong() const |
676fb573 | 186 | { |
187 | // Lists all logical volume tree if the frame logical volume | |
188 | // is defined with numbers of daughters (physical volumes). | |
189 | // ---- | |
190 | ||
191 | if (fModuleFrameLV) | |
192 | ListLVTreeLong(fModuleFrameLV->GetName()); | |
193 | else { | |
194 | G4String text = "AliModuleConstruction::ListAllLVTreeLong:\n"; | |
195 | text = text + " Detector frame is not defined."; | |
196 | AliGlobals::Warning(text); | |
197 | } | |
198 | } | |
199 | ||
78ca1e9c | 200 | //_____________________________________________________________________________ |
cbac26a9 | 201 | void AliModuleConstruction::ListLVTree(const G4String& lvName) const |
676fb573 | 202 | { |
203 | // Lists logical volumes tree (daughters) of the logical volume | |
204 | // with specified lvName. | |
205 | // ---- | |
206 | ||
4ecb3cfd | 207 | G4LogicalVolume* lv |
208 | = TG4GeometryServices::Instance()->FindLogicalVolume(lvName); | |
209 | ||
676fb573 | 210 | if (lv) |
211 | { | |
212 | G4String path = ""; | |
213 | AliLVStructure lvStructure(path); | |
214 | RegisterLogicalVolume(lv, path, lvStructure); | |
215 | lvStructure.ListTree(); | |
216 | } | |
217 | } | |
218 | ||
78ca1e9c | 219 | //_____________________________________________________________________________ |
cbac26a9 | 220 | void AliModuleConstruction::ListLVTreeLong(const G4String& lvName) const |
676fb573 | 221 | { |
222 | // Lists logical volumes tree (daughters) of the logical volume | |
223 | // with specified lvName with numbers of daughters (physical volumes). | |
224 | // ---- | |
225 | ||
4ecb3cfd | 226 | G4LogicalVolume* lv |
227 | = TG4GeometryServices::Instance()->FindLogicalVolume(lvName); | |
228 | ||
676fb573 | 229 | if (lv) { |
230 | G4String path = ""; | |
231 | AliLVStructure lvStructure(path); | |
232 | RegisterLogicalVolume(lv, path, lvStructure); | |
233 | lvStructure.ListTreeLong(); | |
234 | } | |
235 | } | |
236 | ||
676fb573 | 237 | #ifdef ALICE_VISUALIZE |
238 | ||
78ca1e9c | 239 | //_____________________________________________________________________________ |
cbac26a9 | 240 | void AliModuleConstruction::SetDetVisibility(G4bool visibility) const |
676fb573 | 241 | { |
242 | // Sets visibility to all detector logical volumes if | |
243 | // frame logical volume is defined. | |
244 | // --- | |
245 | ||
246 | if (fModuleFrameLV) | |
247 | SetLVTreeVisibility(fModuleFrameLV, visibility); | |
248 | else { | |
249 | G4String text = "AliModuleConstruction::SetDetVisibility:\n"; | |
250 | text = text + " Detector frame is not defined."; | |
251 | AliGlobals::Warning(text); | |
252 | } | |
253 | } | |
254 | ||
255 | ||
78ca1e9c | 256 | //_____________________________________________________________________________ |
676fb573 | 257 | void AliModuleConstruction::SetLVTreeVisibility(G4LogicalVolume* lv, |
cbac26a9 | 258 | G4bool visibility) const |
676fb573 | 259 | { |
260 | // Sets visibility to the logical volumes tree (daughters) of | |
261 | // the logical volume lv. | |
262 | // --- | |
263 | ||
264 | if (lv) { | |
265 | G4String path = ""; | |
266 | AliLVStructure lvStructure(path); | |
267 | RegisterLogicalVolume(lv, path, lvStructure); | |
268 | lvStructure.SetTreeVisibility(visibility); | |
269 | } | |
270 | } | |
271 | ||
78ca1e9c | 272 | //_____________________________________________________________________________ |
676fb573 | 273 | void AliModuleConstruction::SetVolumeVisibility(G4LogicalVolume* lv, |
cbac26a9 | 274 | G4bool visibility) const |
676fb573 | 275 | { |
276 | // Sets visibility to the specified logical volume. | |
277 | // --- | |
278 | ||
279 | if (lv) { | |
280 | const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes (); | |
30a3cbee | 281 | G4VisAttributes* newVisAttributes; |
282 | if (kpVisAttributes) { | |
283 | G4Colour oldColour = kpVisAttributes->GetColour(); | |
284 | newVisAttributes = new G4VisAttributes(oldColour); | |
285 | } | |
286 | else | |
287 | newVisAttributes = new G4VisAttributes(); | |
676fb573 | 288 | delete kpVisAttributes; |
289 | ||
290 | newVisAttributes->SetVisibility(visibility); | |
291 | ||
292 | lv->SetVisAttributes(newVisAttributes); | |
293 | } | |
294 | } | |
295 | ||
78ca1e9c | 296 | //_____________________________________________________________________________ |
cbac26a9 | 297 | void AliModuleConstruction::SetDetColour(G4String colName) const |
676fb573 | 298 | { |
299 | // Sets colour to all detector logical volumes if | |
300 | // frame logical volume is defined. | |
301 | // --- | |
302 | ||
303 | if (fModuleFrameLV) | |
304 | SetLVTreeColour(fModuleFrameLV, colName); | |
305 | else { | |
306 | G4String text = "AliModuleConstruction::SetDetColour:\n"; | |
307 | text = text + " Detector frame is not defined."; | |
308 | AliGlobals::Warning(text); | |
309 | } | |
310 | } | |
311 | ||
78ca1e9c | 312 | //_____________________________________________________________________________ |
676fb573 | 313 | void AliModuleConstruction::SetLVTreeColour(G4LogicalVolume* lv, |
cbac26a9 | 314 | const G4String& colName) const |
676fb573 | 315 | { |
316 | // Sets colour to the logical volumes tree (daughters) of | |
317 | // the logical volume lv. | |
318 | // --- | |
319 | ||
320 | if (lv) { | |
321 | G4String path = ""; | |
322 | AliLVStructure lvStructure(path); | |
323 | RegisterLogicalVolume(lv, path, lvStructure); | |
324 | lvStructure.SetTreeVisibility(true); | |
325 | lvStructure.SetTreeColour(colName); | |
326 | } | |
327 | } | |
328 | ||
78ca1e9c | 329 | //_____________________________________________________________________________ |
676fb573 | 330 | void AliModuleConstruction::SetVolumeColour(G4LogicalVolume* lv, |
cbac26a9 | 331 | const G4String& colName) const |
676fb573 | 332 | { |
333 | // Sets colour to the specified logical volume. | |
334 | // --- | |
335 | ||
336 | if (lv) { | |
337 | const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes (); | |
676fb573 | 338 | delete kpVisAttributes; |
339 | ||
590fb121 | 340 | G4VisAttributes* newVisAttributes = new G4VisAttributes(); |
341 | ||
676fb573 | 342 | AliColourStore* pColours = AliColourStore::Instance(); |
343 | const G4Colour kColour = pColours->GetColour(colName); | |
344 | newVisAttributes->SetVisibility(true); | |
345 | newVisAttributes->SetColour(kColour); | |
346 | ||
347 | lv->SetVisAttributes(newVisAttributes); | |
348 | } | |
349 | } | |
350 | ||
351 | #endif //ALICE_VISUALIZE | |
352 |