1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------
19 // Implementation of the TPC clusterer
21 // Origin: Marian Ivanov
22 //-------------------------------------------------------
24 #include "AliTPCReconstructor.h"
25 #include "AliTPCclustererMI.h"
26 #include "AliTPCclusterMI.h"
27 #include <TObjArray.h>
29 #include "AliTPCClustersArray.h"
30 #include "AliTPCClustersRow.h"
31 #include "AliDigits.h"
32 #include "AliSimDigits.h"
33 #include "AliTPCParam.h"
34 #include "AliRawReader.h"
35 #include "AliTPCRawStream.h"
36 #include "AliRunLoader.h"
37 #include "AliLoader.h"
38 #include "Riostream.h"
41 #include "AliTPCcalibDB.h"
42 #include "AliTPCCalPad.h"
43 #include "AliTPCCalROC.h"
46 ClassImp(AliTPCclustererMI)
50 AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par)
52 fPedSubtraction = kFALSE;
53 fIsOldRCUFormat = kFALSE;
59 void AliTPCclustererMI::SetInput(TTree * tree)
62 // set input tree with digits
65 if (!fInput->GetBranch("Segment")){
66 cerr<<"AliTPC::Digits2Clusters(): no porper input tree !\n";
72 void AliTPCclustererMI::SetOutput(TTree * tree)
77 AliTPCClustersRow clrow;
78 AliTPCClustersRow *pclrow=&clrow;
79 clrow.SetClass("AliTPCclusterMI");
80 clrow.SetArray(1); // to make Clones array
81 fOutput->Branch("Segment","AliTPCClustersRow",&pclrow,32000,200);
85 Float_t AliTPCclustererMI::GetSigmaY2(Int_t iz){
86 // sigma y2 = in digits - we don't know the angle
87 Float_t z = iz*fParam->GetZWidth()+fParam->GetNTBinsL1()*fParam->GetZWidth();
88 Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/
89 (fPadWidth*fPadWidth);
91 Float_t res = sd2+sres;
96 Float_t AliTPCclustererMI::GetSigmaZ2(Int_t iz){
97 //sigma z2 = in digits - angle estimated supposing vertex constraint
98 Float_t z = iz*fZWidth+fParam->GetNTBinsL1()*fParam->GetZWidth();
99 Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/(fZWidth*fZWidth);
100 Float_t angular = fPadLength*(fParam->GetZLength()-z)/(fRx*fZWidth);
103 Float_t sres = fParam->GetZSigma()/fZWidth;
105 Float_t res = angular +sd2+sres;
109 void AliTPCclustererMI::MakeCluster(Int_t k,Int_t max,Float_t *bins, UInt_t /*m*/,
112 Int_t i0=k/max; //central pad
113 Int_t j0=k%max; //central time bin
115 // set pointers to data
116 //Int_t dummy[5] ={0,0,0,0,0};
117 Float_t * matrix[5]; //5x5 matrix with digits - indexing i = 0 ..4 j = -2..2
118 Float_t * resmatrix[5];
119 for (Int_t di=-2;di<=2;di++){
120 matrix[di+2] = &bins[k+di*max];
121 resmatrix[di+2] = &fResBins[k+di*max];
123 //build matrix with virtual charge
124 Float_t sigmay2= GetSigmaY2(j0);
125 Float_t sigmaz2= GetSigmaZ2(j0);
127 Float_t vmatrix[5][5];
128 vmatrix[2][2] = matrix[2][0];
130 c.SetMax((UShort_t)(vmatrix[2][2])); // write maximal amplitude
131 for (Int_t di =-1;di <=1;di++)
132 for (Int_t dj =-1;dj <=1;dj++){
133 Float_t amp = matrix[di+2][dj];
134 if ( (amp<2) && (fLoop<2)){
135 // if under threshold - calculate virtual charge
136 Float_t ratio = TMath::Exp(-1.2*TMath::Abs(di)/sigmay2)*TMath::Exp(-1.2*TMath::Abs(dj)/sigmaz2);
137 amp = ((matrix[2][0]-2)*(matrix[2][0]-2)/(matrix[-di+2][-dj]+2))*ratio;
139 vmatrix[2+di][2+dj]=amp;
140 vmatrix[2+2*di][2+2*dj]=0;
143 vmatrix[2+2*di][2+dj] =0;
144 vmatrix[2+di][2+2*dj] =0;
149 //if small amplitude - below 2 x threshold - don't consider other one
150 vmatrix[2+di][2+dj]=amp;
151 vmatrix[2+2*di][2+2*dj]=0; // don't take to the account next bin
154 vmatrix[2+2*di][2+dj] =0;
155 vmatrix[2+di][2+2*dj] =0;
159 //if bigger then take everything
160 vmatrix[2+di][2+dj]=amp;
161 vmatrix[2+2*di][2+2*dj]= matrix[2*di+2][2*dj] ;
164 vmatrix[2+2*di][2+dj] = matrix[2*di+2][dj];
165 vmatrix[2+di][2+2*dj] = matrix[2+di][dj*2];
177 for (Int_t i=-2;i<=2;i++)
178 for (Int_t j=-2;j<=2;j++){
179 Float_t amp = vmatrix[i+2][j+2];
188 Float_t meani = sumiw/sumw;
189 Float_t mi2 = sumi2w/sumw-meani*meani;
190 Float_t meanj = sumjw/sumw;
191 Float_t mj2 = sumj2w/sumw-meanj*meanj;
193 Float_t ry = mi2/sigmay2;
194 Float_t rz = mj2/sigmaz2;
197 if ( ( (ry<0.6) || (rz<0.6) ) && fLoop==2) return;
198 if ( (ry <1.2) && (rz<1.2) ) {
199 //if cluster looks like expected
200 //+1.2 deviation from expected sigma accepted
201 // c.fMax = FitMax(vmatrix,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2));
205 //set cluster parameters
207 c.SetY(meani*fPadWidth);
208 c.SetZ(meanj*fZWidth);
212 //remove cluster data from data
213 for (Int_t di=-2;di<=2;di++)
214 for (Int_t dj=-2;dj<=2;dj++){
215 resmatrix[di+2][dj] -= vmatrix[di+2][dj+2];
216 if (resmatrix[di+2][dj]<0) resmatrix[di+2][dj]=0;
222 //unfolding when neccessary
225 Float_t * matrix2[7]; //7x7 matrix with digits - indexing i = 0 ..6 j = -3..3
226 Float_t dummy[7]={0,0,0,0,0,0};
227 for (Int_t di=-3;di<=3;di++){
228 matrix2[di+3] = &bins[k+di*max];
229 if ((k+di*max)<3) matrix2[di+3] = &dummy[3];
230 if ((k+di*max)>fMaxBin-3) matrix2[di+3] = &dummy[3];
232 Float_t vmatrix2[5][5];
235 UnfoldCluster(matrix2,vmatrix2,meani,meanj,sumu,overlap);
237 // c.fMax = FitMax(vmatrix2,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2));
240 //set cluster parameters
242 c.SetY(meani*fPadWidth);
243 c.SetZ(meanj*fZWidth);
246 c.SetType(Char_t(overlap)+1);
253 printf("%f\t%f\n", vmatrix2[2][2], vmatrix[2][2]);
258 void AliTPCclustererMI::UnfoldCluster(Float_t * matrix2[7], Float_t recmatrix[5][5], Float_t & meani, Float_t & meanj,
259 Float_t & sumu, Float_t & overlap )
262 //unfold cluster from input matrix
263 //data corresponding to cluster writen in recmatrix
264 //output meani and meanj
266 //take separatelly y and z
268 Float_t sum3i[7] = {0,0,0,0,0,0,0};
269 Float_t sum3j[7] = {0,0,0,0,0,0,0};
271 for (Int_t k =0;k<7;k++)
272 for (Int_t l = -1; l<=1;l++){
273 sum3i[k]+=matrix2[k][l];
274 sum3j[k]+=matrix2[l+3][k-3];
276 Float_t mratio[3][3]={{1,1,1},{1,1,1},{1,1,1}};
279 Float_t sum3wi = 0; //charge minus overlap
280 Float_t sum3wio = 0; //full charge
281 Float_t sum3iw = 0; //sum for mean value
282 for (Int_t dk=-1;dk<=1;dk++){
283 sum3wio+=sum3i[dk+3];
289 if ( ( ((sum3i[dk+3]+3)/(sum3i[3]-3))+1 < (sum3i[2*dk+3]-3)/(sum3i[dk+3]+3))||
290 sum3i[dk+3]<=sum3i[2*dk+3] && sum3i[dk+3]>2 ){
291 Float_t xm2 = sum3i[-dk+3];
292 Float_t xm1 = sum3i[+3];
293 Float_t x1 = sum3i[2*dk+3];
294 Float_t x2 = sum3i[3*dk+3];
295 Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001);
296 Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.);
297 ratio = w11/(w11+w12);
298 for (Int_t dl=-1;dl<=1;dl++)
299 mratio[dk+1][dl+1] *= ratio;
301 Float_t amp = sum3i[dk+3]*ratio;
306 meani = sum3iw/sum3wi;
307 Float_t overlapi = (sum3wio-sum3wi)/sum3wio;
312 Float_t sum3wj = 0; //charge minus overlap
313 Float_t sum3wjo = 0; //full charge
314 Float_t sum3jw = 0; //sum for mean value
315 for (Int_t dk=-1;dk<=1;dk++){
316 sum3wjo+=sum3j[dk+3];
322 if ( ( ((sum3j[dk+3]+3)/(sum3j[3]-3))+1 < (sum3j[2*dk+3]-3)/(sum3j[dk+3]+3)) ||
323 (sum3j[dk+3]<=sum3j[2*dk+3] && sum3j[dk+3]>2)){
324 Float_t xm2 = sum3j[-dk+3];
325 Float_t xm1 = sum3j[+3];
326 Float_t x1 = sum3j[2*dk+3];
327 Float_t x2 = sum3j[3*dk+3];
328 Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001);
329 Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.);
330 ratio = w11/(w11+w12);
331 for (Int_t dl=-1;dl<=1;dl++)
332 mratio[dl+1][dk+1] *= ratio;
334 Float_t amp = sum3j[dk+3]*ratio;
339 meanj = sum3jw/sum3wj;
340 Float_t overlapj = (sum3wjo-sum3wj)/sum3wjo;
341 overlap = Int_t(100*TMath::Max(overlapi,overlapj)+3);
342 sumu = (sum3wj+sum3wi)/2.;
345 //if not overlap detected remove everything
346 for (Int_t di =-2; di<=2;di++)
347 for (Int_t dj =-2; dj<=2;dj++){
348 recmatrix[di+2][dj+2] = matrix2[3+di][dj];
352 for (Int_t di =-1; di<=1;di++)
353 for (Int_t dj =-1; dj<=1;dj++){
355 if (mratio[di+1][dj+1]==1){
356 recmatrix[di+2][dj+2] = matrix2[3+di][dj];
357 if (TMath::Abs(di)+TMath::Abs(dj)>1){
358 recmatrix[2*di+2][dj+2] = matrix2[3+2*di][dj];
359 recmatrix[di+2][2*dj+2] = matrix2[3+di][2*dj];
361 recmatrix[2*di+2][2*dj+2] = matrix2[3+2*di][2*dj];
365 //if we have overlap in direction
366 recmatrix[di+2][dj+2] = mratio[di+1][dj+1]* matrix2[3+di][dj];
367 if (TMath::Abs(di)+TMath::Abs(dj)>1){
368 ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+0*di][1*dj]+1)),(Float_t)1.);
369 recmatrix[2*di+2][dj+2] = ratio*recmatrix[di+2][dj+2];
371 ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+1*di][0*dj]+1)),(Float_t)1.);
372 recmatrix[di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2];
375 ratio = recmatrix[di+2][dj+2]/matrix2[3][0];
376 recmatrix[2*di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2];
382 printf("%f\n", recmatrix[2][2]);
386 Float_t AliTPCclustererMI::FitMax(Float_t vmatrix[5][5], Float_t y, Float_t z, Float_t sigmay, Float_t sigmaz)
393 for (Int_t di = -1;di<=1;di++)
394 for (Int_t dj = -1;dj<=1;dj++){
395 if (vmatrix[2+di][2+dj]>2){
396 Float_t teor = TMath::Gaus(di,y,sigmay*1.2)*TMath::Gaus(dj,z,sigmaz*1.2);
397 sumteor += teor*vmatrix[2+di][2+dj];
398 sumamp += vmatrix[2+di][2+dj]*vmatrix[2+di][2+dj];
401 Float_t max = sumamp/sumteor;
405 void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c){
407 // transform cluster to the global coordinata
408 // add the cluster to the array
410 Float_t meani = c.GetY()/fPadWidth;
411 Float_t meanj = c.GetZ()/fZWidth;
413 Int_t ki = TMath::Nint(meani-3);
415 if (ki>=fMaxPad) ki = fMaxPad-1;
416 Int_t kj = TMath::Nint(meanj-3);
418 if (kj>=fMaxTime-3) kj=fMaxTime-4;
419 // ki and kj shifted to "real" coordinata
421 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,0)-2,0);
422 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,1)-2,1);
423 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,2)-2,2);
427 Float_t s2 = c.GetSigmaY2();
428 Float_t w=fParam->GetPadPitchWidth(fSector);
430 c.SetSigmaY2(s2*w*w);
433 c.SetSigmaZ2(s2*w*w);
434 c.SetY((meani - 2.5 - 0.5*fMaxPad)*fParam->GetPadPitchWidth(fSector));
435 c.SetZ(fZWidth*(meanj-3));
436 c.SetZ(c.GetZ() - 3.*fParam->GetZSigma() + fParam->GetNTBinsL1()*fParam->GetZWidth()); // PASA delay + L1 delay
437 c.SetZ(fSign*(fParam->GetZLength() - c.GetZ()));
439 c.SetDetector(fSector);
442 if (ki<=1 || ki>=fMaxPad-1 || kj==1 || kj==fMaxTime-2) {
443 //c.SetSigmaY2(c.GetSigmaY2()*25.);
444 //c.SetSigmaZ2(c.GetSigmaZ2()*4.);
445 c.SetType(-(c.GetType()+3)); //edge clusters
447 if (fLoop==2) c.SetType(100);
449 TClonesArray * arr = fRowCl->GetArray();
450 // AliTPCclusterMI * cl =
451 new ((*arr)[fNcluster]) AliTPCclusterMI(c);
457 //_____________________________________________________________________________
458 void AliTPCclustererMI::Digits2Clusters()
460 //-----------------------------------------------------------------
461 // This is a simple cluster finder.
462 //-----------------------------------------------------------------
465 Error("Digits2Clusters", "input tree not initialised");
470 Error("Digits2Clusters", "output tree not initialised");
474 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
476 AliSimDigits digarr, *dummy=&digarr;
478 fInput->GetBranch("Segment")->SetAddress(&dummy);
479 Stat_t nentries = fInput->GetEntries();
481 fMaxTime=fParam->GetMaxTBin()+6; // add 3 virtual time bins before and 3 after
485 for (Int_t n=0; n<nentries; n++) {
487 if (!fParam->AdjustSectorRow(digarr.GetID(),fSector,fRow)) {
488 cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl;
492 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
495 AliTPCClustersRow *clrow= new AliTPCClustersRow();
497 clrow->SetClass("AliTPCclusterMI");
500 clrow->SetID(digarr.GetID());
501 fOutput->GetBranch("Segment")->SetAddress(&clrow);
502 fRx=fParam->GetPadRowRadii(fSector,row);
505 const Int_t kNIS=fParam->GetNInnerSector(), kNOS=fParam->GetNOuterSector();
506 fZWidth = fParam->GetZWidth();
507 if (fSector < kNIS) {
508 fMaxPad = fParam->GetNPadsLow(row);
509 fSign = (fSector < kNIS/2) ? 1 : -1;
510 fPadLength = fParam->GetPadPitchLength(fSector,row);
511 fPadWidth = fParam->GetPadPitchWidth();
513 fMaxPad = fParam->GetNPadsUp(row);
514 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
515 fPadLength = fParam->GetPadPitchLength(fSector,row);
516 fPadWidth = fParam->GetPadPitchWidth();
520 fMaxBin=fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
521 fBins =new Float_t[fMaxBin];
522 fResBins =new Float_t[fMaxBin]; //fBins with residuals after 1 finder loop
523 memset(fBins,0,sizeof(Float_t)*fMaxBin);
524 memset(fResBins,0,sizeof(Float_t)*fMaxBin);
526 if (digarr.First()) //MI change
528 Float_t dig=digarr.CurrentDigit();
529 if (dig<=fParam->GetZeroSup()) continue;
530 Int_t j=digarr.CurrentRow()+3, i=digarr.CurrentColumn()+3;
531 Float_t gain = gainROC->GetValue(row,digarr.CurrentColumn());
532 fBins[i*fMaxTime+j]=dig/gain;
533 } while (digarr.Next());
534 digarr.ExpandTrackBuffer();
540 nclusters+=fNcluster;
545 Info("Digits2Clusters", "Number of found clusters : %d", nclusters);
548 void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
550 //-----------------------------------------------------------------
551 // This is a cluster finder for the TPC raw data.
552 // The method assumes NO ordering of the altro channels.
553 // The pedestal subtraction can be switched on and off
554 // using an option of the TPC reconstructor
555 //-----------------------------------------------------------------
558 Error("Digits2Clusters", "output tree not initialised");
564 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
568 fMaxTime = fParam->GetMaxTBin() + 6; // add 3 virtual time bins before and 3 after
569 const Int_t kNIS = fParam->GetNInnerSector();
570 const Int_t kNOS = fParam->GetNOuterSector();
571 const Int_t kNS = kNIS + kNOS;
572 fZWidth = fParam->GetZWidth();
573 Int_t zeroSup = fParam->GetZeroSup();
575 Float_t** allBins = NULL;
576 Float_t** allBinsRes = NULL;
579 for(fSector = 0; fSector < kNS; fSector++) {
581 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
584 Int_t nDDLs = 0, indexDDL = 0;
585 if (fSector < kNIS) {
586 nRows = fParam->GetNRowLow();
587 fSign = (fSector < kNIS/2) ? 1 : -1;
589 indexDDL = fSector * 2;
592 nRows = fParam->GetNRowUp();
593 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
595 indexDDL = (fSector-kNIS) * 4 + kNIS * 2;
598 allBins = new Float_t*[nRows];
599 allBinsRes = new Float_t*[nRows];
601 for (Int_t iRow = 0; iRow < nRows; iRow++) {
604 maxPad = fParam->GetNPadsLow(iRow);
606 maxPad = fParam->GetNPadsUp(iRow);
608 Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after
609 allBins[iRow] = new Float_t[maxBin];
610 allBinsRes[iRow] = new Float_t[maxBin];
611 memset(allBins[iRow],0,sizeof(Float_t)*maxBin);
612 memset(allBinsRes[iRow],0,sizeof(Float_t)*maxBin);
615 // Loas the raw data for corresponding DDLs
617 AliTPCRawStream input(rawReader);
618 input.SetOldRCUFormat(fIsOldRCUFormat);
619 rawReader->Select(0,indexDDL,indexDDL+nDDLs-1);
621 // Begin loop over altro data
622 while (input.Next()) {
624 if (input.GetSector() != fSector)
625 AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",fSector,input.GetSector()));
627 if (input.GetTime() < 40) continue;
629 Int_t iRow = input.GetRow();
630 if (iRow < 0 || iRow >= nRows)
631 AliFatal(Form("Pad-row index (%d) outside the range (%d -> %d) !",
634 Int_t iPad = input.GetPad() + 3;
638 maxPad = fParam->GetNPadsLow(iRow);
640 maxPad = fParam->GetNPadsUp(iRow);
642 if (input.GetPad() < 0 || input.GetPad() >= maxPad)
643 AliFatal(Form("Pad index (%d) outside the range (%d -> %d) !",
644 input.GetPad(), 0, maxPad -1));
646 Int_t iTimeBin = input.GetTime() + 3;
647 if ( input.GetTime() < 0 || input.GetTime() >= fParam->GetMaxTBin())
648 AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !",
649 input.GetTime(), 0, fParam->GetMaxTBin() -1));
651 Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after
653 if (((iPad*fMaxTime+iTimeBin) >= maxBin) ||
654 ((iPad*fMaxTime+iTimeBin) < 0))
655 AliFatal(Form("Index outside the allowed range"
656 " Sector=%d Row=%d Pad=%d Timebin=%d"
657 " (Max.index=%d)",fSector,iRow,iPad,iTimeBin,maxBin));
659 Float_t signal = input.GetSignal();
660 if (!fPedSubtraction && signal <= zeroSup) continue;
662 Float_t gain = gainROC->GetValue(iRow,input.GetPad());
663 allBins[iRow][iPad*fMaxTime+iTimeBin] = signal/gain;
665 } // End of the loop over altro data
667 // Now loop over rows and perform pedestal subtraction
668 if (fPedSubtraction) {
669 for (Int_t iRow = 0; iRow < nRows; iRow++) {
672 maxPad = fParam->GetNPadsLow(iRow);
674 maxPad = fParam->GetNPadsUp(iRow);
676 for (Int_t iPad = 0; iPad < maxPad + 6; iPad++) {
677 Float_t *p = &allBins[iRow][iPad*fMaxTime+3];
678 Float_t pedestal = TMath::Median(fMaxTime, p);
679 for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) {
680 allBins[iRow][iPad*fMaxTime+iTimeBin] -= pedestal;
681 if (allBins[iRow][iPad*fMaxTime+iTimeBin] < zeroSup)
682 allBins[iRow][iPad*fMaxTime+iTimeBin] = 0;
688 // Now loop over rows and find clusters
689 for (fRow = 0; fRow < nRows; fRow++) {
690 fRowCl = new AliTPCClustersRow;
691 fRowCl->SetClass("AliTPCclusterMI");
693 fRowCl->SetID(fParam->GetIndex(fSector, fRow));
694 fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
696 fRx = fParam->GetPadRowRadii(fSector, fRow);
697 fPadLength = fParam->GetPadPitchLength(fSector, fRow);
698 fPadWidth = fParam->GetPadPitchWidth();
700 fMaxPad = fParam->GetNPadsLow(fRow);
702 fMaxPad = fParam->GetNPadsUp(fRow);
703 fMaxBin = fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
705 fBins = allBins[fRow];
706 fResBins = allBinsRes[fRow];
712 nclusters += fNcluster;
713 } // End of loop to find clusters
716 for (Int_t iRow = 0; iRow < nRows; iRow++) {
717 delete [] allBins[iRow];
718 delete [] allBinsRes[iRow];
722 delete [] allBinsRes;
724 } // End of loop over sectors
726 Info("Digits2Clusters", "Number of found clusters : %d\n", nclusters);
730 void AliTPCclustererMI::FindClusters()
732 //add virtual charge at the edge
733 for (Int_t i=0; i<fMaxTime; i++){
734 Float_t amp1 = fBins[i+3*fMaxTime];
737 Float_t amp2 = fBins[i+4*fMaxTime];
738 if (amp2==0) amp2=0.5;
739 Float_t sigma2 = GetSigmaY2(i);
740 amp0 = (amp1*amp1/amp2)*TMath::Exp(-1./sigma2);
741 if (gDebug>4) printf("\n%f\n",amp0);
743 fBins[i+2*fMaxTime] = amp0;
745 amp1 = fBins[(fMaxPad+2)*fMaxTime+i];
747 Float_t amp2 = fBins[i+(fMaxPad+1)*fMaxTime];
748 if (amp2==0) amp2=0.5;
749 Float_t sigma2 = GetSigmaY2(i);
750 amp0 = (amp1*amp1/amp2)*TMath::Exp(-1./sigma2);
751 if (gDebug>4) printf("\n%f\n",amp0);
753 fBins[(fMaxPad+3)*fMaxTime+i] = amp0;
756 // memcpy(fResBins,fBins, fMaxBin*2);
757 memcpy(fResBins,fBins, fMaxBin);
760 //first loop - for "gold cluster"
762 Float_t *b=&fBins[-1]+2*fMaxTime;
763 Int_t crtime = Int_t((fParam->GetZLength()-AliTPCReconstructor::GetCtgRange()*fRx)/fZWidth-fParam->GetNTBinsL1()-5);
765 for (Int_t i=2*fMaxTime; i<fMaxBin-2*fMaxTime; i++) {
767 if (*b<8) continue; //threshold form maxima
768 if (i%fMaxTime<crtime) {
769 Int_t delta = -(i%fMaxTime)+crtime;
775 if (!IsMaximum(*b,fMaxTime,b)) continue;
778 MakeCluster(i, fMaxTime, fBins, dummy,c);
781 //memcpy(fBins,fResBins, fMaxBin*2);
782 //second loop - for rest cluster
785 b=&fResBins[-1]+2*fMaxTime;
786 for (Int_t i=2*fMaxTime; i<fMaxBin-2*fMaxTime; i++) {
788 if (*b<25) continue; // bigger threshold for maxima
789 if (!IsMaximum(*b,fMaxTime,b)) continue;
792 MakeCluster(i, fMaxTime, fResBins, dummy,c);