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