]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCclustererMI.cxx
Adding pad type correction (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCclustererMI.cxx
index 8f3532b34882d27bed4bddaef9d6128d81115e28..c932dd4c49bf2a718990b7aa4af3d67fb8951727 100644 (file)
 //-------------------------------------------------------
 //          Implementation of the TPC clusterer
 //
+//  1. The Input data for reconstruction - Options
+//      1.a Simulated data  - TTree - invoked Digits2Clusters()
+//      1.b Raw data        - Digits2Clusters(AliRawReader* rawReader); 
+//
+//  2. The Output data
+//      2.a TTree with clusters - if  SetOutput(TTree * tree) invoked
+//      2.b TObjArray           - Faster option for HLT
+//      2.c TClonesArray        - Faster option for HLT (smaller memory consumption), activate with fBClonesArray flag
+//
+//  3. Reconstruction setup
+//     see AliTPCRecoParam for list of parameters 
+//     The reconstruction parameterization taken from the 
+//     AliTPCReconstructor::GetRecoParam()
+//     Possible to setup it in reconstruction macro  AliTPCReconstructor::SetRecoParam(...)
+//     
+//
+//
 //   Origin: Marian Ivanov 
 //-------------------------------------------------------
 
 #include <TGraph.h>
 #include <TH1F.h>
 #include <TObjArray.h>
+#include <TClonesArray.h>
 #include <TRandom.h>
 #include <TTree.h>
 #include <TTreeStream.h>
-#include <TVirtualFFT.h>
 
 #include "AliDigits.h"
 #include "AliLoader.h"
@@ -74,30 +91,29 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoPar
   fPadLength(0),
   fZWidth(0),
   fPedSubtraction(kFALSE),
-  fIsOldRCUFormat(kFALSE),
   fEventHeader(0),
   fTimeStamp(0),
   fEventType(0),
   fInput(0),
   fOutput(0),
+  fOutputArray(0),
+  fOutputClonesArray(0),
   fRowCl(0),
   fRowDig(0),
   fParam(0),
   fNcluster(0),
-  fAmplitudeHisto(0),
+  fNclusters(0),
   fDebugStreamer(0),
   fRecoParam(0),
   fBDumpSignal(kFALSE),
-  fFFTr2c(0)
+  fBClonesArray(kFALSE)
 {
   //
   // COSNTRUCTOR
   // param     - tpc parameters for given file
   // recoparam - reconstruction parameters 
   //
-  fIsOldRCUFormat = kFALSE;
   fInput =0;
-  fOutput=0;
   fParam = par;
   if (recoParam) {
     fRecoParam = recoParam;
@@ -106,10 +122,16 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoPar
     fRecoParam = AliTPCReconstructor::GetRecoParam();
     if (!fRecoParam)  fRecoParam = AliTPCRecoParam::GetLowFluxParam();
   }
-  fDebugStreamer = new TTreeSRedirector("TPCsignal.root");
-  fAmplitudeHisto = 0;
-  Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin();
-  fFFTr2c = TVirtualFFT::FFT(1, &nPoints, "R2C  K");
+  if(AliTPCReconstructor::StreamLevel()>0) {
+    fDebugStreamer = new TTreeSRedirector("TPCsignal.root");
+  }
+
+  //  Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin();
+  fRowCl= new AliTPCClustersRow();
+  fRowCl->SetClass("AliTPCclusterMI");
+  fRowCl->SetArray(1);
+
 }
 //______________________________________________________________
 AliTPCclustererMI::AliTPCclustererMI(const AliTPCclustererMI &param)
@@ -129,21 +151,22 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCclustererMI &param)
   fPadLength(0),
   fZWidth(0),
   fPedSubtraction(kFALSE),
-  fIsOldRCUFormat(kFALSE),
   fEventHeader(0),
   fTimeStamp(0),
   fEventType(0),
   fInput(0),
   fOutput(0),
+  fOutputArray(0),
+  fOutputClonesArray(0),
   fRowCl(0),
   fRowDig(0),
   fParam(0),
   fNcluster(0),
-  fAmplitudeHisto(0),
+  fNclusters(0),
   fDebugStreamer(0),
   fRecoParam(0),
   fBDumpSignal(kFALSE),
