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