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