]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometryBuilder.cxx
New methods to display tracking informations have been added
[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{
290// Definition of common materials
291// --
292
293 //
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;
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
325
326 Float_t abak[3] = {12.01 , 1.01 , 16.};
327 Float_t zbak[3] = {6. , 1. , 8.};
328 Float_t wbak[3] = {6. , 6. , 1.};
329 Float_t dbak = 1.4;
330
331 Int_t iSXFLD = gAlice->Field()->Integ();
332 Float_t sXMGMX = gAlice->Field()->Max();
333 //
334 // --- Define the various materials for GEANT ---
335 fMUON->AliMaterial(9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
336 fMUON->AliMaterial(10, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
337 // Air
338 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
339 Float_t zAir[4]={6.,7.,8.,18.};
340 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
341 Float_t dAir = 1.20479E-3;
342 fMUON->AliMixture(15, "AIR$ ", aAir, zAir, dAir,4, wAir);
343 // fMUON->AliMaterial(15, "AIR$ ", 14.61, 7.3, .001205, 30423.24, 67500);
344 fMUON->AliMixture(19, "Bakelite$", abak, zbak, dbak, -3, wbak);
345 fMUON->AliMixture(20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
346 fMUON->AliMixture(21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
347 fMUON->AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
348 fMUON->AliMixture(23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
349 fMUON->AliMixture(24, "ArCO2 GAS$", agas, zgas, dgas, 3, wgas);
350 // materials for slat:
351 // Sensitive area: gas (already defined)
352 // PCB: copper
353 // insulating material and frame: vetronite
354 // walls: carbon, rohacell, carbon
355 Float_t aglass[5]={12.01, 28.09, 16., 10.8, 23.};
356 Float_t zglass[5]={ 6., 14., 8., 5., 11.};
357 Float_t wglass[5]={ 0.5, 0.105, 0.355, 0.03, 0.01};
358 Float_t dglass=1.74;
359
360 // rohacell: C9 H13 N1 O2
361 Float_t arohac[4] = {12.01, 1.01, 14.010, 16.};
362 Float_t zrohac[4] = { 6., 1., 7., 8.};
363 Float_t wrohac[4] = { 9., 13., 1., 2.};
364 Float_t drohac = 0.03;
365
366 fMUON->AliMaterial(31, "COPPER$", 63.54, 29., 8.96, 1.4, 0.);
367 fMUON->AliMixture(32, "Vetronite$",aglass, zglass, dglass, 5, wglass);
368 fMUON->AliMaterial(33, "Carbon$", 12.01, 6., 2.265, 18.8, 49.9);
369 fMUON->AliMixture(34, "Rohacell$", arohac, zrohac, drohac, -4, wrohac);
370
371 Float_t epsil = .001; // Tracking precision,
372 Float_t stemax = -1.; // Maximum displacement for multiple scat
373 Float_t tmaxfd = -20.; // Maximum angle due to field deflection
374 Float_t deemax = -.3; // Maximum fractional energy loss, DLS
375 Float_t stmin = -.8;
376 Float_t maxDestepAlu = fMUON->GetMaxDestepAlu();
377 Float_t maxDestepGas = fMUON->GetMaxDestepGas();
378 Float_t maxStepAlu = fMUON->GetMaxStepAlu();
379 Float_t maxStepGas = fMUON->GetMaxStepGas();
380
381 //
382 // Air
383 fMUON->AliMedium(1, "AIR_CH_US ", 15, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
384 //
385 // Aluminum
386
387 fMUON->AliMedium(4, "ALU_CH_US ", 9, 0, iSXFLD, sXMGMX, tmaxfd, maxStepAlu,
388 maxDestepAlu, epsil, stmin);
389 fMUON->AliMedium(5, "ALU_CH_US ", 10, 0, iSXFLD, sXMGMX, tmaxfd, maxStepAlu,
390 maxDestepAlu, epsil, stmin);
391 //
392 // Ar-isoC4H10 gas
393
394 fMUON->AliMedium(6, "AR_CH_US ", 20, 1, iSXFLD, sXMGMX, tmaxfd, maxStepGas,
395 maxDestepGas, epsil, stmin);
396//
397 // Ar-Isobuthane-Forane-SF6 gas
398
399 fMUON->AliMedium(7, "GAS_CH_TRIGGER ", 21, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
400
401 fMUON->AliMedium(8, "BAKE_CH_TRIGGER ", 19, 0, iSXFLD, sXMGMX, tmaxfd, maxStepAlu,
402 maxDestepAlu, epsil, stmin);
403
404 fMUON->AliMedium(9, "ARG_CO2 ", 22, 1, iSXFLD, sXMGMX, tmaxfd, maxStepGas,
405 maxDestepAlu, epsil, stmin);
406 // tracking media for slats: check the parameters!!
407 fMUON->AliMedium(11, "PCB_COPPER ", 31, 0, iSXFLD, sXMGMX, tmaxfd,
408 maxStepAlu, maxDestepAlu, epsil, stmin);
409 fMUON->AliMedium(12, "VETRONITE ", 32, 0, iSXFLD, sXMGMX, tmaxfd,
410 maxStepAlu, maxDestepAlu, epsil, stmin);
411 fMUON->AliMedium(13, "CARBON ", 33, 0, iSXFLD, sXMGMX, tmaxfd,
412 maxStepAlu, maxDestepAlu, epsil, stmin);
413 fMUON->AliMedium(14, "Rohacell ", 34, 0, iSXFLD, sXMGMX, tmaxfd,
414 maxStepAlu, maxDestepAlu, epsil, stmin);
415
416
417
418 //.Materials specific to stations
419 // created via builders
420
421 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
422
423 // Get the builder
424 AliMUONVGeometryBuilder* builder
425 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
426
427 // Create materials with each builder
428 if (builder) builder->CreateMaterials();
429 }
430}
431
432//______________________________________________________________________________
433void AliMUONGeometryBuilder::InitGeometry()
434{
435 // Initialize geometry
436 // ---
437
438 //
439 // Set the chamber (sensitive region) GEANT identifier
440 //
441 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
442
443 // Get the builder
444 AliMUONVGeometryBuilder* builder
445 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
446
447 // Set sesitive volumes with each builder
76497dec 448 builder->SetSensitiveVolumes();
449
450 // Read sensitive volume map from a file
451 builder->ReadSVMap();
452 if (!fAlign) builder->FillTransformations();
453 }
454}
455
456//______________________________________________________________________________
457void AliMUONGeometryBuilder::WriteTransformations()
458{
459 // Writes transformations into files per builder
460 // ---
461
462 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
463
464 // Get the builder
465 AliMUONVGeometryBuilder* builder
466 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
467
468 // Write transformations
469 builder->WriteTransformations();
470 }
471}
472
473//______________________________________________________________________________
474void AliMUONGeometryBuilder::WriteSVMaps(Bool_t rebuild)
475{
476 // Writes sensitive volume maps into files per builder
477 // ---
478
479 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
480
481 // Get the builder
482 AliMUONVGeometryBuilder* builder
483 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
484
485 // Write transformations
486 builder->WriteSVMap(rebuild);
d4bb94a1 487 }
488}
489
490//_____________________________________________________________________________
491void AliMUONGeometryBuilder::AddBuilder(AliMUONVGeometryBuilder* geomBuilder)
492{
493// Adds the geometry builder to the list
494// ---
495
496 fGeometryBuilders->Add(geomBuilder);
497}
498
76497dec 499//_____________________________________________________________________________
500void AliMUONGeometryBuilder::SetAlign(Bool_t align)
501{
502// Sets the option for alignement
503// ---
504
505 fAlign = align;
506
507 for (Int_t j=0; j<AliMUONConstants::NCh(); j++) {
508
509 AliMUONChamberGeometry* geometry = fMUON->Chamber(j).GetGeometry();
510
511 if (!geometry) continue;
512 // Skip chambers with not defined geometry
513
514 geometry->SetAlign(align);
515 }
516}
517
518