3 // Class AliMUONGeometryTransformStore
4 // ------------------------------------
5 // The class provides the array of transformations of the detection elements
6 // from a defined reference frame to the detection element frame.
7 // (See more in the header file.)
9 // Author: Ivana Hrivnacova, IPN Orsay
11 #include <Riostream.h>
12 #include <TGeoMatrix.h>
13 #include <TObjString.h>
15 #include "AliMUONGeometryTransformStore.h"
17 ClassImp(AliMUONGeometryTransformStore)
19 const Int_t AliMUONGeometryTransformStore::fgkHemisphere = 50;
21 //______________________________________________________________________________
22 AliMUONGeometryTransformStore::AliMUONGeometryTransformStore(
23 Int_t firstDetElemId, Int_t nofDetElems,
24 AliMUONGeometrySVMap* svMap)
26 fFirstDetElemId(firstDetElemId),
27 fNofDetElems(nofDetElems),
31 // Standard constructor
33 fDETransforms.SetOwner(true);
34 for (Int_t i=0; i<nofDetElems; i++) fDETransforms[i] = 0;
37 //______________________________________________________________________________
38 AliMUONGeometryTransformStore::AliMUONGeometryTransformStore()
45 // Default constructor
48 //______________________________________________________________________________
49 AliMUONGeometryTransformStore::AliMUONGeometryTransformStore(
50 const AliMUONGeometryTransformStore& rhs)
53 Fatal("Copy constructor",
54 "Copy constructor is not implemented.");
57 //______________________________________________________________________________
58 AliMUONGeometryTransformStore::~AliMUONGeometryTransformStore() {
60 fDETransforms.Delete();
63 //______________________________________________________________________________
64 AliMUONGeometryTransformStore&
65 AliMUONGeometryTransformStore::operator = (const AliMUONGeometryTransformStore& rhs)
67 // check assignement to self
68 if (this == &rhs) return *this;
71 "Assignment operator is not implemented.");
80 //______________________________________________________________________________
81 Int_t AliMUONGeometryTransformStore::GetDetElementIndex(Int_t detElemId) const
83 // Returns the index of detector element specified by detElemId
86 Int_t index = detElemId - fFirstDetElemId;
87 if (index >= fgkHemisphere)
88 index -= fgkHemisphere - fNofDetElems/2;
93 //______________________________________________________________________________
94 Int_t AliMUONGeometryTransformStore::GetDetElementId(Int_t detElemIndex) const
96 // Returns the ID of detector element specified by index
99 Int_t detElemId = detElemIndex;
101 if (detElemIndex >= fNofDetElems/2)
102 detElemId += fgkHemisphere - fNofDetElems/2;
104 detElemId += fFirstDetElemId;
114 //______________________________________________________________________________
115 void AliMUONGeometryTransformStore::Add(Int_t detElemId,
116 const TString& alignedVolume,
117 const TGeoCombiTrans& transform)
119 // Add transformation specified by alignedVolume in the array
120 // if this alignedVolume is not yet present.
123 TGeoCombiTrans* newTransform = new TGeoCombiTrans(transform);
124 newTransform->SetName(alignedVolume);
126 //cout << ".. adding " << detElemId
127 // << " index: " << GetDetElementIndex(detElemId) << endl;
130 if ( !Get(detElemId)) {
132 newTransform->SetUniqueID(detElemId);
133 // Set detector element id as unique id
135 fDETransforms.AddAt(newTransform, GetDetElementIndex(detElemId));
138 Warning("Add", "The aligned volume %s is already present",
139 alignedVolume.Data());
142 //______________________________________________________________________________
143 void AliMUONGeometryTransformStore::Print(Option_t* /*option*/) const
145 // Prints the detector elements transformations
148 for (Int_t i=0; i<fDETransforms.GetEntriesFast(); i++) {
150 cout << "DetElemId: " << GetDetElementId(i);
152 TGeoCombiTrans* matrix = (TGeoCombiTrans*)fDETransforms.At(i);
153 cout << " name: " << matrix->GetName() << endl;
155 const double* translation = matrix->GetTranslation();
156 cout << " translation: "
158 << std::setw(7) << std::setprecision(4) << translation[0] << ", "
159 << std::setw(7) << std::setprecision(4) << translation[1] << ", "
160 << std::setw(7) << std::setprecision(4) << translation[2] << endl;
162 const double* rotation = matrix->GetRotationMatrix();
163 cout << " rotation matrix: "
165 << std::setw(7) << std::setprecision(4)
166 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
168 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
170 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
175 //______________________________________________________________________________
176 const TGeoCombiTrans*
177 AliMUONGeometryTransformStore::Get(Int_t detElemId) const
179 // Returns transformation for the specified detector element Id
182 Int_t index = GetDetElementIndex(detElemId);
184 if ( index >= 0 && index < fNofDetElems )
185 return (const TGeoCombiTrans*)fDETransforms.At(index);
187 Warning("Get","Index %d out of limits", index);
192 //______________________________________________________________________________
193 const TGeoCombiTrans*
194 AliMUONGeometryTransformStore::FindBySensitiveVolume(const TString& sensVolume) const
196 // Finds TGeoCombiTrans for the detector element Id specified by aligned volume
199 Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
201 if (!detElemId) return 0;
202 // The specified sensitive volume is not in the map
204 return Get(detElemId);