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,
119 // Adds the volume with the specified name and transformation
120 // to the list of envelopes.
124 cout << "... Adding ";
125 if (!isVirtual) cout << " non-";
126 cout << "virtual envelope " << name << endl;
129 AliMUONGeometryEnvelope* envelope
130 = new AliMUONGeometryEnvelope(name, isVirtual, only);
132 fEnvelopes->Add(envelope);
135 //______________________________________________________________________________
136 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual,
137 const TGeoTranslation& translation,
140 // Adds the volume with the specified name and transformation
141 // to the list of envelopes.
145 cout << "... Adding ";
146 if (!isVirtual) cout << " non-";
147 cout << "virtual envelope " << name
148 << " with translation" << endl;
151 AliMUONGeometryEnvelope* envelope
152 = new AliMUONGeometryEnvelope(name, isVirtual, only);
153 envelope->SetTranslation(translation);
155 fEnvelopes->Add(envelope);
158 //______________________________________________________________________________
159 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Bool_t isVirtual,
160 const TGeoTranslation& translation,
161 const TGeoRotation& rotation,
164 // Adds the volume with the specified name and transformation
165 // to the list of envelopes.
169 cout << "... Adding ";
170 if (!isVirtual) cout << " non-";
171 cout << "virtual envelope " << name
172 << " with translation and rotation" << endl;
175 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
176 // would be nice to be so simple
178 AliMUONGeometryEnvelope* envelope
179 = new AliMUONGeometryEnvelope(name, isVirtual, only);
180 envelope->SetRotation(rotation);
181 envelope->SetTranslation(translation);
183 fEnvelopes->Add(envelope);
186 //______________________________________________________________________________
187 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo,
190 // Adds the volume with the specified name and transformation
191 // to the list of envelopes.
195 cout << "... Adding "
196 << " non-virtual envelope " << name
197 << " with copyNo " << copyNo << endl;
200 AliMUONGeometryEnvelope* envelope
201 = new AliMUONGeometryEnvelope(name, copyNo, only);
203 fEnvelopes->Add(envelope);
206 //______________________________________________________________________________
207 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo,
208 const TGeoTranslation& translation,
211 // Adds the volume with the specified name and transformation
212 // to the list of envelopes.
216 cout << "... Adding "
217 << " non-virtual envelope " << name
218 << " with copyNo " << copyNo
219 << " with translation " << endl;
222 AliMUONGeometryEnvelope* envelope
223 = new AliMUONGeometryEnvelope(name, copyNo, only);
224 envelope->SetTranslation(translation);
226 fEnvelopes->Add(envelope);
229 //______________________________________________________________________________
230 void AliMUONChamberGeometry::AddEnvelope(const TString& name, Int_t copyNo,
231 const TGeoTranslation& translation,
232 const TGeoRotation& rotation,
235 // Adds the volume with the specified name and transformation
236 // to the list of envelopes.
240 cout << "... Adding "
241 << " non-virtual envelope " << name
242 << " with copyNo " << copyNo
243 << " with translation and rotation" << endl;
246 // fEnvelopes->Add(new TGeoCombiTrans(name, translation, rotation));
247 // would be nice to be so simple
249 AliMUONGeometryEnvelope* envelope
250 = new AliMUONGeometryEnvelope(name, copyNo, only);
251 envelope->SetRotation(rotation);
252 envelope->SetTranslation(translation);
254 fEnvelopes->Add(envelope);
257 //______________________________________________________________________________
258 void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name,
259 const TString& envName, Int_t copyNo)
261 // Adds the volume with the specified name and transformation
262 // to the list of envelopes.
266 cout << "... Adding constituent " << name
267 << " to envelope " << envName
268 << " with copyNo " << copyNo << endl;
271 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
278 envelope->AddConstituent(name, copyNo);
281 //______________________________________________________________________________
282 void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name,
283 const TString& envName, Int_t copyNo,
284 const TGeoTranslation& translation)
286 // Adds the volume with the specified name and transformation
287 // to the list of envelopes.
291 cout << "... Adding constituent " << name
292 << " to envelope " << envName
293 << " with copyNo " << copyNo
294 << " with translation" << endl;
297 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
304 envelope->AddConstituent(name, copyNo, translation);
307 //______________________________________________________________________________
308 void AliMUONChamberGeometry::AddEnvelopeConstituent(const TString& name,
309 const TString& envName, Int_t copyNo,
310 const TGeoTranslation& translation,
311 const TGeoRotation& rotation)
313 // Adds the volume with the specified name and transformation
314 // to the list of envelopes.
318 cout << "... Adding constituent " << name
319 << " to envelope " << envName
320 << " with copyNo " << copyNo
321 << " with translation and rotation" << endl;
324 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
331 envelope->AddConstituent(name, copyNo, translation, rotation);
334 //______________________________________________________________________________
335 void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name,
336 const TString& envName, Int_t copyNo,
337 Int_t npar, Double_t* param)
339 // Adds the volume with the specified name and transformation
340 // to the list of envelopes.
344 cout << "... Adding parameterised constituent " << name
345 << " to envelope " << envName
346 << " with copyNo " << copyNo << endl;
349 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
356 envelope->AddConstituentParam(name, copyNo, npar, param);
359 //______________________________________________________________________________
360 void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name,
361 const TString& envName, Int_t copyNo,
362 const TGeoTranslation& translation,
363 Int_t npar, Double_t* param)
365 // Adds the volume with the specified name and transformation
366 // to the list of envelopes.
370 cout << "... Adding parameterised constituent " << name
371 << " to envelope " << envName
372 << " with copyNo " << copyNo
373 << " with translation" << endl;
376 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
383 envelope->AddConstituentParam(name, copyNo, translation, npar, param);
386 //______________________________________________________________________________
387 void AliMUONChamberGeometry::AddEnvelopeConstituentParam(const TString& name,
388 const TString& envName, Int_t copyNo,
389 const TGeoTranslation& translation,
390 const TGeoRotation& rotation,
391 Int_t npar, Double_t* param)
393 // Adds the volume with the specified name and transformation
394 // to the list of envelopes.
398 cout << "... Adding parameterised constituent " << name
399 << " to envelope " << envName
400 << " with copyNo " << copyNo
401 << " with translation and rotation" << endl;
404 AliMUONGeometryEnvelope* envelope = FindEnvelope(envName);
411 envelope->AddConstituentParam(name, copyNo, translation, rotation, npar, param);
414 //______________________________________________________________________________
415 void AliMUONChamberGeometry::SetTranslation(const TGeoTranslation& translation)
417 // Sets the chamber position wrt ALIC.
421 ->SetTranslation(const_cast<Double_t*>(translation.GetTranslation()));
424 //______________________________________________________________________________
425 void AliMUONChamberGeometry::SetRotation(const TGeoRotation& rotation)
427 // Sets the chamber rotation wrt ALIC.
430 TGeoRotation* rot = new TGeoRotation();
431 rot->SetMatrix(const_cast<Double_t*>(rotation.GetRotationMatrix()));
433 fTransformation->SetRotation(rot);
436 //______________________________________________________________________________
437 void AliMUONChamberGeometry::SetSensitiveVolume(Int_t volId)
439 // Adds the volume specified by volId to the list of sensitive
442 fSensVolumeIds->AddAt(volId,fNofSensVolumeIds++);
445 //______________________________________________________________________________
446 void AliMUONChamberGeometry::SetSensitiveVolume(const TString& volName)
448 // Adds the volume specified by volId to the list of sensitive
451 fSensVolumeIds->AddAt(gMC->VolId(volName),fNofSensVolumeIds++);
454 //______________________________________________________________________________
455 Bool_t AliMUONChamberGeometry::IsSensitiveVolume(Int_t volId) const
457 // Checks if the volume specified by volId is present in the list
458 // of sensitive volumes.
460 for (Int_t i=0; i<fNofSensVolumeIds; i++) {
461 if (fSensVolumeIds->At(i) == volId) return kTRUE;