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 AliFatal("Copy constructor is not implemented.");
107 //______________________________________________________________________________
108 AliMUONGeometryModule::~AliMUONGeometryModule() {
111 delete fTransformation;
119 //______________________________________________________________________________
120 AliMUONGeometryModule&
121 AliMUONGeometryModule::operator = (const AliMUONGeometryModule& rhs)
123 // check assignement to self
124 if (this == &rhs) return *this;
126 AliFatal("Assignment operator is not implemented.");
135 //______________________________________________________________________________
136 Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
138 // Returns the index of the volume specified by volId
139 // if it is present in the list of sensitive volumes
140 // (or -1 if not present).
142 for (Int_t i=0; i<fNofSVs; i++) {
143 if (fSVVolumeIds->At(i) == svVolId) return i;
152 //______________________________________________________________________________
153 void AliMUONGeometryModule::Global2Local(Int_t detElemId,
154 Float_t xg, Float_t yg, Float_t zg,
155 Float_t& xl, Float_t& yl, Float_t& zl) const
157 // Transforms point from the global reference frame (ALIC)
158 // to the local reference frame of the detection element specified
162 // Get detection element
163 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
164 if (!detElement) return;
167 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
170 //______________________________________________________________________________
171 void AliMUONGeometryModule::Global2Local(Int_t detElemId,
172 Double_t xg, Double_t yg, Double_t zg,
173 Double_t& xl, Double_t& yl, Double_t& zl) const
175 // Transforms point from the global reference frame (ALIC)
176 // to the local reference frame of the detection element specified
180 // Get detection element
181 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
182 if (!detElement) return;
185 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
188 //______________________________________________________________________________
189 void AliMUONGeometryModule::Local2Global(Int_t detElemId,
190 Float_t xl, Float_t yl, Float_t zl,
191 Float_t& xg, Float_t& yg, Float_t& zg) const
193 // Transforms point from the local reference frame of the detection element
194 // specified by detElemId to the global reference frame (ALIC).
197 // Get detection element
198 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
199 if (!detElement) return;
202 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
205 //______________________________________________________________________________
206 void AliMUONGeometryModule::Local2Global(Int_t detElemId,
207 Double_t xl, Double_t yl, Double_t zl,
208 Double_t& xg, Double_t& yg, Double_t& zg) const
210 // Transforms point from the local reference frame of the detection element
211 // specified by detElemId to the global reference frame (ALIC).
214 // Get detection element
215 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
216 if (!detElement) return;
219 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
222 //______________________________________________________________________________
223 void AliMUONGeometryModule::SetVolume(const TString& volumeName)
225 // Sets the concrete volume associated with this module.
226 // The module in not virtual in this case
228 fVolume = volumeName;
232 //______________________________________________________________________________
233 void AliMUONGeometryModule::SetTranslation(const TGeoTranslation& translation)
235 // Sets the module position wrt world.
239 ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
242 //______________________________________________________________________________
243 void AliMUONGeometryModule::SetRotation(const TGeoRotation& rotation)
245 // Sets the module rotation wrt ALIC.
248 TGeoRotation* rot = new TGeoRotation();
249 rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
251 fTransformation->SetRotation(rot);
254 //______________________________________________________________________________
255 void AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
257 // Adds the volume specified by volId to the list of sensitive
261 // Resize TArrayI if needed
262 if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
264 fSVVolumeIds->AddAt(svVolId, fNofSVs++);
267 //______________________________________________________________________________
268 void AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
270 // Adds the volume specified by volName to the list of sensitive
274 SetSensitiveVolume(gMC->VolId(volName));
277 //______________________________________________________________________________
278 void AliMUONGeometryModule::SetAlign(Bool_t align)
280 // Sets alignement option to enevelope store.
283 fEnvelopes->SetAlign(align);
286 //______________________________________________________________________________
287 AliMUONGeometryDetElement*
288 AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
290 // Finds TGeoCombiTrans for the detector element Id specified by aligned volume
293 Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
295 if (!detElemId) return 0;
296 // The specified sensitive volume is not in the map
298 return (AliMUONGeometryDetElement*)fDetElements->Get(detElemId);
301 //______________________________________________________________________________
302 Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
304 // Checks if the volume specified by volId is present in the list
305 // of sensitive volumes.
308 for (Int_t i=0; i<fNofSVs; i++) {
309 if (fSVVolumeIds->At(i) == volId) return kTRUE;
314 //______________________________________________________________________________
315 Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
317 // Checks if the volume specified by volName is present in the list
318 // of sensitive volumes.
321 return IsSensitiveVolume(gMC->VolId(volName));
324 //______________________________________________________________________________
325 AliMUONGeometryDetElement*
326 AliMUONGeometryModule::GetDetElement(Int_t detElemId) const
328 // Returns thethe detection element specified by detElemId.
329 // Gives error if detection element is not defined.
332 // Get detection element
333 AliMUONGeometryDetElement* detElement
334 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
338 << "Detection element " << detElemId
339 << " not found in module " << fModuleId << endl;
347 //______________________________________________________________________________
348 Int_t AliMUONGeometryModule::GetNofDetElements() const
350 // Returns the number of detection elements
353 return fDEIndexing->GetNofDetElements();
356 //______________________________________________________________________________
357 Int_t AliMUONGeometryModule::GetDetElemId(Int_t i) const
359 // Returns the i-th detection element id
362 return fDEIndexing->GetDetElementId(i);