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 // ----------------------------
19 // Class AliMUONGeometry
20 // ----------------------------
21 // Manager class for geometry construction via geometry builders.
22 // Author: Ivana Hrivnacova, IPN Orsay
24 #include "AliMUONGeometry.h"
25 #include "AliMUONGeometryTransformer.h"
26 #include "AliMUONGeometryModule.h"
27 #include "AliMUONStringIntMap.h"
29 #include "AliMpDEManager.h"
33 #include <TObjArray.h>
34 #include <Riostream.h>
40 ClassImp(AliMUONGeometry)
43 //______________________________________________________________________________
44 AliMUONGeometry::AliMUONGeometry(Bool_t isOwner)
50 /// Standard constructor
52 // Create array for geometry modules
53 fModules = new TObjArray();
54 fModules->SetOwner(isOwner);
56 // Geometry parametrisation
57 fTransformer = new AliMUONGeometryTransformer(false);
60 //______________________________________________________________________________
61 AliMUONGeometry::AliMUONGeometry()
66 /// Default constructor
69 //______________________________________________________________________________
70 AliMUONGeometry::~AliMUONGeometry()
82 //______________________________________________________________________________
83 TString AliMUONGeometry::ComposePath(const TString& volName,
86 /// Compose path from given volName and copyNo
88 TString path(volName);
95 //______________________________________________________________________________
96 void AliMUONGeometry::FillData3(const TString& sensVolumePath,
99 /// Fill the mapping of the sensitive volume path to the detection element.
102 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
105 AliMUONGeometryModule* module
106 = (AliMUONGeometryModule*)fModules->At(moduleId);
110 << "Geometry module for det element " << detElemId << " not defined."
115 // Get module sensitive volumes map
116 AliMUONStringIntMap* svMap = module->GetSVMap();
118 // Map the sensitive volume to detection element
119 svMap->Add(sensVolumePath, detElemId);
122 //______________________________________________________________________________
123 TString AliMUONGeometry::ReadData3(ifstream& in)
125 /// Read SV maps from a file.
126 /// Return true, if reading finished correctly.
129 while ( key == TString("SV") ) {
138 //cout << "volumePath=" << volumePath << " "
139 // << "detElemId=" << detElemId
143 FillData3(volumePath, detElemId);
152 //______________________________________________________________________________
153 void AliMUONGeometry::WriteData3(ofstream& out) const
155 /// Write association of sensitive volumes and detection elements
156 /// from the sensitive volume map
158 for (Int_t i=0; i<fModules->GetEntriesFast(); i++) {
159 AliMUONGeometryModule* geometry
160 = (AliMUONGeometryModule*)fModules->At(i);
161 AliMUONStringIntMap* svMap
162 = geometry->GetSVMap();
164 svMap->Print("SV", out);
173 //_____________________________________________________________________________
174 void AliMUONGeometry::AddModule(AliMUONGeometryModule* module)
176 /// Add the geometry module to the array
178 fModules->Add(module);
181 fTransformer->AddModuleTransformer(module->GetTransformer());
184 //______________________________________________________________________________
186 AliMUONGeometry::ReadSVMap(const TString& fileName)
188 /// Read the sensitive volume maps from a file.
189 /// Return true, if reading finished correctly.
192 // if builder is not associated with any geometry module
193 if (fModules->GetEntriesFast() == 0) return false;
196 TString filePath = gSystem->Getenv("ALICE_ROOT");
197 filePath += "/MUON/data/";
198 filePath += fileName;
201 ifstream in(filePath, ios::in);
203 cerr << filePath << endl;
204 AliFatal("File not found.");
210 while ( !in.eof() ) {
211 if (key == TString("SV"))
214 AliFatal(Form("%s key not recognized", key.Data()));
222 //______________________________________________________________________________
224 AliMUONGeometry::WriteSVMap(const TString& fileName) const
226 /// Write sensitive volume map into a file.
227 /// Return true, if writing finished correctly.
230 // if builder is not associated with any geometry module
231 if (fModules->GetEntriesFast() == 0) return false;
234 TString filePath = gSystem->Getenv("ALICE_ROOT");
235 filePath += "/MUON/data/";
236 filePath += fileName;
239 ofstream out(filePath, ios::out);
241 cerr << filePath << endl;
242 AliError("File not found.");
245 #if !defined (__DECCXX)
246 out.setf(std::ios::fixed);
253 //_____________________________________________________________________________
254 const AliMUONGeometryModule*
255 AliMUONGeometry::GetModule(Int_t index, Bool_t warn) const
257 /// Return the geometry module specified by index
259 if (index < 0 || index >= fModules->GetEntriesFast()) {
262 << "Index: " << index << " outside limits" << std::endl;
267 return (const AliMUONGeometryModule*) fModules->At(index);
270 //_____________________________________________________________________________
271 const AliMUONGeometryModule*
272 AliMUONGeometry::GetModuleByDEId(Int_t detElemId, Bool_t warn) const
274 /// Return the geometry module specified by detElemId
277 Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
279 return GetModule(index, warn);