]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryBuilder.cxx
ALIROOT-5420 Changes for CDH v3
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryBuilder.cxx
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 //-----------------------------------------------------------------------------
19 // Class AliMUONGeometryBuilder
20 // ----------------------------
21 // Manager class for geometry construction via geometry builders.
22 // Author: Ivana Hrivnacova, IPN Orsay
23 //-----------------------------------------------------------------------------
24
25 #include "AliMUONGeometryBuilder.h"
26 #include "AliMUONVGeometryBuilder.h"    
27 #include "AliMUONGeometry.h"
28 #include "AliMUONGeometryTransformer.h"
29 #include "AliMUONGeometryModule.h"      
30 #include "AliMUONGeometryModuleTransformer.h"   
31 #include "AliMUONGeometryEnvelope.h"    
32 #include "AliMUONGeometryEnvelopeStore.h"
33 #include "AliMUONGeometryDetElement.h"
34 #include "AliMUONGeometryConstituent.h"
35
36 #include "AliMpDEManager.h"
37
38 #include "AliModule.h"
39 #include "AliSimulation.h"
40 #include "AliLog.h"
41 #include "AliRun.h"
42
43 #include <TObjArray.h>
44 #include <TVirtualMC.h>
45 #include <TGeoManager.h>
46
47 using std::endl;
48 /// \cond CLASSIMP
49 ClassImp(AliMUONGeometryBuilder)
50 /// \endcond
51
52 //
53 // static functions
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
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
137 //
138 // ctors, dtor
139 //
140
141 //______________________________________________________________________________
142 AliMUONGeometryBuilder::AliMUONGeometryBuilder(AliModule* module)
143   : TObject(),
144     fModule(module),
145     fAlign(false),
146     fTransformFileName(GetDefaultTransformFileName()),
147     fSVMapFileName(GetDefaultSVMapFileName()),
148     fGlobalTransformation(), 
149     fGeometryBuilders(0),
150     fGeometry(0)
151 {
152 /// Standard constructor
153
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);
165 }
166
167 //______________________________________________________________________________
168 AliMUONGeometryBuilder::AliMUONGeometryBuilder() 
169   : TObject(),
170     fModule(0),
171     fAlign(false),
172     fTransformFileName(),
173     fSVMapFileName(),
174     fGlobalTransformation(),
175     fGeometryBuilders(0),
176     fGeometry(0)
177 {
178 /// Default constructor
179
180
181 //______________________________________________________________________________
182 AliMUONGeometryBuilder::~AliMUONGeometryBuilder()
183 {
184 /// Destructor
185   
186   delete fGeometryBuilders;
187   delete fGeometry;
188 }
189
190 //
191 // private functions
192 //
193
194 //______________________________________________________________________________
195 void AliMUONGeometryBuilder::PlaceVolume(const TString& name, const TString& mName, 
196                             Int_t copyNo, const TGeoHMatrix& matrix, 
197                             Int_t npar, Double_t* param, const char* only,
198                             Bool_t makeAssembly) const
199 {
200 /// Place the volume specified by name with the given transformation matrix
201
202   if (makeAssembly)
203     gGeoManager->MakeVolumeAssembly(name.Data());
204
205   TGeoHMatrix transform(matrix);
206   // Do not apply global transformation 
207   // if mother volume was already placed in 
208   // the new system of coordinates (that is MUON in negative Z)
209   // (as it is applied on the mother volume)
210   if (mName == TString("DDIP"))
211     transform = fGlobalTransformation.Inverse() * transform;
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         
251     fModule->AliMatrix(krot, theta1, phi1, theta2, phi2, theta3, phi3);
252   }     
253         
254   // Place the volume
255   if (npar == 0)
256     gMC->Gspos(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, only);
257   else 
258     gMC->Gsposp(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, only,
259                 param, npar);
260
261
262 //______________________________________________________________________________
263 void AliMUONGeometryBuilder::CreateGeometryWithTGeo()
264 {
265 /// Construct geometry using geometry builders.
266 /// Virtual modules/envelopes are placed as TGeoVolume assembly
267
268   if (fAlign) {
269     // Read transformations from ASCII data file  
270     fGeometry->GetTransformer()
271       ->LoadGeometryData(fTransformFileName);
272   }    
273  
274   for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
275
276     // Get the builder
277     AliMUONVGeometryBuilder* builder
278       = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
279
280     // Create geometry + envelopes
281     //
282     builder->CreateGeometry();
283     builder->SetVolumes();
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());
299   
300       TGeoCombiTrans appliedGlobalTransform;
301       if (builder->ApplyGlobalTransformation())
302         appliedGlobalTransform = fGlobalTransformation;
303
304       // Loop over envelopes
305       const TObjArray* kEnvelopes 
306         = geometry->GetEnvelopeStore()->GetEnvelopes();
307       for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) {
308
309         // Get envelope
310         AliMUONGeometryEnvelope* env 
311           = (AliMUONGeometryEnvelope*)kEnvelopes->At(k);
312           
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           
327         const TGeoCombiTrans* kEnvTrans = env->GetTransformation();
328         const char* only = "ONLY";
329         if (env->IsMANY()) only = "MANY";
330
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
370 }
371
372 //______________________________________________________________________________
373 void AliMUONGeometryBuilder::CreateGeometryWithoutTGeo()
374 {
375 /// Construct geometry using geometry builders.
376 /// Virtual modules/envelopes are not placed
377
378   if (fAlign) {
379     // Read transformations from ASCII data file  
380     fGeometry->GetTransformer()->LoadGeometryData(fTransformFileName);
381   }     
382
383   for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
384
385     // Get the builder
386     AliMUONVGeometryBuilder* builder
387       = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
388
389     // Create geometry + envelopes
390     //
391     builder->CreateGeometry();
392     if (!fAlign) builder->SetTransformations();
393     
394     // Place module volumes and envelopes
395     //
396     for (Int_t j=0; j<builder->NofGeometries(); j++) {
397
398       AliMUONGeometryModule* geometry = builder->Geometry(j);
399       AliMUONGeometryModuleTransformer* transformer= geometry->GetTransformer();
400       const TGeoHMatrix* kModuleTransform = transformer->GetTransformation();
401       TString volName       = transformer->GetVolumeName(); 
402       TString motherVolName = transformer->GetMotherVolumeName(); 
403       
404       // Place the module volume
405       if ( !geometry->IsVirtual() ) {
406           PlaceVolume(volName, motherVolName, 
407                       1, *kModuleTransform, 0, 0, "ONLY");
408       }               
409   
410       TGeoCombiTrans appliedGlobalTransform;
411       if (builder->ApplyGlobalTransformation())
412         appliedGlobalTransform = fGlobalTransformation;
413
414       // Loop over envelopes
415       const TObjArray* kEnvelopes 
416         = geometry->GetEnvelopeStore()->GetEnvelopes();
417       for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) {
418
419         // Get envelope
420         AliMUONGeometryEnvelope* env 
421           = (AliMUONGeometryEnvelope*)kEnvelopes->At(k);
422           
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           
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         }
448
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 
459           //        => place envelope by composed transformation:
460           //           Tch * [Tglobal] * Tenv
461
462           // Compound chamber transformation with the envelope one
463           if (geometry->IsVirtual()) {
464              TGeoHMatrix total 
465                = Multiply( (*kModuleTransform), 
466                             appliedGlobalTransform, 
467                            (*kEnvTrans) );
468              PlaceVolume(env->GetName(), motherVolName,
469                          env->GetCopyNo(), total, 0, 0, only);
470           }
471           else {
472              TGeoHMatrix total 
473                = Multiply( appliedGlobalTransform, 
474                            (*kEnvTrans) );
475              PlaceVolume(env->GetName(), volName,
476                          env->GetCopyNo(), total, 0, 0, only);
477           }                      
478         }
479
480         if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) {
481           // virtual envelope + nof constituents > 0 
482           //         => do not place envelope and place constituents
483           //            by composed transformation:
484           //            Tch * [Tglobal] * Tenv * Tconst   
485
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
491             if (geometry->IsVirtual()) {
492               TGeoHMatrix total 
493                 = Multiply ( (*kModuleTransform),
494                              appliedGlobalTransform, 
495                              (*kEnvTrans), 
496                              (*constituent->GetTransformation()) );
497
498               PlaceVolume(constituent->GetName(), motherVolName,
499                           constituent->GetCopyNo(), total,
500                           constituent->GetNpar(), constituent->GetParam(), only);
501             }
502             else {                        
503               TGeoHMatrix total 
504                 = Multiply ( appliedGlobalTransform, 
505                              (*kEnvTrans),
506                              (*constituent->GetTransformation()) );
507
508               PlaceVolume(constituent->GetName(), volName,
509                           constituent->GetCopyNo(), total,
510                           constituent->GetNpar(), constituent->GetParam(), only);
511             }                     
512           }
513         }
514       } // end of loop over envelopes
515     } // end of loop over builder geometries
516   } // end of loop over builders
517 }
518
519 //_____________________________________________________________________________
520 void AliMUONGeometryBuilder::SetAlignToBuilder(AliMUONVGeometryBuilder* builder) const
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   
551   SetAlignToBuilder(geomBuilder);
552 }
553
554 //______________________________________________________________________________
555 void AliMUONGeometryBuilder::CreateGeometry()
556 {
557 /// Construct geometry using geometry builders.
558
559   if ( gMC->IsRootGeometrySupported() ) {
560        
561    CreateGeometryWithTGeo();
562   } 
563   else
564    CreateGeometryWithoutTGeo();
565
566   for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
567
568     // Get the builder
569     AliMUONVGeometryBuilder* builder
570       = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
571  
572     // Update detection elements from built geometry
573     Bool_t create = ! fAlign;
574     builder->UpdateDetElements(create);
575   }
576 }
577
578 //_____________________________________________________________________________
579 void AliMUONGeometryBuilder::CreateMaterials()
580 {
581 /// Construct materials specific to modules via builders
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 //______________________________________________________________________________
595 void AliMUONGeometryBuilder::InitGeometry(const TString& svmapFileName)
596 {
597 /// Initialize geometry
598
599   // Load alignement data from geometry if geometry is read from Root file
600   if ( AliSimulation::Instance()->IsGeometryFromFile() ) {
601     fAlign = true;
602     fGeometry->GetTransformer()->LoadGeometryData();
603  }    
604
605   // Read sensitive volume map from a file
606   fGeometry->ReadSVMap(svmapFileName);
607
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
616     // Set sensitive volumes with each builder
617     builder->SetSensitiveVolumes();
618   }  
619 }
620
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
630 //______________________________________________________________________________
631 void AliMUONGeometryBuilder::WriteSVMaps(const TString& fileName, 
632                                          Bool_t rebuild, Bool_t writeEnvelopes)
633 {
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++) {
640
641       AliMUONVGeometryBuilder* builder
642         = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
643
644       builder->RebuildSVMaps(writeEnvelopes);
645     }  
646     
647   // Write maps in file
648   fGeometry->WriteSVMap(fileName);
649 }
650
651 //_____________________________________________________________________________
652 void AliMUONGeometryBuilder::SetAlign(Bool_t align)
653
654 /// Set the option for alignement
655
656   fAlign = align; 
657
658   for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
659
660     AliMUONVGeometryBuilder* builder
661       = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
662     
663     SetAlignToBuilder(builder); 
664   }   
665 }
666
667 //_____________________________________________________________________________
668 void AliMUONGeometryBuilder::SetAlign(const TString& fileName, Bool_t align)
669
670 /// Set the option for alignement and the transformations file name
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     
680     SetAlignToBuilder(builder); 
681   }   
682 }