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 "AliMUONConstants.h"
38 ClassImp(AliMUONGeometryEnvelopeStore)
40 //______________________________________________________________________________
41 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
42 AliMUONGeometryStore* detElements)
45 fDetElements(detElements),
49 /// Standard constructor
51 fEnvelopes = new TObjArray(100);
55 //______________________________________________________________________________
56 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
63 /// Default constructor
67 //______________________________________________________________________________
68 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(const AliMUONGeometryEnvelopeStore& rhs)
71 AliFatal("Copy constructor is not implemented.");
74 //______________________________________________________________________________
75 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
79 // Add deleting rotation matrices
87 //______________________________________________________________________________
88 AliMUONGeometryEnvelopeStore&
89 AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rhs)
91 /// Protected assignement operator
93 // check assignement to self
94 if (this == &rhs) return *this;
96 AliFatal("Assignment operator is not implemented.");
105 //______________________________________________________________________________
106 AliMUONGeometryEnvelope*
107 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
109 /// Find the envelope specified by name.
111 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
112 AliMUONGeometryEnvelope* envelope
113 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
115 if (envelope->GetName() == name) return envelope;
121 //______________________________________________________________________________
122 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
123 AliMUONGeometryEnvelope* envelope) const
125 /// Find transformation by the detection element Id (if not 0)
126 /// (= unique ID of enevelope) and set it to the envelope.
127 /// Return true if transformation is applied, false otherwise.
129 Int_t detElemId = envelope->GetUniqueID();
130 if (detElemId == 0) return false;
132 AliMUONGeometryDetElement* detElement
133 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId);
135 AliWarning("Transformation not found.");
139 envelope->SetTransform(*(detElement->GetLocalTransformation()));
147 //______________________________________________________________________________
148 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
153 /// Add the volume with the specified name and transformation
154 /// to the list of envelopes.
156 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
157 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
159 AliMUONGeometryEnvelope* envelope
160 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
162 if (fAlign) AlignEnvelope(envelope);
164 fEnvelopes->Add(envelope);
167 //______________________________________________________________________________
168 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
171 const TGeoTranslation& translation,
174 /// Add the volume with the specified name and transformation
175 /// to the list of envelopes.
178 cout << "... Adding ";
179 if (!isVirtual) cout << " non-";
180 cout << "virtual envelope " << name
182 << " with translation" << endl;
185 AliMUONGeometryEnvelope* envelope
186 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
188 Bool_t aligned = false;
189 if (fAlign) aligned = AlignEnvelope(envelope);
192 envelope->SetTranslation(translation);
194 fEnvelopes->Add(envelope);
197 //______________________________________________________________________________
198 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
201 const TGeoTranslation& translation,
202 const TGeoRotation& rotation,
205 /// Add the volume with the specified name and transformation
206 /// to the list of envelopes.
209 cout << "... Adding ";
210 if (!isVirtual) cout << " non-";
211 cout << "virtual envelope " << name
213 << " with translation and rotation" << endl;
217 cout << "Adding env... name: " << name;
219 const Double_t* xyz = translation.GetTranslation();
220 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
223 Double_t a1, a2, a3, a4, a5, a6;
224 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
225 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
227 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
228 // would be nice to be so simple
230 AliMUONGeometryEnvelope* envelope
231 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
233 Bool_t aligned = false;
234 if (fAlign) aligned = AlignEnvelope(envelope);
237 envelope->SetRotation(rotation);
238 envelope->SetTranslation(translation);
241 fEnvelopes->Add(envelope);
244 //______________________________________________________________________________
245 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
248 const TGeoCombiTrans& transform,
251 /// Add the volume with the specified name and transformation
252 /// to the list of envelopes.
255 cout << "... Adding ";
256 if (!isVirtual) cout << " non-";
257 cout << "virtual envelope " << name
259 << " with transformation" << endl;
262 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
263 // would be nice to be so simple
265 AliMUONGeometryEnvelope* envelope
266 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
268 Bool_t aligned = false;
269 if (fAlign) aligned = AlignEnvelope(envelope);
272 envelope->SetTransform(transform);
274 fEnvelopes->Add(envelope);
277 //______________________________________________________________________________
278 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
283 /// Add the volume with the specified name and transformation
284 /// to the list of envelopes.
287 cout << "... Adding "
288 << " non-virtual envelope " << name
290 << " with copyNo " << copyNo << endl;
293 AliMUONGeometryEnvelope* envelope
294 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
296 if (fAlign) AlignEnvelope(envelope);
298 fEnvelopes->Add(envelope);
301 //______________________________________________________________________________
302 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
305 const TGeoTranslation& translation,
308 /// Add the volume with the specified name and transformation
309 /// to the list of envelopes.
312 cout << "... Adding "
313 << " non-virtual envelope " << name
315 << " with copyNo " << copyNo
316 << " with translation " << endl;
319 AliMUONGeometryEnvelope* envelope
320 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
322 Bool_t aligned = false;
323 if (fAlign) aligned = AlignEnvelope(envelope);
326 envelope->SetTranslation(translation);
328 fEnvelopes->Add(envelope);
331 //______________________________________________________________________________
332 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
335 const TGeoTranslation& translation,
336 const TGeoRotation& rotation,
339 /// Add the volume with the specified name and transformation
340 /// to the list of envelopes.
343 cout << "... Adding "
344 << " non-virtual envelope " << name
346 << " with copyNo " << copyNo
347 << " with translation and rotation" << endl;
350 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
351 // would be nice to be so simple
353 AliMUONGeometryEnvelope* envelope
354 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
356 Bool_t aligned = false;
357 if (fAlign) aligned = AlignEnvelope(envelope);
360 envelope->SetRotation(rotation);
361 envelope->SetTranslation(translation);
364 fEnvelopes->Add(envelope);
367 //______________________________________________________________________________
368 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
371 const TGeoCombiTrans& transform,
374 /// Add the volume with the specified name and transformation
375 /// to the list of envelopes.
378 cout << "... Adding "
379 << " non-virtual envelope " << name
381 << " with copyNo " << copyNo
382 << " with translation and rotation" << endl;
385 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
386 // would be nice to be so simple
388 AliMUONGeometryEnvelope* envelope
389 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
391 Bool_t aligned = false;
392 if (fAlign) aligned = AlignEnvelope(envelope);
395 envelope->SetTransform(transform);
397 fEnvelopes->Add(envelope);
400 //______________________________________________________________________________
401 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
402 const TString& envName, Int_t copyNo)
404 /// Add the volume with the specified name and transformation
405 /// to the list of envelopes.
408 cout << "... Adding constituent " << name
409 << " to envelope " << envName
410 << " with copyNo " << copyNo << endl;
413 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
420 envelope->AddConstituent(name, copyNo);
423 //______________________________________________________________________________
424 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
425 const TString& envName, Int_t copyNo,
426 const TGeoTranslation& translation)
428 /// Add the volume with the specified name and transformation
429 /// to the list of envelopes.
432 cout << "... Adding constituent " << name
433 << " to envelope " << envName
434 << " with copyNo " << copyNo
435 << " with translation" << endl;
438 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
445 envelope->AddConstituent(name, copyNo, translation);
448 //______________________________________________________________________________
449 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
450 const TString& envName, Int_t copyNo,
451 const TGeoTranslation& translation,
452 const TGeoRotation& rotation)
454 /// Add the volume with the specified name and transformation
455 /// to the list of envelopes.
458 cout << "... Adding constituent " << name
459 << " to envelope " << envName
460 << " with copyNo " << copyNo
461 << " with translation and rotation" << endl;
464 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
471 envelope->AddConstituent(name, copyNo, translation, rotation);
474 //______________________________________________________________________________
475 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
476 const TString& envName, Int_t copyNo,
477 const TGeoCombiTrans& transform)
479 /// Add the volume with the specified name and transformation
480 /// to the list of envelopes.
483 cout << "... Adding constituent " << name
484 << " to envelope " << envName
485 << " with copyNo " << copyNo
486 << " with translation and rotation" << endl;
489 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
496 envelope->AddConstituent(name, copyNo, transform);
499 //______________________________________________________________________________
500 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
501 const TString& envName, Int_t copyNo,
502 Int_t npar, Double_t* param)
504 /// Add the volume with the specified name and transformation
505 /// to the list of envelopes.
508 cout << "... Adding parameterised constituent " << name
509 << " to envelope " << envName
510 << " with copyNo " << copyNo << endl;
513 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
520 envelope->AddConstituentParam(name, copyNo, npar, param);
523 //______________________________________________________________________________
524 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
525 const TString& envName, Int_t copyNo,
526 const TGeoTranslation& translation,
527 Int_t npar, Double_t* param)
529 /// Add the volume with the specified name and transformation
530 /// to the list of envelopes.
533 cout << "... Adding parameterised constituent " << name
534 << " to envelope " << envName
535 << " with copyNo " << copyNo
536 << " with translation" << endl;
539 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
546 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
549 //______________________________________________________________________________
550 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
551 const TString& envName, Int_t copyNo,
552 const TGeoTranslation& translation,
553 const TGeoRotation& rotation,
554 Int_t npar, Double_t* param)
556 /// Add the volume with the specified name and transformation
557 /// to the list of envelopes.
560 cout << "... Adding parameterised constituent " << name
561 << " to envelope " << envName
562 << " with copyNo " << copyNo
563 << " with translation and rotation" << endl;
566 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
573 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
576 //______________________________________________________________________________
577 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
578 const TString& envName, Int_t copyNo,
579 const TGeoCombiTrans& transform,
580 Int_t npar, Double_t* param)
582 /// Add the volume with the specified name and transformation
583 /// to the list of envelopes.
586 cout << "... Adding parameterised constituent " << name
587 << " to envelope " << envName
588 << " with copyNo " << copyNo
589 << " with translation and rotation" << endl;
592 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
599 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
602 //______________________________________________________________________________
603 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
605 /// Return the number od envelopes with detElemId>0.
607 Int_t nofDetElems = 0;
609 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
610 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;