-  fFFTr2c(0)
+  fBClonesArray(kFALSE)
 {
   //
   // dummy
@@ -161,9 +184,18 @@ AliTPCclustererMI & AliTPCclustererMI::operator =(const AliTPCclustererMI & para
 }
 //______________________________________________________________
 AliTPCclustererMI::~AliTPCclustererMI(){
-  DumpHistos();
-  if (fAmplitudeHisto) delete fAmplitudeHisto;
+  //
+  //
+  //
   if (fDebugStreamer) delete fDebugStreamer;
+  if (fOutputArray){
+    //fOutputArray->Delete();
+    delete fOutputArray;
+  }
+  if (fOutputClonesArray){
+    fOutputClonesArray->Delete();
+    delete fOutputClonesArray;
+  }
 }
 
 void AliTPCclustererMI::SetInput(TTree * tree)
@@ -182,8 +214,11 @@ void AliTPCclustererMI::SetInput(TTree * tree)
 void AliTPCclustererMI::SetOutput(TTree * tree) 
 {
   //
+  // Set the output tree
+  // If not set the ObjArray used - Option for HLT 
   //
-  fOutput= tree;  
+  if (!tree) return;
+  fOutput= tree;
   AliTPCClustersRow clrow;
   AliTPCClustersRow *pclrow=&clrow;  
   clrow.SetClass("AliTPCclusterMI");
@@ -192,6 +227,21 @@ void AliTPCclustererMI::SetOutput(TTree * tree)
 }
 
 
+void AliTPCclustererMI::FillRow(){
+  //
+  // fill the output container - 
+  // 2 Options possible
+  //          Tree       
+  //          TObjArray
+  //
+  if (fOutput) fOutput->Fill();
+  if (!fOutput && !fBClonesArray){
+    //
+    if (!fOutputArray) fOutputArray = new TObjArray(fParam->GetNRowsTotal());
+    if (fRowCl && fRowCl->GetArray()->GetEntriesFast()>0) fOutputArray->AddAt(fRowCl->Clone(), fRowCl->GetID());
+  }
+}
+
 Float_t  AliTPCclustererMI::GetSigmaY2(Int_t iz){
   // sigma y2 = in digits  - we don't know the angle
   Float_t z = iz*fParam->GetZWidth()+fParam->GetNTBinsL1()*fParam->GetZWidth();
@@ -359,8 +409,6 @@ AliTPCclusterMI &c)
   //unfolding 2
   meani-=i0;
   meanj-=j0;
-  if (gDebug>4)
-    printf("%f\t%f\n", vmatrix2[2][2], vmatrix[2][2]);
 }
 
 
@@ -488,8 +536,6 @@ void AliTPCclustererMI::UnfoldCluster(Float_t * matrix2[7], Float_t recmatrix[5]
          }
       }
   }
-  if (gDebug>4) 
-    printf("%f\n", recmatrix[2][2]);
   
 }
 
@@ -557,32 +603,42 @@ void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c, Float_t * matrix, Int_t p
   c.SetZ(x[2]);
   //
   //
-  if (!fRecoParam->GetBYMirror()){
-    if (fSector%36>17){
-      c.SetY(-c.GetY());
-    }
-  }
-
   if (ki<=1 || ki>=fMaxPad-1 || kj==1 || kj==fMaxTime-2) {
     c.SetType(-(c.GetType()+3));  //edge clusters
   }
   if (fLoop==2) c.SetType(100);
+  if (!AcceptCluster(&c)) return;
 
-  TClonesArray * arr = fRowCl->GetArray();
-  AliTPCclusterMI * cl = new ((*arr)[fNcluster]) AliTPCclusterMI(c);
-  if (fRecoParam->DumpSignal() &&matrix ) {
-    Int_t nbins=0;
-    Float_t *graph =0;
-    if (fRecoParam->GetCalcPedestal() && cl->GetMax()>fRecoParam->GetDumpAmplitudeMin() &&fBDumpSignal){
-      nbins = fMaxTime;
-      graph = &(fBins[fMaxTime*(pos/fMaxTime)]);
-    }
-    AliTPCclusterInfo * info = new AliTPCclusterInfo(matrix,nbins,graph);
-    cl->SetInfo(info);
+  // select output 
+  TClonesArray * arr = 0;
+  AliTPCclusterMI * cl = 0;
+
+  if(fBClonesArray==kFALSE) {
+     arr = fRowCl->GetArray();
+     cl = new ((*arr)[fNcluster]) AliTPCclusterMI(c);
+  } else {
+     cl = new ((*fOutputClonesArray)[fNclusters+fNcluster]) AliTPCclusterMI(c);
   }
+
+  // if (fRecoParam->DumpSignal() &&matrix ) {
+//     Int_t nbins=0;
+//     Float_t *graph =0;
+//     if (fRecoParam->GetCalcPedestal() && cl->GetMax()>fRecoParam->GetDumpAmplitudeMin() &&fBDumpSignal){
+//       nbins = fMaxTime;
+//       graph = &(fBins[fMaxTime*(pos/fMaxTime)]);
+//     }
+//     AliTPCclusterInfo * info = new AliTPCclusterInfo(matrix,nbins,graph);
+//     cl->SetInfo(info);
+//   }
   if (!fRecoParam->DumpSignal()) {
     cl->SetInfo(0);
   }
+  
+  if (AliTPCReconstructor::StreamLevel()>1) {
+     (*fDebugStreamer)<<"Clusters"<<
+       "Cl.="<<cl<<
+       "\n";
+  }
 
   fNcluster++;
 }
@@ -600,11 +656,6 @@ void AliTPCclustererMI::Digits2Clusters()
     return;
   }
  
-  if (!fOutput) {
-    Error("Digits2Clusters", "output tree not initialised");
-    return;
-  }
-
   AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
   AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
   AliSimDigits digarr, *dummy=&digarr;
@@ -626,13 +677,9 @@ void AliTPCclustererMI::Digits2Clusters()
     AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector);  // pad gains per given sector
     AliTPCCalROC * noiseROC   = noiseTPC->GetCalROC(fSector); // noise per given sector
     //
-    AliTPCClustersRow *clrow= new AliTPCClustersRow();
-    fRowCl = clrow;
-    clrow->SetClass("AliTPCclusterMI");
-    clrow->SetArray(1);
 
-    clrow->SetID(digarr.GetID());
-    fOutput->GetBranch("Segment")->SetAddress(&clrow);
+    fRowCl->SetID(digarr.GetID());
+    if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
     fRx=fParam->GetPadRowRadii(fSector,row);
     
     
