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. *
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 **************************************************************************/
18 // Class AliMUONGeometryBuilder
19 // ----------------------------
20 // MUON manager class for geometry construction,
21 // separated form AliMUONv1
23 // Author: Ivana Hrivnacova, IPN Orsay
25 #include <TClonesArray.h>
26 #include <TGeoMatrix.h>
27 #include <TVirtualMC.h>
29 #include "AliMUONGeometryBuilder.h"
31 #include "AliMUONChamber.h"
32 #include "AliMUONConstants.h"
33 #include "AliMUONVGeometryBuilder.h"
34 #include "AliMUONChamberGeometry.h"
35 #include "AliMUONGeometryEnvelope.h"
36 #include "AliMUONGeometryEnvelopeStore.h"
37 #include "AliMUONGeometryConstituent.h"
41 ClassImp(AliMUONGeometryBuilder)
43 //______________________________________________________________________________//___________________________________________
44 AliMUONGeometryBuilder::AliMUONGeometryBuilder()
48 fGlobalTransformation(0),
51 // Default constructor
54 //______________________________________________________________________________//___________________________________________
55 AliMUONGeometryBuilder::AliMUONGeometryBuilder(AliMUON* muon)
59 fGlobalTransformation(0),
62 // Standars constructor
64 // Define the global transformation:
65 // Transformation from the old ALICE coordinate system to a new one:
67 TGeoRotation* rotGlobal
68 = new TGeoRotation("rotGlobal", 90., 180., 90., 90., 180., 0.);
69 fGlobalTransformation = new TGeoCombiTrans(0., 0., 0., rotGlobal);
71 fGeometryBuilders = new TObjArray(AliMUONConstants::NCh());
74 //______________________________________________________________________________
75 AliMUONGeometryBuilder::AliMUONGeometryBuilder(const AliMUONGeometryBuilder& right)
78 // copy constructor (not implemented)
80 Fatal("AliMUONGeometryBuilder", "Copy constructor not provided.");
83 //______________________________________________________________________________
84 AliMUONGeometryBuilder::~AliMUONGeometryBuilder()
88 delete fGlobalTransformation;
90 if (fGeometryBuilders){
91 fGeometryBuilders->Delete();
92 delete fGeometryBuilders;
96 //______________________________________________________________________________
97 AliMUONGeometryBuilder&
98 AliMUONGeometryBuilder::operator=(const AliMUONGeometryBuilder& right)
100 // assignement operator (not implemented)
102 // check assignement to self
103 if (this == &right) return *this;
105 Fatal("operator =", "Assignement operator not provided.");
114 //______________________________________________________________________________
115 void AliMUONGeometryBuilder::PlaceVolume(const TString& name, const TString& mName,
116 Int_t copyNo, const TGeoHMatrix& matrix,
117 Int_t npar, Double_t* param, const char* only) const
119 // Place the volume specified by name with the given transformation matrix
122 // Do not apply global transformation
123 // if mother volume == DDIP
124 // (as it is applied on this volume)
125 TGeoHMatrix transform(matrix);
126 if (mName == TString("DDIP")) {
127 transform = (*fGlobalTransformation) * transform;
128 // To be changed to (*fGlobalTransformation).inverse()
129 // when available in TGeo
130 // To make this correct also for a general case when
131 // (*fGlobalTransformation) * *fGlobalTransformation) != 1
134 // Decompose transformation
135 const Double_t* xyz = transform.GetTranslation();
136 const Double_t* rm = transform.GetRotationMatrix();
138 //cout << "Got translation: "
139 // << xyz[0] << " " << xyz[1] << " " << xyz[2] << endl;
141 //cout << "Got rotation: "
142 // << rm[0] << " " << rm[1] << " " << rm[2] << endl
143 // << rm[3] << " " << rm[4] << " " << rm[5] << endl
144 // << rm[6] << " " << rm[7] << " " << rm[8] << endl;
146 // Check for presence of rotation
147 // (will be nice to be available in TGeo)
148 const Double_t kTolerance = 1e-04;
149 Bool_t isRotation = true;
150 if (TMath::Abs(rm[0] - 1.) < kTolerance &&
151 TMath::Abs(rm[1] - 0.) < kTolerance &&
152 TMath::Abs(rm[2] - 0.) < kTolerance &&
153 TMath::Abs(rm[3] - 0.) < kTolerance &&
154 TMath::Abs(rm[4] - 1.) < kTolerance &&
155 TMath::Abs(rm[5] - 0.) < kTolerance &&
156 TMath::Abs(rm[6] - 0.) < kTolerance &&
157 TMath::Abs(rm[7] - 0.) < kTolerance &&
158 TMath::Abs(rm[8] - 1.) < kTolerance) isRotation = false;
163 rot.SetMatrix(const_cast<Double_t*>(transform.GetRotationMatrix()));
164 Double_t theta1, phi1, theta2, phi2, theta3, phi3;
165 rot.GetAngles(theta1, phi1, theta2, phi2, theta3, phi3);
168 // << theta1 << " " << phi1 << " "
169 // << theta2 << " " << phi2 << " "
170 // << theta3 << " " << phi3 << endl;
172 fMUON->AliMatrix(krot, theta1, phi1, theta2, phi2, theta3, phi3);
175 // Place the volume in ALIC
177 gMC->Gspos(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, only);
179 gMC->Gsposp(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, only,
188 //______________________________________________________________________________
189 void AliMUONGeometryBuilder::CreateGeometry()
192 // Construct geometry using geometry builders.
195 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
198 AliMUONVGeometryBuilder* builder
199 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
201 // Create geometry with each builder
204 builder->ReadTransformations();
205 builder->CreateGeometry();
208 builder->CreateGeometry();
209 builder->SetTransformations();
214 for (Int_t j=0; j<AliMUONConstants::NCh(); j++) {
216 AliMUONChamberGeometry* geometry = fMUON->Chamber(j).GetGeometry();
218 if (!geometry) continue;
219 // Skip chambers with not defined geometry
221 // Loop over envelopes
222 const TObjArray* kEnvelopes = geometry->GetEnvelopeStore()->GetEnvelopes();
223 for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) {
226 AliMUONGeometryEnvelope* env = (AliMUONGeometryEnvelope*)kEnvelopes->At(k);
227 const TGeoCombiTrans* kEnvTrans = env->GetTransformation();
228 const char* only = "ONLY";
229 if (env->IsMANY()) only = "MANY";
231 if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) {
232 // virtual envelope + nof constituents = 0
234 // empty virtual envelope has no sense
235 Fatal("CreateGeometry", "Virtual envelope must have constituents.");
239 if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) {
240 // non virtual envelope + nof constituents > 0
242 // use VMC to place constituents
243 Fatal("CreateGeometry", "Non virtual envelope cannot have constituents.");
247 if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) {
248 // non virtual envelope + nof constituents = 0
249 // => place envelope in ALICE by composed transformation:
250 // Tglobal * Tch * Tenv
252 // Compound chamber transformation with the envelope one
254 = (*fGlobalTransformation) *
255 (*geometry->GetTransformation()) *
257 PlaceVolume(env->GetName(), geometry->GetMotherVolume(),
258 env->GetCopyNo(), total, 0, 0, only);
261 if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) {
262 // virtual envelope + nof constituents > 0
263 // => do not place envelope and place constituents
264 // in ALICE by composed transformation:
265 // Tglobal * Tch * Tenv * Tconst
267 for (Int_t l=0; l<env->GetConstituents()->GetEntriesFast(); l++) {
268 AliMUONGeometryConstituent* constituent
269 = (AliMUONGeometryConstituent*)env->GetConstituents()->At(l);
271 // Compound chamber transformation with the envelope one + the constituent one
273 = (*fGlobalTransformation) *
274 (*geometry->GetTransformation()) *
276 (*constituent->GetTransformation());
278 PlaceVolume(constituent->GetName(), geometry->GetMotherVolume(),
279 constituent->GetCopyNo(), total,
280 constituent->GetNpar(), constituent->GetParam(), only);
287 //_____________________________________________________________________________
288 void AliMUONGeometryBuilder::CreateMaterials()
290 // Definition of common materials
294 // Ar-CO2 gas (80%+20%)
295 Float_t ag1[3] = { 39.95,12.01,16. };
296 Float_t zg1[3] = { 18.,6.,8. };
297 Float_t wg1[3] = { .8,.0667,.13333 };
298 Float_t dg1 = .001821;
300 // Ar-buthane-freon gas -- trigger chambers
301 Float_t atr1[4] = { 39.95,12.01,1.01,19. };
302 Float_t ztr1[4] = { 18.,6.,1.,9. };
303 Float_t wtr1[4] = { .56,.1262857,.2857143,.028 };
304 Float_t dtr1 = .002599;
307 Float_t agas[3] = { 39.95,12.01,16. };
308 Float_t zgas[3] = { 18.,6.,8. };
309 Float_t wgas[3] = { .74,.086684,.173316 };
310 Float_t dgas = .0018327;
312 // Ar-Isobutane gas (80%+20%) -- tracking
313 Float_t ag[3] = { 39.95,12.01,1.01 };
314 Float_t zg[3] = { 18.,6.,1. };
315 Float_t wg[3] = { .8,.057,.143 };
316 Float_t dg = .0019596;
318 // Ar-Isobutane-Forane-SF6 gas (49%+7%+40%+4%) -- trigger
319 Float_t atrig[5] = { 39.95,12.01,1.01,19.,32.066 };
320 Float_t ztrig[5] = { 18.,6.,1.,9.,16. };
321 Float_t wtrig[5] = { .49,1.08,1.5,1.84,0.04 };
322 Float_t dtrig = .0031463;
325 Float_t abak[3] = {12.01 , 1.01 , 16.};
326 Float_t zbak[3] = {6. , 1. , 8.};
327 Float_t wbak[3] = {6. , 6. , 1.};
330 Int_t iSXFLD = gAlice->Field()->Integ();
331 Float_t sXMGMX = gAlice->Field()->Max();
333 // --- Define the various materials for GEANT ---
334 fMUON->AliMaterial(9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
335 fMUON->AliMaterial(10, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
337 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
338 Float_t zAir[4]={6.,7.,8.,18.};
339 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
340 Float_t dAir = 1.20479E-3;
341 fMUON->AliMixture(15, "AIR$ ", aAir, zAir, dAir,4, wAir);
342 // fMUON->AliMaterial(15, "AIR$ ", 14.61, 7.3, .001205, 30423.24, 67500);
343 fMUON->AliMixture(19, "Bakelite$", abak, zbak, dbak, -3, wbak);
344 fMUON->AliMixture(20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
345 fMUON->AliMixture(21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
346 fMUON->AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
347 fMUON->AliMixture(23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
348 fMUON->AliMixture(24, "ArCO2 GAS$", agas, zgas, dgas, 3, wgas);
350 // materials for slat:
351 // Sensitive area: gas (already defined)
353 // insulating material: vetronite -> replacing by G10 Ch. Finck
354 // spacer: noryl Ch. Finck
355 // panel sandwich: carbon, nomex, carbon replacing rohacell by nomex Ch. Finck
357 // G10: SiO2(60%) + C8H14O4(40%)
358 Float_t aglass[5] = {12.01, 28.09, 16., 1.01, 16.};
359 Float_t zglass[5] = { 6., 14., 8., 1., 8.};
360 Float_t wglass[5] = { 0.22, 0.28, 0.32, 0.03, 0.15};
361 Float_t dglass = 1.7;
363 // rohacell: C9 H13 N1 O2
364 Float_t arohac[4] = {12.01, 1.01, 14.010, 16.};
365 Float_t zrohac[4] = { 6., 1., 7., 8.};
366 Float_t wrohac[4] = { 9., 13., 1., 2.};
367 Float_t drohac = 0.03;
369 // Nomex: C22 H10 N2 O5
370 Float_t aNomex[4] = {12.01, 1.01, 14.010, 16.};
371 Float_t zNomex[4] = { 6., 1., 7., 8.};
372 Float_t wNomex[4] = { 22., 10., 2., 5.};
373 Float_t dNomex = 0.024; //honey comb
374 Float_t dNomex2 = 1.43; //bulk material
377 // Noryl: C8 H8 O polyphenylene oxyde (di-methyl not sure)
378 Float_t aNoryl[3] = {12.01, 1.01, 16.};
379 Float_t zNoryl[3] = { 6., 1., 8.};
380 Float_t wNoryl[3] = { 8., 8., 1.};
381 Float_t dNoryl = 1.06;
383 fMUON->AliMaterial(31, "COPPER$", 63.54, 29., 8.96, 1.4, 0.);
384 fMUON->AliMixture( 32, "G10$", aglass, zglass, dglass, -5, wglass);
385 fMUON->AliMaterial(33, "Carbon$", 12.01, 6., 2.265, 18.8, 49.9);
386 fMUON->AliMixture( 34, "Rohacell$", arohac, zrohac, drohac, -4, wrohac);
387 fMUON->AliMixture( 35, "Nomex$", aNomex, zNomex, dNomex, -4, wNomex);
388 fMUON->AliMixture( 36, "Noryl$", aNoryl, zNoryl, dNoryl, -3, wNoryl);
389 fMUON->AliMixture( 37, "Nomex_bulk$",aNomex, zNomex, dNomex2, -4, wNomex);
391 Float_t epsil = .001; // Tracking precision,
392 Float_t stemax = -1.; // Maximum displacement for multiple scat
393 Float_t tmaxfd = -20.; // Maximum angle due to field deflection
394 Float_t deemax = -.3; // Maximum fractional energy loss, DLS
396 Float_t maxDestepAlu = fMUON->GetMaxDestepAlu();
397 Float_t maxDestepGas = fMUON->GetMaxDestepGas();
398 Float_t maxStepAlu = fMUON->GetMaxStepAlu();
399 Float_t maxStepGas = fMUON->GetMaxStepGas();
403 fMUON->AliMedium(1, "AIR_CH_US ", 15, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
407 fMUON->AliMedium(4, "ALU_CH_US ", 9, 0, iSXFLD, sXMGMX, tmaxfd, maxStepAlu,
408 maxDestepAlu, epsil, stmin);
409 fMUON->AliMedium(5, "ALU_CH_US ", 10, 0, iSXFLD, sXMGMX, tmaxfd, maxStepAlu,
410 maxDestepAlu, epsil, stmin);
413 fMUON->AliMedium(6, "AR_CH_US ", 20, 1, iSXFLD, sXMGMX, tmaxfd, maxStepGas,
414 maxDestepGas, epsil, stmin);
416 // Ar-Isobuthane-Forane-SF6 gas
417 fMUON->AliMedium(7, "GAS_CH_TRIGGER ", 21, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
419 fMUON->AliMedium(8, "BAKE_CH_TRIGGER ", 19, 0, iSXFLD, sXMGMX, tmaxfd, maxStepAlu,
420 maxDestepAlu, epsil, stmin);
423 fMUON->AliMedium(9, "ARG_CO2 ", 22, 1, iSXFLD, sXMGMX, tmaxfd, maxStepGas,
424 maxDestepAlu, epsil, stmin);
426 // tracking media for slats: check the parameters!!
427 fMUON->AliMedium(11, "PCB_COPPER ", 31, 0, iSXFLD, sXMGMX, tmaxfd,
428 maxStepAlu, maxDestepAlu, epsil, stmin);
429 fMUON->AliMedium(12, "G10 ", 32, 0, iSXFLD, sXMGMX, tmaxfd,
430 maxStepAlu, maxDestepAlu, epsil, stmin);
431 fMUON->AliMedium(13, "CARBON ", 33, 0, iSXFLD, sXMGMX, tmaxfd,
432 maxStepAlu, maxDestepAlu, epsil, stmin);
433 fMUON->AliMedium(14, "Rohacell ", 34, 0, iSXFLD, sXMGMX, tmaxfd,
434 maxStepAlu, maxDestepAlu, epsil, stmin);
435 fMUON->AliMedium(15, "Nomex ", 35, 0, iSXFLD, sXMGMX, tmaxfd,
436 maxStepAlu, maxDestepAlu, epsil, stmin);
437 fMUON->AliMedium(16, "Noryl ", 36, 0, iSXFLD, sXMGMX, tmaxfd,
438 maxStepAlu, maxDestepAlu, epsil, stmin);
439 fMUON->AliMedium(17, "Nomex bulk ", 37, 0, iSXFLD, sXMGMX, tmaxfd,
440 maxStepAlu, maxDestepAlu, epsil, stmin);
441 //.Materials specific to stations
442 // created via builders
444 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
447 AliMUONVGeometryBuilder* builder
448 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
450 // Create materials with each builder
451 if (builder) builder->CreateMaterials();
455 //______________________________________________________________________________
456 void AliMUONGeometryBuilder::InitGeometry()
458 // Initialize geometry
462 // Set the chamber (sensitive region) GEANT identifier
464 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
467 AliMUONVGeometryBuilder* builder
468 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
470 // Set sesitive volumes with each builder
471 builder->SetSensitiveVolumes();
473 // Read sensitive volume map from a file
474 builder->ReadSVMap();
475 if (!fAlign) builder->FillTransformations();
479 //______________________________________________________________________________
480 void AliMUONGeometryBuilder::WriteTransformations()
482 // Writes transformations into files per builder
485 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
488 AliMUONVGeometryBuilder* builder
489 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
491 // Write transformations
492 builder->WriteTransformations();
496 //______________________________________________________________________________
497 void AliMUONGeometryBuilder::WriteSVMaps(Bool_t rebuild)
499 // Writes sensitive volume maps into files per builder
502 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
505 AliMUONVGeometryBuilder* builder
506 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
508 // Write transformations
509 builder->WriteSVMap(rebuild);
513 //_____________________________________________________________________________
514 void AliMUONGeometryBuilder::AddBuilder(AliMUONVGeometryBuilder* geomBuilder)
516 // Adds the geometry builder to the list
519 fGeometryBuilders->Add(geomBuilder);
522 //_____________________________________________________________________________
523 void AliMUONGeometryBuilder::SetAlign(Bool_t align)
525 // Sets the option for alignement
530 for (Int_t j=0; j<AliMUONConstants::NCh(); j++) {
532 AliMUONChamberGeometry* geometry = fMUON->Chamber(j).GetGeometry();
534 if (!geometry) continue;
535 // Skip chambers with not defined geometry
537 geometry->SetAlign(align);