]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamberGeometry.cxx
The array of enevelopes and AddEnvelope... functions separated into a new class AliMU...
[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
21 ClassImp(AliMUONChamberGeometry)
22
23 //______________________________________________________________________________
24 AliMUONChamberGeometry::AliMUONChamberGeometry(Int_t chamberId)
25  : TObject(),
26    fChamberId(chamberId),
27    fMotherVolume("ALIC"),
28    fNofSVs(0),
29    fSVVolumeIds(0),
30    fTransformation(0),
31    fDETransforms(0),
32    fEnvelopes(0),
33    fSVMap(0)
34 {
35 // Standard constructor
36
37   // Chamber transformation
38   fTransformation = new TGeoCombiTrans("");
39
40   // Arrays of volumes Ids
41   fSVVolumeIds = new TArrayI(20);
42
43   // Sensitive volumes map
44   fSVMap = new AliMUONGeometrySVMap(100);
45
46   // Det elements transformation store
47   fDETransforms = new AliMUONGeometryTransformStore(
48                          AliMUONConstants::GetFirstDetElemId(chamberId), 
49                          AliMUONConstants::NofDetElements(chamberId),
50                          fSVMap);  
51   // Envelope store
52   fEnvelopes = new AliMUONGeometryEnvelopeStore(fDETransforms);  
53 }
54
55
56 //______________________________________________________________________________
57 AliMUONChamberGeometry::AliMUONChamberGeometry()
58  : TObject(),
59    fChamberId(0),
60    fMotherVolume(),
61    fNofSVs(0),
62    fSVVolumeIds(0),
63    fTransformation(0),
64    fDETransforms(0),
65    fEnvelopes(0),
66    fSVMap(0)
67 {
68 // Default constructor
69 }
70
71
72 //______________________________________________________________________________
73 AliMUONChamberGeometry::AliMUONChamberGeometry(const AliMUONChamberGeometry& rhs)
74   : TObject(rhs)
75 {
76   Fatal("Copy constructor", 
77         "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   Fatal("operator=", 
99         "Assignment operator is not implemented.");
100     
101   return *this;  
102 }
103
104 //
105 // private methods
106 //
107
108 //______________________________________________________________________________
109 Int_t AliMUONChamberGeometry::GetSVIndex(Int_t svVolId) const
110 {
111 // Returns the index of the volume specified by volId
112 // if it is present in the list of sensitive volumes 
113 // (or -1 if not present).
114  
115   for (Int_t i=0; i<fNofSVs; i++) {
116       if (fSVVolumeIds->At(i) == svVolId) return i;
117   }
118   return -1;
119 }
120
121 //
122 // public methods
123 //
124
125 //______________________________________________________________________________
126 void  AliMUONChamberGeometry::SetTranslation(const TGeoTranslation& translation)
127 {
128 // Sets the chamber position wrt ALIC.
129 // ---
130
131   fTransformation
132     ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
133 }  
134
135 //______________________________________________________________________________
136 void  AliMUONChamberGeometry::SetRotation(const TGeoRotation& rotation)
137 {
138 // Sets the chamber rotation wrt ALIC.
139 // ---
140
141   TGeoRotation* rot = new TGeoRotation();
142   rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
143
144   fTransformation->SetRotation(rot);
145 }  
146
147 //______________________________________________________________________________
148 void  AliMUONChamberGeometry::SetSensitiveVolume(Int_t svVolId)
149 {
150 // Adds the volume specified by volId to the list of sensitive
151 // volumes
152 // ---
153   
154   // Resize TArrayI if needed
155   if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);
156
157   fSVVolumeIds->AddAt(svVolId, fNofSVs++);
158 }      
159
160 //______________________________________________________________________________
161 void  AliMUONChamberGeometry::SetSensitiveVolume(const TString& volName)
162 {
163 // Adds the volume specified by volName to the list of sensitive
164 // volumes
165 // ---
166
167   SetSensitiveVolume(gMC->VolId(volName));
168 }      
169
170 //______________________________________________________________________________
171 void  AliMUONChamberGeometry::SetAlign(Bool_t align)
172 {
173 // Sets alignement option to enevelope store.
174 // ---
175   
176   fEnvelopes->SetAlign(align);
177 }  
178
179 //______________________________________________________________________________
180 Bool_t AliMUONChamberGeometry::IsSensitiveVolume(Int_t volId) const
181 {
182 // Checks if the volume specified by volId is present in the list
183 // of sensitive volumes.
184 // ---
185
186   for (Int_t i=0; i<fNofSVs; i++) {
187       if (fSVVolumeIds->At(i) == volId) return kTRUE;
188   }
189   return kFALSE;
190 }
191
192 //______________________________________________________________________________
193 Bool_t AliMUONChamberGeometry::IsSensitiveVolume(const TString& volName) const
194 {
195 // Checks if the volume specified by volName  is present in the list
196 // of sensitive volumes.
197 // ---
198
199   return IsSensitiveVolume(gMC->VolId(volName));
200 }