]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryEnvelope.cxx
New class of global trigger boards
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryEnvelope.cxx
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 // Class AliMUONGeometryEnvelope
19 // -----------------------------
20 // Helper class for definititon an assembly of volumes.
21 // Author: Ivana Hrivnacova, IPN Orsay
22 // 23/01/2004
23
24 #include <TGeoMatrix.h>
25 #include <TString.h>
26 #include <TObjArray.h>
27
28 #include "AliMUONGeometryEnvelope.h"
29 #include "AliMUONGeometryConstituent.h"
30 #include "AliLog.h"
31
32 ClassImp(AliMUONGeometryEnvelope)
33
34 //______________________________________________________________________________
35 AliMUONGeometryEnvelope::AliMUONGeometryEnvelope(const TString& name, 
36                                                  Int_t id, 
37                                                  Bool_t isVirtual,
38                                                  const char* only)
39  : TNamed(name, name),
40    fIsVirtual(isVirtual),
41    fIsMANY(false),
42    fCopyNo(1),
43    fTransformation(0),
44    fConstituents(0)
45 {
46 /// Standard constructor
47
48   if (TString(only) == TString("MANY")) fIsMANY = true;
49
50   // Create the envelope transformation
51   fTransformation = new TGeoCombiTrans("");
52   fConstituents = new TObjArray(20);
53   
54   // Set id
55   SetUniqueID(id);
56 }
57
58
59 //______________________________________________________________________________
60 AliMUONGeometryEnvelope::AliMUONGeometryEnvelope(const TString& name,   
61                                                  Int_t id,
62                                                  Int_t copyNo, 
63                                                  const char* only)
64  : TNamed(name, name),
65    fIsVirtual(false),
66    fIsMANY(false),
67    fCopyNo(copyNo),
68    fTransformation(0),
69    fConstituents(0)
70 {
71 /// Standard constructor for a non virtual enevelope with a specified copy 
72 /// number
73
74   if (TString(only) == TString("MANY")) fIsMANY = true;
75
76   // Create the envelope transformation
77   fTransformation = new TGeoCombiTrans("");
78   fConstituents = new TObjArray(20);
79   
80   // Set id
81   SetUniqueID(id);
82 }
83
84
85 //______________________________________________________________________________
86 AliMUONGeometryEnvelope::AliMUONGeometryEnvelope()
87  : TNamed(),
88    fIsVirtual(0),
89    fIsMANY(false),
90    fCopyNo(0),
91    fTransformation(0),
92    fConstituents(0)
93 {
94 /// Default constructor
95 }
96
97
98 //______________________________________________________________________________
99 AliMUONGeometryEnvelope::AliMUONGeometryEnvelope(
100                                         const AliMUONGeometryEnvelope& rhs)
101   : TNamed(rhs)
102 {
103 /// Protected copy constructor
104
105   AliFatal("Copy constructor is not implemented.");
106 }
107
108 //______________________________________________________________________________
109 AliMUONGeometryEnvelope::~AliMUONGeometryEnvelope() 
110 {
111 /// Destructor
112
113   // Add deleting rotation matrices 
114   
115   delete fTransformation;
116   
117   if (fConstituents) {
118     fConstituents->Delete();
119     delete fConstituents;
120   }  
121 }
122
123 //______________________________________________________________________________
124 AliMUONGeometryEnvelope& 
125 AliMUONGeometryEnvelope::operator = (const AliMUONGeometryEnvelope& rhs) 
126 {
127 /// Protected assignement operator
128
129   // check assignement to self
130   if (this == &rhs) return *this;
131
132   AliFatal("Assignment operator is not implemented.");
133     
134   return *this;  
135 }
136
137 //
138 // public methods
139 //
140
141 //______________________________________________________________________________
142 void  AliMUONGeometryEnvelope::AddConstituent(const TString& name, Int_t copyNo) 
143 {
144 /// Add the volume with the specified name and transformation
145 /// to the list of envelopes.
146
147   fConstituents->Add(new AliMUONGeometryConstituent(name, copyNo, 0, 0));
148 }
149
150 //______________________________________________________________________________
151 void  AliMUONGeometryEnvelope::AddConstituent(const TString& name, Int_t copyNo, 
152                                           const TGeoTranslation& translation)
153 {
154 /// Add the volume with the specified name and transformation
155 /// to the list of envelopes.
156
157   fConstituents
158     ->Add(new AliMUONGeometryConstituent(name, copyNo, translation, 0, 0));
159 }
160
161 //______________________________________________________________________________
162 void  AliMUONGeometryEnvelope::AddConstituent(const TString& name, Int_t copyNo,
163                                           const TGeoTranslation& translation,
164                                           const TGeoRotation& rotation)
165 {
166 /// Add the volume with the specified name and transformation
167 /// to the list of envelopes.
168
169   fConstituents
170     ->Add(new AliMUONGeometryConstituent(
171                      name, copyNo, translation, rotation, 0, 0));
172 }
173
174 //______________________________________________________________________________
175 void  AliMUONGeometryEnvelope::AddConstituent(const TString& name, Int_t copyNo,
176                                           const TGeoCombiTrans& transform )
177 {
178 /// Add the volume with the specified name and transformation
179 /// to the list of envelopes.
180
181   fConstituents
182     ->Add(new AliMUONGeometryConstituent(
183                      name, copyNo, transform, 0, 0));
184 }
185
186 //______________________________________________________________________________
187 void  AliMUONGeometryEnvelope::AddConstituentParam(const TString& name, 
188                                   Int_t copyNo, Int_t npar, Double_t* param) 
189 {
190 /// Add the volume with the specified name and transformation
191 /// to the list of envelopes.
192
193   fConstituents
194     ->Add(new AliMUONGeometryConstituent(name, copyNo, npar, param));
195 }
196
197 //______________________________________________________________________________
198 void  AliMUONGeometryEnvelope::AddConstituentParam(const TString& name, 
199                                   Int_t copyNo, const TGeoTranslation& translation,
200                                   Int_t npar, Double_t* param)
201 {
202 /// Add the volume with the specified name and transformation
203 /// to the list of envelopes.
204
205   fConstituents
206     ->Add(new AliMUONGeometryConstituent(
207                      name, copyNo, translation, npar, param));
208 }
209
210 //______________________________________________________________________________
211 void  AliMUONGeometryEnvelope::AddConstituentParam(const TString& name, 
212                                   Int_t copyNo, const TGeoTranslation& translation,
213                                   const TGeoRotation& rotation, 
214                                   Int_t npar, Double_t* param)
215 {
216 /// Add the volume with the specified name and transformation
217 /// to the list of envelopes.
218
219   fConstituents
220     ->Add(new AliMUONGeometryConstituent(
221                      name, copyNo, translation, rotation, npar, param));
222 }
223
224 //______________________________________________________________________________
225 void  AliMUONGeometryEnvelope::AddConstituentParam(const TString& name, 
226                                   Int_t copyNo, 
227                                   const TGeoCombiTrans& transform, 
228                                   Int_t npar, Double_t* param)
229 {
230 /// Add the volume with the specified name and transformation
231 /// to the list of envelopes.
232
233   fConstituents
234     ->Add(new AliMUONGeometryConstituent(
235                      name, copyNo, transform, npar, param));
236 }
237
238 //______________________________________________________________________________
239 void  AliMUONGeometryEnvelope::SetTranslation(const TGeoTranslation& translation)
240 {
241 /// Set the envelope position
242
243   fTransformation
244     ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
245 }  
246
247 //______________________________________________________________________________
248 void  AliMUONGeometryEnvelope::SetRotation(const TGeoRotation& rotation)
249 {
250 /// Set the enevlope rotation
251
252   TGeoRotation* rot = new TGeoRotation();
253   rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
254
255   fTransformation->SetRotation(rot);
256 }  
257
258 //______________________________________________________________________________
259 void  AliMUONGeometryEnvelope::SetTransform(const TGeoCombiTrans& transform)
260 {
261 // Sets the enevlope transformation
262 // ---
263
264   fTransformation
265     ->SetTranslation(const_cast<Double_t*>(transform.GetTranslation()));
266
267   TGeoRotation* rot = new TGeoRotation();
268   rot->SetMatrix(const_cast<Double_t*>(transform.GetRotationMatrix()));
269
270   fTransformation->SetRotation(rot);
271 }