]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUClusterPix.cxx
Added new class AliITSUClusterPix. Clusters are stored in local frame,
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUClusterPix.cxx
CommitLineData
5e375bb4 1#include "AliITSUClusterPix.h"
2#include "AliITSUGeomTGeo.h"
3#include "AliLog.h"
4#include <TGeoMatrix.h>
5#include <TMath.h>
6using namespace TMath;
7
8ClassImp(AliITSUClusterPix)
9
10AliITSUGeomTGeo* AliITSUClusterPix::fgGeom = 0;
11UInt_t AliITSUClusterPix::fgMode = 0;
12
13//_____________________________________________________
14AliITSUClusterPix::AliITSUClusterPix()
15 : fNxNz(0)
16{
17 // default constructor
18}
19
20//_____________________________________________________
21AliITSUClusterPix::~AliITSUClusterPix()
22{
23 // default destructor
24}
25
26//_____________________________________________________
27AliITSUClusterPix::AliITSUClusterPix(const AliITSUClusterPix& cluster)
28 :AliCluster(cluster)
29 ,fNxNz(cluster.fNxNz)
30{
31 // copy constructor
32}
33
34//______________________________________________________________________________
35AliITSUClusterPix& AliITSUClusterPix::operator=(const AliITSUClusterPix& cluster)
36{
37 // = op
38 if(&cluster == this) return *this;
39 fNxNz = cluster.fNxNz;
40 TObject::operator=(cluster);
41 AliCluster::operator=(cluster);
42 return *this;
43}
44
45//______________________________________________________________________________
46const TGeoHMatrix* AliITSUClusterPix::GetTracking2LocalMatrix() const
47{
48 // get tracking to local matrix (sensor!!!)
49 return (TGeoHMatrix*)fgGeom->GetMatrixT2L(GetVolumeId());
50}
51
52//______________________________________________________________________________
53TGeoHMatrix* AliITSUClusterPix::GetMatrix(Bool_t ) const
54{
55 // get module matrix (sensor!)
56 return (TGeoHMatrix*)fgGeom->GetMatrixSens(GetVolumeId());
57}
58
59//______________________________________________________________________________
60void AliITSUClusterPix::Print(Option_t* /*option*/) const
61{
62 // Print cluster information.
63 printf("Cluster of module %5d, <nx>=%3d <nz>=%3d |Err^2:%.3e %.3e %+.3e |",GetVolumeId(),GetNx(),GetNz(),
64 GetSigmaY2(),GetSigmaZ2(),GetSigmaYZ());
65 printf("XYZ: %+.4e %+.4e %+.4e in frame ",GetX(),GetY(),GetZ());
66 if (IsFrameLoc()) printf("LOC");
67 else if (IsFrameGlo()) printf("GLO");
68 else if (IsFrameTrk()) printf("TRK");
69 if (!IsFrameGlo() && fgGeom) {
70 Float_t g[3];
71 GetGlobalXYZ(g);
72 printf(" (%+.4e %+.4e %+.4e in GLO)",g[0],g[1],g[2]);
73 }
74 printf("\n");
75 //
76}
77
78//______________________________________________________________________________
79Bool_t AliITSUClusterPix::GetGlobalXYZ(Float_t xyz[3]) const
80{
81 // Get the global coordinates of the cluster
82 // All the needed information is taken only
83 // from TGeo.
84 if (IsFrameGlo()) {
85 xyz[0] = GetX();
86 xyz[1] = GetY();
87 xyz[2] = GetZ();
88 }
89 //
90 Double_t lxyz[3] = {0, 0, 0};
91 if (IsFrameTrk()) {
92 const TGeoHMatrix *mt = GetTracking2LocalMatrix();
93 if (!mt) return kFALSE;
94 Double_t txyz[3] = {GetX(), GetY(), GetZ()};
95 mt->LocalToMaster(txyz,lxyz);
96 }
97 else {
98 lxyz[0] = GetX(); lxyz[1] = GetY(); lxyz[2] = GetZ();
99 }
100 //
101 TGeoHMatrix *ml = GetMatrix();
102 if (!ml) return kFALSE;
103 Double_t gxyz[3] = {0, 0, 0};
104 ml->LocalToMaster(lxyz,gxyz);
105 xyz[0] = gxyz[0]; xyz[1] = gxyz[1]; xyz[2] = gxyz[2];
106 return kTRUE;
107}
108
109//______________________________________________________________________________
110Bool_t AliITSUClusterPix::GetGlobalCov(Float_t cov[6]) const
111{
112 // Get the global covariance matrix of the cluster coordinates
113 // All the needed information is taken only
114 // from TGeo.
115 // Note: regardless on in which frame the coordinates are, the errors are always in tracking frame
116 //
117 return AliCluster::GetGlobalCov(cov);
118}
119
120//______________________________________________________________________________
121Bool_t AliITSUClusterPix::GetXRefPlane(Float_t &xref) const
122{
123 // Get the distance between the origin and the ref.plane.
124 // All the needed information is taken only from TGeo.
125 return AliCluster::GetXRefPlane(xref);
126}
127
128//______________________________________________________________________________
129void AliITSUClusterPix::GoToFrameGlo()
130{
131 // convert to global frame
132 if (IsFrameGlo()) return;
133 double loc[3],glo[3];
134 //
135 if (IsFrameTrk()) {
136 double curr[3]={GetX(),GetY(),GetZ()};
137 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
138 ResetBit(kFrameTrk);
139 }
140 else {
141 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
142 ResetBit(kFrameLoc);
143 }
144 GetMatrix()->LocalToMaster(loc,glo);
145 SetX(glo[0]);
146 SetY(glo[1]);
147 SetZ(glo[2]);
148 SetBit(kFrameGlo);
149 //
150}
151
152//______________________________________________________________________________
153void AliITSUClusterPix::GoToFrameLoc()
154{
155 // convert to local frame
156 if (IsFrameLoc()) return;
157 //
158 double loc[3],glo[3];
159 if (IsFrameTrk()) {
160 double curr[3]={GetX(),GetY(),GetZ()};
161 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
162 ResetBit(kFrameTrk);
163 }
164 else {
165 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
166 GetMatrix()->MasterToLocal(glo,loc);
167 ResetBit(kFrameLoc);
168 }
169 SetBit(kFrameLoc);
170 SetX(loc[0]);
171 SetY(loc[1]);
172 SetZ(loc[2]);
173 //
174}
175
176//______________________________________________________________________________
177void AliITSUClusterPix::GetLocalXYZ(Float_t xyz[3]) const
178{
179 // get local coordinates
180 if (IsFrameLoc()) {
181 xyz[0] = GetX(); xyz[1] = 0; xyz[2] = GetZ();
182 return;
183 }
184 double loc[3],glo[3];
185 if (IsFrameTrk()) {
186 double curr[3]={GetX(),GetY(),GetZ()};
187 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
188 }
189 else {
190 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
191 GetMatrix()->MasterToLocal(glo,loc);
192 }
193 for (int i=3;i--;) xyz[i] = loc[i];
194 //
195}
196
197//______________________________________________________________________________
198void AliITSUClusterPix::GoToFrameTrk()
199{
200 // convert to tracking frame
201 if (IsFrameTrk()) return;
202 //
203 double loc[3],trk[3];
204 if (IsFrameGlo()) {
205 double glo[3]={GetX(),GetY(),GetZ()};
206 GetMatrix()->MasterToLocal(glo,loc);
207 ResetBit(kFrameGlo);
208 }
209 else {
210 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
211 ResetBit(kFrameLoc);
212 }
213 // now in local frame
214 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
215 SetBit(kFrameTrk);
216 SetX(trk[0]);
217 SetY(trk[1]);
218 SetZ(trk[2]);
219 //
220}
221
222//______________________________________________________________________________
223void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const
224{
225 // convert to tracking frame
226 if (IsFrameTrk()) {
227 xyz[0] = GetX(); xyz[1] = GetY(); xyz[2] = GetZ();
228 return;
229 }
230 //
231 double loc[3],trk[3];
232 if (IsFrameGlo()) {
233 double glo[3]={GetX(),GetY(),GetZ()};
234 GetMatrix()->MasterToLocal(glo,loc);
235 }
236 else {
237 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
238 }
239 // now in local frame
240 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
241 for (int i=3;i--;) xyz[i] = loc[i];
242 //
243}
244
245//______________________________________________________________________________
246Int_t AliITSUClusterPix::Compare(const TObject* obj) const
247{
248 // compare clusters accodring to specific mode
249 const AliITSUClusterPix* px = dynamic_cast<const AliITSUClusterPix*>(obj);
250 float xyz[3],xyz1[3];
251 if (fgMode & kSortLoc) { // sorting in local frame
252 GetLocalXYZ(xyz);
253 px->GetLocalXYZ(xyz1);
254 if (xyz[2]<xyz1[2]) return -1; // sort in Z then in X
255 if (xyz[2]>xyz1[2]) return 1;
256 if (xyz[0]<xyz1[0]) return -1;
257 if (xyz[0]>xyz1[0]) return 1;
258 return 0;
259 }
260 if (fgMode & kSortTrk) { // sorting in tracking frame
261 GetTrackingXYZ(xyz);
262 px->GetTrackingXYZ(xyz1);
263 if (xyz[2]<xyz1[2]) return -1; // sort in Z then in Y
264 if (xyz[2]>xyz1[2]) return 1;
265 if (xyz[1]<xyz1[1]) return -1;
266 if (xyz[1]>xyz1[1]) return 1;
267 return 0;
268 }
269 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
270 return 0;
271}
272
273//______________________________________________________________________________
274Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const
275{
276 // compare clusters accodring to specific mode
277 const AliITSUClusterPix* px = dynamic_cast<const AliITSUClusterPix*>(obj);
278 const Float_t kTol = 1e-5;
279 float xyz[3],xyz1[3];
280 if (fgMode & kSortLoc) { // sorting in local frame
281 GetLocalXYZ(xyz);
282 px->GetLocalXYZ(xyz1);
283 if (Abs(xyz[2]-xyz1[2])<kTol && Abs(xyz[0]-xyz1[0])<kTol) return kTRUE;
284 return kFALSE;
285 }
286 if (fgMode & kSortTrk) { // sorting in tracking frame
287 GetTrackingXYZ(xyz);
288 px->GetTrackingXYZ(xyz1);
289 if (Abs(xyz[2]-xyz1[2])<kTol && Abs(xyz[1]-xyz1[1])<kTol) return kTRUE;
290 return kFALSE;
291 }
292 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
293 return kFALSE;
294}