3 // Class AliMUONChamberGeometry
4 // -----------------------------
5 // Class for definititon of the MUON chamber positions in ALIC.
7 // Author: Ivana Hrivnacova, IPN Orsay
9 #include <TVirtualMC.h>
10 #include <TGeoMatrix.h>
11 #include <TObjArray.h>
13 #include <Riostream.h>
15 #include "AliMUONChamberGeometry.h"
16 #include "AliMUONGeometryEnvelope.h"
18 ClassImp(AliMUONChamberGeometry)
20 //______________________________________________________________________________
21 AliMUONChamberGeometry::AliMUONChamberGeometry(Int_t chamberId)
23 fChamberId(chamberId),
24 fMotherVolume("ALIC"),
31 // Standard constructor
33 // Create the chamber transformation
34 fTransformation = new TGeoCombiTrans("");
35 fEnvelopes = new TObjArray(20);
36 fSensVolumeIds = new TArrayI(20);
40 //______________________________________________________________________________
41 AliMUONChamberGeometry::AliMUONChamberGeometry()
51 // Default constructor
55 //______________________________________________________________________________
56 AliMUONChamberGeometry::AliMUONChamberGeometry(const AliMUONChamberGeometry& rhs)
59 Fatal("Copy constructor",
60 "Copy constructor is not implemented.");
63 //______________________________________________________________________________
64 AliMUONChamberGeometry::~AliMUONChamberGeometry() {
67 // Add deleting rotation matrices
69 delete fTransformation;
77 //______________________________________________________________________________
78 AliMUONChamberGeometry&
79 AliMUONChamberGeometry::operator = (const AliMUONChamberGeometry& rhs)
81 // check assignement to self
82 if (this == &rhs) return *this;
85 "Assignment operator is not implemented.");
94 //______________________________________________________________________________
95 AliMUONGeometryEnvelope*
96 AliMUONChamberGeometry::FindEnvelope(const TString& name) const
98 // Finds the envelope specified by name.
101 for (Int_t i=0; i<fEnvelopes->GetEntriesFast(); i++) {
102 AliMUONGeometryEnvelope* envelope
103 = (AliMUONGeometryEnvelope*)fEnvelopes->At(i);
105 if (envelope->GetName() == name) return envelope;
115 //______________________________________________________________________________
116 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual)
118 // Adds the volume with the specified name and transformation
119 // to the list of envelopes.
123 cout << "... Adding ";
124 if (!isVirtual) cout << " non-";
125 cout << "virtual envelope " << name << endl;
128 AliMUONGeometryEnvelope* envelope
129 = new AliMUONGeometryEnvelope(name, isVirtual);
131 fEnvelopes->Add(envelope);
134 //______________________________________________________________________________
135 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual,
136 const TGeoTranslation& translation)
138 // Adds the volume with the specified name and transformation
139 // to the list of envelopes.
143 cout << "... Adding ";
144 if (!isVirtual) cout << " non-";
145 cout << "virtual envelope " << name
146 << " with translation" << endl;
149 AliMUONGeometryEnvelope* envelope
150 = new AliMUONGeometryEnvelope(name, isVirtual);
151 envelope->SetTranslation(translation);
153 fEnvelopes->Add(envelope);
156 //______________________________________________________________________________
157 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual,
158 const TGeoTranslation& translation,
159 const TGeoRotation& rotation)
161 // Adds the volume with the specified name and transformation
162 // to the list of envelopes.
166 cout << "... Adding ";
167 if (!isVirtual) cout << " non-";
168 cout << "virtual envelope " << name
169 << " with translation and rotation" << endl;
172 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
173 // would be nice to be so simple
175 AliMUONGeometryEnvelope* envelope
176 = new AliMUONGeometryEnvelope(name, isVirtual);
177 envelope->SetRotation(rotation);
178 envelope->SetTranslation(translation);
180 fEnvelopes->Add(envelope);
183 //______________________________________________________________________________
184 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo)
186 // Adds the volume with the specified name and transformation
187 // to the list of envelopes.
191 cout << "... Adding "
192 << " non-virtual envelope " << name
193 << " with copyNo " << copyNo << endl;
196 AliMUONGeometryEnvelope* envelope
197 = new AliMUONGeometryEnvelope(name, copyNo);
199 fEnvelopes->Add(envelope);
202 //______________________________________________________________________________
203 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo,
204 const TGeoTranslation& translation)
206 // Adds the volume with the specified name and transformation
207 // to the list of envelopes.
211 cout << "... Adding "
212 << " non-virtual envelope " << name
213 << " with copyNo " << copyNo
214 << " with translation " << endl;
217 AliMUONGeometryEnvelope* envelope
218 = new AliMUONGeometryEnvelope(name, copyNo);
219 envelope->SetTranslation(translation);
221 fEnvelopes->Add(envelope);
224 //______________________________________________________________________________
225 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo,
226 const TGeoTranslation& translation,
227 const TGeoRotation& rotation)
229 // Adds the volume with the specified name and transformation
230 // to the list of envelopes.
234 cout << "... Adding "
235 << " non-virtual envelope " << name
236 << " with copyNo " << copyNo
237 << " with translation and rotation" << endl;
240 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
241 // would be nice to be so simple
243 AliMUONGeometryEnvelope* envelope
244 = new AliMUONGeometryEnvelope(name, copyNo);
245 envelope->SetRotation(rotation);
246 envelope->SetTranslation(translation);
248 fEnvelopes->Add(envelope);
251 //______________________________________________________________________________
252 void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name,
253 const TString& envName, Int_t copyNo)
255 // Adds the volume with the specified name and transformation
256 // to the list of envelopes.
260 cout << "... Adding constituent " << name
261 << " to envelope " << envName
262 << " with copyNo " << copyNo << endl;
265 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
272 envelope->AddConstituent(name, copyNo);
275 //______________________________________________________________________________
276 void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name,
277 const TString& envName, Int_t copyNo,
278 const TGeoTranslation& translation)
280 // Adds the volume with the specified name and transformation
281 // to the list of envelopes.
285 cout << "... Adding constituent " << name
286 << " to envelope " << envName
287 << " with copyNo " << copyNo
288 << " with translation" << endl;
291 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
298 envelope->AddConstituent(name, copyNo, translation);
301 //______________________________________________________________________________
302 void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name,
303 const TString& envName, Int_t copyNo,
304 const TGeoTranslation& translation,
305 const TGeoRotation& rotation)
307 // Adds the volume with the specified name and transformation
308 // to the list of envelopes.
312 cout << "... Adding constituent " << name
313 << " to envelope " << envName
314 << " with copyNo " << copyNo
315 << " with translation and rotation" << endl;
318 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
325 envelope->AddConstituent(name, copyNo, translation, rotation);
328 //______________________________________________________________________________
329 void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name,
330 const TString& envName, Int_t copyNo,
331 Int_t npar, Double_t* param)
333 // Adds the volume with the specified name and transformation
334 // to the list of envelopes.
338 cout << "... Adding parameterised constituent " << name
339 << " to envelope " << envName
340 << " with copyNo " << copyNo << endl;
343 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
350 envelope->AddConstituentParam(name, copyNo, npar, param);
353 //______________________________________________________________________________
354 void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name,
355 const TString& envName, Int_t copyNo,
356 const TGeoTranslation& translation,
357 Int_t npar, Double_t* param)
359 // Adds the volume with the specified name and transformation
360 // to the list of envelopes.
364 cout << "... Adding parameterised constituent " << name
365 << " to envelope " << envName
366 << " with copyNo " << copyNo
367 << " with translation" << endl;
370 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
377 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
380 //______________________________________________________________________________
381 void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name,
382 const TString& envName, Int_t copyNo,
383 const TGeoTranslation& translation,
384 const TGeoRotation& rotation,
385 Int_t npar, Double_t* param)
387 // Adds the volume with the specified name and transformation
388 // to the list of envelopes.
392 cout << "... Adding parameterised constituent " << name
393 << " to envelope " << envName
394 << " with copyNo " << copyNo
395 << " with translation and rotation" << endl;
398 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
405 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
408 //______________________________________________________________________________
409 void AliMUONChamberGeometry::SetTranslation(const TGeoTranslation& translation)
411 // Sets the chamber position wrt ALIC.
415 ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
418 //______________________________________________________________________________
419 void AliMUONChamberGeometry::SetRotation(const TGeoRotation& rotation)
421 // Sets the chamber rotation wrt ALIC.
424 TGeoRotation* rot = new TGeoRotation();
425 rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
427 fTransformation->SetRotation(rot);
430 //______________________________________________________________________________
431 void AliMUONChamberGeometry::SetSensitiveVolume(Int_t volId)
433 // Adds the volume specified by volId to the list of sensitive
436 fSensVolumeIds->AddAt(volId,fNofSensVolumeIds++);
439 //______________________________________________________________________________
440 void AliMUONChamberGeometry::SetSensitiveVolume(const TString& volName)
442 // Adds the volume specified by volId to the list of sensitive
445 fSensVolumeIds->AddAt(gMC->VolId(volName),fNofSensVolumeIds++);
448 //______________________________________________________________________________
449 Bool_t AliMUONChamberGeometry::IsSensitiveVolume(Int_t volId) const
451 // Checks if the volume specified by volId is present in the list
452 // of sensitive volumes.
454 for (Int_t i=0; i<fNofSensVolumeIds; i++) {
455 if (fSensVolumeIds->At(i) == volId) return kTRUE;