]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometryModule.cxx
- Modified comment lines to be compatible with Doxygen
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryModule.cxx
CommitLineData
e118b27e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16// $Id$
17//
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).
23//
24// Author: Ivana Hrivnacova, IPN Orsay
25
26#include <TVirtualMC.h>
27#include <TGeoMatrix.h>
28#include <TObjArray.h>
29#include <TArrayI.h>
30#include <Riostream.h>
31
32#include "AliLog.h"
33
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"
41
42ClassImp(AliMUONGeometryModule)
43
44//______________________________________________________________________________
45AliMUONGeometryModule::AliMUONGeometryModule(Int_t moduleId)
46 : TObject(),
cfbf2f7d 47 fIsVirtual(true),
e118b27e 48 fModuleId(moduleId),
49 fMotherVolume("ALIC"),
cfbf2f7d 50 fVolume("NONE"),
e118b27e 51 fNofSVs(0),
52 fSVVolumeIds(0),
53 fTransformation(0),
54 fEnvelopes(0),
55 fDEIndexing(0),
56 fDetElements(0),
57 fSVMap(0)
58{
692de412 59/// Standard constructor
e118b27e 60
61 // Chamber transformation
62 fTransformation = new TGeoCombiTrans("");
63
64 // Arrays of volumes Ids
65 fSVVolumeIds = new TArrayI(20);
66
67 // Sensitive volumes map
68 fSVMap = new AliMUONGeometrySVMap(100);
69
70 // Get indexing
71 fDEIndexing = new AliMUONGeometryDEIndexing(fModuleId, 0);
72
73 // Det elements transformation stores
74 fDetElements = new AliMUONGeometryStore(fDEIndexing);
75
76 // Envelope store
77 fEnvelopes = new AliMUONGeometryEnvelopeStore(fDetElements);
78}
79
80
81//______________________________________________________________________________
82AliMUONGeometryModule::AliMUONGeometryModule()
83 : TObject(),
cfbf2f7d 84 fIsVirtual(true),
e118b27e 85 fModuleId(0),
86 fMotherVolume(),
cfbf2f7d 87 fVolume(),
e118b27e 88 fNofSVs(0),
89 fSVVolumeIds(0),
90 fTransformation(0),
91 fEnvelopes(0),
92 fDEIndexing(0),
93 fDetElements(0),
94 fSVMap(0)
95{
692de412 96/// Default constructor
e118b27e 97}
98
99
100//______________________________________________________________________________
101AliMUONGeometryModule::AliMUONGeometryModule(const AliMUONGeometryModule& rhs)
102 : TObject(rhs)
103{
692de412 104/// Protected copy constructor
105
e118b27e 106 AliFatal("Copy constructor is not implemented.");
107}
108
109//______________________________________________________________________________
692de412 110AliMUONGeometryModule::~AliMUONGeometryModule()
111{
112/// Destructor
e118b27e 113
114 delete fTransformation;
115 delete fSVVolumeIds;
116 delete fEnvelopes;
117 delete fDEIndexing;
118 delete fDetElements;
119 delete fSVMap;
120}
121
122//______________________________________________________________________________
123AliMUONGeometryModule&
124AliMUONGeometryModule::operator = (const AliMUONGeometryModule& rhs)
125{
692de412 126/// Protected assignement operator
127
e118b27e 128 // check assignement to self
129 if (this == &rhs) return *this;
130
131 AliFatal("Assignment operator is not implemented.");
132
133 return *this;
134}
135
136//
137// private methods
138//
139
140//______________________________________________________________________________
141Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
142{
692de412 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).
e118b27e 146
147 for (Int_t i=0; i<fNofSVs; i++) {
148 if (fSVVolumeIds->At(i) == svVolId) return i;
149 }
150 return -1;
151}
152
153//
154// public methods
155//
156
157//______________________________________________________________________________
158void 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
161{
692de412 162/// Transform point from the global reference frame (ALIC)
163/// to the local reference frame of the detection element specified
164/// by detElemId.
e118b27e 165
166 // Get detection element
167 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
168 if (!detElement) return;
169
170 // Transform point
171 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
172}
173
174//______________________________________________________________________________
175void 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
178{
692de412 179/// Transform point from the global reference frame (ALIC)
180/// to the local reference frame of the detection element specified
181/// by detElemId.
e118b27e 182
183 // Get detection element
184 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
185 if (!detElement) return;
186
187 // Transform point
188 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
189}
190
191//______________________________________________________________________________
192void 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
195{
692de412 196/// Transform point from the local reference frame of the detection element
197/// specified by detElemId to the global reference frame (ALIC).
e118b27e 198
199 // Get detection element
200 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
201 if (!detElement) return;
202
203 // Transform point
204 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
205}
206
207//______________________________________________________________________________
208void 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
211{
692de412 212/// Transform point from the local reference frame of the detection element
213/// specified by detElemId to the global reference frame (ALIC).
e118b27e 214
215 // Get detection element
216 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
217 if (!detElement) return;
218
219 // Transform point
220 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
221}
222
cfbf2f7d 223//______________________________________________________________________________
224void AliMUONGeometryModule::SetVolume(const TString& volumeName)
225{
692de412 226/// Set the concrete volume associated with this module.
227/// The module in not virtual in this case
cfbf2f7d 228
229 fVolume = volumeName;
230 fIsVirtual = false;
231}
232
e118b27e 233//______________________________________________________________________________
234void AliMUONGeometryModule::SetTranslation(const TGeoTranslation& translation)
235{
692de412 236/// Set the module position wrt world.
e118b27e 237
238 fTransformation
239 ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
240}
241
242//______________________________________________________________________________
243void AliMUONGeometryModule::SetRotation(const TGeoRotation& rotation)
244{
692de412 245/// Set the module rotation wrt ALIC.
e118b27e 246
247 TGeoRotation* rot = new TGeoRotation();
248 rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
249
250 fTransformation->SetRotation(rot);
251}
252
253//______________________________________________________________________________
254void AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
255{
692de412 256/// Add the volume specified by volId to the list of sensitive
257/// volumes
e118b27e 258
259 // Resize TArrayI if needed
260 if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
261
262 fSVVolumeIds->AddAt(svVolId, fNofSVs++);
263}
264
265//______________________________________________________________________________
266void AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
267{
692de412 268/// Add the volume specified by volName to the list of sensitive
269/// volumes
e118b27e 270
271 SetSensitiveVolume(gMC->VolId(volName));
272}
273
274//______________________________________________________________________________
275void AliMUONGeometryModule::SetAlign(Bool_t align)
276{
692de412 277/// Set alignement option to enevelope store.
e118b27e 278
279 fEnvelopes->SetAlign(align);
280}
281
282//______________________________________________________________________________
283AliMUONGeometryDetElement*
284AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
285{
692de412 286/// Find TGeoCombiTrans for the detector element Id specified by aligned volume
e118b27e 287
288 Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
289
290 if (!detElemId) return 0;
291 // The specified sensitive volume is not in the map
292
293 return (AliMUONGeometryDetElement*)fDetElements->Get(detElemId);
294}
295
296//______________________________________________________________________________
297Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
298{
692de412 299/// Check if the volume specified by volId is present in the list
300/// of sensitive volumes.
e118b27e 301
302 for (Int_t i=0; i<fNofSVs; i++) {
303 if (fSVVolumeIds->At(i) == volId) return kTRUE;
304 }
305 return kFALSE;
306}
307
308//______________________________________________________________________________
309Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
310{
692de412 311/// Check if the volume specified by volName is present in the list
312/// of sensitive volumes.
e118b27e 313
314 return IsSensitiveVolume(gMC->VolId(volName));
315}
316
317//______________________________________________________________________________
318AliMUONGeometryDetElement*
319AliMUONGeometryModule::GetDetElement(Int_t detElemId) const
320{
692de412 321/// Return the detection element specified by detElemId.
322/// Give error if detection element is not defined.
e118b27e 323
324 // Get detection element
325 AliMUONGeometryDetElement* detElement
326 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
327
328 if (!detElement) {
75b9419c 329 AliErrorStream()
330 << "Detection element " << detElemId
331 << " not found in module " << fModuleId << endl;
e118b27e 332 return 0;
333 }
334
335 return detElement;
336}