]>
Commit | Line | Data |
---|---|---|
87594435 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | //------------------------------------------------------------------------- | |
75fb37cc | 17 | // Class AliCluster |
18 | // This is the future base for managing the clusters in barrel detectors. | |
19 | // It is fully interfaced with the ROOT geometrical modeller TGeo. | |
20 | // Each cluster contains XYZ coordinates in the local tracking c.s. and | |
21 | // the unique ID of the sensitive detector element which continas the | |
22 | // cluster. The coordinates in global c.s. are computed using the interface | |
23 | // to TGeo and will be not overwritten by the derived sub-detector cluster | |
24 | // classes. | |
25 | // | |
26 | // cvetan.cheshkov@cern.ch & jouri.belikov@cern.ch 5/3/2007 | |
87594435 | 27 | //------------------------------------------------------------------------- |
28 | ||
75fb37cc | 29 | #include <TGeoManager.h> |
30 | #include <TGeoMatrix.h> | |
31 | #include <TGeoPhysicalNode.h> | |
32 | ||
87594435 | 33 | #include "AliCluster.h" |
75fb37cc | 34 | #include "AliLog.h" |
35 | #include "AliAlignObj.h" | |
87594435 | 36 | |
37 | ClassImp(AliCluster) | |
75fb37cc | 38 | |
39 | //______________________________________________________________________________ | |
40 | AliCluster::AliCluster(): | |
41 | TObject(), | |
42 | fX(0), | |
43 | fY(0), | |
44 | fZ(0), | |
45 | fSigmaY2(0), | |
46 | fSigmaZ2(0), | |
47 | fSigmaYZ(0), | |
48 | fVolumeId(0), | |
49 | fIsMisaligned(kFALSE) | |
50 | { | |
51 | // Default constructor | |
87594435 | 52 | fTracks[0]=fTracks[1]=fTracks[2]=-3141593; |
87594435 | 53 | } |
54 | ||
75fb37cc | 55 | //______________________________________________________________________________ |
56 | AliCluster::AliCluster(UShort_t volId, | |
57 | const Float_t *hit, | |
58 | Float_t x, | |
59 | Float_t sigyz, | |
60 | const Int_t *lab): | |
61 | TObject(), | |
62 | fX(x), | |
63 | fY(hit[0]), | |
64 | fZ(hit[1]), | |
65 | fSigmaY2(hit[2]), | |
66 | fSigmaZ2(hit[3]), | |
67 | fSigmaYZ(sigyz), | |
68 | fVolumeId(volId), | |
69 | fIsMisaligned(kFALSE) | |
968c248e | 70 | { |
75fb37cc | 71 | // Constructor |
72 | if (lab) { | |
73 | fTracks[0] = lab[0]; | |
74 | fTracks[1] = lab[1]; | |
75 | fTracks[2] = lab[2]; | |
76 | } | |
77 | else | |
78 | fTracks[0]=fTracks[1]=fTracks[2]=-3141593; | |
79 | } | |
80 | ||
81 | //______________________________________________________________________________ | |
82 | AliCluster::AliCluster(UShort_t volId, | |
83 | Float_t x, Float_t y, Float_t z, | |
84 | Float_t sy2, Float_t sz2, Float_t syz, | |
85 | const Int_t *lab): | |
86 | TObject(), | |
87 | fX(x), | |
88 | fY(y), | |
89 | fZ(z), | |
90 | fSigmaY2(sy2), | |
91 | fSigmaZ2(sz2), | |
92 | fSigmaYZ(syz), | |
93 | fVolumeId(volId), | |
94 | fIsMisaligned(kFALSE) | |
95 | { | |
96 | // Constructor | |
97 | if (lab) { | |
98 | fTracks[0] = lab[0]; | |
99 | fTracks[1] = lab[1]; | |
100 | fTracks[2] = lab[2]; | |
101 | } | |
102 | else | |
103 | fTracks[0]=fTracks[1]=fTracks[2]=-3141593; | |
104 | } | |
105 | ||
106 | //______________________________________________________________________________ | |
107 | AliCluster::AliCluster(const AliCluster& cluster): | |
108 | TObject(cluster), | |
109 | fX(cluster.fX), | |
110 | fY(cluster.fY), | |
111 | fZ(cluster.fZ), | |
112 | fSigmaY2(cluster.fSigmaY2), | |
113 | fSigmaZ2(cluster.fSigmaZ2), | |
114 | fSigmaYZ(cluster.fSigmaYZ), | |
115 | fVolumeId(cluster.fVolumeId), | |
116 | fIsMisaligned(cluster.fIsMisaligned) | |
117 | { | |
118 | // Copy constructor | |
119 | fTracks[0] = cluster.fTracks[0]; | |
120 | fTracks[1] = cluster.fTracks[1]; | |
121 | fTracks[2] = cluster.fTracks[2]; | |
122 | } | |
123 | ||
124 | //______________________________________________________________________________ | |
125 | AliCluster & AliCluster::operator=(const AliCluster& cluster) | |
126 | { | |
127 | // Assignment operator | |
128 | ||
129 | if(&cluster == this) return *this; | |
130 | ||
131 | fX = cluster.fX; | |
132 | fY = cluster.fY; | |
133 | fZ = cluster.fZ; | |
134 | fSigmaY2 = cluster.fSigmaY2; | |
135 | fSigmaZ2 = cluster.fSigmaZ2; | |
136 | fSigmaYZ = cluster.fSigmaYZ; | |
137 | fVolumeId = cluster.fVolumeId; | |
138 | fIsMisaligned = cluster.fIsMisaligned; | |
139 | ||
140 | fTracks[0] = cluster.fTracks[0]; | |
141 | fTracks[1] = cluster.fTracks[1]; | |
142 | fTracks[2] = cluster.fTracks[2]; | |
143 | ||
144 | return *this; | |
145 | } | |
146 | ||
147 | //______________________________________________________________________________ | |
148 | Bool_t AliCluster::GetGlobalXYZ(Float_t xyz[3]) const | |
149 | { | |
150 | // Get the global coordinates of the cluster | |
151 | // All the needed information is taken only | |
152 | // from TGeo. | |
153 | ||
154 | xyz[0] = xyz[1] = xyz[2] = 0; | |
155 | ||
156 | if (!gGeoManager || !gGeoManager->IsClosed()) { | |
157 | AliError("Can't get the global coordinates! gGeoManager doesn't exist or it is still opened!"); | |
158 | return kFALSE; | |
159 | } | |
160 | ||
161 | const TGeoHMatrix *mt = GetTracking2LocalMatrix(); | |
162 | if (!mt) return kFALSE; | |
163 | Double_t txyz[3] = {fX, fY, fZ}; | |
164 | Double_t lxyz[3] = {0, 0, 0}; | |
165 | mt->LocalToMaster(txyz,lxyz); | |
166 | ||
167 | TGeoHMatrix *ml = GetMatrix(); | |
168 | if (!ml) return kFALSE; | |
169 | Double_t gxyz[3] = {0, 0, 0}; | |
170 | ml->LocalToMaster(lxyz,gxyz); | |
171 | xyz[0] = gxyz[0]; xyz[1] = gxyz[1]; xyz[2] = gxyz[2]; | |
172 | return kTRUE; | |
173 | } | |
174 | ||
175 | //______________________________________________________________________________ | |
176 | Bool_t AliCluster::GetGlobalCov(Float_t cov[6]) const | |
177 | { | |
178 | // Get the global covariance matrix of the cluster coordinates | |
179 | // All the needed information is taken only | |
180 | // from TGeo. | |
181 | for (Int_t i = 0; i < 6; i++) cov[i] = 0; | |
182 | ||
183 | if (!gGeoManager || !gGeoManager->IsClosed()) { | |
184 | AliError("Can't get the global coordinates! gGeoManager doesn't exist or it is still opened!"); | |
185 | return kFALSE; | |
186 | } | |
187 | ||
188 | const TGeoHMatrix *mt = GetTracking2LocalMatrix(); | |
189 | if (!mt) return kFALSE; | |
190 | ||
191 | TGeoHMatrix *ml = GetMatrix(); | |
192 | if (!ml) return kFALSE; | |
193 | ||
194 | TGeoHMatrix m; | |
195 | Double_t tcov[9] = { 0, 0, 0, 0, fSigmaY2, fSigmaYZ, 0, fSigmaYZ, fSigmaZ2 }; | |
196 | m.SetRotation(tcov); | |
197 | m.Multiply(&mt->Inverse()); | |
198 | m.Multiply(&ml->Inverse()); | |
199 | m.MultiplyLeft(mt); | |
200 | m.MultiplyLeft(ml); | |
201 | Double_t *ncov = m.GetRotationMatrix(); | |
202 | cov[0] = ncov[0]; cov[1] = ncov[1]; cov[2] = ncov[2]; | |
203 | cov[3] = ncov[4]; cov[4] = ncov[5]; | |
204 | cov[5] = ncov[8]; | |
205 | ||
206 | return kTRUE; | |
207 | } | |
208 | ||
209 | //______________________________________________________________________________ | |
210 | Bool_t AliCluster::GetXRefPlane(Float_t &xref) const | |
211 | { | |
212 | // Get the distance between the origin and the ref.plane. | |
213 | // All the needed information is taken only | |
214 | // from TGeo. | |
215 | xref = 0; | |
216 | ||
217 | const TGeoHMatrix *mt = GetTracking2LocalMatrix(); | |
218 | if (!mt) return kFALSE; | |
219 | ||
220 | TGeoHMatrix *ml = GetMatrix(); | |
221 | if (!ml) return kFALSE; | |
222 | ||
223 | TGeoHMatrix m = *mt; | |
224 | m.MultiplyLeft(ml); | |
225 | ||
226 | xref = (m.Inverse()).GetTranslation()[0]; | |
227 | return kTRUE; | |
228 | } | |
229 | ||
230 | //______________________________________________________________________________ | |
231 | Bool_t AliCluster::Misalign() | |
232 | { | |
233 | // ... | |
234 | // All the needed information is taken only | |
235 | // from TGeo. | |
236 | if (!gGeoManager || !gGeoManager->IsClosed()) { | |
237 | AliError("Can't get the PN entry! gGeoManager doesn't exist or it is still opened!"); | |
238 | return kFALSE; | |
239 | } | |
240 | ||
241 | if (fIsMisaligned) { | |
242 | AliError("The cluster was already misaligned!"); | |
243 | return kFALSE; | |
244 | } | |
245 | ||
246 | const TGeoHMatrix *mt = GetTracking2LocalMatrix(); | |
247 | if (!mt) return kFALSE; | |
248 | ||
249 | TGeoHMatrix *ml = GetMatrix(); | |
250 | if (!ml) return kFALSE; | |
251 | ||
252 | TGeoHMatrix *mlorig = GetMatrix(kTRUE); | |
253 | if (!mlorig) return kFALSE; | |
254 | ||
255 | TGeoHMatrix delta = *mt; | |
256 | delta.MultiplyLeft(ml); | |
257 | delta.MultiplyLeft(&(mlorig->Inverse())); | |
258 | delta.MultiplyLeft(&(mt->Inverse())); | |
259 | ||
260 | Double_t xyzorig[3] = {fX, fY, fZ}; | |
261 | Double_t xyz[3] = {0, 0, 0}; | |
262 | delta.LocalToMaster(xyzorig,xyz); | |
263 | fX = xyz[0]; fY = xyz[1]; fZ = xyz[2]; | |
264 | fIsMisaligned = kTRUE; | |
265 | return kTRUE; | |
266 | } | |
267 | ||
268 | //______________________________________________________________________________ | |
269 | TGeoHMatrix* AliCluster::GetMatrix(Bool_t original) const | |
270 | { | |
271 | // Get the matrix which transforms from the | |
272 | // local TGeo alignable volume c.s. to the global one. | |
273 | // In case the cluster was already misaligned, get the | |
274 | // ideal matrix from TGeo. The option 'original' | |
275 | // can be used to force the calculation of the ideal | |
276 | // matrix. | |
277 | if (!fIsMisaligned && (original == kFALSE)) { | |
b63e594f | 278 | return AliGeomManager::GetMatrix(fVolumeId); |
75fb37cc | 279 | } |
280 | else { | |
b63e594f | 281 | return AliGeomManager::GetOrigGlobalMatrix(fVolumeId); |
75fb37cc | 282 | } |
283 | } | |
284 | ||
285 | //______________________________________________________________________________ | |
286 | const TGeoHMatrix* AliCluster::GetTracking2LocalMatrix() const | |
287 | { | |
288 | // Get the matrix which is stored with the PN entries in TGeo. | |
289 | // The matrix makes the transformation from the tracking c.s. to | |
559157f8 | 290 | // the local one. |
b63e594f | 291 | return AliGeomManager::GetTracking2LocalMatrix(fVolumeId); |
75fb37cc | 292 | } |
293 |