1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
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 purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // Class AliMUONGeometryModule
19 // -----------------------------
20 // Class for definition of the detector module parameters
21 // (the transformations of detection elements, mapping between
22 // sensitive volumes and detection elements).
24 // Author: Ivana Hrivnacova, IPN Orsay
26 #include <TVirtualMC.h>
27 #include <TGeoMatrix.h>
28 #include <TObjArray.h>
30 #include <Riostream.h>
34 #include "AliMUONGeometryModule.h"
35 #include "AliMUONGeometryEnvelope.h"
36 #include "AliMUONGeometryEnvelopeStore.h"
37 #include "AliMUONGeometryDetElement.h"
38 #include "AliMUONGeometryStore.h"
39 #include "AliMUONGeometrySVMap.h"
40 #include "AliMUONGeometryDEIndexing.h"
42 ClassImp(AliMUONGeometryModule)
44 //______________________________________________________________________________
45 AliMUONGeometryModule::AliMUONGeometryModule(Int_t moduleId)
49 fMotherVolume("ALIC"),
59 /// Standard constructor
61 // Chamber transformation
62 fTransformation = new TGeoCombiTrans("");
64 // Arrays of volumes Ids
65 fSVVolumeIds = new TArrayI(20);
67 // Sensitive volumes map
68 fSVMap = new AliMUONGeometrySVMap(100);
71 fDEIndexing = new AliMUONGeometryDEIndexing(fModuleId, 0);
73 // Det elements transformation stores
74 fDetElements = new AliMUONGeometryStore(fDEIndexing);
77 fEnvelopes = new AliMUONGeometryEnvelopeStore(fDetElements);
81 //______________________________________________________________________________
82 AliMUONGeometryModule::AliMUONGeometryModule()
96 /// Default constructor
100 //______________________________________________________________________________
101 AliMUONGeometryModule::AliMUONGeometryModule(const AliMUONGeometryModule& rhs)
104 /// Protected copy constructor
106 AliFatal("Copy constructor is not implemented.");
109 //______________________________________________________________________________
110 AliMUONGeometryModule::~AliMUONGeometryModule()
114 delete fTransformation;
122 //______________________________________________________________________________
123 AliMUONGeometryModule&
124 AliMUONGeometryModule::operator = (const AliMUONGeometryModule& rhs)
126 /// Protected assignement operator
128 // check assignement to self
129 if (this == &rhs) return *this;
131 AliFatal("Assignment operator is not implemented.");
140 //______________________________________________________________________________
141 Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
143 /// Return the index of the volume specified by volId
144 /// if it is present in the list of sensitive volumes
145 /// (or -1 if not present).
147 for (Int_t i=0; i<fNofSVs; i++) {
148 if (fSVVolumeIds->At(i) == svVolId) return i;
157 //______________________________________________________________________________
158 void AliMUONGeometryModule::Global2Local(Int_t detElemId,
159 Float_t xg, Float_t yg, Float_t zg,
160 Float_t& xl, Float_t& yl, Float_t& zl) const
162 /// Transform point from the global reference frame (ALIC)
163 /// to the local reference frame of the detection element specified
166 // Get detection element
167 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
168 if (!detElement) return;
171 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
174 //______________________________________________________________________________
175 void AliMUONGeometryModule::Global2Local(Int_t detElemId,
176 Double_t xg, Double_t yg, Double_t zg,
177 Double_t& xl, Double_t& yl, Double_t& zl) const
179 /// Transform point from the global reference frame (ALIC)
180 /// to the local reference frame of the detection element specified
183 // Get detection element
184 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
185 if (!detElement) return;
188 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
191 //______________________________________________________________________________
192 void AliMUONGeometryModule::Local2Global(Int_t detElemId,
193 Float_t xl, Float_t yl, Float_t zl,
194 Float_t& xg, Float_t& yg, Float_t& zg) const
196 /// Transform point from the local reference frame of the detection element
197 /// specified by detElemId to the global reference frame (ALIC).
199 // Get detection element
200 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
201 if (!detElement) return;
204 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
207 //______________________________________________________________________________
208 void AliMUONGeometryModule::Local2Global(Int_t detElemId,
209 Double_t xl, Double_t yl, Double_t zl,
210 Double_t& xg, Double_t& yg, Double_t& zg) const
212 /// Transform point from the local reference frame of the detection element
213 /// specified by detElemId to the global reference frame (ALIC).
215 // Get detection element
216 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
217 if (!detElement) return;
220 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
223 //______________________________________________________________________________
224 void AliMUONGeometryModule::SetVolume(const TString& volumeName)
226 /// Set the concrete volume associated with this module.
227 /// The module in not virtual in this case
229 fVolume = volumeName;
233 //______________________________________________________________________________
234 void AliMUONGeometryModule::SetTranslation(const TGeoTranslation& translation)
236 /// Set the module position wrt world.
239 ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
242 //______________________________________________________________________________
243 void AliMUONGeometryModule::SetRotation(const TGeoRotation& rotation)
245 /// Set the module rotation wrt ALIC.
247 TGeoRotation* rot = new TGeoRotation();
248 rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
250 fTransformation->SetRotation(rot);
253 //______________________________________________________________________________
254 void AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
256 /// Add the volume specified by volId to the list of sensitive
259 // Resize TArrayI if needed
260 if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
262 fSVVolumeIds->AddAt(svVolId, fNofSVs++);
265 //______________________________________________________________________________
266 void AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
268 /// Add the volume specified by volName to the list of sensitive
271 SetSensitiveVolume(gMC->VolId(volName));
274 //______________________________________________________________________________
275 void AliMUONGeometryModule::SetAlign(Bool_t align)
277 /// Set alignement option to enevelope store.
279 fEnvelopes->SetAlign(align);
282 //______________________________________________________________________________
283 AliMUONGeometryDetElement*
284 AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
286 /// Find TGeoCombiTrans for the detector element Id specified by aligned volume
288 Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
290 if (!detElemId) return 0;
291 // The specified sensitive volume is not in the map
293 return (AliMUONGeometryDetElement*)fDetElements->Get(detElemId);
296 //______________________________________________________________________________
297 Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
299 /// Check if the volume specified by volId is present in the list
300 /// of sensitive volumes.
302 for (Int_t i=0; i<fNofSVs; i++) {
303 if (fSVVolumeIds->At(i) == volId) return kTRUE;
308 //______________________________________________________________________________
309 Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
311 /// Check if the volume specified by volName is present in the list
312 /// of sensitive volumes.
314 return IsSensitiveVolume(gMC->VolId(volName));
317 //______________________________________________________________________________
318 AliMUONGeometryDetElement*
319 AliMUONGeometryModule::GetDetElement(Int_t detElemId) const
321 /// Return the detection element specified by detElemId.
322 /// Give error if detection element is not defined.
324 // Get detection element
325 AliMUONGeometryDetElement* detElement
326 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
330 << "Detection element " << detElemId
331 << " not found in module " << fModuleId << endl;