]>
Commit | Line | Data |
---|---|---|
b0f5e3fc | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
b0f5e3fc | 16 | #include "AliITSClusterFinder.h" |
f8d9a5b8 | 17 | #include "AliITSdigit.h" |
b0f5e3fc | 18 | #include "AliRun.h" |
e8189707 | 19 | #include "AliITS.h" |
b0f5e3fc | 20 | |
b0f5e3fc | 21 | ClassImp(AliITSClusterFinder) |
22 | ||
9de0700b | 23 | //---------------------------------------------------------------------- |
24 | AliITSClusterFinder::AliITSClusterFinder(){ | |
25 | // default cluster finder | |
26 | ||
27 | fSegmentation = 0; | |
28 | fResponse = 0; | |
29 | fMap = 0; | |
30 | fDigits = 0; | |
31 | fNdigits = 0; | |
32 | fNRawClusters = 0; | |
33 | fNperMax = 0; | |
34 | fDeclusterFlag= 0; | |
35 | fClusterSize = 0; | |
36 | fNPeaks = 0; | |
37 | } | |
38 | //---------------------------------------------------------------------- | |
39 | AliITSClusterFinder::AliITSClusterFinder(AliITSsegmentation *seg, | |
40 | AliITSresponse *response, | |
41 | TClonesArray *digits){ | |
b0f5e3fc | 42 | // cluster finder |
43 | fSegmentation=seg; | |
44 | fResponse=response; | |
45 | fMap = 0; | |
46 | ||
47 | fDigits=digits; | |
48 | fNdigits = fDigits->GetEntriesFast(); | |
49 | ||
50 | fNRawClusters=0; | |
51 | ||
52 | SetNperMax(); | |
53 | SetClusterSize(); | |
54 | SetDeclusterFlag(); | |
55 | ||
56 | fNPeaks=-1; | |
57 | } | |
9de0700b | 58 | //---------------------------------------------------------------------- |
59 | AliITSClusterFinder::~AliITSClusterFinder(){ | |
60 | // destructor cluster finder | |
b0f5e3fc | 61 | |
9de0700b | 62 | // Zero local pointers. Other classes own these pointers. |
55cd883f | 63 | fSegmentation = 0; |
9de0700b | 64 | fResponse = 0; |
65 | fMap = 0; | |
66 | fDigits = 0; | |
67 | fNdigits = 0; | |
68 | fNRawClusters = 0; | |
69 | fNperMax = 0; | |
70 | fDeclusterFlag= 0; | |
71 | fClusterSize = 0; | |
72 | fNPeaks = 0; | |
b0f5e3fc | 73 | } |
b0f5e3fc | 74 | //__________________________________________________________________________ |
75 | AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source){ | |
9de0700b | 76 | // Copy Constructor |
77 | if(&source == this) return; | |
78 | this->fDigits = source.fDigits; | |
79 | this->fNdigits = source.fNdigits; | |
80 | this->fResponse = source.fResponse; | |
81 | this->fSegmentation = source.fSegmentation; | |
82 | this->fNRawClusters = source.fNRawClusters; | |
83 | this->fMap = source.fMap; | |
84 | this->fNperMax = source.fNperMax; | |
85 | this->fDeclusterFlag = source.fDeclusterFlag; | |
86 | this->fClusterSize = source.fClusterSize; | |
87 | this->fNPeaks = source.fNPeaks; | |
88 | return; | |
b0f5e3fc | 89 | } |
9de0700b | 90 | //______________________________________________________________________ |
91 | AliITSClusterFinder& AliITSClusterFinder::operator=(const AliITSClusterFinder &source) { | |
92 | // Assignment operator | |
93 | ||
94 | if(&source == this) return *this; | |
95 | this->fDigits = source.fDigits; | |
96 | this->fNdigits = source.fNdigits; | |
97 | this->fResponse = source.fResponse; | |
98 | this->fSegmentation = source.fSegmentation; | |
99 | this->fNRawClusters = source.fNRawClusters; | |
100 | this->fMap = source.fMap; | |
101 | this->fNperMax = source.fNperMax; | |
102 | this->fDeclusterFlag = source.fDeclusterFlag; | |
103 | this->fClusterSize = source.fClusterSize; | |
104 | this->fNPeaks = source.fNPeaks; | |
105 | return *this; | |
b0f5e3fc | 106 | } |
9de0700b | 107 | //---------------------------------------------------------------------- |
108 | void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c){ | |
109 | // Add a raw cluster copy to the list | |
b0f5e3fc | 110 | |
b0f5e3fc | 111 | AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); |
112 | iTS->AddCluster(branch,c); | |
113 | fNRawClusters++; | |
9355b256 | 114 | } |
9de0700b | 115 | //---------------------------------------------------------------------- |
116 | void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c, | |
117 | AliITSRecPoint &rp){ | |
118 | // Add a raw cluster copy to the list | |
9355b256 | 119 | |
9355b256 | 120 | AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); |
121 | iTS->AddCluster(branch,c); | |
122 | fNRawClusters++; | |
123 | iTS->AddRecPoint(rp); | |
b0f5e3fc | 124 | } |
f8d9a5b8 | 125 | //______________________________________________________________________ |
126 | void AliITSClusterFinder::FindRawClusters(Int_t module){ | |
127 | // Default Cluster finder. | |
128 | // Input: | |
129 | // Int_t module Module number for which culster are to be found. | |
130 | // Output: | |
131 | // none. | |
132 | // Return: | |
133 | // none. | |
134 | const Int_t kelms = 10; | |
135 | Int_t ndigits = fDigits->GetEntriesFast(); | |
136 | TObjArray *digs = new TObjArray(ndigits); | |
137 | TObjArray *clusts = new TObjArray(ndigits); // max # cluster | |
138 | TObjArray *clust0=0; // A spacific cluster of digits | |
139 | TObjArray *clust1=0; // A spacific cluster of digits | |
140 | AliITSdigit *dig=0; // locat pointer to a digit | |
141 | Int_t i=0,nc=0,j[4],k,k2; | |
142 | ||
143 | // Copy all digits for this module into a local TObjArray. | |
144 | for(i=0;i<ndigits;i++) digs->AddAt(new AliITSdigit(*((AliITSdigit*)(fDigits->At(i)))),i); | |
145 | digs->Sort(); | |
146 | // First digit is a cluster. | |
147 | i = 0; | |
148 | nc = 0; | |
149 | clusts->AddAt(new TObjArray(kelms),nc); | |
150 | clust0 = (TObjArray*)(clusts->At(nc)); | |
151 | clust0->AddAtFree(digs->At(i)); // move owner ship from digs to clusts | |
152 | nc++; | |
153 | for(i=1;i<ndigits;i++){ | |
154 | if(IsNeighbor(digs,i,j)){ | |
155 | dig = (AliITSdigit*)(digs->At(j[0])); | |
156 | // Add to existing cluster. Find which cluster this digis | |
157 | for(k=0;k<nc;k++){ | |
158 | clust0 = ((TObjArray*)(clusts->At(k))); | |
159 | if(clust0->IndexOf(dig)>=0) break; | |
160 | } // end for k | |
161 | if(k>=nc){ | |
08d213d6 | 162 | Fatal("FindRawClusters","Digit not found as expected"); |
f8d9a5b8 | 163 | } // end if |
164 | if(j[1]>=0){ | |
165 | dig = (AliITSdigit*)(digs->At(j[1])); | |
166 | // Add to existing cluster. Find which cluster this digis | |
167 | for(k2=0;k2<nc;k2++){ | |
168 | clust1 = ((TObjArray*)(clusts->At(k2))); | |
169 | if(clust1->IndexOf(dig)>=0) break; | |
170 | } // end for k2 | |
171 | if(k2>=nc){ | |
08d213d6 | 172 | Fatal("FindRawClusters","Digit not found as expected"); |
f8d9a5b8 | 173 | } // end if |
174 | } // end if j[1]>=0 | |
175 | // Found cluster with neighboring digits add this one to it. | |
176 | if(clust0==clust1){ // same cluster | |
177 | clust0->AddAtFree(digs->At(i)); | |
178 | clust0 = 0; // finished with cluster. zero for safty | |
179 | clust1 = 0; // finished wit hcluster. zero for safty | |
180 | }else{ // two different clusters which need to be merged. | |
181 | clust0->AddAtFree(digs->At(i)); // Add digit to this cluster. | |
182 | for(k=0;k<clust1->GetEntriesFast();k++){ | |
183 | // move clust1 into clust0 | |
184 | clust0->AddAtFree(clust1->At(k));//move digit to this cluster | |
185 | clust1->AddAt(0,k); // zero this one | |
186 | } // end for k | |
187 | delete clust1; | |
188 | clusts->AddAt(0,k2); // zero array of clusters element clust1 | |
189 | clust0 = 0; // finished with cluster. zero for safty | |
190 | clust1 = 0; // finished wit hcluster. zero for safty | |
191 | } // end if clust0==clust1 | |
192 | }else{// New cluster | |
193 | clusts->AddAt(new TObjArray(kelms),nc); | |
194 | clust0 = ((TObjArray*)(clusts->At(nc))); | |
195 | clust0->AddAtFree(digs->At(i));// move owner ship from digs to clusts | |
196 | clust0 = 0; // finished with cluster. zero for safty | |
197 | nc++; | |
198 | } // End if IsNeighbor | |
199 | } // end for i | |
200 | // There are now nc clusters in clusts. Each element of clust is an | |
201 | // array of digits which are clustered together. | |
202 | ||
203 | // For each cluster call detector specific CreateRecPoints | |
204 | for(i=0;i<nc;i++) CreateRecPoints((TObjArray*)(clusts->At(i)),module); | |
205 | ||
206 | // clean up at the end. | |
207 | for(i=0;i<nc;i++){ | |
208 | clust0 =(TObjArray*)(clusts->At(i)); | |
209 | // Digits deleted below, so zero this TObjArray | |
210 | for(k=0;k<clust0->GetEntriesFast();k++) clust0->AddAt(0,k); | |
211 | delete clust0; // Delete this TObjArray | |
212 | clusts->AddAt(0,i); // Contents deleted above, so zero it. | |
213 | } // end for i | |
214 | delete clusts; // Delete this TObjArray/ | |
215 | // Delete the digits then the TObjArray which containted them. | |
216 | for(i=0;i<ndigits;i++) delete ((AliITSdigit*)(digs->At(i))); | |
217 | delete digs; | |
218 | } | |
219 | //______________________________________________________________________ | |
220 | Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[]){ | |
221 | // Locagical function which checks to see if digit i has a neighbor. | |
222 | // If so, then it returns kTRUE and its neighbor index j. | |
223 | // This routine checks if the digits are side by side or one before the | |
224 | // other. Requires that the array of digits be in proper order. | |
225 | // Returns kTRUE in the following cases. | |
226 | // ji 0j if kdiagonal j0 0i | |
227 | // 00 0i if kdiagonal 0i j0 | |
228 | // Inputs: | |
229 | // TObjArray *digs Array to search for neighbors in | |
230 | // Int_t i Index of digit for which we are searching for | |
231 | // a neighbor of. | |
232 | // Output: | |
233 | // Int_t j[4] Index of one or more of the digits which is a | |
234 | // neighbor of digit a index i. | |
235 | // Return: | |
236 | // Bool_t kTRUE if a neighbor was found kFALSE otherwise. | |
237 | Int_t ix,jx,iz,jz,j; | |
238 | const Bool_t kdiagonal=kFALSE; | |
239 | Bool_t nei[4]; | |
240 | ||
241 | // No neighbors found if array empty. | |
242 | if(digs->GetEntriesFast()<=0) return kFALSE; | |
243 | // can not be a digit with first element or elements out or range | |
244 | if(i<=0 || i>=digs->GetEntriesFast()) return kFALSE; | |
245 | ||
246 | for(j=0;j<4;j++){n[j] = -1;nei[j]=kFALSE;} | |
247 | ix = ((AliITSdigit*)(digs->At(i)))->GetCoord1(); | |
248 | iz = ((AliITSdigit*)(digs->At(i)))->GetCoord2(); | |
249 | for(j=0;j<i;j++){ | |
250 | jx = ((AliITSdigit*)(digs->At(j)))->GetCoord1(); | |
251 | jz = ((AliITSdigit*)(digs->At(j)))->GetCoord2(); | |
252 | if(jx+1==ix && jz ==iz){n[0] = j;nei[0] = kTRUE;} | |
253 | if(jx ==ix && jz+1==iz){n[1] = j;nei[1] = kTRUE;} | |
254 | if(jx+1==ix && jz+1==iz){n[2] = j;nei[2] = kTRUE;} | |
255 | if(jx+1==ix && jz-1==iz){n[3] = j;nei[3] = kTRUE;} | |
256 | } // end for k | |
257 | if(nei[0]||nei[1]) return kTRUE; | |
258 | if(kdiagonal&&(nei[2]||nei[3])) return kTRUE; | |
259 | // no Neighbors found. | |
260 | return kFALSE; | |
261 | } |