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));
86 //______________________________________________________________________________
87 Bool_t AliITSUClusterPix::GetGlobalXYZ(Float_t xyz[3]) const
89 // Get the global coordinates of the cluster
90 // All the needed information is taken only
98 Double_t lxyz[3] = {0, 0, 0};
100 const TGeoHMatrix *mt = GetTracking2LocalMatrix();
101 if (!mt) return kFALSE;
102 Double_t txyz[3] = {GetX(), GetY(), GetZ()};
103 mt->LocalToMaster(txyz,lxyz);
106 lxyz[0] = GetX(); lxyz[1] = GetY(); lxyz[2] = GetZ();
109 TGeoHMatrix *ml = GetMatrix();
110 if (!ml) return kFALSE;
111 Double_t gxyz[3] = {0, 0, 0};
112 ml->LocalToMaster(lxyz,gxyz);
113 xyz[0] = gxyz[0]; xyz[1] = gxyz[1]; xyz[2] = gxyz[2];
117 //______________________________________________________________________________
118 Bool_t AliITSUClusterPix::GetGlobalCov(Float_t cov[6]) const
120 // Get the global covariance matrix of the cluster coordinates
121 // All the needed information is taken only
123 // Note: regardless on in which frame the coordinates are, the errors are always in tracking frame
125 return AliCluster::GetGlobalCov(cov);
128 //______________________________________________________________________________
129 Bool_t AliITSUClusterPix::GetXRefPlane(Float_t &xref) const
131 // Get the distance between the origin and the ref.plane.
132 // All the needed information is taken only from TGeo.
133 return AliCluster::GetXRefPlane(xref);
136 //______________________________________________________________________________
137 void AliITSUClusterPix::GoToFrameGlo()
139 // convert to global frame
140 if (IsFrameGlo()) return;
141 double loc[3],glo[3];
144 double curr[3]={GetX(),GetY(),GetZ()};
145 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
149 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
152 GetMatrix()->LocalToMaster(loc,glo);
160 //______________________________________________________________________________
161 void AliITSUClusterPix::GoToFrameLoc()
163 // convert to local frame
164 if (IsFrameLoc()) return;
166 double loc[3],glo[3];
168 double curr[3]={GetX(),GetY(),GetZ()};
169 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
173 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
174 GetMatrix()->MasterToLocal(glo,loc);
184 //______________________________________________________________________________
185 void AliITSUClusterPix::GetLocalXYZ(Float_t xyz[3]) const
187 // get local coordinates
189 xyz[0] = GetX(); xyz[1] = 0; xyz[2] = GetZ();
192 double loc[3],glo[3];
194 double curr[3]={GetX(),GetY(),GetZ()};
195 GetTracking2LocalMatrix()->LocalToMaster(curr,loc);
198 glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ();
199 GetMatrix()->MasterToLocal(glo,loc);
201 for (int i=3;i--;) xyz[i] = loc[i];
205 //______________________________________________________________________________
206 void AliITSUClusterPix::GoToFrameTrk()
208 // convert to tracking frame
209 if (IsFrameTrk()) return;
211 double loc[3],trk[3];
213 double glo[3]={GetX(),GetY(),GetZ()};
214 GetMatrix()->MasterToLocal(glo,loc);
218 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
221 // now in local frame
222 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
230 //______________________________________________________________________________
231 void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const
233 // convert to tracking frame
235 xyz[0] = GetX(); xyz[1] = GetY(); xyz[2] = GetZ();
239 double loc[3],trk[3];
241 double glo[3]={GetX(),GetY(),GetZ()};
242 GetMatrix()->MasterToLocal(glo,loc);
245 loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ();
247 // now in local frame
248 GetTracking2LocalMatrix()->MasterToLocal(loc,trk);
249 for (int i=3;i--;) xyz[i] = loc[i];
253 //______________________________________________________________________________
254 Int_t AliITSUClusterPix::Compare(const TObject* obj) const
256 // compare clusters accodring to specific mode
257 const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj;
258 float xyz[3],xyz1[3];
259 if (fgMode & kSortIdLocXZ) { // sorting in local frame
260 if (GetVolumeId()==px->GetVolumeId()) {
262 px->GetLocalXYZ(xyz1);
263 if (xyz[0]<xyz1[0]) return -1; // sort in X
264 if (xyz[0]>xyz1[0]) return 1;
265 if (xyz[2]<xyz1[2]) return -1; // then in Z
266 if (xyz[2]>xyz1[2]) return 1;
269 return int(GetVolumeId())-int(px->GetVolumeId());
271 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
272 if (GetVolumeId()==px->GetVolumeId()) {
274 px->GetTrackingXYZ(xyz1);
275 if (xyz[1]<xyz1[1]) return -1; // sort in Y
276 if (xyz[1]>xyz1[1]) return 1;
277 if (xyz[2]<xyz1[2]) return -1; // then in Z
278 if (xyz[2]>xyz1[2]) return 1;
281 return int(GetVolumeId())-int(px->GetVolumeId());
283 AliFatal(Form("Unknown modr for sorting: %d",fgMode));
287 //______________________________________________________________________________
288 Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const
290 // compare clusters accodring to specific mode
291 const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj;
292 const Float_t kTol = 1e-5;
293 float xyz[3],xyz1[3];
294 if (fgMode & kSortIdLocXZ) { // sorting in local frame
295 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
297 px->GetLocalXYZ(xyz1);
298 return (Abs(xyz[0]-xyz1[0])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
300 if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame
301 if (GetVolumeId()!=px->GetVolumeId()) return kFALSE;
303 px->GetTrackingXYZ(xyz1);
304 return (Abs(xyz[1]-xyz1[1])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE;
306 AliFatal(Form("Unknown modr for sorting: %d",fgMode));