]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * SigmaEffect_thetadegrees * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpeateose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | // Class AliMUONGeometryBuilder | |
20 | // ---------------------------- | |
21 | // Manager class for geometry construction via geometry builders. | |
22 | // Author: Ivana Hrivnacova, IPN Orsay | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
25 | #include "AliMUONGeometryBuilder.h" | |
26 | #include "AliMUONVGeometryBuilder.h" | |
27 | #include "AliMUONGeometry.h" | |
28 | #include "AliMUONGeometryTransformer.h" | |
29 | #include "AliMUONGeometryModule.h" | |
30 | #include "AliMUONGeometryModuleTransformer.h" | |
31 | #include "AliMUONGeometryEnvelope.h" | |
32 | #include "AliMUONGeometryEnvelopeStore.h" | |
33 | #include "AliMUONGeometryDetElement.h" | |
34 | #include "AliMUONGeometryConstituent.h" | |
35 | ||
36 | #include "AliMpDEManager.h" | |
37 | ||
38 | #include "AliModule.h" | |
39 | #include "AliSimulation.h" | |
40 | #include "AliLog.h" | |
41 | #include "AliRun.h" | |
42 | ||
43 | #include <TObjArray.h> | |
44 | #include <TVirtualMC.h> | |
45 | #include <TGeoManager.h> | |
46 | ||
47 | /// \cond CLASSIMP | |
48 | ClassImp(AliMUONGeometryBuilder) | |
49 | /// \endcond | |
50 | ||
51 | // | |
52 | // static functions | |
53 | // | |
54 | ||
55 | //______________________________________________________________________________ | |
56 | const TString& AliMUONGeometryBuilder::GetDefaultTransformFileName() | |
57 | { | |
58 | ///< default transformations file name | |
59 | static const TString kDefaultTransformFileName = "transform.dat"; | |
60 | return kDefaultTransformFileName; | |
61 | } | |
62 | ||
63 | //______________________________________________________________________________ | |
64 | const TString& AliMUONGeometryBuilder::GetDefaultSVMapFileName() | |
65 | { | |
66 | ///< default svmaps file name | |
67 | static const TString kDefaultSVMapFileName = "svmap.dat"; | |
68 | return kDefaultSVMapFileName; | |
69 | } | |
70 | ||
71 | //______________________________________________________________________________ | |
72 | const TString& AliMUONGeometryBuilder::GetOutFileNameExtension() | |
73 | { | |
74 | ///< default output file name extension | |
75 | static const TString kOutFileNameExtension = ".out"; | |
76 | return kOutFileNameExtension; | |
77 | } | |
78 | ||
79 | ||
80 | //______________________________________________________________________________ | |
81 | TGeoHMatrix AliMUONGeometryBuilder::Multiply(const TGeoMatrix& m1, | |
82 | const TGeoMatrix& m2) | |
83 | { | |
84 | /// Temporary fix for problem with matrix multiplication in Root 5.02/00 | |
85 | ||
86 | if (m1.IsIdentity() && m2.IsIdentity()) return TGeoHMatrix(); | |
87 | ||
88 | if (m1.IsIdentity()) return m2; | |
89 | ||
90 | if (m2.IsIdentity()) return m1; | |
91 | ||
92 | return m1 * m2; | |
93 | } | |
94 | ||
95 | //______________________________________________________________________________ | |
96 | TGeoHMatrix AliMUONGeometryBuilder::Multiply(const TGeoMatrix& m1, | |
97 | const TGeoMatrix& m2, | |
98 | const TGeoMatrix& m3) | |
99 | { | |
100 | /// Temporary fix for problem with matrix multiplication in Root 5.02/00 | |
101 | ||
102 | if (m1.IsIdentity() && m2.IsIdentity() & m3.IsIdentity()) | |
103 | return TGeoHMatrix(); | |
104 | ||
105 | if (m1.IsIdentity()) return Multiply(m2, m3); | |
106 | ||
107 | if (m2.IsIdentity()) return Multiply(m1, m3); | |
108 | ||
109 | if (m3.IsIdentity()) return Multiply(m1, m2); | |
110 | ||
111 | return m1 * m2 * m3; | |
112 | } | |
113 | ||
114 | //______________________________________________________________________________ | |
115 | TGeoHMatrix AliMUONGeometryBuilder::Multiply(const TGeoMatrix& m1, | |
116 | const TGeoMatrix& m2, | |
117 | const TGeoMatrix& m3, | |
118 | const TGeoMatrix& m4) | |
119 | { | |
120 | /// Temporary fix for problem with matrix multiplication in Root 5.02/00 | |
121 | ||
122 | if (m1.IsIdentity() && m2.IsIdentity() & m3.IsIdentity() & m4.IsIdentity()) | |
123 | return TGeoHMatrix(); | |
124 | ||
125 | if (m1.IsIdentity()) return Multiply(m2, m3, m4); | |
126 | ||
127 | if (m2.IsIdentity()) return Multiply(m1, m3, m4); | |
128 | ||
129 | if (m3.IsIdentity()) return Multiply(m1, m2, m4); | |
130 | ||
131 | if (m4.IsIdentity()) return Multiply(m1, m2, m3); | |
132 | ||
133 | return m1 * m2 * m3 * m4; | |
134 | } | |
135 | ||
136 | // | |
137 | // ctors, dtor | |
138 | // | |
139 | ||
140 | //______________________________________________________________________________ | |
141 | AliMUONGeometryBuilder::AliMUONGeometryBuilder(AliModule* module) | |
142 | : TObject(), | |
143 | fModule(module), | |
144 | fAlign(false), | |
145 | fTransformFileName(GetDefaultTransformFileName()), | |
146 | fSVMapFileName(GetDefaultSVMapFileName()), | |
147 | fGlobalTransformation(), | |
148 | fGeometryBuilders(0), | |
149 | fGeometry(0) | |
150 | { | |
151 | /// Standard constructor | |
152 | ||
153 | fGeometryBuilders = new TObjArray(); | |
154 | fGeometryBuilders->SetOwner(true); | |
155 | ||
156 | fGeometry = new AliMUONGeometry(true); | |
157 | ||
158 | // Define the global transformation: | |
159 | // Transformation from the old ALICE coordinate system to a new one: | |
160 | // x->-x, z->-z | |
161 | TGeoRotation* rotGlobal | |
162 | = new TGeoRotation("rotGlobal", 90., 180., 90., 90., 180., 0.); | |
163 | fGlobalTransformation = TGeoCombiTrans(0., 0., 0., rotGlobal); | |
164 | } | |
165 | ||
166 | //______________________________________________________________________________ | |
167 | AliMUONGeometryBuilder::AliMUONGeometryBuilder() | |
168 | : TObject(), | |
169 | fModule(0), | |
170 | fAlign(false), | |
171 | fTransformFileName(), | |
172 | fSVMapFileName(), | |
173 | fGlobalTransformation(), | |
174 | fGeometryBuilders(0), | |
175 | fGeometry(0) | |
176 | { | |
177 | /// Default constructor | |
178 | } | |
179 | ||
180 | //______________________________________________________________________________ | |
181 | AliMUONGeometryBuilder::~AliMUONGeometryBuilder() | |
182 | { | |
183 | /// Destructor | |
184 | ||
185 | delete fGeometryBuilders; | |
186 | delete fGeometry; | |
187 | } | |
188 | ||
189 | // | |
190 | // private functions | |
191 | // | |
192 | ||
193 | //______________________________________________________________________________ | |
194 | void AliMUONGeometryBuilder::PlaceVolume(const TString& name, const TString& mName, | |
195 | Int_t copyNo, const TGeoHMatrix& matrix, | |
196 | Int_t npar, Double_t* param, const char* only, | |
197 | Bool_t makeAssembly) const | |
198 | { | |
199 | /// Place the volume specified by name with the given transformation matrix | |
200 | ||
201 | if (makeAssembly) | |
202 | gGeoManager->MakeVolumeAssembly(name.Data()); | |
203 | ||
204 | TGeoHMatrix transform(matrix); | |
205 | // Do not apply global transformation | |
206 | // if mother volume was already placed in | |
207 | // the new system of coordinates (that is MUON in negative Z) | |
208 | // (as it is applied on the mother volume) | |
209 | if (mName == TString("DDIP")) | |
210 | transform = fGlobalTransformation.Inverse() * transform; | |
211 | ||
212 | // Decompose transformation | |
213 | const Double_t* xyz = transform.GetTranslation(); | |
214 | const Double_t* rm = transform.GetRotationMatrix(); | |
215 | ||
216 | //cout << "Got translation: " | |
217 | // << xyz[0] << " " << xyz[1] << " " << xyz[2] << endl; | |
218 | ||
219 | //cout << "Got rotation: " | |
220 | // << rm[0] << " " << rm[1] << " " << rm[2] << endl | |
221 | // << rm[3] << " " << rm[4] << " " << rm[5] << endl | |
222 | // << rm[6] << " " << rm[7] << " " << rm[8] << endl; | |
223 | ||
224 | // Check for presence of rotation | |
225 | // (will be nice to be available in TGeo) | |
226 | const Double_t kTolerance = 1e-04; | |
227 | Bool_t isRotation = true; | |
228 | if (TMath::Abs(rm[0] - 1.) < kTolerance && | |
229 | TMath::Abs(rm[1] - 0.) < kTolerance && | |
230 | TMath::Abs(rm[2] - 0.) < kTolerance && | |
231 | TMath::Abs(rm[3] - 0.) < kTolerance && | |
232 | TMath::Abs(rm[4] - 1.) < kTolerance && | |
233 | TMath::Abs(rm[5] - 0.) < kTolerance && | |
234 | TMath::Abs(rm[6] - 0.) < kTolerance && | |
235 | TMath::Abs(rm[7] - 0.) < kTolerance && | |
236 | TMath::Abs(rm[8] - 1.) < kTolerance) isRotation = false; | |
237 | ||
238 | Int_t krot = 0; | |
239 | if (isRotation) { | |
240 | TGeoRotation rot; | |
241 | rot.SetMatrix(const_cast<Double_t*>(transform.GetRotationMatrix())); | |
242 | Double_t theta1, phi1, theta2, phi2, theta3, phi3; | |
243 | rot.GetAngles(theta1, phi1, theta2, phi2, theta3, phi3); | |
244 | ||
245 | //cout << "angles: " | |
246 | // << theta1 << " " << phi1 << " " | |
247 | // << theta2 << " " << phi2 << " " | |
248 | // << theta3 << " " << phi3 << endl; | |
249 | ||
250 | fModule->AliMatrix(krot, theta1, phi1, theta2, phi2, theta3, phi3); | |
251 | } | |
252 | ||
253 | // Place the volume | |
254 | if (npar == 0) | |
255 | gMC->Gspos(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, only); | |
256 | else | |
257 | gMC->Gsposp(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, only, | |
258 | param, npar); | |
259 | } | |
260 | ||
261 | //______________________________________________________________________________ | |
262 | void AliMUONGeometryBuilder::CreateGeometryWithTGeo() | |
263 | { | |
264 | /// Construct geometry using geometry builders. | |
265 | /// Virtual modules/envelopes are placed as TGeoVolume assembly | |
266 | ||
267 | if (fAlign) { | |
268 | // Read transformations from ASCII data file | |
269 | fGeometry->GetTransformer() | |
270 | ->LoadGeometryData(fTransformFileName); | |
271 | } | |
272 | ||
273 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
274 | ||
275 | // Get the builder | |
276 | AliMUONVGeometryBuilder* builder | |
277 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
278 | ||
279 | // Create geometry + envelopes | |
280 | // | |
281 | builder->CreateGeometry(); | |
282 | builder->SetVolumes(); | |
283 | if (!fAlign) builder->SetTransformations(); | |
284 | ||
285 | // Place module volumes and envelopes | |
286 | // | |
287 | for (Int_t j=0; j<builder->NofGeometries(); j++) { | |
288 | ||
289 | AliMUONGeometryModule* geometry = builder->Geometry(j); | |
290 | AliMUONGeometryModuleTransformer* transformer= geometry->GetTransformer(); | |
291 | const TGeoHMatrix* kModuleTransform = transformer->GetTransformation(); | |
292 | TString volName = transformer->GetVolumeName(); | |
293 | TString motherVolName = transformer->GetMotherVolumeName(); | |
294 | ||
295 | // Place the module volume | |
296 | PlaceVolume(volName, motherVolName, | |
297 | 1, *kModuleTransform, 0, 0, "ONLY", geometry->IsVirtual()); | |
298 | ||
299 | TGeoCombiTrans appliedGlobalTransform; | |
300 | if (builder->ApplyGlobalTransformation()) | |
301 | appliedGlobalTransform = fGlobalTransformation; | |
302 | ||
303 | // Loop over envelopes | |
304 | const TObjArray* kEnvelopes | |
305 | = geometry->GetEnvelopeStore()->GetEnvelopes(); | |
306 | for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) { | |
307 | ||
308 | // Get envelope | |
309 | AliMUONGeometryEnvelope* env | |
310 | = (AliMUONGeometryEnvelope*)kEnvelopes->At(k); | |
311 | ||
312 | // Check consistency of detElemId and module Id | |
313 | if ( env->GetUniqueID() > 0 && | |
314 | AliMpDEManager::GetGeomModuleId(env->GetUniqueID()) | |
315 | != geometry->GetModuleId() ) { | |
316 | ||
317 | AliErrorStream() | |
318 | << "Detection element " << env->GetUniqueID() | |
319 | << " is being placed in geometry module " << geometry->GetModuleId() | |
320 | << " but should go in " | |
321 | << AliMpDEManager::GetGeomModuleId(env->GetUniqueID()) | |
322 | << endl; | |
323 | AliFatal("Inconsistent IDs"); | |
324 | } | |
325 | ||
326 | const TGeoCombiTrans* kEnvTrans = env->GetTransformation(); | |
327 | const char* only = "ONLY"; | |
328 | if (env->IsMANY()) only = "MANY"; | |
329 | ||
330 | if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) { | |
331 | // virtual envelope + nof constituents = 0 | |
332 | // => not allowed; | |
333 | // empty virtual envelope has no sense | |
334 | AliFatal("Virtual envelope must have constituents."); | |
335 | return; | |
336 | } | |
337 | ||
338 | if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) { | |
339 | // non virtual envelope + nof constituents > 0 | |
340 | // => not allowed; | |
341 | // use VMC to place constituents | |
342 | AliFatal("Non virtual envelope cannot have constituents."); | |
343 | return; | |
344 | } | |
345 | ||
346 | // Place envelope in geometry module by composed transformation: | |
347 | // [Tglobal] * Tenv | |
348 | TGeoHMatrix total | |
349 | = Multiply( appliedGlobalTransform, | |
350 | (*kEnvTrans) ); | |
351 | PlaceVolume(env->GetName(), volName, | |
352 | env->GetCopyNo(), total, 0, 0, only, env->IsVirtual()); | |
353 | ||
354 | if ( env->IsVirtual() ) { | |
355 | // Place constituents in the envelope | |
356 | for (Int_t l=0; l<env->GetConstituents()->GetEntriesFast(); l++) { | |
357 | AliMUONGeometryConstituent* constituent | |
358 | = (AliMUONGeometryConstituent*)env->GetConstituents()->At(l); | |
359 | ||
360 | PlaceVolume(constituent->GetName(), env->GetName(), | |
361 | constituent->GetCopyNo(), | |
362 | *constituent->GetTransformation() , | |
363 | constituent->GetNpar(), constituent->GetParam(), only); | |
364 | } | |
365 | } | |
366 | } // end of loop over envelopes | |
367 | } // end of loop over builder geometries | |
368 | } // end of loop over builders | |
369 | } | |
370 | ||
371 | //______________________________________________________________________________ | |
372 | void AliMUONGeometryBuilder::CreateGeometryWithoutTGeo() | |
373 | { | |
374 | /// Construct geometry using geometry builders. | |
375 | /// Virtual modules/envelopes are not placed | |
376 | ||
377 | if (fAlign) { | |
378 | // Read transformations from ASCII data file | |
379 | fGeometry->GetTransformer()->LoadGeometryData(fTransformFileName); | |
380 | } | |
381 | ||
382 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
383 | ||
384 | // Get the builder | |
385 | AliMUONVGeometryBuilder* builder | |
386 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
387 | ||
388 | // Create geometry + envelopes | |
389 | // | |
390 | builder->CreateGeometry(); | |
391 | if (!fAlign) builder->SetTransformations(); | |
392 | ||
393 | // Place module volumes and envelopes | |
394 | // | |
395 | for (Int_t j=0; j<builder->NofGeometries(); j++) { | |
396 | ||
397 | AliMUONGeometryModule* geometry = builder->Geometry(j); | |
398 | AliMUONGeometryModuleTransformer* transformer= geometry->GetTransformer(); | |
399 | const TGeoHMatrix* kModuleTransform = transformer->GetTransformation(); | |
400 | TString volName = transformer->GetVolumeName(); | |
401 | TString motherVolName = transformer->GetMotherVolumeName(); | |
402 | ||
403 | // Place the module volume | |
404 | if ( !geometry->IsVirtual() ) { | |
405 | PlaceVolume(volName, motherVolName, | |
406 | 1, *kModuleTransform, 0, 0, "ONLY"); | |
407 | } | |
408 | ||
409 | TGeoCombiTrans appliedGlobalTransform; | |
410 | if (builder->ApplyGlobalTransformation()) | |
411 | appliedGlobalTransform = fGlobalTransformation; | |
412 | ||
413 | // Loop over envelopes | |
414 | const TObjArray* kEnvelopes | |
415 | = geometry->GetEnvelopeStore()->GetEnvelopes(); | |
416 | for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) { | |
417 | ||
418 | // Get envelope | |
419 | AliMUONGeometryEnvelope* env | |
420 | = (AliMUONGeometryEnvelope*)kEnvelopes->At(k); | |
421 | ||
422 | // Check consistency of detElemId and module Id | |
423 | if ( env->GetUniqueID() > 0 && | |
424 | AliMpDEManager::GetGeomModuleId(env->GetUniqueID()) | |
425 | != geometry->GetModuleId() ) { | |
426 | ||
427 | AliErrorStream() | |
428 | << "Detection element " << env->GetUniqueID() | |
429 | << " is being placed in geometry module " << geometry->GetModuleId() | |
430 | << " but should go in " | |
431 | << AliMpDEManager::GetGeomModuleId(env->GetUniqueID()) | |
432 | << endl; | |
433 | AliFatal("Inconsistent IDs"); | |
434 | } | |
435 | ||
436 | const TGeoCombiTrans* kEnvTrans = env->GetTransformation(); | |
437 | const char* only = "ONLY"; | |
438 | if (env->IsMANY()) only = "MANY"; | |
439 | ||
440 | if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) { | |
441 | // virtual envelope + nof constituents = 0 | |
442 | // => not allowed; | |
443 | // empty virtual envelope has no sense | |
444 | AliFatal("Virtual envelope must have constituents."); | |
445 | return; | |
446 | } | |
447 | ||
448 | if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) { | |
449 | // non virtual envelope + nof constituents > 0 | |
450 | // => not allowed; | |
451 | // use VMC to place constituents | |
452 | AliFatal("Non virtual envelope cannot have constituents."); | |
453 | return; | |
454 | } | |
455 | ||
456 | if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) { | |
457 | // non virtual envelope + nof constituents = 0 | |
458 | // => place envelope by composed transformation: | |
459 | // Tch * [Tglobal] * Tenv | |
460 | ||
461 | // Compound chamber transformation with the envelope one | |
462 | if (geometry->IsVirtual()) { | |
463 | TGeoHMatrix total | |
464 | = Multiply( (*kModuleTransform), | |
465 | appliedGlobalTransform, | |
466 | (*kEnvTrans) ); | |
467 | PlaceVolume(env->GetName(), motherVolName, | |
468 | env->GetCopyNo(), total, 0, 0, only); | |
469 | } | |
470 | else { | |
471 | TGeoHMatrix total | |
472 | = Multiply( appliedGlobalTransform, | |
473 | (*kEnvTrans) ); | |
474 | PlaceVolume(env->GetName(), volName, | |
475 | env->GetCopyNo(), total, 0, 0, only); | |
476 | } | |
477 | } | |
478 | ||
479 | if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) { | |
480 | // virtual envelope + nof constituents > 0 | |
481 | // => do not place envelope and place constituents | |
482 | // by composed transformation: | |
483 | // Tch * [Tglobal] * Tenv * Tconst | |
484 | ||
485 | for (Int_t l=0; l<env->GetConstituents()->GetEntriesFast(); l++) { | |
486 | AliMUONGeometryConstituent* constituent | |
487 | = (AliMUONGeometryConstituent*)env->GetConstituents()->At(l); | |
488 | ||
489 | // Compound chamber transformation with the envelope one + the constituent one | |
490 | if (geometry->IsVirtual()) { | |
491 | TGeoHMatrix total | |
492 | = Multiply ( (*kModuleTransform), | |
493 | appliedGlobalTransform, | |
494 | (*kEnvTrans), | |
495 | (*constituent->GetTransformation()) ); | |
496 | ||
497 | PlaceVolume(constituent->GetName(), motherVolName, | |
498 | constituent->GetCopyNo(), total, | |
499 | constituent->GetNpar(), constituent->GetParam(), only); | |
500 | } | |
501 | else { | |
502 | TGeoHMatrix total | |
503 | = Multiply ( appliedGlobalTransform, | |
504 | (*kEnvTrans), | |
505 | (*constituent->GetTransformation()) ); | |
506 | ||
507 | PlaceVolume(constituent->GetName(), volName, | |
508 | constituent->GetCopyNo(), total, | |
509 | constituent->GetNpar(), constituent->GetParam(), only); | |
510 | } | |
511 | } | |
512 | } | |
513 | } // end of loop over envelopes | |
514 | } // end of loop over builder geometries | |
515 | } // end of loop over builders | |
516 | } | |
517 | ||
518 | //_____________________________________________________________________________ | |
519 | void AliMUONGeometryBuilder::SetAlignToBuilder(AliMUONVGeometryBuilder* builder) const | |
520 | { | |
521 | /// Set align option to all geometry modules associated with the builder | |
522 | ||
523 | for (Int_t j=0; j<builder->NofGeometries(); j++) { | |
524 | ||
525 | AliMUONGeometryModule* geometry = builder->Geometry(j); | |
526 | ||
527 | geometry->SetAlign(fAlign); | |
528 | } | |
529 | } | |
530 | ||
531 | // | |
532 | // public functions | |
533 | // | |
534 | ||
535 | //_____________________________________________________________________________ | |
536 | void AliMUONGeometryBuilder::AddBuilder(AliMUONVGeometryBuilder* geomBuilder) | |
537 | { | |
538 | /// Add the geometry builder to the list | |
539 | ||
540 | fGeometryBuilders->Add(geomBuilder); | |
541 | ||
542 | // Pass geometry modules created in the to the geometry parametrisation | |
543 | for (Int_t i=0; i<geomBuilder->NofGeometries(); i++) { | |
544 | fGeometry->AddModule(geomBuilder->Geometry(i)); | |
545 | } | |
546 | ||
547 | if (geomBuilder->ApplyGlobalTransformation()) | |
548 | geomBuilder->SetReferenceFrame(fGlobalTransformation); | |
549 | ||
550 | SetAlignToBuilder(geomBuilder); | |
551 | } | |
552 | ||
553 | //______________________________________________________________________________ | |
554 | void AliMUONGeometryBuilder::CreateGeometry() | |
555 | { | |
556 | /// Construct geometry using geometry builders. | |
557 | ||
558 | if ( gMC->IsRootGeometrySupported() ) { | |
559 | ||
560 | CreateGeometryWithTGeo(); | |
561 | } | |
562 | else | |
563 | CreateGeometryWithoutTGeo(); | |
564 | ||
565 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
566 | ||
567 | // Get the builder | |
568 | AliMUONVGeometryBuilder* builder | |
569 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
570 | ||
571 | // Update detection elements from built geometry | |
572 | Bool_t create = ! fAlign; | |
573 | builder->UpdateDetElements(create); | |
574 | } | |
575 | } | |
576 | ||
577 | //_____________________________________________________________________________ | |
578 | void AliMUONGeometryBuilder::CreateMaterials() | |
579 | { | |
580 | /// Construct materials specific to modules via builders | |
581 | ||
582 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
583 | ||
584 | // Get the builder | |
585 | AliMUONVGeometryBuilder* builder | |
586 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
587 | ||
588 | // Create materials with each builder | |
589 | if (builder) builder->CreateMaterials(); | |
590 | } | |
591 | } | |
592 | ||
593 | //______________________________________________________________________________ | |
594 | void AliMUONGeometryBuilder::InitGeometry(const TString& svmapFileName) | |
595 | { | |
596 | /// Initialize geometry | |
597 | ||
598 | // Load alignement data from geometry if geometry is read from Root file | |
599 | if ( AliSimulation::Instance()->IsGeometryFromFile() ) { | |
600 | fAlign = true; | |
601 | fGeometry->GetTransformer()->LoadGeometryData(); | |
602 | } | |
603 | ||
604 | // Read sensitive volume map from a file | |
605 | fGeometry->ReadSVMap(svmapFileName); | |
606 | ||
607 | // Set the chamber (sensitive region) GEANT identifier | |
608 | // | |
609 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
610 | ||
611 | // Get the builder | |
612 | AliMUONVGeometryBuilder* builder | |
613 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
614 | ||
615 | // Set sensitive volumes with each builder | |
616 | builder->SetSensitiveVolumes(); | |
617 | } | |
618 | } | |
619 | ||
620 | //________________________________________________________________ | |
621 | void AliMUONGeometryBuilder::UpdateInternalGeometry() | |
622 | { | |
623 | /// Update geometry after applying mis-alignment: | |
624 | /// reload transformations in geometry builder. | |
625 | ||
626 | fGeometry->GetTransformer()->LoadTransformations(); | |
627 | } | |
628 | ||
629 | //______________________________________________________________________________ | |
630 | void AliMUONGeometryBuilder::WriteSVMaps(const TString& fileName, | |
631 | Bool_t rebuild, Bool_t writeEnvelopes) | |
632 | { | |
633 | /// Write sensitive volume maps into files per builder | |
634 | ||
635 | // Rebuild sv maps | |
636 | // | |
637 | if (rebuild) | |
638 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
639 | ||
640 | AliMUONVGeometryBuilder* builder | |
641 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
642 | ||
643 | builder->RebuildSVMaps(writeEnvelopes); | |
644 | } | |
645 | ||
646 | // Write maps in file | |
647 | fGeometry->WriteSVMap(fileName); | |
648 | } | |
649 | ||
650 | //_____________________________________________________________________________ | |
651 | void AliMUONGeometryBuilder::SetAlign(Bool_t align) | |
652 | { | |
653 | /// Set the option for alignement | |
654 | ||
655 | fAlign = align; | |
656 | ||
657 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
658 | ||
659 | AliMUONVGeometryBuilder* builder | |
660 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
661 | ||
662 | SetAlignToBuilder(builder); | |
663 | } | |
664 | } | |
665 | ||
666 | //_____________________________________________________________________________ | |
667 | void AliMUONGeometryBuilder::SetAlign(const TString& fileName, Bool_t align) | |
668 | { | |
669 | /// Set the option for alignement and the transformations file name | |
670 | ||
671 | fTransformFileName = fileName; | |
672 | fAlign = align; | |
673 | ||
674 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
675 | ||
676 | AliMUONVGeometryBuilder* builder | |
677 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
678 | ||
679 | SetAlignToBuilder(builder); | |
680 | } | |
681 | } |