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
24 //-----------------------------------------------------------------------------
26 #include "AliMUONGeometryEnvelopeStore.h"
27 #include "AliMUONGeometryEnvelope.h"
28 #include "AliMUONGeometryDetElement.h"
29 #include "AliMUONGeometryBuilder.h"
31 #include "AliMpExMap.h"
35 #include <TGeoMatrix.h>
36 #include <TObjArray.h>
37 #include <Riostream.h>
43 ClassImp(AliMUONGeometryEnvelopeStore)
46 //______________________________________________________________________________
47 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
48 AliMpExMap* detElements)
51 fDetElements(detElements),
56 /// Standard constructor
58 fEnvelopes = new TObjArray(100);
62 //______________________________________________________________________________
63 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
71 /// Default constructor
75 //______________________________________________________________________________
76 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
80 // Add deleting rotation matrices
92 //______________________________________________________________________________
94 AliMUONGeometryEnvelopeStore::ConvertDETransform(const TGeoHMatrix& transform) const
96 /// Convert transformation into the reference frame
98 if ( fReferenceFrame.IsIdentity() )
101 return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(),
106 //______________________________________________________________________________
107 AliMUONGeometryEnvelope*
108 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
110 /// Find the envelope specified by name.
112 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
113 AliMUONGeometryEnvelope* envelope
114 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
116 if (envelope->GetName() == name) return envelope;
122 //______________________________________________________________________________
123 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
124 AliMUONGeometryEnvelope* envelope) const
126 /// Find transformation by the detection element Id (if not 0)
127 /// (= unique ID of enevelope) and set it to the envelope.
128 /// Return true if transformation is applied, false otherwise.
130 Int_t detElemId = envelope->GetUniqueID();
131 if (detElemId == 0) return false;
133 AliMUONGeometryDetElement* detElement
134 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
136 AliWarning("Transformation not found.");
140 // Apply frame transform
141 TGeoHMatrix newTransform
142 = ConvertDETransform(*(detElement->GetLocalTransformation()));
144 envelope->SetTransform(newTransform);
153 //______________________________________________________________________________
154 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
159 /// Add the volume with the specified name and transformation
160 /// to the list of envelopes.
162 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
163 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
165 AliMUONGeometryEnvelope* envelope
166 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
168 if (fAlign) AlignEnvelope(envelope);
170 fEnvelopes->Add(envelope);
173 //______________________________________________________________________________
174 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
177 const TGeoTranslation& translation,
180 /// Add the volume with the specified name and transformation
181 /// to the list of envelopes.
184 cout << "... Adding ";
185 if (!isVirtual) cout << " non-";
186 cout << "virtual envelope " << name
188 << " with translation" << endl;
191 AliMUONGeometryEnvelope* envelope
192 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
194 Bool_t aligned = false;
195 if (fAlign) aligned = AlignEnvelope(envelope);
198 envelope->SetTranslation(translation);
200 fEnvelopes->Add(envelope);
203 //______________________________________________________________________________
204 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
207 const TGeoTranslation& translation,
208 const TGeoRotation& rotation,
211 /// Add the volume with the specified name and transformation
212 /// to the list of envelopes.
215 cout << "... Adding ";
216 if (!isVirtual) cout << " non-";
217 cout << "virtual envelope " << name
219 << " with translation and rotation" << endl;
223 cout << "Adding env... name: " << name;
225 const Double_t* xyz = translation.GetTranslation();
226 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
229 Double_t a1, a2, a3, a4, a5, a6;
230 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
231 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
233 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
234 // would be nice to be so simple
236 AliMUONGeometryEnvelope* envelope
237 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
239 Bool_t aligned = false;
240 if (fAlign) aligned = AlignEnvelope(envelope);
243 envelope->SetRotation(rotation);
244 envelope->SetTranslation(translation);
247 fEnvelopes->Add(envelope);
250 //______________________________________________________________________________
251 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
254 const TGeoCombiTrans& transform,
257 /// Add the volume with the specified name and transformation
258 /// to the list of envelopes.
261 cout << "... Adding ";
262 if (!isVirtual) cout << " non-";
263 cout << "virtual envelope " << name
265 << " with transformation" << endl;
268 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
269 // would be nice to be so simple
271 AliMUONGeometryEnvelope* envelope
272 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
274 Bool_t aligned = false;
275 if (fAlign) aligned = AlignEnvelope(envelope);
278 envelope->SetTransform(transform);
280 fEnvelopes->Add(envelope);
283 //______________________________________________________________________________
284 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
289 /// Add the volume with the specified name and transformation
290 /// to the list of envelopes.
293 cout << "... Adding "
294 << " non-virtual envelope " << name
296 << " with copyNo " << copyNo << endl;
299 AliMUONGeometryEnvelope* envelope
300 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
302 if (fAlign) AlignEnvelope(envelope);
304 fEnvelopes->Add(envelope);
307 //______________________________________________________________________________
308 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
311 const TGeoTranslation& translation,
314 /// Add the volume with the specified name and transformation
315 /// to the list of envelopes.
318 cout << "... Adding "
319 << " non-virtual envelope " << name
321 << " with copyNo " << copyNo
322 << " with translation " << endl;
325 AliMUONGeometryEnvelope* envelope
326 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
328 Bool_t aligned = false;
329 if (fAlign) aligned = AlignEnvelope(envelope);
332 envelope->SetTranslation(translation);
334 fEnvelopes->Add(envelope);
337 //______________________________________________________________________________
338 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
341 const TGeoTranslation& translation,
342 const TGeoRotation& rotation,
345 /// Add the volume with the specified name and transformation
346 /// to the list of envelopes.
349 cout << "... Adding "
350 << " non-virtual envelope " << name
352 << " with copyNo " << copyNo
353 << " with translation and rotation" << endl;
356 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
357 // would be nice to be so simple
359 AliMUONGeometryEnvelope* envelope
360 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
362 Bool_t aligned = false;
363 if (fAlign) aligned = AlignEnvelope(envelope);
366 envelope->SetRotation(rotation);
367 envelope->SetTranslation(translation);
370 fEnvelopes->Add(envelope);
373 //______________________________________________________________________________
374 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
377 const TGeoCombiTrans& transform,
380 /// Add the volume with the specified name and transformation
381 /// to the list of envelopes.
384 cout << "... Adding "
385 << " non-virtual envelope " << name
387 << " with copyNo " << copyNo
388 << " with translation and rotation" << endl;
391 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
392 // would be nice to be so simple
394 AliMUONGeometryEnvelope* envelope
395 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
397 Bool_t aligned = false;
398 if (fAlign) aligned = AlignEnvelope(envelope);
401 envelope->SetTransform(transform);
403 fEnvelopes->Add(envelope);
406 //______________________________________________________________________________
407 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
408 const TString& envName, Int_t copyNo)
410 /// Add the volume with the specified name and transformation
411 /// as a constituent of the envelope envName.
414 cout << "... Adding constituent " << name
415 << " to envelope " << envName
416 << " with copyNo " << copyNo << endl;
419 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
426 envelope->AddConstituent(name, copyNo);
429 //______________________________________________________________________________
430 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
431 const TString& envName, Int_t copyNo,
432 const TGeoTranslation& translation)
434 /// Add the volume with the specified name and transformation
435 /// as a constituent of the envelope envName.
438 cout << "... Adding constituent " << name
439 << " to envelope " << envName
440 << " with copyNo " << copyNo
441 << " with translation" << endl;
444 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
451 envelope->AddConstituent(name, copyNo, translation);
454 //______________________________________________________________________________
455 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
456 const TString& envName, Int_t copyNo,
457 const TGeoTranslation& translation,
458 const TGeoRotation& rotation)
460 /// Add the volume with the specified name and transformation
461 /// as a constituent of the envelope envName.
464 cout << "... Adding constituent " << name
465 << " to envelope " << envName
466 << " with copyNo " << copyNo
467 << " with translation and rotation" << endl;
470 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
477 envelope->AddConstituent(name, copyNo, translation, rotation);
480 //______________________________________________________________________________
481 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
482 const TString& envName, Int_t copyNo,
483 const TGeoCombiTrans& transform)
485 /// Add the volume with the specified name and transformation
486 /// as a constituent of the envelope envName.
489 cout << "... Adding constituent " << name
490 << " to envelope " << envName
491 << " with copyNo " << copyNo
492 << " with translation and rotation" << endl;
495 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
502 envelope->AddConstituent(name, copyNo, transform);
505 //______________________________________________________________________________
506 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
507 const TString& envName, Int_t copyNo,
508 Int_t npar, Double_t* param)
510 /// Add the volume with the specified name and transformation
511 /// as a constituent of the envelope envName.
514 cout << "... Adding parameterised constituent " << name
515 << " to envelope " << envName
516 << " with copyNo " << copyNo << endl;
519 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
526 envelope->AddConstituentParam(name, copyNo, npar, param);
529 //______________________________________________________________________________
530 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
531 const TString& envName, Int_t copyNo,
532 const TGeoTranslation& translation,
533 Int_t npar, Double_t* param)
535 /// Add the volume with the specified name and transformation
536 /// as a constituent of the envelope envName.
539 cout << "... Adding parameterised constituent " << name
540 << " to envelope " << envName
541 << " with copyNo " << copyNo
542 << " with translation" << endl;
545 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
552 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
555 //______________________________________________________________________________
556 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
557 const TString& envName, Int_t copyNo,
558 const TGeoTranslation& translation,
559 const TGeoRotation& rotation,
560 Int_t npar, Double_t* param)
562 /// Add the volume with the specified name and transformation
563 /// as a constituent of the envelope envName.
566 cout << "... Adding parameterised constituent " << name
567 << " to envelope " << envName
568 << " with copyNo " << copyNo
569 << " with translation and rotation" << endl;
572 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
579 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
582 //______________________________________________________________________________
583 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
584 const TString& envName, Int_t copyNo,
585 const TGeoCombiTrans& transform,
586 Int_t npar, Double_t* param)
588 /// Add the volume with the specified name and transformation
589 /// as a constituent of the envelope envName.
592 cout << "... Adding parameterised constituent " << name
593 << " to envelope " << envName
594 << " with copyNo " << copyNo
595 << " with translation and rotation" << endl;
598 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
605 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
608 //______________________________________________________________________________
609 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
611 /// Return the number od envelopes with detElemId>0.
613 Int_t nofDetElems = 0;
615 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
616 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;