]>
Commit | Line | Data |
---|---|---|
d4bb94a1 | 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$ | |
3d1463c8 | 17 | |
18 | //----------------------------------------------------------------------------- | |
d4bb94a1 | 19 | // Class AliMUONGeometryBuilder |
20 | // ---------------------------- | |
e118b27e | 21 | // Manager class for geometry construction via geometry builders. |
d4bb94a1 | 22 | // Author: Ivana Hrivnacova, IPN Orsay |
3d1463c8 | 23 | //----------------------------------------------------------------------------- |
d4bb94a1 | 24 | |
d4bb94a1 | 25 | #include "AliMUONGeometryBuilder.h" |
d4bb94a1 | 26 | #include "AliMUONVGeometryBuilder.h" |
6cfb12b4 | 27 | #include "AliMUONGeometry.h" |
28 | #include "AliMUONGeometryTransformer.h" | |
e118b27e | 29 | #include "AliMUONGeometryModule.h" |
6cfb12b4 | 30 | #include "AliMUONGeometryModuleTransformer.h" |
d4bb94a1 | 31 | #include "AliMUONGeometryEnvelope.h" |
76497dec | 32 | #include "AliMUONGeometryEnvelopeStore.h" |
e118b27e | 33 | #include "AliMUONGeometryDetElement.h" |
6cfb12b4 | 34 | #include "AliMUONGeometryConstituent.h" |
08086cd0 | 35 | |
47d608ac | 36 | #include "AliMpDEManager.h" |
37 | ||
e118b27e | 38 | #include "AliModule.h" |
d97f1dbe | 39 | #include "AliSimulation.h" |
8c343c7c | 40 | #include "AliLog.h" |
4a9de4af | 41 | #include "AliRun.h" |
42 | ||
08086cd0 | 43 | #include <TObjArray.h> |
44 | #include <TVirtualMC.h> | |
45 | #include <TGeoManager.h> | |
46 | ||
a9aad96e | 47 | /// \cond CLASSIMP |
63ed9c6b | 48 | ClassImp(AliMUONGeometryBuilder) |
a9aad96e | 49 | /// \endcond |
63ed9c6b | 50 | |
31edb2d7 | 51 | // |
067866a3 | 52 | // static functions |
31edb2d7 | 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 | ||
067866a3 | 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 | ||
31edb2d7 | 136 | // |
137 | // ctors, dtor | |
138 | // | |
139 | ||
e118b27e | 140 | //______________________________________________________________________________ |
141 | AliMUONGeometryBuilder::AliMUONGeometryBuilder(AliModule* module) | |
d4bb94a1 | 142 | : TObject(), |
e118b27e | 143 | fModule(module), |
76497dec | 144 | fAlign(false), |
31edb2d7 | 145 | fTransformFileName(GetDefaultTransformFileName()), |
146 | fSVMapFileName(GetDefaultSVMapFileName()), | |
e118b27e | 147 | fGlobalTransformation(), |
6cfb12b4 | 148 | fGeometryBuilders(0), |
149 | fGeometry(0) | |
d4bb94a1 | 150 | { |
692de412 | 151 | /// Standard constructor |
e118b27e | 152 | |
6cfb12b4 | 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); | |
e118b27e | 164 | } |
d4bb94a1 | 165 | |
e118b27e | 166 | //______________________________________________________________________________ |
167 | AliMUONGeometryBuilder::AliMUONGeometryBuilder() | |
d4bb94a1 | 168 | : TObject(), |
e118b27e | 169 | fModule(0), |
76497dec | 170 | fAlign(false), |
eea63c73 | 171 | fTransformFileName(), |
172 | fSVMapFileName(), | |
e118b27e | 173 | fGlobalTransformation(), |
6cfb12b4 | 174 | fGeometryBuilders(0), |
175 | fGeometry(0) | |
d4bb94a1 | 176 | { |
692de412 | 177 | /// Default constructor |
e118b27e | 178 | } |
d4bb94a1 | 179 | |
d4bb94a1 | 180 | //______________________________________________________________________________ |
181 | AliMUONGeometryBuilder::~AliMUONGeometryBuilder() | |
182 | { | |
692de412 | 183 | /// Destructor |
6cfb12b4 | 184 | |
185 | delete fGeometryBuilders; | |
186 | delete fGeometry; | |
d4bb94a1 | 187 | } |
188 | ||
d4bb94a1 | 189 | // |
190 | // private functions | |
191 | // | |
192 | ||
193 | //______________________________________________________________________________ | |
194 | void AliMUONGeometryBuilder::PlaceVolume(const TString& name, const TString& mName, | |
195 | Int_t copyNo, const TGeoHMatrix& matrix, | |
08086cd0 | 196 | Int_t npar, Double_t* param, const char* only, |
197 | Bool_t makeAssembly) const | |
d4bb94a1 | 198 | { |
692de412 | 199 | /// Place the volume specified by name with the given transformation matrix |
d4bb94a1 | 200 | |
08086cd0 | 201 | if (makeAssembly) |
202 | gGeoManager->MakeVolumeAssembly(name.Data()); | |
203 | ||
6cfb12b4 | 204 | TGeoHMatrix transform(matrix); |
d4bb94a1 | 205 | // Do not apply global transformation |
cfbf2f7d | 206 | // if mother volume was already placed in |
207 | // the new system of coordinates (that is MUON in negative Z) | |
e118b27e | 208 | // (as it is applied on the mother volume) |
cfbf2f7d | 209 | if (mName == TString("DDIP")) |
e118b27e | 210 | transform = fGlobalTransformation.Inverse() * transform; |
d4bb94a1 | 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 | ||
e118b27e | 250 | fModule->AliMatrix(krot, theta1, phi1, theta2, phi2, theta3, phi3); |
d4bb94a1 | 251 | } |
252 | ||
da0465d0 | 253 | // Place the volume |
d4bb94a1 | 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); | |
d4bb94a1 | 259 | } |
260 | ||
08086cd0 | 261 | //______________________________________________________________________________ |
262 | void AliMUONGeometryBuilder::CreateGeometryWithTGeo() | |
8618c022 | 263 | { |
08086cd0 | 264 | /// Construct geometry using geometry builders. |
265 | /// Virtual modules/envelopes are placed as TGeoVolume assembly | |
8618c022 | 266 | |
08086cd0 | 267 | if (fAlign) { |
268 | // Read transformations from ASCII data file | |
269 | fGeometry->GetTransformer() | |
21555211 | 270 | ->LoadGeometryData(fTransformFileName); |
08086cd0 | 271 | } |
272 | ||
273 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
8618c022 | 274 | |
08086cd0 | 275 | // Get the builder |
276 | AliMUONVGeometryBuilder* builder | |
277 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
278 | ||
279 | // Create geometry + envelopes | |
280 | // | |
281 | builder->CreateGeometry(); | |
b96f7067 | 282 | builder->SetVolumes(); |
08086cd0 | 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()); | |
8618c022 | 298 | |
08086cd0 | 299 | TGeoCombiTrans appliedGlobalTransform; |
300 | if (builder->ApplyGlobalTransformation()) | |
301 | appliedGlobalTransform = fGlobalTransformation; | |
8618c022 | 302 | |
08086cd0 | 303 | // Loop over envelopes |
304 | const TObjArray* kEnvelopes | |
305 | = geometry->GetEnvelopeStore()->GetEnvelopes(); | |
306 | for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) { | |
d4bb94a1 | 307 | |
08086cd0 | 308 | // Get envelope |
309 | AliMUONGeometryEnvelope* env | |
310 | = (AliMUONGeometryEnvelope*)kEnvelopes->At(k); | |
311 | ||
47d608ac | 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 | ||
08086cd0 | 326 | const TGeoCombiTrans* kEnvTrans = env->GetTransformation(); |
327 | const char* only = "ONLY"; | |
328 | if (env->IsMANY()) only = "MANY"; | |
e118b27e | 329 | |
08086cd0 | 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 | |
e118b27e | 369 | } |
370 | ||
d4bb94a1 | 371 | //______________________________________________________________________________ |
08086cd0 | 372 | void AliMUONGeometryBuilder::CreateGeometryWithoutTGeo() |
d4bb94a1 | 373 | { |
692de412 | 374 | /// Construct geometry using geometry builders. |
a9aad96e | 375 | /// Virtual modules/envelopes are not placed |
d4bb94a1 | 376 | |
08086cd0 | 377 | if (fAlign) { |
378 | // Read transformations from ASCII data file | |
21555211 | 379 | fGeometry->GetTransformer()->LoadGeometryData(fTransformFileName); |
08086cd0 | 380 | } |
6cfb12b4 | 381 | |
d4bb94a1 | 382 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { |
383 | ||
384 | // Get the builder | |
385 | AliMUONVGeometryBuilder* builder | |
386 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
387 | ||
e118b27e | 388 | // Create geometry + envelopes |
389 | // | |
6cfb12b4 | 390 | builder->CreateGeometry(); |
391 | if (!fAlign) builder->SetTransformations(); | |
392 | ||
cfbf2f7d | 393 | // Place module volumes and envelopes |
e118b27e | 394 | // |
395 | for (Int_t j=0; j<builder->NofGeometries(); j++) { | |
d4bb94a1 | 396 | |
e118b27e | 397 | AliMUONGeometryModule* geometry = builder->Geometry(j); |
08086cd0 | 398 | AliMUONGeometryModuleTransformer* transformer= geometry->GetTransformer(); |
399 | const TGeoHMatrix* kModuleTransform = transformer->GetTransformation(); | |
400 | TString volName = transformer->GetVolumeName(); | |
401 | TString motherVolName = transformer->GetMotherVolumeName(); | |
cfbf2f7d | 402 | |
403 | // Place the module volume | |
404 | if ( !geometry->IsVirtual() ) { | |
08086cd0 | 405 | PlaceVolume(volName, motherVolName, |
6cfb12b4 | 406 | 1, *kModuleTransform, 0, 0, "ONLY"); |
cfbf2f7d | 407 | } |
e118b27e | 408 | |
6cfb12b4 | 409 | TGeoCombiTrans appliedGlobalTransform; |
410 | if (builder->ApplyGlobalTransformation()) | |
411 | appliedGlobalTransform = fGlobalTransformation; | |
412 | ||
e118b27e | 413 | // Loop over envelopes |
6cfb12b4 | 414 | const TObjArray* kEnvelopes |
415 | = geometry->GetEnvelopeStore()->GetEnvelopes(); | |
e118b27e | 416 | for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) { |
417 | ||
418 | // Get envelope | |
6cfb12b4 | 419 | AliMUONGeometryEnvelope* env |
420 | = (AliMUONGeometryEnvelope*)kEnvelopes->At(k); | |
421 | ||
47d608ac | 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 | ||
e118b27e | 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 | } | |
d4bb94a1 | 447 | |
e118b27e | 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 | |
da0465d0 | 458 | // => place envelope by composed transformation: |
6cfb12b4 | 459 | // Tch * [Tglobal] * Tenv |
e118b27e | 460 | |
461 | // Compound chamber transformation with the envelope one | |
cfbf2f7d | 462 | if (geometry->IsVirtual()) { |
463 | TGeoHMatrix total | |
6cfb12b4 | 464 | = Multiply( (*kModuleTransform), |
465 | appliedGlobalTransform, | |
067866a3 | 466 | (*kEnvTrans) ); |
08086cd0 | 467 | PlaceVolume(env->GetName(), motherVolName, |
cfbf2f7d | 468 | env->GetCopyNo(), total, 0, 0, only); |
469 | } | |
470 | else { | |
471 | TGeoHMatrix total | |
6cfb12b4 | 472 | = Multiply( appliedGlobalTransform, |
473 | (*kEnvTrans) ); | |
08086cd0 | 474 | PlaceVolume(env->GetName(), volName, |
cfbf2f7d | 475 | env->GetCopyNo(), total, 0, 0, only); |
476 | } | |
e118b27e | 477 | } |
478 | ||
479 | if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) { | |
480 | // virtual envelope + nof constituents > 0 | |
481 | // => do not place envelope and place constituents | |
da0465d0 | 482 | // by composed transformation: |
6cfb12b4 | 483 | // Tch * [Tglobal] * Tenv * Tconst |
d4bb94a1 | 484 | |
e118b27e | 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 | |
cfbf2f7d | 490 | if (geometry->IsVirtual()) { |
491 | TGeoHMatrix total | |
6cfb12b4 | 492 | = Multiply ( (*kModuleTransform), |
493 | appliedGlobalTransform, | |
494 | (*kEnvTrans), | |
067866a3 | 495 | (*constituent->GetTransformation()) ); |
cfbf2f7d | 496 | |
08086cd0 | 497 | PlaceVolume(constituent->GetName(), motherVolName, |
cfbf2f7d | 498 | constituent->GetCopyNo(), total, |
499 | constituent->GetNpar(), constituent->GetParam(), only); | |
500 | } | |
501 | else { | |
502 | TGeoHMatrix total | |
6cfb12b4 | 503 | = Multiply ( appliedGlobalTransform, |
504 | (*kEnvTrans), | |
067866a3 | 505 | (*constituent->GetTransformation()) ); |
cfbf2f7d | 506 | |
08086cd0 | 507 | PlaceVolume(constituent->GetName(), volName, |
cfbf2f7d | 508 | constituent->GetCopyNo(), total, |
509 | constituent->GetNpar(), constituent->GetParam(), only); | |
510 | } | |
e118b27e | 511 | } |
d4bb94a1 | 512 | } |
e118b27e | 513 | } // end of loop over envelopes |
514 | } // end of loop over builder geometries | |
515 | } // end of loop over builders | |
d4bb94a1 | 516 | } |
517 | ||
08086cd0 | 518 | //_____________________________________________________________________________ |
9ee1d6ff | 519 | void AliMUONGeometryBuilder::SetAlignToBuilder(AliMUONVGeometryBuilder* builder) const |
08086cd0 | 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 | ||
9ee1d6ff | 550 | SetAlignToBuilder(geomBuilder); |
08086cd0 | 551 | } |
552 | ||
553 | //______________________________________________________________________________ | |
554 | void AliMUONGeometryBuilder::CreateGeometry() | |
555 | { | |
556 | /// Construct geometry using geometry builders. | |
557 | ||
38baba3c | 558 | if ( gMC->IsRootGeometrySupported() ) { |
08086cd0 | 559 | |
560 | CreateGeometryWithTGeo(); | |
561 | } | |
562 | else | |
563 | CreateGeometryWithoutTGeo(); | |
21555211 | 564 | |
565 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { | |
566 | ||
567 | // Get the builder | |
568 | AliMUONVGeometryBuilder* builder | |
569 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
b96f7067 | 570 | |
571 | // Update detection elements from built geometry | |
572 | Bool_t create = ! fAlign; | |
573 | builder->UpdateDetElements(create); | |
574 | } | |
08086cd0 | 575 | } |
576 | ||
d4bb94a1 | 577 | //_____________________________________________________________________________ |
578 | void AliMUONGeometryBuilder::CreateMaterials() | |
579 | { | |
692de412 | 580 | /// Construct materials specific to modules via builders |
d4bb94a1 | 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 | //______________________________________________________________________________ | |
6cfb12b4 | 594 | void AliMUONGeometryBuilder::InitGeometry(const TString& svmapFileName) |
d4bb94a1 | 595 | { |
692de412 | 596 | /// Initialize geometry |
d4bb94a1 | 597 | |
08086cd0 | 598 | // Load alignement data from geometry if geometry is read from Root file |
d97f1dbe | 599 | if ( AliSimulation::Instance()->IsGeometryFromFile() ) { |
6cfb12b4 | 600 | fAlign = true; |
21555211 | 601 | fGeometry->GetTransformer()->LoadGeometryData(); |
602 | } | |
6cfb12b4 | 603 | |
604 | // Read sensitive volume map from a file | |
605 | fGeometry->ReadSVMap(svmapFileName); | |
47d608ac | 606 | |
d4bb94a1 | 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 | ||
6cfb12b4 | 615 | // Set sensitive volumes with each builder |
76497dec | 616 | builder->SetSensitiveVolumes(); |
e118b27e | 617 | } |
76497dec | 618 | } |
619 | ||
450ca6fb | 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 | ||
6cfb12b4 | 629 | //______________________________________________________________________________ |
eea63c73 | 630 | void AliMUONGeometryBuilder::WriteSVMaps(const TString& fileName, |
94bc50cf | 631 | Bool_t rebuild, Bool_t writeEnvelopes) |
d4bb94a1 | 632 | { |
6cfb12b4 | 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++) { | |
d4bb94a1 | 639 | |
6cfb12b4 | 640 | AliMUONVGeometryBuilder* builder |
641 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
642 | ||
08086cd0 | 643 | builder->RebuildSVMaps(writeEnvelopes); |
6cfb12b4 | 644 | } |
645 | ||
646 | // Write maps in file | |
647 | fGeometry->WriteSVMap(fileName); | |
648 | } | |
d4bb94a1 | 649 | |
76497dec | 650 | //_____________________________________________________________________________ |
651 | void AliMUONGeometryBuilder::SetAlign(Bool_t align) | |
652 | { | |
067866a3 | 653 | /// Set the option for alignement |
76497dec | 654 | |
655 | fAlign = align; | |
656 | ||
e118b27e | 657 | for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) { |
658 | ||
e118b27e | 659 | AliMUONVGeometryBuilder* builder |
660 | = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i); | |
8618c022 | 661 | |
9ee1d6ff | 662 | SetAlignToBuilder(builder); |
8618c022 | 663 | } |
76497dec | 664 | } |
eea63c73 | 665 | |
666 | //_____________________________________________________________________________ | |
667 | void AliMUONGeometryBuilder::SetAlign(const TString& fileName, Bool_t align) | |
668 | { | |
a9aad96e | 669 | /// Set the option for alignement and the transformations file name |
eea63c73 | 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 | ||
9ee1d6ff | 679 | SetAlignToBuilder(builder); |
eea63c73 | 680 | } |
681 | } |