3 // Class AliMUONGeometryEnvelopeStore
4 // ----------------------------------
5 // Class for definititon of the temporary volume envelopes
6 // used in geometry construction
8 // Author: Ivana Hrivnacova, IPN Orsay
10 #include <TVirtualMC.h>
11 #include <TGeoMatrix.h>
12 #include <TObjArray.h>
14 #include <Riostream.h>
16 #include "AliMUONGeometryEnvelopeStore.h"
17 #include "AliMUONGeometryTransformStore.h"
18 #include "AliMUONGeometryEnvelope.h"
19 #include "AliMUONConstants.h"
22 ClassImp(AliMUONGeometryEnvelopeStore)
24 //______________________________________________________________________________
25 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
26 AliMUONGeometryTransformStore* transforms)
28 fDETransforms(transforms),
33 // Standard constructor
35 fEnvelopes = new TObjArray(100);
39 //______________________________________________________________________________
40 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
47 // Default constructor
51 //______________________________________________________________________________
52 AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(const AliMUONGeometryEnvelopeStore& rhs)
55 AliFatal("Copy constructor is not implemented.");
58 //______________________________________________________________________________
59 AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
63 // Add deleting rotation matrices
71 //______________________________________________________________________________
72 AliMUONGeometryEnvelopeStore&
73 AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rhs)
75 // check assignement to self
76 if (this == &rhs) return *this;
78 AliFatal("Assignment operator is not implemented.");
87 //______________________________________________________________________________
88 AliMUONGeometryEnvelope*
89 AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
91 // Finds the envelope specified by name.
94 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
95 AliMUONGeometryEnvelope* envelope
96 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
98 if (envelope->GetName() == name) return envelope;
104 //______________________________________________________________________________
105 Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
106 AliMUONGeometryEnvelope* envelope) const
108 // Find transformation by the detection element Id (if not 0)
109 // (= unique ID of enevelope) and set it to the envelope.
110 // Return true if transformation is applied, false otherwise.
113 Int_t detElemId = envelope->GetUniqueID();
114 if (detElemId == 0) return false;
116 const TGeoCombiTrans* kTransform = fDETransforms->Get(detElemId);
118 AliWarning("Transformation not found.");
122 envelope->SetTransform(*kTransform);
130 //______________________________________________________________________________
131 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
136 // Adds the volume with the specified name and transformation
137 // to the list of envelopes.
140 if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
141 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
143 AliMUONGeometryEnvelope* envelope
144 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
146 if (fAlign) AlignEnvelope(envelope);
148 fEnvelopes->Add(envelope);
151 //______________________________________________________________________________
152 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
155 const TGeoTranslation& translation,
158 // Adds the volume with the specified name and transformation
159 // to the list of envelopes.
163 cout << "... Adding ";
164 if (!isVirtual) cout << " non-";
165 cout << "virtual envelope " << name
167 << " with translation" << endl;
170 AliMUONGeometryEnvelope* envelope
171 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
173 Bool_t aligned = false;
174 if (fAlign) aligned = AlignEnvelope(envelope);
177 envelope->SetTranslation(translation);
179 fEnvelopes->Add(envelope);
182 //______________________________________________________________________________
183 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
186 const TGeoTranslation& translation,
187 const TGeoRotation& rotation,
190 // Adds the volume with the specified name and transformation
191 // to the list of envelopes.
195 cout << "... Adding ";
196 if (!isVirtual) cout << " non-";
197 cout << "virtual envelope " << name
199 << " with translation and rotation" << endl;
203 cout << "Adding env... name: " << name;
205 const Double_t* xyz = translation.GetTranslation();
206 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
209 Double_t a1, a2, a3, a4, a5, a6;
210 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
211 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
213 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
214 // would be nice to be so simple
216 AliMUONGeometryEnvelope* envelope
217 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
219 Bool_t aligned = false;
220 if (fAlign) aligned = AlignEnvelope(envelope);
223 envelope->SetRotation(rotation);
224 envelope->SetTranslation(translation);
227 fEnvelopes->Add(envelope);
230 //______________________________________________________________________________
231 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
234 const TGeoCombiTrans& transform,
237 // Adds the volume with the specified name and transformation
238 // to the list of envelopes.
242 cout << "... Adding ";
243 if (!isVirtual) cout << " non-";
244 cout << "virtual envelope " << name
246 << " with transformation" << endl;
249 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
250 // would be nice to be so simple
252 AliMUONGeometryEnvelope* envelope
253 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
255 Bool_t aligned = false;
256 if (fAlign) aligned = AlignEnvelope(envelope);
259 envelope->SetTransform(transform);
261 fEnvelopes->Add(envelope);
264 //______________________________________________________________________________
265 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
270 // Adds the volume with the specified name and transformation
271 // to the list of envelopes.
275 cout << "... Adding "
276 << " non-virtual envelope " << name
278 << " with copyNo " << copyNo << endl;
281 AliMUONGeometryEnvelope* envelope
282 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
284 if (fAlign) AlignEnvelope(envelope);
286 fEnvelopes->Add(envelope);
289 //______________________________________________________________________________
290 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
293 const TGeoTranslation& translation,
296 // Adds the volume with the specified name and transformation
297 // to the list of envelopes.
301 cout << "... Adding "
302 << " non-virtual envelope " << name
304 << " with copyNo " << copyNo
305 << " with translation " << endl;
308 AliMUONGeometryEnvelope* envelope
309 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
311 Bool_t aligned = false;
312 if (fAlign) aligned = AlignEnvelope(envelope);
315 envelope->SetTranslation(translation);
317 fEnvelopes->Add(envelope);
320 //______________________________________________________________________________
321 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
324 const TGeoTranslation& translation,
325 const TGeoRotation& rotation,
328 // Adds the volume with the specified name and transformation
329 // to the list of envelopes.
333 cout << "... Adding "
334 << " non-virtual envelope " << name
336 << " with copyNo " << copyNo
337 << " with translation and rotation" << endl;
340 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
341 // would be nice to be so simple
343 AliMUONGeometryEnvelope* envelope
344 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
346 Bool_t aligned = false;
347 if (fAlign) aligned = AlignEnvelope(envelope);
350 envelope->SetRotation(rotation);
351 envelope->SetTranslation(translation);
354 fEnvelopes->Add(envelope);
357 //______________________________________________________________________________
358 void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
361 const TGeoCombiTrans& transform,
364 // Adds the volume with the specified name and transformation
365 // to the list of envelopes.
369 cout << "... Adding "
370 << " non-virtual envelope " << name
372 << " with copyNo " << copyNo
373 << " with translation and rotation" << endl;
376 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
377 // would be nice to be so simple
379 AliMUONGeometryEnvelope* envelope
380 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
382 Bool_t aligned = false;
383 if (fAlign) aligned = AlignEnvelope(envelope);
386 envelope->SetTransform(transform);
388 fEnvelopes->Add(envelope);
391 //______________________________________________________________________________
392 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
393 const TString& envName, Int_t copyNo)
395 // Adds the volume with the specified name and transformation
396 // to the list of envelopes.
400 cout << "... Adding constituent " << name
401 << " to envelope " << envName
402 << " with copyNo " << copyNo << endl;
405 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
412 envelope->AddConstituent(name, copyNo);
415 //______________________________________________________________________________
416 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
417 const TString& envName, Int_t copyNo,
418 const TGeoTranslation& translation)
420 // Adds the volume with the specified name and transformation
421 // to the list of envelopes.
425 cout << "... Adding constituent " << name
426 << " to envelope " << envName
427 << " with copyNo " << copyNo
428 << " with translation" << endl;
431 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
438 envelope->AddConstituent(name, copyNo, translation);
441 //______________________________________________________________________________
442 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
443 const TString& envName, Int_t copyNo,
444 const TGeoTranslation& translation,
445 const TGeoRotation& rotation)
447 // Adds the volume with the specified name and transformation
448 // to the list of envelopes.
452 cout << "... Adding constituent " << name
453 << " to envelope " << envName
454 << " with copyNo " << copyNo
455 << " with translation and rotation" << endl;
458 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
465 envelope->AddConstituent(name, copyNo, translation, rotation);
468 //______________________________________________________________________________
469 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
470 const TString& envName, Int_t copyNo,
471 const TGeoCombiTrans& transform)
473 // Adds the volume with the specified name and transformation
474 // to the list of envelopes.
478 cout << "... Adding constituent " << name
479 << " to envelope " << envName
480 << " with copyNo " << copyNo
481 << " with translation and rotation" << endl;
484 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
491 envelope->AddConstituent(name, copyNo, transform);
494 //______________________________________________________________________________
495 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
496 const TString& envName, Int_t copyNo,
497 Int_t npar, Double_t* param)
499 // Adds the volume with the specified name and transformation
500 // to the list of envelopes.
504 cout << "... Adding parameterised constituent " << name
505 << " to envelope " << envName
506 << " with copyNo " << copyNo << endl;
509 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
516 envelope->AddConstituentParam(name, copyNo, npar, param);
519 //______________________________________________________________________________
520 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
521 const TString& envName, Int_t copyNo,
522 const TGeoTranslation& translation,
523 Int_t npar, Double_t* param)
525 // Adds the volume with the specified name and transformation
526 // to the list of envelopes.
530 cout << "... Adding parameterised constituent " << name
531 << " to envelope " << envName
532 << " with copyNo " << copyNo
533 << " with translation" << endl;
536 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
543 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
546 //______________________________________________________________________________
547 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
548 const TString& envName, Int_t copyNo,
549 const TGeoTranslation& translation,
550 const TGeoRotation& rotation,
551 Int_t npar, Double_t* param)
553 // Adds the volume with the specified name and transformation
554 // to the list of envelopes.
558 cout << "... Adding parameterised constituent " << name
559 << " to envelope " << envName
560 << " with copyNo " << copyNo
561 << " with translation and rotation" << endl;
564 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
571 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
574 //______________________________________________________________________________
575 void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
576 const TString& envName, Int_t copyNo,
577 const TGeoCombiTrans& transform,
578 Int_t npar, Double_t* param)
580 // Adds the volume with the specified name and transformation
581 // to the list of envelopes.
585 cout << "... Adding parameterised constituent " << name
586 << " to envelope " << envName
587 << " with copyNo " << copyNo
588 << " with translation and rotation" << endl;
591 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
598 envelope->AddConstituentParam(name, copyNo, transform, npar, param);