Adding comment lines to class description needed for Root documentation,
[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$
3d1463c8 17
18//-----------------------------------------------------------------------------
e118b27e 19// Class AliMUONGeometryModule
20// -----------------------------
21// Class for definition of the detector module parameters
22// (the transformations of detection elements, mapping between
23// sensitive volumes and detection elements).
24//
25// Author: Ivana Hrivnacova, IPN Orsay
3d1463c8 26//-----------------------------------------------------------------------------
e118b27e 27
e118b27e 28#include "AliMUONGeometryModule.h"
6cfb12b4 29#include "AliMUONGeometryModuleTransformer.h"
e118b27e 30#include "AliMUONGeometryEnvelope.h"
31#include "AliMUONGeometryEnvelopeStore.h"
32#include "AliMUONGeometryDetElement.h"
fbdfcd24 33#include "AliMUONStringIntMap.h"
34
35#include "AliLog.h"
36
37#include <TVirtualMC.h>
38#include <TGeoMatrix.h>
39#include <TObjArray.h>
40#include <TArrayI.h>
41#include <Riostream.h>
e118b27e 42
a9aad96e 43/// \cond CLASSIMP
e118b27e 44ClassImp(AliMUONGeometryModule)
a9aad96e 45/// \endcond
e118b27e 46
47//______________________________________________________________________________
48AliMUONGeometryModule::AliMUONGeometryModule(Int_t moduleId)
49 : TObject(),
cfbf2f7d 50 fIsVirtual(true),
e118b27e 51 fNofSVs(0),
52 fSVVolumeIds(0),
e118b27e 53 fEnvelopes(0),
6cfb12b4 54 fSVMap(0),
55 fTransformer(0)
e118b27e 56{
692de412 57/// Standard constructor
e118b27e 58
e118b27e 59 // Arrays of volumes Ids
60 fSVVolumeIds = new TArrayI(20);
61
62 // Sensitive volumes map
fbdfcd24 63 fSVMap = new AliMUONStringIntMap();
e118b27e 64
6cfb12b4 65 // Geometry parametrisation
66 fTransformer = new AliMUONGeometryModuleTransformer(moduleId);
e118b27e 67
68 // Envelope store
6cfb12b4 69 fEnvelopes = new AliMUONGeometryEnvelopeStore(
70 fTransformer->GetDetElementStore());
e118b27e 71}
72
73
74//______________________________________________________________________________
75AliMUONGeometryModule::AliMUONGeometryModule()
76 : TObject(),
cfbf2f7d 77 fIsVirtual(true),
e118b27e 78 fNofSVs(0),
79 fSVVolumeIds(0),
e118b27e 80 fEnvelopes(0),
6cfb12b4 81 fSVMap(0),
82 fTransformer(0)
e118b27e 83{
692de412 84/// Default constructor
e118b27e 85}
86
e118b27e 87//______________________________________________________________________________
692de412 88AliMUONGeometryModule::~AliMUONGeometryModule()
89{
90/// Destructor
e118b27e 91
e118b27e 92 delete fSVVolumeIds;
93 delete fEnvelopes;
e118b27e 94 delete fSVMap;
6cfb12b4 95 delete fTransformer;
e118b27e 96}
97
e118b27e 98//
99// private methods
100//
101
102//______________________________________________________________________________
103Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
104{
692de412 105/// Return the index of the volume specified by volId
106/// if it is present in the list of sensitive volumes
107/// (or -1 if not present).
e118b27e 108
109 for (Int_t i=0; i<fNofSVs; i++) {
110 if (fSVVolumeIds->At(i) == svVolId) return i;
111 }
112 return -1;
113}
114
115//
116// public methods
117//
118
119//______________________________________________________________________________
6cfb12b4 120void AliMUONGeometryModule::SetTransformation(const TGeoCombiTrans& transform)
e118b27e 121{
692de412 122/// Set the module position wrt world.
e118b27e 123
6cfb12b4 124 fTransformer->SetTransformation(transform);
e118b27e 125}
126
127//______________________________________________________________________________
fbdfcd24 128void AliMUONGeometryModule::SetVolumePath(const TString& volumePath)
129{
130/// Set the volume path to transformer
131
132 fTransformer->SetVolumePath(volumePath);
133}
134
135//______________________________________________________________________________
e118b27e 136void AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
137{
692de412 138/// Add the volume specified by volId to the list of sensitive
139/// volumes
e118b27e 140
141 // Resize TArrayI if needed
142 if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
143
144 fSVVolumeIds->AddAt(svVolId, fNofSVs++);
145}
146
147//______________________________________________________________________________
148void AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
149{
692de412 150/// Add the volume specified by volName to the list of sensitive
151/// volumes
e118b27e 152
153 SetSensitiveVolume(gMC->VolId(volName));
154}
155
156//______________________________________________________________________________
157void AliMUONGeometryModule::SetAlign(Bool_t align)
158{
6cfb12b4 159/// Set alignement option to envelope store.
e118b27e 160
161 fEnvelopes->SetAlign(align);
162}
163
164//______________________________________________________________________________
165AliMUONGeometryDetElement*
166AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
167{
a9aad96e 168/// Find detection element which the sensitive volume specified by name belongs to
e118b27e 169
fbdfcd24 170 Int_t detElemId = fSVMap->Get(sensVolume);
e118b27e 171
172 if (!detElemId) return 0;
173 // The specified sensitive volume is not in the map
174
6cfb12b4 175 return fTransformer->GetDetElement(detElemId);
e118b27e 176}
177
178//______________________________________________________________________________
179Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
180{
692de412 181/// Check if the volume specified by volId is present in the list
182/// of sensitive volumes.
e118b27e 183
184 for (Int_t i=0; i<fNofSVs; i++) {
185 if (fSVVolumeIds->At(i) == volId) return kTRUE;
186 }
187 return kFALSE;
188}
189
190//______________________________________________________________________________
191Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
192{
692de412 193/// Check if the volume specified by volName is present in the list
194/// of sensitive volumes.
e118b27e 195
196 return IsSensitiveVolume(gMC->VolId(volName));
197}