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