]>
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 | |
18 | ////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Hit compression class // | |
21 | // Adapted from AliTPCTimeBin by Marian // | |
22 | // // | |
23 | ////////////////////////////////////////////////////////////////////// | |
24 | ||
46d29e70 | 25 | #include "AliTRDcluster.h" |
46d29e70 | 26 | #include "AliTRDtimeBin.h" |
27 | ||
28 | ClassImp(AliTRDtimeBin) | |
29 | ||
2685bf00 | 30 | //______________________________________________________ |
31 | ||
32 | AliTRDtimeBin::AliTRDtimeBin() { | |
33 | //default constructor | |
34 | fN=0; | |
0a29d0f1 | 35 | for (UInt_t i=0; i<kMaxClusterPerTimeBin; i++) |
2685bf00 | 36 | fClusters[i]=0; |
37 | } | |
46d29e70 | 38 | //______________________________________________________ |
39 | ||
40 | void AliTRDtimeBin::InsertCluster(AliTRDcluster* c, UInt_t index) { | |
41 | ||
42 | // Insert cluster in TimeBin cluster array. | |
43 | // Clusters are sorted according to Y coordinate. | |
44 | ||
0a29d0f1 | 45 | if (fN==kMaxClusterPerTimeBin) { |
46d29e70 | 46 | printf("AliTRDtimeBin::InsertCluster(): Too many clusters !\n"); |
47 | return; | |
48 | } | |
49 | if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;} | |
50 | Int_t i=Find(c->GetY()); | |
51 | memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*)); | |
52 | memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t)); | |
53 | fIndex[i]=index; fClusters[i]=c; fN++; | |
54 | } | |
55 | ||
56 | //______________________________________________________ | |
57 | ||
58 | Int_t AliTRDtimeBin::Find(Double_t y) const { | |
59 | ||
60 | // Returns index of the cluster nearest in Y | |
61 | ||
62 | if (y <= fClusters[0]->GetY()) return 0; | |
63 | if (y > fClusters[fN-1]->GetY()) return fN; | |
64 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
65 | for (; b<e; m=(b+e)/2) { | |
66 | if (y > fClusters[m]->GetY()) b=m+1; | |
67 | else e=m; | |
68 | } | |
69 | return m; | |
70 | } | |
71 | ||
72 | //______________________________________________________ | |
73 | AliTRDcluster *AliTRDtimeBin::operator[](Int_t i) | |
74 | { | |
75 | // | |
76 | // Index operator | |
77 | // | |
78 | ||
79 | return fClusters[i]; | |
80 | ||
81 | } |