]>
Commit | Line | Data |
---|---|---|
46d29e70 | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
0a29d0f1 | 17 | |
04eeac11 | 18 | //////////////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // Hit compression class // | |
21 | // Adapted from AliTPCTimeBin by Marian // | |
22 | // // | |
23 | //////////////////////////////////////////////////////////////////////////// | |
0a29d0f1 | 24 | |
46d29e70 | 25 | #include "AliTRDcluster.h" |
46d29e70 | 26 | #include "AliTRDtimeBin.h" |
27 | ||
28 | ClassImp(AliTRDtimeBin) | |
29 | ||
04eeac11 | 30 | //_____________________________________________________________________________ |
31 | AliTRDtimeBin::AliTRDtimeBin() | |
32 | :TObject() | |
33 | ,fN(0) | |
34 | { | |
35 | // | |
36 | // Default constructor | |
37 | // | |
2685bf00 | 38 | |
04eeac11 | 39 | for (UInt_t i = 0; i < kMaxClusterPerTimeBin; i++) { |
40 | fClusters[i] = 0; | |
2685bf00 | 41 | } |
46d29e70 | 42 | |
04eeac11 | 43 | } |
46d29e70 | 44 | |
04eeac11 | 45 | //_____________________________________________________________________________ |
46 | void AliTRDtimeBin::InsertCluster(AliTRDcluster* c, UInt_t index) | |
47 | { | |
48 | // | |
49 | // Insert cluster in TimeBin cluster array. | |
50 | // Clusters are sorted according to Y coordinate. | |
51 | // | |
46d29e70 | 52 | |
04eeac11 | 53 | if (fN == kMaxClusterPerTimeBin) { |
54 | AliError("Too many clusters!\n"); | |
46d29e70 | 55 | return; |
56 | } | |
04eeac11 | 57 | |
58 | if (fN == 0) { | |
59 | fIndex[0] = index; | |
60 | fClusters[fN++] = c; | |
61 | return; | |
62 | } | |
63 | ||
64 | Int_t i = Find(c->GetY()); | |
65 | ||
66 | memmove(fClusters+i+1,fClusters+i,(fN-i)*sizeof(AliTRDcluster*)); | |
67 | memmove(fIndex +i+1,fIndex +i,(fN-i)*sizeof(UInt_t)); | |
68 | ||
69 | fIndex[i] = index; | |
70 | fClusters[i] = c; | |
71 | fN++; | |
72 | ||
46d29e70 | 73 | } |
74 | ||
04eeac11 | 75 | //_____________________________________________________________________________ |
76 | Int_t AliTRDtimeBin::Find(Double_t y) const | |
77 | { | |
78 | // | |
79 | // Returns index of the cluster nearest in Y | |
80 | // | |
46d29e70 | 81 | |
04eeac11 | 82 | if (y <= fClusters[ 0]->GetY()) { |
83 | return 0; | |
84 | } | |
85 | if (y > fClusters[fN-1]->GetY()) { | |
86 | return fN; | |
87 | } | |
46d29e70 | 88 | |
04eeac11 | 89 | Int_t b = 0; |
90 | Int_t e = fN - 1; | |
91 | Int_t m = (b + e) / 2; | |
46d29e70 | 92 | |
04eeac11 | 93 | for ( ; b < e; m = (b+e)/2) { |
94 | if (y > fClusters[m]->GetY()) { | |
95 | b = m + 1; | |
96 | } | |
97 | else { | |
98 | e = m; | |
99 | } | |
46d29e70 | 100 | } |
04eeac11 | 101 | |
46d29e70 | 102 | return m; |
04eeac11 | 103 | |
46d29e70 | 104 | } |
105 | ||
04eeac11 | 106 | //_____________________________________________________________________________ |
46d29e70 | 107 | AliTRDcluster *AliTRDtimeBin::operator[](Int_t i) |
108 | { | |
109 | // | |
110 | // Index operator | |
111 | // | |
112 | ||
113 | return fClusters[i]; | |
114 | ||
115 | } |