]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometryModule.cxx
Put split level for the HLT ESD tree to zero.
[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(),
47 fModuleId(moduleId),
48 fMotherVolume("ALIC"),
49 fNofSVs(0),
50 fSVVolumeIds(0),
51 fTransformation(0),
52 fEnvelopes(0),
53 fDEIndexing(0),
54 fDetElements(0),
55 fSVMap(0)
56{
57// Standard constructor
58
59 // Chamber transformation
60 fTransformation = new TGeoCombiTrans("");
61
62 // Arrays of volumes Ids
63 fSVVolumeIds = new TArrayI(20);
64
65 // Sensitive volumes map
66 fSVMap = new AliMUONGeometrySVMap(100);
67
68 // Get indexing
69 fDEIndexing = new AliMUONGeometryDEIndexing(fModuleId, 0);
70
71 // Det elements transformation stores
72 fDetElements = new AliMUONGeometryStore(fDEIndexing);
73
74 // Envelope store
75 fEnvelopes = new AliMUONGeometryEnvelopeStore(fDetElements);
76}
77
78
79//______________________________________________________________________________
80AliMUONGeometryModule::AliMUONGeometryModule()
81 : TObject(),
82 fModuleId(0),
83 fMotherVolume(),
84 fNofSVs(0),
85 fSVVolumeIds(0),
86 fTransformation(0),
87 fEnvelopes(0),
88 fDEIndexing(0),
89 fDetElements(0),
90 fSVMap(0)
91{
92// Default constructor
93}
94
95
96//______________________________________________________________________________
97AliMUONGeometryModule::AliMUONGeometryModule(const AliMUONGeometryModule& rhs)
98 : TObject(rhs)
99{
100 AliFatal("Copy constructor is not implemented.");
101}
102
103//______________________________________________________________________________
104AliMUONGeometryModule::~AliMUONGeometryModule() {
105//
106
107 delete fTransformation;
108 delete fSVVolumeIds;
109 delete fEnvelopes;
110 delete fDEIndexing;
111 delete fDetElements;
112 delete fSVMap;
113}
114
115//______________________________________________________________________________
116AliMUONGeometryModule&
117AliMUONGeometryModule::operator = (const AliMUONGeometryModule& rhs)
118{
119 // check assignement to self
120 if (this == &rhs) return *this;
121
122 AliFatal("Assignment operator is not implemented.");
123
124 return *this;
125}
126
127//
128// private methods
129//
130
131//______________________________________________________________________________
132Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
133{
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).
137
138 for (Int_t i=0; i<fNofSVs; i++) {
139 if (fSVVolumeIds->At(i) == svVolId) return i;
140 }
141 return -1;
142}
143
144//
145// public methods
146//
147
148//______________________________________________________________________________
149void 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
152{
153// Transforms point from the global reference frame (ALIC)
154// to the local reference frame of the detection element specified
155// by detElemId.
156// ---
157
158 // Get detection element
159 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
160 if (!detElement) return;
161
162 // Transform point
163 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
164}
165
166//______________________________________________________________________________
167void 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
170{
171// Transforms point from the global reference frame (ALIC)
172// to the local reference frame of the detection element specified
173// by detElemId.
174// ---
175
176 // Get detection element
177 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
178 if (!detElement) return;
179
180 // Transform point
181 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
182}
183
184//______________________________________________________________________________
185void 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
188{
189// Transforms point from the local reference frame of the detection element
190// specified by detElemId to the global reference frame (ALIC).
191// ---
192
193 // Get detection element
194 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
195 if (!detElement) return;
196
197 // Transform point
198 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
199}
200
201//______________________________________________________________________________
202void 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
205{
206// Transforms point from the local reference frame of the detection element
207// specified by detElemId to the global reference frame (ALIC).
208// ---
209
210 // Get detection element
211 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
212 if (!detElement) return;
213
214 // Transform point
215 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
216}
217
218//______________________________________________________________________________
219void AliMUONGeometryModule::SetTranslation(const TGeoTranslation& translation)
220{
221// Sets the module position wrt world.
222// ---
223
224 fTransformation
225 ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
226}
227
228//______________________________________________________________________________
229void AliMUONGeometryModule::SetRotation(const TGeoRotation& rotation)
230{
231// Sets the module rotation wrt ALIC.
232// ---
233
234 TGeoRotation* rot = new TGeoRotation();
235 rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
236
237 fTransformation->SetRotation(rot);
238}
239
240//______________________________________________________________________________
241void AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
242{
243// Adds the volume specified by volId to the list of sensitive
244// volumes
245// ---
246
247 // Resize TArrayI if needed
248 if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
249
250 fSVVolumeIds->AddAt(svVolId, fNofSVs++);
251}
252
253//______________________________________________________________________________
254void AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
255{
256// Adds the volume specified by volName to the list of sensitive
257// volumes
258// ---
259
260 SetSensitiveVolume(gMC->VolId(volName));
261}
262
263//______________________________________________________________________________
264void AliMUONGeometryModule::SetAlign(Bool_t align)
265{
266// Sets alignement option to enevelope store.
267// ---
268
269 fEnvelopes->SetAlign(align);
270}
271
272//______________________________________________________________________________
273AliMUONGeometryDetElement*
274AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
275{
276// Finds TGeoCombiTrans for the detector element Id specified by aligned volume
277// ---
278
279 Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
280
281 if (!detElemId) return 0;
282 // The specified sensitive volume is not in the map
283
284 return (AliMUONGeometryDetElement*)fDetElements->Get(detElemId);
285}
286
287//______________________________________________________________________________
288Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
289{
290// Checks if the volume specified by volId is present in the list
291// of sensitive volumes.
292// ---
293
294 for (Int_t i=0; i<fNofSVs; i++) {
295 if (fSVVolumeIds->At(i) == volId) return kTRUE;
296 }
297 return kFALSE;
298}
299
300//______________________________________________________________________________
301Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
302{
303// Checks if the volume specified by volName is present in the list
304// of sensitive volumes.
305// ---
306
307 return IsSensitiveVolume(gMC->VolId(volName));
308}
309
310//______________________________________________________________________________
311AliMUONGeometryDetElement*
312AliMUONGeometryModule::GetDetElement(Int_t detElemId) const
313{
314// Returns thethe detection element specified by detElemId.
315// Gives error if detection element is not defined.
316// ---
317
318 // Get detection element
319 AliMUONGeometryDetElement* detElement
320 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
321
322 if (!detElement) {
75b9419c 323 AliErrorStream()
324 << "Detection element " << detElemId
325 << " not found in module " << fModuleId << endl;
e118b27e 326 return 0;
327 }
328
329 return detElement;
330}
331
332/*
333//______________________________________________________________________________
334Int_t AliMUONGeometryModule::GetNofDetElements() const
335{
336// Returns the number of detection elements
337// ---
338
339 return fDEIndexing->GetNofDetElements();
340}
341
342//______________________________________________________________________________
343Int_t AliMUONGeometryModule::GetDetElemId(Int_t i) const
344{
345// Returns the i-th detection element id
346// ---
347
348 return fDEIndexing->GetDetElementId(i);
349}
350*/