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 // check assignement to self
92 if (this == &rhs) return *this;
94 AliFatal("Assignment operator is not implemented.");
103 //______________________________________________________________________________
104 AliMUONGeometryEnvelope*
105 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
107 // Finds 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.
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 // Adds the volume with the specified name and transformation
154 // to the list of envelopes.
157 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
158 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
160 AliMUONGeometryEnvelope* envelope
161 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
163 if (fAlign) AlignEnvelope(envelope);
165 fEnvelopes->Add(envelope);
168 //______________________________________________________________________________
169 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
172 const TGeoTranslation& translation,
175 // Adds the volume with the specified name and transformation
176 // to the list of envelopes.
180 cout << "... Adding ";
181 if (!isVirtual) cout << " non-";
182 cout << "virtual envelope " << name
184 << " with translation" << endl;
187 AliMUONGeometryEnvelope* envelope
188 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
190 Bool_t aligned = false;
191 if (fAlign) aligned = AlignEnvelope(envelope);
194 envelope->SetTranslation(translation);
196 fEnvelopes->Add(envelope);
199 //______________________________________________________________________________
200 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
203 const TGeoTranslation& translation,
204 const TGeoRotation& rotation,
207 // Adds the volume with the specified name and transformation
208 // 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 // Adds the volume with the specified name and transformation
255 // 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 // Adds the volume with the specified name and transformation
288 // to the list of envelopes.
292 cout << "... Adding "
293 << " non-virtual envelope " << name
295 << " with copyNo " << copyNo << endl;
298 AliMUONGeometryEnvelope* envelope
299 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
301 if (fAlign) AlignEnvelope(envelope);
303 fEnvelopes->Add(envelope);
306 //______________________________________________________________________________
307 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
310 const TGeoTranslation& translation,
313 // Adds the volume with the specified name and transformation
314 // 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 // Adds the volume with the specified name and transformation
346 // to the list of envelopes.
350 cout << "... Adding "
351 << " non-virtual envelope " << name
353 << " with copyNo " << copyNo
354 << " with translation and rotation" << endl;
357 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
358 // would be nice to be so simple
360 AliMUONGeometryEnvelope* envelope
361 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
363 Bool_t aligned = false;
364 if (fAlign) aligned = AlignEnvelope(envelope);
367 envelope->SetRotation(rotation);
368 envelope->SetTranslation(translation);
371 fEnvelopes->Add(envelope);
374 //______________________________________________________________________________
375 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
378 const TGeoCombiTrans& transform,
381 // Adds the volume with the specified name and transformation
382 // to the list of envelopes.
386 cout << "... Adding "
387 << " non-virtual envelope " << name
389 << " with copyNo " << copyNo
390 << " with translation and rotation" << endl;
393 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
394 // would be nice to be so simple
396 AliMUONGeometryEnvelope* envelope
397 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
399 Bool_t aligned = false;
400 if (fAlign) aligned = AlignEnvelope(envelope);
403 envelope->SetTransform(transform);
405 fEnvelopes->Add(envelope);
408 //______________________________________________________________________________
409 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
410 const TString& envName, Int_t copyNo)
412 // Adds the volume with the specified name and transformation
413 // to the list of envelopes.
417 cout << "... Adding constituent " << name
418 << " to envelope " << envName
419 << " with copyNo " << copyNo << endl;
422 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
429 envelope->AddConstituent(name, copyNo);
432 //______________________________________________________________________________
433 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
434 const TString& envName, Int_t copyNo,
435 const TGeoTranslation& translation)
437 // Adds the volume with the specified name and transformation
438 // to the list of envelopes.
442 cout << "... Adding constituent " << name
443 << " to envelope " << envName
444 << " with copyNo " << copyNo
445 << " with translation" << endl;
448 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
455 envelope->AddConstituent(name, copyNo, translation);
458 //______________________________________________________________________________
459 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
460 const TString& envName, Int_t copyNo,
461 const TGeoTranslation& translation,
462 const TGeoRotation& rotation)
464 // Adds the volume with the specified name and transformation
465 // to the list of envelopes.
469 cout << "... Adding constituent " << name
470 << " to envelope " << envName
471 << " with copyNo " << copyNo
472 << " with translation and rotation" << endl;
475 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
482 envelope->AddConstituent(name, copyNo, translation, rotation);
485 //______________________________________________________________________________
486 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
487 const TString& envName, Int_t copyNo,
488 const TGeoCombiTrans& transform)
490 // Adds the volume with the specified name and transformation
491 // to the list of envelopes.
495 cout << "... Adding constituent " << name
496 << " to envelope " << envName
497 << " with copyNo " << copyNo
498 << " with translation and rotation" << endl;
501 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
508 envelope->AddConstituent(name, copyNo, transform);
511 //______________________________________________________________________________
512 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
513 const TString& envName, Int_t copyNo,
514 Int_t npar, Double_t* param)
516 // Adds the volume with the specified name and transformation
517 // to the list of envelopes.
521 cout << "... Adding parameterised constituent " << name
522 << " to envelope " << envName
523 << " with copyNo " << copyNo << endl;
526 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
533 envelope->AddConstituentParam(name, copyNo, npar, param);
536 //______________________________________________________________________________
537 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
538 const TString& envName, Int_t copyNo,
539 const TGeoTranslation& translation,
540 Int_t npar, Double_t* param)
542 // Adds the volume with the specified name and transformation
543 // to the list of envelopes.
547 cout << "... Adding parameterised constituent " << name
548 << " to envelope " << envName
549 << " with copyNo " << copyNo
550 << " with translation" << endl;
553 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
560 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
563 //______________________________________________________________________________
564 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
565 const TString& envName, Int_t copyNo,
566 const TGeoTranslation& translation,
567 const TGeoRotation& rotation,
568 Int_t npar, Double_t* param)
570 // Adds the volume with the specified name and transformation
571 // to the list of envelopes.
575 cout << "... Adding parameterised constituent " << name
576 << " to envelope " << envName
577 << " with copyNo " << copyNo
578 << " with translation and rotation" << endl;
581 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
588 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
591 //______________________________________________________________________________
592 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
593 const TString& envName, Int_t copyNo,
594 const TGeoCombiTrans& transform,
595 Int_t npar, Double_t* param)
597 // Adds the volume with the specified name and transformation
598 // to the list of envelopes.
602 cout << "... Adding parameterised constituent " << name
603 << " to envelope " << envName
604 << " with copyNo " << copyNo
605 << " with translation and rotation" << endl;
608 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
615 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
618 //______________________________________________________________________________
619 Int_t AliMUONGeometryEnvelopeStore::GetNofDetElements() const
621 // Returns the number od envelopes with detElemId>0.
624 Int_t nofDetElems = 0;
626 for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
627 if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;