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()
20 // default constructor
23 //_____________________________________________________
24 AliITSUClusterPix::~AliITSUClusterPix()
29 //_____________________________________________________
30 AliITSUClusterPix::AliITSUClusterPix(const AliITSUClusterPix& cluster)
32 ,fCharge(cluster.fCharge)
33 ,fRecoInfo(cluster.fRecoInfo)
34 ,fNxNzN(cluster.fNxNzN)
39 //______________________________________________________________________________
40 AliITSUClusterPix& AliITSUClusterPix::operator=(const AliITSUClusterPix& cluster)
43 if(&cluster == this) return *this;
44 fNxNzN = cluster.fNxNzN;
45 fCharge = cluster.fCharge;
46 fRecoInfo = cluster.fRecoInfo;
47 TObject::operator=(cluster);
48 AliCluster::operator=(cluster);
52 //______________________________________________________________________________
53 const TGeoHMatrix* AliITSUClusterPix::GetTracking2LocalMatrix() const
55 // get tracking to local matrix (sensor!!!)
56 return (TGeoHMatrix*)fgGeom->GetMatrixT2L(GetVolumeId());
59 //______________________________________________________________________________
60 TGeoHMatrix* AliITSUClusterPix::GetMatrix(Bool_t ) const
62 // get module matrix (sensor!)
63 return (TGeoHMatrix*)fgGeom->GetMatrixSens(GetVolumeId());
66 //______________________________________________________________________________
67 void AliITSUClusterPix::Print(Option_t* option) const
69 // Print cluster information.
72 printf("Cl.in mod %5d, nx:%3d nz:%3d n:%d |Err^2:%.3e %.3e %+.3e |",GetVolumeId(),GetNx(),GetNz(),
73 GetNPix(),GetSigmaY2(),GetSigmaZ2(),GetSigmaYZ());
74 printf("XYZ: (%+.4e %+.4e %+.4e ",GetX(),GetY(),GetZ());
75 if (IsFrameLoc()) printf("LOC)");
76 else if (IsFrameGlo()) printf("GLO)");
77 else if (IsFrameTrk()) printf("TRK)");
78 if (str.Contains("glo") && !IsFrameGlo() && fgGeom) {
81 printf(" (%+.4e %+.4e %+.4e GLO)",g[0],g[1],g[2]);
84 for (int i=0;i<3;i++) printf(" %5d",GetLabel(i));
85 if (TestBit(kSplit)) printf(" Spl");
90 //______________________________________________________________________________
91 Bool_t AliITSUClusterPix::GetGlobalXYZ(Float_t xyz[3]) const
93 // Get the global coordinates of the cluster
94 // All the needed information is taken only
102 Double_t lxyz[3] = {0, 0, 0};
104 const TGeoHMatrix *mt = GetTracking2LocalMatrix();
105 if (!mt) return kFALSE;
106 Double_t txyz[3] = {GetX(), GetY(), GetZ()};
107 mt->LocalToMaster(txyz,lxyz);
110 lxyz[0] = GetX(); lxyz[1] = GetY(); lxyz[2] = GetZ();
113 TGeoHMatrix *ml = GetMatrix();
114 if (!ml) return kFALSE;
115 Double_t gxyz[3] = {0, 0, 0};
116 ml->LocalToMaster(lxyz,gxyz);
117 xyz[0] = gxyz[0]; xyz[1] = gxyz[1]; xyz[2] = gxyz[2];
121 //______________________________________________________________________________
122 Bool_t AliITSUClusterPix::GetGlobalCov(Float_t cov[6]) const
124 // Get the global covariance matrix of the cluster coordinates
125 // All the needed information is taken only
127 // Note: regardless on in which frame the coordinates are, the errors are always in tracking frame
129 return AliCluster::GetGlobalCov(cov);
132 //______________________________________________________________________________
133 Bool_t AliITSUClusterPix::GetXRefPlane(Float_t &xref) const
135 // Get the distance between the origin and the ref.plane.
136 // All the needed information is taken only from TGeo.
137 return AliCluster::GetXRefPlane(xref);
140 //______________________________________________________________________________
141 void AliITSUClusterPix::GoToFrameGlo()
143 // convert to global frame
144 if (IsFrameGlo()) return;
145 double loc[3],glo[3];
148 double curr[3]={GetX(),GetY(),GetZ()};
149 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
153 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
156 GetMatrix()->LocalToMaster(loc,glo);
164 //______________________________________________________________________________
165 void AliITSUClusterPix::GoToFrameLoc()
167 // convert to local frame
168 if (IsFrameLoc()) return;
170 double loc[3],glo[3];
172 double curr[3]={GetX(),GetY(),GetZ()};
173 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
177 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
178 GetMatrix()->MasterToLocal(glo,loc);
188 //______________________________________________________________________________
189 void AliITSUClusterPix::GetLocalXYZ(Float_t xyz[3]) const
191 // get local coordinates
193 xyz[0] = GetX(); xyz[1] = 0; xyz[2] = GetZ();
196 double loc[3],glo[3];
198 double curr[3]={GetX(),GetY(),GetZ()};
199 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
202 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
203 GetMatrix()->MasterToLocal(glo,loc);
205 for (int i=3;i--;) xyz[i] = loc[i];
209 //______________________________________________________________________________
210 void AliITSUClusterPix::GoToFrameTrk()
212 // convert to tracking frame
213 if (IsFrameTrk()) return;
215 double loc[3],trk[3];
217 double glo[3]={GetX(),GetY(),GetZ()};
218 GetMatrix()->MasterToLocal(glo,loc);
222 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
225 // now in local frame
226 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
234 //______________________________________________________________________________
235 void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const
237 // convert to tracking frame
239 xyz[0] = GetX(); xyz[1] = GetY(); xyz[2] = GetZ();
243 double loc[3],trk[3];
245 double glo[3]={GetX(),GetY(),GetZ()};
246 GetMatrix()->MasterToLocal(glo,loc);
249 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
251 // now in local frame
252 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
253 for (int i=3;i--;) xyz[i] = trk[i];
257 //______________________________________________________________________________
258 Int_t AliITSUClusterPix::Compare(const TObject* obj) const
260 // compare clusters accodring to specific mode
261 const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj;
262 float xyz[3],xyz1[3];
263 if (fgMode & kSortIdLocXZ) { // sorting in local frame
264 if (GetVolumeId()==px->GetVolumeId()) {
266 px->GetLocalXYZ(xyz1);
267 if (xyz[0]<xyz1[0]) return -1; // sort in X
268 if (xyz[0]>xyz1[0]) return 1;
269 if (xyz[2]<xyz1[2]) return -1; // then in Z
270 if (xyz[2]>xyz1[2]) return 1;
273 return int(GetVolumeId())-int(px->GetVolumeId());
275 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
276 if (GetVolumeId()==px->GetVolumeId()) {
278 px->GetTrackingXYZ(xyz1);
279 if (xyz[1]<xyz1[1]) return -1; // sort in Y
280 if (xyz[1]>xyz1[1]) return 1;
281 if (xyz[2]<xyz1[2]) return -1; // then in Z
282 if (xyz[2]>xyz1[2]) return 1;
285 return int(GetVolumeId())-int(px->GetVolumeId());
287 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
291 //______________________________________________________________________________
292 Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const
294 // compare clusters accodring to specific mode
295 const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj;
296 const Float_t kTol = 1e-5;
297 float xyz[3],xyz1[3];
298 if (fgMode & kSortIdLocXZ) { // sorting in local frame
299 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
301 px->GetLocalXYZ(xyz1);
302 return (Abs(xyz[0]-xyz1[0])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
304 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
305 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
307 px->GetTrackingXYZ(xyz1);
308 return (Abs(xyz[1]-xyz1[1])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
310 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
314 //______________________________________________________________________________
315 Bool_t AliITSUClusterPix::HasCommonTrack(const AliCluster* cl) const
317 // check if clusters have common tracks
319 for (int i=0;i<3;i++) {
320 if ((lbi=GetLabel(i))<0) break;
321 for (int j=0;j<3;j++) {
322 if ((lbj=cl->GetLabel(j))<0) break;
323 if (lbi==lbj) return kTRUE;