]>
Commit | Line | Data |
---|---|---|
01f43166 | 1 | // @(#) $Id$ |
2 | ||
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
7 | * Authors: Kenneth Aamodt <Kenneth.Aamodt@student.uib.no> * | |
8 | * for The ALICE HLT Project. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /** @file AliHLTTPCPadArray.cxx | |
20 | @author Kenneth Aamodt | |
21 | @date | |
22 | @brief Class containing TPC Pad objects. | |
23 | */ | |
24 | ||
a1dbf058 | 25 | // see header file for class documentation |
26 | // or | |
27 | // refer to README to build package | |
28 | // or | |
29 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
30 | ||
01f43166 | 31 | #if __GNUC__>= 3 |
32 | using namespace std; | |
33 | #endif | |
34 | ||
35 | #include <cerrno> | |
36 | #include "AliHLTTPCPadArray.h" | |
37 | #include "AliHLTTPCPad.h" | |
38 | #include "AliHLTStdIncludes.h" | |
39 | #include "AliHLTTPCTransform.h" | |
40 | #include "AliHLTTPCDigitReader.h" | |
41 | #include "AliHLTTPCClusters.h" | |
42 | #include <vector> | |
43 | #include <sys/time.h> | |
44 | ||
45 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
46 | ClassImp(AliHLTTPCPadArray) | |
47 | ||
48 | AliHLTTPCPadArray::AliHLTTPCPadArray() | |
49 | : | |
a1dbf058 | 50 | fRowPadVector(), |
51 | fClusters(), | |
01f43166 | 52 | fPatch(-1), |
53 | fFirstRow(-1), | |
54 | fLastRow(-1), | |
3ab89155 | 55 | fThreshold(10), |
3ab89155 | 56 | fNumberOfPadsInRow(NULL), |
a1dbf058 | 57 | fNumberOfRows(0), |
58 | fDigitReader(NULL) | |
01f43166 | 59 | { |
60 | // see header file for class documentation | |
61 | // or | |
62 | // refer to README to build package | |
63 | // or | |
64 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
65 | } | |
66 | ||
67 | AliHLTTPCPadArray::AliHLTTPCPadArray(Int_t patch) | |
68 | : | |
a1dbf058 | 69 | fRowPadVector(), |
70 | fClusters(), | |
01f43166 | 71 | fPatch(patch), |
72 | fFirstRow(-1), | |
73 | fLastRow(-1), | |
3ab89155 | 74 | fThreshold(10), |
3ab89155 | 75 | fNumberOfPadsInRow(NULL), |
a1dbf058 | 76 | fNumberOfRows(0), |
77 | fDigitReader(NULL) | |
01f43166 | 78 | { |
79 | // see header file for class documentation | |
01f43166 | 80 | } |
81 | ||
82 | AliHLTTPCPadArray::~AliHLTTPCPadArray() | |
83 | { | |
84 | // see header file for class documentation | |
85 | } | |
86 | ||
a1dbf058 | 87 | Int_t AliHLTTPCPadArray::InitializeVector() |
88 | { | |
01f43166 | 89 | // see header file for class documentation |
90 | ||
91 | if(fPatch>5||fPatch<0){ | |
92 | HLTFatal("Patch is not set"); | |
93 | return 0; | |
94 | } | |
95 | ||
96 | fFirstRow = AliHLTTPCTransform::GetFirstRow(fPatch); | |
97 | fLastRow = AliHLTTPCTransform::GetLastRow(fPatch); | |
98 | ||
99 | fNumberOfRows=fLastRow-fFirstRow+1; | |
100 | fNumberOfPadsInRow= new Int_t[fNumberOfRows]; | |
101 | ||
102 | memset( fNumberOfPadsInRow, 0, sizeof(Int_t)*(fNumberOfRows)); | |
103 | ||
104 | for(Int_t i=0;i<fNumberOfRows;i++){ | |
105 | fNumberOfPadsInRow[i]=AliHLTTPCTransform::GetNPads(i+fFirstRow); | |
a1dbf058 | 106 | AliHLTTPCPadVector tmpRow; |
01f43166 | 107 | for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){ |
108 | AliHLTTPCPad *tmpPad = new AliHLTTPCPad(); | |
109 | tmpPad->SetID(i,j); | |
110 | tmpRow.push_back(tmpPad); | |
111 | } | |
112 | fRowPadVector.push_back(tmpRow); | |
113 | } | |
a1dbf058 | 114 | return 0; |
01f43166 | 115 | } |
116 | ||
a1dbf058 | 117 | Int_t AliHLTTPCPadArray::DeInitializeVector() |
118 | { | |
119 | // see header file for class documentation | |
01f43166 | 120 | for(Int_t i=0;i<fNumberOfRows;i++){ |
121 | for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){ | |
122 | delete fRowPadVector[i][j]; | |
123 | } | |
124 | fRowPadVector[i].clear(); | |
125 | } | |
126 | fRowPadVector.clear(); | |
127 | return 1; | |
128 | } | |
a1dbf058 | 129 | |
130 | void AliHLTTPCPadArray::SetPatch(Int_t patch) | |
131 | { | |
132 | // see header file for class documentation | |
01f43166 | 133 | fPatch=patch; |
134 | } | |
135 | ||
a1dbf058 | 136 | void AliHLTTPCPadArray::SetDigitReader(AliHLTTPCDigitReader* digitReader) |
137 | { | |
138 | // see header file for class documentation | |
01f43166 | 139 | fDigitReader=digitReader; |
140 | } | |
a1dbf058 | 141 | |
142 | Int_t AliHLTTPCPadArray::ReadData() | |
143 | { | |
144 | // see header file for class documentation | |
01f43166 | 145 | |
146 | switch (fPatch){ | |
147 | case 0: | |
148 | while(fDigitReader->Next()){ | |
149 | fRowPadVector[fDigitReader->GetRow()-fFirstRow][fDigitReader->GetPad()]->SetDataSignal(fDigitReader->GetTime(),fDigitReader->GetSignal()); | |
150 | } | |
d8b2f74a | 151 | break; |
01f43166 | 152 | case 1: |
153 | while(fDigitReader->Next()){ | |
154 | fRowPadVector[fDigitReader->GetRow()-fFirstRow][fDigitReader->GetPad()]->SetDataSignal(fDigitReader->GetTime(),fDigitReader->GetSignal()); | |
155 | } | |
d8b2f74a | 156 | break; |
01f43166 | 157 | case 2: |
158 | while(fDigitReader->Next()){ | |
159 | fRowPadVector[fDigitReader->GetRow()][fDigitReader->GetPad()]->SetDataSignal(fDigitReader->GetTime(),fDigitReader->GetSignal()); | |
160 | } | |
d8b2f74a | 161 | break; |
01f43166 | 162 | case 3: |
163 | while(fDigitReader->Next()){ | |
164 | fRowPadVector[fDigitReader->GetRow()-27][fDigitReader->GetPad()]->SetDataSignal(fDigitReader->GetTime(),fDigitReader->GetSignal()); | |
165 | } | |
d8b2f74a | 166 | break; |
01f43166 | 167 | case 4: |
168 | while(fDigitReader->Next()){ | |
169 | fRowPadVector[fDigitReader->GetRow()-54][fDigitReader->GetPad()]->SetDataSignal(fDigitReader->GetTime(),fDigitReader->GetSignal()); | |
170 | } | |
d8b2f74a | 171 | break; |
01f43166 | 172 | case 5: |
173 | while(fDigitReader->Next()){ | |
174 | fRowPadVector[fDigitReader->GetRow()-76][fDigitReader->GetPad()]->SetDataSignal(fDigitReader->GetTime(),fDigitReader->GetSignal()); | |
175 | } | |
d8b2f74a | 176 | break; |
01f43166 | 177 | } |
e83e889b | 178 | return 0; |
01f43166 | 179 | } |
a1dbf058 | 180 | |
181 | void AliHLTTPCPadArray::FindClusters(Int_t match) | |
182 | { | |
01f43166 | 183 | //see header file for documentation |
184 | Int_t nClusters=0; | |
185 | Int_t totalChargeOfPreviousCandidate=0; | |
186 | Int_t clusterChargeIsFalling=0; | |
187 | for(Int_t row=0;row<fNumberOfRows;row++){ | |
188 | for(Int_t pad=0;pad<fNumberOfPadsInRow[row]-1;pad++){ | |
189 | AliHLTTPCPad *tmp1=fRowPadVector[row][pad]; | |
190 | AliHLTTPCPad *tmp2=fRowPadVector[row][pad+1]; | |
191 | for(Int_t c1=0;c1<tmp1->fClusterCandidates.size();c1++){ | |
192 | ||
193 | if(tmp1->fUsedClusterCandidates[c1]){ | |
194 | continue; | |
195 | } | |
196 | ||
197 | for(Int_t c2=0;c2<tmp2->fClusterCandidates.size();c2++){ | |
198 | ||
199 | if(tmp2->fUsedClusterCandidates[c2]){ | |
200 | continue; | |
201 | } | |
202 | ||
203 | Int_t diff= tmp1->fClusterCandidates[c1].fMean - tmp2->fClusterCandidates[c2].fMean; | |
204 | ||
205 | if(diff < -match){ | |
206 | break; | |
207 | } | |
208 | if(diff <= match){ | |
209 | ||
210 | if((Int_t)(tmp1->fClusterCandidates[c1].fTotalCharge - tmp2->fClusterCandidates[c2].fTotalCharge)>0){ | |
211 | clusterChargeIsFalling=1; | |
212 | } | |
213 | ||
214 | tmp1->fUsedClusterCandidates[c1]=1; | |
215 | tmp2->fUsedClusterCandidates[c2]=1; | |
216 | ||
217 | AliHLTTPCClusters tmpCluster; | |
218 | tmpCluster.fTotalCharge = tmp1->fClusterCandidates[c1].fTotalCharge; | |
219 | tmpCluster.fPad = tmp1->fClusterCandidates[c1].fPad; | |
220 | tmpCluster.fPad2 = tmp1->fClusterCandidates[c1].fPad2; | |
221 | tmpCluster.fTime = tmp1->fClusterCandidates[c1].fTime; | |
222 | tmpCluster.fTime2 = tmp1->fClusterCandidates[c1].fTime2; | |
223 | tmpCluster.fRowNumber = row; | |
224 | ||
225 | tmpCluster.fTotalCharge += tmp2->fClusterCandidates[c2].fTotalCharge; | |
226 | tmpCluster.fPad += tmp2->fClusterCandidates[c2].fPad; | |
227 | tmpCluster.fPad2 += tmp2->fClusterCandidates[c2].fPad2; | |
228 | tmpCluster.fTime += tmp2->fClusterCandidates[c2].fTime; | |
229 | tmpCluster.fTime2 += tmp2->fClusterCandidates[c2].fTime2; | |
230 | tmpCluster.fMean = tmp2->fClusterCandidates[c2].fMean; | |
231 | totalChargeOfPreviousCandidate = tmp2->fClusterCandidates[c2].fTotalCharge; | |
232 | ||
233 | int rowNumber=row; | |
234 | int lastPad=pad+1; | |
235 | nClusters++; | |
236 | Int_t doBreak=0; | |
237 | for(Int_t morePads=pad+2;morePads<fNumberOfPadsInRow[row];morePads++){ | |
238 | AliHLTTPCPad *tmpx=fRowPadVector[row][morePads]; | |
239 | if(morePads>lastPad+1){ | |
240 | break; | |
241 | } | |
242 | for(Int_t cx=0;cx<tmpx->fClusterCandidates.size();cx++){ | |
243 | if(tmpx->fUsedClusterCandidates[cx]){ | |
244 | continue; | |
245 | } | |
246 | Int_t diffx=tmpCluster.fMean - tmpx->fClusterCandidates[cx].fMean; | |
247 | if(diffx<-match){ | |
248 | doBreak=1; | |
249 | break; | |
250 | } | |
251 | if(diffx <= match){ | |
252 | if((Int_t)(totalChargeOfPreviousCandidate - tmpx->fClusterCandidates[cx].fTotalCharge)>0){ | |
253 | clusterChargeIsFalling=1; | |
254 | } | |
255 | ||
256 | if(clusterChargeIsFalling&&(Int_t)(totalChargeOfPreviousCandidate - tmpx->fClusterCandidates[cx].fTotalCharge)<=0){ | |
257 | //Means we have a deconvoluted cluster. | |
258 | totalChargeOfPreviousCandidate=0; | |
259 | doBreak=1; | |
260 | break; | |
261 | } | |
262 | ||
263 | tmpx->fUsedClusterCandidates[cx]=1; | |
264 | tmpCluster.fTotalCharge += tmpx->fClusterCandidates[cx].fTotalCharge; | |
265 | tmpCluster.fPad += tmpx->fClusterCandidates[cx].fPad; | |
266 | tmpCluster.fPad2 += tmpx->fClusterCandidates[cx].fPad2; | |
267 | tmpCluster.fTime += tmpx->fClusterCandidates[cx].fTime; | |
268 | tmpCluster.fTime2 += tmpx->fClusterCandidates[cx].fTime2; | |
269 | tmpCluster.fMean = tmpx->fClusterCandidates[cx].fMean; | |
270 | lastPad=morePads; | |
271 | ||
272 | totalChargeOfPreviousCandidate=tmpx->fClusterCandidates[cx].fTotalCharge; | |
273 | } | |
274 | } | |
275 | if(doBreak){ | |
276 | break; | |
277 | } | |
278 | } | |
279 | ||
280 | if(tmpCluster.fTotalCharge<fThreshold){ | |
281 | nClusters--; | |
282 | } | |
283 | else{ | |
284 | //Code to look for tails, TODO insert flag. | |
d8b2f74a | 285 | /* UInt_t meanTime=tmpCluster.fMean; |
01f43166 | 286 | if(pad>0){ |
287 | AliHLTTPCPad *tmpBefore=fRowPadVector[row][pad-1]; | |
288 | //checking the fMean -1 timebin for single timebin value in the pad before the cluster | |
289 | if(meanTime>0){ | |
290 | Int_t charge =tmpBefore->GetDataSignal(meanTime-1); | |
291 | if(charge){ | |
292 | tmpCluster.fTotalCharge+= charge; | |
293 | tmpCluster.fPad += charge*(pad-1); | |
294 | tmpCluster.fPad2 += charge*(pad-1)*(pad-1); | |
295 | tmpCluster.fTime += meanTime*charge; | |
296 | tmpCluster.fTime2 += meanTime*charge*charge; | |
297 | } | |
298 | } | |
299 | //checking the fMean timebin for single timebin value in the pad before the cluster | |
300 | Int_t charge2 =tmpBefore->GetDataSignal(meanTime); | |
301 | if(charge2){ | |
302 | tmpCluster.fTotalCharge+= charge2; | |
303 | tmpCluster.fPad += charge2*(pad); | |
304 | tmpCluster.fPad2 += charge2*(pad)*(pad); | |
305 | tmpCluster.fTime += meanTime*charge2; | |
306 | tmpCluster.fTime2 += meanTime*charge2*charge2; | |
307 | } | |
308 | //checking the fMean +1 timebin for single timebin value in the pad before the cluster | |
309 | if(meanTime<AliHLTTPCTransform::GetNTimeBins()){ | |
310 | Int_t charge3 =tmpBefore->GetDataSignal(meanTime+1); | |
311 | if(charge3){ | |
312 | tmpCluster.fTotalCharge+= charge3; | |
313 | tmpCluster.fPad += charge3*(pad+1); | |
314 | tmpCluster.fPad2 += charge3*(pad+1)*(pad+1); | |
315 | tmpCluster.fTime += meanTime*charge3; | |
316 | tmpCluster.fTime2 += meanTime*charge3*charge3; | |
317 | } | |
318 | } | |
319 | } | |
320 | ||
321 | if(lastPad<fNumberOfPadsInRow[row]-2){ | |
322 | AliHLTTPCPad *tmpAfter=fRowPadVector[row][lastPad+1]; | |
323 | //checking the fMean +1 timebin for single timebin value in the pad after the cluster | |
324 | if(meanTime>0){ | |
325 | Int_t charge4 =tmpAfter->GetDataSignal(meanTime-1); | |
326 | if(charge4){ | |
327 | tmpCluster.fTotalCharge+= charge4; | |
328 | tmpCluster.fPad += charge4*(pad-1); | |
329 | tmpCluster.fPad2 += charge4*(pad-1)*(pad-1); | |
330 | tmpCluster.fTime += meanTime*charge4; | |
331 | tmpCluster.fTime2 += meanTime*charge4*charge4; | |
332 | } | |
333 | } | |
334 | ||
335 | ||
336 | //checking the fMean +1 timebin for single timebin value in the pad after the cluster | |
337 | Int_t charge5 =tmpAfter->GetDataSignal(meanTime); | |
338 | if(charge5){ | |
339 | tmpCluster.fTotalCharge+= charge5; | |
340 | tmpCluster.fPad += charge5*(pad); | |
341 | tmpCluster.fPad2 += charge5*(pad)*(pad); | |
342 | tmpCluster.fTime += meanTime*charge5; | |
343 | tmpCluster.fTime2 += meanTime*charge5*charge5; | |
344 | } | |
345 | //checking the fMean +1 timebin for single timebin value in the pad after the cluster | |
346 | if(meanTime<AliHLTTPCTransform::GetNTimeBins()){ | |
347 | Int_t charge6 =tmpAfter->GetDataSignal(meanTime+1); | |
348 | if(charge6){ | |
349 | tmpCluster.fTotalCharge+= charge6; | |
350 | tmpCluster.fPad += charge6*(pad+1); | |
351 | tmpCluster.fPad2 += charge6*(pad+1)*(pad+1); | |
352 | tmpCluster.fTime += meanTime*charge6; | |
353 | tmpCluster.fTime2 += meanTime*charge6*charge6; | |
354 | } | |
355 | } | |
356 | } | |
d8b2f74a | 357 | */ |
358 | // tmpCluster.fTime= tmpCluster.fTime/tmpCluster.fTotalCharge; | |
01f43166 | 359 | totalChargeOfPreviousCandidate=0; |
360 | clusterChargeIsFalling=0; | |
01f43166 | 361 | tmpCluster.fFirstPad=pad; |
d8b2f74a | 362 | switch (fPatch){ |
363 | case 0: | |
364 | tmpCluster.fRowNumber=row; | |
365 | break; | |
366 | case 1: | |
367 | tmpCluster.fRowNumber=row+30; | |
368 | break; | |
369 | case 2: | |
370 | tmpCluster.fRowNumber=row+63; | |
371 | break; | |
372 | case 3: | |
373 | tmpCluster.fRowNumber=row+90; | |
374 | break; | |
375 | case 4: | |
376 | tmpCluster.fRowNumber=row+117; | |
377 | break; | |
378 | case 5: | |
379 | tmpCluster.fRowNumber=row+139; | |
380 | break; | |
381 | } | |
01f43166 | 382 | |
383 | fClusters.push_back(tmpCluster); | |
384 | } | |
385 | } | |
386 | } | |
387 | } | |
388 | } | |
389 | } | |
390 | ||
391 | HLTInfo("Found %d clusters.",nClusters); | |
392 | // PrintClusters(); | |
393 | } | |
a1dbf058 | 394 | |
395 | void AliHLTTPCPadArray::PrintClusters() | |
396 | { | |
397 | // see header file for class documentation | |
01f43166 | 398 | for(int i=0;i<fClusters.size();i++){ |
399 | cout<<"Cluster number: "<<i<<endl; | |
400 | cout<<"Row: "<<fClusters[i].fRowNumber<<" Pad: "<<fClusters[i].fFirstPad<<endl; | |
401 | cout<<"Total Charge: "<<fClusters[i].fTotalCharge<<endl; | |
402 | cout<<"PadError: "<<fClusters[i].fPad2<<endl; | |
403 | cout<<"TimeMean: "<<fClusters[i].fTime<<endl; | |
404 | cout<<"TimeError: "<<fClusters[i].fTime2<<endl; | |
405 | cout<<endl; | |
406 | cout<<endl; | |
407 | } | |
408 | } | |
a1dbf058 | 409 | |
410 | void AliHLTTPCPadArray::DataToDefault() | |
411 | { | |
412 | for(Int_t i=0;i<fNumberOfRows;i++){ | |
413 | for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){ | |
414 | fRowPadVector[i][j]->SetDataToDefault(); | |
415 | } | |
416 | } | |
417 | } | |
418 | ||
419 | void AliHLTTPCPadArray::FindClusterCandidates() | |
420 | { | |
421 | for(Int_t row=0;row<fNumberOfRows;row++){ | |
422 | for(Int_t pad=0;pad<fNumberOfPadsInRow[row];pad++){ | |
423 | fRowPadVector[row][pad]->FindClusterCandidates(); | |
424 | } | |
425 | } | |
426 | } |