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.2 2000/04/17 09:37:33 kowal2
19 removed obsolete AliTPCDigitsDisplay.C
21 Revision 1.1.4.2 2000/04/10 11:34:02 kowal2
23 Clusters handling in a new data structure
28 ///////////////////////////////////////////////////////////////////////////////
30 // Time Projection Chamber clusters objects //
32 // Origin: Marian Ivanov , GSI Darmstadt
36 ///////////////////////////////////////////////////////////////////////////////
38 #include "AliTPCCluster.h"
39 #include "TClonesArray.h"
40 #include "TDirectory.h"
43 const Int_t kDefSize = 1; //defalut size
46 ClassImp(AliTPCClustersRow)
49 //*****************************************************************************
51 //_____________________________________________________________________________
52 AliTPCClustersRow::AliTPCClustersRow()
57 fClusters = new TClonesArray("AliTPCcluster",kDefSize);
60 //_____________________________________________________________________________
61 AliTPCClustersRow::AliTPCClustersRow(Int_t size)
64 fClusters = new TClonesArray("AliTPCcluster",size);
67 //_____________________________________________________________________________
68 const AliTPCcluster* AliTPCClustersRow::operator[](Int_t i)
71 // return cluster at internal position i
73 if (fClusters==0) return 0;
74 void * cl = fClusters->UncheckedAt(i);
76 return (AliTPCcluster*)cl;
78 //_____________________________________________________________________________
79 void AliTPCClustersRow::Sort()
82 if (fClusters) fClusters->Sort();
85 //_____________________________________________________________________________
86 void AliTPCClustersRow::InsertCluster(const AliTPCcluster * c)
89 // Add a simulated cluster copy to the list
91 if(!fClusters) fClusters=new TClonesArray("AliTPCcluster",1000);
92 TClonesArray &lclusters = *fClusters;
93 new(lclusters[fNclusters++]) AliTPCcluster(*c);
96 //_____________________________________________________________________________
97 Int_t AliTPCClustersRow::Find(Double_t y) const
100 // return index of cluster nearest to given y position
103 cl=(AliTPCcluster*)fClusters->UncheckedAt(0);
104 if (y <= cl->fY) return 0;
105 cl=(AliTPCcluster*)fClusters->UncheckedAt(fNclusters-1);
106 if (y > cl->fY) return fNclusters;
107 //if (y <= clusters[0]->fY) return 0;
108 //if (y > clusters[num_of_clusters-1]->fY) return num_of_clusters;
109 Int_t b=0, e=fNclusters-1, m=(b+e)/2;
110 // Int_t b=0, e=num_of_clusters-1, m=(b+e)/2;
111 for (; b<e; m=(b+e)/2) {
112 cl = (AliTPCcluster*)fClusters->UncheckedAt(m);
113 if (y > cl->fY) b=m+1;
114 // if (y > clusters[m]->fY) b=m+1;
121 //_____________________________________________________________________________
123 ClassImp(AliTPCClustersArray)
125 AliTPCClustersArray::AliTPCClustersArray()
130 AliTPCClustersArray::~AliTPCClustersArray()
133 //object is only owner of fParam
135 if (fParam) delete fParam;
138 const AliTPCClustersRow * AliTPCClustersArray::GetRow(Int_t sector,Int_t row)
141 //return clusters ((AliTPCClustersRow *) per given sector and padrow
143 if (fParam==0) return 0;
144 Int_t index = fParam->GetIndex(sector,row);
145 return (AliTPCClustersRow *)(*this)[index];
148 Bool_t AliTPCClustersArray::LoadRow(Int_t sector,Int_t row)
151 //return clusters ((AliTPCClustersRow *) per given sector and padrow
153 if (fParam==0) return 0;
154 Int_t index = fParam->GetIndex(sector,row);
155 return LoadSegment(index);
158 Bool_t AliTPCClustersArray::StoreRow(Int_t sector,Int_t row)
161 //return clusters ((AliTPCClustersRow *) per given sector and padrow
163 if (fParam==0) return 0;
164 Int_t index = fParam->GetIndex(sector,row);
171 Bool_t AliTPCClustersArray::Setup(AliTPCParam *param)
174 //setup function to adjust array parameters
176 if (param==0) return kFALSE;
177 fParam = new AliTPCParam(*param);
178 return MakeArray(fParam->GetNRowsTotal());