1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.1.4.2 2000/04/10 11:34:02 kowal2
20 Clusters handling in a new data structure
25 ///////////////////////////////////////////////////////////////////////////////
27 // Time Projection Chamber clusters objects //
29 // Origin: Marian Ivanov , GSI Darmstadt
33 ///////////////////////////////////////////////////////////////////////////////
35 #include "AliTPCCluster.h"
36 #include "TClonesArray.h"
37 #include "TDirectory.h"
40 const Int_t kDefSize = 1; //defalut size
43 ClassImp(AliTPCClustersRow)
46 //*****************************************************************************
48 //_____________________________________________________________________________
49 AliTPCClustersRow::AliTPCClustersRow()
54 fClusters = new TClonesArray("AliTPCcluster",kDefSize);
56 //_____________________________________________________________________________
57 AliTPCClustersRow::AliTPCClustersRow(Int_t size)
60 fClusters = new TClonesArray("AliTPCcluster",size);
63 //_____________________________________________________________________________
64 const AliTPCcluster* AliTPCClustersRow::operator[](Int_t i)
67 // return cluster at internal position i
69 if (fClusters==0) return 0;
70 void * cl = fClusters->UncheckedAt(i);
72 return (AliTPCcluster*)cl;
74 //_____________________________________________________________________________
75 void AliTPCClustersRow::Sort()
78 if (fClusters) fClusters->Sort();
81 //_____________________________________________________________________________
82 void AliTPCClustersRow::InsertCluster(const AliTPCcluster * c)
85 // Add a simulated cluster copy to the list
87 if(!fClusters) fClusters=new TClonesArray("AliTPCcluster",1000);
88 TClonesArray &lclusters = *fClusters;
89 new(lclusters[fNclusters++]) AliTPCcluster(*c);
92 //_____________________________________________________________________________
93 Int_t AliTPCClustersRow::Find(Double_t y) const
96 // return index of cluster nearest to given y position
99 cl=(AliTPCcluster*)fClusters->UncheckedAt(0);
100 if (y <= cl->fY) return 0;
101 cl=(AliTPCcluster*)fClusters->UncheckedAt(fNclusters-1);
102 if (y > cl->fY) return fNclusters;
103 //if (y <= clusters[0]->fY) return 0;
104 //if (y > clusters[num_of_clusters-1]->fY) return num_of_clusters;
105 Int_t b=0, e=fNclusters-1, m=(b+e)/2;
106 // Int_t b=0, e=num_of_clusters-1, m=(b+e)/2;
107 for (; b<e; m=(b+e)/2) {
108 cl = (AliTPCcluster*)fClusters->UncheckedAt(m);
109 if (y > cl->fY) b=m+1;
110 // if (y > clusters[m]->fY) b=m+1;
117 //_____________________________________________________________________________
119 ClassImp(AliTPCClustersArray)
121 AliTPCClustersArray::AliTPCClustersArray()
126 AliTPCClustersArray::~AliTPCClustersArray()
129 //object is only owner of fParam
131 if (fParam) delete fParam;
134 const AliTPCClustersRow * AliTPCClustersArray::GetRow(Int_t sector,Int_t row)
137 //return clusters ((AliTPCClustersRow *) per given sector and padrow
139 if (fParam==0) return 0;
140 Int_t index = fParam->GetIndex(sector,row);
141 return (AliTPCClustersRow *)(*this)[index];
144 Bool_t AliTPCClustersArray::LoadRow(Int_t sector,Int_t row)
147 //return clusters ((AliTPCClustersRow *) per given sector and padrow
149 if (fParam==0) return 0;
150 Int_t index = fParam->GetIndex(sector,row);
151 return LoadSegment(index);
154 Bool_t AliTPCClustersArray::StoreRow(Int_t sector,Int_t row)
157 //return clusters ((AliTPCClustersRow *) per given sector and padrow
159 if (fParam==0) return 0;
160 Int_t index = fParam->GetIndex(sector,row);
167 Bool_t AliTPCClustersArray::Setup(AliTPCParam *param)
170 //setup function to adjust array parameters
172 if (param==0) return kFALSE;
173 fParam = new AliTPCParam(*param);
174 return MakeArray(fParam->GetNRowsTotal());