X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDtimeBin.cxx;h=0c4dee47a1c3a33a3c765370e1c819152c1048ca;hb=1afc1008439f5daf583b542d5ef42d4216744ca3;hp=c6dd571ad56c8ffdfdc542a9b6765299c84a9282;hpb=46d29e70f4a95bcdfb79ded060b04aee708ac03b;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDtimeBin.cxx b/TRD/AliTRDtimeBin.cxx index c6dd571ad56..0c4dee47a1c 100644 --- a/TRD/AliTRDtimeBin.cxx +++ b/TRD/AliTRDtimeBin.cxx @@ -13,57 +13,97 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* -$Log$ -Revision 1.1.2.2 2000/10/04 16:34:58 cblume -Replace include files by forward declarations - -Revision 1.1.2.1 2000/09/22 14:47:52 cblume -Add the tracking code - -*/ - +/* $Id$ */ + +//////////////////////////////////////////////////////////////////////////// +// // +// Hit compression class // +// Adapted from AliTPCTimeBin by Marian // +// // +//////////////////////////////////////////////////////////////////////////// + #include "AliTRDcluster.h" -#include "AliTRDconst.h" #include "AliTRDtimeBin.h" ClassImp(AliTRDtimeBin) -//______________________________________________________ +//_____________________________________________________________________________ +AliTRDtimeBin::AliTRDtimeBin() + :TObject() + ,fN(0) +{ + // + // Default constructor + // -void AliTRDtimeBin::InsertCluster(AliTRDcluster* c, UInt_t index) { + for (UInt_t i = 0; i < kMaxClusterPerTimeBin; i++) { + fClusters[i] = 0; + } -// Insert cluster in TimeBin cluster array. -// Clusters are sorted according to Y coordinate. +} - if (fN==kMAX_CLUSTER_PER_TIME_BIN) { - printf("AliTRDtimeBin::InsertCluster(): Too many clusters !\n"); +//_____________________________________________________________________________ +void AliTRDtimeBin::InsertCluster(AliTRDcluster* c, UInt_t index) +{ + // + // Insert cluster in TimeBin cluster array. + // Clusters are sorted according to Y coordinate. + // + + if (fN == kMaxClusterPerTimeBin) { + AliError("Too many clusters!\n"); return; } - if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;} - Int_t i=Find(c->GetY()); - memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTRDcluster*)); - memmove(fIndex +i+1 ,fIndex +i,(fN-i)*sizeof(UInt_t)); - fIndex[i]=index; fClusters[i]=c; fN++; + + if (fN == 0) { + fIndex[0] = index; + fClusters[fN++] = c; + return; + } + + Int_t i = Find(c->GetY()); + + memmove(fClusters+i+1,fClusters+i,(fN-i)*sizeof(AliTRDcluster*)); + memmove(fIndex +i+1,fIndex +i,(fN-i)*sizeof(UInt_t)); + + fIndex[i] = index; + fClusters[i] = c; + fN++; + } -//______________________________________________________ +//_____________________________________________________________________________ +Int_t AliTRDtimeBin::Find(Double_t y) const +{ + // + // Returns index of the cluster nearest in Y + // -Int_t AliTRDtimeBin::Find(Double_t y) const { + if (y <= fClusters[ 0]->GetY()) { + return 0; + } + if (y > fClusters[fN-1]->GetY()) { + return fN; + } -// Returns index of the cluster nearest in Y + Int_t b = 0; + Int_t e = fN - 1; + Int_t m = (b + e) / 2; - if (y <= fClusters[0]->GetY()) return 0; - if (y > fClusters[fN-1]->GetY()) return fN; - Int_t b=0, e=fN-1, m=(b+e)/2; - for (; b fClusters[m]->GetY()) b=m+1; - else e=m; + for ( ; b < e; m = (b+e)/2) { + if (y > fClusters[m]->GetY()) { + b = m + 1; + } + else { + e = m; + } } + return m; + } -//______________________________________________________ +//_____________________________________________________________________________ AliTRDcluster *AliTRDtimeBin::operator[](Int_t i) { //