]>
Commit | Line | Data |
---|---|---|
1 | // $Id$ | |
2 | // | |
3 | // Class AliMUONChamberGeometry | |
4 | // ----------------------------- | |
5 | // Class for definititon of the MUON chamber positions in ALIC. | |
6 | // | |
7 | // Author: Ivana Hrivnacova, IPN Orsay | |
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 | ||
18 | ClassImp(AliMUONChamberGeometry) | |
19 | ||
20 | //______________________________________________________________________________ | |
21 | AliMUONChamberGeometry::AliMUONChamberGeometry(Int_t chamberId) | |
22 | : TObject(), | |
23 | fChamberId(chamberId), | |
24 | fMotherVolume("ALIC"), | |
25 | fTransformation(0), | |
26 | fEnvelopes(0), | |
27 | fNofSensVolumeIds(0), | |
28 | fSensVolumeIds(0), | |
29 | fDebug(kFALSE) | |
30 | { | |
31 | // Standard constructor | |
32 | ||
33 | // Create the chamber transformation | |
34 | fTransformation = new TGeoCombiTrans(""); | |
35 | fEnvelopes = new TObjArray(20); | |
36 | fSensVolumeIds = new TArrayI(20); | |
37 | } | |
38 | ||
39 | ||
40 | //______________________________________________________________________________ | |
41 | AliMUONChamberGeometry::AliMUONChamberGeometry() | |
42 | : TObject(), | |
43 | fChamberId(0), | |
44 | fMotherVolume(), | |
45 | fTransformation(0), | |
46 | fEnvelopes(0), | |
47 | fNofSensVolumeIds(0), | |
48 | fSensVolumeIds(0), | |
49 | fDebug(kFALSE) | |
50 | { | |
51 | // Default constructor | |
52 | } | |
53 | ||
54 | ||
55 | //______________________________________________________________________________ | |
56 | AliMUONChamberGeometry::AliMUONChamberGeometry(const AliMUONChamberGeometry& rhs) | |
57 | : TObject(rhs) | |
58 | { | |
59 | Fatal("Copy constructor", | |
60 | "Copy constructor is not implemented."); | |
61 | } | |
62 | ||
63 | //______________________________________________________________________________ | |
64 | AliMUONChamberGeometry::~AliMUONChamberGeometry() { | |
65 | // | |
66 | ||
67 | // Add deleting rotation matrices | |
68 | ||
69 | delete fTransformation; | |
70 | ||
71 | if (fEnvelopes) { | |
72 | fEnvelopes->Delete(); | |
73 | delete fEnvelopes; | |
74 | } | |
75 | } | |
76 | ||
77 | //______________________________________________________________________________ | |
78 | AliMUONChamberGeometry& | |
79 | AliMUONChamberGeometry::operator = (const AliMUONChamberGeometry& rhs) | |
80 | { | |
81 | // check assignement to self | |
82 | if (this == &rhs) return *this; | |
83 | ||
84 | Fatal("operator=", | |
85 | "Assignment operator is not implemented."); | |
86 | ||
87 | return *this; | |
88 | } | |
89 | ||
90 | // | |
91 | // private methods | |
92 | // | |
93 | ||
94 | //______________________________________________________________________________ | |
95 | AliMUONGeometryEnvelope* | |
96 | AliMUONChamberGeometry::FindEnvelope(const TString& name) const | |
97 | { | |
98 | // Finds the envelope specified by name. | |
99 | // --- | |
100 | ||
101 | for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) { | |
102 | AliMUONGeometryEnvelope* envelope | |
103 | = (AliMUONGeometryEnvelope*)fEnvelopes->At(i); | |
104 | ||
105 | if (envelope->GetName() == name) return envelope; | |
106 | } | |
107 | ||
108 | return 0; | |
109 | } | |
110 | ||
111 | // | |
112 | // public methods | |
113 | // | |
114 | ||
115 | //______________________________________________________________________________ | |
116 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual) | |
117 | { | |
118 | // Adds the volume with the specified name and transformation | |
119 | // to the list of envelopes. | |
120 | // --- | |
121 | ||
122 | if (fDebug) { | |
123 | cout << "... Adding "; | |
124 | if (!isVirtual) cout << " non-"; | |
125 | cout << "virtual envelope " << name << endl; | |
126 | } | |
127 | ||
128 | AliMUONGeometryEnvelope* envelope | |
129 | = new AliMUONGeometryEnvelope(name, isVirtual); | |
130 | ||
131 | fEnvelopes->Add(envelope); | |
132 | } | |
133 | ||
134 | //______________________________________________________________________________ | |
135 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual, | |
136 | const TGeoTranslation& translation) | |
137 | { | |
138 | // Adds the volume with the specified name and transformation | |
139 | // to the list of envelopes. | |
140 | // --- | |
141 | ||
142 | if (fDebug) { | |
143 | cout << "... Adding "; | |
144 | if (!isVirtual) cout << " non-"; | |
145 | cout << "virtual envelope " << name | |
146 | << " with translation" << endl; | |
147 | } | |
148 | ||
149 | AliMUONGeometryEnvelope* envelope | |
150 | = new AliMUONGeometryEnvelope(name, isVirtual); | |
151 | envelope->SetTranslation(translation); | |
152 | ||
153 | fEnvelopes->Add(envelope); | |
154 | } | |
155 | ||
156 | //______________________________________________________________________________ | |
157 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual, | |
158 | const TGeoTranslation& translation, | |
159 | const TGeoRotation& rotation) | |
160 | { | |
161 | // Adds the volume with the specified name and transformation | |
162 | // to the list of envelopes. | |
163 | // --- | |
164 | ||
165 | if (fDebug) { | |
166 | cout << "... Adding "; | |
167 | if (!isVirtual) cout << " non-"; | |
168 | cout << "virtual envelope " << name | |
169 | << " with translation and rotation" << endl; | |
170 | } | |
171 | ||
172 | // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation)); | |
173 | // would be nice to be so simple | |
174 | ||
175 | AliMUONGeometryEnvelope* envelope | |
176 | = new AliMUONGeometryEnvelope(name, isVirtual); | |
177 | envelope->SetRotation(rotation); | |
178 | envelope->SetTranslation(translation); | |
179 | ||
180 | fEnvelopes->Add(envelope); | |
181 | } | |
182 | ||
183 | //______________________________________________________________________________ | |
184 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo) | |
185 | { | |
186 | // Adds the volume with the specified name and transformation | |
187 | // to the list of envelopes. | |
188 | // --- | |
189 | ||
190 | if (fDebug) { | |
191 | cout << "... Adding " | |
192 | << " non-virtual envelope " << name | |
193 | << " with copyNo " << copyNo << endl; | |
194 | } | |
195 | ||
196 | AliMUONGeometryEnvelope* envelope | |
197 | = new AliMUONGeometryEnvelope(name, copyNo); | |
198 | ||
199 | fEnvelopes->Add(envelope); | |
200 | } | |
201 | ||
202 | //______________________________________________________________________________ | |
203 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo, | |
204 | const TGeoTranslation& translation) | |
205 | { | |
206 | // Adds the volume with the specified name and transformation | |
207 | // to the list of envelopes. | |
208 | // --- | |
209 | ||
210 | if (fDebug) { | |
211 | cout << "... Adding " | |
212 | << " non-virtual envelope " << name | |
213 | << " with copyNo " << copyNo | |
214 | << " with translation " << endl; | |
215 | } | |
216 | ||
217 | AliMUONGeometryEnvelope* envelope | |
218 | = new AliMUONGeometryEnvelope(name, copyNo); | |
219 | envelope->SetTranslation(translation); | |
220 | ||
221 | fEnvelopes->Add(envelope); | |
222 | } | |
223 | ||
224 | //______________________________________________________________________________ | |
225 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo, | |
226 | const TGeoTranslation& translation, | |
227 | const TGeoRotation& rotation) | |
228 | { | |
229 | // Adds the volume with the specified name and transformation | |
230 | // to the list of envelopes. | |
231 | // --- | |
232 | ||
233 | if (fDebug) { | |
234 | cout << "... Adding " | |
235 | << " non-virtual envelope " << name | |
236 | << " with copyNo " << copyNo | |
237 | << " with translation and rotation" << endl; | |
238 | } | |
239 | ||
240 | // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation)); | |
241 | // would be nice to be so simple | |
242 | ||
243 | AliMUONGeometryEnvelope* envelope | |
244 | = new AliMUONGeometryEnvelope(name, copyNo); | |
245 | envelope->SetRotation(rotation); | |
246 | envelope->SetTranslation(translation); | |
247 | ||
248 | fEnvelopes->Add(envelope); | |
249 | } | |
250 | ||
251 | //______________________________________________________________________________ | |
252 | void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name, | |
253 | const TString& envName, Int_t copyNo) | |
254 | { | |
255 | // Adds the volume with the specified name and transformation | |
256 | // to the list of envelopes. | |
257 | // --- | |
258 | ||
259 | if (fDebug) { | |
260 | cout << "... Adding constituent " << name | |
261 | << " to envelope " << envName | |
262 | << " with copyNo " << copyNo << endl; | |
263 | } | |
264 | ||
265 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
266 | ||
267 | if (!envelope) { | |
268 | // add warning | |
269 | return; | |
270 | } | |
271 | ||
272 | envelope->AddConstituent(name, copyNo); | |
273 | } | |
274 | ||
275 | //______________________________________________________________________________ | |
276 | void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name, | |
277 | const TString& envName, Int_t copyNo, | |
278 | const TGeoTranslation& translation) | |
279 | { | |
280 | // Adds the volume with the specified name and transformation | |
281 | // to the list of envelopes. | |
282 | // --- | |
283 | ||
284 | if (fDebug) { | |
285 | cout << "... Adding constituent " << name | |
286 | << " to envelope " << envName | |
287 | << " with copyNo " << copyNo | |
288 | << " with translation" << endl; | |
289 | } | |
290 | ||
291 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
292 | ||
293 | if (!envelope) { | |
294 | // add warning | |
295 | return; | |
296 | } | |
297 | ||
298 | envelope->AddConstituent(name, copyNo, translation); | |
299 | } | |
300 | ||
301 | //______________________________________________________________________________ | |
302 | void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name, | |
303 | const TString& envName, Int_t copyNo, | |
304 | const TGeoTranslation& translation, | |
305 | const TGeoRotation& rotation) | |
306 | { | |
307 | // Adds the volume with the specified name and transformation | |
308 | // to the list of envelopes. | |
309 | // --- | |
310 | ||
311 | if (fDebug) { | |
312 | cout << "... Adding constituent " << name | |
313 | << " to envelope " << envName | |
314 | << " with copyNo " << copyNo | |
315 | << " with translation and rotation" << endl; | |
316 | } | |
317 | ||
318 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
319 | ||
320 | if (!envelope) { | |
321 | // add warning | |
322 | return; | |
323 | } | |
324 | ||
325 | envelope->AddConstituent(name, copyNo, translation, rotation); | |
326 | } | |
327 | ||
328 | //______________________________________________________________________________ | |
329 | void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, | |
330 | const TString& envName, Int_t copyNo, | |
331 | Int_t npar, Double_t* param) | |
332 | { | |
333 | // Adds the volume with the specified name and transformation | |
334 | // to the list of envelopes. | |
335 | // --- | |
336 | ||
337 | if (fDebug) { | |
338 | cout << "... Adding parameterised constituent " << name | |
339 | << " to envelope " << envName | |
340 | << " with copyNo " << copyNo << endl; | |
341 | } | |
342 | ||
343 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
344 | ||
345 | if (!envelope) { | |
346 | // add warning | |
347 | return; | |
348 | } | |
349 | ||
350 | envelope->AddConstituentParam(name, copyNo, npar, param); | |
351 | } | |
352 | ||
353 | //______________________________________________________________________________ | |
354 | void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, | |
355 | const TString& envName, Int_t copyNo, | |
356 | const TGeoTranslation& translation, | |
357 | Int_t npar, Double_t* param) | |
358 | { | |
359 | // Adds the volume with the specified name and transformation | |
360 | // to the list of envelopes. | |
361 | // --- | |
362 | ||
363 | if (fDebug) { | |
364 | cout << "... Adding parameterised constituent " << name | |
365 | << " to envelope " << envName | |
366 | << " with copyNo " << copyNo | |
367 | << " with translation" << endl; | |
368 | } | |
369 | ||
370 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
371 | ||
372 | if (!envelope) { | |
373 | // add warning | |
374 | return; | |
375 | } | |
376 | ||
377 | envelope->AddConstituentParam(name, copyNo, translation, npar, param); | |
378 | } | |
379 | ||
380 | //______________________________________________________________________________ | |
381 | void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, | |
382 | const TString& envName, Int_t copyNo, | |
383 | const TGeoTranslation& translation, | |
384 | const TGeoRotation& rotation, | |
385 | Int_t npar, Double_t* param) | |
386 | { | |
387 | // Adds the volume with the specified name and transformation | |
388 | // to the list of envelopes. | |
389 | // --- | |
390 | ||
391 | if (fDebug) { | |
392 | cout << "... Adding parameterised constituent " << name | |
393 | << " to envelope " << envName | |
394 | << " with copyNo " << copyNo | |
395 | << " with translation and rotation" << endl; | |
396 | } | |
397 | ||
398 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
399 | ||
400 | if (!envelope) { | |
401 | // add warning | |
402 | return; | |
403 | } | |
404 | ||
405 | envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param); | |
406 | } | |
407 | ||
408 | //______________________________________________________________________________ | |
409 | void AliMUONChamberGeometry::SetTranslation(const TGeoTranslation& translation) | |
410 | { | |
411 | // Sets the chamber position wrt ALIC. | |
412 | // --- | |
413 | ||
414 | fTransformation | |
415 | ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation())); | |
416 | } | |
417 | ||
418 | //______________________________________________________________________________ | |
419 | void AliMUONChamberGeometry::SetRotation(const TGeoRotation& rotation) | |
420 | { | |
421 | // Sets the chamber rotation wrt ALIC. | |
422 | // --- | |
423 | ||
424 | TGeoRotation* rot = new TGeoRotation(); | |
425 | rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix())); | |
426 | ||
427 | fTransformation->SetRotation(rot); | |
428 | } | |
429 | ||
430 | //______________________________________________________________________________ | |
431 | void AliMUONChamberGeometry::SetSensitiveVolume(Int_t volId) | |
432 | { | |
433 | // Adds the volume specified by volId to the list of sensitive | |
434 | // volumes | |
435 | ||
436 | fSensVolumeIds->AddAt(volId,fNofSensVolumeIds++); | |
437 | } | |
438 | ||
439 | //______________________________________________________________________________ | |
440 | void AliMUONChamberGeometry::SetSensitiveVolume(const TString& volName) | |
441 | { | |
442 | // Adds the volume specified by volId to the list of sensitive | |
443 | // volumes | |
444 | ||
445 | fSensVolumeIds->AddAt(gMC->VolId(volName),fNofSensVolumeIds++); | |
446 | } | |
447 | ||
448 | //______________________________________________________________________________ | |
449 | Bool_t AliMUONChamberGeometry::IsSensitiveVolume(Int_t volId) const | |
450 | { | |
451 | // Checks if the volume specified by volId is present in the list | |
452 | // of sensitive volumes. | |
453 | ||
454 | for (Int_t i=0; i<fNofSensVolumeIds; i++) { | |
455 | if (fSensVolumeIds->At(i) == volId) return kTRUE; | |
456 | } | |
457 | return kFALSE; | |
458 | } |