]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometryBuilder.cxx
Extracting PHOS and EMCAL trackers from the correspondig reconstructors (Yu.Belikov)
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryBuilder.cxx
CommitLineData
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$
17//
18// Class AliMUONGeometryBuilder
19// ----------------------------
20// MUON manager class for geometry construction,
21// separated form AliMUONv1
22//
23// Author: Ivana Hrivnacova, IPN Orsay
24
25#include <TClonesArray.h>
26#include <TGeoMatrix.h>
27#include <TVirtualMC.h>
28
29#include "AliMUONGeometryBuilder.h"
30#include "AliMUON.h"
31#include "AliMUONChamber.h"
32#include "AliMUONConstants.h"
33#include "AliMUONVGeometryBuilder.h"
34#include "AliMUONChamberGeometry.h"
35#include "AliMUONGeometryEnvelope.h"
76497dec 36#include "AliMUONGeometryEnvelopeStore.h"
d4bb94a1 37#include "AliMUONGeometryConstituent.h"
38#include "AliMagF.h"
39#include "AliRun.h"
40
41ClassImp(AliMUONGeometryBuilder)
42
43//______________________________________________________________________________//___________________________________________
44AliMUONGeometryBuilder::AliMUONGeometryBuilder()
45 : TObject(),
46 fMUON(0),
76497dec 47 fAlign(false),
d4bb94a1 48 fGlobalTransformation(0),
49 fGeometryBuilders(0)
50{
51// Default constructor
52}
53
54//______________________________________________________________________________//___________________________________________
55AliMUONGeometryBuilder::AliMUONGeometryBuilder(AliMUON* muon)
56 : TObject(),
57 fMUON(muon),
76497dec 58 fAlign(false),
d4bb94a1 59 fGlobalTransformation(0),
60 fGeometryBuilders(0)
61{
62// Standars constructor
63
64 // Define the global transformation:
65 // Transformation from the old ALICE coordinate system to a new one:
66 // x->-x, z->-z
67 TGeoRotation* rotGlobal
68 = new TGeoRotation("rotGlobal", 90., 180., 90., 90., 180., 0.);
69 fGlobalTransformation = new TGeoCombiTrans(0., 0., 0., rotGlobal);
70
71 fGeometryBuilders = new TObjArray(AliMUONConstants::NCh());
72}
73
74//______________________________________________________________________________
75AliMUONGeometryBuilder::AliMUONGeometryBuilder(const AliMUONGeometryBuilder& right)
76 : TObject(right)
77{
78 // copy constructor (not implemented)
79
80 Fatal("AliMUONGeometryBuilder", "Copy constructor not provided.");
81}
82
83//______________________________________________________________________________
84AliMUONGeometryBuilder::~AliMUONGeometryBuilder()
85{
86// Destructor
87
88 delete fGlobalTransformation;
89
90 if (fGeometryBuilders){
91 fGeometryBuilders->Delete();
92 delete fGeometryBuilders;
93 }
94}
95
96//______________________________________________________________________________
97AliMUONGeometryBuilder&
98AliMUONGeometryBuilder::operator=(const AliMUONGeometryBuilder& right)
99{
100 // assignement operator (not implemented)
101
102 // check assignement to self
103 if (this == &right) return *this;
104
105 Fatal("operator =", "Assignement operator not provided.");
106
107 return *this;
108}
109
110//
111// private functions
112//
113
114//______________________________________________________________________________
115void 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
118{
119// Place the volume specified by name with the given transformation matrix
120// ---
121
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
132 }
133
134 // Decompose transformation
135 const Double_t* xyz = transform.GetTranslation();
136 const Double_t* rm = transform.GetRotationMatrix();
137
138 //cout << "Got translation: "
139 // << xyz[0] << " " << xyz[1] << " " << xyz[2] << endl;
140
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;
145
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;
159
160 Int_t krot = 0;
161 if (isRotation) {
162 TGeoRotation rot;
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);
166
167 //cout << "angles: "
168 // << theta1 << " " << phi1 << " "
169 // << theta2 << " " << phi2 << " "
170 // << theta3 << " " << phi3 << endl;
171
172 fMUON->AliMatrix(krot, theta1, phi1, theta2, phi2, theta3, phi3);
173 }
174
175 // Place the volume in ALIC
176 if (npar == 0)
177 gMC->Gspos(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, only);
178 else
179 gMC->Gsposp(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, only,
180 param, npar);
181
182}
183
184//
185// public functions
186//
187
188//______________________________________________________________________________
189void AliMUONGeometryBuilder::CreateGeometry()
190{
191//
192// Construct geometry using geometry builders.
193//
194
195 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
196
197 // Get the builder
198 AliMUONVGeometryBuilder* builder
199 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
200
201 // Create geometry with each builder
202 if (builder) {
76497dec 203 if (fAlign) {
204 builder->ReadTransformations();
205 builder->CreateGeometry();
206 }
207 else {
208 builder->CreateGeometry();
209 builder->SetTransformations();
210 }
d4bb94a1 211 }
212 }
213
214 for (Int_t j=0; j<AliMUONConstants::NCh(); j++) {
215
216 AliMUONChamberGeometry* geometry = fMUON->Chamber(j).GetGeometry();
217
218 if (!geometry) continue;
219 // Skip chambers with not defined geometry
220
221 // Loop over envelopes
76497dec 222 const TObjArray* kEnvelopes = geometry->GetEnvelopeStore()->GetEnvelopes();
d4bb94a1 223 for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) {
224
225 // Get envelope
226 AliMUONGeometryEnvelope* env = (AliMUONGeometryEnvelope*)kEnvelopes->At(k);
227 const TGeoCombiTrans* kEnvTrans = env->GetTransformation();
228 const char* only = "ONLY";
229 if (env->IsMANY()) only = "MANY";
230
231 if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) {
232 // virtual envelope + nof constituents = 0
233 // => not allowed;
234 // empty virtual envelope has no sense
235 Fatal("CreateGeometry", "Virtual envelope must have constituents.");
236 return;
237 }
238
239 if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) {
240 // non virtual envelope + nof constituents > 0
241 // => not allowed;
242 // use VMC to place constituents
243 Fatal("CreateGeometry", "Non virtual envelope cannot have constituents.");
244 return;
245 }
246
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
251
252 // Compound chamber transformation with the envelope one
253 TGeoHMatrix total
254 = (*fGlobalTransformation) *
255 (*geometry->GetTransformation()) *
256 (*kEnvTrans);
257 PlaceVolume(env->GetName(), geometry->GetMotherVolume(),
258 env->GetCopyNo(), total, 0, 0, only);
259 }
260
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
266
267 for (Int_t l=0; l<env->GetConstituents()->GetEntriesFast(); l++) {
268 AliMUONGeometryConstituent* constituent
269 = (AliMUONGeometryConstituent*)env->GetConstituents()->At(l);
270
271 // Compound chamber transformation with the envelope one + the constituent one
272 TGeoHMatrix total
273 = (*fGlobalTransformation) *
274 (*geometry->GetTransformation()) *
275 (*kEnvTrans) *
276 (*constituent->GetTransformation());
277
278 PlaceVolume(constituent->GetName(), geometry->GetMotherVolume(),
279 constituent->GetCopyNo(), total,
280 constituent->GetNpar(), constituent->GetParam(), only);
281 }
282 }
283 }
284 }
285}
286
287//_____________________________________________________________________________
288void AliMUONGeometryBuilder::CreateMaterials()
289{
c3b69531 290 // Definition of common materials
291 // --
d4bb94a1 292
293 //
294 // Ar-CO2 gas (80%+20%)
c3b69531 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;
299 //
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;
305 //
306 // Ar-CO2 gas
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;
311 //
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;
317 //
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;
323 //
324 // bakelite: C6 H6 O
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.};
328 Float_t dbak = 1.4;
329
330 Int_t iSXFLD = gAlice->Field()->Integ();
331 Float_t sXMGMX = gAlice->Field()->Max();
332 //
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);
336 // Air
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);
349
350 // materials for slat:
351 // Sensitive area: gas (already defined)
352 // PCB: copper
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
356
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;
d4bb94a1 362
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;
368
c3b69531 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
375
376
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;
382
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);
390
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
395 Float_t stmin = -.8;
396 Float_t maxDestepAlu = fMUON->GetMaxDestepAlu();
397 Float_t maxDestepGas = fMUON->GetMaxDestepGas();
398 Float_t maxStepAlu = fMUON->GetMaxStepAlu();
399 Float_t maxStepGas = fMUON->GetMaxStepGas();
d4bb94a1 400
c3b69531 401 //
402 // Air
403 fMUON->AliMedium(1, "AIR_CH_US ", 15, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
404
405 //
406 // Aluminum
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);
411 //
412 // Ar-isoC4H10 gas
413 fMUON->AliMedium(6, "AR_CH_US ", 20, 1, iSXFLD, sXMGMX, tmaxfd, maxStepGas,
414 maxDestepGas, epsil, stmin);
415 //
416 // Ar-Isobuthane-Forane-SF6 gas
417 fMUON->AliMedium(7, "GAS_CH_TRIGGER ", 21, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
d4bb94a1 418
c3b69531 419 fMUON->AliMedium(8, "BAKE_CH_TRIGGER ", 19, 0, iSXFLD, sXMGMX, tmaxfd, maxStepAlu,
420 maxDestepAlu, epsil, stmin);
421 //
422 // slat medium
423 fMUON->AliMedium(9, "ARG_CO2 ", 22, 1, iSXFLD, sXMGMX, tmaxfd, maxStepGas,
424 maxDestepAlu, epsil, stmin);
425 //
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);
d4bb94a1 441 //.Materials specific to stations
442 // created via builders
443
444 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
445
446 // Get the builder
447 AliMUONVGeometryBuilder* builder
448 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
449
450 // Create materials with each builder
451 if (builder) builder->CreateMaterials();
452 }
453}
454
455//______________________________________________________________________________
456void AliMUONGeometryBuilder::InitGeometry()
457{
458 // Initialize geometry
459 // ---
460
461 //
462 // Set the chamber (sensitive region) GEANT identifier
463 //
464 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
465
466 // Get the builder
467 AliMUONVGeometryBuilder* builder
468 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
469
470 // Set sesitive volumes with each builder
76497dec 471 builder->SetSensitiveVolumes();
472
473 // Read sensitive volume map from a file
474 builder->ReadSVMap();
475 if (!fAlign) builder->FillTransformations();
476 }
477}
478
479//______________________________________________________________________________
480void AliMUONGeometryBuilder::WriteTransformations()
481{
482 // Writes transformations into files per builder
483 // ---
484
485 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
486
487 // Get the builder
488 AliMUONVGeometryBuilder* builder
489 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
490
491 // Write transformations
492 builder->WriteTransformations();
493 }
494}
495
496//______________________________________________________________________________
497void AliMUONGeometryBuilder::WriteSVMaps(Bool_t rebuild)
498{
499 // Writes sensitive volume maps into files per builder
500 // ---
501
502 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
503
504 // Get the builder
505 AliMUONVGeometryBuilder* builder
506 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
507
508 // Write transformations
509 builder->WriteSVMap(rebuild);
d4bb94a1 510 }
511}
512
513//_____________________________________________________________________________
514void AliMUONGeometryBuilder::AddBuilder(AliMUONVGeometryBuilder* geomBuilder)
515{
516// Adds the geometry builder to the list
517// ---
518
519 fGeometryBuilders->Add(geomBuilder);
520}
521
76497dec 522//_____________________________________________________________________________
523void AliMUONGeometryBuilder::SetAlign(Bool_t align)
524{
525// Sets the option for alignement
526// ---
527
528 fAlign = align;
529
530 for (Int_t j=0; j<AliMUONConstants::NCh(); j++) {
531
532 AliMUONChamberGeometry* geometry = fMUON->Chamber(j).GetGeometry();
533
534 if (!geometry) continue;
535 // Skip chambers with not defined geometry
536
537 geometry->SetAlign(align);
538 }
539}
540
541