1 #ifndef TCLUSTERFINDER_H
2 #define TCLUSTERFINDER_H
5 // include files and class forward declarations
8 //#include "AliComplexCluster.h"
11 class AliComplexCluster;
14 class AliDetectorParam;
17 class AliDigitCluster;
19 class AliTPCClusterFinder : public TObject {
22 AliTPCClusterFinder();
23 // constructor which create cluster finder object
24 ~AliTPCClusterFinder();
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);
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;}
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;}
48 AliH2F * DrawHisto( const char *option,Float_t x1=-1, Float_t x2=-1, Float_t y1=-1, Float_t y2=-1);
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);
54 void SetSigmaX(Float_t s0, Float_t s1x, Float_t s1y);
55 void SetSigmaY(Float_t s0, Float_t s1x, Float_t s1y);
58 Bool_t IsMaximum(Int_t i, Int_t j);
59 Bool_t IsVirtualMaximum(Float_t x, Float_t y);
61 void ResetSignal(); //reset signals to 0
62 void ResetStatus(); //reset status of signals to not used
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
67 void SetDetectorParam(AliDetectorParam*param) {fDetectorParam = param;}
68 //set Detector parameters -necesssary to estimate cluster size
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);
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;}
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);
96 inline Int_t GetSignal(Int_t i, Int_t j);
97 inline void SetSignal(Int_t signal, Int_t i, Int_t j);
98 Float_t GetVirtualSignal(Float_t ri, Float_t rj);
99 //create new virtual cell and interpolate signal at position ri,rj
101 void Transform(AliDigitCluster *c);
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; //
111 Float_t fMulSigma2; //
112 Float_t fDirSigmaFac; //!for direction border calculation
113 Float_t fDirAmpFac; //!for direction border calculation
115 Float_t fThreshold; //treshold;
116 Float_t fNoiseTh; //noise threshoshol to accept maximum
117 Int_t *fDigits; //field with all digits
118 AliCell *fCells; //field with all cell status
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
127 AliDetectorParam * fDetectorParam; //pointer to detector param - finder is not owner
128 Int_t * fDetectorIndex; // detector index -
130 Float_t fSigmaX[3]; //x cluster size parametrization
131 Float_t fSigmaY[3]; //y cluster size parametrization
141 TClonesArray * fClustersArray; //array with current clusters
143 //signalize that all fields were initialised
144 ClassDef(AliTPCClusterFinder,2) // Cluster finder
149 ////////////////////////////////////////////////////////////////////////////
150 ////////////////////////////////////////////////////////////////////////////
155 enum State {krCheck = 1,krBorder = 2,krThBorder = 4,krDirBorder = 8, krMaximum = 16,krIndexNull =0x1F};
157 AliCell(Int_t status = 0){fStatus = status;}
158 //at the begining set
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);}
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;}
174 Bool_t IsChecked() {return fStatus&&krBorder;}
175 Bool_t IsChecked(Int_t index) {return ((fStatus>>5)==index);}
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));}
184 Bool_t IsMaximum() {return ((fStatus&krMaximum)!=0);}
185 Bool_t IsMaximum(Int_t index) {return ( ((fStatus&krMaximum)!=0) && ((fStatus>>5)==index));}
187 void Reset() { fStatus = 0;}
189 Int_t GetStatus() {return fStatus;}
193 // ClassDef(AliCell,0)
198 Int_t AliTPCClusterFinder::GetSignal(Int_t i, Int_t j)
200 return ( (i>=0) && (i<fDimX) && (j>=0) && (j<fDimY) ) ? fDigits[i+j*fDimX]: 0;
204 void AliTPCClusterFinder::SetSignal(Int_t signal, Int_t i, Int_t j)
206 if ( (i>=0) && (i<fDimX) && (j>=0) && (j<fDimY) ) fDigits[i+j*fDimX] = signal;
212 Bool_t AliTPCClusterFinder::IsBorder(Int_t index, Int_t i, Int_t j)
214 AliCell *c = GetCell(i,j);
216 if (c==0) res = kFALSE;
218 if (index == 0) res = c->IsBorder();
219 else res = c->IsBorder(index);
226 Bool_t AliTPCClusterFinder::IsThBorder(Int_t index, Int_t i, Int_t j)
228 AliCell *c = GetCell(i,j);
230 if (c==0) res = kFALSE;
232 if (index == 0) res = c->IsThBorder();
233 else res = c->IsThBorder(index);
238 Bool_t AliTPCClusterFinder::IsDirBorder(Int_t index, Int_t i, Int_t j)
240 AliCell *c = GetCell(i,j);
242 if (c==0) res = kFALSE;
244 if (index == 0) res = c->IsDirBorder();
245 else res = c->IsDirBorder(index);
250 Bool_t AliTPCClusterFinder::IsChecked(Int_t index, Int_t i, Int_t j)
252 AliCell *c = GetCell(i,j);
254 if (c==0) res = kTRUE;
256 if (index == 0) res = c->IsChecked();
257 else res = c->IsChecked(index);
262 Bool_t AliTPCClusterFinder::IsMaximum(Int_t index, Int_t i, Int_t j)
264 AliCell *c = GetCell(i,j);
266 if (c==0) res = kTRUE;
268 if (index == 0) res = c->IsMaximum();
269 else res = c->IsMaximum(index);
275 void AliTPCClusterFinder::SetChecked(Int_t index, Int_t i, Int_t j)
277 AliCell *c = GetCell(i,j);
279 if (index>0) c->SetChecked(index);
280 else c->SetChecked();
284 void AliTPCClusterFinder::SetBorder(Int_t index, Int_t i, Int_t j)
286 AliCell *c = GetCell(i,j);
288 if (index>0) c->SetBorder(index);
289 // else c->SetBorder();
294 void AliTPCClusterFinder::SetThBorder(Int_t index, Int_t i, Int_t j)
296 AliCell *c = GetCell(i,j);
298 if (index>0) c->SetThBorder(index);
299 else c->SetThBorder(0);
304 void AliTPCClusterFinder::SetDirBorder(Int_t index, Int_t i, Int_t j)
306 AliCell *c = GetCell(i,j);
308 if (index>0) c->SetDirBorder(index);
309 else c->SetDirBorder(0);
314 void AliTPCClusterFinder::SetMaximum(Int_t index, Int_t i, Int_t j)
316 AliCell *c = GetCell(i,j);
318 if (index>0) c->SetMaximum(index);
319 else c->SetMaximum(0);
323 #endif /* TCLUSTERFINDER_H */