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
23 //-----------------------------------------------------------------------------
25 #include "AliMUONGeometry.h"
26 #include "AliMUONGeometryTransformer.h"
27 #include "AliMUONGeometryModule.h"
28 #include "AliMUONStringIntMap.h"
30 #include "AliMpDEManager.h"
34 #include <TObjArray.h>
35 #include <Riostream.h>
44 ClassImp(AliMUONGeometry)
47 //______________________________________________________________________________
48 AliMUONGeometry::AliMUONGeometry(Bool_t isOwner)
54 /// Standard constructor
56 // Create array for geometry modules
57 fModules = new TObjArray();
58 fModules->SetOwner(isOwner);
60 // Geometry parametrisation
61 fTransformer = new AliMUONGeometryTransformer();
62 fTransformer->SetOwner(false);
65 //______________________________________________________________________________
66 AliMUONGeometry::AliMUONGeometry()
71 /// Default constructor
74 //______________________________________________________________________________
75 AliMUONGeometry::~AliMUONGeometry()
87 //______________________________________________________________________________
88 TString AliMUONGeometry::ComposePath(const TString& volName,
91 /// Compose path from given volName and copyNo
93 TString path(volName);
100 //______________________________________________________________________________
101 void AliMUONGeometry::FillData3(const TString& sensVolumePath,
104 /// Fill the mapping of the sensitive volume path to the detection element.
107 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
110 AliMUONGeometryModule* module
111 = (AliMUONGeometryModule*)fModules->At(moduleId);
115 << "Geometry module for det element " << detElemId << " not defined."
120 // Get module sensitive volumes map
121 AliMUONStringIntMap* svMap = module->GetSVMap();
123 // Map the sensitive volume to detection element
124 svMap->Add(sensVolumePath, detElemId);
127 //______________________________________________________________________________
128 TString AliMUONGeometry::ReadData3(ifstream& in)
130 /// Read SV maps from a file.
131 /// Return true, if reading finished correctly.
134 while ( key == TString("SV") ) {
143 //cout << "volumePath=" << volumePath << " "
144 // << "detElemId=" << detElemId
148 FillData3(volumePath, detElemId);
157 //______________________________________________________________________________
158 void AliMUONGeometry::WriteData3(ofstream& out) const
160 /// Write association of sensitive volumes and detection elements
161 /// from the sensitive volume map
163 for (Int_t i=0; i<fModules->GetEntriesFast(); i++) {
164 AliMUONGeometryModule* geometry
165 = (AliMUONGeometryModule*)fModules->At(i);
166 AliMUONStringIntMap* svMap
167 = geometry->GetSVMap();
169 svMap->Print("SV", out);
178 //_____________________________________________________________________________
179 void AliMUONGeometry::AddModule(AliMUONGeometryModule* module)
181 /// Add the geometry module to the array
183 fModules->Add(module);
186 fTransformer->AddModuleTransformer(module->GetTransformer());
189 //______________________________________________________________________________
191 AliMUONGeometry::ReadSVMap(const TString& fileName)
193 /// Read the sensitive volume maps from a file.
194 /// Return true, if reading finished correctly.
197 // if builder is not associated with any geometry module
198 if (fModules->GetEntriesFast() == 0) return false;
201 TString filePath = gSystem->Getenv("ALICE_ROOT");
202 filePath += "/MUON/data/";
203 filePath += fileName;
206 ifstream in(filePath, ios::in);
208 cerr << filePath << endl;
209 AliFatal("File not found.");
215 while ( !in.eof() ) {
216 if (key == TString("SV"))
219 AliFatal(Form("%s key not recognized", key.Data()));
227 //______________________________________________________________________________
229 AliMUONGeometry::WriteSVMap(const TString& fileName) const
231 /// Write sensitive volume map into a file.
232 /// Return true, if writing finished correctly.
235 // if builder is not associated with any geometry module
236 if (fModules->GetEntriesFast() == 0) return false;
239 TString filePath = gSystem->Getenv("ALICE_ROOT");
240 filePath += "/MUON/data/";
241 filePath += fileName;
244 ofstream out(filePath, ios::out);
246 cerr << filePath << endl;
247 AliError("File not found.");
250 #if !defined (__DECCXX)
251 out.setf(std::ios::fixed);
258 //_____________________________________________________________________________
259 const AliMUONGeometryModule*
260 AliMUONGeometry::GetModule(Int_t index, Bool_t warn) const
262 /// Return the geometry module specified by index
264 if (index < 0 || index >= fModules->GetEntriesFast()) {
267 << "Index: " << index << " outside limits" << std::endl;
272 return (const AliMUONGeometryModule*) fModules->At(index);
275 //_____________________________________________________________________________
276 const AliMUONGeometryModule*
277 AliMUONGeometry::GetModuleByDEId(Int_t detElemId, Bool_t warn) const
279 /// Return the geometry module specified by detElemId
282 Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
284 return GetModule(index, warn);