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