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 "AliMUONGeometryBuilder.h"
30 #include "AliMpExMap.h"
34 #include <TGeoMatrix.h>
35 #include <TObjArray.h>
36 #include <Riostream.h>
40 ClassImp(AliMUONGeometryEnvelopeStore)
43 //______________________________________________________________________________
44 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
45 AliMpExMap* detElements)
48 fDetElements(detElements),
53 /// Standard constructor
55 fEnvelopes = new TObjArray(100);
59 //______________________________________________________________________________
60 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
68 /// Default constructor
72 //______________________________________________________________________________
73 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
77 // Add deleting rotation matrices
89 //______________________________________________________________________________
91 AliMUONGeometryEnvelopeStore::ConvertDETransform(const TGeoHMatrix& transform) const
93 /// Convert transformation into the reference frame
95 if ( fReferenceFrame.IsIdentity() )
98 return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(),
103 //______________________________________________________________________________
104 AliMUONGeometryEnvelope*
105 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
107 /// Find the envelope specified by name.
109 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
110 AliMUONGeometryEnvelope* envelope
111 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
113 if (envelope->GetName() == name) return envelope;
119 //______________________________________________________________________________
120 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
121 AliMUONGeometryEnvelope* envelope) const
123 /// Find transformation by the detection element Id (if not 0)
124 /// (= unique ID of enevelope) and set it to the envelope.
125 /// Return true if transformation is applied, false otherwise.
127 Int_t detElemId = envelope->GetUniqueID();
128 if (detElemId == 0) return false;
130 AliMUONGeometryDetElement* detElement
131 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
133 AliWarning("Transformation not found.");
137 // Apply frame transform
138 TGeoHMatrix newTransform
139 = ConvertDETransform(*(detElement->GetLocalTransformation()));
141 envelope->SetTransform(newTransform);
150 //______________________________________________________________________________
151 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
156 /// Add the volume with the specified name and transformation
157 /// to the list of envelopes.
159 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
160 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
162 AliMUONGeometryEnvelope* envelope
163 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
165 if (fAlign) AlignEnvelope(envelope);
167 fEnvelopes->Add(envelope);
170 //______________________________________________________________________________
171 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
174 const TGeoTranslation& translation,
177 /// Add the volume with the specified name and transformation
178 /// to the list of envelopes.
181 cout << "... Adding ";
182 if (!isVirtual) cout << " non-";
183 cout << "virtual envelope " << name
185 << " with translation" << endl;
188 AliMUONGeometryEnvelope* envelope
189 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
191 Bool_t aligned = false;
192 if (fAlign) aligned = AlignEnvelope(envelope);
195 envelope->SetTranslation(translation);
197 fEnvelopes->Add(envelope);
200 //______________________________________________________________________________
201 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
204 const TGeoTranslation& translation,
205 const TGeoRotation& rotation,
208 /// Add the volume with the specified name and transformation
209 /// to the list of envelopes.
212 cout << "... Adding ";
213 if (!isVirtual) cout << " non-";
214 cout << "virtual envelope " << name
216 << " with translation and rotation" << endl;
220 cout << "Adding env... name: " << name;
222 const Double_t* xyz = translation.GetTranslation();
223 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
226 Double_t a1, a2, a3, a4, a5, a6;
227 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
228 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
230 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
231 // would be nice to be so simple
233 AliMUONGeometryEnvelope* envelope
234 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
236 Bool_t aligned = false;
237 if (fAlign) aligned = AlignEnvelope(envelope);
240 envelope->SetRotation(rotation);
241 envelope->SetTranslation(translation);
244 fEnvelopes->Add(envelope);
247 //______________________________________________________________________________
248 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
251 const TGeoCombiTrans& transform,
254 /// Add the volume with the specified name and transformation
255 /// to the list of envelopes.
258 cout << "... Adding ";
259 if (!isVirtual) cout << " non-";
260 cout << "virtual envelope " << name
262 << " with transformation" << endl;
265 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
266 // would be nice to be so simple
268 AliMUONGeometryEnvelope* envelope
269 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
271 Bool_t aligned = false;
272 if (fAlign) aligned = AlignEnvelope(envelope);
275 envelope->SetTransform(transform);
277 fEnvelopes->Add(envelope);
280 //______________________________________________________________________________
281 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
286 /// Add the volume with the specified name and transformation
287 /// to the list of envelopes.
290 cout << "... Adding "
291 << " non-virtual envelope " << name
293 << " with copyNo " << copyNo << endl;
296 AliMUONGeometryEnvelope* envelope
297 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
299 if (fAlign) AlignEnvelope(envelope);
301 fEnvelopes->Add(envelope);
304 //______________________________________________________________________________
305 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
308 const TGeoTranslation& translation,
311 /// Add the volume with the specified name and transformation
312 /// to the list of envelopes.
315 cout << "... Adding "
316 << " non-virtual envelope " << name
318 << " with copyNo " << copyNo
319 << " with translation " << endl;
322 AliMUONGeometryEnvelope* envelope
323 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
325 Bool_t aligned = false;
326 if (fAlign) aligned = AlignEnvelope(envelope);
329 envelope->SetTranslation(translation);
331 fEnvelopes->Add(envelope);
334 //______________________________________________________________________________
335 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
338 const TGeoTranslation& translation,
339 const TGeoRotation& rotation,
342 /// Add the volume with the specified name and transformation
343 /// to the list of envelopes.
346 cout << "... Adding "
347 << " non-virtual envelope " << name
349 << " with copyNo " << copyNo
350 << " with translation and rotation" << endl;
353 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
354 // would be nice to be so simple
356 AliMUONGeometryEnvelope* envelope
357 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
359 Bool_t aligned = false;
360 if (fAlign) aligned = AlignEnvelope(envelope);
363 envelope->SetRotation(rotation);
364 envelope->SetTranslation(translation);
367 fEnvelopes->Add(envelope);
370 //______________________________________________________________________________
371 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
374 const TGeoCombiTrans& transform,
377 /// Add the volume with the specified name and transformation
378 /// to the list of envelopes.
381 cout << "... Adding "
382 << " non-virtual envelope " << name
384 << " with copyNo " << copyNo
385 << " with translation and rotation" << endl;
388 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
389 // would be nice to be so simple
391 AliMUONGeometryEnvelope* envelope
392 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
394 Bool_t aligned = false;
395 if (fAlign) aligned = AlignEnvelope(envelope);
398 envelope->SetTransform(transform);
400 fEnvelopes->Add(envelope);
403 //______________________________________________________________________________
404 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
405 const TString& envName, Int_t copyNo)
407 /// Add the volume with the specified name and transformation
408 /// as a constituent of the envelope envName.
411 cout << "... Adding constituent " << name
412 << " to envelope " << envName
413 << " with copyNo " << copyNo << endl;
416 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
423 envelope->AddConstituent(name, copyNo);
426 //______________________________________________________________________________
427 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
428 const TString& envName, Int_t copyNo,
429 const TGeoTranslation& translation)
431 /// Add the volume with the specified name and transformation
432 /// as a constituent of the envelope envName.
435 cout << "... Adding constituent " << name
436 << " to envelope " << envName
437 << " with copyNo " << copyNo
438 << " with translation" << endl;
441 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
448 envelope->AddConstituent(name, copyNo, translation);
451 //______________________________________________________________________________
452 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
453 const TString& envName, Int_t copyNo,
454 const TGeoTranslation& translation,
455 const TGeoRotation& rotation)
457 /// Add the volume with the specified name and transformation
458 /// as a constituent of the envelope envName.
461 cout << "... Adding constituent " << name
462 << " to envelope " << envName
463 << " with copyNo " << copyNo
464 << " with translation and rotation" << endl;
467 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
474 envelope->AddConstituent(name, copyNo, translation, rotation);
477 //______________________________________________________________________________
478 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
479 const TString& envName, Int_t copyNo,
480 const TGeoCombiTrans& transform)
482 /// Add the volume with the specified name and transformation
483 /// as a constituent of the envelope envName.
486 cout << "... Adding constituent " << name
487 << " to envelope " << envName
488 << " with copyNo " << copyNo
489 << " with translation and rotation" << endl;
492 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
499 envelope->AddConstituent(name, copyNo, transform);
502 //______________________________________________________________________________
503 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
504 const TString& envName, Int_t copyNo,
505 Int_t npar, Double_t* param)
507 /// Add the volume with the specified name and transformation
508 /// as a constituent of the envelope envName.
511 cout << "... Adding parameterised constituent " << name
512 << " to envelope " << envName
513 << " with copyNo " << copyNo << endl;
516 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
523 envelope->AddConstituentParam(name, copyNo, npar, param);
526 //______________________________________________________________________________
527 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
528 const TString& envName, Int_t copyNo,
529 const TGeoTranslation& translation,
530 Int_t npar, Double_t* param)
532 /// Add the volume with the specified name and transformation
533 /// as a constituent of the envelope envName.
536 cout << "... Adding parameterised constituent " << name
537 << " to envelope " << envName
538 << " with copyNo " << copyNo
539 << " with translation" << endl;
542 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
549 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
552 //______________________________________________________________________________
553 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
554 const TString& envName, Int_t copyNo,
555 const TGeoTranslation& translation,
556 const TGeoRotation& rotation,
557 Int_t npar, Double_t* param)
559 /// Add the volume with the specified name and transformation
560 /// as a constituent of the envelope envName.
563 cout << "... Adding parameterised constituent " << name
564 << " to envelope " << envName
565 << " with copyNo " << copyNo
566 << " with translation and rotation" << endl;
569 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
576 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
579 //______________________________________________________________________________
580 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
581 const TString& envName, Int_t copyNo,
582 const TGeoCombiTrans& transform,
583 Int_t npar, Double_t* param)
585 /// Add the volume with the specified name and transformation
586 /// as a constituent of the envelope envName.
589 cout << "... Adding parameterised constituent " << name
590 << " to envelope " << envName
591 << " with copyNo " << copyNo
592 << " with translation and rotation" << endl;
595 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
602 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
605 //______________________________________________________________________________
606 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
608 /// Return the number od envelopes with detElemId>0.
610 Int_t nofDetElems = 0;
612 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
613 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;