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"
18 ClassImp(AliMUONGeometryTransformStore)
20 const Int_t AliMUONGeometryTransformStore::fgkHemisphere = 50;
22 //______________________________________________________________________________
23 AliMUONGeometryTransformStore::AliMUONGeometryTransformStore(
24 Int_t firstDetElemId, Int_t nofDetElems,
25 AliMUONGeometrySVMap* svMap)
27 fFirstDetElemId(firstDetElemId),
28 fNofDetElems(nofDetElems),
32 // Standard constructor
34 fDETransforms.SetOwner(true);
35 for (Int_t i=0; i<nofDetElems; i++) fDETransforms[i] = 0;
38 //______________________________________________________________________________
39 AliMUONGeometryTransformStore::AliMUONGeometryTransformStore()
46 // Default constructor
49 //______________________________________________________________________________
50 AliMUONGeometryTransformStore::AliMUONGeometryTransformStore(
51 const AliMUONGeometryTransformStore& rhs)
54 AliFatal("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;
70 AliFatal("Assignment operator is not implemented.");
79 //______________________________________________________________________________
80 Int_t AliMUONGeometryTransformStore::GetDetElementIndex(Int_t detElemId) const
82 // Returns the index of detector element specified by detElemId
85 Int_t index = detElemId - fFirstDetElemId;
86 if (index >= fgkHemisphere)
87 index -= fgkHemisphere - fNofDetElems/2;
92 //______________________________________________________________________________
93 Int_t AliMUONGeometryTransformStore::GetDetElementId(Int_t detElemIndex) const
95 // Returns the ID of detector element specified by index
98 Int_t detElemId = detElemIndex;
100 if (detElemIndex >= fNofDetElems/2)
101 detElemId += fgkHemisphere - fNofDetElems/2;
103 detElemId += fFirstDetElemId;
113 //______________________________________________________________________________
114 void AliMUONGeometryTransformStore::Add(Int_t detElemId,
115 const TString& alignedVolume,
116 const TGeoCombiTrans& transform)
118 // Add transformation specified by alignedVolume in the array
119 // if this alignedVolume is not yet present.
122 TGeoCombiTrans* newTransform = new TGeoCombiTrans(transform);
123 newTransform->SetName(alignedVolume);
125 //cout << ".. adding " << detElemId
126 // << " index: " << GetDetElementIndex(detElemId) << endl;
129 if ( !Get(detElemId)) {
131 newTransform->SetUniqueID(detElemId);
132 // Set detector element id as unique id
134 fDETransforms.AddAt(newTransform, GetDetElementIndex(detElemId));
137 AliWarning(Form("The aligned volume %s is already present",
138 alignedVolume.Data()));
141 //______________________________________________________________________________
142 void AliMUONGeometryTransformStore::Print(Option_t* /*option*/) const
144 // Prints the detector elements transformations
147 for (Int_t i=0; i<fDETransforms.GetEntriesFast(); i++) {
149 cout << "DetElemId: " << GetDetElementId(i);
151 TGeoCombiTrans* matrix = (TGeoCombiTrans*)fDETransforms.At(i);
152 cout << " name: " << matrix->GetName() << endl;
154 const double* translation = matrix->GetTranslation();
155 cout << " translation: "
156 #if defined (__DECCXX)
157 << translation[0] << ", "
158 << translation[1] << ", "
159 << translation[2] << endl;
162 << std::setw(7) << std::setprecision(4) << translation[0] << ", "
163 << std::setw(7) << std::setprecision(4) << translation[1] << ", "
164 << std::setw(7) << std::setprecision(4) << translation[2] << endl;
167 const double* rotation = matrix->GetRotationMatrix();
168 cout << " rotation matrix: "
169 #if defined (__DECCXX)
170 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
172 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
174 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
177 << std::setw(7) << std::setprecision(4)
178 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
180 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
182 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
187 //______________________________________________________________________________
188 const TGeoCombiTrans*
189 AliMUONGeometryTransformStore::Get(Int_t detElemId) const
191 // Returns transformation for the specified detector element Id
194 Int_t index = GetDetElementIndex(detElemId);
196 if ( index >= 0 && index < fNofDetElems )
197 return (const TGeoCombiTrans*)fDETransforms.At(index);
199 AliWarning(Form("Index %d out of limits", index));
204 //______________________________________________________________________________
205 const TGeoCombiTrans*
206 AliMUONGeometryTransformStore::FindBySensitiveVolume(const TString& sensVolume) const
208 // Finds TGeoCombiTrans for the detector element Id specified by aligned volume
211 Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
213 if (!detElemId) return 0;
214 // The specified sensitive volume is not in the map
216 return Get(detElemId);