]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryModule.cxx
Add option to set scaler trigger event on, for raw data (Christian)
[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 <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 "AliMUONGeometryModuleTransformer.h"
36 #include "AliMUONGeometryEnvelope.h"
37 #include "AliMUONGeometryEnvelopeStore.h"
38 #include "AliMUONGeometryDetElement.h"  
39 #include "AliMUONGeometryStore.h"       
40 #include "AliMUONGeometrySVMap.h"       
41
42 ClassImp(AliMUONGeometryModule)
43
44 //______________________________________________________________________________
45 AliMUONGeometryModule::AliMUONGeometryModule(Int_t moduleId)
46  : TObject(),
47    fIsVirtual(true),
48    fMotherVolume("ALIC"),
49    fVolume("NONE"),
50    fNofSVs(0),
51    fSVVolumeIds(0),
52    fEnvelopes(0),
53    fSVMap(0),
54    fTransformer(0)
55 {
56 /// Standard constructor
57
58   // Arrays of volumes Ids
59   fSVVolumeIds = new TArrayI(20);
60
61   // Sensitive volumes map
62   fSVMap = new AliMUONGeometrySVMap(100);
63
64   // Geometry parametrisation
65   fTransformer = new AliMUONGeometryModuleTransformer(moduleId);
66     
67   // Envelope store
68   fEnvelopes = new AliMUONGeometryEnvelopeStore(
69                              fTransformer->GetDetElementStore());  
70 }
71
72
73 //______________________________________________________________________________
74 AliMUONGeometryModule::AliMUONGeometryModule()
75  : TObject(),
76    fIsVirtual(true),
77    fMotherVolume(),
78    fVolume(),
79    fNofSVs(0),
80    fSVVolumeIds(0),
81    fEnvelopes(0),
82    fSVMap(0),
83    fTransformer(0)
84 {
85 /// Default constructor
86 }
87
88
89 //______________________________________________________________________________
90 AliMUONGeometryModule::AliMUONGeometryModule(const AliMUONGeometryModule& rhs)
91   : TObject(rhs)
92 {
93 /// Protected copy constructor
94
95   AliFatal("Copy constructor is not implemented.");
96 }
97
98 //______________________________________________________________________________
99 AliMUONGeometryModule::~AliMUONGeometryModule() 
100 {
101 /// Destructor
102
103   delete fSVVolumeIds;
104   delete fEnvelopes;
105   delete fSVMap;
106   delete fTransformer;
107 }
108
109 //______________________________________________________________________________
110 AliMUONGeometryModule& 
111 AliMUONGeometryModule::operator = (const AliMUONGeometryModule& rhs) 
112 {
113 /// Protected assignement operator
114
115   // check assignement to self
116   if (this == &rhs) return *this;
117
118   AliFatal("Assignment operator is not implemented.");
119     
120   return *this;  
121 }
122
123 //
124 // private methods
125 //
126
127 //______________________________________________________________________________
128 Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
129 {
130 /// Return the index of the volume specified by volId
131 /// if it is present in the list of sensitive volumes 
132 /// (or -1 if not present).
133  
134   for (Int_t i=0; i<fNofSVs; i++) {
135       if (fSVVolumeIds->At(i) == svVolId) return i;
136   }
137   return -1;
138 }
139
140 //
141 // public methods
142 //
143
144 //______________________________________________________________________________
145 void AliMUONGeometryModule::SetVolume(const TString& volumeName)
146
147 /// Set the concrete volume associated with this module.
148 /// The module in not virtual in this case
149
150   fVolume = volumeName;
151   fIsVirtual = false;
152 }
153
154 //______________________________________________________________________________
155 void  AliMUONGeometryModule::SetTransformation(const TGeoCombiTrans& transform)
156 {
157 /// Set the module position wrt world.
158
159   fTransformer->SetTransformation(transform);
160 }  
161
162 //______________________________________________________________________________
163 void  AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
164 {
165 /// Add the volume specified by volId to the list of sensitive
166 /// volumes
167   
168   // Resize TArrayI if needed
169   if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
170
171   fSVVolumeIds->AddAt(svVolId, fNofSVs++);
172 }      
173
174 //______________________________________________________________________________
175 void  AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
176 {
177 /// Add the volume specified by volName to the list of sensitive
178 /// volumes
179
180   SetSensitiveVolume(gMC->VolId(volName));
181 }      
182
183 //______________________________________________________________________________
184 void  AliMUONGeometryModule::SetAlign(Bool_t align)
185 {
186 /// Set alignement option to envelope store.
187   
188   fEnvelopes->SetAlign(align);
189 }  
190
191 //______________________________________________________________________________
192 AliMUONGeometryDetElement* 
193 AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
194 {
195 /// Find TGeoCombiTrans for the detector element Id specified by aligned volume 
196
197   Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
198
199   if (!detElemId) return 0; 
200         // The specified sensitive volume is not in the map   
201   
202   return fTransformer->GetDetElement(detElemId);
203 }  
204
205 //______________________________________________________________________________
206 Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
207 {
208 /// Check if the volume specified by volId is present in the list
209 /// of sensitive volumes.
210
211   for (Int_t i=0; i<fNofSVs; i++) {
212       if (fSVVolumeIds->At(i) == volId) return kTRUE;
213   }
214   return kFALSE;
215 }
216
217 //______________________________________________________________________________
218 Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
219 {
220 /// Check if the volume specified by volName  is present in the list
221 /// of sensitive volumes.
222
223   return IsSensitiveVolume(gMC->VolId(volName));
224 }