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