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>
41 ClassImp(AliMUONGeometryEnvelopeStore)
44 //______________________________________________________________________________
45 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
46 AliMpExMap* detElements)
49 fDetElements(detElements),
54 /// Standard constructor
56 fEnvelopes = new TObjArray(100);
60 //______________________________________________________________________________
61 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
69 /// Default constructor
73 //______________________________________________________________________________
74 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
78 // Add deleting rotation matrices
90 //______________________________________________________________________________
92 AliMUONGeometryEnvelopeStore::ConvertDETransform(const TGeoHMatrix& transform) const
94 /// Convert transformation into the reference frame
96 if ( fReferenceFrame.IsIdentity() )
99 return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(),
104 //______________________________________________________________________________
105 AliMUONGeometryEnvelope*
106 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
108 /// Find the envelope specified by name.
110 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
111 AliMUONGeometryEnvelope* envelope
112 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
114 if (envelope->GetName() == name) return envelope;
120 //______________________________________________________________________________
121 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
122 AliMUONGeometryEnvelope* envelope) const
124 /// Find transformation by the detection element Id (if not 0)
125 /// (= unique ID of enevelope) and set it to the envelope.
126 /// Return true if transformation is applied, false otherwise.
128 Int_t detElemId = envelope->GetUniqueID();
129 if (detElemId == 0) return false;
131 AliMUONGeometryDetElement* detElement
132 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
134 AliWarning("Transformation not found.");
138 // Apply frame transform
139 TGeoHMatrix newTransform
140 = ConvertDETransform(*(detElement->GetLocalTransformation()));
142 envelope->SetTransform(newTransform);
151 //______________________________________________________________________________
152 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
157 /// Add the volume with the specified name and transformation
158 /// to the list of envelopes.
160 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
161 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
163 AliMUONGeometryEnvelope* envelope
164 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
166 if (fAlign) AlignEnvelope(envelope);
168 fEnvelopes->Add(envelope);
171 //______________________________________________________________________________
172 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
175 const TGeoTranslation& translation,
178 /// Add the volume with the specified name and transformation
179 /// to the list of envelopes.
182 cout << "... Adding ";
183 if (!isVirtual) cout << " non-";
184 cout << "virtual envelope " << name
186 << " with translation" << endl;
189 AliMUONGeometryEnvelope* envelope
190 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
192 Bool_t aligned = false;
193 if (fAlign) aligned = AlignEnvelope(envelope);
196 envelope->SetTranslation(translation);
198 fEnvelopes->Add(envelope);
201 //______________________________________________________________________________
202 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
205 const TGeoTranslation& translation,
206 const TGeoRotation& rotation,
209 /// Add the volume with the specified name and transformation
210 /// to the list of envelopes.
213 cout << "... Adding ";
214 if (!isVirtual) cout << " non-";
215 cout << "virtual envelope " << name
217 << " with translation and rotation" << endl;
221 cout << "Adding env... name: " << name;
223 const Double_t* xyz = translation.GetTranslation();
224 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
227 Double_t a1, a2, a3, a4, a5, a6;
228 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
229 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
231 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
232 // would be nice to be so simple
234 AliMUONGeometryEnvelope* envelope
235 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
237 Bool_t aligned = false;
238 if (fAlign) aligned = AlignEnvelope(envelope);
241 envelope->SetRotation(rotation);
242 envelope->SetTranslation(translation);
245 fEnvelopes->Add(envelope);
248 //______________________________________________________________________________
249 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
252 const TGeoCombiTrans& transform,
255 /// Add the volume with the specified name and transformation
256 /// to the list of envelopes.
259 cout << "... Adding ";
260 if (!isVirtual) cout << " non-";
261 cout << "virtual envelope " << name
263 << " with transformation" << endl;
266 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
267 // would be nice to be so simple
269 AliMUONGeometryEnvelope* envelope
270 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
272 Bool_t aligned = false;
273 if (fAlign) aligned = AlignEnvelope(envelope);
276 envelope->SetTransform(transform);
278 fEnvelopes->Add(envelope);
281 //______________________________________________________________________________
282 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
287 /// Add the volume with the specified name and transformation
288 /// to the list of envelopes.
291 cout << "... Adding "
292 << " non-virtual envelope " << name
294 << " with copyNo " << copyNo << endl;
297 AliMUONGeometryEnvelope* envelope
298 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
300 if (fAlign) AlignEnvelope(envelope);
302 fEnvelopes->Add(envelope);
305 //______________________________________________________________________________
306 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
309 const TGeoTranslation& translation,
312 /// Add the volume with the specified name and transformation
313 /// to the list of envelopes.
316 cout << "... Adding "
317 << " non-virtual envelope " << name
319 << " with copyNo " << copyNo
320 << " with translation " << endl;
323 AliMUONGeometryEnvelope* envelope
324 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
326 Bool_t aligned = false;
327 if (fAlign) aligned = AlignEnvelope(envelope);
330 envelope->SetTranslation(translation);
332 fEnvelopes->Add(envelope);
335 //______________________________________________________________________________
336 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
339 const TGeoTranslation& translation,
340 const TGeoRotation& rotation,
343 /// Add the volume with the specified name and transformation
344 /// to the list of envelopes.
347 cout << "... Adding "
348 << " non-virtual envelope " << name
350 << " with copyNo " << copyNo
351 << " with translation and rotation" << endl;
354 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
355 // would be nice to be so simple
357 AliMUONGeometryEnvelope* envelope
358 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
360 Bool_t aligned = false;
361 if (fAlign) aligned = AlignEnvelope(envelope);
364 envelope->SetRotation(rotation);
365 envelope->SetTranslation(translation);
368 fEnvelopes->Add(envelope);
371 //______________________________________________________________________________
372 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
375 const TGeoCombiTrans& transform,
378 /// Add the volume with the specified name and transformation
379 /// to the list of envelopes.
382 cout << "... Adding "
383 << " non-virtual envelope " << name
385 << " with copyNo " << copyNo
386 << " with translation and rotation" << endl;
389 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
390 // would be nice to be so simple
392 AliMUONGeometryEnvelope* envelope
393 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
395 Bool_t aligned = false;
396 if (fAlign) aligned = AlignEnvelope(envelope);
399 envelope->SetTransform(transform);
401 fEnvelopes->Add(envelope);
404 //______________________________________________________________________________
405 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
406 const TString& envName, Int_t copyNo)
408 /// Add the volume with the specified name and transformation
409 /// as a constituent of the envelope envName.
412 cout << "... Adding constituent " << name
413 << " to envelope " << envName
414 << " with copyNo " << copyNo << endl;
417 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
424 envelope->AddConstituent(name, copyNo);
427 //______________________________________________________________________________
428 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
429 const TString& envName, Int_t copyNo,
430 const TGeoTranslation& translation)
432 /// Add the volume with the specified name and transformation
433 /// as a constituent of the envelope envName.
436 cout << "... Adding constituent " << name
437 << " to envelope " << envName
438 << " with copyNo " << copyNo
439 << " with translation" << endl;
442 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
449 envelope->AddConstituent(name, copyNo, translation);
452 //______________________________________________________________________________
453 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
454 const TString& envName, Int_t copyNo,
455 const TGeoTranslation& translation,
456 const TGeoRotation& rotation)
458 /// Add the volume with the specified name and transformation
459 /// as a constituent of the envelope envName.
462 cout << "... Adding constituent " << name
463 << " to envelope " << envName
464 << " with copyNo " << copyNo
465 << " with translation and rotation" << endl;
468 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
475 envelope->AddConstituent(name, copyNo, translation, rotation);
478 //______________________________________________________________________________
479 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
480 const TString& envName, Int_t copyNo,
481 const TGeoCombiTrans& transform)
483 /// Add the volume with the specified name and transformation
484 /// as a constituent of the envelope envName.
487 cout << "... Adding constituent " << name
488 << " to envelope " << envName
489 << " with copyNo " << copyNo
490 << " with translation and rotation" << endl;
493 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
500 envelope->AddConstituent(name, copyNo, transform);
503 //______________________________________________________________________________
504 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
505 const TString& envName, Int_t copyNo,
506 Int_t npar, Double_t* param)
508 /// Add the volume with the specified name and transformation
509 /// as a constituent of the envelope envName.
512 cout << "... Adding parameterised constituent " << name
513 << " to envelope " << envName
514 << " with copyNo " << copyNo << endl;
517 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
524 envelope->AddConstituentParam(name, copyNo, npar, param);
527 //______________________________________________________________________________
528 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
529 const TString& envName, Int_t copyNo,
530 const TGeoTranslation& translation,
531 Int_t npar, Double_t* param)
533 /// Add the volume with the specified name and transformation
534 /// as a constituent of the envelope envName.
537 cout << "... Adding parameterised constituent " << name
538 << " to envelope " << envName
539 << " with copyNo " << copyNo
540 << " with translation" << endl;
543 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
550 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
553 //______________________________________________________________________________
554 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
555 const TString& envName, Int_t copyNo,
556 const TGeoTranslation& translation,
557 const TGeoRotation& rotation,
558 Int_t npar, Double_t* param)
560 /// Add the volume with the specified name and transformation
561 /// as a constituent of the envelope envName.
564 cout << "... Adding parameterised constituent " << name
565 << " to envelope " << envName
566 << " with copyNo " << copyNo
567 << " with translation and rotation" << endl;
570 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
577 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
580 //______________________________________________________________________________
581 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
582 const TString& envName, Int_t copyNo,
583 const TGeoCombiTrans& transform,
584 Int_t npar, Double_t* param)
586 /// Add the volume with the specified name and transformation
587 /// as a constituent of the envelope envName.
590 cout << "... Adding parameterised constituent " << name
591 << " to envelope " << envName
592 << " with copyNo " << copyNo
593 << " with translation and rotation" << endl;
596 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
603 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
606 //______________________________________________________________________________
607 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
609 /// Return the number od envelopes with detElemId>0.
611 Int_t nofDetElems = 0;
613 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
614 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;