@@ -664,16 +711,20 @@ void AliTPCclustererMI::Digits2Clusters()
        Int_t j=digarr.CurrentRow()+3, i=digarr.CurrentColumn()+3;
        Float_t gain = gainROC->GetValue(row,digarr.CurrentColumn());
        Int_t bin = i*fMaxTime+j;
-       fBins[bin]=dig/gain;
+       if (gain>0){
+         fBins[bin]=dig/gain;
+       }else{
+         fBins[bin]=0;
+       }
        fSigBins[fNSigBins++]=bin;
       } while (digarr.Next());
     digarr.ExpandTrackBuffer();
 
     FindClusters(noiseROC);
-
-    fOutput->Fill();
-    delete clrow;    
+    FillRow();
+    fRowCl->GetArray()->Clear();    
     nclusters+=fNcluster;    
+
     delete[] fBins;
     delete[] fSigBins;
   }  
@@ -690,10 +741,6 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
 // using an option of the TPC reconstructor
 //-----------------------------------------------------------------
 
-  if (!fOutput) {
-    Error("Digits2Clusters", "output tree not initialised");
-    return;
-  }
 
   fRowDig = NULL;
   AliTPCROC * roc = AliTPCROC::Instance();
@@ -709,8 +756,10 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
     fEventType = fEventHeader->Get("Type");  
   }
 
-
-  Int_t nclusters  = 0;
+  // creaate one TClonesArray for all clusters
+  if(fBClonesArray && !fOutputClonesArray) fOutputClonesArray = new TClonesArray("AliTPCclusterMI",1000);
+  // reset counter
+  fNclusters  = 0;
   
   fMaxTime = fRecoParam->GetLastBin() + 6; // add 3 virtual time bins before and 3 after
   const Int_t kNIS = fParam->GetNInnerSector();
@@ -742,10 +791,6 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
   //
   for(fSector = 0; fSector < kNS; fSector++) {
 
-    AliTPCCalROC * gainROC    = gainTPC->GetCalROC(fSector);  // pad gains per given sector
-    AliTPCCalROC * pedestalROC = pedestalTPC->GetCalROC(fSector);  // pedestal per given sector
-    AliTPCCalROC * noiseROC   = noiseTPC->GetCalROC(fSector);  // noise per given sector
     Int_t nRows = 0;
     Int_t nDDLs = 0, indexDDL = 0;
     if (fSector < kNIS) {
@@ -761,6 +806,23 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
       indexDDL = (fSector-kNIS) * 4 + kNIS * 2;
     }
 
+    // load the raw data for corresponding DDLs
+    rawReader->Reset();
+    rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
+
+    // select only good sector 
+    input.Next();
+    if(input.GetSector() != fSector) continue;
+
+    AliTPCCalROC * gainROC    = gainTPC->GetCalROC(fSector);  // pad gains per given sector
+    AliTPCCalROC * pedestalROC = pedestalTPC->GetCalROC(fSector);  // pedestal per given sector
+    AliTPCCalROC * noiseROC   = noiseTPC->GetCalROC(fSector);  // noise per given sector
+    //check the presence of the calibration
+    if (!noiseROC ||!pedestalROC ) {
+      AliError(Form("Missing calibration per sector\t%d\n",fSector));
+      continue;
+    }
+    
     for (Int_t iRow = 0; iRow < nRows; iRow++) {
       Int_t maxPad;
       if (fSector < kNIS)
@@ -773,21 +835,23 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
       allNSigBins[iRow] = 0;
     }
     
-    // Loas the raw data for corresponding DDLs
-    rawReader->Reset();
-    input.SetOldRCUFormat(fIsOldRCUFormat);
-    rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
     Int_t digCounter=0;
     // Begin loop over altro data
     Bool_t calcPedestal = fRecoParam->GetCalcPedestal();
     Float_t gain =1;
     Int_t lastPad=-1;
+
+    input.Reset();
     while (input.Next()) {
       if (input.GetSector() != fSector)
        AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",fSector,input.GetSector()));
 
       
       Int_t iRow = input.GetRow();
+      if (iRow < 0){
+       continue;
+      }
+
       if (iRow < 0 || iRow >= nRows){
        AliError(Form("Pad-row index (%d) outside the range (%d -> %d) !",
                      iRow, 0, nRows -1));
@@ -817,9 +881,14 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
       //signal
       Float_t signal = input.GetSignal();
       if (!calcPedestal && signal <= zeroSup) continue;      
+
       if (!calcPedestal) {
        Int_t bin = iPad*fMaxTime+iTimeBin;
-       allBins[iRow][bin] = signal/gain;
+       if (gain>0){
+         allBins[iRow][bin] = signal/gain;
+       }else{
+         allBins[iRow][bin] =0;
+       }
        allSigBins[iRow][allNSigBins[iRow]++] = bin;
       }else{
        allBins[iRow][iPad*fMaxTime+iTimeBin] = signal;
@@ -884,13 +953,52 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
        }
       }
     }
+
+    if (AliTPCReconstructor::StreamLevel()>3) {
+      for (Int_t iRow = 0; iRow < nRows; iRow++) {
+       Int_t maxPad;
+       if (fSector < kNIS)
+         maxPad = fParam->GetNPadsLow(iRow);
+       else
+         maxPad = fParam->GetNPadsUp(iRow);
+       
+       for (Int_t iPad = 3; iPad < maxPad + 3; iPad++) {
+         for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) {
+           Int_t bin = iPad*fMaxTime+iTimeBin;
+           Float_t signal = allBins[iRow][bin];
+           if (AliTPCReconstructor::StreamLevel()>3 && signal>3) {
+             Double_t x[]={iRow,iPad-3,iTimeBin-3};
+             Int_t i[]={fSector};
+             AliTPCTransform trafo;
+             trafo.Transform(x,i,0,1);
+             Double_t gx[3]={x[0],x[1],x[2]};
+             trafo.RotatedGlobal2Global(fSector,gx);
+             
+              if (AliTPCReconstructor::StreamLevel()>0) {
+             (*fDebugStreamer)<<"Digits"<<
+               "sec="<<fSector<<
+               "row="<<iRow<<
+               "pad="<<iPad<<
+               "time="<<iTimeBin<<
+               "sig="<<signal<<
+               "x="<<x[0]<<
+               "y="<<x[1]<<
+               "z="<<x[2]<<      
+               "gx="<<gx[0]<<
+               "gy="<<gx[1]<<
+               "gz="<<gx[2]<<
+               "\n";
+             }
+           }
+         }
+       }
+      }
+    }
+
     // Now loop over rows and find clusters
     for (fRow = 0; fRow < nRows; fRow++) {
-      fRowCl = new AliTPCClustersRow;
-      fRowCl->SetClass("AliTPCclusterMI");
-      fRowCl->SetArray(1);
       fRowCl->SetID(fParam->GetIndex(fSector, fRow));
-      fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
+      if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
 
       fRx = fParam->GetPadRowRadii(fSector, fRow);
       fPadLength = fParam->GetPadPitchLength(fSector, fRow);
@@ -907,12 +1015,13 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
 
       FindClusters(noiseROC);
 
-      fOutput->Fill();
-      delete fRowCl;    
-      nclusters += fNcluster;    
+      FillRow();
+      if(fBClonesArray == kFALSE) fRowCl->GetArray()->Clear();    
+      fNclusters += fNcluster;    
+
     } // End of loop to find clusters
   } // End of loop over sectors
