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 "Riostream.h"
29 #include <TObjArray.h>
32 #include <TTreeStream.h>
33 #include <TVirtualFFT.h>
35 #include "AliDigits.h"
36 #include "AliLoader.h"
38 #include "AliMathBase.h"
39 #include "AliRawEventHeaderBase.h"
40 #include "AliRawReader.h"
41 #include "AliRunLoader.h"
42 #include "AliSimDigits.h"
43 #include "AliTPCCalPad.h"
44 #include "AliTPCCalROC.h"
45 #include "AliTPCClustersArray.h"
46 #include "AliTPCClustersRow.h"
47 #include "AliTPCParam.h"
48 #include "AliTPCRawStream.h"
49 #include "AliTPCRecoParam.h"
50 #include "AliTPCReconstructor.h"
51 #include "AliTPCcalibDB.h"
52 #include "AliTPCclusterInfo.h"
53 #include "AliTPCclusterMI.h"
54 #include "AliTPCTransform.h"
55 #include "AliTPCclustererMI.h"
57 ClassImp(AliTPCclustererMI)
61 AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoParam * recoParam):
76 fPedSubtraction(kFALSE),
77 fIsOldRCUFormat(kFALSE),
95 // param - tpc parameters for given file
96 // recoparam - reconstruction parameters
98 fIsOldRCUFormat = kFALSE;
103 fRecoParam = recoParam;
105 //set default parameters if not specified
106 fRecoParam = AliTPCReconstructor::GetRecoParam();
107 if (!fRecoParam) fRecoParam = AliTPCRecoParam::GetLowFluxParam();
109 fDebugStreamer = new TTreeSRedirector("TPCsignal.root");
111 Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin();
112 fFFTr2c = TVirtualFFT::FFT(1, &nPoints, "R2C K");
114 //______________________________________________________________
115 AliTPCclustererMI::AliTPCclustererMI(const AliTPCclustererMI ¶m)
131 fPedSubtraction(kFALSE),
132 fIsOldRCUFormat(kFALSE),
145 fBDumpSignal(kFALSE),
151 fMaxBin = param.fMaxBin;
153 //______________________________________________________________
154 AliTPCclustererMI & AliTPCclustererMI::operator =(const AliTPCclustererMI & param)
157 // assignment operator - dummy
159 fMaxBin=param.fMaxBin;
162 //______________________________________________________________
163 AliTPCclustererMI::~AliTPCclustererMI(){
165 if (fAmplitudeHisto) delete fAmplitudeHisto;
166 if (fDebugStreamer) delete fDebugStreamer;
169 void AliTPCclustererMI::SetInput(TTree * tree)
172 // set input tree with digits
175 if (!fInput->GetBranch("Segment")){
176 cerr<<"AliTPC::Digits2Clusters(): no porper input tree !\n";
182 void AliTPCclustererMI::SetOutput(TTree * tree)
187 AliTPCClustersRow clrow;
188 AliTPCClustersRow *pclrow=&clrow;
189 clrow.SetClass("AliTPCclusterMI");
190 clrow.SetArray(1); // to make Clones array
191 fOutput->Branch("Segment","AliTPCClustersRow",&pclrow,32000,200);
195 Float_t AliTPCclustererMI::GetSigmaY2(Int_t iz){
196 // sigma y2 = in digits - we don't know the angle
197 Float_t z = iz*fParam->GetZWidth()+fParam->GetNTBinsL1()*fParam->GetZWidth();
198 Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/
199 (fPadWidth*fPadWidth);
201 Float_t res = sd2+sres;
206 Float_t AliTPCclustererMI::GetSigmaZ2(Int_t iz){
207 //sigma z2 = in digits - angle estimated supposing vertex constraint
208 Float_t z = iz*fZWidth+fParam->GetNTBinsL1()*fParam->GetZWidth();
209 Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/(fZWidth*fZWidth);
210 Float_t angular = fPadLength*(fParam->GetZLength(fSector)-z)/(fRx*fZWidth);
213 Float_t sres = fParam->GetZSigma()/fZWidth;
215 Float_t res = angular +sd2+sres;
219 void AliTPCclustererMI::MakeCluster(Int_t k,Int_t max,Float_t *bins, UInt_t /*m*/,
223 // k - Make cluster at position k
224 // bins - 2 D array of signals mapped to 1 dimensional array -
225 // max - the number of time bins er one dimension
226 // c - refernce to cluster to be filled
228 Int_t i0=k/max; //central pad
229 Int_t j0=k%max; //central time bin
231 // set pointers to data
232 //Int_t dummy[5] ={0,0,0,0,0};
233 Float_t * matrix[5]; //5x5 matrix with digits - indexing i = 0 ..4 j = -2..2
234 for (Int_t di=-2;di<=2;di++){
235 matrix[di+2] = &bins[k+di*max];
237 //build matrix with virtual charge
238 Float_t sigmay2= GetSigmaY2(j0);
239 Float_t sigmaz2= GetSigmaZ2(j0);
241 Float_t vmatrix[5][5];
242 vmatrix[2][2] = matrix[2][0];
244 c.SetMax((UShort_t)(vmatrix[2][2])); // write maximal amplitude
245 for (Int_t di =-1;di <=1;di++)
246 for (Int_t dj =-1;dj <=1;dj++){
247 Float_t amp = matrix[di+2][dj];
248 if ( (amp<2) && (fLoop<2)){
249 // if under threshold - calculate virtual charge
250 Float_t ratio = TMath::Exp(-1.2*TMath::Abs(di)/sigmay2)*TMath::Exp(-1.2*TMath::Abs(dj)/sigmaz2);
251 amp = ((matrix[2][0]-2)*(matrix[2][0]-2)/(matrix[-di+2][-dj]+2))*ratio;
253 vmatrix[2+di][2+dj]=amp;
254 vmatrix[2+2*di][2+2*dj]=0;
257 vmatrix[2+2*di][2+dj] =0;
258 vmatrix[2+di][2+2*dj] =0;
263 //if small amplitude - below 2 x threshold - don't consider other one
264 vmatrix[2+di][2+dj]=amp;
265 vmatrix[2+2*di][2+2*dj]=0; // don't take to the account next bin
268 vmatrix[2+2*di][2+dj] =0;
269 vmatrix[2+di][2+2*dj] =0;
273 //if bigger then take everything
274 vmatrix[2+di][2+dj]=amp;
275 vmatrix[2+2*di][2+2*dj]= matrix[2*di+2][2*dj] ;
278 vmatrix[2+2*di][2+dj] = matrix[2*di+2][dj];
279 vmatrix[2+di][2+2*dj] = matrix[2+di][dj*2];
291 for (Int_t i=-2;i<=2;i++)
292 for (Int_t j=-2;j<=2;j++){
293 Float_t amp = vmatrix[i+2][j+2];
302 Float_t meani = sumiw/sumw;
303 Float_t mi2 = sumi2w/sumw-meani*meani;
304 Float_t meanj = sumjw/sumw;
305 Float_t mj2 = sumj2w/sumw-meanj*meanj;
307 Float_t ry = mi2/sigmay2;
308 Float_t rz = mj2/sigmaz2;
311 if ( ( (ry<0.6) || (rz<0.6) ) && fLoop==2) return;
312 if ( (ry <1.2) && (rz<1.2) || (!fRecoParam->GetDoUnfold())) {
314 //if cluster looks like expected or Unfolding not switched on
315 //standard COG is used
316 //+1.2 deviation from expected sigma accepted
317 // c.fMax = FitMax(vmatrix,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2));
321 //set cluster parameters
324 c.SetTimeBin(meanj-3);
328 AddCluster(c,(Float_t*)vmatrix,k);
332 //unfolding when neccessary
335 Float_t * matrix2[7]; //7x7 matrix with digits - indexing i = 0 ..6 j = -3..3
336 Float_t dummy[7]={0,0,0,0,0,0};
337 for (Int_t di=-3;di<=3;di++){
338 matrix2[di+3] = &bins[k+di*max];
339 if ((k+di*max)<3) matrix2[di+3] = &dummy[3];
340 if ((k+di*max)>fMaxBin-3) matrix2[di+3] = &dummy[3];
342 Float_t vmatrix2[5][5];
345 UnfoldCluster(matrix2,vmatrix2,meani,meanj,sumu,overlap);
347 // c.fMax = FitMax(vmatrix2,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2));
350 //set cluster parameters
353 c.SetTimeBin(meanj-3);
356 c.SetType(Char_t(overlap)+1);
357 AddCluster(c,(Float_t*)vmatrix,k);
363 printf("%f\t%f\n", vmatrix2[2][2], vmatrix[2][2]);
368 void AliTPCclustererMI::UnfoldCluster(Float_t * matrix2[7], Float_t recmatrix[5][5], Float_t & meani, Float_t & meanj,
369 Float_t & sumu, Float_t & overlap )
372 //unfold cluster from input matrix
373 //data corresponding to cluster writen in recmatrix
374 //output meani and meanj
376 //take separatelly y and z
378 Float_t sum3i[7] = {0,0,0,0,0,0,0};
379 Float_t sum3j[7] = {0,0,0,0,0,0,0};
381 for (Int_t k =0;k<7;k++)
382 for (Int_t l = -1; l<=1;l++){
383 sum3i[k]+=matrix2[k][l];
384 sum3j[k]+=matrix2[l+3][k-3];
386 Float_t mratio[3][3]={{1,1,1},{1,1,1},{1,1,1}};
389 Float_t sum3wi = 0; //charge minus overlap
390 Float_t sum3wio = 0; //full charge
391 Float_t sum3iw = 0; //sum for mean value
392 for (Int_t dk=-1;dk<=1;dk++){
393 sum3wio+=sum3i[dk+3];
399 if ( ( ((sum3i[dk+3]+3)/(sum3i[3]-3))+1 < (sum3i[2*dk+3]-3)/(sum3i[dk+3]+3))||
400 sum3i[dk+3]<=sum3i[2*dk+3] && sum3i[dk+3]>2 ){
401 Float_t xm2 = sum3i[-dk+3];
402 Float_t xm1 = sum3i[+3];
403 Float_t x1 = sum3i[2*dk+3];
404 Float_t x2 = sum3i[3*dk+3];
405 Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001);
406 Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.);
407 ratio = w11/(w11+w12);
408 for (Int_t dl=-1;dl<=1;dl++)
409 mratio[dk+1][dl+1] *= ratio;
411 Float_t amp = sum3i[dk+3]*ratio;
416 meani = sum3iw/sum3wi;
417 Float_t overlapi = (sum3wio-sum3wi)/sum3wio;
422 Float_t sum3wj = 0; //charge minus overlap
423 Float_t sum3wjo = 0; //full charge
424 Float_t sum3jw = 0; //sum for mean value
425 for (Int_t dk=-1;dk<=1;dk++){
426 sum3wjo+=sum3j[dk+3];
432 if ( ( ((sum3j[dk+3]+3)/(sum3j[3]-3))+1 < (sum3j[2*dk+3]-3)/(sum3j[dk+3]+3)) ||
433 (sum3j[dk+3]<=sum3j[2*dk+3] && sum3j[dk+3]>2)){
434 Float_t xm2 = sum3j[-dk+3];
435 Float_t xm1 = sum3j[+3];
436 Float_t x1 = sum3j[2*dk+3];
437 Float_t x2 = sum3j[3*dk+3];
438 Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001);
439 Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.);
440 ratio = w11/(w11+w12);
441 for (Int_t dl=-1;dl<=1;dl++)
442 mratio[dl+1][dk+1] *= ratio;
444 Float_t amp = sum3j[dk+3]*ratio;
449 meanj = sum3jw/sum3wj;
450 Float_t overlapj = (sum3wjo-sum3wj)/sum3wjo;
451 overlap = Int_t(100*TMath::Max(overlapi,overlapj)+3);
452 sumu = (sum3wj+sum3wi)/2.;
455 //if not overlap detected remove everything
456 for (Int_t di =-2; di<=2;di++)
457 for (Int_t dj =-2; dj<=2;dj++){
458 recmatrix[di+2][dj+2] = matrix2[3+di][dj];
462 for (Int_t di =-1; di<=1;di++)
463 for (Int_t dj =-1; dj<=1;dj++){
465 if (mratio[di+1][dj+1]==1){
466 recmatrix[di+2][dj+2] = matrix2[3+di][dj];
467 if (TMath::Abs(di)+TMath::Abs(dj)>1){
468 recmatrix[2*di+2][dj+2] = matrix2[3+2*di][dj];
469 recmatrix[di+2][2*dj+2] = matrix2[3+di][2*dj];
471 recmatrix[2*di+2][2*dj+2] = matrix2[3+2*di][2*dj];
475 //if we have overlap in direction
476 recmatrix[di+2][dj+2] = mratio[di+1][dj+1]* matrix2[3+di][dj];
477 if (TMath::Abs(di)+TMath::Abs(dj)>1){
478 ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+0*di][1*dj]+1)),(Float_t)1.);
479 recmatrix[2*di+2][dj+2] = ratio*recmatrix[di+2][dj+2];
481 ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+1*di][0*dj]+1)),(Float_t)1.);
482 recmatrix[di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2];
485 ratio = recmatrix[di+2][dj+2]/matrix2[3][0];
486 recmatrix[2*di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2];
492 printf("%f\n", recmatrix[2][2]);
496 Float_t AliTPCclustererMI::FitMax(Float_t vmatrix[5][5], Float_t y, Float_t z, Float_t sigmay, Float_t sigmaz)
503 for (Int_t di = -1;di<=1;di++)
504 for (Int_t dj = -1;dj<=1;dj++){
505 if (vmatrix[2+di][2+dj]>2){
506 Float_t teor = TMath::Gaus(di,y,sigmay*1.2)*TMath::Gaus(dj,z,sigmaz*1.2);
507 sumteor += teor*vmatrix[2+di][2+dj];
508 sumamp += vmatrix[2+di][2+dj]*vmatrix[2+di][2+dj];
511 Float_t max = sumamp/sumteor;
515 void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c, Float_t * matrix, Int_t pos){
518 // Transform cluster to the rotated global coordinata
519 // Assign labels to the cluster
520 // add the cluster to the array
521 // for more details - See AliTPCTranform::Transform(x,i,0,1)
522 Float_t meani = c.GetPad();
523 Float_t meanj = c.GetTimeBin();
525 Int_t ki = TMath::Nint(meani);
527 if (ki>=fMaxPad) ki = fMaxPad-1;
528 Int_t kj = TMath::Nint(meanj);
530 if (kj>=fMaxTime-3) kj=fMaxTime-4;
531 // ki and kj shifted as integers coordinata
533 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,0)-2,0);
534 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,1)-2,1);
535 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,2)-2,2);
539 c.SetDetector(fSector);
540 Float_t s2 = c.GetSigmaY2();
541 Float_t w=fParam->GetPadPitchWidth(fSector);
542 c.SetSigmaY2(s2*w*w);
544 c.SetSigmaZ2(s2*fZWidth*fZWidth);
548 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
550 AliFatal("Tranformations not in calibDB");
552 Double_t x[3]={c.GetRow(),c.GetPad(),c.GetTimeBin()};
553 Int_t i[1]={fSector};
554 transform->Transform(x,i,0,1);
560 if (!fRecoParam->GetBYMirror()){
566 if (ki<=1 || ki>=fMaxPad-1 || kj==1 || kj==fMaxTime-2) {
567 c.SetType(-(c.GetType()+3)); //edge clusters
569 if (fLoop==2) c.SetType(100);
571 TClonesArray * arr = fRowCl->GetArray();
572 AliTPCclusterMI * cl = new ((*arr)[fNcluster]) AliTPCclusterMI(c);
573 if (fRecoParam->DumpSignal() &&matrix ) {
576 if (fRecoParam->GetCalcPedestal() && cl->GetMax()>fRecoParam->GetDumpAmplitudeMin() &&fBDumpSignal){
578 graph = &(fBins[fMaxTime*(pos/fMaxTime)]);
580 AliTPCclusterInfo * info = new AliTPCclusterInfo(matrix,nbins,graph);
583 if (!fRecoParam->DumpSignal()) {
591 //_____________________________________________________________________________
592 void AliTPCclustererMI::Digits2Clusters()
594 //-----------------------------------------------------------------
595 // This is a simple cluster finder.
596 //-----------------------------------------------------------------
599 Error("Digits2Clusters", "input tree not initialised");
604 Error("Digits2Clusters", "output tree not initialised");
608 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
609 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
610 AliSimDigits digarr, *dummy=&digarr;
612 fInput->GetBranch("Segment")->SetAddress(&dummy);
613 Stat_t nentries = fInput->GetEntries();
615 fMaxTime=fRecoParam->GetLastBin()+6; // add 3 virtual time bins before and 3 after
619 for (Int_t n=0; n<nentries; n++) {
621 if (!fParam->AdjustSectorRow(digarr.GetID(),fSector,fRow)) {
622 cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl;
626 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
627 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(fSector); // noise per given sector
629 AliTPCClustersRow *clrow= new AliTPCClustersRow();
631 clrow->SetClass("AliTPCclusterMI");
634 clrow->SetID(digarr.GetID());
635 fOutput->GetBranch("Segment")->SetAddress(&clrow);
636 fRx=fParam->GetPadRowRadii(fSector,row);
639 const Int_t kNIS=fParam->GetNInnerSector(), kNOS=fParam->GetNOuterSector();
640 fZWidth = fParam->GetZWidth();
641 if (fSector < kNIS) {
642 fMaxPad = fParam->GetNPadsLow(row);
643 fSign = (fSector < kNIS/2) ? 1 : -1;
644 fPadLength = fParam->GetPadPitchLength(fSector,row);
645 fPadWidth = fParam->GetPadPitchWidth();
647 fMaxPad = fParam->GetNPadsUp(row);
648 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
649 fPadLength = fParam->GetPadPitchLength(fSector,row);
650 fPadWidth = fParam->GetPadPitchWidth();
654 fMaxBin=fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
655 fBins =new Float_t[fMaxBin];
656 fSigBins =new Int_t[fMaxBin];
658 memset(fBins,0,sizeof(Float_t)*fMaxBin);
660 if (digarr.First()) //MI change
662 Float_t dig=digarr.CurrentDigit();
663 if (dig<=fParam->GetZeroSup()) continue;
664 Int_t j=digarr.CurrentRow()+3, i=digarr.CurrentColumn()+3;
665 Float_t gain = gainROC->GetValue(row,digarr.CurrentColumn());
666 Int_t bin = i*fMaxTime+j;
668 fSigBins[fNSigBins++]=bin;
669 } while (digarr.Next());
670 digarr.ExpandTrackBuffer();
672 FindClusters(noiseROC);
676 nclusters+=fNcluster;
681 Info("Digits2Clusters", "Number of found clusters : %d", nclusters);
684 void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
686 //-----------------------------------------------------------------
687 // This is a cluster finder for the TPC raw data.
688 // The method assumes NO ordering of the altro channels.
689 // The pedestal subtraction can be switched on and off
690 // using an option of the TPC reconstructor
691 //-----------------------------------------------------------------
694 Error("Digits2Clusters", "output tree not initialised");
699 AliTPCROC * roc = AliTPCROC::Instance();
700 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
701 AliTPCCalPad * pedestalTPC = AliTPCcalibDB::Instance()->GetPedestals();
702 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
703 AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
705 AliTPCRawStream input(rawReader,(AliAltroMapping**)mapping);
706 fEventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
708 fTimeStamp = fEventHeader->Get("Timestamp");
709 fEventType = fEventHeader->Get("Type");
715 fMaxTime = fRecoParam->GetLastBin() + 6; // add 3 virtual time bins before and 3 after
716 const Int_t kNIS = fParam->GetNInnerSector();
717 const Int_t kNOS = fParam->GetNOuterSector();
718 const Int_t kNS = kNIS + kNOS;
719 fZWidth = fParam->GetZWidth();
720 Int_t zeroSup = fParam->GetZeroSup();
722 //alocate memory for sector - maximal case
724 Float_t** allBins = NULL;
725 Int_t** allSigBins = NULL;
726 Int_t* allNSigBins = NULL;
727 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
728 Int_t nPadsMax = roc->GetNPads(roc->GetNSector()-1,nRowsMax-1);
729 allBins = new Float_t*[nRowsMax];
730 allSigBins = new Int_t*[nRowsMax];
731 allNSigBins = new Int_t[nRowsMax];
732 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
734 Int_t maxBin = fMaxTime*(nPadsMax+6); // add 3 virtual pads before and 3 after
735 allBins[iRow] = new Float_t[maxBin];
736 memset(allBins[iRow],0,sizeof(Float_t)*maxBin);
737 allSigBins[iRow] = new Int_t[maxBin];
743 for(fSector = 0; fSector < kNS; fSector++) {
745 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
746 AliTPCCalROC * pedestalROC = pedestalTPC->GetCalROC(fSector); // pedestal per given sector
747 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(fSector); // noise per given sector
750 Int_t nDDLs = 0, indexDDL = 0;
751 if (fSector < kNIS) {
752 nRows = fParam->GetNRowLow();
753 fSign = (fSector < kNIS/2) ? 1 : -1;
755 indexDDL = fSector * 2;
758 nRows = fParam->GetNRowUp();
759 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
761 indexDDL = (fSector-kNIS) * 4 + kNIS * 2;
764 for (Int_t iRow = 0; iRow < nRows; iRow++) {
767 maxPad = fParam->GetNPadsLow(iRow);
769 maxPad = fParam->GetNPadsUp(iRow);
771 Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after
772 memset(allBins[iRow],0,sizeof(Float_t)*maxBin);
773 allNSigBins[iRow] = 0;
776 // Loas the raw data for corresponding DDLs
778 input.SetOldRCUFormat(fIsOldRCUFormat);
779 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
781 // Begin loop over altro data
782 Bool_t calcPedestal = fRecoParam->GetCalcPedestal();
785 while (input.Next()) {
786 if (input.GetSector() != fSector)
787 AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",fSector,input.GetSector()));
790 Int_t iRow = input.GetRow();
791 if (iRow < 0 || iRow >= nRows){
792 AliError(Form("Pad-row index (%d) outside the range (%d -> %d) !",
797 Int_t iPad = input.GetPad();
798 if (iPad < 0 || iPad >= nPadsMax) {
799 AliError(Form("Pad index (%d) outside the range (%d -> %d) !",
800 iPad, 0, nPadsMax-1));
804 gain = gainROC->GetValue(iRow,iPad);
809 Int_t iTimeBin = input.GetTime();
810 if ( iTimeBin < fRecoParam->GetFirstBin() || iTimeBin >= fRecoParam->GetLastBin()){
812 AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !",
813 iTimeBin, 0, iTimeBin -1));
818 Float_t signal = input.GetSignal();
819 if (!calcPedestal && signal <= zeroSup) continue;
821 Int_t bin = iPad*fMaxTime+iTimeBin;
822 allBins[iRow][bin] = signal/gain;
823 allSigBins[iRow][allNSigBins[iRow]++] = bin;
825 allBins[iRow][iPad*fMaxTime+iTimeBin] = signal;
827 allBins[iRow][iPad*fMaxTime+0]+=1.; // pad with signal
831 } // End of the loop over altro data
836 // Now loop over rows and perform pedestal subtraction
837 if (digCounter==0) continue;
838 // if (calcPedestal) {
840 for (Int_t iRow = 0; iRow < nRows; iRow++) {
843 maxPad = fParam->GetNPadsLow(iRow);
845 maxPad = fParam->GetNPadsUp(iRow);
847 for (Int_t iPad = 3; iPad < maxPad + 3; iPad++) {
849 // Temporary fix for data production - !!!! MARIAN
850 // The noise calibration should take mean and RMS - currently the Gaussian fit used
851 // In case of double peak - the pad should be rejected
853 // Line mean - if more than given digits over threshold - make a noise calculation
854 // and pedestal substration
855 if (!calcPedestal && allBins[iRow][iPad*fMaxTime+0]<50) continue;
857 if (allBins[iRow][iPad*fMaxTime+0] <1 ) continue; // no data
858 Float_t *p = &allBins[iRow][iPad*fMaxTime+3];
859 //Float_t pedestal = TMath::Median(fMaxTime, p);
860 Int_t id[3] = {fSector, iRow, iPad-3};
862 Double_t rmsCalib= noiseROC->GetValue(iRow,iPad-3);
863 Double_t pedestalCalib = pedestalROC->GetValue(iRow,iPad-3);
864 Double_t rmsEvent = rmsCalib;
865 Double_t pedestalEvent = pedestalCalib;
866 ProcesSignal(p, fMaxTime, id, rmsEvent, pedestalEvent);
867 if (rmsEvent<rmsCalib) rmsEvent = rmsCalib; // take worst scenario
868 if (TMath::Abs(pedestalEvent-pedestalCalib)<1.0) pedestalEvent = pedestalCalib;
871 for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) {
872 Int_t bin = iPad*fMaxTime+iTimeBin;
873 allBins[iRow][bin] -= pedestalEvent;
874 if (iTimeBin < AliTPCReconstructor::GetRecoParam()->GetFirstBin())
875 allBins[iRow][bin] = 0;
876 if (iTimeBin > AliTPCReconstructor::GetRecoParam()->GetLastBin())
877 allBins[iRow][bin] = 0;
878 if (allBins[iRow][iPad*fMaxTime+iTimeBin] < zeroSup)
879 allBins[iRow][bin] = 0;
880 if (allBins[iRow][bin] < 3.0*rmsEvent) // 3 sigma cut on RMS
881 allBins[iRow][bin] = 0;
882 if (allBins[iRow][bin]) allSigBins[iRow][allNSigBins[iRow]++] = bin;
887 // Now loop over rows and find clusters
888 for (fRow = 0; fRow < nRows; fRow++) {
889 fRowCl = new AliTPCClustersRow;
890 fRowCl->SetClass("AliTPCclusterMI");
892 fRowCl->SetID(fParam->GetIndex(fSector, fRow));
893 fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
895 fRx = fParam->GetPadRowRadii(fSector, fRow);
896 fPadLength = fParam->GetPadPitchLength(fSector, fRow);
897 fPadWidth = fParam->GetPadPitchWidth();
899 fMaxPad = fParam->GetNPadsLow(fRow);
901 fMaxPad = fParam->GetNPadsUp(fRow);
902 fMaxBin = fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
904 fBins = allBins[fRow];
905 fSigBins = allSigBins[fRow];
906 fNSigBins = allNSigBins[fRow];
908 FindClusters(noiseROC);
912 nclusters += fNcluster;
913 } // End of loop to find clusters
914 } // End of loop over sectors
916 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
917 delete [] allBins[iRow];
918 delete [] allSigBins[iRow];
921 delete [] allSigBins;
922 delete [] allNSigBins;
924 if (rawReader->GetEventId() && fOutput ){
925 Info("Digits2Clusters", "File %s Event\t%d\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), nclusters);
930 void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
934 // add virtual charge at the edge
936 Double_t kMaxDumpSize = 500000;
937 if (fRecoParam->GetCalcPedestal() && fOutput->GetZipBytes()< kMaxDumpSize) fBDumpSignal =kTRUE; //dump signal flag
941 Int_t crtime = Int_t((fParam->GetZLength(fSector)-fRecoParam->GetCtgRange()*fRx)/fZWidth-fParam->GetNTBinsL1()-5);
942 Float_t minMaxCutAbs = fRecoParam->GetMinMaxCutAbs();
943 Float_t minLeftRightCutAbs = fRecoParam->GetMinLeftRightCutAbs();
944 Float_t minUpDownCutAbs = fRecoParam->GetMinUpDownCutAbs();
945 Float_t minMaxCutSigma = fRecoParam->GetMinMaxCutSigma();
946 Float_t minLeftRightCutSigma = fRecoParam->GetMinLeftRightCutSigma();
947 Float_t minUpDownCutSigma = fRecoParam->GetMinUpDownCutSigma();
948 for (Int_t iSig = 0; iSig < fNSigBins; iSig++) {
949 Int_t i = fSigBins[iSig];
950 if (i%fMaxTime<=crtime) continue;
951 Float_t *b = &fBins[i];
953 if (b[0]<minMaxCutAbs) continue; //threshold for maxima
955 if (b[-1]+b[1]+b[-fMaxTime]+b[fMaxTime]<=0) continue; // cut on isolated clusters
956 if (b[-1]+b[1]<=0) continue; // cut on isolated clusters
957 if (b[-fMaxTime]+b[fMaxTime]<=0) continue; // cut on isolated clusters
959 if ((b[0]+b[-1]+b[1])<minUpDownCutAbs) continue; //threshold for up down (TRF)
960 if ((b[0]+b[-fMaxTime]+b[fMaxTime])<minLeftRightCutAbs) continue; //threshold for left right (PRF)
961 if (!IsMaximum(*b,fMaxTime,b)) continue;
963 Float_t noise = noiseROC->GetValue(fRow, i/fMaxTime);
965 if (b[0]<minMaxCutSigma*noise) continue; //threshold form maxima
966 if ((b[0]+b[-1]+b[1])<minUpDownCutSigma*noise) continue; //threshold for up town TRF
967 if ((b[0]+b[-fMaxTime]+b[fMaxTime])<minLeftRightCutSigma*noise) continue; //threshold for left right (PRF)
969 AliTPCclusterMI c(kFALSE); // default cosntruction without info
971 MakeCluster(i, fMaxTime, fBins, dummy,c);
978 Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t id[3], Double_t &rmsEvent, Double_t &pedestalEvent){
980 // process signal on given pad - + streaming of additional information in special mode
987 // ESTIMATE pedestal and the noise
989 const Int_t kPedMax = 100;
990 Double_t kMaxDebugSize = 5000000.;
996 Float_t rmsCalib = rmsEvent; // backup initial value ( from calib)
997 Float_t pedestalCalib = pedestalEvent;// backup initial value ( from calib)
998 Int_t firstBin = AliTPCReconstructor::GetRecoParam()->GetFirstBin();
1000 UShort_t histo[kPedMax];
1001 memset(histo,0,kPedMax*sizeof(UShort_t));
1002 for (Int_t i=0; i<fMaxTime; i++){
1003 if (signal[i]<=0) continue;
1004 if (signal[i]>max && i>firstBin) {
1008 if (signal[i]>kPedMax-1) continue;
1009 histo[int(signal[i]+0.5)]++;
1013 for (Int_t i=1; i<kPedMax; i++){
1014 if (count1<count0*0.5) median=i;
1019 Float_t count10=histo[median] ,mean=histo[median]*median, rms=histo[median]*median*median ;
1020 Float_t count06=histo[median] ,mean06=histo[median]*median, rms06=histo[median]*median*median ;
1021 Float_t count09=histo[median] ,mean09=histo[median]*median, rms09=histo[median]*median*median ;
1023 for (Int_t idelta=1; idelta<10; idelta++){
1024 if (median-idelta<=0) continue;
1025 if (median+idelta>kPedMax) continue;
1026 if (count06<0.6*count1){
1027 count06+=histo[median-idelta];
1028 mean06 +=histo[median-idelta]*(median-idelta);
1029 rms06 +=histo[median-idelta]*(median-idelta)*(median-idelta);
1030 count06+=histo[median+idelta];
1031 mean06 +=histo[median+idelta]*(median+idelta);
1032 rms06 +=histo[median+idelta]*(median+idelta)*(median+idelta);
1034 if (count09<0.9*count1){
1035 count09+=histo[median-idelta];
1036 mean09 +=histo[median-idelta]*(median-idelta);
1037 rms09 +=histo[median-idelta]*(median-idelta)*(median-idelta);
1038 count09+=histo[median+idelta];
1039 mean09 +=histo[median+idelta]*(median+idelta);
1040 rms09 +=histo[median+idelta]*(median+idelta)*(median+idelta);
1042 if (count10<0.95*count1){
1043 count10+=histo[median-idelta];
1044 mean +=histo[median-idelta]*(median-idelta);
1045 rms +=histo[median-idelta]*(median-idelta)*(median-idelta);
1046 count10+=histo[median+idelta];
1047 mean +=histo[median+idelta]*(median+idelta);
1048 rms +=histo[median+idelta]*(median+idelta)*(median+idelta);
1053 rms = TMath::Sqrt(TMath::Abs(rms/count10-mean*mean));
1057 rms06 = TMath::Sqrt(TMath::Abs(rms06/count06-mean06*mean06));
1061 rms09 = TMath::Sqrt(TMath::Abs(rms09/count09-mean09*mean09));
1065 pedestalEvent = median;
1066 if (AliLog::GetDebugLevel("","AliTPCclustererMI")==0) return median;
1068 UInt_t uid[3] = {UInt_t(id[0]),UInt_t(id[1]),UInt_t(id[2])};
1070 // Dump mean signal info
1072 (*fDebugStreamer)<<"Signal"<<
1073 "TimeStamp="<<fTimeStamp<<
1074 "EventType="<<fEventType<<
1088 "RMSCalib="<<rmsCalib<<
1089 "PedCalib="<<pedestalCalib<<
1092 // fill pedestal histogram
1094 AliTPCROC * roc = AliTPCROC::Instance();
1095 if (!fAmplitudeHisto){
1096 fAmplitudeHisto = new TObjArray(72);
1099 if (uid[0]<roc->GetNSectors()
1100 && uid[1]< roc->GetNRows(uid[0]) &&
1101 uid[2] <roc->GetNPads(uid[0], uid[1])){
1102 TObjArray * sectorArray = (TObjArray*)fAmplitudeHisto->UncheckedAt(uid[0]);
1104 Int_t npads =roc->GetNChannels(uid[0]);
1105 sectorArray = new TObjArray(npads);
1106 fAmplitudeHisto->AddAt(sectorArray, uid[0]);
1108 Int_t position = uid[2]+roc->GetRowIndexes(uid[0])[uid[1]];
1109 // TH1F * histo = (TH1F*)sectorArray->UncheckedAt(position);
1112 // sprintf(hname,"Amp_%d_%d_%d",uid[0],uid[1],uid[2]);
1113 // TFile * backup = gFile;
1114 // fDebugStreamer->GetFile()->cd();
1115 // histo = new TH1F(hname, hname, 100, 5,100);
1116 // //histo->SetDirectory(0); // histogram not connected to directory -(File)
1117 // sectorArray->AddAt(histo, position);
1118 // if (backup) backup->cd();
1120 // for (Int_t i=0; i<nchannels; i++){
1121 // histo->Fill(signal[i]);
1127 Float_t kMin =fRecoParam->GetDumpAmplitudeMin(); // minimal signal to be dumped
1128 Float_t *dsignal = new Float_t[nchannels];
1129 Float_t *dtime = new Float_t[nchannels];
1130 for (Int_t i=0; i<nchannels; i++){
1132 dsignal[i] = signal[i];
1137 // if (max-median>30.*TMath::Max(1.,Double_t(rms06)) && (((*fDebugStreamer)<<"SignalDN").GetSize()<kMaxDebugSize)){
1140 // TGraph * graph =new TGraph(nchannels, dtime, dsignal);
1143 // // jumps left - right
1145 // Double_t deltaT0[2000];
1146 // Double_t deltaA0[2000];
1147 // Int_t lastJump0 = fRecoParam->GetFirstBin();
1149 // Double_t deltaT1[2000];
1150 // Double_t deltaA1[2000];
1151 // Int_t lastJump1 = fRecoParam->GetFirstBin();
1153 // Double_t deltaT2[2000];
1154 // Double_t deltaA2[2000];
1155 // Int_t lastJump2 = fRecoParam->GetFirstBin();
1157 // for (Int_t itime=fRecoParam->GetFirstBin()+1; itime<fRecoParam->GetLastBin()-1; itime++){
1158 // if (TMath::Abs(dsignal[itime]-dsignal[itime-1])>30.*TMath::Max(1.,Double_t(rms06)) &&
1159 // TMath::Abs(dsignal[itime]-dsignal[itime+1])>30.*TMath::Max(1.,Double_t(rms06)) &&
1160 // (dsignal[itime-1]-median<5.*rms06) &&
1161 // (dsignal[itime+1]-median<5.*rms06)
1163 // deltaA0[njumps0] = dsignal[itime]-dsignal[itime-1];
1164 // deltaT0[njumps0] = itime-lastJump0;
1165 // lastJump0 = itime;
1168 // if (TMath::Abs(dsignal[itime]-dsignal[itime-1])>30.*TMath::Max(1.,Double_t(rms06)) &&
1169 // (dsignal[itime-1]-median<5.*rms06)
1171 // deltaA1[njumps1] = dsignal[itime]-dsignal[itime-1];
1172 // deltaT1[njumps1] = itime-lastJump1;
1173 // lastJump1 = itime;
1176 // if (TMath::Abs(dsignal[itime]-dsignal[itime+1])>30.*TMath::Max(1.,Double_t(rms06)) &&
1177 // (dsignal[itime+1]-median<5.*rms06)
1179 // deltaA2[njumps2] = dsignal[itime]-dsignal[itime+1];
1180 // deltaT2[njumps2] = itime-lastJump2;
1181 // lastJump2 = itime;
1186 // if (njumps0>0 || njumps1>0 || njumps2>0){
1187 // TGraph *graphDN0 = new TGraph(njumps0, deltaT0, deltaA0);
1188 // TGraph *graphDN1 = new TGraph(njumps1, deltaT1, deltaA1);
1189 // TGraph *graphDN2 = new TGraph(njumps2, deltaT2, deltaA2);
1190 // (*fDebugStreamer)<<"SignalDN"<< //digital - noise pads - or random sample of pads
1191 // "TimeStamp="<<fTimeStamp<<
1192 // "EventType="<<fEventType<<
1193 // "Sector="<<uid[0]<<
1196 // "Graph="<<graph<<
1198 // "MaxPos="<<maxPos<<
1199 // "Graph.="<<graph<<
1200 // "P0GraphDN0.="<<graphDN0<<
1201 // "P1GraphDN1.="<<graphDN1<<
1202 // "P2GraphDN2.="<<graphDN2<<
1204 // "Median="<<median<<
1207 // "Mean06="<<mean06<<
1208 // "RMS06="<<rms06<<
1209 // "Mean09="<<mean09<<
1210 // "RMS09="<<rms09<<
1220 // NOISE STUDY Fourier transform
1223 Bool_t random = (gRandom->Rndm()<0.0003);
1224 if (((*fDebugStreamer)<<"SignalN").GetSize()<kMaxDebugSize)
1225 if (max-median>kMin || rms06>1.*fParam->GetZeroSup() || random){
1226 graph =new TGraph(nchannels, dtime, dsignal);
1227 if (rms06>1.*fParam->GetZeroSup() || random){
1228 //Double_t *input, Double_t threshold, Bool_t locMax, Double_t *freq, Double_t *re, Double_t *im, Double_t *mag, Double_t *phi);
1229 Float_t * input = &(dsignal[fRecoParam->GetFirstBin()]);
1230 Float_t freq[2000], re[2000], im[2000], mag[2000], phi[2000];
1231 Int_t npoints = TransformFFT(input, -1,kFALSE, freq, re, im, mag, phi);
1232 TGraph *graphMag0 = new TGraph(npoints, freq, mag);
1233 TGraph *graphPhi0 = new TGraph(npoints, freq, phi);
1234 npoints = TransformFFT(input, 0.5,kTRUE, freq, re, im, mag, phi);
1235 TGraph *graphMag1 = new TGraph(npoints, freq, mag);
1236 TGraph *graphPhi1 = new TGraph(npoints, freq, phi);
1238 (*fDebugStreamer)<<"SignalN"<< //noise pads - or random sample of pads
1239 "TimeStamp="<<fTimeStamp<<
1240 "EventType="<<fEventType<<
1256 "Mag0.="<<graphMag0<<
1257 "Mag1.="<<graphMag1<<
1258 "Phi0.="<<graphPhi0<<
1259 "Phi1.="<<graphPhi1<<
1267 // Big signals dumping
1270 if (max-median>kMin &&maxPos>AliTPCReconstructor::GetRecoParam()->GetFirstBin())
1271 (*fDebugStreamer)<<"SignalB"<< // pads with signal
1272 "TimeStamp="<<fTimeStamp<<
1273 "EventType="<<fEventType<<
1294 // Central Electrode signal analysis
1296 Float_t ceQmax =0, ceQsum=0, ceTime=0;
1297 Float_t cemean = mean06, cerms=rms06 ;
1299 Float_t ceThreshold=5.*cerms;
1300 Float_t ceSumThreshold=8.*cerms;
1301 const Int_t kCemin=5; // range for the analysis of the ce signal +- channels from the peak
1302 const Int_t kCemax=5;
1303 for (Int_t i=nchannels-2; i>nchannels/2; i--){
1304 if ( (dsignal[i]-mean06)>ceThreshold && dsignal[i]>=dsignal[i+1] && dsignal[i]>=dsignal[i-1] ){
1312 for (Int_t i=cemaxpos-20; i<cemaxpos+5; i++){
1313 if (i<0 || i>nchannels-1) continue;
1314 Double_t val=dsignal[i]- cemean;
1320 cemaxpos = cemaxpos2;
1322 for (Int_t i=cemaxpos-kCemin; i<cemaxpos+kCemax; i++){
1323 if (i>0 && i<nchannels&&dsignal[i]- cemean>0){
1324 Double_t val=dsignal[i]- cemean;
1325 ceTime+=val*dtime[i];
1327 if (val>ceQmax) ceQmax=val;
1330 if (ceQmax&&ceQsum>ceSumThreshold) {
1332 (*fDebugStreamer)<<"Signalce"<<
1333 "TimeStamp="<<fTimeStamp<<
1334 "EventType="<<fEventType<<
1346 // end of ce signal analysis
1350 // Gating grid signal analysis
1352 Double_t ggQmax =0, ggQsum=0, ggTime=0;
1353 Double_t ggmean = mean06, ggrms=rms06 ;
1355 Double_t ggThreshold=5.*ggrms;
1356 Double_t ggSumThreshold=8.*ggrms;
1358 for (Int_t i=1; i<nchannels/4; i++){
1359 if ( (dsignal[i]-mean06)>ggThreshold && dsignal[i]>=dsignal[i+1] && dsignal[i]>=dsignal[i-1] &&
1360 (dsignal[i]+dsignal[i+1]+dsignal[i-1]-3*mean06)>ggSumThreshold){
1362 if (dsignal[i-1]>dsignal[i+1]) ggmaxpos=i-1;
1367 for (Int_t i=ggmaxpos-1; i<ggmaxpos+3; i++){
1368 if (i>0 && i<nchannels && dsignal[i]-ggmean>0){
1369 Double_t val=dsignal[i]- ggmean;
1370 ggTime+=val*dtime[i];
1372 if (val>ggQmax) ggQmax=val;
1375 if (ggQmax&&ggQsum>ggSumThreshold) {
1377 (*fDebugStreamer)<<"Signalgg"<<
1378 "TimeStamp="<<fTimeStamp<<
1379 "EventType="<<fEventType<<
1391 // end of gg signal analysis
1396 if (rms06>fRecoParam->GetMaxNoise()) {
1397 pedestalEvent+=1024.;
1398 return 1024+median; // sign noisy channel in debug mode
1405 void AliTPCclustererMI::DumpHistos(){
1407 // Dump histogram information
1409 if (!fAmplitudeHisto) return;
1410 AliTPCROC * roc = AliTPCROC::Instance();
1411 for (UInt_t isector=0; isector<AliTPCROC::Instance()->GetNSectors(); isector++){
1412 TObjArray * array = (TObjArray*)fAmplitudeHisto->UncheckedAt(isector);
1413 if (!array) continue;
1414 for (UInt_t ipad = 0; ipad <(UInt_t)array->GetEntriesFast(); ipad++){
1415 TH1F * histo = (TH1F*) array->UncheckedAt(ipad);
1416 if (!histo) continue;
1417 if (histo->GetEntries()<100) continue;
1418 histo->Fit("gaus","q");
1419 Float_t mean = histo->GetMean();
1420 Float_t rms = histo->GetRMS();
1421 Float_t gmean = histo->GetFunction("gaus")->GetParameter(1);
1422 Float_t gsigma = histo->GetFunction("gaus")->GetParameter(2);
1423 Float_t gmeanErr = histo->GetFunction("gaus")->GetParError(1);
1424 Float_t gsigmaErr = histo->GetFunction("gaus")->GetParError(2);
1425 Float_t max = histo->GetFunction("gaus")->GetParameter(0);
1428 UInt_t row=0, pad =0;
1429 const UInt_t *indexes =roc->GetRowIndexes(isector);
1430 for (UInt_t irow=0; irow<roc->GetNRows(isector); irow++){
1431 if (indexes[irow]<=ipad){
1433 pad = ipad-indexes[irow];
1436 Int_t rpad = pad - (AliTPCROC::Instance()->GetNPads(isector,row))/2;
1438 (*fDebugStreamer)<<"Fit"<<
1439 "TimeStamp="<<fTimeStamp<<
1440 "EventType="<<fEventType<<
1441 "Sector="<<isector<<
1450 "GMeanErr="<<gmeanErr<<
1451 "GSigmaErr="<<gsigmaErr<<
1453 if (array->UncheckedAt(ipad)) fDebugStreamer->StoreObject(array->UncheckedAt(ipad));
1460 Int_t AliTPCclustererMI::TransformFFT(Float_t *input, Float_t threshold, Bool_t locMax, Float_t *freq, Float_t *re, Float_t *im, Float_t *mag, Float_t *phi)
1463 // calculate fourrie transform
1464 // return only frequncies with mag over threshold
1465 // if locMax is spectified only freque with local maxima over theshold is returned
1467 if (! fFFTr2c) return kFALSE;
1468 if (!freq) return kFALSE;
1471 Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin();
1472 Double_t *in = new Double_t[nPoints];
1473 Double_t *rfft = new Double_t[nPoints];
1474 Double_t *ifft = new Double_t[nPoints];
1475 for (Int_t i=0; i<nPoints; i++){in[i]=input[i];}
1476 fFFTr2c->SetPoints(in);
1477 fFFTr2c->Transform();
1478 fFFTr2c->GetPointsComplex(rfft, ifft);
1479 for (Int_t i=3; i<nPoints/2-3; i++){
1480 Float_t lmag = TMath::Sqrt(rfft[i]*rfft[i]+ifft[i]*ifft[i])/nPoints;
1481 if (lmag<threshold) continue;
1483 if ( TMath::Sqrt(rfft[i-1]*rfft[i-1]+ifft[i-1]*ifft[i-1])/nPoints>lmag) continue;
1484 if ( TMath::Sqrt(rfft[i+1]*rfft[i+1]+ifft[i+1]*ifft[i+1])/nPoints>lmag) continue;
1485 if ( TMath::Sqrt(rfft[i-2]*rfft[i-2]+ifft[i-2]*ifft[i-2])/nPoints>lmag) continue;
1486 if ( TMath::Sqrt(rfft[i+2]*rfft[i+2]+ifft[i+2]*ifft[i+2])/nPoints>lmag) continue;
1487 if ( TMath::Sqrt(rfft[i-3]*rfft[i-3]+ifft[i-3]*ifft[i-3])/nPoints>lmag) continue;
1488 if ( TMath::Sqrt(rfft[i+3]*rfft[i+3]+ifft[i+3]*ifft[i+3])/nPoints>lmag) continue;
1491 freq[current] = Float_t(i)/Float_t(nPoints);
1493 re[current] = rfft[i];
1494 im[current] = ifft[i];
1496 phi[current]=TMath::ATan2(ifft[i],rfft[i]);