1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // Class AliMUONGeometryEnvelopeStore
19 // ----------------------------------
20 // Class for definititon of the temporary volume envelopes
21 // used in geometry construction
23 // Author: Ivana Hrivnacova, IPN Orsay
25 #include <TVirtualMC.h>
26 #include <TGeoMatrix.h>
27 #include <TObjArray.h>
29 #include <Riostream.h>
31 #include "AliMUONGeometryEnvelopeStore.h"
32 #include "AliMUONGeometryEnvelope.h"
33 #include "AliMUONGeometryDetElement.h"
34 #include "AliMUONGeometryStore.h"
35 #include "AliMUONConstants.h"
36 #include "AliMUONGeometryBuilder.h"
39 ClassImp(AliMUONGeometryEnvelopeStore)
41 //______________________________________________________________________________
42 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
43 AliMUONGeometryStore* detElements)
46 fDetElements(detElements),
51 /// Standard constructor
53 fEnvelopes = new TObjArray(100);
57 //______________________________________________________________________________
58 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
66 /// Default constructor
70 //______________________________________________________________________________
71 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(const AliMUONGeometryEnvelopeStore& rhs)
74 AliFatal("Copy constructor is not implemented.");
77 //______________________________________________________________________________
78 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
82 // Add deleting rotation matrices
90 //______________________________________________________________________________
91 AliMUONGeometryEnvelopeStore&
92 AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rhs)
94 /// Protected assignement operator
96 // check assignement to self
97 if (this == &rhs) return *this;
99 AliFatal("Assignment operator is not implemented.");
108 //______________________________________________________________________________
110 AliMUONGeometryEnvelopeStore::ConvertDETransform(const TGeoHMatrix& transform) const
112 // Convert transformation into the reference frame
114 if ( fReferenceFrame.IsIdentity() )
117 return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(),
122 //______________________________________________________________________________
123 AliMUONGeometryEnvelope*
124 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
126 /// Find the envelope specified by name.
128 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
129 AliMUONGeometryEnvelope* envelope
130 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
132 if (envelope->GetName() == name) return envelope;
138 //______________________________________________________________________________
139 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
140 AliMUONGeometryEnvelope* envelope) const
142 /// Find transformation by the detection element Id (if not 0)
143 /// (= unique ID of enevelope) and set it to the envelope.
144 /// Return true if transformation is applied, false otherwise.
146 Int_t detElemId = envelope->GetUniqueID();
147 if (detElemId == 0) return false;
149 AliMUONGeometryDetElement* detElement
150 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
152 AliWarning("Transformation not found.");
156 // Apply frame transform
157 TGeoHMatrix newTransform
158 = ConvertDETransform(*(detElement->GetLocalTransformation()));
160 envelope->SetTransform(newTransform);
169 //______________________________________________________________________________
170 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
175 /// Add the volume with the specified name and transformation
176 /// to the list of envelopes.
178 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
179 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
181 AliMUONGeometryEnvelope* envelope
182 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
184 if (fAlign) AlignEnvelope(envelope);
186 fEnvelopes->Add(envelope);
189 //______________________________________________________________________________
190 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
193 const TGeoTranslation& translation,
196 /// Add the volume with the specified name and transformation
197 /// to the list of envelopes.
200 cout << "... Adding ";
201 if (!isVirtual) cout << " non-";
202 cout << "virtual envelope " << name
204 << " with translation" << endl;
207 AliMUONGeometryEnvelope* envelope
208 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
210 Bool_t aligned = false;
211 if (fAlign) aligned = AlignEnvelope(envelope);
214 envelope->SetTranslation(translation);
216 fEnvelopes->Add(envelope);
219 //______________________________________________________________________________
220 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
223 const TGeoTranslation& translation,
224 const TGeoRotation& rotation,
227 /// Add the volume with the specified name and transformation
228 /// to the list of envelopes.
231 cout << "... Adding ";
232 if (!isVirtual) cout << " non-";
233 cout << "virtual envelope " << name
235 << " with translation and rotation" << endl;
239 cout << "Adding env... name: " << name;
241 const Double_t* xyz = translation.GetTranslation();
242 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
245 Double_t a1, a2, a3, a4, a5, a6;
246 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
247 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
249 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
250 // would be nice to be so simple
252 AliMUONGeometryEnvelope* envelope
253 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
255 Bool_t aligned = false;
256 if (fAlign) aligned = AlignEnvelope(envelope);
259 envelope->SetRotation(rotation);
260 envelope->SetTranslation(translation);
263 fEnvelopes->Add(envelope);
266 //______________________________________________________________________________
267 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
270 const TGeoCombiTrans& transform,
273 /// Add the volume with the specified name and transformation
274 /// to the list of envelopes.
277 cout << "... Adding ";
278 if (!isVirtual) cout << " non-";
279 cout << "virtual envelope " << name
281 << " with transformation" << endl;
284 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
285 // would be nice to be so simple
287 AliMUONGeometryEnvelope* envelope
288 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
290 Bool_t aligned = false;
291 if (fAlign) aligned = AlignEnvelope(envelope);
294 envelope->SetTransform(transform);
296 fEnvelopes->Add(envelope);
299 //______________________________________________________________________________
300 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
305 /// Add the volume with the specified name and transformation
306 /// to the list of envelopes.
309 cout << "... Adding "
310 << " non-virtual envelope " << name
312 << " with copyNo " << copyNo << endl;
315 AliMUONGeometryEnvelope* envelope
316 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
318 if (fAlign) AlignEnvelope(envelope);
320 fEnvelopes->Add(envelope);
323 //______________________________________________________________________________
324 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
327 const TGeoTranslation& translation,
330 /// Add the volume with the specified name and transformation
331 /// to the list of envelopes.
334 cout << "... Adding "
335 << " non-virtual envelope " << name
337 << " with copyNo " << copyNo
338 << " with translation " << endl;
341 AliMUONGeometryEnvelope* envelope
342 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
344 Bool_t aligned = false;
345 if (fAlign) aligned = AlignEnvelope(envelope);
348 envelope->SetTranslation(translation);
350 fEnvelopes->Add(envelope);
353 //______________________________________________________________________________
354 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
357 const TGeoTranslation& translation,
358 const TGeoRotation& rotation,
361 /// Add the volume with the specified name and transformation
362 /// to the list of envelopes.
365 cout << "... Adding "
366 << " non-virtual envelope " << name
368 << " with copyNo " << copyNo
369 << " with translation and rotation" << endl;
372 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
373 // would be nice to be so simple
375 AliMUONGeometryEnvelope* envelope
376 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
378 Bool_t aligned = false;
379 if (fAlign) aligned = AlignEnvelope(envelope);
382 envelope->SetRotation(rotation);
383 envelope->SetTranslation(translation);
386 fEnvelopes->Add(envelope);
389 //______________________________________________________________________________
390 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
393 const TGeoCombiTrans& transform,
396 /// Add the volume with the specified name and transformation
397 /// to the list of envelopes.
400 cout << "... Adding "
401 << " non-virtual envelope " << name
403 << " with copyNo " << copyNo
404 << " with translation and rotation" << endl;
407 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
408 // would be nice to be so simple
410 AliMUONGeometryEnvelope* envelope
411 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
413 Bool_t aligned = false;
414 if (fAlign) aligned = AlignEnvelope(envelope);
417 envelope->SetTransform(transform);
419 fEnvelopes->Add(envelope);
422 //______________________________________________________________________________
423 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
424 const TString& envName, Int_t copyNo)
426 /// Add the volume with the specified name and transformation
427 /// to the list of envelopes.
430 cout << "... Adding constituent " << name
431 << " to envelope " << envName
432 << " with copyNo " << copyNo << endl;
435 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
442 envelope->AddConstituent(name, copyNo);
445 //______________________________________________________________________________
446 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
447 const TString& envName, Int_t copyNo,
448 const TGeoTranslation& translation)
450 /// Add the volume with the specified name and transformation
451 /// to the list of envelopes.
454 cout << "... Adding constituent " << name
455 << " to envelope " << envName
456 << " with copyNo " << copyNo
457 << " with translation" << endl;
460 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
467 envelope->AddConstituent(name, copyNo, translation);
470 //______________________________________________________________________________
471 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
472 const TString& envName, Int_t copyNo,
473 const TGeoTranslation& translation,
474 const TGeoRotation& rotation)
476 /// Add the volume with the specified name and transformation
477 /// to the list of envelopes.
480 cout << "... Adding constituent " << name
481 << " to envelope " << envName
482 << " with copyNo " << copyNo
483 << " with translation and rotation" << endl;
486 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
493 envelope->AddConstituent(name, copyNo, translation, rotation);
496 //______________________________________________________________________________
497 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
498 const TString& envName, Int_t copyNo,
499 const TGeoCombiTrans& transform)
501 /// Add the volume with the specified name and transformation
502 /// to the list of envelopes.
505 cout << "... Adding constituent " << name
506 << " to envelope " << envName
507 << " with copyNo " << copyNo
508 << " with translation and rotation" << endl;
511 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
518 envelope->AddConstituent(name, copyNo, transform);
521 //______________________________________________________________________________
522 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
523 const TString& envName, Int_t copyNo,
524 Int_t npar, Double_t* param)
526 /// Add the volume with the specified name and transformation
527 /// to the list of envelopes.
530 cout << "... Adding parameterised constituent " << name
531 << " to envelope " << envName
532 << " with copyNo " << copyNo << endl;
535 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
542 envelope->AddConstituentParam(name, copyNo, npar, param);
545 //______________________________________________________________________________
546 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
547 const TString& envName, Int_t copyNo,
548 const TGeoTranslation& translation,
549 Int_t npar, Double_t* param)
551 /// Add the volume with the specified name and transformation
552 /// to the list of envelopes.
555 cout << "... Adding parameterised constituent " << name
556 << " to envelope " << envName
557 << " with copyNo " << copyNo
558 << " with translation" << endl;
561 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
568 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
571 //______________________________________________________________________________
572 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
573 const TString& envName, Int_t copyNo,
574 const TGeoTranslation& translation,
575 const TGeoRotation& rotation,
576 Int_t npar, Double_t* param)
578 /// Add the volume with the specified name and transformation
579 /// to the list of envelopes.
582 cout << "... Adding parameterised constituent " << name
583 << " to envelope " << envName
584 << " with copyNo " << copyNo
585 << " with translation and rotation" << endl;
588 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
595 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
598 //______________________________________________________________________________
599 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
600 const TString& envName, Int_t copyNo,
601 const TGeoCombiTrans& transform,
602 Int_t npar, Double_t* param)
604 /// Add the volume with the specified name and transformation
605 /// to the list of envelopes.
608 cout << "... Adding parameterised constituent " << name
609 << " to envelope " << envName
610 << " with copyNo " << copyNo
611 << " with translation and rotation" << endl;
614 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
621 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
624 //______________________________________________________________________________
625 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
627 /// Return the number od envelopes with detElemId>0.
629 Int_t nofDetElems = 0;
631 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
632 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;