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
103 Double_t lxyz[3] = {0, 0, 0};
105 const TGeoHMatrix *mt = GetTracking2LocalMatrix();
106 if (!mt) return kFALSE;
107 Double_t txyz[3] = {GetX(), GetY(), GetZ()};
108 mt->LocalToMaster(txyz,lxyz);
111 lxyz[0] = GetX(); lxyz[1] = GetY(); lxyz[2] = GetZ();
114 TGeoHMatrix *ml = GetMatrix();
115 if (!ml) return kFALSE;
116 Double_t gxyz[3] = {0, 0, 0};
117 ml->LocalToMaster(lxyz,gxyz);
118 xyz[0] = gxyz[0]; xyz[1] = gxyz[1]; xyz[2] = gxyz[2];
122 //______________________________________________________________________________
123 Bool_t AliITSUClusterPix::GetGlobalCov(Float_t cov[6]) const
125 // Get the global covariance matrix of the cluster coordinates
126 // All the needed information is taken only
128 // Note: regardless on in which frame the coordinates are, the errors are always in tracking frame
130 return AliCluster::GetGlobalCov(cov);
133 //______________________________________________________________________________
134 Bool_t AliITSUClusterPix::GetXRefPlane(Float_t &xref) const
136 // Get the distance between the origin and the ref.plane.
137 // All the needed information is taken only from TGeo.
138 return AliCluster::GetXRefPlane(xref);
141 //______________________________________________________________________________
142 void AliITSUClusterPix::GoToFrameGlo()
144 // convert to global frame
145 if (IsFrameGlo()) return;
146 double loc[3],glo[3];
149 double curr[3]={GetX(),GetY(),GetZ()};
150 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
154 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
157 GetMatrix()->LocalToMaster(loc,glo);
165 //______________________________________________________________________________
166 void AliITSUClusterPix::GoToFrameLoc()
168 // convert to local frame
169 if (IsFrameLoc()) return;
171 double loc[3],glo[3];
173 double curr[3]={GetX(),GetY(),GetZ()};
174 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
178 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
179 GetMatrix()->MasterToLocal(glo,loc);
189 //______________________________________________________________________________
190 void AliITSUClusterPix::GetLocalXYZ(Float_t xyz[3]) const
192 // get local coordinates
194 xyz[0] = GetX(); xyz[1] = 0; xyz[2] = GetZ();
197 double loc[3],glo[3];
199 double curr[3]={GetX(),GetY(),GetZ()};
200 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
203 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
204 GetMatrix()->MasterToLocal(glo,loc);
206 for (int i=3;i--;) xyz[i] = loc[i];
210 //______________________________________________________________________________
211 void AliITSUClusterPix::GoToFrameTrk()
213 // convert to tracking frame
214 if (IsFrameTrk()) return;
216 double loc[3],trk[3];
218 double glo[3]={GetX(),GetY(),GetZ()};
219 GetMatrix()->MasterToLocal(glo,loc);
223 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
226 // now in local frame
227 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
235 //______________________________________________________________________________
236 void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const
238 // convert to tracking frame
240 xyz[0] = GetX(); xyz[1] = GetY(); xyz[2] = GetZ();
244 double loc[3],trk[3];
246 double glo[3]={GetX(),GetY(),GetZ()};
247 GetMatrix()->MasterToLocal(glo,loc);
250 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
252 // now in local frame
253 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
254 for (int i=3;i--;) xyz[i] = trk[i];
258 //______________________________________________________________________________
259 Int_t AliITSUClusterPix::Compare(const TObject* obj) const
261 // compare clusters accodring to specific mode
262 const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj;
263 float xyz[3],xyz1[3];
264 if (fgMode & kSortIdLocXZ) { // sorting in local frame
265 if (GetVolumeId()==px->GetVolumeId()) {
267 px->GetLocalXYZ(xyz1);
268 if (xyz[0]<xyz1[0]) return -1; // sort in X
269 if (xyz[0]>xyz1[0]) return 1;
270 if (xyz[2]<xyz1[2]) return -1; // then in Z
271 if (xyz[2]>xyz1[2]) return 1;
274 return int(GetVolumeId())-int(px->GetVolumeId());
276 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
277 if (GetVolumeId()==px->GetVolumeId()) {
279 px->GetTrackingXYZ(xyz1);
280 if (xyz[1]<xyz1[1]) return -1; // sort in Y
281 if (xyz[1]>xyz1[1]) return 1;
282 if (xyz[2]<xyz1[2]) return -1; // then in Z
283 if (xyz[2]>xyz1[2]) return 1;
286 return int(GetVolumeId())-int(px->GetVolumeId());
288 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
292 //______________________________________________________________________________
293 Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const
295 // compare clusters accodring to specific mode
296 const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj;
297 const Float_t kTol = 1e-5;
298 float xyz[3],xyz1[3];
299 if (fgMode & kSortIdLocXZ) { // sorting in local frame
300 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
302 px->GetLocalXYZ(xyz1);
303 return (Abs(xyz[0]-xyz1[0])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
305 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
306 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
308 px->GetTrackingXYZ(xyz1);
309 return (Abs(xyz[1]-xyz1[1])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
311 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
315 //______________________________________________________________________________
316 Bool_t AliITSUClusterPix::HasCommonTrack(const AliCluster* cl) const
318 // check if clusters have common tracks
320 for (int i=0;i<3;i++) {
321 if ((lbi=GetLabel(i))<0) break;
322 for (int j=0;j<3;j++) {
323 if ((lbj=cl->GetLabel(j))<0) break;
324 if (lbi==lbj) return kTRUE;