]>
Commit | Line | Data |
---|---|---|
04366a57 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, 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 | //////////////////////////////////////////////////////////////////////////// | |
16 | // Implementation of the ITS clusterer V2 class // | |
17 | // // | |
18 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch // | |
19 | // // | |
20 | /////////////////////////////////////////////////////////////////////////// | |
21 | ||
22 | ||
23 | #include "AliRun.h" | |
24 | #include "AliITSClusterFinderV2.h" | |
00a7cc50 | 25 | #include "AliITSRecPoint.h" |
8ba39da9 | 26 | #include "AliITSDetTypeRec.h" |
27 | //#include "AliITSgeom.h" | |
04366a57 | 28 | #include <TParticle.h> |
29 | #include "AliMC.h" | |
30 | ||
31 | ClassImp(AliITSClusterFinderV2) | |
32 | ||
33 | extern AliRun *gAlice; | |
34 | ||
8ba39da9 | 35 | AliITSClusterFinderV2::AliITSClusterFinderV2(AliITSDetTypeRec* dettyp):AliITSClusterFinder(dettyp){ |
04366a57 | 36 | |
37 | //Default constructor | |
38 | fEvent = 0; | |
39 | fModule = 0; | |
8ba39da9 | 40 | fNModules = dettyp->GetITSgeom()->GetIndexMax(); |
04366a57 | 41 | } |
42 | ||
43 | //______________________________________________________________________ | |
44 | AliITSClusterFinderV2::AliITSClusterFinderV2(const AliITSClusterFinderV2 &source) : AliITSClusterFinder(source) { | |
45 | // Copy constructor | |
46 | // Copies are not allowed. The method is protected to avoid misuse. | |
47 | Fatal("AliITSClusterFinderV2","Copy constructor not allowed\n"); | |
48 | } | |
49 | ||
50 | //______________________________________________________________________ | |
51 | AliITSClusterFinderV2& AliITSClusterFinderV2::operator=(const AliITSClusterFinderV2& /* source */){ | |
52 | // Assignment operator | |
53 | // Assignment is not allowed. The method is protected to avoid misuse. | |
54 | Fatal("= operator","Assignment operator not allowed\n"); | |
55 | return *this; | |
56 | } | |
57 | ||
58 | ||
59 | //______________________________________________________________________ | |
60 | void AliITSClusterFinderV2::CheckLabels2(Int_t lab[10]) { | |
61 | //------------------------------------------------------------ | |
62 | // Tries to find mother's labels | |
63 | //------------------------------------------------------------ | |
64 | Int_t nlabels =0; | |
65 | for (Int_t i=0;i<10;i++) if (lab[i]>=0) nlabels++; | |
66 | if(nlabels == 0) return; // In case of no labels just exit | |
67 | ||
68 | ||
69 | Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); | |
70 | ||
71 | for (Int_t i=0;i<10;i++){ | |
72 | Int_t label = lab[i]; | |
73 | if (label>=0 && label<ntracks) { | |
74 | TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label); | |
75 | ||
76 | if (part->P() < 0.02) { | |
77 | Int_t m=part->GetFirstMother(); | |
78 | if (m<0) { | |
79 | continue; | |
80 | } | |
81 | if (part->GetStatusCode()>0) { | |
82 | continue; | |
83 | } | |
84 | lab[i]=m; | |
85 | } | |
86 | else | |
87 | if (part->P() < 0.12 && nlabels>3) { | |
88 | lab[i]=-2; | |
89 | nlabels--; | |
90 | } | |
91 | } | |
92 | else{ | |
93 | if ( (label>ntracks||label <0) && nlabels>3) { | |
94 | lab[i]=-2; | |
95 | nlabels--; | |
96 | } | |
97 | } | |
98 | } | |
99 | if (nlabels>3){ | |
100 | for (Int_t i=0;i<10;i++){ | |
101 | if (nlabels>3){ | |
102 | Int_t label = lab[i]; | |
103 | if (label>=0 && label<ntracks) { | |
104 | TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label); | |
105 | if (part->P() < 0.1) { | |
106 | lab[i]=-2; | |
107 | nlabels--; | |
108 | } | |
109 | } | |
110 | } | |
111 | } | |
112 | } | |
113 | ||
114 | //compress labels -- if multi-times the same | |
115 | Int_t lab2[10]; | |
116 | for (Int_t i=0;i<10;i++) lab2[i]=-2; | |
117 | for (Int_t i=0;i<10 ;i++){ | |
118 | if (lab[i]<0) continue; | |
119 | for (Int_t j=0;j<10 &&lab2[j]!=lab[i];j++){ | |
120 | if (lab2[j]<0) { | |
121 | lab2[j]= lab[i]; | |
122 | break; | |
123 | } | |
124 | } | |
125 | } | |
126 | for (Int_t j=0;j<10;j++) lab[j]=lab2[j]; | |
127 | ||
128 | } | |
129 | ||
130 | //______________________________________________________________________ | |
131 | void AliITSClusterFinderV2::AddLabel(Int_t lab[10], Int_t label) { | |
132 | ||
133 | //add label to the cluster | |
134 | ||
135 | if(label<0) return; // In case of no label just exit | |
136 | ||
137 | Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); | |
138 | if (label>ntracks) return; | |
139 | for (Int_t i=0;i<10;i++){ | |
140 | // if (label<0) break; | |
141 | if (lab[i]==label) break; | |
142 | if (lab[i]<0) { | |
143 | lab[i]= label; | |
144 | break; | |
145 | } | |
146 | } | |
147 | } | |
148 | ||
149 | ||
150 | //______________________________________________________________________ | |
151 | void AliITSClusterFinderV2:: | |
152 | FindCluster(Int_t k,Int_t maxz,AliBin *bins,Int_t &n,Int_t *idx) { | |
153 | //------------------------------------------------------------ | |
154 | // returns an array of indices of digits belonging to the cluster | |
155 | // (needed when the segmentation is not regular) | |
156 | //------------------------------------------------------------ | |
157 | if (n<200) idx[n++]=bins[k].GetIndex(); | |
158 | bins[k].Use(); | |
159 | ||
160 | if (bins[k-maxz].IsNotUsed()) FindCluster(k-maxz,maxz,bins,n,idx); | |
161 | if (bins[k-1 ].IsNotUsed()) FindCluster(k-1 ,maxz,bins,n,idx); | |
162 | if (bins[k+maxz].IsNotUsed()) FindCluster(k+maxz,maxz,bins,n,idx); | |
163 | if (bins[k+1 ].IsNotUsed()) FindCluster(k+1 ,maxz,bins,n,idx); | |
164 | /* | |
165 | if (bins[k-maxz-1].IsNotUsed()) FindCluster(k-maxz-1,maxz,bins,n,idx); | |
166 | if (bins[k-maxz+1].IsNotUsed()) FindCluster(k-maxz+1,maxz,bins,n,idx); | |
167 | if (bins[k+maxz-1].IsNotUsed()) FindCluster(k+maxz-1,maxz,bins,n,idx); | |
168 | if (bins[k+maxz+1].IsNotUsed()) FindCluster(k+maxz+1,maxz,bins,n,idx); | |
169 | */ | |
170 | } | |
171 | ||
172 | //______________________________________________________________________ | |
173 | Bool_t AliITSClusterFinderV2::IsMaximum(Int_t k,Int_t max,const AliBin *bins) { | |
174 | //------------------------------------------------------------ | |
175 | //is this a local maximum ? | |
176 | //------------------------------------------------------------ | |
177 | UShort_t q=bins[k].GetQ(); | |
178 | if (q==1023) return kFALSE; | |
179 | if (bins[k-max].GetQ() > q) return kFALSE; | |
180 | if (bins[k-1 ].GetQ() > q) return kFALSE; | |
181 | if (bins[k+max].GetQ() > q) return kFALSE; | |
182 | if (bins[k+1 ].GetQ() > q) return kFALSE; | |
183 | if (bins[k-max-1].GetQ() > q) return kFALSE; | |
184 | if (bins[k+max-1].GetQ() > q) return kFALSE; | |
185 | if (bins[k+max+1].GetQ() > q) return kFALSE; | |
186 | if (bins[k-max+1].GetQ() > q) return kFALSE; | |
187 | return kTRUE; | |
188 | } | |
189 | ||
190 | //______________________________________________________________________ | |
191 | void AliITSClusterFinderV2:: | |
192 | FindPeaks(Int_t k,Int_t max,AliBin *b,Int_t *idx,UInt_t *msk,Int_t& n) { | |
193 | //------------------------------------------------------------ | |
194 | //find local maxima | |
195 | //------------------------------------------------------------ | |
196 | if (n<31) | |
197 | if (IsMaximum(k,max,b)) { | |
198 | idx[n]=k; msk[n]=(2<<n); | |
199 | n++; | |
200 | } | |
201 | b[k].SetMask(0); | |
202 | if (b[k-max].GetMask()&1) FindPeaks(k-max,max,b,idx,msk,n); | |
203 | if (b[k-1 ].GetMask()&1) FindPeaks(k-1 ,max,b,idx,msk,n); | |
204 | if (b[k+max].GetMask()&1) FindPeaks(k+max,max,b,idx,msk,n); | |
205 | if (b[k+1 ].GetMask()&1) FindPeaks(k+1 ,max,b,idx,msk,n); | |
206 | } | |
207 | ||
208 | //______________________________________________________________________ | |
209 | void AliITSClusterFinderV2:: | |
210 | MarkPeak(Int_t k, Int_t max, AliBin *bins, UInt_t m) { | |
211 | //------------------------------------------------------------ | |
212 | //mark this peak | |
213 | //------------------------------------------------------------ | |
214 | UShort_t q=bins[k].GetQ(); | |
215 | ||
216 | bins[k].SetMask(bins[k].GetMask()|m); | |
217 | ||
218 | if (bins[k-max].GetQ() <= q) | |
219 | if ((bins[k-max].GetMask()&m) == 0) MarkPeak(k-max,max,bins,m); | |
220 | if (bins[k-1 ].GetQ() <= q) | |
221 | if ((bins[k-1 ].GetMask()&m) == 0) MarkPeak(k-1 ,max,bins,m); | |
222 | if (bins[k+max].GetQ() <= q) | |
223 | if ((bins[k+max].GetMask()&m) == 0) MarkPeak(k+max,max,bins,m); | |
224 | if (bins[k+1 ].GetQ() <= q) | |
225 | if ((bins[k+1 ].GetMask()&m) == 0) MarkPeak(k+1 ,max,bins,m); | |
226 | } | |
227 | ||
228 | //______________________________________________________________________ | |
229 | void AliITSClusterFinderV2:: | |
00a7cc50 | 230 | MakeCluster(Int_t k,Int_t max,AliBin *bins,UInt_t m,AliITSRecPoint &c) { |
04366a57 | 231 | //------------------------------------------------------------ |
232 | //make cluster using digits of this peak | |
233 | //------------------------------------------------------------ | |
234 | Float_t q=(Float_t)bins[k].GetQ(); | |
235 | Int_t i=k/max, j=k-i*max; | |
236 | ||
237 | c.SetQ(c.GetQ()+q); | |
00a7cc50 | 238 | c.SetYZ(GetModule(),c.GetY()+i*q,c.GetZ()+j*q); |
04366a57 | 239 | c.SetSigmaY2(c.GetSigmaY2()+i*i*q); |
240 | c.SetSigmaZ2(c.GetSigmaZ2()+j*j*q); | |
241 | ||
242 | bins[k].SetMask(0xFFFFFFFE); | |
243 | ||
244 | if (bins[k-max].GetMask() == m) MakeCluster(k-max,max,bins,m,c); | |
245 | if (bins[k-1 ].GetMask() == m) MakeCluster(k-1 ,max,bins,m,c); | |
246 | if (bins[k+max].GetMask() == m) MakeCluster(k+max,max,bins,m,c); | |
247 | if (bins[k+1 ].GetMask() == m) MakeCluster(k+1 ,max,bins,m,c); | |
248 | } |