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)
48 fMotherVolume("ALIC"),
57 // Standard constructor
59 // Chamber transformation
60 fTransformation = new TGeoCombiTrans("");
62 // Arrays of volumes Ids
63 fSVVolumeIds = new TArrayI(20);
65 // Sensitive volumes map
66 fSVMap = new AliMUONGeometrySVMap(100);
69 fDEIndexing = new AliMUONGeometryDEIndexing(fModuleId, 0);
71 // Det elements transformation stores
72 fDetElements = new AliMUONGeometryStore(fDEIndexing);
75 fEnvelopes = new AliMUONGeometryEnvelopeStore(fDetElements);
79 //______________________________________________________________________________
80 AliMUONGeometryModule::AliMUONGeometryModule()
92 // Default constructor
96 //______________________________________________________________________________
97 AliMUONGeometryModule::AliMUONGeometryModule(const AliMUONGeometryModule& rhs)
100 AliFatal("Copy constructor is not implemented.");
103 //______________________________________________________________________________
104 AliMUONGeometryModule::~AliMUONGeometryModule() {
107 delete fTransformation;
115 //______________________________________________________________________________
116 AliMUONGeometryModule&
117 AliMUONGeometryModule::operator = (const AliMUONGeometryModule& rhs)
119 // check assignement to self
120 if (this == &rhs) return *this;
122 AliFatal("Assignment operator is not implemented.");
131 //______________________________________________________________________________
132 Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
134 // Returns the index of the volume specified by volId
135 // if it is present in the list of sensitive volumes
136 // (or -1 if not present).
138 for (Int_t i=0; i<fNofSVs; i++) {
139 if (fSVVolumeIds->At(i) == svVolId) return i;
148 //______________________________________________________________________________
149 void AliMUONGeometryModule::Global2Local(Int_t detElemId,
150 Float_t xg, Float_t yg, Float_t zg,
151 Float_t& xl, Float_t& yl, Float_t& zl) const
153 // Transforms point from the global reference frame (ALIC)
154 // to the local reference frame of the detection element specified
158 // Get detection element
159 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
160 if (!detElement) return;
163 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
166 //______________________________________________________________________________
167 void AliMUONGeometryModule::Global2Local(Int_t detElemId,
168 Double_t xg, Double_t yg, Double_t zg,
169 Double_t& xl, Double_t& yl, Double_t& zl) const
171 // Transforms point from the global reference frame (ALIC)
172 // to the local reference frame of the detection element specified
176 // Get detection element
177 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
178 if (!detElement) return;
181 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
184 //______________________________________________________________________________
185 void AliMUONGeometryModule::Local2Global(Int_t detElemId,
186 Float_t xl, Float_t yl, Float_t zl,
187 Float_t& xg, Float_t& yg, Float_t& zg) const
189 // Transforms point from the local reference frame of the detection element
190 // specified by detElemId to the global reference frame (ALIC).
193 // Get detection element
194 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
195 if (!detElement) return;
198 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
201 //______________________________________________________________________________
202 void AliMUONGeometryModule::Local2Global(Int_t detElemId,
203 Double_t xl, Double_t yl, Double_t zl,
204 Double_t& xg, Double_t& yg, Double_t& zg) const
206 // Transforms point from the local reference frame of the detection element
207 // specified by detElemId to the global reference frame (ALIC).
210 // Get detection element
211 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
212 if (!detElement) return;
215 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
218 //______________________________________________________________________________
219 void AliMUONGeometryModule::SetTranslation(const TGeoTranslation& translation)
221 // Sets the module position wrt world.
225 ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
228 //______________________________________________________________________________
229 void AliMUONGeometryModule::SetRotation(const TGeoRotation& rotation)
231 // Sets the module rotation wrt ALIC.
234 TGeoRotation* rot = new TGeoRotation();
235 rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
237 fTransformation->SetRotation(rot);
240 //______________________________________________________________________________
241 void AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
243 // Adds the volume specified by volId to the list of sensitive
247 // Resize TArrayI if needed
248 if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
250 fSVVolumeIds->AddAt(svVolId, fNofSVs++);
253 //______________________________________________________________________________
254 void AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
256 // Adds the volume specified by volName to the list of sensitive
260 SetSensitiveVolume(gMC->VolId(volName));
263 //______________________________________________________________________________
264 void AliMUONGeometryModule::SetAlign(Bool_t align)
266 // Sets alignement option to enevelope store.
269 fEnvelopes->SetAlign(align);
272 //______________________________________________________________________________
273 AliMUONGeometryDetElement*
274 AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
276 // Finds TGeoCombiTrans for the detector element Id specified by aligned volume
279 Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
281 if (!detElemId) return 0;
282 // The specified sensitive volume is not in the map
284 return (AliMUONGeometryDetElement*)fDetElements->Get(detElemId);
287 //______________________________________________________________________________
288 Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
290 // Checks if the volume specified by volId is present in the list
291 // of sensitive volumes.
294 for (Int_t i=0; i<fNofSVs; i++) {
295 if (fSVVolumeIds->At(i) == volId) return kTRUE;
300 //______________________________________________________________________________
301 Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
303 // Checks if the volume specified by volName is present in the list
304 // of sensitive volumes.
307 return IsSensitiveVolume(gMC->VolId(volName));
310 //______________________________________________________________________________
311 AliMUONGeometryDetElement*
312 AliMUONGeometryModule::GetDetElement(Int_t detElemId) const
314 // Returns thethe detection element specified by detElemId.
315 // Gives error if detection element is not defined.
318 // Get detection element
319 AliMUONGeometryDetElement* detElement
320 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
324 << "Detection element " << detElemId
325 << " not found in module " << fModuleId << endl;
333 //______________________________________________________________________________
334 Int_t AliMUONGeometryModule::GetNofDetElements() const
336 // Returns the number of detection elements
339 return fDEIndexing->GetNofDetElements();
342 //______________________________________________________________________________
343 Int_t AliMUONGeometryModule::GetDetElemId(Int_t i) const
345 // Returns the i-th detection element id
348 return fDEIndexing->GetDetElementId(i);