AliRoot Core  da88d91 (da88d91)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONGeometryEnvelopeStore.cxx
Go to the documentation of this file.
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 
16 // $Id$
17 
18 //-----------------------------------------------------------------------------
19 // Class AliMUONGeometryEnvelopeStore
20 // ----------------------------------
21 // Class for definititon of the temporary volume envelopes
22 // used in geometry construction
23 // Author: Ivana Hrivnacova, IPN Orsay
24 //-----------------------------------------------------------------------------
25 
29 #include "AliMUONGeometryBuilder.h"
30 
31 #include "AliMpExMap.h"
32 
33 #include "AliLog.h"
34 
35 #include <TGeoMatrix.h>
36 #include <TObjArray.h>
37 #include <Riostream.h>
38 #include <TString.h>
39 
40 using std::cout;
41 using std::endl;
45 
46 //______________________________________________________________________________
48  AliMpExMap* detElements)
49  : TObject(),
50  fEnvelopes(0),
51  fDetElements(detElements),
52  fReferenceFrame(),
53  fDebug(false),
54  fAlign(false)
55 {
57 
58  fEnvelopes = new TObjArray(100);
59 }
60 
61 
62 //______________________________________________________________________________
64  : TObject(),
65  fEnvelopes(0),
66  fDetElements(0),
67  fReferenceFrame(),
68  fDebug(false),
69  fAlign(false)
70 {
72 }
73 
74 
75 //______________________________________________________________________________
77 {
79 
80  // Add deleting rotation matrices
81 
82  if (fEnvelopes) {
83  fEnvelopes->Delete();
84  delete fEnvelopes;
85  }
86 }
87 
88 //
89 // private methods
90 //
91 
92 //______________________________________________________________________________
93 TGeoHMatrix
94 AliMUONGeometryEnvelopeStore::ConvertDETransform(const TGeoHMatrix& transform) const
95 {
97 
98  if ( fReferenceFrame.IsIdentity() )
99  return transform;
100  else {
102  transform );
103  }
104 }
105 
106 //______________________________________________________________________________
109 {
111 
112  for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
113  AliMUONGeometryEnvelope* envelope
115 
116  if (envelope->GetName() == name) return envelope;
117  }
118 
119  return 0;
120 }
121 
122 //______________________________________________________________________________
124  AliMUONGeometryEnvelope* envelope) const
125 {
129 
130  Int_t detElemId = envelope->GetUniqueID();
131  if (detElemId == 0) return false;
132 
133  AliMUONGeometryDetElement* detElement
135  if (!detElement) {
136  AliWarning("Transformation not found.");
137  return false;
138  };
139 
140  // Apply frame transform
141  TGeoHMatrix newTransform
142  = ConvertDETransform(*(detElement->GetLocalTransformation()));
143 
144  envelope->SetTransform(newTransform);
145 
146  return true;
147 }
148 
149 //
150 // public methods
151 //
152 
153 //______________________________________________________________________________
155  Int_t id,
156  Bool_t isVirtual,
157  const char* only)
158 {
161 
162  if (!isVirtual) AliDebug(1,Form("Adding non-virtual envelope %s id %d",name.Data(),id));
163 // else AliDebug(1,Form("Adding virtual envelope %s id %d",name.Data(),id));
164 
165  AliMUONGeometryEnvelope* envelope
166  = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
167 
168  if (fAlign) AlignEnvelope(envelope);
169 
170  fEnvelopes->Add(envelope);
171 }
172 
173 //______________________________________________________________________________
175  Int_t id,
176  Bool_t isVirtual,
177  const TGeoTranslation& translation,
178  const char* only)
179 {
182 
183  if (fDebug) {
184  cout << "... Adding ";
185  if (!isVirtual) cout << " non-";
186  cout << "virtual envelope " << name
187  << " id " << id
188  << " with translation" << endl;
189  }
190 
191  AliMUONGeometryEnvelope* envelope
192  = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
193 
194  Bool_t aligned = false;
195  if (fAlign) aligned = AlignEnvelope(envelope);
196 
197  if (!aligned)
198  envelope->SetTranslation(translation);
199 
200  fEnvelopes->Add(envelope);
201 }
202 
203 //______________________________________________________________________________
205  Int_t id,
206  Bool_t isVirtual,
207  const TGeoTranslation& translation,
208  const TGeoRotation& rotation,
209  const char* only)
210 {
213 
214  if (fDebug) {
215  cout << "... Adding ";
216  if (!isVirtual) cout << " non-";
217  cout << "virtual envelope " << name
218  << " id " << id
219  << " with translation and rotation" << endl;
220  }
221 
222 /*
223  cout << "Adding env... name: " << name;
224 
225  const Double_t* xyz = translation.GetTranslation();
226  cout << " translation: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]
227  << " rotation: ";
228 
229  Double_t a1, a2, a3, a4, a5, a6;
230  rotation.GetAngles(a1, a2, a3, a4, a5, a6);
231  cout << a1 << ", " << a2 << ", " << a3 << ", " << a4 << ", " << a5 << ", " << a6 << endl;
232 */
233  // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
234  // would be nice to be so simple
235 
236  AliMUONGeometryEnvelope* envelope
237  = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
238 
239  Bool_t aligned = false;
240  if (fAlign) aligned = AlignEnvelope(envelope);
241 
242  if (!aligned) {
243  envelope->SetRotation(rotation);
244  envelope->SetTranslation(translation);
245  }
246 
247  fEnvelopes->Add(envelope);
248 }
249 
250 //______________________________________________________________________________
252  Int_t id,
253  Bool_t isVirtual,
254  const TGeoCombiTrans& transform,
255  const char* only)
256 {
259 
260  if (fDebug) {
261  cout << "... Adding ";
262  if (!isVirtual) cout << " non-";
263  cout << "virtual envelope " << name
264  << " id " << id
265  << " with transformation" << endl;
266  }
267 
268  // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
269  // would be nice to be so simple
270 
271  AliMUONGeometryEnvelope* envelope
272  = new AliMUONGeometryEnvelope(name, id, isVirtual, only);
273 
274  Bool_t aligned = false;
275  if (fAlign) aligned = AlignEnvelope(envelope);
276 
277  if (!aligned)
278  envelope->SetTransform(transform);
279 
280  fEnvelopes->Add(envelope);
281 }
282 
283 //______________________________________________________________________________
285  Int_t id,
286  Int_t copyNo,
287  const char* only)
288 {
291 
292  if (fDebug) {
293  cout << "... Adding "
294  << " non-virtual envelope " << name
295  << " id " << id
296  << " with copyNo " << copyNo << endl;
297  }
298 
299  AliMUONGeometryEnvelope* envelope
300  = new AliMUONGeometryEnvelope(name, id, copyNo, only);
301 
302  if (fAlign) AlignEnvelope(envelope);
303 
304  fEnvelopes->Add(envelope);
305 }
306 
307 //______________________________________________________________________________
309  Int_t id,
310  Int_t copyNo,
311  const TGeoTranslation& translation,
312  const char* only)
313 {
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 //______________________________________________________________________________
339  Int_t id,
340  Int_t copyNo,
341  const TGeoTranslation& translation,
342  const TGeoRotation& rotation,
343  const char* only)
344 {
347 
348  if (fDebug) {
349  cout << "... Adding "
350  << " non-virtual envelope " << name
351  << " id " << id
352  << " with copyNo " << copyNo
353  << " with translation and rotation" << endl;
354  }
355 
356  // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
357  // would be nice to be so simple
358 
359  AliMUONGeometryEnvelope* envelope
360  = new AliMUONGeometryEnvelope(name, id, copyNo, only);
361 
362  Bool_t aligned = false;
363  if (fAlign) aligned = AlignEnvelope(envelope);
364 
365  if (!aligned) {
366  envelope->SetRotation(rotation);
367  envelope->SetTranslation(translation);
368  }
369 
370  fEnvelopes->Add(envelope);
371 }
372 
373 //______________________________________________________________________________
375  Int_t id,
376  Int_t copyNo,
377  const TGeoCombiTrans& transform,
378  const char* only)
379 {
382 
383  if (fDebug) {
384  cout << "... Adding "
385  << " non-virtual envelope " << name
386  << " id " << id
387  << " with copyNo " << copyNo
388  << " with translation and rotation" << endl;
389  }
390 
391  // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
392  // would be nice to be so simple
393 
394  AliMUONGeometryEnvelope* envelope
395  = new AliMUONGeometryEnvelope(name, id, copyNo, only);
396 
397  Bool_t aligned = false;
398  if (fAlign) aligned = AlignEnvelope(envelope);
399 
400  if (!aligned)
401  envelope->SetTransform(transform);
402 
403  fEnvelopes->Add(envelope);
404 }
405 
406 //______________________________________________________________________________
408  const TString& envName, Int_t copyNo)
409 {
412 
413  if (fDebug) {
414  cout << "... Adding constituent " << name
415  << " to envelope " << envName
416  << " with copyNo " << copyNo << endl;
417  }
418 
419  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
420 
421  if (!envelope) {
422  // add warning
423  return;
424  }
425 
426  envelope->AddConstituent(name, copyNo);
427 }
428 
429 //______________________________________________________________________________
431  const TString& envName, Int_t copyNo,
432  const TGeoTranslation& translation)
433 {
436 
437  if (fDebug) {
438  cout << "... Adding constituent " << name
439  << " to envelope " << envName
440  << " with copyNo " << copyNo
441  << " with translation" << endl;
442  }
443 
444  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
445 
446  if (!envelope) {
447  // add warning
448  return;
449  }
450 
451  envelope->AddConstituent(name, copyNo, translation);
452 }
453 
454 //______________________________________________________________________________
456  const TString& envName, Int_t copyNo,
457  const TGeoTranslation& translation,
458  const TGeoRotation& rotation)
459 {
462 
463  if (fDebug) {
464  cout << "... Adding constituent " << name
465  << " to envelope " << envName
466  << " with copyNo " << copyNo
467  << " with translation and rotation" << endl;
468  }
469 
470  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
471 
472  if (!envelope) {
473  // add warning
474  return;
475  }
476 
477  envelope->AddConstituent(name, copyNo, translation, rotation);
478 }
479 
480 //______________________________________________________________________________
482  const TString& envName, Int_t copyNo,
483  const TGeoCombiTrans& transform)
484 {
487 
488  if (fDebug) {
489  cout << "... Adding constituent " << name
490  << " to envelope " << envName
491  << " with copyNo " << copyNo
492  << " with translation and rotation" << endl;
493  }
494 
495  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
496 
497  if (!envelope) {
498  // add warning
499  return;
500  }
501 
502  envelope->AddConstituent(name, copyNo, transform);
503 }
504 
505 //______________________________________________________________________________
507  const TString& envName, Int_t copyNo,
508  Int_t npar, Double_t* param)
509 {
512 
513  if (fDebug) {
514  cout << "... Adding parameterised constituent " << name
515  << " to envelope " << envName
516  << " with copyNo " << copyNo << endl;
517  }
518 
519  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
520 
521  if (!envelope) {
522  // add warning
523  return;
524  }
525 
526  envelope->AddConstituentParam(name, copyNo, npar, param);
527 }
528 
529 //______________________________________________________________________________
531  const TString& envName, Int_t copyNo,
532  const TGeoTranslation& translation,
533  Int_t npar, Double_t* param)
534 {
537 
538  if (fDebug) {
539  cout << "... Adding parameterised constituent " << name
540  << " to envelope " << envName
541  << " with copyNo " << copyNo
542  << " with translation" << endl;
543  }
544 
545  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
546 
547  if (!envelope) {
548  // add warning
549  return;
550  }
551 
552  envelope->AddConstituentParam(name, copyNo, translation, npar, param);
553 }
554 
555 //______________________________________________________________________________
557  const TString& envName, Int_t copyNo,
558  const TGeoTranslation& translation,
559  const TGeoRotation& rotation,
560  Int_t npar, Double_t* param)
561 {
564 
565  if (fDebug) {
566  cout << "... Adding parameterised constituent " << name
567  << " to envelope " << envName
568  << " with copyNo " << copyNo
569  << " with translation and rotation" << endl;
570  }
571 
572  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
573 
574  if (!envelope) {
575  // add warning
576  return;
577  }
578 
579  envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
580 }
581 
582 //______________________________________________________________________________
584  const TString& envName, Int_t copyNo,
585  const TGeoCombiTrans& transform,
586  Int_t npar, Double_t* param)
587 {
590 
591  if (fDebug) {
592  cout << "... Adding parameterised constituent " << name
593  << " to envelope " << envName
594  << " with copyNo " << copyNo
595  << " with translation and rotation" << endl;
596  }
597 
598  AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
599 
600  if (!envelope) {
601  // add warning
602  return;
603  }
604 
605  envelope->AddConstituentParam(name, copyNo, transform, npar, param);
606 }
607 
608 //______________________________________________________________________________
610 {
612 
613  Int_t nofDetElems = 0;
614 
615  for(Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++)
616  if ( fEnvelopes->At(i)->GetUniqueID() > 0 ) nofDetElems++;
617 
618  return nofDetElems;
619 }
void AddConstituentParam(const TString &name, Int_t copyNo, Int_t npar, Double_t *param)
Bool_t fAlign
option to read transformations from a file
#define TObjArray
AliMpExMap * fDetElements
wrt to the chamber position in mother volume
TGeoHMatrix ConvertDETransform(const TGeoHMatrix &transform) const
Bool_t AlignEnvelope(AliMUONGeometryEnvelope *envelope) const
void AddEnvelope(const TString &name, Int_t id, Bool_t isVirtual, const char *only="ONLY")
void SetTransform(const TGeoCombiTrans &transform)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
AliMUONGeometryEnvelope * FindEnvelope(const TString &name) const
TGeoCombiTrans fReferenceFrame
the transformation from the builder reference frame to that of the transform
TObjArray * fEnvelopes
the envelopes names and transformations
void AddEnvelopeConstituent(const TString &name, const TString &envName, Int_t copyNo)
Store for temporary volumes envelopes.
Geometry envelope helper class.
static TGeoHMatrix Multiply(const TGeoMatrix &m1, const TGeoMatrix &m2)
void AddConstituent(const TString &name, Int_t copyNo)
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
void SetTranslation(const TGeoTranslation &translation)
void AddEnvelopeConstituentParam(const TString &name, const TString &envName, Int_t copyNo, Int_t npar, Double_t *param)
Class for storing detection element transformations.
void SetRotation(const TGeoRotation &rotation)
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28
const TGeoHMatrix * GetLocalTransformation() const
Return the detection element transformation wrt module.