]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometryEnvelopeStore.cxx
- Modified comment lines to be compatible with Doxygen
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryEnvelopeStore.cxx
CommitLineData
e118b27e 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
89cc3034 16// $Id$
17//
18// Class AliMUONGeometryEnvelopeStore
19// ----------------------------------
20// Class for definititon of the temporary volume envelopes
21// used in geometry construction
22//
23// Author: Ivana Hrivnacova, IPN Orsay
24
25#include <TVirtualMC.h>
26#include <TGeoMatrix.h>
27#include <TObjArray.h>
28#include <TArrayI.h>
29#include <Riostream.h>
30
31#include "AliMUONGeometryEnvelopeStore.h"
89cc3034 32#include "AliMUONGeometryEnvelope.h"
e118b27e 33#include "AliMUONGeometryDetElement.h"
34#include "AliMUONGeometryStore.h"
89cc3034 35#include "AliMUONConstants.h"
8c343c7c 36#include "AliLog.h"
89cc3034 37
38ClassImp(AliMUONGeometryEnvelopeStore)
39
40//______________________________________________________________________________
41AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
e118b27e 42 AliMUONGeometryStore* detElements)
89cc3034 43 : TObject(),
89cc3034 44 fEnvelopes(0),
e118b27e 45 fDetElements(detElements),
89cc3034 46 fDebug(false),
47 fAlign(false)
48{
692de412 49/// Standard constructor
89cc3034 50
51 fEnvelopes = new TObjArray(100);
52}
53
54
55//______________________________________________________________________________
56AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
57 : TObject(),
89cc3034 58 fEnvelopes(0),
e118b27e 59 fDetElements(0),
89cc3034 60 fDebug(false),
61 fAlign(false)
62{
692de412 63/// Default constructor
89cc3034 64}
65
66
67//______________________________________________________________________________
68AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(const AliMUONGeometryEnvelopeStore& rhs)
69 : TObject(rhs)
70{
8c343c7c 71 AliFatal("Copy constructor is not implemented.");
89cc3034 72}
73
74//______________________________________________________________________________
75AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
76{
692de412 77/// Destructor
89cc3034 78
79 // Add deleting rotation matrices
80
81 if (fEnvelopes) {
82 fEnvelopes->Delete();
83 delete fEnvelopes;
84 }
85}
86
87//______________________________________________________________________________
88AliMUONGeometryEnvelopeStore&
89AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rhs)
90{
692de412 91/// Protected assignement operator
92
89cc3034 93 // check assignement to self
94 if (this == &rhs) return *this;
95
8c343c7c 96 AliFatal("Assignment operator is not implemented.");
89cc3034 97
98 return *this;
99}
100
101//
102// private methods
103//
104
105//______________________________________________________________________________
106AliMUONGeometryEnvelope*
107AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
108{
692de412 109/// Find the envelope specified by name.
89cc3034 110
111 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
112 AliMUONGeometryEnvelope* envelope
113 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
114
115 if (envelope->GetName() == name) return envelope;
116 }
117
118 return 0;
119}
120
121//______________________________________________________________________________
122Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
123 AliMUONGeometryEnvelope* envelope) const
124{
692de412 125/// Find transformation by the detection element Id (if not 0)
126/// (= unique ID of enevelope) and set it to the envelope.
127/// Return true if transformation is applied, false otherwise.
89cc3034 128
129 Int_t detElemId = envelope->GetUniqueID();
130 if (detElemId == 0) return false;
131
e118b27e 132 AliMUONGeometryDetElement* detElement
133 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
134 if (!detElement) {
8c343c7c 135 AliWarning("Transformation not found.");
89cc3034 136 return false;
137 };
138
e118b27e 139 envelope->SetTransform(*(detElement->GetLocalTransformation()));
89cc3034 140 return true;
141}
142
143//
144// public methods
145//
146
147//______________________________________________________________________________
148void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
149 Int_t id,
150 Bool_t isVirtual,
151 const char* only)
152{
692de412 153/// Add the volume with the specified name and transformation
154/// to the list of envelopes.
89cc3034 155
8c343c7c 156 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
157// else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
89cc3034 158
159 AliMUONGeometryEnvelope* envelope
160 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
161
162 if (fAlign) AlignEnvelope(envelope);
163
164 fEnvelopes->Add(envelope);
165}
166
167//______________________________________________________________________________
168void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
169 Int_t id,
170 Bool_t isVirtual,
171 const TGeoTranslation& translation,
172 const char* only)
173{
692de412 174/// Add the volume with the specified name and transformation
175/// to the list of envelopes.
89cc3034 176
177 if (fDebug) {
178 cout << "... Adding ";
179 if (!isVirtual) cout << " non-";
180 cout << "virtual envelope " << name
181 << " id " << id
182 << " with translation" << endl;
183 }
184
185 AliMUONGeometryEnvelope* envelope
186 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
187
188 Bool_t aligned = false;
189 if (fAlign) aligned = AlignEnvelope(envelope);
190
191 if (!aligned)
192 envelope->SetTranslation(translation);
193
194 fEnvelopes->Add(envelope);
195}
196
197//______________________________________________________________________________
198void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
199 Int_t id,
200 Bool_t isVirtual,
201 const TGeoTranslation& translation,
202 const TGeoRotation& rotation,
203 const char* only)
204{
692de412 205/// Add the volume with the specified name and transformation
206/// to the list of envelopes.
89cc3034 207
208 if (fDebug) {
209 cout << "... Adding ";
210 if (!isVirtual) cout << " non-";
211 cout << "virtual envelope " << name
212 << " id " << id
213 << " with translation and rotation" << endl;
214 }
215
216/*
217 cout << "Adding env... name: " << name;
218
219 const Double_t* xyz = translation.GetTranslation();
220 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
221 << " rotation: ";
222
223 Double_t a1, a2, a3, a4, a5, a6;
224 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
225 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
226*/
227 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
228 // would be nice to be so simple
229
230 AliMUONGeometryEnvelope* envelope
231 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
232
233 Bool_t aligned = false;
234 if (fAlign) aligned = AlignEnvelope(envelope);
235
236 if (!aligned) {
237 envelope->SetRotation(rotation);
238 envelope->SetTranslation(translation);
239 }
240
241 fEnvelopes->Add(envelope);
242}
243
244//______________________________________________________________________________
245void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
246 Int_t id,
247 Bool_t isVirtual,
248 const TGeoCombiTrans& transform,
249 const char* only)
250{
692de412 251/// Add the volume with the specified name and transformation
252/// to the list of envelopes.
89cc3034 253
254 if (fDebug) {
255 cout << "... Adding ";
256 if (!isVirtual) cout << " non-";
257 cout << "virtual envelope " << name
258 << " id " << id
259 << " with transformation" << endl;
260 }
261
262 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
263 // would be nice to be so simple
264
265 AliMUONGeometryEnvelope* envelope
266 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
267
268 Bool_t aligned = false;
269 if (fAlign) aligned = AlignEnvelope(envelope);
270
271 if (!aligned)
272 envelope->SetTransform(transform);
273
274 fEnvelopes->Add(envelope);
275}
276
277//______________________________________________________________________________
278void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
279 Int_t id,
280 Int_t copyNo,
281 const char* only)
282{
692de412 283/// Add the volume with the specified name and transformation
284/// to the list of envelopes.
89cc3034 285
286 if (fDebug) {
287 cout << "... Adding "
288 << " non-virtual envelope " << name
289 << " id " << id
290 << " with copyNo " << copyNo << endl;
291 }
292
293 AliMUONGeometryEnvelope* envelope
294 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
295
296 if (fAlign) AlignEnvelope(envelope);
297
298 fEnvelopes->Add(envelope);
299}
300
301//______________________________________________________________________________
302void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
303 Int_t id,
304 Int_t copyNo,
305 const TGeoTranslation& translation,
306 const char* only)
307{
692de412 308/// Add the volume with the specified name and transformation
309/// to the list of envelopes.
89cc3034 310
311 if (fDebug) {
312 cout << "... Adding "
313 << " non-virtual envelope " << name
314 << " id " << id
315 << " with copyNo " << copyNo
316 << " with translation " << endl;
317 }
318
319 AliMUONGeometryEnvelope* envelope
320 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
321
322 Bool_t aligned = false;
323 if (fAlign) aligned = AlignEnvelope(envelope);
324
325 if (!aligned)
326 envelope->SetTranslation(translation);
327
328 fEnvelopes->Add(envelope);
329}
330
331//______________________________________________________________________________
332void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
333 Int_t id,
334 Int_t copyNo,
335 const TGeoTranslation& translation,
336 const TGeoRotation& rotation,
337 const char* only)
338{
692de412 339/// Add the volume with the specified name and transformation
340/// to the list of envelopes.
89cc3034 341
342 if (fDebug) {
343 cout << "... Adding "
344 << " non-virtual envelope " << name
345 << " id " << id
346 << " with copyNo " << copyNo
347 << " with translation and rotation" << endl;
348 }
349
350 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
351 // would be nice to be so simple
352
353 AliMUONGeometryEnvelope* envelope
354 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
355
356 Bool_t aligned = false;
357 if (fAlign) aligned = AlignEnvelope(envelope);
358
359 if (!aligned) {
360 envelope->SetRotation(rotation);
361 envelope->SetTranslation(translation);
362 }
363
364 fEnvelopes->Add(envelope);
365}
366
367//______________________________________________________________________________
368void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
369 Int_t id,
370 Int_t copyNo,
371 const TGeoCombiTrans& transform,
372 const char* only)
373{
692de412 374/// Add the volume with the specified name and transformation
375/// to the list of envelopes.
89cc3034 376
377 if (fDebug) {
378 cout << "... Adding "
379 << " non-virtual envelope " << name
380 << " id " << id
381 << " with copyNo " << copyNo
382 << " with translation and rotation" << endl;
383 }
384
385 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
386 // would be nice to be so simple
387
388 AliMUONGeometryEnvelope* envelope
389 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
390
391 Bool_t aligned = false;
392 if (fAlign) aligned = AlignEnvelope(envelope);
393
394 if (!aligned)
395 envelope->SetTransform(transform);
396
397 fEnvelopes->Add(envelope);
398}
399
400//______________________________________________________________________________
401void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
402 const TString& envName, Int_t copyNo)
403{
692de412 404/// Add the volume with the specified name and transformation
405/// to the list of envelopes.
89cc3034 406
407 if (fDebug) {
408 cout << "... Adding constituent " << name
409 << " to envelope " << envName
410 << " with copyNo " << copyNo << endl;
411 }
412
413 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
414
415 if (!envelope) {
416 // add warning
417 return;
418 }
419
420 envelope->AddConstituent(name, copyNo);
421}
422
423//______________________________________________________________________________
424void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
425 const TString& envName, Int_t copyNo,
426 const TGeoTranslation& translation)
427{
692de412 428/// Add the volume with the specified name and transformation
429/// to the list of envelopes.
89cc3034 430
431 if (fDebug) {
432 cout << "... Adding constituent " << name
433 << " to envelope " << envName
434 << " with copyNo " << copyNo
435 << " with translation" << endl;
436 }
437
438 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
439
440 if (!envelope) {
441 // add warning
442 return;
443 }
444
445 envelope->AddConstituent(name, copyNo, translation);
446}
447
448//______________________________________________________________________________
449void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
450 const TString& envName, Int_t copyNo,
451 const TGeoTranslation& translation,
452 const TGeoRotation& rotation)
453{
692de412 454/// Add the volume with the specified name and transformation
455/// to the list of envelopes.
89cc3034 456
457 if (fDebug) {
458 cout << "... Adding constituent " << name
459 << " to envelope " << envName
460 << " with copyNo " << copyNo
461 << " with translation and rotation" << endl;
462 }
463
464 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
465
466 if (!envelope) {
467 // add warning
468 return;
469 }
470
471 envelope->AddConstituent(name, copyNo, translation, rotation);
472}
473
474//______________________________________________________________________________
475void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
476 const TString& envName, Int_t copyNo,
477 const TGeoCombiTrans& transform)
478{
692de412 479/// Add the volume with the specified name and transformation
480/// to the list of envelopes.
89cc3034 481
482 if (fDebug) {
483 cout << "... Adding constituent " << name
484 << " to envelope " << envName
485 << " with copyNo " << copyNo
486 << " with translation and rotation" << endl;
487 }
488
489 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
490
491 if (!envelope) {
492 // add warning
493 return;
494 }
495
496 envelope->AddConstituent(name, copyNo, transform);
497}
498
499//______________________________________________________________________________
500void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
501 const TString& envName, Int_t copyNo,
502 Int_t npar, Double_t* param)
503{
692de412 504/// Add the volume with the specified name and transformation
505/// to the list of envelopes.
89cc3034 506
507 if (fDebug) {
508 cout << "... Adding parameterised constituent " << name
509 << " to envelope " << envName
510 << " with copyNo " << copyNo << endl;
511 }
512
513 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
514
515 if (!envelope) {
516 // add warning
517 return;
518 }
519
520 envelope->AddConstituentParam(name, copyNo, npar, param);
521}
522
523//______________________________________________________________________________
524void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
525 const TString& envName, Int_t copyNo,
526 const TGeoTranslation& translation,
527 Int_t npar, Double_t* param)
528{
692de412 529/// Add the volume with the specified name and transformation
530/// to the list of envelopes.
89cc3034 531
532 if (fDebug) {
533 cout << "... Adding parameterised constituent " << name
534 << " to envelope " << envName
535 << " with copyNo " << copyNo
536 << " with translation" << endl;
537 }
538
539 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
540
541 if (!envelope) {
542 // add warning
543 return;
544 }
545
546 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
547}
548
549//______________________________________________________________________________
550void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
551 const TString& envName, Int_t copyNo,
552 const TGeoTranslation& translation,
553 const TGeoRotation& rotation,
554 Int_t npar, Double_t* param)
555{
692de412 556/// Add the volume with the specified name and transformation
557/// to the list of envelopes.
89cc3034 558
559 if (fDebug) {
560 cout << "... Adding parameterised constituent " << name
561 << " to envelope " << envName
562 << " with copyNo " << copyNo
563 << " with translation and rotation" << endl;
564 }
565
566 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
567
568 if (!envelope) {
569 // add warning
570 return;
571 }
572
573 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
574}
575
576//______________________________________________________________________________
577void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
578 const TString& envName, Int_t copyNo,
579 const TGeoCombiTrans& transform,
580 Int_t npar, Double_t* param)
581{
692de412 582/// Add the volume with the specified name and transformation
583/// to the list of envelopes.
89cc3034 584
585 if (fDebug) {
586 cout << "... Adding parameterised constituent " << name
587 << " to envelope " << envName
588 << " with copyNo " << copyNo
589 << " with translation and rotation" << endl;
590 }
591
592 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
593
594 if (!envelope) {
595 // add warning
596 return;
597 }
598
599 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
600}
601
e118b27e 602//______________________________________________________________________________
603Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
604{
692de412 605/// Return the number od envelopes with detElemId>0.
e118b27e 606
607 Int_t nofDetElems = 0;
608
609 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
610 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;
611
612 return nofDetElems;
613}