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