-  
+
   for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
     delete [] allBins[iRow];
     delete [] allSigBins[iRow];
@@ -922,9 +1031,16 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
   delete [] allNSigBins;
   
   if (rawReader->GetEventId() && fOutput ){
-    Info("Digits2Clusters", "File  %s Event\t%d\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), nclusters);
+    Info("Digits2Clusters", "File  %s Event\t%d\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), fNclusters);
+  }
+  
+  if(rawReader->GetEventId()) {
+    Info("Digits2Clusters", "Event\t%d\tNumber of found clusters : %d\n",*(rawReader->GetEventId()), fNclusters);
   }
 
+  if(fBClonesArray) {
+    //Info("Digits2Clusters", "Number of found clusters : %d\n",fOutputClonesArray->GetEntriesFast());
+  }
 }
 
 void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
@@ -934,8 +1050,12 @@ void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
   // add virtual charge at the edge   
   //
   Double_t kMaxDumpSize = 500000;
-  if (fRecoParam->GetCalcPedestal() && fOutput->GetZipBytes()< kMaxDumpSize) fBDumpSignal =kTRUE;   //dump signal flag
-  //
+  if (!fOutput) {
+    fBDumpSignal =kFALSE;
+  }else{
+    if (fRecoParam->GetCalcPedestal() && fOutput->GetZipBytes()< kMaxDumpSize) fBDumpSignal =kTRUE;   //dump signal flag
+  }
+   
   fNcluster=0;
   fLoop=1;
   Int_t crtime = Int_t((fParam->GetZLength(fSector)-fRecoParam->GetCtgRange()*fRx)/fZWidth-fParam->GetNTBinsL1()-5);
@@ -961,12 +1081,13 @@ void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
     if (!IsMaximum(*b,fMaxTime,b)) continue;
     //
     Float_t noise = noiseROC->GetValue(fRow, i/fMaxTime);
+    if (noise>fRecoParam->GetMaxNoise()) continue;
     // sigma cuts
     if (b[0]<minMaxCutSigma*noise) continue;   //threshold form maxima  
     if ((b[0]+b[-1]+b[1])<minUpDownCutSigma*noise) continue;   //threshold for up town TRF 
     if ((b[0]+b[-fMaxTime]+b[fMaxTime])<minLeftRightCutSigma*noise) continue;   //threshold for left right (PRF)    
   
-    AliTPCclusterMI c(kFALSE);   // default cosntruction  without info
+    AliTPCclusterMI c;   // default cosntruction  without info
     Int_t dummy=0;
     MakeCluster(i, fMaxTime, fBins, dummy,c);
     
@@ -974,6 +1095,22 @@ void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
   }
 }
 
