]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCCluster.cxx
Correction in Binaries().
[u/mrichter/AliRoot.git] / TPC / AliTPCCluster.cxx
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$
18 Revision 1.2  2000/04/17 09:37:33  kowal2
19 removed obsolete AliTPCDigitsDisplay.C
20
21 Revision 1.1.4.2  2000/04/10 11:34:02  kowal2
22
23 Clusters handling in a new data structure
24
25 */
26
27
28 ///////////////////////////////////////////////////////////////////////////////
29 //                                                                           //
30 //  Time Projection Chamber clusters objects                                //
31 //
32 //  Origin: Marian Ivanov , GSI Darmstadt
33 //                                                                           //
34 //                                                                           //
35 //                                                                          //
36 ///////////////////////////////////////////////////////////////////////////////
37 #include "AliTPC.h"
38 #include "AliTPCCluster.h"
39 #include "TClonesArray.h"
40 #include "TDirectory.h"
41
42
43 const Int_t kDefSize = 1;  //defalut size
44
45
46 ClassImp(AliTPCClustersRow) 
47
48
49 //*****************************************************************************
50 //
51 //_____________________________________________________________________________
52 AliTPCClustersRow::AliTPCClustersRow() 
53 {  
54   //
55   //default constructor
56   fNclusters=0;
57   fClusters =  new TClonesArray("AliTPCcluster",kDefSize);
58   fParam = 0;
59 }
60 //_____________________________________________________________________________
61 AliTPCClustersRow::AliTPCClustersRow(Int_t size) 
62 {  
63   fNclusters=0;
64   fClusters = new TClonesArray("AliTPCcluster",size);
65 }
66
67 //_____________________________________________________________________________
68 const  AliTPCcluster* AliTPCClustersRow::operator[](Int_t i)
69 {
70   //
71   // return cluster at internal position i
72   //
73   if (fClusters==0) return 0;
74   void * cl = fClusters->UncheckedAt(i);
75   if (cl==0) return 0;
76   return  (AliTPCcluster*)cl;
77 }
78 //_____________________________________________________________________________
79 void  AliTPCClustersRow::Sort()
80 {
81   // sort cluster 
82   if (fClusters) fClusters->Sort();
83 }
84
85 //_____________________________________________________________________________
86 void AliTPCClustersRow::InsertCluster(const AliTPCcluster * c) 
87
88   //
89   // Add a simulated cluster copy to the list
90   //
91   if(!fClusters) fClusters=new TClonesArray("AliTPCcluster",1000);
92   TClonesArray &lclusters = *fClusters;
93   new(lclusters[fNclusters++]) AliTPCcluster(*c);
94 }
95
96 //_____________________________________________________________________________
97 Int_t AliTPCClustersRow::Find(Double_t y) const 
98 {
99   //
100   // return index of cluster nearest to given y position
101   //
102   AliTPCcluster* cl;
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;
115     else e=m; 
116   }
117   return m;
118 }
119
120
121 //_____________________________________________________________________________
122
123 ClassImp(AliTPCClustersArray) 
124
125 AliTPCClustersArray::AliTPCClustersArray()
126 {
127   fParam = 0;
128 }
129
130 AliTPCClustersArray::~AliTPCClustersArray()
131 {
132   //
133   //object is only owner of fParam
134   //
135   if (fParam) delete fParam;
136 }
137
138 const AliTPCClustersRow * AliTPCClustersArray::GetRow(Int_t sector,Int_t row)
139 {
140   //
141   //return clusters ((AliTPCClustersRow *) per given sector and padrow
142   //
143   if (fParam==0) return 0;
144   Int_t index = fParam->GetIndex(sector,row);  
145   return (AliTPCClustersRow *)(*this)[index];
146 }
147
148 Bool_t  AliTPCClustersArray::LoadRow(Int_t sector,Int_t row)
149 {
150   //
151   //return clusters ((AliTPCClustersRow *) per given sector and padrow
152   //
153   if (fParam==0) return 0;
154   Int_t index = fParam->GetIndex(sector,row);  
155   return LoadSegment(index);
156 }
157
158 Bool_t  AliTPCClustersArray::StoreRow(Int_t sector,Int_t row)
159 {
160   //
161   //return clusters ((AliTPCClustersRow *) per given sector and padrow
162   //
163   if (fParam==0) return 0;
164   Int_t index = fParam->GetIndex(sector,row);  
165   StoreSegment(index);
166   return kTRUE;
167 }
168
169
170
171 Bool_t AliTPCClustersArray::Setup(AliTPCParam *param)
172 {
173   //
174   //setup  function to adjust array parameters
175   //
176   if (param==0) return kFALSE;
177   fParam = new AliTPCParam(*param);
178   return MakeArray(fParam->GetNRowsTotal());
179 }