]>
Commit | Line | Data |
---|---|---|
2874a2f5 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: $ */ | |
17 | ||
18 | //_________________________________________________________________________// | |
19 | //_________________________________________________________________________// | |
20 | ||
21 | #include "AliESDTOFCluster.h" | |
22 | #include "TClonesArray.h" | |
23 | #include "AliESDEvent.h" | |
24 | ||
25 | ClassImp(AliESDTOFCluster) | |
26 | ||
27 | //_________________________________________________________________________ | |
28 | AliESDTOFCluster::AliESDTOFCluster(Int_t clID) : | |
29 | fID(clID), | |
30 | fNTOFhits(0), | |
31 | fStatus(0), | |
32 | fNmatchableTracks(0) | |
33 | { | |
34 | // | |
35 | // default ctor | |
36 | // | |
37 | ||
38 | for(Int_t i=kMaxHits;i--;) fHitIndex[i] = -1; | |
39 | for(Int_t i=kMaxMatches;i--;) fMatchIndex[i] = -1; | |
40 | } | |
41 | ||
42 | //_________________________________________________________________________ | |
43 | AliESDTOFCluster::AliESDTOFCluster(Int_t ,Int_t ,Float_t ,Float_t ,Float_t ,Int_t*,Int_t ,Int_t , | |
44 | Bool_t ,Float_t ,Float_t ,Float_t , | |
45 | Int_t ,Float_t ,Float_t ,Float_t ,Float_t ,Double_t*) : | |
46 | fID(-1), | |
47 | fNTOFhits(0), | |
48 | fStatus(1), | |
49 | fNmatchableTracks(1) | |
50 | { | |
51 | // | |
52 | // Constructor of AliESDTOFCluster object | |
53 | // | |
54 | ||
55 | // to be replaced with hit creation | |
56 | for(Int_t i=kMaxHits;i--;) fHitIndex[i] = -1; | |
57 | for(Int_t i=kMaxMatches;i--;) fMatchIndex[i] = -1; | |
58 | // | |
59 | } | |
60 | ||
61 | //_________________________________________________________________________ | |
62 | AliESDTOFCluster::AliESDTOFCluster(Int_t ,Int_t ,Float_t ,Float_t ,Float_t ,Int_t*,Int_t ,Int_t , | |
63 | Bool_t ,Float_t ,Float_t ,Float_t ) : | |
64 | fID(-1), | |
65 | fNTOFhits(0), | |
66 | fStatus(1), | |
67 | fNmatchableTracks(0) | |
68 | { | |
69 | // | |
70 | // Constructor of AliESDTOFCluster object | |
71 | // | |
72 | ||
73 | // to be replaced with hit creation | |
74 | for(Int_t i=kMaxHits;i--;) fHitIndex[i] = -1; | |
75 | for(Int_t i=kMaxMatches;i--;) fMatchIndex[i] = -1; | |
76 | ||
77 | } | |
78 | ||
79 | //_________________________________________________________________________ | |
80 | AliESDTOFCluster::AliESDTOFCluster(const AliESDTOFCluster & source) : | |
81 | AliVTOFcluster(source), | |
82 | fID(source.fID), | |
83 | fNTOFhits(source.fNTOFhits), | |
84 | fStatus(source.fStatus), | |
85 | fNmatchableTracks(source.fNmatchableTracks) | |
86 | { | |
87 | // | |
88 | // copy ctor for AliESDTOFCluster object | |
89 | // | |
90 | ||
91 | SetEvent(source.GetEvent()); | |
92 | ||
93 | for(Int_t i=kMaxHits;i--;) fHitIndex[i] = source.fHitIndex[i]; | |
94 | for(Int_t i=kMaxMatches;i--;) fMatchIndex[i] = source.fMatchIndex[i]; | |
95 | ||
96 | } | |
97 | ||
98 | //_________________________________________________________________________ | |
99 | AliESDTOFCluster & AliESDTOFCluster::operator=(const AliESDTOFCluster & source) | |
100 | { | |
101 | // | |
102 | // assignment op-r | |
103 | // | |
104 | if (this == &source) return *this; | |
105 | AliVTOFcluster::operator=(source); | |
106 | fID = source.fID; | |
107 | fNTOFhits = source.fNTOFhits; | |
108 | fStatus = source.fStatus; | |
109 | fNmatchableTracks = source.fNmatchableTracks; | |
110 | ||
111 | for(Int_t i=kMaxHits;i--;) fHitIndex[i] = source.fHitIndex[i]; | |
112 | for(Int_t i=kMaxMatches;i--;) fMatchIndex[i] = source.fMatchIndex[i]; | |
113 | ||
114 | return *this; | |
115 | } | |
116 | ||
117 | //_________________________________________________________________________ | |
118 | Int_t AliESDTOFCluster::Update(Int_t trackIndex,Float_t dX,Float_t dY,Float_t dZ, | |
119 | Float_t length,Double_t expTimes[AliPID::kSPECIESC]) | |
120 | { | |
121 | // update cluster info by new track | |
122 | // AliInfo(Form("TOF %d %d",fNmatchableTracks,fNTOFhits)); | |
123 | ||
124 | if(fNmatchableTracks >= kMaxMatches) return 2; // max number reached | |
125 | // | |
126 | // check if the track is not already stored | |
127 | for (Int_t ii=fNmatchableTracks; ii--;) if (trackIndex==GetTrackIndex(ii)) return 1; | |
128 | // | |
129 | const AliESDEvent *event = (AliESDEvent *) GetEvent(); | |
130 | TClonesArray *matchAr = event->GetESDTOFMatches(); | |
131 | int ntr = matchAr->GetEntriesFast(); | |
132 | new((*matchAr)[ntr]) AliESDTOFMatch(trackIndex,expTimes,dX,dY,dZ,length); | |
133 | fMatchIndex[fNmatchableTracks++] = ntr; | |
134 | // | |
135 | return 0; | |
136 | // | |
137 | } | |
138 | ||
139 | //_________________________________________________________________________ | |
140 | void AliESDTOFCluster::AddESDTOFHitIndex(Int_t hitID) | |
141 | { | |
142 | // register new hit in the cluster | |
143 | if(fNTOFhits >= kMaxHits) return; | |
144 | fHitIndex[fNTOFhits++] = hitID; // add the hit to the array | |
145 | } | |
146 | ||
147 | //_________________________________________________________________________ | |
148 | void AliESDTOFCluster::AddTOFhit(AliESDTOFHit *hit) | |
149 | { | |
150 | // add new hit | |
151 | if(fNTOFhits >= kMaxHits) return; | |
152 | // add the hit to the array | |
153 | const AliESDEvent *event = (AliESDEvent *) GetEvent(); | |
154 | TClonesArray *hitAr = event->GetESDTOFHits(); | |
155 | int nh = hitAr->GetEntriesFast(); | |
156 | new((*hitAr)[nh]) AliESDTOFHit(*hit); | |
157 | // hitN->SetIndex(nh); // RS: why do we need this | |
158 | fHitIndex[fNTOFhits++] = nh; | |
159 | // | |
160 | } | |
161 | ||
162 | //_________________________________________________________________________ | |
163 | void AliESDTOFCluster::AddTOFhit(Int_t ,Int_t ,Float_t ,Float_t ,Float_t ,Int_t*,Int_t ,Int_t , Bool_t ,Float_t ,Float_t ,Float_t ) | |
164 | { | |
165 | } | |
166 | ||
167 | //_________________________________________________________________________ | |
168 | Int_t AliESDTOFCluster::GetClusterIndex(int ihit) const | |
169 | { | |
170 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
171 | return hit ? hit->GetClusterIndex() : -1; | |
172 | } | |
173 | ||
174 | //_________________________________________________________________________ | |
175 | Int_t AliESDTOFCluster::GetTOFchannel(int ihit) const | |
176 | { | |
177 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
178 | return hit ? hit->GetTOFchannel() : -1; | |
179 | } | |
180 | ||
181 | //_________________________________________________________________________ | |
182 | Float_t AliESDTOFCluster::GetTime(int ihit) const | |
183 | { | |
184 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
185 | return hit ? hit->GetTime() : 0; | |
186 | } | |
187 | ||
188 | //_________________________________________________________________________ | |
189 | Float_t AliESDTOFCluster::GetTimeRaw(Int_t ihit) const | |
190 | { | |
191 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
192 | return hit ? hit->GetTimeRaw() : 0; | |
193 | } // TOF raw time | |
194 | ||
195 | //_________________________________________________________________________ | |
196 | Float_t AliESDTOFCluster::GetTOT(Int_t ihit) const | |
197 | { | |
198 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
199 | return hit ? hit->GetTOT() : 0; | |
200 | } // TOF tot | |
201 | ||
202 | //_________________________________________________________________________ | |
203 | Float_t AliESDTOFCluster::GetTOFsignalToT(Int_t ihit) const | |
204 | { | |
205 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
206 | return hit ? hit->GetTOT() : 0; // RS: Why signalTot and TOT are the same? | |
207 | } // TOF tot | |
208 | ||
209 | //_________________________________________________________________________ | |
210 | Int_t AliESDTOFCluster::GetLabel(Int_t i,Int_t ihit) const | |
211 | { | |
212 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
213 | if (!hit || i>=3) return -999; | |
214 | return hit->GetTOFLabel(i); | |
215 | } | |
216 | ||
217 | //_________________________________________________________________________ | |
218 | Int_t AliESDTOFCluster::GetDeltaBC(Int_t ihit) const | |
219 | { | |
220 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
221 | return hit ? hit->GetDeltaBC() : 0; | |
222 | } | |
223 | ||
224 | //_________________________________________________________________________ | |
225 | Int_t AliESDTOFCluster::GetL0L1Latency(Int_t ihit) const | |
226 | { | |
227 | AliESDTOFHit* hit = GetTOFHit(ihit); | |
228 | return hit ? hit->GetL0L1Latency() : 0; | |
229 | } | |
230 | ||
231 | //_________________________________________________________________________ | |
232 | Bool_t AliESDTOFCluster::GetStatus() const | |
233 | { | |
234 | if(!fEvent){ | |
235 | AliInfo("No AliESDEvent available here!"); | |
236 | return 0; | |
237 | } | |
238 | return fStatus; | |
239 | } | |
240 | ||
241 | //_________________________________________________________________________ | |
242 | Float_t AliESDTOFCluster::GetZ() const | |
243 | { | |
244 | AliESDTOFHit* hit = GetTOFHit(0); | |
245 | return hit ? hit->GetZ() : 0; | |
246 | } | |
247 | ||
248 | //_________________________________________________________________________ | |
249 | Float_t AliESDTOFCluster::GetPhi() const | |
250 | { | |
251 | AliESDTOFHit* hit = GetTOFHit(0); | |
252 | return hit ? hit->GetPhi() : 0; | |
253 | } | |
254 | ||
255 | //_________________________________________________________________________ | |
256 | Float_t AliESDTOFCluster::GetR() const | |
257 | { | |
258 | AliESDTOFHit* hit = GetTOFHit(0); | |
259 | return hit ? hit->GetR() : 0; | |
260 | } | |
261 | ||
262 | //_________________________________________________________________________ | |
263 | Int_t AliESDTOFCluster::GetNMatchableTracks() const | |
264 | { | |
265 | return fNmatchableTracks; | |
266 | } | |
267 | ||
268 | //_________________________________________________________________________ | |
269 | Int_t AliESDTOFCluster::GetNTOFhits() const | |
270 | { | |
271 | return fNTOFhits; | |
272 | } | |
273 | ||
274 | //_________________________________________________________________________ | |
275 | Int_t AliESDTOFCluster::GetTrackIndex(Int_t i) const | |
276 | { | |
277 | AliESDTOFMatch* match = 0; | |
278 | return (i<fNmatchableTracks && (match=GetTOFMatch(i))) ? match->GetTrackIndex() : -999; | |
279 | } | |
280 | ||
281 | //_________________________________________________________________________ | |
282 | Float_t AliESDTOFCluster::GetDistanceInStripPlane(Int_t i) const | |
283 | { | |
284 | // distance | |
285 | AliESDTOFMatch* match = 0; | |
286 | if (i>=fNmatchableTracks || !(match=GetTOFMatch(i))) return -999; | |
287 | Double_t dz = match->GetDz(); | |
288 | Double_t dx = match->GetDx(); | |
289 | return TMath::Sqrt(dx*dx+dz*dz); | |
290 | } | |
291 | ||
292 | //_________________________________________________________________________ | |
293 | Float_t AliESDTOFCluster::GetDx(Int_t i) const | |
294 | { | |
295 | AliESDTOFMatch* match = 0; | |
296 | return (i<fNmatchableTracks && (match=GetTOFMatch(i))) ? match->GetDx() : -999; | |
297 | } // distance, X component | |
298 | ||
299 | //_________________________________________________________________________ | |
300 | Float_t AliESDTOFCluster::GetDy(Int_t i) const | |
301 | { | |
302 | AliESDTOFMatch* match = 0; | |
303 | return (i<fNmatchableTracks && (match=GetTOFMatch(i))) ? match->GetDy() : -999; | |
304 | } // distance, Y component | |
305 | ||
306 | //_________________________________________________________________________ | |
307 | Float_t AliESDTOFCluster::GetDz(Int_t i) const | |
308 | { | |
309 | AliESDTOFMatch* match = 0; | |
310 | return (i<fNmatchableTracks && (match=GetTOFMatch(i))) ? match->GetDz() : -999; | |
311 | } // distance, Z component | |
312 | ||
313 | //_________________________________________________________________________ | |
314 | Float_t AliESDTOFCluster::GetLength(Int_t i) const | |
315 | { | |
316 | AliESDTOFMatch* match = 0; | |
317 | return (i<fNmatchableTracks && (match=GetTOFMatch(i))) ? match->GetTrackLength() : -999.; | |
318 | } // reconstructed track length at TOF | |
319 | ||
320 | //_________________________________________________________________________ | |
321 | Double_t AliESDTOFCluster::GetIntegratedTime(Int_t iPart,Int_t i) const | |
322 | { | |
323 | AliESDTOFMatch* match = 0; | |
324 | return (i<fNmatchableTracks && (match=GetTOFMatch(i))) ? match->GetIntegratedTimes(iPart) : -999.; | |
325 | } // reconstructed track length at TOF | |
326 | ||
327 | //_________________________________________________________________________ | |
328 | void AliESDTOFCluster::Print(const Option_t*) const | |
329 | { | |
330 | // print full chain | |
331 | printf("#%5d TOF Cluster %5d of %d Hits, %d Matchable Tracks\n",GetESDID(),fID, fNTOFhits, fNmatchableTracks); | |
332 | for (int ih=0;ih<fNTOFhits;ih++) { | |
333 | AliESDTOFHit* ht = GetTOFHit(ih); | |
334 | if (ht) { | |
335 | printf("%d: ",ih); | |
336 | ht->Print(); | |
337 | } | |
338 | } | |
339 | // | |
340 | for (int it=0;it<fNmatchableTracks;it++) { | |
341 | AliESDTOFMatch* mt = GetTOFMatch(it); | |
342 | if (mt) { | |
343 | printf("%d: ",it); | |
344 | mt->Print(); | |
345 | } | |
346 | } | |
347 | // | |
348 | } | |
349 | ||
350 | //_________________________________________________________________________ | |
351 | AliESDTOFHit* AliESDTOFCluster::GetTOFHit(Int_t i) const | |
352 | { | |
353 | return fEvent ? ((AliESDTOFHit *) ((AliESDEvent *) GetEvent())->GetESDTOFHits()->At(fHitIndex[i])):0; | |
354 | } | |
355 | ||
356 | //_________________________________________________________________________ | |
357 | AliESDTOFMatch* AliESDTOFCluster::GetTOFMatch(Int_t i) const | |
358 | { | |
359 | return fEvent ? ((AliESDTOFMatch *) ((AliESDEvent *) GetEvent())->GetESDTOFMatches()->At(fMatchIndex[i])) : 0; | |
360 | } | |
361 | ||
362 | //_________________________________________________________________________ | |
363 | void AliESDTOFCluster::SuppressMatchedTrack(Int_t id) | |
364 | { | |
365 | // suppress the reference to track id | |
366 | for (int it=fNmatchableTracks;it--;) { | |
367 | AliESDTOFMatch* mtc = GetTOFMatch(it); | |
368 | if (mtc->GetTrackIndex()!=id) continue; | |
369 | // need to suprress the match: simply remove reference to it | |
370 | int rmID = fMatchIndex[it]; | |
371 | for (int jt=it+1;jt<fNmatchableTracks;jt++) fMatchIndex[jt-1] = fMatchIndex[jt]; | |
372 | fNmatchableTracks--; | |
373 | // remove match rmID | |
374 | TClonesArray* arrMatch = ((AliESDEvent *)GetEvent())->GetESDTOFMatches(); | |
375 | int last = arrMatch->GetEntriesFast()-1; | |
376 | AliESDTOFMatch* mtcL = (AliESDTOFMatch*)arrMatch->At(last); | |
377 | if (rmID!=last) { | |
378 | *mtc = *mtcL; // assign the last match to removed slot | |
379 | int trID = mtc->GetTrackIndex(); | |
380 | AliESDtrack* trc = ((AliESDEvent *)GetEvent())->GetTrack(trID); | |
381 | trc->ReplaceTOFMatchID(last,rmID); // fix the reference to reassigned match | |
382 | // fix the | |
383 | } | |
384 | arrMatch->RemoveAt(last); | |
385 | break; | |
386 | } | |
387 | // | |
388 | if (!fNmatchableTracks) { // no matches left, clear all hits: prepare for selfelimination | |
389 | // first remove associated hits | |
390 | TClonesArray* arrHits = ((AliESDEvent *)GetEvent())->GetESDTOFHits(); | |
391 | TClonesArray* arrClus = ((AliESDEvent *)GetEvent())->GetESDTOFClusters(); | |
392 | int last = arrHits->GetEntriesFast()-1; | |
393 | for (;fNTOFhits--;) { // remove hits | |
394 | int hID = fHitIndex[fNTOFhits]; | |
395 | AliESDTOFHit* hit = (AliESDTOFHit*)arrHits->At(hID); | |
396 | AliESDTOFHit* hitL = (AliESDTOFHit*)arrHits->At(last); | |
397 | if (hID!=last) { | |
398 | *hit = *hitL; // assign the last match to removed slot | |
399 | // fix reference on hitL in the owner cluster | |
400 | int clID = hit->GetESDTOFClusterIndex(); | |
401 | AliESDTOFCluster* clusL = (AliESDTOFCluster*)arrClus->At(clID); | |
402 | clusL->ReplaceHitID(last,hID); | |
403 | } | |
404 | arrHits->RemoveAt(last--); | |
405 | } | |
406 | } | |
407 | ||
408 | } | |
409 | ||
410 | //_________________________________________________________________________ | |
411 | void AliESDTOFCluster::ReplaceHitID(int oldID, int newID) | |
412 | { | |
413 | // replace the reference to hit from oldID by newID | |
414 | for (int it=fNTOFhits;it--;) { | |
415 | if (fHitIndex[it]==oldID) { | |
416 | fHitIndex[it]=newID; | |
417 | return; | |
418 | } | |
419 | } | |
420 | } | |
421 | ||
422 | //_________________________________________________________________________ | |
423 | void AliESDTOFCluster::ReplaceMatchID(int oldID, int newID) | |
424 | { | |
425 | // replace the reference to match from oldID by newID | |
426 | for (int it=fNmatchableTracks;it--;) { | |
427 | if (fMatchIndex[it]==oldID) { | |
428 | fMatchIndex[it]=newID; | |
429 | return; | |
430 | } | |
431 | } | |
432 | } | |
433 | ||
434 | //_________________________________________________________________________ | |
435 | void AliESDTOFCluster::ReplaceMatchedTrackID(int oldID, int newID) | |
436 | { | |
437 | // replace the reference to track oldID by newID | |
438 | for (int it=fNmatchableTracks;it--;) { | |
439 | AliESDTOFMatch* mtc = GetTOFMatch(it); | |
440 | if (mtc->GetTrackIndex()!=oldID) continue; | |
441 | mtc->SetTrackIndex(newID); | |
442 | break; | |
443 | } | |
444 | // | |
445 | } | |
446 | ||
447 | //_________________________________________________________________________ | |
448 | void AliESDTOFCluster::FixSelfReferences(int oldID, int newID) | |
449 | { | |
450 | // replace the references (in tracks and hist) to this cluster from oldID by newID | |
451 | for (int it=fNmatchableTracks;it--;) { | |
452 | int trID = GetTOFMatch(it)->GetTrackIndex(); | |
453 | AliESDtrack* trc = ((AliESDEvent *)GetEvent())->GetTrack(trID); | |
454 | trc->ReplaceTOFClusterID(oldID,newID); | |
455 | } | |
456 | for (int it=fNTOFhits;it--;) { | |
457 | AliESDTOFHit* hit = GetTOFHit(it); | |
683f60ae | 458 | if (hit) hit->SetESDTOFClusterIndex(newID); |
2874a2f5 | 459 | } |
460 | // | |
461 | } |