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