]>
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 | ||
16 | /* | |
17 | $Log$ | |
18 | Revision 1.1.2.2 2000/10/04 16:34:58 cblume | |
19 | Replace include files by forward declarations | |
20 | ||
21 | Revision 1.1.2.1 2000/09/22 14:47:52 cblume | |
22 | Add the tracking code | |
23 | ||
24 | */ | |
25 | ||
26 | #include "AliTRDcluster.h" | |
27 | #include "AliTRDconst.h" | |
28 | #include "AliTRDtimeBin.h" | |
29 | ||
30 | ClassImp(AliTRDtimeBin) | |
31 | ||
32 | //______________________________________________________ | |
33 | ||
34 | void AliTRDtimeBin::InsertCluster(AliTRDcluster* c, UInt_t index) { | |
35 | ||
36 | // Insert cluster in TimeBin cluster array. | |
37 | // Clusters are sorted according to Y coordinate. | |
38 | ||
39 | if (fN==kMAX_CLUSTER_PER_TIME_BIN) { | |
40 | printf("AliTRDtimeBin::InsertCluster(): Too many clusters !\n"); | |
41 | return; | |
42 | } | |
43 | if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;} | |
44 | Int_t i=Find(c->GetY()); | |
45 | memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*)); | |
46 | memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t)); | |
47 | fIndex[i]=index; fClusters[i]=c; fN++; | |
48 | } | |
49 | ||
50 | //______________________________________________________ | |
51 | ||
52 | Int_t AliTRDtimeBin::Find(Double_t y) const { | |
53 | ||
54 | // Returns index of the cluster nearest in Y | |
55 | ||
56 | if (y <= fClusters[0]->GetY()) return 0; | |
57 | if (y > fClusters[fN-1]->GetY()) return fN; | |
58 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
59 | for (; b<e; m=(b+e)/2) { | |
60 | if (y > fClusters[m]->GetY()) b=m+1; | |
61 | else e=m; | |
62 | } | |
63 | return m; | |
64 | } | |
65 | ||
66 | //______________________________________________________ | |
67 | AliTRDcluster *AliTRDtimeBin::operator[](Int_t i) | |
68 | { | |
69 | // | |
70 | // Index operator | |
71 | // | |
72 | ||
73 | return fClusters[i]; | |
74 | ||
75 | } |