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