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 "AliMUONGeometryBuilder.h"
38 ClassImp(AliMUONGeometryEnvelopeStore)
40 //______________________________________________________________________________
41 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
42 AliMUONGeometryStore* detElements)
45 fDetElements(detElements),
50 /// Standard constructor
52 fEnvelopes = new TObjArray(100);
56 //______________________________________________________________________________
57 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
65 /// Default constructor
69 //______________________________________________________________________________
70 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(const AliMUONGeometryEnvelopeStore& rhs)
73 AliFatal("Copy constructor is not implemented.");
76 //______________________________________________________________________________
77 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
81 // Add deleting rotation matrices
89 //______________________________________________________________________________
90 AliMUONGeometryEnvelopeStore&
91 AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rhs)
93 /// Protected assignement operator
95 // check assignement to self
96 if (this == &rhs) return *this;
98 AliFatal("Assignment operator is not implemented.");
107 //______________________________________________________________________________
109 AliMUONGeometryEnvelopeStore::ConvertDETransform(const TGeoHMatrix& transform) const
111 // Convert transformation into the reference frame
113 if ( fReferenceFrame.IsIdentity() )
116 return AliMUONGeometryBuilder::Multiply( fReferenceFrame.Inverse(),
121 //______________________________________________________________________________
122 AliMUONGeometryEnvelope*
123 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
125 /// Find the envelope specified by name.
127 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
128 AliMUONGeometryEnvelope* envelope
129 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
131 if (envelope->GetName() == name) return envelope;
137 //______________________________________________________________________________
138 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
139 AliMUONGeometryEnvelope* envelope) const
141 /// Find transformation by the detection element Id (if not 0)
142 /// (= unique ID of enevelope) and set it to the envelope.
143 /// Return true if transformation is applied, false otherwise.
145 Int_t detElemId = envelope->GetUniqueID();
146 if (detElemId == 0) return false;
148 AliMUONGeometryDetElement* detElement
149 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
151 AliWarning("Transformation not found.");
155 // Apply frame transform
156 TGeoHMatrix newTransform
157 = ConvertDETransform(*(detElement->GetLocalTransformation()));
159 envelope->SetTransform(newTransform);
168 //______________________________________________________________________________
169 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
174 /// Add the volume with the specified name and transformation
175 /// to the list of envelopes.
177 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
178 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
180 AliMUONGeometryEnvelope* envelope
181 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
183 if (fAlign) AlignEnvelope(envelope);
185 fEnvelopes->Add(envelope);
188 //______________________________________________________________________________
189 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
192 const TGeoTranslation& translation,
195 /// Add the volume with the specified name and transformation
196 /// to the list of envelopes.
199 cout << "... Adding ";
200 if (!isVirtual) cout << " non-";
201 cout << "virtual envelope " << name
203 << " with translation" << endl;
206 AliMUONGeometryEnvelope* envelope
207 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
209 Bool_t aligned = false;
210 if (fAlign) aligned = AlignEnvelope(envelope);
213 envelope->SetTranslation(translation);
215 fEnvelopes->Add(envelope);
218 //______________________________________________________________________________
219 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
222 const TGeoTranslation& translation,
223 const TGeoRotation& rotation,
226 /// Add the volume with the specified name and transformation
227 /// to the list of envelopes.
230 cout << "... Adding ";
231 if (!isVirtual) cout << " non-";
232 cout << "virtual envelope " << name
234 << " with translation and rotation" << endl;
238 cout << "Adding env... name: " << name;
240 const Double_t* xyz = translation.GetTranslation();
241 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
244 Double_t a1, a2, a3, a4, a5, a6;
245 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
246 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
248 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
249 // would be nice to be so simple
251 AliMUONGeometryEnvelope* envelope
252 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
254 Bool_t aligned = false;
255 if (fAlign) aligned = AlignEnvelope(envelope);
258 envelope->SetRotation(rotation);
259 envelope->SetTranslation(translation);
262 fEnvelopes->Add(envelope);
265 //______________________________________________________________________________
266 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
269 const TGeoCombiTrans& transform,
272 /// Add the volume with the specified name and transformation
273 /// to the list of envelopes.
276 cout << "... Adding ";
277 if (!isVirtual) cout << " non-";
278 cout << "virtual envelope " << name
280 << " with transformation" << endl;
283 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
284 // would be nice to be so simple
286 AliMUONGeometryEnvelope* envelope
287 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
289 Bool_t aligned = false;
290 if (fAlign) aligned = AlignEnvelope(envelope);
293 envelope->SetTransform(transform);
295 fEnvelopes->Add(envelope);
298 //______________________________________________________________________________
299 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
304 /// Add the volume with the specified name and transformation
305 /// to the list of envelopes.
308 cout << "... Adding "
309 << " non-virtual envelope " << name
311 << " with copyNo " << copyNo << endl;
314 AliMUONGeometryEnvelope* envelope
315 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
317 if (fAlign) AlignEnvelope(envelope);
319 fEnvelopes->Add(envelope);
322 //______________________________________________________________________________
323 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
326 const TGeoTranslation& translation,
329 /// Add the volume with the specified name and transformation
330 /// to the list of envelopes.
333 cout << "... Adding "
334 << " non-virtual envelope " << name
336 << " with copyNo " << copyNo
337 << " with translation " << endl;
340 AliMUONGeometryEnvelope* envelope
341 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
343 Bool_t aligned = false;
344 if (fAlign) aligned = AlignEnvelope(envelope);
347 envelope->SetTranslation(translation);
349 fEnvelopes->Add(envelope);
352 //______________________________________________________________________________
353 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
356 const TGeoTranslation& translation,
357 const TGeoRotation& rotation,
360 /// Add the volume with the specified name and transformation
361 /// to the list of envelopes.
364 cout << "... Adding "
365 << " non-virtual envelope " << name
367 << " with copyNo " << copyNo
368 << " with translation and rotation" << endl;
371 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
372 // would be nice to be so simple
374 AliMUONGeometryEnvelope* envelope
375 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
377 Bool_t aligned = false;
378 if (fAlign) aligned = AlignEnvelope(envelope);
381 envelope->SetRotation(rotation);
382 envelope->SetTranslation(translation);
385 fEnvelopes->Add(envelope);
388 //______________________________________________________________________________
389 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
392 const TGeoCombiTrans& transform,
395 /// Add the volume with the specified name and transformation
396 /// to the list of envelopes.
399 cout << "... Adding "
400 << " non-virtual envelope " << name
402 << " with copyNo " << copyNo
403 << " with translation and rotation" << endl;
406 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
407 // would be nice to be so simple
409 AliMUONGeometryEnvelope* envelope
410 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
412 Bool_t aligned = false;
413 if (fAlign) aligned = AlignEnvelope(envelope);
416 envelope->SetTransform(transform);
418 fEnvelopes->Add(envelope);
421 //______________________________________________________________________________
422 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
423 const TString& envName, Int_t copyNo)
425 /// Add the volume with the specified name and transformation
426 /// to the list of envelopes.
429 cout << "... Adding constituent " << name
430 << " to envelope " << envName
431 << " with copyNo " << copyNo << endl;
434 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
441 envelope->AddConstituent(name, copyNo);
444 //______________________________________________________________________________
445 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
446 const TString& envName, Int_t copyNo,
447 const TGeoTranslation& translation)
449 /// Add the volume with the specified name and transformation
450 /// to the list of envelopes.
453 cout << "... Adding constituent " << name
454 << " to envelope " << envName
455 << " with copyNo " << copyNo
456 << " with translation" << endl;
459 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
466 envelope->AddConstituent(name, copyNo, translation);
469 //______________________________________________________________________________
470 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
471 const TString& envName, Int_t copyNo,
472 const TGeoTranslation& translation,
473 const TGeoRotation& rotation)
475 /// Add the volume with the specified name and transformation
476 /// to the list of envelopes.
479 cout << "... Adding constituent " << name
480 << " to envelope " << envName
481 << " with copyNo " << copyNo
482 << " with translation and rotation" << endl;
485 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
492 envelope->AddConstituent(name, copyNo, translation, rotation);
495 //______________________________________________________________________________
496 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
497 const TString& envName, Int_t copyNo,
498 const TGeoCombiTrans& transform)
500 /// Add the volume with the specified name and transformation
501 /// to the list of envelopes.
504 cout << "... Adding constituent " << name
505 << " to envelope " << envName
506 << " with copyNo " << copyNo
507 << " with translation and rotation" << endl;
510 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
517 envelope->AddConstituent(name, copyNo, transform);
520 //______________________________________________________________________________
521 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
522 const TString& envName, Int_t copyNo,
523 Int_t npar, Double_t* param)
525 /// Add the volume with the specified name and transformation
526 /// to the list of envelopes.
529 cout << "... Adding parameterised constituent " << name
530 << " to envelope " << envName
531 << " with copyNo " << copyNo << endl;
534 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
541 envelope->AddConstituentParam(name, copyNo, npar, param);
544 //______________________________________________________________________________
545 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
546 const TString& envName, Int_t copyNo,
547 const TGeoTranslation& translation,
548 Int_t npar, Double_t* param)
550 /// Add the volume with the specified name and transformation
551 /// to the list of envelopes.
554 cout << "... Adding parameterised constituent " << name
555 << " to envelope " << envName
556 << " with copyNo " << copyNo
557 << " with translation" << endl;
560 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
567 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
570 //______________________________________________________________________________
571 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
572 const TString& envName, Int_t copyNo,
573 const TGeoTranslation& translation,
574 const TGeoRotation& rotation,
575 Int_t npar, Double_t* param)
577 /// Add the volume with the specified name and transformation
578 /// to the list of envelopes.
581 cout << "... Adding parameterised constituent " << name
582 << " to envelope " << envName
583 << " with copyNo " << copyNo
584 << " with translation and rotation" << endl;
587 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
594 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
597 //______________________________________________________________________________
598 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
599 const TString& envName, Int_t copyNo,
600 const TGeoCombiTrans& transform,
601 Int_t npar, Double_t* param)
603 /// Add the volume with the specified name and transformation
604 /// to the list of envelopes.
607 cout << "... Adding parameterised constituent " << name
608 << " to envelope " << envName
609 << " with copyNo " << copyNo
610 << " with translation and rotation" << endl;
613 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
620 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
623 //______________________________________________________________________________
624 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
626 /// Return the number od envelopes with detElemId>0.
628 Int_t nofDetElems = 0;
630 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
631 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;