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()
19 // default constructor
22 //_____________________________________________________
23 AliITSUClusterPix::~AliITSUClusterPix()
28 //_____________________________________________________
29 AliITSUClusterPix::AliITSUClusterPix(const AliITSUClusterPix& cluster)
31 ,fCharge(cluster.fCharge)
32 ,fNxNzN(cluster.fNxNzN)
37 //______________________________________________________________________________
38 AliITSUClusterPix& AliITSUClusterPix::operator=(const AliITSUClusterPix& cluster)
41 if(&cluster == this) return *this;
42 fNxNzN = cluster.fNxNzN;
43 fCharge = cluster.fCharge;
44 TObject::operator=(cluster);
45 AliCluster::operator=(cluster);
49 //______________________________________________________________________________
50 const TGeoHMatrix* AliITSUClusterPix::GetTracking2LocalMatrix() const
52 // get tracking to local matrix (sensor!!!)
53 return (TGeoHMatrix*)fgGeom->GetMatrixT2L(GetVolumeId());
56 //______________________________________________________________________________
57 TGeoHMatrix* AliITSUClusterPix::GetMatrix(Bool_t ) const
59 // get module matrix (sensor!)
60 return (TGeoHMatrix*)fgGeom->GetMatrixSens(GetVolumeId());
63 //______________________________________________________________________________
64 void AliITSUClusterPix::Print(Option_t* option) const
66 // Print cluster information.
69 printf("Cl.in mod %5d, nx:%3d nz:%3d n:%d |Err^2:%.3e %.3e %+.3e |",GetVolumeId(),GetNx(),GetNz(),
70 GetNPix(),GetSigmaY2(),GetSigmaZ2(),GetSigmaYZ());
71 printf("XYZ: (%+.4e %+.4e %+.4e ",GetX(),GetY(),GetZ());
72 if (IsFrameLoc()) printf("LOC)");
73 else if (IsFrameGlo()) printf("GLO)");
74 else if (IsFrameTrk()) printf("TRK)");
75 if (str.Contains("glo") && !IsFrameGlo() && fgGeom) {
78 printf(" (%+.4e %+.4e %+.4e GLO)",g[0],g[1],g[2]);
81 for (int i=0;i<3;i++) printf(" %5d",GetLabel(i));
82 if (TestBit(kSplit)) printf(" Spl");
87 //______________________________________________________________________________
88 Bool_t AliITSUClusterPix::GetGlobalXYZ(Float_t xyz[3]) const
90 // Get the global coordinates of the cluster
91 // All the needed information is taken only
99 Double_t lxyz[3] = {0, 0, 0};
101 const TGeoHMatrix *mt = GetTracking2LocalMatrix();
102 if (!mt) return kFALSE;
103 Double_t txyz[3] = {GetX(), GetY(), GetZ()};
104 mt->LocalToMaster(txyz,lxyz);
107 lxyz[0] = GetX(); lxyz[1] = GetY(); lxyz[2] = GetZ();
110 TGeoHMatrix *ml = GetMatrix();
111 if (!ml) return kFALSE;
112 Double_t gxyz[3] = {0, 0, 0};
113 ml->LocalToMaster(lxyz,gxyz);
114 xyz[0] = gxyz[0]; xyz[1] = gxyz[1]; xyz[2] = gxyz[2];
118 //______________________________________________________________________________
119 Bool_t AliITSUClusterPix::GetGlobalCov(Float_t cov[6]) const
121 // Get the global covariance matrix of the cluster coordinates
122 // All the needed information is taken only
124 // Note: regardless on in which frame the coordinates are, the errors are always in tracking frame
126 return AliCluster::GetGlobalCov(cov);
129 //______________________________________________________________________________
130 Bool_t AliITSUClusterPix::GetXRefPlane(Float_t &xref) const
132 // Get the distance between the origin and the ref.plane.
133 // All the needed information is taken only from TGeo.
134 return AliCluster::GetXRefPlane(xref);
137 //______________________________________________________________________________
138 void AliITSUClusterPix::GoToFrameGlo()
140 // convert to global frame
141 if (IsFrameGlo()) return;
142 double loc[3],glo[3];
145 double curr[3]={GetX(),GetY(),GetZ()};
146 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
150 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
153 GetMatrix()->LocalToMaster(loc,glo);
161 //______________________________________________________________________________
162 void AliITSUClusterPix::GoToFrameLoc()
164 // convert to local frame
165 if (IsFrameLoc()) return;
167 double loc[3],glo[3];
169 double curr[3]={GetX(),GetY(),GetZ()};
170 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
174 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
175 GetMatrix()->MasterToLocal(glo,loc);
185 //______________________________________________________________________________
186 void AliITSUClusterPix::GetLocalXYZ(Float_t xyz[3]) const
188 // get local coordinates
190 xyz[0] = GetX(); xyz[1] = 0; xyz[2] = GetZ();
193 double loc[3],glo[3];
195 double curr[3]={GetX(),GetY(),GetZ()};
196 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
199 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
200 GetMatrix()->MasterToLocal(glo,loc);
202 for (int i=3;i--;) xyz[i] = loc[i];
206 //______________________________________________________________________________
207 void AliITSUClusterPix::GoToFrameTrk()
209 // convert to tracking frame
210 if (IsFrameTrk()) return;
212 double loc[3],trk[3];
214 double glo[3]={GetX(),GetY(),GetZ()};
215 GetMatrix()->MasterToLocal(glo,loc);
219 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
222 // now in local frame
223 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
231 //______________________________________________________________________________
232 void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const
234 // convert to tracking frame
236 xyz[0] = GetX(); xyz[1] = GetY(); xyz[2] = GetZ();
240 double loc[3],trk[3];
242 double glo[3]={GetX(),GetY(),GetZ()};
243 GetMatrix()->MasterToLocal(glo,loc);
246 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
248 // now in local frame
249 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
250 for (int i=3;i--;) xyz[i] = loc[i];
254 //______________________________________________________________________________
255 Int_t AliITSUClusterPix::Compare(const TObject* obj) const
257 // compare clusters accodring to specific mode
258 const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj;
259 float xyz[3],xyz1[3];
260 if (fgMode & kSortIdLocXZ) { // sorting in local frame
261 if (GetVolumeId()==px->GetVolumeId()) {
263 px->GetLocalXYZ(xyz1);
264 if (xyz[0]<xyz1[0]) return -1; // sort in X
265 if (xyz[0]>xyz1[0]) return 1;
266 if (xyz[2]<xyz1[2]) return -1; // then in Z
267 if (xyz[2]>xyz1[2]) return 1;
270 return int(GetVolumeId())-int(px->GetVolumeId());
272 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
273 if (GetVolumeId()==px->GetVolumeId()) {
275 px->GetTrackingXYZ(xyz1);
276 if (xyz[1]<xyz1[1]) return -1; // sort in Y
277 if (xyz[1]>xyz1[1]) return 1;
278 if (xyz[2]<xyz1[2]) return -1; // then in Z
279 if (xyz[2]>xyz1[2]) return 1;
282 return int(GetVolumeId())-int(px->GetVolumeId());
284 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
288 //______________________________________________________________________________
289 Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const
291 // compare clusters accodring to specific mode
292 const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj;
293 const Float_t kTol = 1e-5;
294 float xyz[3],xyz1[3];
295 if (fgMode & kSortIdLocXZ) { // sorting in local frame
296 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
298 px->GetLocalXYZ(xyz1);
299 return (Abs(xyz[0]-xyz1[0])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
301 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
302 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
304 px->GetTrackingXYZ(xyz1);
305 return (Abs(xyz[1]-xyz1[1])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
307 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
311 //______________________________________________________________________________
312 Bool_t AliITSUClusterPix::HasCommonTrack(const AliCluster* cl) const
314 // check if clusters have common tracks
316 for (int i=0;i<3;i++) {
317 if ((lbi=GetLabel(i))<0) break;
318 for (int j=0;j<3;j++) {
319 if ((lbj=cl->GetLabel(j))<0) break;
320 if (lbi==lbj) return kTRUE;