]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamberGeometry.cxx
properly take care of chamber edges in GetPadI
[u/mrichter/AliRoot.git] / MUON / AliMUONChamberGeometry.cxx
1 // $Id$
2 //
3 // Class AliMUONChamberGeometry
4 // -----------------------------
5 // Class for definititon of the MUON chamber positions in ALIC
6 // Author: Ivana Hrivnacova, IPN Orsay
7 // 23/01/2004
8
9 #include <TVirtualMC.h>
10 #include <TGeoMatrix.h>
11 #include <TObjArray.h>
12 #include <TArrayI.h>
13 #include <Riostream.h>
14
15 #include "AliMUONChamberGeometry.h"
16 #include "AliMUONGeometryEnvelope.h"
17 #include "AliMUONGeometryEnvelopeStore.h"
18 #include "AliMUONGeometryTransformStore.h"      
19 #include "AliMUONConstants.h"
20 #include "AliLog.h"
21
22 ClassImp(AliMUONChamberGeometry)
23
24 //______________________________________________________________________________
25 AliMUONChamberGeometry::AliMUONChamberGeometry(Int_t chamberId)
26  : TObject(),
27    fChamberId(chamberId),
28    fMotherVolume("ALIC"),
29    fNofSVs(0),
30    fSVVolumeIds(0),
31    fTransformation(0),
32    fDETransforms(0),
33    fEnvelopes(0),
34    fSVMap(0)
35 {
36 // Standard constructor
37
38   // Chamber transformation
39   fTransformation = new TGeoCombiTrans("");
40
41   // Arrays of volumes Ids
42   fSVVolumeIds = new TArrayI(20);
43
44   // Sensitive volumes map
45   fSVMap = new AliMUONGeometrySVMap(100);
46
47   // Det elements transformation store
48   fDETransforms = new AliMUONGeometryTransformStore(
49                          AliMUONConstants::GetFirstDetElemId(chamberId), 
50                          AliMUONConstants::NofDetElements(chamberId),
51                          fSVMap);  
52   // Envelope store
53   fEnvelopes = new AliMUONGeometryEnvelopeStore(fDETransforms);  
54 }
55
56
57 //______________________________________________________________________________
58 AliMUONChamberGeometry::AliMUONChamberGeometry()
59  : TObject(),
60    fChamberId(0),
61    fMotherVolume(),
62    fNofSVs(0),
63    fSVVolumeIds(0),
64    fTransformation(0),
65    fDETransforms(0),
66    fEnvelopes(0),
67    fSVMap(0)
68 {
69 // Default constructor
70 }
71
72
73 //______________________________________________________________________________
74 AliMUONChamberGeometry::AliMUONChamberGeometry(const AliMUONChamberGeometry& rhs)
75   : TObject(rhs)
76 {
77   AliFatal("Copy constructor is not implemented.");
78 }
79
80 //______________________________________________________________________________
81 AliMUONChamberGeometry::~AliMUONChamberGeometry() {
82 //
83
84   delete fTransformation;
85   delete fSVVolumeIds;
86   delete fEnvelopes;
87   delete fDETransforms;
88   delete fSVMap;
89 }
90
91 //______________________________________________________________________________
92 AliMUONChamberGeometry& 
93 AliMUONChamberGeometry::operator = (const AliMUONChamberGeometry& rhs) 
94 {
95   // check assignement to self
96   if (this == &rhs) return *this;
97
98   AliFatal("Assignment operator is not implemented.");
99     
100   return *this;  
101 }
102
103 //
104 // private methods
105 //
106
107 //______________________________________________________________________________
108 Int_t AliMUONChamberGeometry::GetSVIndex(Int_t svVolId) const
109 {
110 // Returns the index of the volume specified by volId
111 // if it is present in the list of sensitive volumes 
112 // (or -1 if not present).
113  
114   for (Int_t i=0; i<fNofSVs; i++) {
115       if (fSVVolumeIds->At(i) == svVolId) return i;
116   }
117   return -1;
118 }
119
120 //
121 // public methods
122 //
123
124 //______________________________________________________________________________
125 void  AliMUONChamberGeometry::SetTranslation(const TGeoTranslation& translation)
126 {
127 // Sets the chamber position wrt ALIC.
128 // ---
129
130   fTransformation
131     ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
132 }  
133
134 //______________________________________________________________________________
135 void  AliMUONChamberGeometry::SetRotation(const TGeoRotation& rotation)
136 {
137 // Sets the chamber rotation wrt ALIC.
138 // ---
139
140   TGeoRotation* rot = new TGeoRotation();
141   rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
142
143   fTransformation->SetRotation(rot);
144 }  
145
146 //______________________________________________________________________________
147 void  AliMUONChamberGeometry::SetSensitiveVolume(Int_t svVolId)
148 {
149 // Adds the volume specified by volId to the list of sensitive
150 // volumes
151 // ---
152   
153   // Resize TArrayI if needed
154   if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
155
156   fSVVolumeIds->AddAt(svVolId, fNofSVs++);
157 }      
158
159 //______________________________________________________________________________
160 void  AliMUONChamberGeometry::SetSensitiveVolume(const TString& volName)
161 {
162 // Adds the volume specified by volName to the list of sensitive
163 // volumes
164 // ---
165
166   SetSensitiveVolume(gMC->VolId(volName));
167 }      
168
169 //______________________________________________________________________________
170 void  AliMUONChamberGeometry::SetAlign(Bool_t align)
171 {
172 // Sets alignement option to enevelope store.
173 // ---
174   
175   fEnvelopes->SetAlign(align);
176 }  
177
178 //______________________________________________________________________________
179 Bool_t AliMUONChamberGeometry::IsSensitiveVolume(Int_t volId) const
180 {
181 // Checks if the volume specified by volId is present in the list
182 // of sensitive volumes.
183 // ---
184
185   for (Int_t i=0; i<fNofSVs; i++) {
186       if (fSVVolumeIds->At(i) == volId) return kTRUE;
187   }
188   return kFALSE;
189 }
190
191 //______________________________________________________________________________
192 Bool_t AliMUONChamberGeometry::IsSensitiveVolume(const TString& volName) const
193 {
194 // Checks if the volume specified by volName  is present in the list
195 // of sensitive volumes.
196 // ---
197
198   return IsSensitiveVolume(gMC->VolId(volName));
199 }