]>
Commit | Line | Data |
---|---|---|
5e375bb4 | 1 | #include "AliITSUClusterPix.h" |
2 | #include "AliITSUGeomTGeo.h" | |
3 | #include "AliLog.h" | |
4 | #include <TGeoMatrix.h> | |
3dd9c283 | 5 | #include <TString.h> |
6 | ||
5e375bb4 | 7 | using namespace TMath; |
8 | ||
9 | ClassImp(AliITSUClusterPix) | |
10 | ||
11 | AliITSUGeomTGeo* AliITSUClusterPix::fgGeom = 0; | |
12 | UInt_t AliITSUClusterPix::fgMode = 0; | |
13 | ||
14 | //_____________________________________________________ | |
15 | AliITSUClusterPix::AliITSUClusterPix() | |
29ad4146 | 16 | : fCharge(0) |
17 | , fNxNzN(0) | |
5e375bb4 | 18 | { |
19 | // default constructor | |
20 | } | |
21 | ||
22 | //_____________________________________________________ | |
23 | AliITSUClusterPix::~AliITSUClusterPix() | |
24 | { | |
25 | // default destructor | |
26 | } | |
27 | ||
28 | //_____________________________________________________ | |
29 | AliITSUClusterPix::AliITSUClusterPix(const AliITSUClusterPix& cluster) | |
30 | :AliCluster(cluster) | |
29ad4146 | 31 | ,fCharge(cluster.fCharge) |
32 | ,fNxNzN(cluster.fNxNzN) | |
5e375bb4 | 33 | { |
34 | // copy constructor | |
35 | } | |
36 | ||
37 | //______________________________________________________________________________ | |
38 | AliITSUClusterPix& AliITSUClusterPix::operator=(const AliITSUClusterPix& cluster) | |
39 | { | |
40 | // = op | |
41 | if(&cluster == this) return *this; | |
29ad4146 | 42 | fNxNzN = cluster.fNxNzN; |
43 | fCharge = cluster.fCharge; | |
5e375bb4 | 44 | TObject::operator=(cluster); |
45 | AliCluster::operator=(cluster); | |
46 | return *this; | |
47 | } | |
48 | ||
49 | //______________________________________________________________________________ | |
50 | const TGeoHMatrix* AliITSUClusterPix::GetTracking2LocalMatrix() const | |
51 | { | |
52 | // get tracking to local matrix (sensor!!!) | |
53 | return (TGeoHMatrix*)fgGeom->GetMatrixT2L(GetVolumeId()); | |
54 | } | |
55 | ||
56 | //______________________________________________________________________________ | |
57 | TGeoHMatrix* AliITSUClusterPix::GetMatrix(Bool_t ) const | |
58 | { | |
59 | // get module matrix (sensor!) | |
60 | return (TGeoHMatrix*)fgGeom->GetMatrixSens(GetVolumeId()); | |
61 | } | |
62 | ||
63 | //______________________________________________________________________________ | |
3dd9c283 | 64 | void AliITSUClusterPix::Print(Option_t* option) const |
5e375bb4 | 65 | { |
66 | // Print cluster information. | |
3dd9c283 | 67 | TString str = option; |
68 | str.ToLower(); | |
29ad4146 | 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()); | |
0e84ce67 | 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)"); | |
3dd9c283 | 75 | if (str.Contains("glo") && !IsFrameGlo() && fgGeom) { |
5e375bb4 | 76 | Float_t g[3]; |
77 | GetGlobalXYZ(g); | |
0e84ce67 | 78 | printf(" (%+.4e %+.4e %+.4e GLO)",g[0],g[1],g[2]); |
5e375bb4 | 79 | } |
0e84ce67 | 80 | printf(" MClb:"); |
81 | for (int i=0;i<3;i++) printf(" %5d",GetLabel(i)); | |
53870004 | 82 | if (TestBit(kSplit)) printf(" Spl"); |
5e375bb4 | 83 | printf("\n"); |
84 | // | |
85 | } | |
86 | ||
87 | //______________________________________________________________________________ | |
88 | Bool_t AliITSUClusterPix::GetGlobalXYZ(Float_t xyz[3]) const | |
89 | { | |
90 | // Get the global coordinates of the cluster | |
91 | // All the needed information is taken only | |
92 | // from TGeo. | |
93 | if (IsFrameGlo()) { | |
94 | xyz[0] = GetX(); | |
95 | xyz[1] = GetY(); | |
96 | xyz[2] = GetZ(); | |
97 | } | |
98 | // | |
99 | Double_t lxyz[3] = {0, 0, 0}; | |
100 | if (IsFrameTrk()) { | |
101 | const TGeoHMatrix *mt = GetTracking2LocalMatrix(); | |
102 | if (!mt) return kFALSE; | |
103 | Double_t txyz[3] = {GetX(), GetY(), GetZ()}; | |
104 | mt->LocalToMaster(txyz,lxyz); | |
105 | } | |
106 | else { | |
107 | lxyz[0] = GetX(); lxyz[1] = GetY(); lxyz[2] = GetZ(); | |
108 | } | |
109 | // | |
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]; | |
115 | return kTRUE; | |
116 | } | |
117 | ||
118 | //______________________________________________________________________________ | |
119 | Bool_t AliITSUClusterPix::GetGlobalCov(Float_t cov[6]) const | |
120 | { | |
121 | // Get the global covariance matrix of the cluster coordinates | |
122 | // All the needed information is taken only | |
123 | // from TGeo. | |
124 | // Note: regardless on in which frame the coordinates are, the errors are always in tracking frame | |
125 | // | |
126 | return AliCluster::GetGlobalCov(cov); | |
127 | } | |
128 | ||
129 | //______________________________________________________________________________ | |
130 | Bool_t AliITSUClusterPix::GetXRefPlane(Float_t &xref) const | |
131 | { | |
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); | |
135 | } | |
136 | ||
137 | //______________________________________________________________________________ | |
138 | void AliITSUClusterPix::GoToFrameGlo() | |
139 | { | |
140 | // convert to global frame | |
141 | if (IsFrameGlo()) return; | |
142 | double loc[3],glo[3]; | |
143 | // | |
144 | if (IsFrameTrk()) { | |
145 | double curr[3]={GetX(),GetY(),GetZ()}; | |
146 | GetTracking2LocalMatrix()->LocalToMaster(curr,loc); | |
147 | ResetBit(kFrameTrk); | |
148 | } | |
149 | else { | |
150 | loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ(); | |
151 | ResetBit(kFrameLoc); | |
152 | } | |
153 | GetMatrix()->LocalToMaster(loc,glo); | |
154 | SetX(glo[0]); | |
155 | SetY(glo[1]); | |
156 | SetZ(glo[2]); | |
157 | SetBit(kFrameGlo); | |
158 | // | |
159 | } | |
160 | ||
161 | //______________________________________________________________________________ | |
162 | void AliITSUClusterPix::GoToFrameLoc() | |
163 | { | |
164 | // convert to local frame | |
165 | if (IsFrameLoc()) return; | |
166 | // | |
167 | double loc[3],glo[3]; | |
168 | if (IsFrameTrk()) { | |
169 | double curr[3]={GetX(),GetY(),GetZ()}; | |
170 | GetTracking2LocalMatrix()->LocalToMaster(curr,loc); | |
171 | ResetBit(kFrameTrk); | |
172 | } | |
173 | else { | |
174 | glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ(); | |
175 | GetMatrix()->MasterToLocal(glo,loc); | |
176 | ResetBit(kFrameLoc); | |
177 | } | |
178 | SetBit(kFrameLoc); | |
179 | SetX(loc[0]); | |
180 | SetY(loc[1]); | |
181 | SetZ(loc[2]); | |
182 | // | |
183 | } | |
184 | ||
185 | //______________________________________________________________________________ | |
186 | void AliITSUClusterPix::GetLocalXYZ(Float_t xyz[3]) const | |
187 | { | |
188 | // get local coordinates | |
189 | if (IsFrameLoc()) { | |
190 | xyz[0] = GetX(); xyz[1] = 0; xyz[2] = GetZ(); | |
191 | return; | |
192 | } | |
193 | double loc[3],glo[3]; | |
194 | if (IsFrameTrk()) { | |
195 | double curr[3]={GetX(),GetY(),GetZ()}; | |
196 | GetTracking2LocalMatrix()->LocalToMaster(curr,loc); | |
197 | } | |
198 | else { | |
199 | glo[0] = GetX(); glo[1] = GetY(); glo[2] = GetZ(); | |
200 | GetMatrix()->MasterToLocal(glo,loc); | |
201 | } | |
202 | for (int i=3;i--;) xyz[i] = loc[i]; | |
203 | // | |
204 | } | |
205 | ||
206 | //______________________________________________________________________________ | |
207 | void AliITSUClusterPix::GoToFrameTrk() | |
208 | { | |
209 | // convert to tracking frame | |
210 | if (IsFrameTrk()) return; | |
211 | // | |
212 | double loc[3],trk[3]; | |
213 | if (IsFrameGlo()) { | |
214 | double glo[3]={GetX(),GetY(),GetZ()}; | |
215 | GetMatrix()->MasterToLocal(glo,loc); | |
216 | ResetBit(kFrameGlo); | |
217 | } | |
218 | else { | |
219 | loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ(); | |
220 | ResetBit(kFrameLoc); | |
221 | } | |
222 | // now in local frame | |
223 | GetTracking2LocalMatrix()->MasterToLocal(loc,trk); | |
224 | SetBit(kFrameTrk); | |
225 | SetX(trk[0]); | |
226 | SetY(trk[1]); | |
227 | SetZ(trk[2]); | |
228 | // | |
229 | } | |
230 | ||
231 | //______________________________________________________________________________ | |
232 | void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const | |
233 | { | |
234 | // convert to tracking frame | |
235 | if (IsFrameTrk()) { | |
236 | xyz[0] = GetX(); xyz[1] = GetY(); xyz[2] = GetZ(); | |
237 | return; | |
238 | } | |
239 | // | |
240 | double loc[3],trk[3]; | |
241 | if (IsFrameGlo()) { | |
242 | double glo[3]={GetX(),GetY(),GetZ()}; | |
243 | GetMatrix()->MasterToLocal(glo,loc); | |
244 | } | |
245 | else { | |
246 | loc[0] = GetX(); loc[1] = GetY(); loc[2] = GetZ(); | |
247 | } | |
248 | // now in local frame | |
249 | GetTracking2LocalMatrix()->MasterToLocal(loc,trk); | |
250 | for (int i=3;i--;) xyz[i] = loc[i]; | |
251 | // | |
252 | } | |
253 | ||
254 | //______________________________________________________________________________ | |
255 | Int_t AliITSUClusterPix::Compare(const TObject* obj) const | |
256 | { | |
257 | // compare clusters accodring to specific mode | |
44785f3e | 258 | const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj; |
5e375bb4 | 259 | float xyz[3],xyz1[3]; |
1f9b6041 | 260 | if (fgMode & kSortIdLocXZ) { // sorting in local frame |
261 | if (GetVolumeId()==px->GetVolumeId()) { | |
262 | GetLocalXYZ(xyz); | |
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; | |
268 | return 0; | |
269 | } | |
270 | return int(GetVolumeId())-int(px->GetVolumeId()); | |
5e375bb4 | 271 | } |
1f9b6041 | 272 | if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame |
273 | if (GetVolumeId()==px->GetVolumeId()) { | |
274 | GetTrackingXYZ(xyz); | |
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; | |
280 | return 0; | |
281 | } | |
282 | return int(GetVolumeId())-int(px->GetVolumeId()); | |
5e375bb4 | 283 | } |
284 | AliFatal(Form("Unknown modr for sorting: %d",fgMode)); | |
285 | return 0; | |
286 | } | |
287 | ||
288 | //______________________________________________________________________________ | |
289 | Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const | |
290 | { | |
291 | // compare clusters accodring to specific mode | |
44785f3e | 292 | const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj; |
5e375bb4 | 293 | const Float_t kTol = 1e-5; |
294 | float xyz[3],xyz1[3]; | |
1f9b6041 | 295 | if (fgMode & kSortIdLocXZ) { // sorting in local frame |
296 | if (GetVolumeId()!=px->GetVolumeId()) return kFALSE; | |
5e375bb4 | 297 | GetLocalXYZ(xyz); |
298 | px->GetLocalXYZ(xyz1); | |
1f9b6041 | 299 | return (Abs(xyz[0]-xyz1[0])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE; |
5e375bb4 | 300 | } |
1f9b6041 | 301 | if (fgMode & kSortIdTrkYZ) { // sorting in tracking frame |
302 | if (GetVolumeId()!=px->GetVolumeId()) return kFALSE; | |
5e375bb4 | 303 | GetTrackingXYZ(xyz); |
304 | px->GetTrackingXYZ(xyz1); | |
1f9b6041 | 305 | return (Abs(xyz[1]-xyz1[1])<kTol && Abs(xyz[2]-xyz1[2])<kTol) ? kTRUE : kFALSE; |
5e375bb4 | 306 | } |
307 | AliFatal(Form("Unknown modr for sorting: %d",fgMode)); | |
308 | return kFALSE; | |
309 | } | |
53870004 | 310 | |
311 | //______________________________________________________________________________ | |
312 | Bool_t AliITSUClusterPix::HasCommonTrack(const AliCluster* cl) const | |
313 | { | |
314 | // check if clusters have common tracks | |
315 | int lbi,lbj; | |
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; | |
321 | } | |
322 | } | |
323 | return kFALSE; | |
324 | } |