cc80f89e |
1 | #ifndef TCLUSTERFINDER_H |
2 | #define TCLUSTERFINDER_H |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * See cxx source for full Copyright notice */ |
5 | |
6 | /* $Id$ */ |
7 | |
8 | // include files and class forward declarations |
9 | #include "TObject.h" |
10 | #include "TH2.h" |
11 | class TClonesArray; |
12 | class AliCluster; |
13 | class AliCell; |
14 | class AliArrayI; |
15 | class AliDetectorParam; |
16 | class TMinuit; |
17 | class AliH2F; |
18 | class AliClusterFinder : public TObject { |
19 | |
20 | public: |
21 | AliClusterFinder(); |
22 | // constructor which create cluster finder object |
23 | ~AliClusterFinder(); |
24 | void GetHisto(TH2F * his2); |
25 | //reset object to include histograms values |
26 | TClonesArray * FindPeaks1( TClonesArray *arr=0); |
27 | TClonesArray * FindPeaks2( TClonesArray *arr=0); |
28 | TClonesArray * FindPeaks3( TClonesArray *arr=0); |
29 | |
30 | void FindMaxima(); |
31 | // if at point is local maximum return cell with maximum information (for testing only |
32 | Int_t & GetNType(){return fNType;} //return type of neighborow for max determinatio |
33 | void SetThreshold(Float_t threshold) { fThreshold = threshold;} |
34 | void SetNoise(Float_t noise) {fNoiseTh =noise;} |
35 | void SetDirSigmaFac(Float_t fac) {fDirSigmaFac = fac;} |
36 | void SetDirAmpFac(Float_t fac) {fDirAmpFac = fac;} |
37 | |
38 | void SetDetectorParam(AliDetectorParam*param) {fDetectorParam = param;} |
39 | //set Detector parameters -necesssary to estimate cluster size |
40 | void SetDetectorIndex(Int_t *index) {fDetectorIndex = index;} |
41 | //set index of described detector |
42 | Bool_t SetSigma2(Int_t i, Int_t j, Float_t & sigmax2, Float_t & sigmay2); |
43 | //set sigmax and sigma y accordig i and j position of cell |
44 | void SetMulSigma(Float_t sigma) {fMulSigma2= sigma*sigma;} |
45 | AliArrayI * GetStack(){return fStack;} |
46 | Int_t GetStackIndex(){return fStackIndex;} |
47 | void SetBFit(Bool_t fit) {fBFit = fit;} |
48 | TMinuit * GetMinuit() {return fMinuit;} |
49 | AliH2F * Draw( const char *option=0,Float_t x1=-1, Float_t x2=-1, Float_t y1=-1, Float_t y2=-1); |
50 | //draw digits |
51 | void DrawCluster(Int_t color=5, Int_t size=5, Int_t style=4); |
52 | AliH2F * DrawBorders( const char *option=0, AliH2F *his=0, Int_t type =0, Float_t x1=-1, Float_t x2=-1, Float_t y1=-1, Float_t y2=-1); |
53 | //draw digits |
54 | public: |
55 | Bool_t IsMaximum(Int_t i, Int_t j); |
56 | Bool_t IsVirtualMaximum(Float_t x, Float_t y); |
57 | |
58 | void ResetSignal(); //reset signals to 0 |
59 | void ResetStatus(); //reset status of signals to not used |
60 | |
61 | AliCell * GetCell(Int_t i, Int_t j); |
62 | //return reference to the cell with index i,j |
63 | void SetBlockIndex(Int_t *index); //calculate which indexes we must check for border |
64 | public: |
65 | void AddToStack(Int_t i, Int_t j, Int_t signal); |
66 | //add given cell to the stack of particles |
67 | void GetClusterStatistic(AliDigitCluster & cluster); |
68 | //go through the cluster and calculate statistic |
69 | void GetClusterFit(AliDigitCluster & cluster); |
70 | Bool_t CheckIfDirBorder(Float_t x, Float_t y, Int_t i,Int_t j); |
71 | //check if given cell is border |
72 | void Adjacent(Int_t i, Int_t j); |
73 | //recursion procedure |
74 | Float_t ItoX(Float_t i) {return (fX1)+(i+0.5)*(fX2-fX1)/fDimX;} |
75 | Float_t JtoY(Float_t j) {return (fY1)+(j+0.5)*(fY2-fY1)/fDimY;} |
76 | |
77 | inline Bool_t IsChecked(Int_t index, Int_t i, Int_t j); |
78 | inline Bool_t IsBorder(Int_t index, Int_t i, Int_t j); |
79 | inline Bool_t IsThBorder(Int_t index, Int_t i, Int_t j); |
80 | inline Bool_t IsDirBorder(Int_t index, Int_t i, Int_t j); |
81 | inline Bool_t IsMaximum(Int_t index, Int_t i, Int_t j); |
82 | inline void SetChecked(Int_t index, Int_t i, Int_t j); |
83 | inline void SetBorder(Int_t index, Int_t i, Int_t j); |
84 | inline void SetThBorder(Int_t index, Int_t i, Int_t j); |
85 | inline void SetDirBorder(Int_t index, Int_t i, Int_t j); |
86 | inline void SetMaximum(Int_t index, Int_t i, Int_t j); |
87 | |
88 | |
89 | |
90 | inline Int_t GetSignal(Int_t i, Int_t j); |
91 | Float_t GetVirtualSignal(Float_t ri, Float_t rj); |
92 | //create new virtual cell and interpolate signal at position ri,rj |
93 | |
94 | void Transform(AliDigitCluster *c); |
95 | private: |
96 | Int_t fNType; //type of neighborow for maximum determination |
97 | Float_t fCurrentMaxX; //!current cluster maximum X index |
98 | Float_t fCurrentMaxY; //!current cluster maximum X index |
99 | Float_t fCurrentSigmaX2; //!current sigmax2 according detector (updated by function ...) |
100 | Float_t fCurrentSigmaY2;//! |
101 | Float_t fCurrentMaxAmp;//!current cluster maximum amplitude |
102 | Bool_t fBDistType; // |
103 | Bool_t fBFit; // |
104 | Float_t fMulSigma2; // |
105 | Float_t fDirSigmaFac; //!for direction border calculation |
106 | Float_t fDirAmpFac; //!for direction border calculation |
107 | |
108 | Float_t fThreshold; //treshold; |
109 | Float_t fNoiseTh; //noise threshoshol to accept maximum |
110 | AliCell * fDigits; //field with all cell digits |
111 | |
112 | |
113 | Int_t fIndex; //!index of current cluster |
114 | AliArrayI * fStack; //!stack with digits index |
115 | Int_t fStackIndex; //!stack index |
116 | TMinuit *fMinuit; //!minuit object |
117 | AliDetectorParam * fDetectorParam; //pointer to detector param - finder is not owner |
118 | Int_t * fDetectorIndex; // detector index - |
119 | //original frame |
120 | Float_t fX1; |
121 | Float_t fY1; |
122 | Float_t fX2; |
123 | Float_t fY2; |
124 | Int_t fDimX; |
125 | Int_t fDimY; |
126 | Int_t fOver; |
127 | |
128 | // |
129 | TClonesArray * fClustersArray; //array with current clusters |
130 | Bool_t rOK; |
131 | //signalize that all fields were initialised |
132 | ClassDef(AliClusterFinder,2) |
133 | }; |
134 | |
135 | |
136 | |
137 | //////////////////////////////////////////////////////////////////////////// |
138 | //////////////////////////////////////////////////////////////////////////// |
139 | //objec AliCell |
140 | |
141 | const Int_t krCheck = 1; |
142 | const Int_t krBorder = 2; |
143 | const Int_t krThBorder = 4; |
144 | const Int_t krDirBorder = 8; |
145 | const Int_t krMaximum = 16; |
146 | const Int_t krIndexNull =0x1F; |
147 | |
148 | class AliCell{ |
149 | public : |
150 | AliCell(Int_t signal =0, Int_t status = 0){fSignal =signal;fStatus = status;} |
151 | //at the begining set |
152 | void SetSignal(Int_t signal){fSignal = signal;} |
153 | void SetStatus(Int_t status){fStatus = status;} |
154 | void SetChecked(Int_t index) {fStatus &=krIndexNull; fStatus+=(index<<5); fStatus|=krCheck;} |
155 | void SetChecked() {fStatus|=krCheck;} |
156 | void SetBorder(Int_t index) {fStatus &=krIndexNull; fStatus |= krBorder;fStatus+=(index<<5);} |
157 | void SetThBorder(Int_t index) {fStatus &=krIndexNull;fStatus|=krBorder|krThBorder;fStatus+=(index<<5);} |
158 | void SetDirBorder(Int_t index) {fStatus &=krIndexNull;fStatus|=krBorder|krDirBorder;fStatus+=(index<<5);} |
159 | void SetMaximum(Int_t index) {fStatus &=krIndexNull;fStatus|=krMaximum;fStatus+=(index<<5);} |
160 | |
161 | |
162 | void SetUnChecked(){if (fStatus&krCheck) fStatus-=krCheck;} |
163 | void SetUnBorder(){if (fStatus&krBorder) fStatus-=krBorder;} |
164 | void SetThUnBorder(){SetUnBorder();if (fStatus&krBorder) fStatus-=krThBorder+krBorder;} |
165 | void SetDirUnBorder(){SetUnBorder();if (fStatus&krBorder) fStatus-=krDirBorder+krBorder;} |
166 | |
167 | Bool_t IsChecked() {return fStatus&&krBorder;} |
168 | Bool_t IsChecked(Int_t index) {return ((fStatus>>5)==index);} |
169 | |
170 | Bool_t IsBorder() {return ((fStatus&krBorder)!=0);} |
171 | Bool_t IsBorder(Int_t index) {return ( ((fStatus&krBorder)!=0) && ((fStatus>>5)==index));} |
172 | Bool_t IsDirBorder() {return ((fStatus&krDirBorder)!=0);} |
173 | Bool_t IsDirBorder(Int_t index) {return ( ((fStatus&krDirBorder)!=0) && ((fStatus>>5)==index));} |
174 | Bool_t IsThBorder() {return ((fStatus&krThBorder)!=0);} |
175 | Bool_t IsThBorder(Int_t index) {return ( ((fStatus&krThBorder)!=0) && ((fStatus>>5)==index));} |
176 | |
177 | Bool_t IsMaximum() {return ((fStatus&krMaximum)!=0);} |
178 | Bool_t IsMaximum(Int_t index) {return ( ((fStatus&krMaximum)!=0) && ((fStatus>>5)==index));} |
179 | |
180 | void Reset() { fStatus = 0; fSignal =0;} |
181 | Int_t GetSignal() {return fSignal;} |
182 | Int_t GetStatus() {return fStatus;} |
183 | |
184 | |
185 | private: |
186 | Int_t fSignal; |
187 | Int_t fStatus; |
188 | }; |
189 | |
190 | |
191 | |
192 | Int_t AliClusterFinder::GetSignal(Int_t i, Int_t j) |
193 | { |
194 | AliCell *c = GetCell(i,j); |
195 | Int_t res; |
196 | if (c==0) res = -1; |
197 | else res = c->GetSignal(); |
198 | return res; |
199 | } |
200 | |
201 | |
202 | |
203 | Bool_t AliClusterFinder::IsBorder(Int_t index, Int_t i, Int_t j) |
204 | { |
205 | AliCell *c = GetCell(i,j); |
206 | Bool_t res; |
207 | if (c==0) res = kFALSE; |
208 | else { |
209 | if (index == 0) res = c->IsBorder(); |
210 | else res = c->IsBorder(index); |
211 | } |
212 | return res; |
213 | } |
214 | |
215 | |
216 | |
217 | Bool_t AliClusterFinder::IsThBorder(Int_t index, Int_t i, Int_t j) |
218 | { |
219 | AliCell *c = GetCell(i,j); |
220 | Bool_t res; |
221 | if (c==0) res = kFALSE; |
222 | else { |
223 | if (index == 0) res = c->IsThBorder(); |
224 | else res = c->IsThBorder(index); |
225 | } |
226 | return res; |
227 | } |
228 | |
229 | Bool_t AliClusterFinder::IsDirBorder(Int_t index, Int_t i, Int_t j) |
230 | { |
231 | AliCell *c = GetCell(i,j); |
232 | Bool_t res; |
233 | if (c==0) res = kFALSE; |
234 | else { |
235 | if (index == 0) res = c->IsDirBorder(); |
236 | else res = c->IsDirBorder(index); |
237 | } |
238 | return res; |
239 | } |
240 | |
241 | Bool_t AliClusterFinder::IsChecked(Int_t index, Int_t i, Int_t j) |
242 | { |
243 | AliCell *c = GetCell(i,j); |
244 | Bool_t res; |
245 | if (c==0) res = kTRUE; |
246 | else { |
247 | if (index == 0) res = c->IsChecked(); |
248 | else res = c->IsChecked(index); |
249 | } |
250 | return res; |
251 | } |
252 | |
253 | Bool_t AliClusterFinder::IsMaximum(Int_t index, Int_t i, Int_t j) |
254 | { |
255 | AliCell *c = GetCell(i,j); |
256 | Bool_t res; |
257 | if (c==0) res = kTRUE; |
258 | else { |
259 | if (index == 0) res = c->IsMaximum(); |
260 | else res = c->IsMaximum(index); |
261 | } |
262 | return res; |
263 | } |
264 | |
265 | |
266 | void AliClusterFinder::SetChecked(Int_t index, Int_t i, Int_t j) |
267 | { |
268 | AliCell *c = GetCell(i,j); |
269 | if (c!=0) { |
270 | if (index>0) c->SetChecked(index); |
271 | else c->SetChecked(); |
272 | } |
273 | } |
274 | |
275 | void AliClusterFinder::SetBorder(Int_t index, Int_t i, Int_t j) |
276 | { |
277 | AliCell *c = GetCell(i,j); |
278 | if (c!=0) { |
279 | if (index>0) c->SetBorder(index); |
280 | // else c->SetBorder(); |
281 | } |
282 | } |
283 | |
284 | |
285 | void AliClusterFinder::SetThBorder(Int_t index, Int_t i, Int_t j) |
286 | { |
287 | AliCell *c = GetCell(i,j); |
288 | if (c!=0) { |
289 | if (index>0) c->SetThBorder(index); |
290 | else c->SetThBorder(0); |
291 | } |
292 | } |
293 | |
294 | |
295 | void AliClusterFinder::SetDirBorder(Int_t index, Int_t i, Int_t j) |
296 | { |
297 | AliCell *c = GetCell(i,j); |
298 | if (c!=0) { |
299 | if (index>0) c->SetDirBorder(index); |
300 | else c->SetDirBorder(0); |
301 | } |
302 | } |
303 | |
304 | |
305 | void AliClusterFinder::SetMaximum(Int_t index, Int_t i, Int_t j) |
306 | { |
307 | AliCell *c = GetCell(i,j); |
308 | if (c!=0) { |
309 | if (index>0) c->SetMaximum(index); |
310 | else c->SetMaximum(0); |
311 | } |
312 | } |
313 | |
314 | #endif /* TCLUSTERFINDER_H */ |