1 #include "AliITSUClusterPix.h"
2 #include "AliITSUGeomTGeo.h"
4 #include <TGeoMatrix.h>
9 ClassImp(AliITSUClusterPix)
11 AliITSUGeomTGeo* AliITSUClusterPix::fgGeom = 0;
12 UInt_t AliITSUClusterPix::fgMode = 0;
14 //_____________________________________________________
15 AliITSUClusterPix::AliITSUClusterPix()
18 // default constructor
21 //_____________________________________________________
22 AliITSUClusterPix::~AliITSUClusterPix()
27 //_____________________________________________________
28 AliITSUClusterPix::AliITSUClusterPix(const AliITSUClusterPix& cluster)
35 //______________________________________________________________________________
36 AliITSUClusterPix& AliITSUClusterPix::operator=(const AliITSUClusterPix& cluster)
39 if(&cluster == this) return *this;
40 fNxNz = cluster.fNxNz;
41 TObject::operator=(cluster);
42 AliCluster::operator=(cluster);
46 //______________________________________________________________________________
47 const TGeoHMatrix* AliITSUClusterPix::GetTracking2LocalMatrix() const
49 // get tracking to local matrix (sensor!!!)
50 return (TGeoHMatrix*)fgGeom->GetMatrixT2L(GetVolumeId());
53 //______________________________________________________________________________
54 TGeoHMatrix* AliITSUClusterPix::GetMatrix(Bool_t ) const
56 // get module matrix (sensor!)
57 return (TGeoHMatrix*)fgGeom->GetMatrixSens(GetVolumeId());
60 //______________________________________________________________________________
61 void AliITSUClusterPix::Print(Option_t* option) const
63 // Print cluster information.
66 printf("Cl.in mod %5d, nx:%3d nz:%3d |Err^2:%.3e %.3e %+.3e |",GetVolumeId(),GetNx(),GetNz(),
67 GetSigmaY2(),GetSigmaZ2(),GetSigmaYZ());
68 printf("XYZ: (%+.4e %+.4e %+.4e ",GetX(),GetY(),GetZ());
69 if (IsFrameLoc()) printf("LOC)");
70 else if (IsFrameGlo()) printf("GLO)");
71 else if (IsFrameTrk()) printf("TRK)");
72 if (str.Contains("glo") && !IsFrameGlo() && fgGeom) {
75 printf(" (%+.4e %+.4e %+.4e GLO)",g[0],g[1],g[2]);
78 for (int i=0;i<3;i++) printf(" %5d",GetLabel(i));
83 //______________________________________________________________________________
84 Bool_t AliITSUClusterPix::GetGlobalXYZ(Float_t xyz[3]) const
86 // Get the global coordinates of the cluster
87 // All the needed information is taken only
95 Double_t lxyz[3] = {0, 0, 0};
97 const TGeoHMatrix *mt = GetTracking2LocalMatrix();
98 if (!mt) return kFALSE;
99 Double_t txyz[3] = {GetX(), GetY(), GetZ()};
100 mt->LocalToMaster(txyz,lxyz);
103 lxyz[0] = GetX(); lxyz[1] = GetY(); lxyz[2] = GetZ();
106 TGeoHMatrix *ml = GetMatrix();
107 if (!ml) return kFALSE;
108 Double_t gxyz[3] = {0, 0, 0};
109 ml->LocalToMaster(lxyz,gxyz);
110 xyz[0] = gxyz[0]; xyz[1] = gxyz[1]; xyz[2] = gxyz[2];
114 //______________________________________________________________________________
115 Bool_t AliITSUClusterPix::GetGlobalCov(Float_t cov[6]) const
117 // Get the global covariance matrix of the cluster coordinates
118 // All the needed information is taken only
120 // Note: regardless on in which frame the coordinates are, the errors are always in tracking frame
122 return AliCluster::GetGlobalCov(cov);
125 //______________________________________________________________________________
126 Bool_t AliITSUClusterPix::GetXRefPlane(Float_t &xref) const
128 // Get the distance between the origin and the ref.plane.
129 // All the needed information is taken only from TGeo.
130 return AliCluster::GetXRefPlane(xref);
133 //______________________________________________________________________________
134 void AliITSUClusterPix::GoToFrameGlo()
136 // convert to global frame
137 if (IsFrameGlo()) return;
138 double loc[3],glo[3];
141 double curr[3]={GetX(),GetY(),GetZ()};
142 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
146 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
149 GetMatrix()->LocalToMaster(loc,glo);
157 //______________________________________________________________________________
158 void AliITSUClusterPix::GoToFrameLoc()
160 // convert to local frame
161 if (IsFrameLoc()) return;
163 double loc[3],glo[3];
165 double curr[3]={GetX(),GetY(),GetZ()};
166 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
170 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
171 GetMatrix()->MasterToLocal(glo,loc);
181 //______________________________________________________________________________
182 void AliITSUClusterPix::GetLocalXYZ(Float_t xyz[3]) const
184 // get local coordinates
186 xyz[0] = GetX(); xyz[1] = 0; xyz[2] = GetZ();
189 double loc[3],glo[3];
191 double curr[3]={GetX(),GetY(),GetZ()};
192 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
195 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
196 GetMatrix()->MasterToLocal(glo,loc);
198 for (int i=3;i--;) xyz[i] = loc[i];
202 //______________________________________________________________________________
203 void AliITSUClusterPix::GoToFrameTrk()
205 // convert to tracking frame
206 if (IsFrameTrk()) return;
208 double loc[3],trk[3];
210 double glo[3]={GetX(),GetY(),GetZ()};
211 GetMatrix()->MasterToLocal(glo,loc);
215 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
218 // now in local frame
219 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
227 //______________________________________________________________________________
228 void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const
230 // convert to tracking frame
232 xyz[0] = GetX(); xyz[1] = GetY(); xyz[2] = GetZ();
236 double loc[3],trk[3];
238 double glo[3]={GetX(),GetY(),GetZ()};
239 GetMatrix()->MasterToLocal(glo,loc);
242 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
244 // now in local frame
245 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
246 for (int i=3;i--;) xyz[i] = loc[i];
250 //______________________________________________________________________________
251 Int_t AliITSUClusterPix::Compare(const TObject* obj) const
253 // compare clusters accodring to specific mode
254 const AliITSUClusterPix* px = dynamic_cast<const AliITSUClusterPix*>(obj);
255 float xyz[3],xyz1[3];
256 if (fgMode & kSortIdLocXZ) { // sorting in local frame
257 if (GetVolumeId()==px->GetVolumeId()) {
259 px->GetLocalXYZ(xyz1);
260 if (xyz[0]<xyz1[0]) return -1; // sort in X
261 if (xyz[0]>xyz1[0]) return 1;
262 if (xyz[2]<xyz1[2]) return -1; // then in Z
263 if (xyz[2]>xyz1[2]) return 1;
266 return int(GetVolumeId())-int(px->GetVolumeId());
268 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
269 if (GetVolumeId()==px->GetVolumeId()) {
271 px->GetTrackingXYZ(xyz1);
272 if (xyz[1]<xyz1[1]) return -1; // sort in Y
273 if (xyz[1]>xyz1[1]) return 1;
274 if (xyz[2]<xyz1[2]) return -1; // then in Z
275 if (xyz[2]>xyz1[2]) return 1;
278 return int(GetVolumeId())-int(px->GetVolumeId());
280 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
284 //______________________________________________________________________________
285 Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const
287 // compare clusters accodring to specific mode
288 const AliITSUClusterPix* px = dynamic_cast<const AliITSUClusterPix*>(obj);
289 const Float_t kTol = 1e-5;
290 float xyz[3],xyz1[3];
291 if (fgMode & kSortIdLocXZ) { // sorting in local frame
292 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
294 px->GetLocalXYZ(xyz1);
295 return (Abs(xyz[0]-xyz1[0])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
297 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
298 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
300 px->GetTrackingXYZ(xyz1);
301 return (Abs(xyz[1]-xyz1[1])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
303 AliFatal(Form("Unknown modr for sorting: %d",fgMode));