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