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::ConvertTransform(const TGeoHMatrix& transform) const
112 // Convert transformation into the reference frame
114 if ( fReferenceFrame.IsIdentity() )
117 return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(),
123 //______________________________________________________________________________
124 AliMUONGeometryEnvelope*
125 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
127 /// Find the envelope specified by name.
129 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
130 AliMUONGeometryEnvelope* envelope
131 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
133 if (envelope->GetName() == name) return envelope;
139 //______________________________________________________________________________
140 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
141 AliMUONGeometryEnvelope* envelope) const
143 /// Find transformation by the detection element Id (if not 0)
144 /// (= unique ID of enevelope) and set it to the envelope.
145 /// Return true if transformation is applied, false otherwise.
147 Int_t detElemId = envelope->GetUniqueID();
148 if (detElemId == 0) return false;
150 AliMUONGeometryDetElement* detElement
151 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
153 AliWarning("Transformation not found.");
157 // Apply frame transform
158 TGeoHMatrix newTransform
159 = ConvertTransform(*(detElement->GetLocalTransformation()));
161 envelope->SetTransform(newTransform);
170 //______________________________________________________________________________
171 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
176 /// Add the volume with the specified name and transformation
177 /// to the list of envelopes.
179 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
180 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
182 AliMUONGeometryEnvelope* envelope
183 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
185 if (fAlign) AlignEnvelope(envelope);
187 fEnvelopes->Add(envelope);
190 //______________________________________________________________________________
191 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
194 const TGeoTranslation& translation,
197 /// Add the volume with the specified name and transformation
198 /// to the list of envelopes.
201 cout << "... Adding ";
202 if (!isVirtual) cout << " non-";
203 cout << "virtual envelope " << name
205 << " with translation" << endl;
208 AliMUONGeometryEnvelope* envelope
209 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
211 Bool_t aligned = false;
212 if (fAlign) aligned = AlignEnvelope(envelope);
215 envelope->SetTranslation(translation);
217 fEnvelopes->Add(envelope);
220 //______________________________________________________________________________
221 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
224 const TGeoTranslation& translation,
225 const TGeoRotation& rotation,
228 /// Add the volume with the specified name and transformation
229 /// to the list of envelopes.
232 cout << "... Adding ";
233 if (!isVirtual) cout << " non-";
234 cout << "virtual envelope " << name
236 << " with translation and rotation" << endl;
240 cout << "Adding env... name: " << name;
242 const Double_t* xyz = translation.GetTranslation();
243 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
246 Double_t a1, a2, a3, a4, a5, a6;
247 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
248 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
250 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
251 // would be nice to be so simple
253 AliMUONGeometryEnvelope* envelope
254 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
256 Bool_t aligned = false;
257 if (fAlign) aligned = AlignEnvelope(envelope);
260 envelope->SetRotation(rotation);
261 envelope->SetTranslation(translation);
264 fEnvelopes->Add(envelope);
267 //______________________________________________________________________________
268 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
271 const TGeoCombiTrans& transform,
274 /// Add the volume with the specified name and transformation
275 /// to the list of envelopes.
278 cout << "... Adding ";
279 if (!isVirtual) cout << " non-";
280 cout << "virtual envelope " << name
282 << " with transformation" << endl;
285 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
286 // would be nice to be so simple
288 AliMUONGeometryEnvelope* envelope
289 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
291 Bool_t aligned = false;
292 if (fAlign) aligned = AlignEnvelope(envelope);
295 envelope->SetTransform(transform);
297 fEnvelopes->Add(envelope);
300 //______________________________________________________________________________
301 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
306 /// Add the volume with the specified name and transformation
307 /// to the list of envelopes.
310 cout << "... Adding "
311 << " non-virtual envelope " << name
313 << " with copyNo " << copyNo << endl;
316 AliMUONGeometryEnvelope* envelope
317 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
319 if (fAlign) AlignEnvelope(envelope);
321 fEnvelopes->Add(envelope);
324 //______________________________________________________________________________
325 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
328 const TGeoTranslation& translation,
331 /// Add the volume with the specified name and transformation
332 /// to the list of envelopes.
335 cout << "... Adding "
336 << " non-virtual envelope " << name
338 << " with copyNo " << copyNo
339 << " with translation " << endl;
342 AliMUONGeometryEnvelope* envelope
343 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
345 Bool_t aligned = false;
346 if (fAlign) aligned = AlignEnvelope(envelope);
349 envelope->SetTranslation(translation);
351 fEnvelopes->Add(envelope);
354 //______________________________________________________________________________
355 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
358 const TGeoTranslation& translation,
359 const TGeoRotation& rotation,
362 /// Add the volume with the specified name and transformation
363 /// to the list of envelopes.
366 cout << "... Adding "
367 << " non-virtual envelope " << name
369 << " with copyNo " << copyNo
370 << " with translation and rotation" << endl;
373 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
374 // would be nice to be so simple
376 AliMUONGeometryEnvelope* envelope
377 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
379 Bool_t aligned = false;
380 if (fAlign) aligned = AlignEnvelope(envelope);
383 envelope->SetRotation(rotation);
384 envelope->SetTranslation(translation);
387 fEnvelopes->Add(envelope);
390 //______________________________________________________________________________
391 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
394 const TGeoCombiTrans& transform,
397 /// Add the volume with the specified name and transformation
398 /// to the list of envelopes.
401 cout << "... Adding "
402 << " non-virtual envelope " << name
404 << " with copyNo " << copyNo
405 << " with translation and rotation" << endl;
408 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
409 // would be nice to be so simple
411 AliMUONGeometryEnvelope* envelope
412 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
414 Bool_t aligned = false;
415 if (fAlign) aligned = AlignEnvelope(envelope);
418 envelope->SetTransform(transform);
420 fEnvelopes->Add(envelope);
423 //______________________________________________________________________________
424 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
425 const TString& envName, Int_t copyNo)
427 /// Add the volume with the specified name and transformation
428 /// to the list of envelopes.
431 cout << "... Adding constituent " << name
432 << " to envelope " << envName
433 << " with copyNo " << copyNo << endl;
436 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
443 envelope->AddConstituent(name, copyNo);
446 //______________________________________________________________________________
447 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
448 const TString& envName, Int_t copyNo,
449 const TGeoTranslation& translation)
451 /// Add the volume with the specified name and transformation
452 /// to the list of envelopes.
455 cout << "... Adding constituent " << name
456 << " to envelope " << envName
457 << " with copyNo " << copyNo
458 << " with translation" << endl;
461 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
468 envelope->AddConstituent(name, copyNo, translation);
471 //______________________________________________________________________________
472 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
473 const TString& envName, Int_t copyNo,
474 const TGeoTranslation& translation,
475 const TGeoRotation& rotation)
477 /// Add the volume with the specified name and transformation
478 /// to the list of envelopes.
481 cout << "... Adding constituent " << name
482 << " to envelope " << envName
483 << " with copyNo " << copyNo
484 << " with translation and rotation" << endl;
487 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
494 envelope->AddConstituent(name, copyNo, translation, rotation);
497 //______________________________________________________________________________
498 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
499 const TString& envName, Int_t copyNo,
500 const TGeoCombiTrans& transform)
502 /// Add the volume with the specified name and transformation
503 /// to the list of envelopes.
506 cout << "... Adding constituent " << name
507 << " to envelope " << envName
508 << " with copyNo " << copyNo
509 << " with translation and rotation" << endl;
512 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
519 envelope->AddConstituent(name, copyNo, transform);
522 //______________________________________________________________________________
523 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
524 const TString& envName, Int_t copyNo,
525 Int_t npar, Double_t* param)
527 /// Add the volume with the specified name and transformation
528 /// to the list of envelopes.
531 cout << "... Adding parameterised constituent " << name
532 << " to envelope " << envName
533 << " with copyNo " << copyNo << endl;
536 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
543 envelope->AddConstituentParam(name, copyNo, npar, param);
546 //______________________________________________________________________________
547 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
548 const TString& envName, Int_t copyNo,
549 const TGeoTranslation& translation,
550 Int_t npar, Double_t* param)
552 /// Add the volume with the specified name and transformation
553 /// to the list of envelopes.
556 cout << "... Adding parameterised constituent " << name
557 << " to envelope " << envName
558 << " with copyNo " << copyNo
559 << " with translation" << endl;
562 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
569 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
572 //______________________________________________________________________________
573 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
574 const TString& envName, Int_t copyNo,
575 const TGeoTranslation& translation,
576 const TGeoRotation& rotation,
577 Int_t npar, Double_t* param)
579 /// Add the volume with the specified name and transformation
580 /// to the list of envelopes.
583 cout << "... Adding parameterised constituent " << name
584 << " to envelope " << envName
585 << " with copyNo " << copyNo
586 << " with translation and rotation" << endl;
589 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
596 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
599 //______________________________________________________________________________
600 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
601 const TString& envName, Int_t copyNo,
602 const TGeoCombiTrans& transform,
603 Int_t npar, Double_t* param)
605 /// Add the volume with the specified name and transformation
606 /// to the list of envelopes.
609 cout << "... Adding parameterised constituent " << name
610 << " to envelope " << envName
611 << " with copyNo " << copyNo
612 << " with translation and rotation" << endl;
615 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
622 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
625 //______________________________________________________________________________
626 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
628 /// Return the number od envelopes with detElemId>0.
630 Int_t nofDetElems = 0;
632 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
633 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;