]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometryTransformStore.cxx
Logging of Debug, Info and Error Messages follwing AliRoot Standard http://aliweb...
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryTransformStore.cxx
CommitLineData
89cc3034 1// $Id$
2//
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.)
8//
9// Author: Ivana Hrivnacova, IPN Orsay
10
11#include <Riostream.h>
12#include <TGeoMatrix.h>
13#include <TObjString.h>
14
15#include "AliMUONGeometryTransformStore.h"
8c343c7c 16#include "AliLog.h"
89cc3034 17
18ClassImp(AliMUONGeometryTransformStore)
19
20const Int_t AliMUONGeometryTransformStore::fgkHemisphere = 50;
21
22//______________________________________________________________________________
23AliMUONGeometryTransformStore::AliMUONGeometryTransformStore(
24 Int_t firstDetElemId, Int_t nofDetElems,
25 AliMUONGeometrySVMap* svMap)
26 : TObject(),
27 fFirstDetElemId(firstDetElemId),
28 fNofDetElems(nofDetElems),
29 fDETransforms(100),
30 fSVMap(svMap)
31{
32// Standard constructor
33
34 fDETransforms.SetOwner(true);
35 for (Int_t i=0; i<nofDetElems; i++) fDETransforms[i] = 0;
36}
37
38//______________________________________________________________________________
39AliMUONGeometryTransformStore::AliMUONGeometryTransformStore()
40 : TObject(),
41 fFirstDetElemId(0),
42 fNofDetElems(0),
43 fDETransforms(),
44 fSVMap(0)
45{
46// Default constructor
47}
48
49//______________________________________________________________________________
50AliMUONGeometryTransformStore::AliMUONGeometryTransformStore(
51 const AliMUONGeometryTransformStore& rhs)
52 : TObject(rhs)
53{
8c343c7c 54 AliFatal("Copy constructor is not implemented.");
89cc3034 55}
56
57//______________________________________________________________________________
58AliMUONGeometryTransformStore::~AliMUONGeometryTransformStore() {
59//
60 fDETransforms.Delete();
61}
62
63//______________________________________________________________________________
64AliMUONGeometryTransformStore&
65AliMUONGeometryTransformStore::operator = (const AliMUONGeometryTransformStore& rhs)
66{
67 // check assignement to self
68 if (this == &rhs) return *this;
69
8c343c7c 70 AliFatal("Assignment operator is not implemented.");
89cc3034 71
72 return *this;
73}
74
75//
76// private methods
77//
78
79//______________________________________________________________________________
80Int_t AliMUONGeometryTransformStore::GetDetElementIndex(Int_t detElemId) const
81{
82// Returns the index of detector element specified by detElemId
83// ---
84
85 Int_t index = detElemId - fFirstDetElemId;
86 if (index >= fgkHemisphere)
87 index -= fgkHemisphere - fNofDetElems/2;
88
89 return index;
90}
91
92//______________________________________________________________________________
93Int_t AliMUONGeometryTransformStore::GetDetElementId(Int_t detElemIndex) const
94{
95// Returns the ID of detector element specified by index
96// ---
97
98 Int_t detElemId = detElemIndex;
99
100 if (detElemIndex >= fNofDetElems/2)
101 detElemId += fgkHemisphere - fNofDetElems/2;
102
103 detElemId += fFirstDetElemId;
104
105 return detElemId;
106}
107
108
109//
110// public methods
111//
112
113//______________________________________________________________________________
114void AliMUONGeometryTransformStore::Add(Int_t detElemId,
115 const TString& alignedVolume,
116 const TGeoCombiTrans& transform)
117{
118// Add transformation specified by alignedVolume in the array
119// if this alignedVolume is not yet present.
120// ---
121
122 TGeoCombiTrans* newTransform = new TGeoCombiTrans(transform);
123 newTransform->SetName(alignedVolume);
124
125 //cout << ".. adding " << detElemId
126 // << " index: " << GetDetElementIndex(detElemId) << endl;
127
128 // Add to the map
129 if ( !Get(detElemId)) {
130
131 newTransform->SetUniqueID(detElemId);
132 // Set detector element id as unique id
133
134 fDETransforms.AddAt(newTransform, GetDetElementIndex(detElemId));
135 }
136 else
8c343c7c 137 AliWarning(Form("The aligned volume %s is already present",
138 alignedVolume.Data()));
89cc3034 139}
140
141//______________________________________________________________________________
142void AliMUONGeometryTransformStore::Print(Option_t* /*option*/) const
143{
144// Prints the detector elements transformations
145// ---
146
147 for (Int_t i=0; i<fDETransforms.GetEntriesFast(); i++) {
148
149 cout << "DetElemId: " << GetDetElementId(i);
150
151 TGeoCombiTrans* matrix = (TGeoCombiTrans*)fDETransforms.At(i);
152 cout << " name: " << matrix->GetName() << endl;
153
154 const double* translation = matrix->GetTranslation();
155 cout << " translation: "
e516b01d 156#if defined (__DECCXX)
157 << translation[0] << ", "
158 << translation[1] << ", "
159 << translation[2] << endl;
160#else
89cc3034 161 << std::fixed
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;
e516b01d 165#endif
89cc3034 166
167 const double* rotation = matrix->GetRotationMatrix();
168 cout << " rotation matrix: "
e516b01d 169#if defined (__DECCXX)
170 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
171 << " "
172 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
173 << " "
174 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
175#else
89cc3034 176 << std::fixed
177 << std::setw(7) << std::setprecision(4)
178 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
179 << " "
180 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
181 << " "
182 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
e516b01d 183#endif
89cc3034 184 }
185}
186
187//______________________________________________________________________________
188const TGeoCombiTrans*
189AliMUONGeometryTransformStore::Get(Int_t detElemId) const
190{
191// Returns transformation for the specified detector element Id
192// ---
193
194 Int_t index = GetDetElementIndex(detElemId);
195
196 if ( index >= 0 && index < fNofDetElems )
197 return (const TGeoCombiTrans*)fDETransforms.At(index);
198 else {
8c343c7c 199 AliWarning(Form("Index %d out of limits", index));
89cc3034 200 return 0;
201 }
202}
203
204//______________________________________________________________________________
205const TGeoCombiTrans*
206AliMUONGeometryTransformStore::FindBySensitiveVolume(const TString& sensVolume) const
207{
208// Finds TGeoCombiTrans for the detector element Id specified by aligned volume
209// ---
210
211 Int_t detElemId = fSVMap->GetDetElemId(sensVolume);
212
213 if (!detElemId) return 0;
214 // The specified sensitive volume is not in the map
215
216 return Get(detElemId);
217}
218