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"
28 #include "AliMUONGeometryStore.h"
32 #include <TObjArray.h>
33 #include <Riostream.h>
38 ClassImp(AliMUONGeometry)
40 //______________________________________________________________________________
41 AliMUONGeometry::AliMUONGeometry(Bool_t isOwner)
47 /// Standard constructor
49 // Create array for geometry modules
50 fModules = new TObjArray();
51 fModules->SetOwner(isOwner);
53 // Geometry parametrisation
54 fTransformer = new AliMUONGeometryTransformer(false);
57 //______________________________________________________________________________
58 AliMUONGeometry::AliMUONGeometry()
63 /// Default constructor
66 //______________________________________________________________________________
67 AliMUONGeometry::AliMUONGeometry(const AliMUONGeometry& right)
70 /// Copy constructor (not implemented)
72 AliFatal("Copy constructor not provided.");
75 //______________________________________________________________________________
76 AliMUONGeometry::~AliMUONGeometry()
84 //______________________________________________________________________________
86 AliMUONGeometry::operator=(const AliMUONGeometry& right)
88 /// Assignement operator (not implemented)
90 // check assignement to self
91 if (this == &right) return *this;
93 AliFatal("Assignement operator not provided.");
102 //______________________________________________________________________________
103 TString AliMUONGeometry::ComposePath(const TString& volName,
106 // Compose path from given volName and copyNo
109 TString path(volName);
116 //______________________________________________________________________________
117 void AliMUONGeometry::FillData3(const TString& sensVolumePath,
120 // Fill the mapping of the sensitive volume path to the detection element.
124 Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
127 AliMUONGeometryModule* module
128 = (AliMUONGeometryModule*)fModules->At(moduleId);
132 << "Geometry module for det element " << detElemId << " not defined."
137 // Get module sensitive volumes map
138 AliMUONStringIntMap* svMap = module->GetSVMap();
140 // Map the sensitive volume to detection element
141 svMap->Add(sensVolumePath, detElemId);
144 //______________________________________________________________________________
145 TString AliMUONGeometry::ReadData3(ifstream& in)
147 // Reads SV maps from a file
148 // Returns true, if reading finished correctly.
152 while ( key == TString("SV") ) {
161 //cout << "volumePath=" << volumePath << " "
162 // << "detElemId=" << detElemId
166 FillData3(volumePath, detElemId);
175 //______________________________________________________________________________
176 void AliMUONGeometry::WriteData3(ofstream& out) const
178 // Writes association of sensitive volumes and detection elements
179 // from the sensitive volume map
182 for (Int_t i=0; i<fModules->GetEntriesFast(); i++) {
183 AliMUONGeometryModule* geometry
184 = (AliMUONGeometryModule*)fModules->At(i);
185 AliMUONStringIntMap* svMap
186 = geometry->GetSVMap();
188 svMap->Print("SV", out);
197 //_____________________________________________________________________________
198 void AliMUONGeometry::AddModule(AliMUONGeometryModule* module)
200 /// Add the geometrymodule to the array
202 fModules->Add(module);
205 fTransformer->AddModuleTransformer(module->GetTransformer());
208 //______________________________________________________________________________
210 AliMUONGeometry::ReadSVMap(const TString& fileName)
212 // Reads the sensitive volume maps from a file
213 // Returns true, if reading finished correctly.
217 // if builder is not associated with any geometry module
218 if (fModules->GetEntriesFast() == 0) return false;
221 TString filePath = gSystem->Getenv("ALICE_ROOT");
222 filePath += "/MUON/data/";
223 filePath += fileName;
226 ifstream in(filePath, ios::in);
228 cerr << filePath << endl;
229 AliFatal("File not found.");
235 while ( !in.eof() ) {
236 if (key == TString("SV"))
239 AliFatal(Form("%s key not recognized", key.Data()));
247 //______________________________________________________________________________
249 AliMUONGeometry::WriteSVMap(const TString& fileName) const
251 // Writes sensitive volume map into a file
252 // Returns true, if writing finished correctly.
256 // if builder is not associated with any geometry module
257 if (fModules->GetEntriesFast() == 0) return false;
260 TString filePath = gSystem->Getenv("ALICE_ROOT");
261 filePath += "/MUON/data/";
262 filePath += fileName;
265 ofstream out(filePath, ios::out);
267 cerr << filePath << endl;
268 AliError("File not found.");
271 #if !defined (__DECCXX)
272 out.setf(std::ios::fixed);
279 //_____________________________________________________________________________
280 const AliMUONGeometryModule*
281 AliMUONGeometry::GetModule(Int_t index, Bool_t warn) const
283 /// Return the geometry module specified by index
285 if (index < 0 || index >= fModules->GetEntriesFast()) {
288 << "Index: " << index << " outside limits" << std::endl;
293 return (const AliMUONGeometryModule*) fModules->At(index);
296 //_____________________________________________________________________________
297 const AliMUONGeometryModule*
298 AliMUONGeometry::GetModuleByDEId(Int_t detElemId, Bool_t warn) const
300 /// Return the geometry module specified by index
303 Int_t index = AliMUONGeometryStore::GetModuleId(detElemId);
305 return GetModule(index, warn);