]>
Commit | Line | Data |
---|---|---|
1c53abe2 | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
1c53abe2 | 17 | |
18 | //------------------------------------------------------- | |
19 | // Implementation of the TPC clusterer | |
20 | // | |
21 | // Origin: Marian Ivanov | |
22 | //------------------------------------------------------- | |
23 | ||
d7a11555 | 24 | #include "AliTPCReconstructor.h" |
1c53abe2 | 25 | #include "AliTPCclustererMI.h" |
26 | #include "AliTPCclusterMI.h" | |
27 | #include <TObjArray.h> | |
28 | #include <TFile.h> | |
65c045f0 | 29 | #include "TGraph.h" |
30 | #include "TF1.h" | |
31 | #include "TRandom.h" | |
32 | #include "AliMathBase.h" | |
33 | ||
1c53abe2 | 34 | #include "AliTPCClustersArray.h" |
35 | #include "AliTPCClustersRow.h" | |
36 | #include "AliDigits.h" | |
37 | #include "AliSimDigits.h" | |
38 | #include "AliTPCParam.h" | |
194b0609 | 39 | #include "AliTPCRecoParam.h" |
f8aae377 | 40 | #include "AliRawReader.h" |
41 | #include "AliTPCRawStream.h" | |
42 | #include "AliRunLoader.h" | |
43 | #include "AliLoader.h" | |
cc5e9db0 | 44 | #include "Riostream.h" |
1c53abe2 | 45 | #include <TTree.h> |
13116aec | 46 | #include "AliTPCcalibDB.h" |
47 | #include "AliTPCCalPad.h" | |
48 | #include "AliTPCCalROC.h" | |
65c045f0 | 49 | #include "TTreeStream.h" |
50 | #include "AliLog.h" | |
13116aec | 51 | |
52 | ||
1c53abe2 | 53 | ClassImp(AliTPCclustererMI) |
54 | ||
55 | ||
56 | ||
2f32844a | 57 | AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoParam * recoParam): |
58 | fBins(0), | |
59 | fResBins(0), | |
60 | fLoop(0), | |
61 | fMaxBin(0), | |
62 | fMaxTime(0), | |
63 | fMaxPad(0), | |
64 | fSector(-1), | |
65 | fRow(-1), | |
66 | fSign(0), | |
67 | fRx(0), | |
68 | fPadWidth(0), | |
69 | fPadLength(0), | |
70 | fZWidth(0), | |
71 | fPedSubtraction(kFALSE), | |
72 | fIsOldRCUFormat(kFALSE), | |
73 | fInput(0), | |
74 | fOutput(0), | |
75 | fRowCl(0), | |
76 | fRowDig(0), | |
77 | fParam(0), | |
78 | fNcluster(0), | |
79 | fAmplitudeHisto(0), | |
80 | fDebugStreamer(0), | |
81 | fRecoParam(0) | |
1c53abe2 | 82 | { |
97f127bb | 83 | // |
84 | // COSNTRUCTOR | |
85 | // param - tpc parameters for given file | |
86 | // recoparam - reconstruction parameters | |
87 | // | |
22c352f8 | 88 | fIsOldRCUFormat = kFALSE; |
1c53abe2 | 89 | fInput =0; |
90 | fOutput=0; | |
f8aae377 | 91 | fParam = par; |
194b0609 | 92 | if (recoParam) { |
93 | fRecoParam = recoParam; | |
94 | }else{ | |
95 | //set default parameters if not specified | |
96 | fRecoParam = AliTPCReconstructor::GetRecoParam(); | |
97 | if (!fRecoParam) fRecoParam = AliTPCRecoParam::GetLowFluxParam(); | |
98 | } | |
65c045f0 | 99 | fDebugStreamer = new TTreeSRedirector("TPCsignal.root"); |
100 | fAmplitudeHisto = 0; | |
101 | } | |
102 | ||
103 | AliTPCclustererMI::~AliTPCclustererMI(){ | |
104 | DumpHistos(); | |
105 | if (fAmplitudeHisto) delete fAmplitudeHisto; | |
106 | if (fDebugStreamer) delete fDebugStreamer; | |
1c53abe2 | 107 | } |
22c352f8 | 108 | |
1c53abe2 | 109 | void AliTPCclustererMI::SetInput(TTree * tree) |
110 | { | |
111 | // | |
112 | // set input tree with digits | |
113 | // | |
114 | fInput = tree; | |
115 | if (!fInput->GetBranch("Segment")){ | |
116 | cerr<<"AliTPC::Digits2Clusters(): no porper input tree !\n"; | |
117 | fInput=0; | |
118 | return; | |
119 | } | |
120 | } | |
121 | ||
122 | void AliTPCclustererMI::SetOutput(TTree * tree) | |
123 | { | |
124 | // | |
125 | // | |
126 | fOutput= tree; | |
127 | AliTPCClustersRow clrow; | |
128 | AliTPCClustersRow *pclrow=&clrow; | |
129 | clrow.SetClass("AliTPCclusterMI"); | |
130 | clrow.SetArray(1); // to make Clones array | |
131 | fOutput->Branch("Segment","AliTPCClustersRow",&pclrow,32000,200); | |
132 | } | |
133 | ||
134 | ||
135 | Float_t AliTPCclustererMI::GetSigmaY2(Int_t iz){ | |
136 | // sigma y2 = in digits - we don't know the angle | |
753797ce | 137 | Float_t z = iz*fParam->GetZWidth()+fParam->GetNTBinsL1()*fParam->GetZWidth(); |
1c53abe2 | 138 | Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/ |
139 | (fPadWidth*fPadWidth); | |
140 | Float_t sres = 0.25; | |
141 | Float_t res = sd2+sres; | |
142 | return res; | |
143 | } | |
144 | ||
145 | ||
146 | Float_t AliTPCclustererMI::GetSigmaZ2(Int_t iz){ | |
147 | //sigma z2 = in digits - angle estimated supposing vertex constraint | |
753797ce | 148 | Float_t z = iz*fZWidth+fParam->GetNTBinsL1()*fParam->GetZWidth(); |
1c53abe2 | 149 | Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/(fZWidth*fZWidth); |
150 | Float_t angular = fPadLength*(fParam->GetZLength()-z)/(fRx*fZWidth); | |
151 | angular*=angular; | |
152 | angular/=12.; | |
153 | Float_t sres = fParam->GetZSigma()/fZWidth; | |
154 | sres *=sres; | |
155 | Float_t res = angular +sd2+sres; | |
156 | return res; | |
157 | } | |
158 | ||
13116aec | 159 | void AliTPCclustererMI::MakeCluster(Int_t k,Int_t max,Float_t *bins, UInt_t /*m*/, |
1c53abe2 | 160 | AliTPCclusterMI &c) |
161 | { | |
97f127bb | 162 | // |
163 | // k - Make cluster at position k | |
164 | // bins - 2 D array of signals mapped to 1 dimensional array - | |
165 | // max - the number of time bins er one dimension | |
166 | // c - refernce to cluster to be filled | |
167 | // | |
1c53abe2 | 168 | Int_t i0=k/max; //central pad |
169 | Int_t j0=k%max; //central time bin | |
170 | ||
171 | // set pointers to data | |
172 | //Int_t dummy[5] ={0,0,0,0,0}; | |
13116aec | 173 | Float_t * matrix[5]; //5x5 matrix with digits - indexing i = 0 ..4 j = -2..2 |
174 | Float_t * resmatrix[5]; | |
1c53abe2 | 175 | for (Int_t di=-2;di<=2;di++){ |
176 | matrix[di+2] = &bins[k+di*max]; | |
177 | resmatrix[di+2] = &fResBins[k+di*max]; | |
178 | } | |
179 | //build matrix with virtual charge | |
180 | Float_t sigmay2= GetSigmaY2(j0); | |
181 | Float_t sigmaz2= GetSigmaZ2(j0); | |
182 | ||
183 | Float_t vmatrix[5][5]; | |
184 | vmatrix[2][2] = matrix[2][0]; | |
185 | c.SetType(0); | |
6c024a0e | 186 | c.SetMax((UShort_t)(vmatrix[2][2])); // write maximal amplitude |
1c53abe2 | 187 | for (Int_t di =-1;di <=1;di++) |
188 | for (Int_t dj =-1;dj <=1;dj++){ | |
189 | Float_t amp = matrix[di+2][dj]; | |
190 | if ( (amp<2) && (fLoop<2)){ | |
191 | // if under threshold - calculate virtual charge | |
192 | Float_t ratio = TMath::Exp(-1.2*TMath::Abs(di)/sigmay2)*TMath::Exp(-1.2*TMath::Abs(dj)/sigmaz2); | |
193 | amp = ((matrix[2][0]-2)*(matrix[2][0]-2)/(matrix[-di+2][-dj]+2))*ratio; | |
194 | if (amp>2) amp = 2; | |
195 | vmatrix[2+di][2+dj]=amp; | |
196 | vmatrix[2+2*di][2+2*dj]=0; | |
197 | if ( (di*dj)!=0){ | |
198 | //DIAGONAL ELEMENTS | |
199 | vmatrix[2+2*di][2+dj] =0; | |
200 | vmatrix[2+di][2+2*dj] =0; | |
201 | } | |
202 | continue; | |
203 | } | |
204 | if (amp<4){ | |
205 | //if small amplitude - below 2 x threshold - don't consider other one | |
206 | vmatrix[2+di][2+dj]=amp; | |
207 | vmatrix[2+2*di][2+2*dj]=0; // don't take to the account next bin | |
208 | if ( (di*dj)!=0){ | |
209 | //DIAGONAL ELEMENTS | |
210 | vmatrix[2+2*di][2+dj] =0; | |
211 | vmatrix[2+di][2+2*dj] =0; | |
212 | } | |
213 | continue; | |
214 | } | |
215 | //if bigger then take everything | |
216 | vmatrix[2+di][2+dj]=amp; | |
217 | vmatrix[2+2*di][2+2*dj]= matrix[2*di+2][2*dj] ; | |
218 | if ( (di*dj)!=0){ | |
219 | //DIAGONAL ELEMENTS | |
220 | vmatrix[2+2*di][2+dj] = matrix[2*di+2][dj]; | |
221 | vmatrix[2+di][2+2*dj] = matrix[2+di][dj*2]; | |
222 | } | |
223 | } | |
224 | ||
225 | ||
226 | ||
227 | Float_t sumw=0; | |
228 | Float_t sumiw=0; | |
229 | Float_t sumi2w=0; | |
230 | Float_t sumjw=0; | |
231 | Float_t sumj2w=0; | |
232 | // | |
233 | for (Int_t i=-2;i<=2;i++) | |
234 | for (Int_t j=-2;j<=2;j++){ | |
235 | Float_t amp = vmatrix[i+2][j+2]; | |
236 | ||
237 | sumw += amp; | |
238 | sumiw += i*amp; | |
239 | sumi2w += i*i*amp; | |
240 | sumjw += j*amp; | |
241 | sumj2w += j*j*amp; | |
242 | } | |
243 | // | |
244 | Float_t meani = sumiw/sumw; | |
245 | Float_t mi2 = sumi2w/sumw-meani*meani; | |
246 | Float_t meanj = sumjw/sumw; | |
247 | Float_t mj2 = sumj2w/sumw-meanj*meanj; | |
248 | // | |
249 | Float_t ry = mi2/sigmay2; | |
250 | Float_t rz = mj2/sigmaz2; | |
251 | ||
252 | // | |
253 | if ( ( (ry<0.6) || (rz<0.6) ) && fLoop==2) return; | |
194b0609 | 254 | if ( (ry <1.2) && (rz<1.2) || (!fRecoParam->GetDoUnfold())) { |
255 | // | |
256 | //if cluster looks like expected or Unfolding not switched on | |
257 | //standard COG is used | |
1c53abe2 | 258 | //+1.2 deviation from expected sigma accepted |
259 | // c.fMax = FitMax(vmatrix,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2)); | |
260 | ||
261 | meani +=i0; | |
262 | meanj +=j0; | |
263 | //set cluster parameters | |
264 | c.SetQ(sumw); | |
265 | c.SetY(meani*fPadWidth); | |
266 | c.SetZ(meanj*fZWidth); | |
267 | c.SetSigmaY2(mi2); | |
268 | c.SetSigmaZ2(mj2); | |
269 | AddCluster(c); | |
270 | //remove cluster data from data | |
271 | for (Int_t di=-2;di<=2;di++) | |
272 | for (Int_t dj=-2;dj<=2;dj++){ | |
13116aec | 273 | resmatrix[di+2][dj] -= vmatrix[di+2][dj+2]; |
1c53abe2 | 274 | if (resmatrix[di+2][dj]<0) resmatrix[di+2][dj]=0; |
275 | } | |
276 | resmatrix[2][0] =0; | |
277 | return; | |
278 | } | |
279 | // | |
280 | //unfolding when neccessary | |
281 | // | |
282 | ||
13116aec | 283 | Float_t * matrix2[7]; //7x7 matrix with digits - indexing i = 0 ..6 j = -3..3 |
284 | Float_t dummy[7]={0,0,0,0,0,0}; | |
1c53abe2 | 285 | for (Int_t di=-3;di<=3;di++){ |
286 | matrix2[di+3] = &bins[k+di*max]; | |
287 | if ((k+di*max)<3) matrix2[di+3] = &dummy[3]; | |
288 | if ((k+di*max)>fMaxBin-3) matrix2[di+3] = &dummy[3]; | |
289 | } | |
290 | Float_t vmatrix2[5][5]; | |
291 | Float_t sumu; | |
292 | Float_t overlap; | |
293 | UnfoldCluster(matrix2,vmatrix2,meani,meanj,sumu,overlap); | |
294 | // | |
295 | // c.fMax = FitMax(vmatrix2,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2)); | |
296 | meani +=i0; | |
297 | meanj +=j0; | |
298 | //set cluster parameters | |
299 | c.SetQ(sumu); | |
300 | c.SetY(meani*fPadWidth); | |
301 | c.SetZ(meanj*fZWidth); | |
302 | c.SetSigmaY2(mi2); | |
303 | c.SetSigmaZ2(mj2); | |
304 | c.SetType(Char_t(overlap)+1); | |
305 | AddCluster(c); | |
306 | ||
307 | //unfolding 2 | |
308 | meani-=i0; | |
309 | meanj-=j0; | |
310 | if (gDebug>4) | |
311 | printf("%f\t%f\n", vmatrix2[2][2], vmatrix[2][2]); | |
312 | } | |
313 | ||
314 | ||
315 | ||
13116aec | 316 | void AliTPCclustererMI::UnfoldCluster(Float_t * matrix2[7], Float_t recmatrix[5][5], Float_t & meani, Float_t & meanj, |
1c53abe2 | 317 | Float_t & sumu, Float_t & overlap ) |
318 | { | |
319 | // | |
320 | //unfold cluster from input matrix | |
321 | //data corresponding to cluster writen in recmatrix | |
322 | //output meani and meanj | |
323 | ||
324 | //take separatelly y and z | |
325 | ||
326 | Float_t sum3i[7] = {0,0,0,0,0,0,0}; | |
327 | Float_t sum3j[7] = {0,0,0,0,0,0,0}; | |
328 | ||
329 | for (Int_t k =0;k<7;k++) | |
330 | for (Int_t l = -1; l<=1;l++){ | |
331 | sum3i[k]+=matrix2[k][l]; | |
332 | sum3j[k]+=matrix2[l+3][k-3]; | |
333 | } | |
334 | Float_t mratio[3][3]={{1,1,1},{1,1,1},{1,1,1}}; | |
335 | // | |
336 | //unfold y | |
337 | Float_t sum3wi = 0; //charge minus overlap | |
338 | Float_t sum3wio = 0; //full charge | |
339 | Float_t sum3iw = 0; //sum for mean value | |
340 | for (Int_t dk=-1;dk<=1;dk++){ | |
341 | sum3wio+=sum3i[dk+3]; | |
342 | if (dk==0){ | |
343 | sum3wi+=sum3i[dk+3]; | |
344 | } | |
345 | else{ | |
346 | Float_t ratio =1; | |
347 | if ( ( ((sum3i[dk+3]+3)/(sum3i[3]-3))+1 < (sum3i[2*dk+3]-3)/(sum3i[dk+3]+3))|| | |
348 | sum3i[dk+3]<=sum3i[2*dk+3] && sum3i[dk+3]>2 ){ | |
349 | Float_t xm2 = sum3i[-dk+3]; | |
350 | Float_t xm1 = sum3i[+3]; | |
351 | Float_t x1 = sum3i[2*dk+3]; | |
352 | Float_t x2 = sum3i[3*dk+3]; | |
cc5e9db0 | 353 | Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001); |
354 | Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.); | |
1c53abe2 | 355 | ratio = w11/(w11+w12); |
356 | for (Int_t dl=-1;dl<=1;dl++) | |
357 | mratio[dk+1][dl+1] *= ratio; | |
358 | } | |
359 | Float_t amp = sum3i[dk+3]*ratio; | |
360 | sum3wi+=amp; | |
361 | sum3iw+= dk*amp; | |
362 | } | |
363 | } | |
364 | meani = sum3iw/sum3wi; | |
365 | Float_t overlapi = (sum3wio-sum3wi)/sum3wio; | |
366 | ||
367 | ||
368 | ||
369 | //unfold z | |
370 | Float_t sum3wj = 0; //charge minus overlap | |
371 | Float_t sum3wjo = 0; //full charge | |
372 | Float_t sum3jw = 0; //sum for mean value | |
373 | for (Int_t dk=-1;dk<=1;dk++){ | |
374 | sum3wjo+=sum3j[dk+3]; | |
375 | if (dk==0){ | |
376 | sum3wj+=sum3j[dk+3]; | |
377 | } | |
378 | else{ | |
379 | Float_t ratio =1; | |
380 | if ( ( ((sum3j[dk+3]+3)/(sum3j[3]-3))+1 < (sum3j[2*dk+3]-3)/(sum3j[dk+3]+3)) || | |
381 | (sum3j[dk+3]<=sum3j[2*dk+3] && sum3j[dk+3]>2)){ | |
382 | Float_t xm2 = sum3j[-dk+3]; | |
383 | Float_t xm1 = sum3j[+3]; | |
384 | Float_t x1 = sum3j[2*dk+3]; | |
385 | Float_t x2 = sum3j[3*dk+3]; | |
cc5e9db0 | 386 | Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001); |
387 | Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.); | |
1c53abe2 | 388 | ratio = w11/(w11+w12); |
389 | for (Int_t dl=-1;dl<=1;dl++) | |
390 | mratio[dl+1][dk+1] *= ratio; | |
391 | } | |
392 | Float_t amp = sum3j[dk+3]*ratio; | |
393 | sum3wj+=amp; | |
394 | sum3jw+= dk*amp; | |
395 | } | |
396 | } | |
397 | meanj = sum3jw/sum3wj; | |
398 | Float_t overlapj = (sum3wjo-sum3wj)/sum3wjo; | |
399 | overlap = Int_t(100*TMath::Max(overlapi,overlapj)+3); | |
400 | sumu = (sum3wj+sum3wi)/2.; | |
401 | ||
402 | if (overlap ==3) { | |
403 | //if not overlap detected remove everything | |
404 | for (Int_t di =-2; di<=2;di++) | |
405 | for (Int_t dj =-2; dj<=2;dj++){ | |
406 | recmatrix[di+2][dj+2] = matrix2[3+di][dj]; | |
407 | } | |
408 | } | |
409 | else{ | |
410 | for (Int_t di =-1; di<=1;di++) | |
411 | for (Int_t dj =-1; dj<=1;dj++){ | |
412 | Float_t ratio =1; | |
413 | if (mratio[di+1][dj+1]==1){ | |
414 | recmatrix[di+2][dj+2] = matrix2[3+di][dj]; | |
415 | if (TMath::Abs(di)+TMath::Abs(dj)>1){ | |
416 | recmatrix[2*di+2][dj+2] = matrix2[3+2*di][dj]; | |
417 | recmatrix[di+2][2*dj+2] = matrix2[3+di][2*dj]; | |
418 | } | |
419 | recmatrix[2*di+2][2*dj+2] = matrix2[3+2*di][2*dj]; | |
420 | } | |
421 | else | |
422 | { | |
423 | //if we have overlap in direction | |
424 | recmatrix[di+2][dj+2] = mratio[di+1][dj+1]* matrix2[3+di][dj]; | |
425 | if (TMath::Abs(di)+TMath::Abs(dj)>1){ | |
cc5e9db0 | 426 | ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+0*di][1*dj]+1)),(Float_t)1.); |
1c53abe2 | 427 | recmatrix[2*di+2][dj+2] = ratio*recmatrix[di+2][dj+2]; |
428 | // | |
cc5e9db0 | 429 | ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+1*di][0*dj]+1)),(Float_t)1.); |
1c53abe2 | 430 | recmatrix[di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2]; |
431 | } | |
432 | else{ | |
433 | ratio = recmatrix[di+2][dj+2]/matrix2[3][0]; | |
434 | recmatrix[2*di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2]; | |
435 | } | |
436 | } | |
437 | } | |
438 | } | |
439 | if (gDebug>4) | |
440 | printf("%f\n", recmatrix[2][2]); | |
441 | ||
442 | } | |
443 | ||
444 | Float_t AliTPCclustererMI::FitMax(Float_t vmatrix[5][5], Float_t y, Float_t z, Float_t sigmay, Float_t sigmaz) | |
445 | { | |
446 | // | |
447 | // estimate max | |
448 | Float_t sumteor= 0; | |
449 | Float_t sumamp = 0; | |
450 | ||
451 | for (Int_t di = -1;di<=1;di++) | |
452 | for (Int_t dj = -1;dj<=1;dj++){ | |
453 | if (vmatrix[2+di][2+dj]>2){ | |
454 | Float_t teor = TMath::Gaus(di,y,sigmay*1.2)*TMath::Gaus(dj,z,sigmaz*1.2); | |
455 | sumteor += teor*vmatrix[2+di][2+dj]; | |
456 | sumamp += vmatrix[2+di][2+dj]*vmatrix[2+di][2+dj]; | |
457 | } | |
458 | } | |
459 | Float_t max = sumamp/sumteor; | |
460 | return max; | |
461 | } | |
462 | ||
463 | void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c){ | |
464 | // | |
465 | // transform cluster to the global coordinata | |
466 | // add the cluster to the array | |
467 | // | |
468 | Float_t meani = c.GetY()/fPadWidth; | |
469 | Float_t meanj = c.GetZ()/fZWidth; | |
470 | ||
471 | Int_t ki = TMath::Nint(meani-3); | |
472 | if (ki<0) ki=0; | |
473 | if (ki>=fMaxPad) ki = fMaxPad-1; | |
474 | Int_t kj = TMath::Nint(meanj-3); | |
475 | if (kj<0) kj=0; | |
476 | if (kj>=fMaxTime-3) kj=fMaxTime-4; | |
477 | // ki and kj shifted to "real" coordinata | |
f8aae377 | 478 | if (fRowDig) { |
479 | c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,0)-2,0); | |
480 | c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,1)-2,1); | |
481 | c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,2)-2,2); | |
482 | } | |
1c53abe2 | 483 | |
484 | ||
485 | Float_t s2 = c.GetSigmaY2(); | |
486 | Float_t w=fParam->GetPadPitchWidth(fSector); | |
487 | ||
488 | c.SetSigmaY2(s2*w*w); | |
489 | s2 = c.GetSigmaZ2(); | |
490 | w=fZWidth; | |
491 | c.SetSigmaZ2(s2*w*w); | |
492 | c.SetY((meani - 2.5 - 0.5*fMaxPad)*fParam->GetPadPitchWidth(fSector)); | |
493 | c.SetZ(fZWidth*(meanj-3)); | |
753797ce | 494 | c.SetZ(c.GetZ() - 3.*fParam->GetZSigma() + fParam->GetNTBinsL1()*fParam->GetZWidth()); // PASA delay + L1 delay |
1c53abe2 | 495 | c.SetZ(fSign*(fParam->GetZLength() - c.GetZ())); |
508541c7 | 496 | c.SetX(fRx); |
497 | c.SetDetector(fSector); | |
498 | c.SetRow(fRow); | |
499 | ||
1c53abe2 | 500 | if (ki<=1 || ki>=fMaxPad-1 || kj==1 || kj==fMaxTime-2) { |
501 | //c.SetSigmaY2(c.GetSigmaY2()*25.); | |
502 | //c.SetSigmaZ2(c.GetSigmaZ2()*4.); | |
503 | c.SetType(-(c.GetType()+3)); //edge clusters | |
504 | } | |
505 | if (fLoop==2) c.SetType(100); | |
506 | ||
507 | TClonesArray * arr = fRowCl->GetArray(); | |
45bcf167 | 508 | // AliTPCclusterMI * cl = |
509 | new ((*arr)[fNcluster]) AliTPCclusterMI(c); | |
1c53abe2 | 510 | |
511 | fNcluster++; | |
512 | } | |
513 | ||
514 | ||
515 | //_____________________________________________________________________________ | |
f8aae377 | 516 | void AliTPCclustererMI::Digits2Clusters() |
1c53abe2 | 517 | { |
518 | //----------------------------------------------------------------- | |
519 | // This is a simple cluster finder. | |
520 | //----------------------------------------------------------------- | |
1c53abe2 | 521 | |
f8aae377 | 522 | if (!fInput) { |
523 | Error("Digits2Clusters", "input tree not initialised"); | |
1c53abe2 | 524 | return; |
525 | } | |
526 | ||
f8aae377 | 527 | if (!fOutput) { |
528 | Error("Digits2Clusters", "output tree not initialised"); | |
529 | return; | |
1c53abe2 | 530 | } |
531 | ||
13116aec | 532 | AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor(); |
533 | ||
1c53abe2 | 534 | AliSimDigits digarr, *dummy=&digarr; |
535 | fRowDig = dummy; | |
536 | fInput->GetBranch("Segment")->SetAddress(&dummy); | |
537 | Stat_t nentries = fInput->GetEntries(); | |
538 | ||
f8aae377 | 539 | fMaxTime=fParam->GetMaxTBin()+6; // add 3 virtual time bins before and 3 after |
1c53abe2 | 540 | |
1c53abe2 | 541 | Int_t nclusters = 0; |
13116aec | 542 | |
1c53abe2 | 543 | for (Int_t n=0; n<nentries; n++) { |
544 | fInput->GetEvent(n); | |
508541c7 | 545 | if (!fParam->AdjustSectorRow(digarr.GetID(),fSector,fRow)) { |
1c53abe2 | 546 | cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl; |
547 | continue; | |
548 | } | |
508541c7 | 549 | Int_t row = fRow; |
13116aec | 550 | AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector |
551 | ||
552 | // | |
1c53abe2 | 553 | AliTPCClustersRow *clrow= new AliTPCClustersRow(); |
554 | fRowCl = clrow; | |
555 | clrow->SetClass("AliTPCclusterMI"); | |
556 | clrow->SetArray(1); | |
557 | ||
558 | clrow->SetID(digarr.GetID()); | |
559 | fOutput->GetBranch("Segment")->SetAddress(&clrow); | |
f8aae377 | 560 | fRx=fParam->GetPadRowRadii(fSector,row); |
1c53abe2 | 561 | |
562 | ||
f8aae377 | 563 | const Int_t kNIS=fParam->GetNInnerSector(), kNOS=fParam->GetNOuterSector(); |
1c53abe2 | 564 | fZWidth = fParam->GetZWidth(); |
565 | if (fSector < kNIS) { | |
f8aae377 | 566 | fMaxPad = fParam->GetNPadsLow(row); |
1c53abe2 | 567 | fSign = (fSector < kNIS/2) ? 1 : -1; |
f8aae377 | 568 | fPadLength = fParam->GetPadPitchLength(fSector,row); |
569 | fPadWidth = fParam->GetPadPitchWidth(); | |
1c53abe2 | 570 | } else { |
f8aae377 | 571 | fMaxPad = fParam->GetNPadsUp(row); |
1c53abe2 | 572 | fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1; |
f8aae377 | 573 | fPadLength = fParam->GetPadPitchLength(fSector,row); |
574 | fPadWidth = fParam->GetPadPitchWidth(); | |
1c53abe2 | 575 | } |
576 | ||
577 | ||
578 | fMaxBin=fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after | |
13116aec | 579 | fBins =new Float_t[fMaxBin]; |
580 | fResBins =new Float_t[fMaxBin]; //fBins with residuals after 1 finder loop | |
581 | memset(fBins,0,sizeof(Float_t)*fMaxBin); | |
582 | memset(fResBins,0,sizeof(Float_t)*fMaxBin); | |
1c53abe2 | 583 | |
584 | if (digarr.First()) //MI change | |
585 | do { | |
13116aec | 586 | Float_t dig=digarr.CurrentDigit(); |
f8aae377 | 587 | if (dig<=fParam->GetZeroSup()) continue; |
1c53abe2 | 588 | Int_t j=digarr.CurrentRow()+3, i=digarr.CurrentColumn()+3; |
9d4f75a9 | 589 | Float_t gain = gainROC->GetValue(row,digarr.CurrentColumn()); |
13116aec | 590 | fBins[i*fMaxTime+j]=dig/gain; |
1c53abe2 | 591 | } while (digarr.Next()); |
592 | digarr.ExpandTrackBuffer(); | |
593 | ||
f8aae377 | 594 | FindClusters(); |
8569a2b0 | 595 | |
596 | fOutput->Fill(); | |
88cb7938 | 597 | delete clrow; |
598 | nclusters+=fNcluster; | |
8569a2b0 | 599 | delete[] fBins; |
600 | delete[] fResBins; | |
88cb7938 | 601 | } |
f8aae377 | 602 | |
19dd5b2f | 603 | Info("Digits2Clusters", "Number of found clusters : %d", nclusters); |
f8aae377 | 604 | } |
605 | ||
606 | void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader) | |
607 | { | |
608 | //----------------------------------------------------------------- | |
22c352f8 | 609 | // This is a cluster finder for the TPC raw data. |
610 | // The method assumes NO ordering of the altro channels. | |
611 | // The pedestal subtraction can be switched on and off | |
612 | // using an option of the TPC reconstructor | |
f8aae377 | 613 | //----------------------------------------------------------------- |
614 | ||
615 | if (!fOutput) { | |
616 | Error("Digits2Clusters", "output tree not initialised"); | |
617 | return; | |
618 | } | |
619 | ||
f8aae377 | 620 | fRowDig = NULL; |
621 | ||
22c352f8 | 622 | AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor(); |
623 | ||
f8aae377 | 624 | Int_t nclusters = 0; |
88cb7938 | 625 | |
f8aae377 | 626 | fMaxTime = fParam->GetMaxTBin() + 6; // add 3 virtual time bins before and 3 after |
627 | const Int_t kNIS = fParam->GetNInnerSector(); | |
628 | const Int_t kNOS = fParam->GetNOuterSector(); | |
629 | const Int_t kNS = kNIS + kNOS; | |
630 | fZWidth = fParam->GetZWidth(); | |
631 | Int_t zeroSup = fParam->GetZeroSup(); | |
632 | ||
22c352f8 | 633 | Float_t** allBins = NULL; |
634 | Float_t** allBinsRes = NULL; | |
f8aae377 | 635 | |
22c352f8 | 636 | // Loop over sectors |
637 | for(fSector = 0; fSector < kNS; fSector++) { | |
f8aae377 | 638 | |
22c352f8 | 639 | AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector |
640 | ||
641 | Int_t nRows = 0; | |
642 | Int_t nDDLs = 0, indexDDL = 0; | |
643 | if (fSector < kNIS) { | |
644 | nRows = fParam->GetNRowLow(); | |
645 | fSign = (fSector < kNIS/2) ? 1 : -1; | |
646 | nDDLs = 2; | |
647 | indexDDL = fSector * 2; | |
648 | } | |
649 | else { | |
650 | nRows = fParam->GetNRowUp(); | |
651 | fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1; | |
652 | nDDLs = 4; | |
653 | indexDDL = (fSector-kNIS) * 4 + kNIS * 2; | |
654 | } | |
655 | ||
656 | allBins = new Float_t*[nRows]; | |
657 | allBinsRes = new Float_t*[nRows]; | |
658 | ||
659 | for (Int_t iRow = 0; iRow < nRows; iRow++) { | |
660 | Int_t maxPad; | |
661 | if (fSector < kNIS) | |
662 | maxPad = fParam->GetNPadsLow(iRow); | |
663 | else | |
664 | maxPad = fParam->GetNPadsUp(iRow); | |
665 | ||
666 | Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after | |
667 | allBins[iRow] = new Float_t[maxBin]; | |
668 | allBinsRes[iRow] = new Float_t[maxBin]; | |
669 | memset(allBins[iRow],0,sizeof(Float_t)*maxBin); | |
670 | memset(allBinsRes[iRow],0,sizeof(Float_t)*maxBin); | |
671 | } | |
672 | ||
673 | // Loas the raw data for corresponding DDLs | |
674 | rawReader->Reset(); | |
675 | AliTPCRawStream input(rawReader); | |
676 | input.SetOldRCUFormat(fIsOldRCUFormat); | |
362c9d61 | 677 | rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1); |
f8aae377 | 678 | |
22c352f8 | 679 | // Begin loop over altro data |
680 | while (input.Next()) { | |
681 | ||
682 | if (input.GetSector() != fSector) | |
683 | AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",fSector,input.GetSector())); | |
684 | ||
22c352f8 | 685 | |
686 | Int_t iRow = input.GetRow(); | |
687 | if (iRow < 0 || iRow >= nRows) | |
688 | AliFatal(Form("Pad-row index (%d) outside the range (%d -> %d) !", | |
689 | iRow, 0, nRows -1)); | |
690 | ||
691 | Int_t iPad = input.GetPad() + 3; | |
692 | ||
693 | Int_t maxPad; | |
694 | if (fSector < kNIS) | |
695 | maxPad = fParam->GetNPadsLow(iRow); | |
696 | else | |
697 | maxPad = fParam->GetNPadsUp(iRow); | |
698 | ||
699 | if (input.GetPad() < 0 || input.GetPad() >= maxPad) | |
700 | AliFatal(Form("Pad index (%d) outside the range (%d -> %d) !", | |
701 | input.GetPad(), 0, maxPad -1)); | |
702 | ||
703 | Int_t iTimeBin = input.GetTime() + 3; | |
704 | if ( input.GetTime() < 0 || input.GetTime() >= fParam->GetMaxTBin()) | |
705 | AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !", | |
706 | input.GetTime(), 0, fParam->GetMaxTBin() -1)); | |
707 | ||
708 | Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after | |
709 | ||
710 | if (((iPad*fMaxTime+iTimeBin) >= maxBin) || | |
711 | ((iPad*fMaxTime+iTimeBin) < 0)) | |
712 | AliFatal(Form("Index outside the allowed range" | |
713 | " Sector=%d Row=%d Pad=%d Timebin=%d" | |
714 | " (Max.index=%d)",fSector,iRow,iPad,iTimeBin,maxBin)); | |
715 | ||
716 | Float_t signal = input.GetSignal(); | |
194b0609 | 717 | // if (!fPedSubtraction && signal <= zeroSup) continue; |
718 | if (!fRecoParam->GetCalcPedestal() && signal <= zeroSup) continue; | |
22c352f8 | 719 | |
720 | Float_t gain = gainROC->GetValue(iRow,input.GetPad()); | |
721 | allBins[iRow][iPad*fMaxTime+iTimeBin] = signal/gain; | |
65c045f0 | 722 | allBins[iRow][iPad*fMaxTime+0] = 1; // pad with signal |
22c352f8 | 723 | } // End of the loop over altro data |
724 | ||
725 | // Now loop over rows and perform pedestal subtraction | |
194b0609 | 726 | // if (fPedSubtraction) { |
727 | if (fRecoParam->GetCalcPedestal()) { | |
22c352f8 | 728 | for (Int_t iRow = 0; iRow < nRows; iRow++) { |
729 | Int_t maxPad; | |
730 | if (fSector < kNIS) | |
731 | maxPad = fParam->GetNPadsLow(iRow); | |
732 | else | |
733 | maxPad = fParam->GetNPadsUp(iRow); | |
734 | ||
735 | for (Int_t iPad = 0; iPad < maxPad + 6; iPad++) { | |
65c045f0 | 736 | if (allBins[iRow][iPad*fMaxTime+0] !=1) continue; // no data |
22c352f8 | 737 | Float_t *p = &allBins[iRow][iPad*fMaxTime+3]; |
65c045f0 | 738 | //Float_t pedestal = TMath::Median(fMaxTime, p); |
739 | Int_t id[3] = {fSector, iRow, iPad-3}; | |
740 | Float_t pedestal = ProcesSignal(p, fMaxTime, id); | |
22c352f8 | 741 | for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) { |
742 | allBins[iRow][iPad*fMaxTime+iTimeBin] -= pedestal; | |
7fef31a6 | 743 | if (iTimeBin < AliTPCReconstructor::GetRecoParam()->GetFirstBin()) |
744 | allBins[iRow][iPad*fMaxTime+iTimeBin] = 0; | |
745 | if (iTimeBin > AliTPCReconstructor::GetRecoParam()->GetLastBin()) | |
746 | allBins[iRow][iPad*fMaxTime+iTimeBin] = 0; | |
22c352f8 | 747 | if (allBins[iRow][iPad*fMaxTime+iTimeBin] < zeroSup) |
748 | allBins[iRow][iPad*fMaxTime+iTimeBin] = 0; | |
749 | } | |
750 | } | |
f8aae377 | 751 | } |
22c352f8 | 752 | } |
753 | ||
754 | // Now loop over rows and find clusters | |
755 | for (fRow = 0; fRow < nRows; fRow++) { | |
756 | fRowCl = new AliTPCClustersRow; | |
757 | fRowCl->SetClass("AliTPCclusterMI"); | |
758 | fRowCl->SetArray(1); | |
759 | fRowCl->SetID(fParam->GetIndex(fSector, fRow)); | |
760 | fOutput->GetBranch("Segment")->SetAddress(&fRowCl); | |
761 | ||
762 | fRx = fParam->GetPadRowRadii(fSector, fRow); | |
763 | fPadLength = fParam->GetPadPitchLength(fSector, fRow); | |
f8aae377 | 764 | fPadWidth = fParam->GetPadPitchWidth(); |
22c352f8 | 765 | if (fSector < kNIS) |
766 | fMaxPad = fParam->GetNPadsLow(fRow); | |
767 | else | |
768 | fMaxPad = fParam->GetNPadsUp(fRow); | |
f8aae377 | 769 | fMaxBin = fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after |
22c352f8 | 770 | |
771 | fBins = allBins[fRow]; | |
772 | fResBins = allBinsRes[fRow]; | |
773 | ||
774 | FindClusters(); | |
775 | ||
776 | fOutput->Fill(); | |
777 | delete fRowCl; | |
778 | nclusters += fNcluster; | |
779 | } // End of loop to find clusters | |
780 | ||
781 | ||
782 | for (Int_t iRow = 0; iRow < nRows; iRow++) { | |
783 | delete [] allBins[iRow]; | |
784 | delete [] allBinsRes[iRow]; | |
f8aae377 | 785 | } |
786 | ||
22c352f8 | 787 | delete [] allBins; |
788 | delete [] allBinsRes; | |
f8aae377 | 789 | |
22c352f8 | 790 | } // End of loop over sectors |
f8aae377 | 791 | |
f8aae377 | 792 | Info("Digits2Clusters", "Number of found clusters : %d\n", nclusters); |
22c352f8 | 793 | |
f8aae377 | 794 | } |
795 | ||
796 | void AliTPCclustererMI::FindClusters() | |
797 | { | |
798 | //add virtual charge at the edge | |
799 | for (Int_t i=0; i<fMaxTime; i++){ | |
800 | Float_t amp1 = fBins[i+3*fMaxTime]; | |
801 | Float_t amp0 =0; | |
802 | if (amp1>0){ | |
803 | Float_t amp2 = fBins[i+4*fMaxTime]; | |
804 | if (amp2==0) amp2=0.5; | |
805 | Float_t sigma2 = GetSigmaY2(i); | |
806 | amp0 = (amp1*amp1/amp2)*TMath::Exp(-1./sigma2); | |
807 | if (gDebug>4) printf("\n%f\n",amp0); | |
808 | } | |
13116aec | 809 | fBins[i+2*fMaxTime] = amp0; |
f8aae377 | 810 | amp0 = 0; |
811 | amp1 = fBins[(fMaxPad+2)*fMaxTime+i]; | |
812 | if (amp1>0){ | |
813 | Float_t amp2 = fBins[i+(fMaxPad+1)*fMaxTime]; | |
814 | if (amp2==0) amp2=0.5; | |
815 | Float_t sigma2 = GetSigmaY2(i); | |
816 | amp0 = (amp1*amp1/amp2)*TMath::Exp(-1./sigma2); | |
817 | if (gDebug>4) printf("\n%f\n",amp0); | |
818 | } | |
13116aec | 819 | fBins[(fMaxPad+3)*fMaxTime+i] = amp0; |
f8aae377 | 820 | } |
821 | ||
822 | // memcpy(fResBins,fBins, fMaxBin*2); | |
823 | memcpy(fResBins,fBins, fMaxBin); | |
824 | // | |
825 | fNcluster=0; | |
826 | //first loop - for "gold cluster" | |
827 | fLoop=1; | |
13116aec | 828 | Float_t *b=&fBins[-1]+2*fMaxTime; |
194b0609 | 829 | Int_t crtime = Int_t((fParam->GetZLength()-fRecoParam->GetCtgRange()*fRx)/fZWidth-fParam->GetNTBinsL1()-5); |
f8aae377 | 830 | |
831 | for (Int_t i=2*fMaxTime; i<fMaxBin-2*fMaxTime; i++) { | |
832 | b++; | |
833 | if (*b<8) continue; //threshold form maxima | |
834 | if (i%fMaxTime<crtime) { | |
835 | Int_t delta = -(i%fMaxTime)+crtime; | |
836 | b+=delta; | |
837 | i+=delta; | |
838 | continue; | |
839 | } | |
840 | ||
841 | if (!IsMaximum(*b,fMaxTime,b)) continue; | |
842 | AliTPCclusterMI c; | |
843 | Int_t dummy=0; | |
844 | MakeCluster(i, fMaxTime, fBins, dummy,c); | |
845 | //} | |
846 | } | |
847 | //memcpy(fBins,fResBins, fMaxBin*2); | |
848 | //second loop - for rest cluster | |
849 | /* | |
850 | fLoop=2; | |
851 | b=&fResBins[-1]+2*fMaxTime; | |
852 | for (Int_t i=2*fMaxTime; i<fMaxBin-2*fMaxTime; i++) { | |
853 | b++; | |
854 | if (*b<25) continue; // bigger threshold for maxima | |
855 | if (!IsMaximum(*b,fMaxTime,b)) continue; | |
856 | AliTPCclusterMI c; | |
857 | Int_t dummy; | |
858 | MakeCluster(i, fMaxTime, fResBins, dummy,c); | |
859 | //} | |
860 | } | |
861 | */ | |
8569a2b0 | 862 | } |
65c045f0 | 863 | |
864 | ||
865 | Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t id[3]){ | |
866 | // | |
867 | // process signal on given pad - + streaming of additional information in special mode | |
868 | // | |
869 | // id[0] - sector | |
870 | // id[1] - row | |
871 | // id[2] - pad | |
872 | Int_t offset =100; | |
194b0609 | 873 | Float_t kMin =fRecoParam->GetDumpAmplitudeMin(); // minimal signal to be dumped |
65c045f0 | 874 | Double_t median = TMath::Median(nchannels-offset, &(signal[offset])); |
875 | if (AliLog::GetDebugLevel("","AliTPCclustererMI")==0) return median; | |
876 | // | |
877 | ||
878 | Double_t mean = TMath::Mean(nchannels-offset, &(signal[offset])); | |
879 | Double_t rms = TMath::RMS(nchannels-offset, &(signal[offset])); | |
880 | Double_t *dsignal = new Double_t[nchannels]; | |
881 | Double_t *dtime = new Double_t[nchannels]; | |
882 | Float_t max = 0; | |
883 | Float_t maxPos = 0; | |
884 | for (Int_t i=0; i<nchannels; i++){ | |
885 | dtime[i] = i; | |
886 | dsignal[i] = signal[i]; | |
bd85a5e8 | 887 | if (i<offset) continue; |
65c045f0 | 888 | if (signal[i]>max && i <fMaxTime-100) { // temporary remove spike signals at the end |
889 | max = signal[i]; | |
890 | maxPos = i; | |
891 | } | |
892 | } | |
893 | ||
194b0609 | 894 | Double_t mean06=0, mean09=0; |
895 | Double_t rms06=0, rms09=0; | |
65c045f0 | 896 | AliMathBase::EvaluateUni(nchannels-offset, &(dsignal[offset]), mean06, rms06, int(0.6*(nchannels-offset))); |
65c045f0 | 897 | AliMathBase::EvaluateUni(nchannels-offset, &(dsignal[offset]), mean09, rms09, int(0.9*(nchannels-offset))); |
7fef31a6 | 898 | // |
65c045f0 | 899 | // |
900 | UInt_t uid[3] = {UInt_t(id[0]),UInt_t(id[1]),UInt_t(id[2])}; | |
901 | if (uid[0]< AliTPCROC::Instance()->GetNSectors() | |
902 | && uid[1]< AliTPCROC::Instance()->GetNRows(uid[0]) && | |
903 | uid[2] < AliTPCROC::Instance()->GetNPads(uid[0], uid[1])){ | |
904 | if (!fAmplitudeHisto){ | |
905 | fAmplitudeHisto = new TObjArray(72); | |
906 | } | |
907 | TObjArray * sectorArray = (TObjArray*)fAmplitudeHisto->UncheckedAt(uid[0]); | |
908 | if (!sectorArray){ | |
909 | Int_t npads = AliTPCROC::Instance()->GetNChannels(uid[0]); | |
910 | sectorArray = new TObjArray(npads); | |
911 | fAmplitudeHisto->AddAt(sectorArray, uid[0]); | |
912 | } | |
913 | Int_t position = uid[2]+ AliTPCROC::Instance()->GetRowIndexes(uid[0])[uid[1]]; | |
914 | TH1F * histo = (TH1F*)sectorArray->UncheckedAt(position); | |
915 | if (!histo){ | |
916 | char hname[100]; | |
917 | sprintf(hname,"Amp_%d_%d_%d",uid[0],uid[1],uid[2]); | |
918 | TFile * backup = gFile; | |
919 | fDebugStreamer->GetFile()->cd(); | |
194b0609 | 920 | histo = new TH1F(hname, hname, 100, 5,100); |
65c045f0 | 921 | //histo->SetDirectory(0); // histogram not connected to directory -(File) |
922 | sectorArray->AddAt(histo, position); | |
923 | if (backup) backup->cd(); | |
924 | } | |
925 | for (Int_t i=0; i<nchannels; i++){ | |
926 | if (signal[i]>0) histo->Fill(signal[i]); | |
927 | } | |
928 | } | |
929 | // | |
930 | TGraph * graph; | |
931 | Bool_t random = (gRandom->Rndm()<0.0001); | |
932 | if (max-median>kMin || rms06>2.*fParam->GetZeroSup() || random){ | |
933 | graph =new TGraph(nchannels, dtime, dsignal); | |
934 | if (rms06>2.*fParam->GetZeroSup() || random) | |
935 | (*fDebugStreamer)<<"SignalN"<< //noise pads - or random sample of pads | |
936 | "Sector="<<uid[0]<< | |
937 | "Row="<<uid[1]<< | |
938 | "Pad="<<uid[2]<< | |
864c1803 | 939 | "Graph="<<graph<< |
65c045f0 | 940 | "Max="<<max<< |
941 | "MaxPos="<<maxPos<< | |
942 | // | |
943 | "Median="<<median<< | |
944 | "Mean="<<mean<< | |
945 | "RMS="<<rms<< | |
946 | "Mean06="<<mean06<< | |
947 | "RMS06="<<rms06<< | |
65c045f0 | 948 | "Mean09="<<mean09<< |
949 | "RMS09="<<rms09<< | |
950 | "\n"; | |
951 | if (max-median>kMin) | |
952 | (*fDebugStreamer)<<"SignalB"<< // pads with signal | |
953 | "Sector="<<uid[0]<< | |
954 | "Row="<<uid[1]<< | |
955 | "Pad="<<uid[2]<< | |
864c1803 | 956 | "Graph="<<graph<< |
65c045f0 | 957 | "Max="<<max<< |
958 | "MaxPos="<<maxPos<< | |
959 | // | |
960 | "Median="<<median<< | |
961 | "Mean="<<mean<< | |
962 | "RMS="<<rms<< | |
963 | "Mean06="<<mean06<< | |
964 | "RMS06="<<rms06<< | |
65c045f0 | 965 | "Mean09="<<mean09<< |
966 | "RMS09="<<rms09<< | |
967 | "\n"; | |
968 | delete graph; | |
969 | } | |
970 | ||
971 | (*fDebugStreamer)<<"Signal"<< | |
972 | "Sector="<<uid[0]<< | |
973 | "Row="<<uid[1]<< | |
974 | "Pad="<<uid[2]<< | |
975 | "Max="<<max<< | |
976 | "MaxPos="<<maxPos<< | |
977 | // | |
978 | "Median="<<median<< | |
979 | "Mean="<<mean<< | |
980 | "RMS="<<rms<< | |
981 | "Mean06="<<mean06<< | |
982 | "RMS06="<<rms06<< | |
65c045f0 | 983 | "Mean09="<<mean09<< |
984 | "RMS09="<<rms09<< | |
985 | "\n"; | |
7fef31a6 | 986 | // |
987 | // | |
988 | // Central Electrode signal analysis | |
989 | // | |
990 | Double_t ceQmax =0, ceQsum=0, ceTime=0; | |
991 | Double_t cemean = mean06, cerms=rms06 ; | |
992 | Int_t cemaxpos= 0; | |
993 | Double_t ceThreshold=5.*cerms; | |
994 | Double_t ceSumThreshold=8.*cerms; | |
97f127bb | 995 | const Int_t kCemin=5; // range for the analysis of the ce signal +- channels from the peak |
996 | const Int_t kCemax=5; | |
bd85a5e8 | 997 | for (Int_t i=nchannels-2; i>1; i--){ |
7fef31a6 | 998 | if ( (dsignal[i]-mean06)>ceThreshold && dsignal[i]>=dsignal[i+1] && dsignal[i]>=dsignal[i-1] ){ |
999 | cemaxpos=i; | |
1000 | break; | |
1001 | } | |
1002 | } | |
1003 | if (cemaxpos!=0){ | |
97f127bb | 1004 | for (Int_t i=cemaxpos-kCemin; i<cemaxpos+kCemax; i++){ |
bd85a5e8 | 1005 | if (i>0 && i<nchannels&&dsignal[i]- cemean>0){ |
7fef31a6 | 1006 | Double_t val=dsignal[i]- cemean; |
1007 | ceTime+=val*dtime[i]; | |
1008 | ceQsum+=val; | |
1009 | if (val>ceQmax) ceQmax=val; | |
1010 | } | |
1011 | } | |
1012 | if (ceQmax&&ceQsum>ceSumThreshold) { | |
1013 | ceTime/=ceQsum; | |
1014 | (*fDebugStreamer)<<"Signalce"<< | |
1015 | "Sector="<<uid[0]<< | |
1016 | "Row="<<uid[1]<< | |
1017 | "Pad="<<uid[2]<< | |
1018 | "Max="<<ceQmax<< | |
1019 | "Qsum="<<ceQsum<< | |
1020 | "Time="<<ceTime<< | |
bd85a5e8 | 1021 | "RMS06="<<rms06<< |
7fef31a6 | 1022 | // |
1023 | "\n"; | |
1024 | } | |
1025 | } | |
1026 | // end of ce signal analysis | |
1027 | // | |
1028 | ||
1029 | // | |
1030 | // Gating grid signal analysis | |
1031 | // | |
1032 | Double_t ggQmax =0, ggQsum=0, ggTime=0; | |
1033 | Double_t ggmean = mean06, ggrms=rms06 ; | |
1034 | Int_t ggmaxpos= 0; | |
1035 | Double_t ggThreshold=5.*ggrms; | |
1036 | Double_t ggSumThreshold=8.*ggrms; | |
bd85a5e8 | 1037 | |
1038 | for (Int_t i=1; i<nchannels-1; i++){ | |
1039 | if ( (dsignal[i]-mean06)>ggThreshold && dsignal[i]>=dsignal[i+1] && dsignal[i]>=dsignal[i-1] && | |
1040 | (dsignal[i]+dsignal[i+1]+dsignal[i-1]-3*mean06)>ggSumThreshold){ | |
7fef31a6 | 1041 | ggmaxpos=i; |
bd85a5e8 | 1042 | if (dsignal[i-1]>dsignal[i+1]) ggmaxpos=i-1; |
7fef31a6 | 1043 | break; |
1044 | } | |
1045 | } | |
1046 | if (ggmaxpos!=0){ | |
bd85a5e8 | 1047 | for (Int_t i=ggmaxpos-1; i<ggmaxpos+3; i++){ |
1048 | if (i>0 && i<nchannels && dsignal[i]-ggmean>0){ | |
7fef31a6 | 1049 | Double_t val=dsignal[i]- ggmean; |
1050 | ggTime+=val*dtime[i]; | |
1051 | ggQsum+=val; | |
1052 | if (val>ggQmax) ggQmax=val; | |
1053 | } | |
1054 | } | |
1055 | if (ggQmax&&ggQsum>ggSumThreshold) { | |
1056 | ggTime/=ggQsum; | |
1057 | (*fDebugStreamer)<<"Signalgg"<< | |
1058 | "Sector="<<uid[0]<< | |
1059 | "Row="<<uid[1]<< | |
1060 | "Pad="<<uid[2]<< | |
1061 | "Max="<<ggQmax<< | |
1062 | "Qsum="<<ggQsum<< | |
1063 | "Time="<<ggTime<< | |
bd85a5e8 | 1064 | "RMS06="<<rms06<< |
7fef31a6 | 1065 | // |
1066 | "\n"; | |
1067 | } | |
1068 | } | |
1069 | // end of gg signal analysis | |
1070 | ||
1071 | ||
65c045f0 | 1072 | delete [] dsignal; |
1073 | delete [] dtime; | |
194b0609 | 1074 | if (rms06>fRecoParam->GetMaxNoise()) return 1024+median; // sign noisy channel in debug mode |
65c045f0 | 1075 | return median; |
1076 | } | |
1077 | ||
1078 | ||
1079 | ||
1080 | void AliTPCclustererMI::DumpHistos(){ | |
1081 | if (!fAmplitudeHisto) return; | |
1082 | for (UInt_t isector=0; isector<AliTPCROC::Instance()->GetNSectors(); isector++){ | |
1083 | TObjArray * array = (TObjArray*)fAmplitudeHisto->UncheckedAt(isector); | |
1084 | if (!array) continue; | |
1085 | for (UInt_t ipad = 0; ipad <(UInt_t)array->GetEntriesFast(); ipad++){ | |
1086 | TH1F * histo = (TH1F*) array->UncheckedAt(ipad); | |
1087 | if (!histo) continue; | |
1088 | if (histo->GetEntries()<100) continue; | |
1089 | histo->Fit("gaus","q"); | |
1090 | Float_t mean = histo->GetMean(); | |
1091 | Float_t rms = histo->GetRMS(); | |
1092 | Float_t gmean = histo->GetFunction("gaus")->GetParameter(1); | |
1093 | Float_t gsigma = histo->GetFunction("gaus")->GetParameter(2); | |
1094 | Float_t max = histo->GetFunction("gaus")->GetParameter(0); | |
1095 | ||
1096 | // get pad number | |
1097 | UInt_t row=0, pad =0; | |
1098 | const UInt_t *indexes = AliTPCROC::Instance()->GetRowIndexes(isector); | |
1099 | for (UInt_t irow=0; irow< AliTPCROC::Instance()->GetNRows(isector); irow++){ | |
1100 | if (indexes[irow]<ipad){ | |
1101 | row = irow; | |
1102 | pad = ipad-indexes[irow]; | |
1103 | } | |
1104 | } | |
1105 | Int_t rpad = pad - (AliTPCROC::Instance()->GetNPads(isector,row))/2; | |
1106 | // | |
1107 | (*fDebugStreamer)<<"Fit"<< | |
1108 | "Sector="<<isector<< | |
1109 | "Row="<<row<< | |
1110 | "Pad="<<pad<< | |
1111 | "RPad="<<rpad<< | |
1112 | "Max="<<max<< | |
1113 | "Mean="<<mean<< | |
1114 | "RMS="<<rms<< | |
1115 | "GMean="<<gmean<< | |
1116 | "GSigma="<<gsigma<< | |
1117 | "\n"; | |
1118 | if (array->UncheckedAt(ipad)) fDebugStreamer->StoreObject(array->UncheckedAt(ipad)); | |
1119 | } | |
1120 | } | |
1121 | } |