]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONGeometryEnvelopeStore.cxx
Reversing previous commit (Gines)
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryEnvelopeStore.cxx
... / ...
CommitLineData
1// $Id$
2//
3// Class AliMUONGeometryEnvelopeStore
4// ----------------------------------
5// Class for definititon of the temporary volume envelopes
6// used in geometry construction
7//
8// Author: Ivana Hrivnacova, IPN Orsay
9
10#include <TVirtualMC.h>
11#include <TGeoMatrix.h>
12#include <TObjArray.h>
13#include <TArrayI.h>
14#include <Riostream.h>
15
16#include "AliMUONGeometryEnvelopeStore.h"
17#include "AliMUONGeometryTransformStore.h"
18#include "AliMUONGeometryEnvelope.h"
19#include "AliMUONConstants.h"
20
21ClassImp(AliMUONGeometryEnvelopeStore)
22
23//______________________________________________________________________________
24AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(
25 AliMUONGeometryTransformStore* transforms)
26 : TObject(),
27 fDETransforms(transforms),
28 fEnvelopes(0),
29 fDebug(false),
30 fAlign(false)
31{
32// Standard constructor
33
34 fEnvelopes = new TObjArray(100);
35}
36
37
38//______________________________________________________________________________
39AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore()
40 : TObject(),
41 fDETransforms(0),
42 fEnvelopes(0),
43 fDebug(false),
44 fAlign(false)
45{
46// Default constructor
47}
48
49
50//______________________________________________________________________________
51AliMUONGeometryEnvelopeStore::AliMUONGeometryEnvelopeStore(const AliMUONGeometryEnvelopeStore& rhs)
52 : TObject(rhs)
53{
54 Fatal("Copy constructor",
55 "Copy constructor is not implemented.");
56}
57
58//______________________________________________________________________________
59AliMUONGeometryEnvelopeStore::~AliMUONGeometryEnvelopeStore()
60{
61//
62
63 // Add deleting rotation matrices
64
65 if (fEnvelopes) {
66 fEnvelopes->Delete();
67 delete fEnvelopes;
68 }
69}
70
71//______________________________________________________________________________
72AliMUONGeometryEnvelopeStore&
73AliMUONGeometryEnvelopeStore::operator = (const AliMUONGeometryEnvelopeStore& rhs)
74{
75 // check assignement to self
76 if (this == &rhs) return *this;
77
78 Fatal("operator=",
79 "Assignment operator is not implemented.");
80
81 return *this;
82}
83
84//
85// private methods
86//
87
88//______________________________________________________________________________
89AliMUONGeometryEnvelope*
90AliMUONGeometryEnvelopeStore::FindEnvelope(const TString& name) const
91{
92// Finds the envelope specified by name.
93// ---
94
95 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
96 AliMUONGeometryEnvelope* envelope
97 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
98
99 if (envelope->GetName() == name) return envelope;
100 }
101
102 return 0;
103}
104
105//______________________________________________________________________________
106Bool_t AliMUONGeometryEnvelopeStore::AlignEnvelope(
107 AliMUONGeometryEnvelope* envelope) const
108{
109// Find transformation by the detection element Id (if not 0)
110// (= unique ID of enevelope) and set it to the envelope.
111// Return true if transformation is applied, false otherwise.
112// ---
113
114 Int_t detElemId = envelope->GetUniqueID();
115 if (detElemId == 0) return false;
116
117 const TGeoCombiTrans* kTransform = fDETransforms->Get(detElemId);
118 if (!kTransform) {
119 Warning("AlignEnvelope", "Transformation not found.");
120 return false;
121 };
122
123 envelope->SetTransform(*kTransform);
124 return true;
125}
126
127//
128// public methods
129//
130
131//______________________________________________________________________________
132void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
133 Int_t id,
134 Bool_t isVirtual,
135 const char* only)
136{
137// Adds the volume with the specified name and transformation
138// to the list of envelopes.
139// ---
140
141 if (fDebug) {
142 cout << "... Adding ";
143 if (!isVirtual) cout << " non-";
144 cout << "virtual envelope " << name
145 << " id " << id << endl;
146 }
147
148 AliMUONGeometryEnvelope* envelope
149 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
150
151 if (fAlign) AlignEnvelope(envelope);
152
153 fEnvelopes->Add(envelope);
154}
155
156//______________________________________________________________________________
157void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
158 Int_t id,
159 Bool_t isVirtual,
160 const TGeoTranslation& translation,
161 const char* only)
162{
163// Adds the volume with the specified name and transformation
164// to the list of envelopes.
165// ---
166
167 if (fDebug) {
168 cout << "... Adding ";
169 if (!isVirtual) cout << " non-";
170 cout << "virtual envelope " << name
171 << " id " << id
172 << " with translation" << endl;
173 }
174
175 AliMUONGeometryEnvelope* envelope
176 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
177
178 Bool_t aligned = false;
179 if (fAlign) aligned = AlignEnvelope(envelope);
180
181 if (!aligned)
182 envelope->SetTranslation(translation);
183
184 fEnvelopes->Add(envelope);
185}
186
187//______________________________________________________________________________
188void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
189 Int_t id,
190 Bool_t isVirtual,
191 const TGeoTranslation& translation,
192 const TGeoRotation& rotation,
193 const char* only)
194{
195// Adds the volume with the specified name and transformation
196// to the list of envelopes.
197// ---
198
199 if (fDebug) {
200 cout << "... Adding ";
201 if (!isVirtual) cout << " non-";
202 cout << "virtual envelope " << name
203 << " id " << id
204 << " with translation and rotation" << endl;
205 }
206
207/*
208 cout << "Adding env... name: " << name;
209
210 const Double_t* xyz = translation.GetTranslation();
211 cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
212 << " rotation: ";
213
214 Double_t a1, a2, a3, a4, a5, a6;
215 rotation.GetAngles(a1, a2, a3, a4, a5, a6);
216 cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
217*/
218 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
219 // would be nice to be so simple
220
221 AliMUONGeometryEnvelope* envelope
222 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
223
224 Bool_t aligned = false;
225 if (fAlign) aligned = AlignEnvelope(envelope);
226
227 if (!aligned) {
228 envelope->SetRotation(rotation);
229 envelope->SetTranslation(translation);
230 }
231
232 fEnvelopes->Add(envelope);
233}
234
235//______________________________________________________________________________
236void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
237 Int_t id,
238 Bool_t isVirtual,
239 const TGeoCombiTrans& transform,
240 const char* only)
241{
242// Adds the volume with the specified name and transformation
243// to the list of envelopes.
244// ---
245
246 if (fDebug) {
247 cout << "... Adding ";
248 if (!isVirtual) cout << " non-";
249 cout << "virtual envelope " << name
250 << " id " << id
251 << " with transformation" << endl;
252 }
253
254 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
255 // would be nice to be so simple
256
257 AliMUONGeometryEnvelope* envelope
258 = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
259
260 Bool_t aligned = false;
261 if (fAlign) aligned = AlignEnvelope(envelope);
262
263 if (!aligned)
264 envelope->SetTransform(transform);
265
266 fEnvelopes->Add(envelope);
267}
268
269//______________________________________________________________________________
270void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
271 Int_t id,
272 Int_t copyNo,
273 const char* only)
274{
275// Adds the volume with the specified name and transformation
276// to the list of envelopes.
277// ---
278
279 if (fDebug) {
280 cout << "... Adding "
281 << " non-virtual envelope " << name
282 << " id " << id
283 << " with copyNo " << copyNo << endl;
284 }
285
286 AliMUONGeometryEnvelope* envelope
287 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
288
289 if (fAlign) AlignEnvelope(envelope);
290
291 fEnvelopes->Add(envelope);
292}
293
294//______________________________________________________________________________
295void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
296 Int_t id,
297 Int_t copyNo,
298 const TGeoTranslation& translation,
299 const char* only)
300{
301// Adds the volume with the specified name and transformation
302// to the list of envelopes.
303// ---
304
305 if (fDebug) {
306 cout << "... Adding "
307 << " non-virtual envelope " << name
308 << " id " << id
309 << " with copyNo " << copyNo
310 << " with translation " << endl;
311 }
312
313 AliMUONGeometryEnvelope* envelope
314 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
315
316 Bool_t aligned = false;
317 if (fAlign) aligned = AlignEnvelope(envelope);
318
319 if (!aligned)
320 envelope->SetTranslation(translation);
321
322 fEnvelopes->Add(envelope);
323}
324
325//______________________________________________________________________________
326void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
327 Int_t id,
328 Int_t copyNo,
329 const TGeoTranslation& translation,
330 const TGeoRotation& rotation,
331 const char* only)
332{
333// Adds the volume with the specified name and transformation
334// to the list of envelopes.
335// ---
336
337 if (fDebug) {
338 cout << "... Adding "
339 << " non-virtual envelope " << name
340 << " id " << id
341 << " with copyNo " << copyNo
342 << " with translation and rotation" << endl;
343 }
344
345 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
346 // would be nice to be so simple
347
348 AliMUONGeometryEnvelope* envelope
349 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
350
351 Bool_t aligned = false;
352 if (fAlign) aligned = AlignEnvelope(envelope);
353
354 if (!aligned) {
355 envelope->SetRotation(rotation);
356 envelope->SetTranslation(translation);
357 }
358
359 fEnvelopes->Add(envelope);
360}
361
362//______________________________________________________________________________
363void AliMUONGeometryEnvelopeStore::AddEnvelope(const TString& name,
364 Int_t id,
365 Int_t copyNo,
366 const TGeoCombiTrans& transform,
367 const char* only)
368{
369// Adds the volume with the specified name and transformation
370// to the list of envelopes.
371// ---
372
373 if (fDebug) {
374 cout << "... Adding "
375 << " non-virtual envelope " << name
376 << " id " << id
377 << " with copyNo " << copyNo
378 << " with translation and rotation" << endl;
379 }
380
381 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
382 // would be nice to be so simple
383
384 AliMUONGeometryEnvelope* envelope
385 = new AliMUONGeometryEnvelope(name, id, copyNo, only);
386
387 Bool_t aligned = false;
388 if (fAlign) aligned = AlignEnvelope(envelope);
389
390 if (!aligned)
391 envelope->SetTransform(transform);
392
393 fEnvelopes->Add(envelope);
394}
395
396//______________________________________________________________________________
397void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
398 const TString& envName, Int_t copyNo)
399{
400// Adds the volume with the specified name and transformation
401// to the list of envelopes.
402// ---
403
404 if (fDebug) {
405 cout << "... Adding constituent " << name
406 << " to envelope " << envName
407 << " with copyNo " << copyNo << endl;
408 }
409
410 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
411
412 if (!envelope) {
413 // add warning
414 return;
415 }
416
417 envelope->AddConstituent(name, copyNo);
418}
419
420//______________________________________________________________________________
421void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
422 const TString& envName, Int_t copyNo,
423 const TGeoTranslation& translation)
424{
425// Adds the volume with the specified name and transformation
426// to the list of envelopes.
427// ---
428
429 if (fDebug) {
430 cout << "... Adding constituent " << name
431 << " to envelope " << envName
432 << " with copyNo " << copyNo
433 << " with translation" << endl;
434 }
435
436 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
437
438 if (!envelope) {
439 // add warning
440 return;
441 }
442
443 envelope->AddConstituent(name, copyNo, translation);
444}
445
446//______________________________________________________________________________
447void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
448 const TString& envName, Int_t copyNo,
449 const TGeoTranslation& translation,
450 const TGeoRotation& rotation)
451{
452// Adds the volume with the specified name and transformation
453// to the list of envelopes.
454// ---
455
456 if (fDebug) {
457 cout << "... Adding constituent " << name
458 << " to envelope " << envName
459 << " with copyNo " << copyNo
460 << " with translation and rotation" << endl;
461 }
462
463 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
464
465 if (!envelope) {
466 // add warning
467 return;
468 }
469
470 envelope->AddConstituent(name, copyNo, translation, rotation);
471}
472
473//______________________________________________________________________________
474void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituent(const TString& name,
475 const TString& envName, Int_t copyNo,
476 const TGeoCombiTrans& transform)
477{
478// Adds the volume with the specified name and transformation
479// to the list of envelopes.
480// ---
481
482 if (fDebug) {
483 cout << "... Adding constituent " << name
484 << " to envelope " << envName
485 << " with copyNo " << copyNo
486 << " with translation and rotation" << endl;
487 }
488
489 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
490
491 if (!envelope) {
492 // add warning
493 return;
494 }
495
496 envelope->AddConstituent(name, copyNo, transform);
497}
498
499//______________________________________________________________________________
500void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
501 const TString& envName, Int_t copyNo,
502 Int_t npar, Double_t* param)
503{
504// Adds the volume with the specified name and transformation
505// to the list of envelopes.
506// ---
507
508 if (fDebug) {
509 cout << "... Adding parameterised constituent " << name
510 << " to envelope " << envName
511 << " with copyNo " << copyNo << endl;
512 }
513
514 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
515
516 if (!envelope) {
517 // add warning
518 return;
519 }
520
521 envelope->AddConstituentParam(name, copyNo, npar, param);
522}
523
524//______________________________________________________________________________
525void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
526 const TString& envName, Int_t copyNo,
527 const TGeoTranslation& translation,
528 Int_t npar, Double_t* param)
529{
530// Adds the volume with the specified name and transformation
531// to the list of envelopes.
532// ---
533
534 if (fDebug) {
535 cout << "... Adding parameterised constituent " << name
536 << " to envelope " << envName
537 << " with copyNo " << copyNo
538 << " with translation" << endl;
539 }
540
541 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
542
543 if (!envelope) {
544 // add warning
545 return;
546 }
547
548 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
549}
550
551//______________________________________________________________________________
552void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
553 const TString& envName, Int_t copyNo,
554 const TGeoTranslation& translation,
555 const TGeoRotation& rotation,
556 Int_t npar, Double_t* param)
557{
558// Adds the volume with the specified name and transformation
559// to the list of envelopes.
560// ---
561
562 if (fDebug) {
563 cout << "... Adding parameterised constituent " << name
564 << " to envelope " << envName
565 << " with copyNo " << copyNo
566 << " with translation and rotation" << endl;
567 }
568
569 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
570
571 if (!envelope) {
572 // add warning
573 return;
574 }
575
576 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
577}
578
579//______________________________________________________________________________
580void AliMUONGeometryEnvelopeStore::AddEnvelopeConstituentParam(const TString& name,
581 const TString& envName, Int_t copyNo,
582 const TGeoCombiTrans& transform,
583 Int_t npar, Double_t* param)
584{
585// Adds the volume with the specified name and transformation
586// to the list of envelopes.
587// ---
588
589 if (fDebug) {
590 cout << "... Adding parameterised constituent " << name
591 << " to envelope " << envName
592 << " with copyNo " << copyNo
593 << " with translation and rotation" << endl;
594 }
595
596 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
597
598 if (!envelope) {
599 // add warning
600 return;
601 }
602
603 envelope->AddConstituentParam(name, copyNo, transform, npar, param);
604}
605