Line data Source code
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 : //-----------------------------------------------------------------------------
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
26 : //-----------------------------------------------------------------------------
27 :
28 : #include "AliMUONGeometryModule.h"
29 : #include "AliMUONGeometryModuleTransformer.h"
30 : #include "AliMUONGeometryEnvelope.h"
31 : #include "AliMUONGeometryEnvelopeStore.h"
32 : #include "AliMUONGeometryDetElement.h"
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>
42 :
43 : /// \cond CLASSIMP
44 18 : ClassImp(AliMUONGeometryModule)
45 : /// \endcond
46 :
47 : //______________________________________________________________________________
48 : AliMUONGeometryModule::AliMUONGeometryModule(Int_t moduleId)
49 20 : : TObject(),
50 20 : fIsVirtual(true),
51 20 : fNofSVs(0),
52 20 : fSVVolumeIds(0),
53 20 : fEnvelopes(0),
54 20 : fSVMap(0),
55 20 : fTransformer(0)
56 100 : {
57 : /// Standard constructor
58 :
59 : // Arrays of volumes Ids
60 60 : fSVVolumeIds = new TArrayI(20);
61 :
62 : // Sensitive volumes map
63 60 : fSVMap = new AliMUONStringIntMap();
64 :
65 : // Geometry parametrisation
66 60 : fTransformer = new AliMUONGeometryModuleTransformer(moduleId);
67 :
68 : // Envelope store
69 80 : fEnvelopes = new AliMUONGeometryEnvelopeStore(
70 20 : fTransformer->GetDetElementStore());
71 40 : }
72 :
73 :
74 : //______________________________________________________________________________
75 : AliMUONGeometryModule::AliMUONGeometryModule()
76 240 : : TObject(),
77 240 : fIsVirtual(true),
78 240 : fNofSVs(0),
79 240 : fSVVolumeIds(0),
80 240 : fEnvelopes(0),
81 240 : fSVMap(0),
82 240 : fTransformer(0)
83 1200 : {
84 : /// Default constructor
85 480 : }
86 :
87 : //______________________________________________________________________________
88 : AliMUONGeometryModule::~AliMUONGeometryModule()
89 1560 : {
90 : /// Destructor
91 :
92 520 : delete fSVVolumeIds;
93 520 : delete fEnvelopes;
94 520 : delete fSVMap;
95 520 : delete fTransformer;
96 780 : }
97 :
98 : //
99 : // private methods
100 : //
101 :
102 : //______________________________________________________________________________
103 : Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
104 : {
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).
108 :
109 0 : for (Int_t i=0; i<fNofSVs; i++) {
110 0 : if (fSVVolumeIds->At(i) == svVolId) return i;
111 : }
112 0 : return -1;
113 0 : }
114 :
115 : //
116 : // public methods
117 : //
118 :
119 : //______________________________________________________________________________
120 : void AliMUONGeometryModule::SetTransformation(const TGeoCombiTrans& transform)
121 : {
122 : /// Set the module position wrt world.
123 :
124 60 : fTransformer->SetTransformation(transform);
125 20 : }
126 :
127 : //______________________________________________________________________________
128 : void AliMUONGeometryModule::SetVolumePath(const TString& volumePath)
129 : {
130 : /// Set the volume path to transformer
131 :
132 80 : fTransformer->SetVolumePath(volumePath);
133 40 : }
134 :
135 : //______________________________________________________________________________
136 : void AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
137 : {
138 : /// Add the volume specified by volId to the list of sensitive
139 : /// volumes
140 :
141 : // Resize TArrayI if needed
142 80 : if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
143 :
144 40 : fSVVolumeIds->AddAt(svVolId, fNofSVs++);
145 40 : }
146 :
147 : //______________________________________________________________________________
148 : void AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
149 : {
150 : /// Add the volume specified by volName to the list of sensitive
151 : /// volumes
152 :
153 80 : SetSensitiveVolume(TVirtualMC::GetMC()->VolId(volName));
154 40 : }
155 :
156 : //______________________________________________________________________________
157 : void AliMUONGeometryModule::SetAlign(Bool_t align)
158 : {
159 : /// Set alignement option to envelope store.
160 :
161 20 : fEnvelopes->SetAlign(align);
162 20 : }
163 :
164 : //______________________________________________________________________________
165 : AliMUONGeometryDetElement*
166 : AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
167 : {
168 : /// Find detection element which the sensitive volume specified by name belongs to
169 :
170 1950 : Int_t detElemId = fSVMap->Get(sensVolume);
171 :
172 1205 : if (!detElemId) return 0;
173 : // The specified sensitive volume is not in the map
174 :
175 745 : return fTransformer->GetDetElement(detElemId);
176 975 : }
177 :
178 : //______________________________________________________________________________
179 : Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
180 : {
181 : /// Check if the volume specified by volId is present in the list
182 : /// of sensitive volumes.
183 :
184 1356879 : for (Int_t i=0; i<fNofSVs; i++) {
185 341232 : if (fSVVolumeIds->At(i) == volId) return kTRUE;
186 : }
187 168790 : return kFALSE;
188 169535 : }
189 :
190 : //______________________________________________________________________________
191 : Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
192 : {
193 : /// Check if the volume specified by volName is present in the list
194 : /// of sensitive volumes.
195 :
196 0 : return IsSensitiveVolume(TVirtualMC::GetMC()->VolId(volName));
197 : }
|