]>
Commit | Line | Data |
---|---|---|
d1cd2474 | 1 | // $Id$ |
2 | // | |
3 | // Class AliMUONChamberGeometry | |
4 | // ----------------------------- | |
5f1df83a | 5 | // Class for definititon of the MUON chamber positions in ALIC |
d1cd2474 | 6 | // Author: Ivana Hrivnacova, IPN Orsay |
5f1df83a | 7 | // 23/01/2004 |
d1cd2474 | 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 | //______________________________________________________________________________ | |
6b82c1f0 | 116 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual, |
117 | const char* only) | |
d1cd2474 | 118 | { |
119 | // Adds the volume with the specified name and transformation | |
120 | // to the list of envelopes. | |
121 | // --- | |
122 | ||
123 | if (fDebug) { | |
124 | cout << "... Adding "; | |
125 | if (!isVirtual) cout << " non-"; | |
126 | cout << "virtual envelope " << name << endl; | |
127 | } | |
128 | ||
129 | AliMUONGeometryEnvelope* envelope | |
6b82c1f0 | 130 | = new AliMUONGeometryEnvelope(name, isVirtual, only); |
d1cd2474 | 131 | |
132 | fEnvelopes->Add(envelope); | |
133 | } | |
134 | ||
135 | //______________________________________________________________________________ | |
136 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual, | |
6b82c1f0 | 137 | const TGeoTranslation& translation, |
138 | const char* only) | |
d1cd2474 | 139 | { |
140 | // Adds the volume with the specified name and transformation | |
141 | // to the list of envelopes. | |
142 | // --- | |
143 | ||
144 | if (fDebug) { | |
145 | cout << "... Adding "; | |
146 | if (!isVirtual) cout << " non-"; | |
147 | cout << "virtual envelope " << name | |
148 | << " with translation" << endl; | |
149 | } | |
150 | ||
151 | AliMUONGeometryEnvelope* envelope | |
6b82c1f0 | 152 | = new AliMUONGeometryEnvelope(name, isVirtual, only); |
d1cd2474 | 153 | envelope->SetTranslation(translation); |
154 | ||
155 | fEnvelopes->Add(envelope); | |
156 | } | |
157 | ||
158 | //______________________________________________________________________________ | |
159 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual, | |
160 | const TGeoTranslation& translation, | |
6b82c1f0 | 161 | const TGeoRotation& rotation, |
162 | const char* only) | |
d1cd2474 | 163 | { |
164 | // Adds the volume with the specified name and transformation | |
165 | // to the list of envelopes. | |
166 | // --- | |
167 | ||
168 | if (fDebug) { | |
169 | cout << "... Adding "; | |
170 | if (!isVirtual) cout << " non-"; | |
171 | cout << "virtual envelope " << name | |
172 | << " with translation and rotation" << endl; | |
173 | } | |
174 | ||
175 | // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation)); | |
176 | // would be nice to be so simple | |
177 | ||
178 | AliMUONGeometryEnvelope* envelope | |
6b82c1f0 | 179 | = new AliMUONGeometryEnvelope(name, isVirtual, only); |
d1cd2474 | 180 | envelope->SetRotation(rotation); |
181 | envelope->SetTranslation(translation); | |
182 | ||
183 | fEnvelopes->Add(envelope); | |
184 | } | |
185 | ||
186 | //______________________________________________________________________________ | |
6b82c1f0 | 187 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo, |
188 | const char* only) | |
d1cd2474 | 189 | { |
190 | // Adds the volume with the specified name and transformation | |
191 | // to the list of envelopes. | |
192 | // --- | |
193 | ||
194 | if (fDebug) { | |
195 | cout << "... Adding " | |
196 | << " non-virtual envelope " << name | |
197 | << " with copyNo " << copyNo << endl; | |
198 | } | |
199 | ||
200 | AliMUONGeometryEnvelope* envelope | |
6b82c1f0 | 201 | = new AliMUONGeometryEnvelope(name, copyNo, only); |
d1cd2474 | 202 | |
203 | fEnvelopes->Add(envelope); | |
204 | } | |
205 | ||
206 | //______________________________________________________________________________ | |
207 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo, | |
6b82c1f0 | 208 | const TGeoTranslation& translation, |
209 | const char* only) | |
d1cd2474 | 210 | { |
211 | // Adds the volume with the specified name and transformation | |
212 | // to the list of envelopes. | |
213 | // --- | |
214 | ||
215 | if (fDebug) { | |
216 | cout << "... Adding " | |
217 | << " non-virtual envelope " << name | |
218 | << " with copyNo " << copyNo | |
219 | << " with translation " << endl; | |
220 | } | |
221 | ||
222 | AliMUONGeometryEnvelope* envelope | |
6b82c1f0 | 223 | = new AliMUONGeometryEnvelope(name, copyNo, only); |
d1cd2474 | 224 | envelope->SetTranslation(translation); |
225 | ||
226 | fEnvelopes->Add(envelope); | |
227 | } | |
228 | ||
229 | //______________________________________________________________________________ | |
230 | void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo, | |
231 | const TGeoTranslation& translation, | |
6b82c1f0 | 232 | const TGeoRotation& rotation, |
233 | const char* only) | |
d1cd2474 | 234 | { |
235 | // Adds the volume with the specified name and transformation | |
236 | // to the list of envelopes. | |
237 | // --- | |
238 | ||
239 | if (fDebug) { | |
240 | cout << "... Adding " | |
241 | << " non-virtual envelope " << name | |
242 | << " with copyNo " << copyNo | |
243 | << " with translation and rotation" << endl; | |
244 | } | |
245 | ||
246 | // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation)); | |
247 | // would be nice to be so simple | |
248 | ||
249 | AliMUONGeometryEnvelope* envelope | |
6b82c1f0 | 250 | = new AliMUONGeometryEnvelope(name, copyNo, only); |
d1cd2474 | 251 | envelope->SetRotation(rotation); |
252 | envelope->SetTranslation(translation); | |
253 | ||
254 | fEnvelopes->Add(envelope); | |
255 | } | |
256 | ||
257 | //______________________________________________________________________________ | |
258 | void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name, | |
259 | const TString& envName, Int_t copyNo) | |
260 | { | |
261 | // Adds the volume with the specified name and transformation | |
262 | // to the list of envelopes. | |
263 | // --- | |
264 | ||
265 | if (fDebug) { | |
266 | cout << "... Adding constituent " << name | |
267 | << " to envelope " << envName | |
268 | << " with copyNo " << copyNo << endl; | |
269 | } | |
270 | ||
271 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
272 | ||
273 | if (!envelope) { | |
274 | // add warning | |
275 | return; | |
276 | } | |
277 | ||
278 | envelope->AddConstituent(name, copyNo); | |
279 | } | |
280 | ||
281 | //______________________________________________________________________________ | |
282 | void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name, | |
283 | const TString& envName, Int_t copyNo, | |
284 | const TGeoTranslation& translation) | |
285 | { | |
286 | // Adds the volume with the specified name and transformation | |
287 | // to the list of envelopes. | |
288 | // --- | |
289 | ||
290 | if (fDebug) { | |
291 | cout << "... Adding constituent " << name | |
292 | << " to envelope " << envName | |
293 | << " with copyNo " << copyNo | |
294 | << " with translation" << endl; | |
295 | } | |
296 | ||
297 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
298 | ||
299 | if (!envelope) { | |
300 | // add warning | |
301 | return; | |
302 | } | |
303 | ||
304 | envelope->AddConstituent(name, copyNo, translation); | |
305 | } | |
306 | ||
307 | //______________________________________________________________________________ | |
308 | void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name, | |
309 | const TString& envName, Int_t copyNo, | |
310 | const TGeoTranslation& translation, | |
311 | const TGeoRotation& rotation) | |
312 | { | |
313 | // Adds the volume with the specified name and transformation | |
314 | // to the list of envelopes. | |
315 | // --- | |
316 | ||
317 | if (fDebug) { | |
318 | cout << "... Adding constituent " << name | |
319 | << " to envelope " << envName | |
320 | << " with copyNo " << copyNo | |
321 | << " with translation and rotation" << endl; | |
322 | } | |
323 | ||
324 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
325 | ||
326 | if (!envelope) { | |
327 | // add warning | |
328 | return; | |
329 | } | |
330 | ||
331 | envelope->AddConstituent(name, copyNo, translation, rotation); | |
332 | } | |
333 | ||
334 | //______________________________________________________________________________ | |
335 | void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, | |
336 | const TString& envName, Int_t copyNo, | |
337 | Int_t npar, Double_t* param) | |
338 | { | |
339 | // Adds the volume with the specified name and transformation | |
340 | // to the list of envelopes. | |
341 | // --- | |
342 | ||
343 | if (fDebug) { | |
344 | cout << "... Adding parameterised constituent " << name | |
345 | << " to envelope " << envName | |
346 | << " with copyNo " << copyNo << endl; | |
347 | } | |
348 | ||
349 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
350 | ||
351 | if (!envelope) { | |
352 | // add warning | |
353 | return; | |
354 | } | |
355 | ||
356 | envelope->AddConstituentParam(name, copyNo, npar, param); | |
357 | } | |
358 | ||
359 | //______________________________________________________________________________ | |
360 | void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, | |
361 | const TString& envName, Int_t copyNo, | |
362 | const TGeoTranslation& translation, | |
363 | Int_t npar, Double_t* param) | |
364 | { | |
365 | // Adds the volume with the specified name and transformation | |
366 | // to the list of envelopes. | |
367 | // --- | |
368 | ||
369 | if (fDebug) { | |
370 | cout << "... Adding parameterised constituent " << name | |
371 | << " to envelope " << envName | |
372 | << " with copyNo " << copyNo | |
373 | << " with translation" << endl; | |
374 | } | |
375 | ||
376 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
377 | ||
378 | if (!envelope) { | |
379 | // add warning | |
380 | return; | |
381 | } | |
382 | ||
383 | envelope->AddConstituentParam(name, copyNo, translation, npar, param); | |
384 | } | |
385 | ||
386 | //______________________________________________________________________________ | |
387 | void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name, | |
388 | const TString& envName, Int_t copyNo, | |
389 | const TGeoTranslation& translation, | |
390 | const TGeoRotation& rotation, | |
391 | Int_t npar, Double_t* param) | |
392 | { | |
393 | // Adds the volume with the specified name and transformation | |
394 | // to the list of envelopes. | |
395 | // --- | |
396 | ||
397 | if (fDebug) { | |
398 | cout << "... Adding parameterised constituent " << name | |
399 | << " to envelope " << envName | |
400 | << " with copyNo " << copyNo | |
401 | << " with translation and rotation" << endl; | |
402 | } | |
403 | ||
404 | AliMUONGeometryEnvelope* envelope = FindEnvelope(envName); | |
405 | ||
406 | if (!envelope) { | |
407 | // add warning | |
408 | return; | |
409 | } | |
410 | ||
411 | envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param); | |
412 | } | |
413 | ||
414 | //______________________________________________________________________________ | |
415 | void AliMUONChamberGeometry::SetTranslation(const TGeoTranslation& translation) | |
416 | { | |
417 | // Sets the chamber position wrt ALIC. | |
418 | // --- | |
419 | ||
420 | fTransformation | |
421 | ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation())); | |
422 | } | |
423 | ||
424 | //______________________________________________________________________________ | |
425 | void AliMUONChamberGeometry::SetRotation(const TGeoRotation& rotation) | |
426 | { | |
427 | // Sets the chamber rotation wrt ALIC. | |
428 | // --- | |
429 | ||
430 | TGeoRotation* rot = new TGeoRotation(); | |
431 | rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix())); | |
432 | ||
433 | fTransformation->SetRotation(rot); | |
434 | } | |
435 | ||
436 | //______________________________________________________________________________ | |
437 | void AliMUONChamberGeometry::SetSensitiveVolume(Int_t volId) | |
438 | { | |
439 | // Adds the volume specified by volId to the list of sensitive | |
440 | // volumes | |
441 | ||
442 | fSensVolumeIds->AddAt(volId,fNofSensVolumeIds++); | |
443 | } | |
444 | ||
445 | //______________________________________________________________________________ | |
446 | void AliMUONChamberGeometry::SetSensitiveVolume(const TString& volName) | |
447 | { | |
448 | // Adds the volume specified by volId to the list of sensitive | |
449 | // volumes | |
450 | ||
451 | fSensVolumeIds->AddAt(gMC->VolId(volName),fNofSensVolumeIds++); | |
452 | } | |
453 | ||
454 | //______________________________________________________________________________ | |
455 | Bool_t AliMUONChamberGeometry::IsSensitiveVolume(Int_t volId) const | |
456 | { | |
457 | // Checks if the volume specified by volId is present in the list | |
458 | // of sensitive volumes. | |
459 | ||
460 | for (Int_t i=0; i<fNofSensVolumeIds; i++) { | |
461 | if (fSensVolumeIds->At(i) == volId) return kTRUE; | |
462 | } | |
463 | return kFALSE; | |
464 | } |