]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDtimeBin.cxx
Introduce parameter class
[u/mrichter/AliRoot.git] / TRD / AliTRDtimeBin.cxx
CommitLineData
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$
16bf9884 18Revision 1.4 2001/10/21 18:30:02 hristov
19Several pointers were set to zero in the default constructors to avoid memory management problems
20
2685bf00 21Revision 1.3 2000/10/15 23:40:01 cblume
22Remove AliTRDconst
23
0e9c2ad5 24Revision 1.2 2000/10/06 16:49:46 cblume
25Made Getters const
26
46d29e70 27Revision 1.1.2.2 2000/10/04 16:34:58 cblume
28Replace include files by forward declarations
29
30Revision 1.1.2.1 2000/09/22 14:47:52 cblume
31Add the tracking code
32
33*/
34
35#include "AliTRDcluster.h"
46d29e70 36#include "AliTRDtimeBin.h"
37
38ClassImp(AliTRDtimeBin)
39
2685bf00 40//______________________________________________________
41
42 AliTRDtimeBin::AliTRDtimeBin() {
43 //default constructor
44 fN=0;
16bf9884 45 for (UInt_t i=0; i<kMAX_CLUSTER_PER_TIME_BIN; i++)
2685bf00 46 fClusters[i]=0;
47 }
46d29e70 48//______________________________________________________
49
50void AliTRDtimeBin::InsertCluster(AliTRDcluster* c, UInt_t index) {
51
52// Insert cluster in TimeBin cluster array.
53// Clusters are sorted according to Y coordinate.
54
55 if (fN==kMAX_CLUSTER_PER_TIME_BIN) {
56 printf("AliTRDtimeBin::InsertCluster(): Too many clusters !\n");
57 return;
58 }
59 if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
60 Int_t i=Find(c->GetY());
61 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*));
62 memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t));
63 fIndex[i]=index; fClusters[i]=c; fN++;
64}
65
66//______________________________________________________
67
68Int_t AliTRDtimeBin::Find(Double_t y) const {
69
70// Returns index of the cluster nearest in Y
71
72 if (y <= fClusters[0]->GetY()) return 0;
73 if (y > fClusters[fN-1]->GetY()) return fN;
74 Int_t b=0, e=fN-1, m=(b+e)/2;
75 for (; b<e; m=(b+e)/2) {
76 if (y > fClusters[m]->GetY()) b=m+1;
77 else e=m;
78 }
79 return m;
80}
81
82//______________________________________________________
83AliTRDcluster *AliTRDtimeBin::operator[](Int_t i)
84{
85 //
86 // Index operator
87 //
88
89 return fClusters[i];
90
91}