1 #include "AliITSUClusterPix.h"
2 #include "AliITSUGeomTGeo.h"
4 #include <TGeoMatrix.h>
8 ClassImp(AliITSUClusterPix)
10 AliITSUGeomTGeo* AliITSUClusterPix::fgGeom = 0;
11 UInt_t AliITSUClusterPix::fgMode = 0;
13 //_____________________________________________________
14 AliITSUClusterPix::AliITSUClusterPix()
17 // default constructor
20 //_____________________________________________________
21 AliITSUClusterPix::~AliITSUClusterPix()
26 //_____________________________________________________
27 AliITSUClusterPix::AliITSUClusterPix(const AliITSUClusterPix& cluster)
34 //______________________________________________________________________________
35 AliITSUClusterPix& AliITSUClusterPix::operator=(const AliITSUClusterPix& cluster)
38 if(&cluster == this) return *this;
39 fNxNz = cluster.fNxNz;
40 TObject::operator=(cluster);
41 AliCluster::operator=(cluster);
45 //______________________________________________________________________________
46 const TGeoHMatrix* AliITSUClusterPix::GetTracking2LocalMatrix() const
48 // get tracking to local matrix (sensor!!!)
49 return (TGeoHMatrix*)fgGeom->GetMatrixT2L(GetVolumeId());
52 //______________________________________________________________________________
53 TGeoHMatrix* AliITSUClusterPix::GetMatrix(Bool_t ) const
55 // get module matrix (sensor!)
56 return (TGeoHMatrix*)fgGeom->GetMatrixSens(GetVolumeId());
59 //______________________________________________________________________________
60 void AliITSUClusterPix::Print(Option_t* /*option*/) const
62 // Print cluster information.
63 printf("Cl.in mod %5d, nx:%3d nz:%3d |Err^2:%.3e %.3e %+.3e |",GetVolumeId(),GetNx(),GetNz(),
64 GetSigmaY2(),GetSigmaZ2(),GetSigmaYZ());
65 printf("XYZ: (%+.4e %+.4e %+.4e ",GetX(),GetY(),GetZ());
66 if (IsFrameLoc()) printf("LOC)");
67 else if (IsFrameGlo()) printf("GLO)");
68 else if (IsFrameTrk()) printf("TRK)");
69 if (!IsFrameGlo() && fgGeom) {
72 printf(" (%+.4e %+.4e %+.4e GLO)",g[0],g[1],g[2]);
75 for (int i=0;i<3;i++) printf(" %5d",GetLabel(i));
80 //______________________________________________________________________________
81 Bool_t AliITSUClusterPix::GetGlobalXYZ(Float_t xyz[3]) const
83 // Get the global coordinates of the cluster
84 // All the needed information is taken only
92 Double_t lxyz[3] = {0, 0, 0};
94 const TGeoHMatrix *mt = GetTracking2LocalMatrix();
95 if (!mt) return kFALSE;
96 Double_t txyz[3] = {GetX(), GetY(), GetZ()};
97 mt->LocalToMaster(txyz,lxyz);
100 lxyz[0] = GetX(); lxyz[1] = GetY(); lxyz[2] = GetZ();
103 TGeoHMatrix *ml = GetMatrix();
104 if (!ml) return kFALSE;
105 Double_t gxyz[3] = {0, 0, 0};
106 ml->LocalToMaster(lxyz,gxyz);
107 xyz[0] = gxyz[0]; xyz[1] = gxyz[1]; xyz[2] = gxyz[2];
111 //______________________________________________________________________________
112 Bool_t AliITSUClusterPix::GetGlobalCov(Float_t cov[6]) const
114 // Get the global covariance matrix of the cluster coordinates
115 // All the needed information is taken only
117 // Note: regardless on in which frame the coordinates are, the errors are always in tracking frame
119 return AliCluster::GetGlobalCov(cov);
122 //______________________________________________________________________________
123 Bool_t AliITSUClusterPix::GetXRefPlane(Float_t &xref) const
125 // Get the distance between the origin and the ref.plane.
126 // All the needed information is taken only from TGeo.
127 return AliCluster::GetXRefPlane(xref);
130 //______________________________________________________________________________
131 void AliITSUClusterPix::GoToFrameGlo()
133 // convert to global frame
134 if (IsFrameGlo()) return;
135 double loc[3],glo[3];
138 double curr[3]={GetX(),GetY(),GetZ()};
139 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
143 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
146 GetMatrix()->LocalToMaster(loc,glo);
154 //______________________________________________________________________________
155 void AliITSUClusterPix::GoToFrameLoc()
157 // convert to local frame
158 if (IsFrameLoc()) return;
160 double loc[3],glo[3];
162 double curr[3]={GetX(),GetY(),GetZ()};
163 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
167 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
168 GetMatrix()->MasterToLocal(glo,loc);
178 //______________________________________________________________________________
179 void AliITSUClusterPix::GetLocalXYZ(Float_t xyz[3]) const
181 // get local coordinates
183 xyz[0] = GetX(); xyz[1] = 0; xyz[2] = GetZ();
186 double loc[3],glo[3];
188 double curr[3]={GetX(),GetY(),GetZ()};
189 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
192 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
193 GetMatrix()->MasterToLocal(glo,loc);
195 for (int i=3;i--;) xyz[i] = loc[i];
199 //______________________________________________________________________________
200 void AliITSUClusterPix::GoToFrameTrk()
202 // convert to tracking frame
203 if (IsFrameTrk()) return;
205 double loc[3],trk[3];
207 double glo[3]={GetX(),GetY(),GetZ()};
208 GetMatrix()->MasterToLocal(glo,loc);
212 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
215 // now in local frame
216 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
224 //______________________________________________________________________________
225 void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const
227 // convert to tracking frame
229 xyz[0] = GetX(); xyz[1] = GetY(); xyz[2] = GetZ();
233 double loc[3],trk[3];
235 double glo[3]={GetX(),GetY(),GetZ()};
236 GetMatrix()->MasterToLocal(glo,loc);
239 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
241 // now in local frame
242 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
243 for (int i=3;i--;) xyz[i] = loc[i];
247 //______________________________________________________________________________
248 Int_t AliITSUClusterPix::Compare(const TObject* obj) const
250 // compare clusters accodring to specific mode
251 const AliITSUClusterPix* px = dynamic_cast<const AliITSUClusterPix*>(obj);
252 float xyz[3],xyz1[3];
253 if (fgMode & kSortIdLocXZ) { // sorting in local frame
254 if (GetVolumeId()==px->GetVolumeId()) {
256 px->GetLocalXYZ(xyz1);
257 if (xyz[0]<xyz1[0]) return -1; // sort in X
258 if (xyz[0]>xyz1[0]) return 1;
259 if (xyz[2]<xyz1[2]) return -1; // then in Z
260 if (xyz[2]>xyz1[2]) return 1;
263 return int(GetVolumeId())-int(px->GetVolumeId());
265 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
266 if (GetVolumeId()==px->GetVolumeId()) {
268 px->GetTrackingXYZ(xyz1);
269 if (xyz[1]<xyz1[1]) return -1; // sort in Y
270 if (xyz[1]>xyz1[1]) return 1;
271 if (xyz[2]<xyz1[2]) return -1; // then in Z
272 if (xyz[2]>xyz1[2]) return 1;
275 return int(GetVolumeId())-int(px->GetVolumeId());
277 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
281 //______________________________________________________________________________
282 Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const
284 // compare clusters accodring to specific mode
285 const AliITSUClusterPix* px = dynamic_cast<const AliITSUClusterPix*>(obj);
286 const Float_t kTol = 1e-5;
287 float xyz[3],xyz1[3];
288 if (fgMode & kSortIdLocXZ) { // sorting in local frame
289 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
291 px->GetLocalXYZ(xyz1);
292 return (Abs(xyz[0]-xyz1[0])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
294 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
295 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
297 px->GetTrackingXYZ(xyz1);
298 return (Abs(xyz[1]-xyz1[1])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
300 AliFatal(Form("Unknown modr for sorting: %d",fgMode));