]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONVGeometryBuilder.cxx
Mapping test macros (D. Guez, I. Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / AliMUONVGeometryBuilder.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
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 purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // $Id$
17 //
18 // Class AliMUONVGeometryBuilder
19 // -----------------------------
20 // Abstract base class for geometry construction per geometry module(s).
21 // Author: Ivana Hrivnacova, IPN Orsay
22 // 23/01/2004
23
24 #include <Riostream.h>
25 #include <TObjArray.h>
26 #include <TSystem.h>
27 #include <TGeoMatrix.h>
28 #include <TVirtualMC.h>
29
30 #include "AliMUONVGeometryBuilder.h"
31 #include "AliMUONGeometryModule.h"
32 #include "AliMUONGeometryDetElement.h"
33 #include "AliMUONGeometryStore.h"
34 #include "AliMUONGeometrySVMap.h"
35 #include "AliMUONGeometryEnvelopeStore.h"
36 #include "AliMUONGeometryEnvelope.h"
37 #include "AliMUONGeometryConstituent.h"
38 #include "AliMUONVGeometryDEIndexing.h"
39 #include "AliLog.h"
40
41 ClassImp(AliMUONVGeometryBuilder)
42
43 const TString AliMUONVGeometryBuilder::fgkTransformFileNamePrefix = "transform_";
44 const TString AliMUONVGeometryBuilder::fgkSVMapFileNamePrefix = "svmap_";
45 const TString AliMUONVGeometryBuilder::fgkOutFileNameSuffix = ".out";
46
47 //______________________________________________________________________________
48 AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(const TString& fileName,
49                             AliMUONGeometryModule* mg1, AliMUONGeometryModule* mg2,
50                             AliMUONGeometryModule* mg3, AliMUONGeometryModule* mg4,
51                             AliMUONGeometryModule* mg5, AliMUONGeometryModule* mg6)
52  : TObject(),
53    fTransformFileName(fgkTransformFileNamePrefix+fileName),
54    fSVMapFileName(fgkSVMapFileNamePrefix+fileName),
55    fModuleGeometries(0)
56  {
57 // Standard constructor
58
59   // Create the module geometries array
60   fModuleGeometries = new TObjArray();
61   
62   if (mg1) fModuleGeometries->Add(mg1);
63   if (mg2) fModuleGeometries->Add(mg2);
64   if (mg3) fModuleGeometries->Add(mg3);
65   if (mg4) fModuleGeometries->Add(mg4);
66   if (mg5) fModuleGeometries->Add(mg5);
67   if (mg6) fModuleGeometries->Add(mg6);
68 }
69
70
71 //______________________________________________________________________________
72 AliMUONVGeometryBuilder::AliMUONVGeometryBuilder()
73  : TObject(),
74    fTransformFileName(),
75    fSVMapFileName(),
76    fModuleGeometries(0)
77 {
78 // Default constructor
79 }
80
81
82 //______________________________________________________________________________
83 AliMUONVGeometryBuilder::AliMUONVGeometryBuilder(const AliMUONVGeometryBuilder& rhs)
84   : TObject(rhs)
85 {
86 // Protected copy constructor
87
88   AliFatal("Copy constructor is not implemented.");
89 }
90
91 //______________________________________________________________________________
92 AliMUONVGeometryBuilder::~AliMUONVGeometryBuilder() {
93 //
94   if (fModuleGeometries) {
95     fModuleGeometries->Clear(); // Sets pointers to 0 since it is not the owner
96     delete fModuleGeometries;
97   }
98 }
99
100 //______________________________________________________________________________
101 AliMUONVGeometryBuilder& 
102 AliMUONVGeometryBuilder::operator = (const AliMUONVGeometryBuilder& rhs) 
103 {
104 // Protected assignement operator
105
106   // check assignement to self
107   if (this == &rhs) return *this;
108
109   AliFatal("Assignment operator is not implemented.");
110     
111   return *this;  
112 }
113
114 //
115 // private methods
116 //
117
118 //______________________________________________________________________________
119  TString  AliMUONVGeometryBuilder::ComposePath(const TString& volName, 
120                                                Int_t copyNo) const
121 {
122 // Compose path from given volName and copyNo
123 // ---
124
125   TString path(volName);
126   path += ".";
127   path += copyNo;
128   
129   return path;
130 }  
131
132 //______________________________________________________________________________
133 void AliMUONVGeometryBuilder::MapSV(const TString& path0, 
134                                     const TString& volName, Int_t detElemId) const
135 {
136 // Update the path with all daughters volumes recursively
137 // and map it to the detection element Id if it is a sensitive volume
138 // ---
139
140   Int_t nofDaughters = gMC->NofVolDaughters(volName);
141   if (nofDaughters == 0) {
142
143     // Get the name of the last volume in the path
144     Ssiz_t npos1 = path0.Last('/')+1; 
145     Ssiz_t npos2 = path0.Last('.');
146     TString volName(path0(npos1, npos2-npos1));  
147     
148     // Check if it is sensitive volume
149     Int_t moduleId = AliMUONVGeometryDEIndexing::GetModuleId(detElemId);
150     AliMUONGeometryModule* geometry = GetGeometry(moduleId);
151     if (geometry->IsSensitiveVolume(volName)) {
152       //cout << ".. adding to the map  " 
153       //     <<  path0 << "  "  << detElemId << endl;
154       FillData(path0, detElemId); 
155     }  
156     return; 
157   }  
158
159   for (Int_t i=0; i<nofDaughters; i++) {
160     Int_t copyNo = gMC->VolDaughterCopyNo(volName, i);
161     TString newName =  gMC->VolDaughterName(volName, i);
162             
163     TString path = path0;
164     path += "/";
165     path += ComposePath(newName, copyNo);
166
167     MapSV(path, newName, detElemId);
168   }
169 }     
170
171 //______________________________________________________________________________
172 void AliMUONVGeometryBuilder::FillData(Int_t moduleId, Int_t nofDetElements,
173                   Double_t x, Double_t y, Double_t z,
174                   Double_t a1, Double_t a2, Double_t a3,
175                   Double_t a4, Double_t a5, Double_t a6) const 
176 {
177 // Fill the transformation of the module.
178 // ---
179
180   moduleId--;
181       // Modules numbers in the file are starting from 1
182       
183   GetGeometry(moduleId)
184     ->GetDEIndexing()->SetNofDetElements(nofDetElements);    
185   GetGeometry(moduleId)
186     ->SetTranslation(TGeoTranslation(x, y, z));
187   GetGeometry(moduleId)
188     ->SetRotation(TGeoRotation("rot", a1, a2, a3, a4, a5, a6));
189 }                  
190   
191 //______________________________________________________________________________
192 void AliMUONVGeometryBuilder::FillData(
193                   Int_t detElemId, const TString& volName, Int_t copyNo,
194                   Double_t x, Double_t y, Double_t z,
195                   Double_t a1, Double_t a2, Double_t a3,
196                   Double_t a4, Double_t a5, Double_t a6) const 
197 {
198 // Fill the transformation of the detection element.
199 // ---
200
201   // Module Id
202   Int_t moduleId 
203     = AliMUONVGeometryDEIndexing::GetModuleId(detElemId);
204
205   // Compose path
206   TString path = ComposePath(volName, copyNo);
207   
208   // Compose matrix
209   TGeoCombiTrans transform(path, x, y, z, 
210                            new TGeoRotation(path, a1, a2, a3, a4, a5, a6));
211     
212   // Get detection element store
213   AliMUONGeometryStore* detElements = GetDetElements(moduleId);     
214
215   // Add detection element
216   detElements->Add(detElemId,
217      new AliMUONGeometryDetElement(detElemId, path, transform)); 
218 }                  
219   
220 //______________________________________________________________________________
221 void AliMUONVGeometryBuilder::FillData(
222                    const TString& sensVolumePath, Int_t detElemId) const
223 {
224 // Fill the mapping of the sensitive volume path to the detection element.
225 // ---
226
227   // Module Id
228   Int_t moduleId 
229     = AliMUONVGeometryDEIndexing::GetModuleId(detElemId);
230
231   // Get module sensitive volumes map
232   AliMUONGeometrySVMap* svMap = GetSVMap(moduleId);     
233
234   // Map the sensitive volume to detection element
235   svMap->Add(sensVolumePath, detElemId); 
236 }                  
237   
238 //______________________________________________________________________________
239 TString  AliMUONVGeometryBuilder::ReadData1(ifstream& in) const
240 {
241 // Reads and fills modules transformations from a file
242 // Returns true, if reading finished correctly.
243 // ---
244
245   TString key("CH");
246   while ( key == TString("CH") ) {
247     Int_t id, n;
248     Double_t  x, y, z;
249     Double_t  a1, a2, a3, a4, a5, a6;
250     TString dummy;
251   
252     in >> id;
253     in >> n;
254     in >> dummy;
255     in >> x;
256     in >> y;
257     in >> z;
258     in >> dummy;
259     in >> a1; 
260     in >> a2; 
261     in >> a3; 
262     in >> a4; 
263     in >> a5; 
264     in >> a6; 
265
266     //cout << "id="     << id << "  "
267     //   << "position= " << x << ", " << y << ", " << z << "  "
268     //   << "rotation= " << a1 << ", " << a2 << ", " << a3  << ", "
269     //                   << a4 << ", " << a5 << ", " << a6 
270     //   << endl;   
271          
272     // Fill data
273     FillData(id, n, x, y, z, a1, a2, a3, a4, a5, a6);
274     
275     // Go to next line
276     in >> key;
277   }
278   
279   return key;            
280 }
281
282 //______________________________________________________________________________
283 TString  AliMUONVGeometryBuilder::ReadData2(ifstream& in) const
284 {
285 // Reads detection elements transformations from a file
286 // Returns true, if reading finished correctly.
287 // ---
288
289   TString key("DE");
290   while ( key == TString("DE") ) {
291
292     // Input data
293     Int_t detElemId;
294     TString   volumeName;
295     Int_t     copyNo;
296     Double_t  x, y, z;
297     Double_t  a1, a2, a3, a4, a5, a6;
298     TString dummy;
299   
300     in >> detElemId;
301     in >> volumeName;
302     in >> copyNo;
303     in >> dummy;
304     in >> x;
305     in >> y;
306     in >> z;
307     in >> dummy;
308     in >> a1; 
309     in >> a2; 
310     in >> a3; 
311     in >> a4; 
312     in >> a5; 
313     in >> a6; 
314
315     //cout << "detElemId=" << detElemId << "  "
316     //     << "volume=" << volumeName << "  "
317     //     << "copyNo=" << copyNo << "  "
318     //     << "position= " << x << ", " << y << ", " << z << "  "
319     //     << "rotation= " << a1 << ", " << a2 << ", " << a3  << ", "
320     //                   << a4 << ", " << a5 << ", " << a6 
321     //     << endl;   
322          
323     // Fill data
324     FillData(detElemId, volumeName, copyNo, x, y, z, a1, a2, a3, a4, a5, a6);    
325     
326     // Go to next line
327     in >> key;
328   } 
329   
330   return key;
331 }
332
333 //______________________________________________________________________________
334 TString  AliMUONVGeometryBuilder::ReadData3(ifstream& in) const
335 {
336 // Reads detection elements transformations from a file
337 // Returns true, if reading finished correctly.
338 // ---
339
340   TString key("SV");
341   while ( key == TString("SV") ) {
342
343     // Input data
344     TString   volumePath;
345     Int_t     detElemId;
346   
347     in >> volumePath;
348     in >> detElemId;
349
350     //cout << "volumePath=" << volumePath << "  "
351     //   << "detElemId=" << detElemId    
352     //     << endl;   
353          
354     // Fill data
355     FillData(volumePath, detElemId); 
356      
357     // Go to next line
358     in >> key;
359   } 
360   
361   return key;
362 }
363
364 //______________________________________________________________________________
365 void AliMUONVGeometryBuilder::WriteTransform(ofstream& out, 
366                                    const TGeoCombiTrans* transform) const
367 {
368 // Writes the transformations 
369 // ---
370
371   out << "   pos: ";
372   const Double_t* xyz = transform->GetTranslation();
373   out << setw(10) << setprecision(4) << xyz[0] << "  " 
374       << setw(10) << setprecision(4) << xyz[1] << "  " 
375       << setw(10) << setprecision(4) << xyz[2];
376
377   out << "   rot: ";
378   Double_t a1, a2, a3, a4, a5, a6;
379   TGeoRotation* rotation = transform->GetRotation();
380   if (rotation) { 
381     rotation->GetAngles(a1, a2, a3, a4, a5, a6);
382   }
383   else {
384     TGeoRotation rotation2; 
385     rotation2.GetAngles(a1, a2, a3, a4, a5, a6);
386   }  
387       
388   out << setw(8) << setprecision(4) << a1 << "  " 
389       << setw(8) << setprecision(4) << a2 << "  " 
390       << setw(8) << setprecision(4) << a3 << "  " 
391       << setw(8) << setprecision(4) << a4 << "  " 
392       << setw(8) << setprecision(4) << a5 << "  " 
393       << setw(8) << setprecision(4) << a6 << "  " << endl; 
394 }
395
396 //______________________________________________________________________________
397 void AliMUONVGeometryBuilder::WriteData1(ofstream& out) const
398 {
399 // Writes modules transformations
400 // ---
401
402   for (Int_t i=0; i<fModuleGeometries->GetEntriesFast(); i++) {
403     AliMUONGeometryModule* geometry 
404       = (AliMUONGeometryModule*)fModuleGeometries->At(i);
405     const TGeoCombiTrans* transform 
406       = geometry->GetTransformation();    
407
408     out << "CH " 
409         << setw(4) << geometry->GetModuleId() + 1 << "  "
410         << setw(4) << geometry->GetDetElementStore()->GetNofEntries() << "  ";
411     
412     WriteTransform(out, transform);
413   }
414   out << endl;
415 }
416
417 //______________________________________________________________________________
418 void AliMUONVGeometryBuilder::WriteData2(ofstream& out) const
419 {
420 // Writes detection elements (envelopes) transformations
421 // ---
422
423
424   for (Int_t i=0; i<fModuleGeometries->GetEntriesFast(); i++) {
425     AliMUONGeometryModule* geometry 
426       = (AliMUONGeometryModule*)fModuleGeometries->At(i);
427     const TObjArray* envelopes 
428       = geometry->GetEnvelopeStore()->GetEnvelopes();    
429
430     for (Int_t j=0; j<envelopes->GetEntriesFast(); j++) {
431       AliMUONGeometryEnvelope* envelope
432         = (AliMUONGeometryEnvelope*)envelopes->At(j);
433       const TGeoCombiTrans* transform 
434         = envelope->GetTransformation(); 
435       
436       // skip envelope not corresponding to detection element
437       if(envelope->GetUniqueID() == 0) continue;
438        
439       out << "DE " 
440           << setw(4) << envelope->GetUniqueID() << "    " 
441           << envelope->GetName() << " " 
442           << setw(4)<< envelope->GetCopyNo();
443      
444       WriteTransform(out, transform);
445     }
446     out << endl;                        
447   }     
448 }
449
450 //______________________________________________________________________________
451 void AliMUONVGeometryBuilder::WriteData3(ofstream& out) const
452 {
453 // Writes association of sensitive volumes and detection elements
454 // from the sensitive volume map
455 // ---
456
457   for (Int_t i=0; i<fModuleGeometries->GetEntriesFast(); i++) {
458     AliMUONGeometryModule* geometry 
459       = (AliMUONGeometryModule*)fModuleGeometries->At(i);
460     AliMUONGeometrySVMap* svMap
461       = geometry->GetSVMap();
462
463     svMap->WriteMap(out);
464     out << endl;  
465   }    
466 }
467
468 //
469 // protected methods
470 //
471
472 //______________________________________________________________________________
473 AliMUONGeometryModule*  
474 AliMUONVGeometryBuilder::GetGeometry(Int_t moduleId) const
475 {
476 // Returns the module geometry specified by moduleId
477 // ---
478
479   for (Int_t i=0; i<fModuleGeometries->GetEntriesFast(); i++) {
480
481     AliMUONGeometryModule* geometry 
482       = (AliMUONGeometryModule*)fModuleGeometries->At(i);
483
484     if ( geometry->GetModuleId() == moduleId) return geometry;
485   }   
486   
487   return 0;
488 }  
489
490 //______________________________________________________________________________
491 AliMUONGeometryEnvelopeStore*  
492 AliMUONVGeometryBuilder::GetEnvelopes(Int_t moduleId) const
493 {
494 // Returns the envelope store of the module geometry specified by moduleId
495 // ---
496
497   AliMUONGeometryModule* geometry = GetGeometry(moduleId);
498   
499   if (!geometry) {
500     AliFatal(Form("Module geometry %d is not defined", moduleId)); 
501     return 0;
502   }
503   
504   return geometry->GetEnvelopeStore();
505 }  
506
507 //______________________________________________________________________________
508 AliMUONGeometryStore*  
509 AliMUONVGeometryBuilder::GetDetElements(Int_t moduleId) const
510 {
511 // Returns the detection elemnts store of the module geometry specified 
512 // by moduleId
513 // ---
514
515   AliMUONGeometryModule* geometry = GetGeometry(moduleId);
516   
517   if (!geometry) {
518     AliFatal(Form("Module geometry %d is not defined", moduleId)); 
519     return 0;
520   }
521   
522   return geometry->GetDetElementStore();
523 }  
524
525 //______________________________________________________________________________
526 AliMUONGeometrySVMap*  
527 AliMUONVGeometryBuilder::GetSVMap(Int_t moduleId) const
528 {
529 // Returns the transformation store of the module geometry specified by moduleId
530 // ---
531
532   AliMUONGeometryModule* geometry = GetGeometry(moduleId);
533   
534   if (!geometry) {
535     AliFatal(Form("Geometry %d is not defined", moduleId)); 
536     return 0;
537   }
538   
539   return geometry->GetSVMap();
540 }  
541
542 //
543 // public functions
544 //
545
546 //______________________________________________________________________________
547 void  AliMUONVGeometryBuilder::FillTransformations() const
548 {
549 // Fills transformations store from defined geometry.
550 // ---
551
552   for (Int_t i=0; i<fModuleGeometries->GetEntriesFast(); i++) {
553     AliMUONGeometryModule* geometry 
554       = (AliMUONGeometryModule*)fModuleGeometries->At(i);
555     const TObjArray* envelopes 
556       = geometry->GetEnvelopeStore()->GetEnvelopes();    
557     
558     AliMUONGeometryStore* detElements = geometry->GetDetElementStore(); 
559       
560     // Set nof detection elements to the indexing
561     geometry->GetDEIndexing()
562       ->SetNofDetElements(geometry->GetEnvelopeStore()->GetNofDetElements()); 
563
564     for (Int_t j=0; j<envelopes->GetEntriesFast(); j++) {
565       AliMUONGeometryEnvelope* envelope
566         = (AliMUONGeometryEnvelope*)envelopes->At(j);
567
568       // skip envelope not corresponding to detection element
569       if(envelope->GetUniqueID() == 0) continue;
570        
571       // Get envelope data 
572       Int_t detElemId = envelope->GetUniqueID();        
573       TString path = ComposePath(envelope->GetName(), 
574                                  envelope->GetCopyNo());
575       const TGeoCombiTrans* transform = envelope->GetTransformation(); 
576
577       // Add detection element transformation 
578       detElements->Add(detElemId,
579         new AliMUONGeometryDetElement(detElemId, path, *transform)); 
580     }  
581   }
582 }
583
584 //_____ _________________________________________________________________________
585 void  AliMUONVGeometryBuilder::RebuildSVMaps() const
586 {
587 // Clear the SV maps in memory and fill them from defined geometry.
588 // ---
589
590   for (Int_t i=0; i<fModuleGeometries->GetEntriesFast(); i++) {
591     AliMUONGeometryModule* geometry 
592       = (AliMUONGeometryModule*)fModuleGeometries->At(i);
593     
594     // Clear the map   
595     geometry->GetSVMap()->Clear();
596      
597     // Fill the map from geometry
598     const TObjArray* envelopes 
599       = geometry->GetEnvelopeStore()->GetEnvelopes();    
600
601     for (Int_t j=0; j<envelopes->GetEntriesFast(); j++) {
602       AliMUONGeometryEnvelope* envelope
603         = (AliMUONGeometryEnvelope*)envelopes->At(j);
604
605       // skip envelope not corresponding to detection element
606       if(envelope->GetUniqueID() == 0) continue;
607        
608       TString path0("/ALIC.1");
609       if (geometry->GetMotherVolume() != "ALIC") {
610         path0 += "/";
611         path0 += ComposePath(geometry->GetMotherVolume(), 1);
612       }  
613        
614       if (!envelope->IsVirtual()) {
615          TString path = path0;
616          path += "/";
617          path += ComposePath(envelope->GetName(), envelope->GetCopyNo());
618          MapSV(path, envelope->GetName(), envelope->GetUniqueID());
619       }
620       else {     
621         for  (Int_t k=0; k<envelope->GetConstituents()->GetEntriesFast(); k++) {
622           AliMUONGeometryConstituent* constituent
623             = (AliMUONGeometryConstituent*)envelope->GetConstituents()->At(k);
624          TString path = path0;
625          path += "/";
626          path += ComposePath(constituent->GetName(), constituent->GetCopyNo());
627          MapSV(path, constituent->GetName(), envelope->GetUniqueID());
628         }
629       }
630     }  
631   }                  
632 }
633
634 //______________________________________________________________________________
635 Bool_t  AliMUONVGeometryBuilder::ReadTransformations() const
636 {
637 // Reads transformations from a file
638 // Returns true, if reading finished correctly.
639 // ---
640
641   // No reading
642   // if builder is not associated with any geometry module
643   if (fModuleGeometries->GetEntriesFast() == 0) return false;
644
645   // File path
646   TString filePath = gSystem->Getenv("ALICE_ROOT");
647   filePath += "/MUON/data/";
648   filePath += fTransformFileName;
649   
650   // Open input file
651   ifstream in(filePath, ios::in);
652   if (!in) {
653     cerr << filePath << endl;   
654     AliFatal("File not found.");
655     return false;
656   }
657
658   TString key;
659   in >> key;
660   while ( !in.eof() ) {
661     if (key == TString("CH")) 
662       key = ReadData1(in);
663     else if (key == TString("DE"))
664       key = ReadData2(in);
665     else {
666       AliFatal(Form("%s key not recognized",  key.Data()));
667       return false;
668     }
669   }     
670
671   return true;
672 }
673
674 //______________________________________________________________________________
675 Bool_t  AliMUONVGeometryBuilder::ReadSVMap() const
676 {
677 // Reads the sensitive volume from a file
678 // Returns true, if reading finished correctly.
679 // ---
680
681   // No reading
682   // if builder is not associated with any geometry module
683   if (fModuleGeometries->GetEntriesFast() == 0) return false;
684
685   // File path
686   TString filePath = gSystem->Getenv("ALICE_ROOT");
687   filePath += "/MUON/data/";
688   filePath += fSVMapFileName;
689   
690   // Open input file
691   ifstream in(filePath, ios::in);
692   if (!in) {
693     cerr << filePath << endl;   
694     AliFatal("File not found.");
695     return false;
696   }
697
698   TString key;
699   in >> key;
700   while ( !in.eof() ) {
701     if (key == TString("SV")) 
702       key = ReadData3(in);
703     else {
704       AliFatal(Form("%s key not recognized",  key.Data()));
705       return false;
706     }
707   }     
708
709   return true;
710 }
711
712 //______________________________________________________________________________
713 Bool_t  AliMUONVGeometryBuilder::WriteTransformations() const
714 {
715 // Writes transformations into a file
716 // Returns true, if writing finished correctly.
717 // ---
718
719   // No writing
720   // if builder is not associated with any geometry module
721   if (fModuleGeometries->GetEntriesFast() == 0) return false;
722
723   // File path
724   TString filePath = gSystem->Getenv("ALICE_ROOT");
725   filePath += "/MUON/data/";
726   filePath += fTransformFileName;
727   filePath += fgkOutFileNameSuffix;
728   
729   // Open input file
730   ofstream out(filePath, ios::out);
731   if (!out) {
732     cerr << filePath << endl;   
733     AliError("File not found.");
734     return false;
735   }
736 #if !defined (__DECCXX)
737   out.setf(std::ios::fixed);
738 #endif
739   WriteData1(out);
740   WriteData2(out);
741   
742   return true;
743 }  
744
745 //______________________________________________________________________________
746 Bool_t  AliMUONVGeometryBuilder::WriteSVMap(Bool_t rebuild) const
747 {
748 // Writes sensitive volume map into a file
749 // Returns true, if writing finished correctly.
750 // ---
751
752   // No writing
753   // if builder is not associated with any geometry module
754   if (fModuleGeometries->GetEntriesFast() == 0) return false;
755
756   // File path
757   TString filePath = gSystem->Getenv("ALICE_ROOT");
758   filePath += "/MUON/data/";
759   filePath += fSVMapFileName;
760   filePath += fgkOutFileNameSuffix;
761   
762   // Open input file
763   ofstream out(filePath, ios::out);
764   if (!out) {
765     cerr << filePath << endl;   
766     AliError("File not found.");
767     return false;
768   }
769 #if !defined (__DECCXX)
770   out.setf(std::ios::fixed);
771 #endif  
772   if (rebuild)  RebuildSVMaps();
773
774   WriteData3(out);
775   
776   return true;
777 }  
778