+Bool_t AliTPCclustererMI::AcceptCluster(AliTPCclusterMI *cl){
+  //
+  // Currently hack to filter digital noise (15.06.2008)
+  // To be parameterized in the AliTPCrecoParam
+  // More inteligent way  to be used in future
+  // Acces to the proper pedestal file needed
+  //
+  if (cl->GetMax()<400) return kTRUE;
+  Double_t ratio = cl->GetQ()/cl->GetMax();
+  if (cl->GetMax()>700){
+    if ((ratio - int(ratio)>0.8)) return kFALSE;
+  }
+  if ((ratio - int(ratio)<0.95)) return kTRUE;
+  return kFALSE;
+}
+
 
 Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t id[3], Double_t &rmsEvent, Double_t &pedestalEvent){
   //
@@ -987,7 +1124,6 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
   // ESTIMATE pedestal and the noise
   // 
   const Int_t kPedMax = 100;
-  Double_t kMaxDebugSize = 5000000.;
   Float_t  max    =  0;
   Float_t  maxPos =  0;
   Int_t    median =  -1;
@@ -998,7 +1134,8 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
   Int_t    firstBin = AliTPCReconstructor::GetRecoParam()->GetFirstBin();
   //
   UShort_t histo[kPedMax];
-  memset(histo,0,kPedMax*sizeof(UShort_t));
+  //memset(histo,0,kPedMax*sizeof(UShort_t));
+  for (Int_t i=0; i<kPedMax; i++) histo[i]=0;
   for (Int_t i=0; i<fMaxTime; i++){
     if (signal[i]<=0) continue;
     if (signal[i]>max && i>firstBin) {
@@ -1069,7 +1206,8 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
   //
   // Dump mean signal info
   //
-  (*fDebugStreamer)<<"Signal"<<
+    if (AliTPCReconstructor::StreamLevel()>0) {
+    (*fDebugStreamer)<<"Signal"<<
     "TimeStamp="<<fTimeStamp<<
     "EventType="<<fEventType<<
     "Sector="<<uid[0]<<
@@ -1088,39 +1226,10 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
     "RMSCalib="<<rmsCalib<<
     "PedCalib="<<pedestalCalib<<
     "\n";
+    }
   //
   // fill pedestal histogram
   //
-  AliTPCROC * roc = AliTPCROC::Instance();
-  if (!fAmplitudeHisto){
-    fAmplitudeHisto = new TObjArray(72);
-  }  
-  //
-  if (uid[0]<roc->GetNSectors() 
-      && uid[1]< roc->GetNRows(uid[0])  && 
-      uid[2] <roc->GetNPads(uid[0], uid[1])){
-    TObjArray  * sectorArray = (TObjArray*)fAmplitudeHisto->UncheckedAt(uid[0]);
-    if (!sectorArray){
-      Int_t npads =roc->GetNChannels(uid[0]);
-      sectorArray = new TObjArray(npads);
-      fAmplitudeHisto->AddAt(sectorArray, uid[0]);
-    }
-    Int_t position =  uid[2]+roc->GetRowIndexes(uid[0])[uid[1]];
-    // TH1F * histo = (TH1F*)sectorArray->UncheckedAt(position);
-//     if (!histo){
-//       char hname[100];
-//       sprintf(hname,"Amp_%d_%d_%d",uid[0],uid[1],uid[2]);
-//       TFile * backup = gFile;
-//       fDebugStreamer->GetFile()->cd();
-//       histo = new TH1F(hname, hname, 100, 5,100);
-//       //histo->SetDirectory(0);     // histogram not connected to directory -(File)
-//       sectorArray->AddAt(histo, position);
-//       if (backup) backup->cd();
-//     }
-//     for (Int_t i=0; i<nchannels; i++){
-//       histo->Fill(signal[i]);
-//     }
-  }
   //
   //
   //
@@ -1131,265 +1240,33 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
     dtime[i] = i;
     dsignal[i] = signal[i];
   }
-  //
-  // Digital noise
-  //
- //  if (max-median>30.*TMath::Max(1.,Double_t(rms06)) &&  (((*fDebugStreamer)<<"SignalDN").GetSize()<kMaxDebugSize)){    
-//     //
-//     //
-//     TGraph * graph =new TGraph(nchannels, dtime, dsignal);
-//     //
-//     //
-//     // jumps left - right
-//     Int_t    njumps0=0;
-//     Double_t deltaT0[2000];
-//     Double_t deltaA0[2000];
-//     Int_t    lastJump0 = fRecoParam->GetFirstBin();
-//     Int_t    njumps1=0;
-//     Double_t deltaT1[2000];
-//     Double_t deltaA1[2000];
-//     Int_t    lastJump1 = fRecoParam->GetFirstBin();
-//     Int_t    njumps2=0;
-//     Double_t deltaT2[2000];
-//     Double_t deltaA2[2000];
-//     Int_t    lastJump2 = fRecoParam->GetFirstBin();
-
-//     for (Int_t itime=fRecoParam->GetFirstBin()+1; itime<fRecoParam->GetLastBin()-1; itime++){
-//       if (TMath::Abs(dsignal[itime]-dsignal[itime-1])>30.*TMath::Max(1.,Double_t(rms06))  && 
-//       TMath::Abs(dsignal[itime]-dsignal[itime+1])>30.*TMath::Max(1.,Double_t(rms06))  &&
-//       (dsignal[itime-1]-median<5.*rms06) &&
-//       (dsignal[itime+1]-median<5.*rms06)      
-//       ){
-//     deltaA0[njumps0] = dsignal[itime]-dsignal[itime-1];
-//     deltaT0[njumps0] = itime-lastJump0;
-//     lastJump0 = itime;
-//     njumps0++;
-//       }
-//       if (TMath::Abs(dsignal[itime]-dsignal[itime-1])>30.*TMath::Max(1.,Double_t(rms06)) &&
-//       (dsignal[itime-1]-median<5.*rms06) 
-//       ) {
-//     deltaA1[njumps1] = dsignal[itime]-dsignal[itime-1];
-//     deltaT1[njumps1] = itime-lastJump1;
-//     lastJump1 = itime;
-//     njumps1++;
-//       }
-//       if (TMath::Abs(dsignal[itime]-dsignal[itime+1])>30.*TMath::Max(1.,Double_t(rms06)) &&
-//       (dsignal[itime+1]-median<5.*rms06) 
-//       ) {
-//     deltaA2[njumps2] = dsignal[itime]-dsignal[itime+1];
-//     deltaT2[njumps2] = itime-lastJump2;
-//     lastJump2 = itime;
-//     njumps2++;
-//       }
-//     }
-//     //
-//     if (njumps0>0 || njumps1>0 || njumps2>0){
-//       TGraph *graphDN0 = new TGraph(njumps0, deltaT0, deltaA0);
-//       TGraph *graphDN1 = new TGraph(njumps1, deltaT1, deltaA1);
-//       TGraph *graphDN2 = new TGraph(njumps2, deltaT2, deltaA2);
-//       (*fDebugStreamer)<<"SignalDN"<<    //digital - noise pads - or random sample of pads
-//     "TimeStamp="<<fTimeStamp<<
-//     "EventType="<<fEventType<<
-//     "Sector="<<uid[0]<<
-//     "Row="<<uid[1]<<
-//     "Pad="<<uid[2]<<
-//     "Graph="<<graph<<
-//     "Max="<<max<<
-//     "MaxPos="<<maxPos<<
-//     "Graph.="<<graph<<  
-//     "P0GraphDN0.="<<graphDN0<<
-//     "P1GraphDN1.="<<graphDN1<<
-//     "P2GraphDN2.="<<graphDN2<<
-//     //
-//     "Median="<<median<<
-//     "Mean="<<mean<<
-//     "RMS="<<rms<<      
-//     "Mean06="<<mean06<<
-//     "RMS06="<<rms06<<
-//     "Mean09="<<mean09<<
-//     "RMS09="<<rms09<<
-//     "\n";
-//       delete graphDN0;
-//       delete graphDN1;
-//       delete graphDN2;
-//     }
-//     delete graph;
-//   }
-
-  //
-  // NOISE STUDY  Fourier transform
-  //
-  TGraph * graph;
-  Bool_t random = (gRandom->Rndm()<0.0003);
-  if (((*fDebugStreamer)<<"SignalN").GetSize()<kMaxDebugSize)
-    if (max-median>kMin || rms06>1.*fParam->GetZeroSup() || random){
-    graph =new TGraph(nchannels, dtime, dsignal);
-    if (rms06>1.*fParam->GetZeroSup() || random){
-      //Double_t *input, Double_t threshold, Bool_t locMax, Double_t *freq, Double_t *re, Double_t *im, Double_t *mag, Double_t *phi);
-      Float_t * input = &(dsignal[fRecoParam->GetFirstBin()]);
-      Float_t freq[2000], re[2000], im[2000], mag[2000], phi[2000];
-      Int_t npoints = TransformFFT(input, -1,kFALSE, freq, re, im, mag, phi);
-      TGraph *graphMag0 = new TGraph(npoints, freq, mag);
-      TGraph *graphPhi0 = new TGraph(npoints, freq, phi);
-      npoints = TransformFFT(input, 0.5,kTRUE, freq, re, im, mag, phi);
-      TGraph *graphMag1 = new TGraph(npoints, freq, mag);
-      TGraph *graphPhi1 = new TGraph(npoints, freq, phi);
-      
-      (*fDebugStreamer)<<"SignalN"<<    //noise pads - or random sample of pads
-       "TimeStamp="<<fTimeStamp<<
-       "EventType="<<fEventType<<
-       "Sector="<<uid[0]<<
-       "Row="<<uid[1]<<
-       "Pad="<<uid[2]<<
-       "Graph.="<<graph<<
-       "Max="<<max<<
-       "MaxPos="<<maxPos<<
-       //
-       "Median="<<median<<
-       "Mean="<<mean<<
-       "RMS="<<rms<<      
-       "Mean06="<<mean06<<
-       "RMS06="<<rms06<<
-       "Mean09="<<mean09<<
-       "RMS09="<<rms09<<
-       // FFT part
-       "Mag0.="<<graphMag0<<
-       "Mag1.="<<graphMag1<<
-       "Phi0.="<<graphPhi0<<
-       "Phi1.="<<graphPhi1<<
-       "\n";
-      delete graphMag0;
-      delete graphMag1;
-      delete graphPhi0;
-      delete graphPhi1;
-    }
-    //
-    // Big signals dumping
-    //
-    
-    if (max-median>kMin &&maxPos>AliTPCReconstructor::GetRecoParam()->GetFirstBin()) 
-      (*fDebugStreamer)<<"SignalB"<<     // pads with signal
-       "TimeStamp="<<fTimeStamp<<
-       "EventType="<<fEventType<<
-       "Sector="<<uid[0]<<
-       "Row="<<uid[1]<<
-       "Pad="<<uid[2]<<
-       "Graph="<<graph<<
-       "Max="<<max<<
-       "MaxPos="<<maxPos<<     
-       //
-       "Median="<<median<<
-       "Mean="<<mean<<
-       "RMS="<<rms<<      
-       "Mean06="<<mean06<<
-       "RMS06="<<rms06<<
-       "Mean09="<<mean09<<
-       "RMS09="<<rms09<<
-       "\n";
-    delete graph;
-  }
-  
-  //
-  //
-  //  Central Electrode signal analysis  
-  //
-  Float_t ceQmax  =0, ceQsum=0, ceTime=0;
-  Float_t cemean  = mean06, cerms=rms06 ;
-  Int_t    cemaxpos= 0;
-  Float_t ceThreshold=5.*cerms;
-  Float_t ceSumThreshold=8.*cerms;
-  const Int_t    kCemin=5;  // range for the analysis of the ce signal +- channels from the peak
-  const Int_t    kCemax=5;
-  for (Int_t i=nchannels-2; i>nchannels/2; i--){
-    if ( (dsignal[i]-mean06)>ceThreshold && dsignal[i]>=dsignal[i+1] && dsignal[i]>=dsignal[i-1] ){
-      cemaxpos=i;
-      break;
-    }
-  }
-  if (cemaxpos!=0){
-    ceQmax = 0;
-    Int_t cemaxpos2=0;
-    for (Int_t i=cemaxpos-20; i<cemaxpos+5; i++){
-      if (i<0 || i>nchannels-1) continue;
-      Double_t val=dsignal[i]- cemean;
-      if (val>ceQmax){
-       cemaxpos2=i;
-       ceQmax = val;
-      }
-    }
-    cemaxpos = cemaxpos2;
-    for (Int_t i=cemaxpos-kCemin; i<cemaxpos+kCemax; i++){
-      if (i>0 && i<nchannels&&dsignal[i]- cemean>0){
-       Double_t val=dsignal[i]- cemean;
-       ceTime+=val*dtime[i];
-       ceQsum+=val;
-       if (val>ceQmax) ceQmax=val;
-      }
-    }
-    if (ceQmax&&ceQsum>ceSumThreshold) {
-      ceTime/=ceQsum;
-      (*fDebugStreamer)<<"Signalce"<<
-       "TimeStamp="<<fTimeStamp<<
-       "EventType="<<fEventType<<
-       "Sector="<<uid[0]<<
-       "Row="<<uid[1]<<
-       "Pad="<<uid[2]<<
-       "Max="<<ceQmax<<
-       "Qsum="<<ceQsum<<
-       "Time="<<ceTime<<
-       "RMS06="<<rms06<<
-       //
-       "\n";
-    }
-  }
-  // end of ce signal analysis
-  //
 
-  //
-  //  Gating grid signal analysis  
-  //
-  Double_t ggQmax  =0, ggQsum=0, ggTime=0;
-  Double_t ggmean  = mean06, ggrms=rms06 ;
-  Int_t    ggmaxpos= 0;
-  Double_t ggThreshold=5.*ggrms;
-  Double_t ggSumThreshold=8.*ggrms;
-
-  for (Int_t i=1; i<nchannels/4; i++){
-    if ( (dsignal[i]-mean06)>ggThreshold && dsignal[i]>=dsignal[i+1] && dsignal[i]>=dsignal[i-1] &&
-        (dsignal[i]+dsignal[i+1]+dsignal[i-1]-3*mean06)>ggSumThreshold){
-      ggmaxpos=i;
-      if (dsignal[i-1]>dsignal[i+1]) ggmaxpos=i-1;
-      break;
-    }
-  }
-  if (ggmaxpos!=0){
-      for (Int_t i=ggmaxpos-1; i<ggmaxpos+3; i++){       
-         if (i>0 && i<nchannels && dsignal[i]-ggmean>0){
-             Double_t val=dsignal[i]- ggmean;
-             ggTime+=val*dtime[i];
-             ggQsum+=val;
-             if (val>ggQmax) ggQmax=val;
-         }
-      }
-      if (ggQmax&&ggQsum>ggSumThreshold) {
-         ggTime/=ggQsum;
-         (*fDebugStreamer)<<"Signalgg"<<
-           "TimeStamp="<<fTimeStamp<<
-           "EventType="<<fEventType<<
-             "Sector="<<uid[0]<<
-             "Row="<<uid[1]<<
-             "Pad="<<uid[2]<<
-             "Max="<<ggQmax<<
-             "Qsum="<<ggQsum<<
-             "Time="<<ggTime<<
-             "RMS06="<<rms06<<
-             //
-             "\n";
-      }
+  TGraph * graph=0;
+  //
+  // Big signals dumping
+  //    
+  if (AliTPCReconstructor::StreamLevel()>0) {
+  if (max-median>kMin &&maxPos>AliTPCReconstructor::GetRecoParam()->GetFirstBin()) 
+    (*fDebugStreamer)<<"SignalB"<<     // pads with signal
+      "TimeStamp="<<fTimeStamp<<
+      "EventType="<<fEventType<<
+      "Sector="<<uid[0]<<
+      "Row="<<uid[1]<<
+      "Pad="<<uid[2]<<
+      "Graph="<<graph<<
+      "Max="<<max<<
+      "MaxPos="<<maxPos<<      
+      //
+      "Median="<<median<<
+      "Mean="<<mean<<
+      "RMS="<<rms<<      
+      "Mean06="<<mean06<<
+      "RMS06="<<rms06<<
+      "Mean09="<<mean09<<
+      "RMS09="<<rms09<<
+      "\n";
+  delete graph;  
   }
-  // end of gg signal analysis
-      
 
   delete [] dsignal;
   delete [] dtime;
@@ -1402,103 +1279,5 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
 
 
 
-void AliTPCclustererMI::DumpHistos(){
-  //
-  // Dump histogram information
-  //
-  if (!fAmplitudeHisto) return;
-  AliTPCROC * roc = AliTPCROC::Instance();
-  for (UInt_t isector=0; isector<AliTPCROC::Instance()->GetNSectors(); isector++){
-    TObjArray * array = (TObjArray*)fAmplitudeHisto->UncheckedAt(isector);
-    if (!array) continue;
-    for (UInt_t ipad = 0; ipad <(UInt_t)array->GetEntriesFast(); ipad++){
-      TH1F * histo = (TH1F*) array->UncheckedAt(ipad);
-      if (!histo) continue;
-      if (histo->GetEntries()<100) continue;
-      histo->Fit("gaus","q");
-      Float_t mean =  histo->GetMean();
-      Float_t rms  =  histo->GetRMS();
-      Float_t gmean = histo->GetFunction("gaus")->GetParameter(1);
-      Float_t gsigma = histo->GetFunction("gaus")->GetParameter(2);
-      Float_t gmeanErr = histo->GetFunction("gaus")->GetParError(1);
-      Float_t gsigmaErr = histo->GetFunction("gaus")->GetParError(2);
-      Float_t max = histo->GetFunction("gaus")->GetParameter(0);
-
-      // get pad number
-      UInt_t row=0, pad =0;
-      const UInt_t *indexes =roc->GetRowIndexes(isector);
-      for (UInt_t irow=0; irow<roc->GetNRows(isector); irow++){
-       if (indexes[irow]<=ipad){
-         row = irow;
-         pad = ipad-indexes[irow];
-       }
-      }      
-      Int_t rpad = pad - (AliTPCROC::Instance()->GetNPads(isector,row))/2;
-      //
-      (*fDebugStreamer)<<"Fit"<<
-       "TimeStamp="<<fTimeStamp<<
-       "EventType="<<fEventType<<
-       "Sector="<<isector<<
-       "Row="<<row<<
-       "Pad="<<pad<<
-       "RPad="<<rpad<<
-       "Max="<<max<<
-       "Mean="<<mean<<
-       "RMS="<<rms<<      
-       "GMean="<<gmean<<
-       "GSigma="<<gsigma<<
-       "GMeanErr="<<gmeanErr<<
-       "GSigmaErr="<<gsigmaErr<<
-       "\n";
-      if (array->UncheckedAt(ipad)) fDebugStreamer->StoreObject(array->UncheckedAt(ipad));
-    }
-  }
-}
 
 
-
-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)
-{
-  //
-  // calculate fourrie transform 
-  // return only frequncies with mag over threshold
-  // if locMax is spectified only freque with local maxima over theshold is returned 
-
-  if (! fFFTr2c) return kFALSE;
-  if (!freq) return kFALSE;
-
-  Int_t current=0;
-  Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin();
-  Double_t *in = new Double_t[nPoints];
-  Double_t *rfft = new Double_t[nPoints];
-  Double_t *ifft = new Double_t[nPoints];
-  for (Int_t i=0; i<nPoints; i++){in[i]=input[i];}
-  fFFTr2c->SetPoints(in);
-  fFFTr2c->Transform();
-  fFFTr2c->GetPointsComplex(rfft, ifft);
-  for (Int_t i=3; i<nPoints/2-3; i++){
-    Float_t lmag =  TMath::Sqrt(rfft[i]*rfft[i]+ifft[i]*ifft[i])/nPoints;
-    if (lmag<threshold) continue;
-    if (locMax){
-      if ( TMath::Sqrt(rfft[i-1]*rfft[i-1]+ifft[i-1]*ifft[i-1])/nPoints>lmag) continue;
-      if ( TMath::Sqrt(rfft[i+1]*rfft[i+1]+ifft[i+1]*ifft[i+1])/nPoints>lmag) continue;
-      if ( TMath::Sqrt(rfft[i-2]*rfft[i-2]+ifft[i-2]*ifft[i-2])/nPoints>lmag) continue;
-      if ( TMath::Sqrt(rfft[i+2]*rfft[i+2]+ifft[i+2]*ifft[i+2])/nPoints>lmag) continue;
-      if ( TMath::Sqrt(rfft[i-3]*rfft[i-3]+ifft[i-3]*ifft[i-3])/nPoints>lmag) continue;
-      if ( TMath::Sqrt(rfft[i+3]*rfft[i+3]+ifft[i+3]*ifft[i+3])/nPoints>lmag) continue;
-    }
-    
-    freq[current] = Float_t(i)/Float_t(nPoints);
-    //
-    re[current] = rfft[i];
-    im[current] = ifft[i];
-    mag[current]=lmag;
-    phi[current]=TMath::ATan2(ifft[i],rfft[i]);
-    current++;
-  }
-  delete [] in;
-  delete [] rfft;
-  delete [] ifft;
-  return current;
-}
-