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 */
8 // include files and class forward declarations
15 class AliDetectorParam;
18 class AliClusterFinder : public TObject {
22 // constructor which create cluster finder object
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);
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;}
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);
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);
55 Bool_t IsMaximum(Int_t i, Int_t j);
56 Bool_t IsVirtualMaximum(Float_t x, Float_t y);
58 void ResetSignal(); //reset signals to 0
59 void ResetStatus(); //reset status of signals to not used
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
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);
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;}
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);
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
94 void Transform(AliDigitCluster *c);
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; //
104 Float_t fMulSigma2; //
105 Float_t fDirSigmaFac; //!for direction border calculation
106 Float_t fDirAmpFac; //!for direction border calculation
108 Float_t fThreshold; //treshold;
109 Float_t fNoiseTh; //noise threshoshol to accept maximum
110 AliCell * fDigits; //field with all cell digits
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 -
129 TClonesArray * fClustersArray; //array with current clusters
131 //signalize that all fields were initialised
132 ClassDef(AliClusterFinder,2)
137 ////////////////////////////////////////////////////////////////////////////
138 ////////////////////////////////////////////////////////////////////////////
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;
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);}
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;}
167 Bool_t IsChecked() {return fStatus&&krBorder;}
168 Bool_t IsChecked(Int_t index) {return ((fStatus>>5)==index);}
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));}
177 Bool_t IsMaximum() {return ((fStatus&krMaximum)!=0);}
178 Bool_t IsMaximum(Int_t index) {return ( ((fStatus&krMaximum)!=0) && ((fStatus>>5)==index));}
180 void Reset() { fStatus = 0; fSignal =0;}
181 Int_t GetSignal() {return fSignal;}
182 Int_t GetStatus() {return fStatus;}
192 Int_t AliClusterFinder::GetSignal(Int_t i, Int_t j)
194 AliCell *c = GetCell(i,j);
197 else res = c->GetSignal();
203 Bool_t AliClusterFinder::IsBorder(Int_t index, Int_t i, Int_t j)
205 AliCell *c = GetCell(i,j);
207 if (c==0) res = kFALSE;
209 if (index == 0) res = c->IsBorder();
210 else res = c->IsBorder(index);
217 Bool_t AliClusterFinder::IsThBorder(Int_t index, Int_t i, Int_t j)
219 AliCell *c = GetCell(i,j);
221 if (c==0) res = kFALSE;
223 if (index == 0) res = c->IsThBorder();
224 else res = c->IsThBorder(index);
229 Bool_t AliClusterFinder::IsDirBorder(Int_t index, Int_t i, Int_t j)
231 AliCell *c = GetCell(i,j);
233 if (c==0) res = kFALSE;
235 if (index == 0) res = c->IsDirBorder();
236 else res = c->IsDirBorder(index);
241 Bool_t AliClusterFinder::IsChecked(Int_t index, Int_t i, Int_t j)
243 AliCell *c = GetCell(i,j);
245 if (c==0) res = kTRUE;
247 if (index == 0) res = c->IsChecked();
248 else res = c->IsChecked(index);
253 Bool_t AliClusterFinder::IsMaximum(Int_t index, Int_t i, Int_t j)
255 AliCell *c = GetCell(i,j);
257 if (c==0) res = kTRUE;
259 if (index == 0) res = c->IsMaximum();
260 else res = c->IsMaximum(index);
266 void AliClusterFinder::SetChecked(Int_t index, Int_t i, Int_t j)
268 AliCell *c = GetCell(i,j);
270 if (index>0) c->SetChecked(index);
271 else c->SetChecked();
275 void AliClusterFinder::SetBorder(Int_t index, Int_t i, Int_t j)
277 AliCell *c = GetCell(i,j);
279 if (index>0) c->SetBorder(index);
280 // else c->SetBorder();
285 void AliClusterFinder::SetThBorder(Int_t index, Int_t i, Int_t j)
287 AliCell *c = GetCell(i,j);
289 if (index>0) c->SetThBorder(index);
290 else c->SetThBorder(0);
295 void AliClusterFinder::SetDirBorder(Int_t index, Int_t i, Int_t j)
297 AliCell *c = GetCell(i,j);
299 if (index>0) c->SetDirBorder(index);
300 else c->SetDirBorder(0);
305 void AliClusterFinder::SetMaximum(Int_t index, Int_t i, Int_t j)
307 AliCell *c = GetCell(i,j);
309 if (index>0) c->SetMaximum(index);
310 else c->SetMaximum(0);
314 #endif /* TCLUSTERFINDER_H */