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 // ----------------------------------
19 // Class AliMUONGeometryEnvelopeStore
20 // ----------------------------------
21 // Class for definititon of the temporary volume envelopes
22 // used in geometry construction
23 // Author: Ivana Hrivnacova, IPN Orsay
25 #include "AliMUONGeometryEnvelopeStore.h"
26 #include "AliMUONGeometryEnvelope.h"
27 #include "AliMUONGeometryDetElement.h"
28 #include "AliMUONGeometryStore.h"
29 #include "AliMUONGeometryBuilder.h"
33 #include <TGeoMatrix.h>
34 #include <TObjArray.h>
35 #include <Riostream.h>
39 ClassImp(AliMUONGeometryEnvelopeStore)
42 //______________________________________________________________________________
43 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
44 AliMUONGeometryStore* detElements)
47 fDetElements(detElements),
52 /// Standard constructor
54 fEnvelopes = new TObjArray(100);
58 //______________________________________________________________________________
59 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
67 /// Default constructor
71 //______________________________________________________________________________
72 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
76 // Add deleting rotation matrices
88 //______________________________________________________________________________
90 AliMUONGeometryEnvelopeStore::ConvertDETransform(const TGeoHMatrix& transform) const
92 /// Convert transformation into the reference frame
94 if ( fReferenceFrame.IsIdentity() )
97 return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(),
102 //______________________________________________________________________________
103 AliMUONGeometryEnvelope*
104 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
106 /// Find the envelope specified by name.
108 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
109 AliMUONGeometryEnvelope* envelope
110 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
112 if (envelope->GetName() == name) return envelope;
118 //______________________________________________________________________________
119 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
120 AliMUONGeometryEnvelope* envelope) const
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.
126 Int_t detElemId = envelope->GetUniqueID();
127 if (detElemId == 0) return false;
129 AliMUONGeometryDetElement* detElement
130 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
132 AliWarning("Transformation not found.");
136 // Apply frame transform
137 TGeoHMatrix newTransform
138 = ConvertDETransform(*(detElement->GetLocalTransformation()));
140 envelope->SetTransform(newTransform);
149 //______________________________________________________________________________
150 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
155 /// Add the volume with the specified name and transformation
156 /// to the list of envelopes.
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));
161 AliMUONGeometryEnvelope* envelope
162 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
164 if (fAlign) AlignEnvelope(envelope);
166 fEnvelopes->Add(envelope);
169 //______________________________________________________________________________
170 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
173 const TGeoTranslation& translation,
176 /// Add the volume with the specified name and transformation
177 /// to the list of envelopes.
180 cout << "... Adding ";
181 if (!isVirtual) cout << " non-";
182 cout << "virtual envelope " << name
184 << " with translation" << endl;
187 AliMUONGeometryEnvelope* envelope
188 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
190 Bool_t aligned = false;
191 if (fAlign) aligned = AlignEnvelope(envelope);
194 envelope->SetTranslation(translation);
196 fEnvelopes->Add(envelope);
199 //______________________________________________________________________________
200 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
203 const TGeoTranslation& translation,
204 const TGeoRotation& rotation,
207 /// Add the volume with the specified name and transformation
208 /// to the list of envelopes.
211 cout << "... Adding ";
212 if (!isVirtual) cout << " non-";
213 cout << "virtual envelope " << name
215 << " with translation and rotation" << endl;
219 cout << "Adding env... name: " << name;
221 const Double_t* xyz = translation.GetTranslation();
222 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
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;
229 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
230 // would be nice to be so simple
232 AliMUONGeometryEnvelope* envelope
233 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
235 Bool_t aligned = false;
236 if (fAlign) aligned = AlignEnvelope(envelope);
239 envelope->SetRotation(rotation);
240 envelope->SetTranslation(translation);
243 fEnvelopes->Add(envelope);
246 //______________________________________________________________________________
247 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
250 const TGeoCombiTrans& transform,
253 /// Add the volume with the specified name and transformation
254 /// to the list of envelopes.
257 cout << "... Adding ";
258 if (!isVirtual) cout << " non-";
259 cout << "virtual envelope " << name
261 << " with transformation" << endl;
264 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
265 // would be nice to be so simple
267 AliMUONGeometryEnvelope* envelope
268 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
270 Bool_t aligned = false;
271 if (fAlign) aligned = AlignEnvelope(envelope);
274 envelope->SetTransform(transform);
276 fEnvelopes->Add(envelope);
279 //______________________________________________________________________________
280 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
285 /// Add the volume with the specified name and transformation
286 /// to the list of envelopes.
289 cout << "... Adding "
290 << " non-virtual envelope " << name
292 << " with copyNo " << copyNo << endl;
295 AliMUONGeometryEnvelope* envelope
296 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
298 if (fAlign) AlignEnvelope(envelope);
300 fEnvelopes->Add(envelope);
303 //______________________________________________________________________________
304 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
307 const TGeoTranslation& translation,
310 /// Add the volume with the specified name and transformation
311 /// to the list of envelopes.
314 cout << "... Adding "
315 << " non-virtual envelope " << name
317 << " with copyNo " << copyNo
318 << " with translation " << endl;
321 AliMUONGeometryEnvelope* envelope
322 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
324 Bool_t aligned = false;
325 if (fAlign) aligned = AlignEnvelope(envelope);
328 envelope->SetTranslation(translation);
330 fEnvelopes->Add(envelope);
333 //______________________________________________________________________________
334 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
337 const TGeoTranslation& translation,
338 const TGeoRotation& rotation,
341 /// Add the volume with the specified name and transformation
342 /// to the list of envelopes.
345 cout << "... Adding "
346 << " non-virtual envelope " << name
348 << " with copyNo " << copyNo
349 << " with translation and rotation" << endl;
352 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
353 // would be nice to be so simple
355 AliMUONGeometryEnvelope* envelope
356 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
358 Bool_t aligned = false;
359 if (fAlign) aligned = AlignEnvelope(envelope);
362 envelope->SetRotation(rotation);
363 envelope->SetTranslation(translation);
366 fEnvelopes->Add(envelope);
369 //______________________________________________________________________________
370 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
373 const TGeoCombiTrans& transform,
376 /// Add the volume with the specified name and transformation
377 /// to the list of envelopes.
380 cout << "... Adding "
381 << " non-virtual envelope " << name
383 << " with copyNo " << copyNo
384 << " with translation and rotation" << endl;
387 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
388 // would be nice to be so simple
390 AliMUONGeometryEnvelope* envelope
391 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
393 Bool_t aligned = false;
394 if (fAlign) aligned = AlignEnvelope(envelope);
397 envelope->SetTransform(transform);
399 fEnvelopes->Add(envelope);
402 //______________________________________________________________________________
403 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
404 const TString& envName, Int_t copyNo)
406 /// Add the volume with the specified name and transformation
407 /// as a constituent of the envelope envName.
410 cout << "... Adding constituent " << name
411 << " to envelope " << envName
412 << " with copyNo " << copyNo << endl;
415 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
422 envelope->AddConstituent(name, copyNo);
425 //______________________________________________________________________________
426 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
427 const TString& envName, Int_t copyNo,
428 const TGeoTranslation& translation)
430 /// Add the volume with the specified name and transformation
431 /// as a constituent of the envelope envName.
434 cout << "... Adding constituent " << name
435 << " to envelope " << envName
436 << " with copyNo " << copyNo
437 << " with translation" << endl;
440 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
447 envelope->AddConstituent(name, copyNo, translation);
450 //______________________________________________________________________________
451 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
452 const TString& envName, Int_t copyNo,
453 const TGeoTranslation& translation,
454 const TGeoRotation& rotation)
456 /// Add the volume with the specified name and transformation
457 /// as a constituent of the envelope envName.
460 cout << "... Adding constituent " << name
461 << " to envelope " << envName
462 << " with copyNo " << copyNo
463 << " with translation and rotation" << endl;
466 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
473 envelope->AddConstituent(name, copyNo, translation, rotation);
476 //______________________________________________________________________________
477 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
478 const TString& envName, Int_t copyNo,
479 const TGeoCombiTrans& transform)
481 /// Add the volume with the specified name and transformation
482 /// as a constituent of the envelope envName.
485 cout << "... Adding constituent " << name
486 << " to envelope " << envName
487 << " with copyNo " << copyNo
488 << " with translation and rotation" << endl;
491 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
498 envelope->AddConstituent(name, copyNo, transform);
501 //______________________________________________________________________________
502 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
503 const TString& envName, Int_t copyNo,
504 Int_t npar, Double_t* param)
506 /// Add the volume with the specified name and transformation
507 /// as a constituent of the envelope envName.
510 cout << "... Adding parameterised constituent " << name
511 << " to envelope " << envName
512 << " with copyNo " << copyNo << endl;
515 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
522 envelope->AddConstituentParam(name, copyNo, npar, param);
525 //______________________________________________________________________________
526 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
527 const TString& envName, Int_t copyNo,
528 const TGeoTranslation& translation,
529 Int_t npar, Double_t* param)
531 /// Add the volume with the specified name and transformation
532 /// as a constituent of the envelope envName.
535 cout << "... Adding parameterised constituent " << name
536 << " to envelope " << envName
537 << " with copyNo " << copyNo
538 << " with translation" << endl;
541 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
548 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
551 //______________________________________________________________________________
552 void 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)
558 /// Add the volume with the specified name and transformation
559 /// as a constituent of the envelope envName.
562 cout << "... Adding parameterised constituent " << name
563 << " to envelope " << envName
564 << " with copyNo " << copyNo
565 << " with translation and rotation" << endl;
568 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
575 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
578 //______________________________________________________________________________
579 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
580 const TString& envName, Int_t copyNo,
581 const TGeoCombiTrans& transform,
582 Int_t npar, Double_t* param)
584 /// Add the volume with the specified name and transformation
585 /// as a constituent of the envelope envName.
588 cout << "... Adding parameterised constituent " << name
589 << " to envelope " << envName
590 << " with copyNo " << copyNo
591 << " with translation and rotation" << endl;
594 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
601 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
604 //______________________________________________________________________________
605 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
607 /// Return the number od envelopes with detElemId>0.
609 Int_t nofDetElems = 0;
611 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
612 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;