]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCclustererMI.cxx
New check for bad SDD modules (F. Prino)
[u/mrichter/AliRoot.git] / TPC / AliTPCclustererMI.cxx
index afd6b76b86819dc03f16c99ca7a26c1450ce999f..7fe62b1fb1681614ad92a6d53e6fa52a009fd52e 100644 (file)
@@ -25,6 +25,7 @@
 //  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 
@@ -43,6 +44,7 @@
 #include <TGraph.h>
 #include <TH1F.h>
 #include <TObjArray.h>
+#include <TClonesArray.h>
 #include <TRandom.h>
 #include <TTree.h>
 #include <TTreeStream.h>
@@ -95,13 +97,16 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoPar
   fInput(0),
   fOutput(0),
   fOutputArray(0),
+  fOutputClonesArray(0),
   fRowCl(0),
   fRowDig(0),
   fParam(0),
   fNcluster(0),
+  fNclusters(0),
   fDebugStreamer(0),
   fRecoParam(0),
-  fBDumpSignal(kFALSE)
+  fBDumpSignal(kFALSE),
+  fBClonesArray(kFALSE)
 {
   //
   // COSNTRUCTOR
@@ -117,7 +122,11 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoPar
     fRecoParam = AliTPCReconstructor::GetRecoParam();
     if (!fRecoParam)  fRecoParam = AliTPCRecoParam::GetLowFluxParam();
   }
-  fDebugStreamer = new TTreeSRedirector("TPCsignal.root");
+  if(AliTPCReconstructor::StreamLevel()>0) {
+    fDebugStreamer = new TTreeSRedirector("TPCsignal.root");
+  }
+
   //  Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin();
   fRowCl= new AliTPCClustersRow();
   fRowCl->SetClass("AliTPCclusterMI");
@@ -148,13 +157,16 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCclustererMI &param)
   fInput(0),
   fOutput(0),
   fOutputArray(0),
+  fOutputClonesArray(0),
   fRowCl(0),
   fRowDig(0),
   fParam(0),
   fNcluster(0),
+  fNclusters(0),
   fDebugStreamer(0),
   fRecoParam(0),
-  fBDumpSignal(kFALSE)
+  fBDumpSignal(kFALSE),
+  fBClonesArray(kFALSE)
 {
   //
   // dummy
@@ -180,6 +192,10 @@ AliTPCclustererMI::~AliTPCclustererMI(){
     //fOutputArray->Delete();
     delete fOutputArray;
   }
+  if (fOutputClonesArray){
+    fOutputClonesArray->Delete();
+    delete fOutputClonesArray;
+  }
 }
 
 void AliTPCclustererMI::SetInput(TTree * tree)
@@ -219,10 +235,10 @@ void AliTPCclustererMI::FillRow(){
   //          TObjArray
   //
   if (fOutput) fOutput->Fill();
-  if (!fOutput){
+  if (!fOutput && !fBClonesArray){
     //
     if (!fOutputArray) fOutputArray = new TObjArray(fParam->GetNRowsTotal());
-    if (fRowCl) fOutputArray->AddAt(fRowCl->Clone(), fRowCl->GetID());
+    if (fRowCl && fRowCl->GetArray()->GetEntriesFast()>0) fOutputArray->AddAt(fRowCl->Clone(), fRowCl->GetID());
   }
 }
 
@@ -393,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]);
 }
 
 
@@ -522,8 +536,6 @@ void AliTPCclustererMI::UnfoldCluster(Float_t * matrix2[7], Float_t recmatrix[5]
          }
       }
   }
-  if (gDebug>4) 
-    printf("%f\n", recmatrix[2][2]);
   
 }
 
@@ -591,10 +603,8 @@ 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 (fSector%36>17){
+    c.SetY(-c.GetY());
   }
 
   if (ki<=1 || ki>=fMaxPad-1 || kj==1 || kj==fMaxTime-2) {
@@ -603,8 +613,17 @@ void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c, Float_t * matrix, Int_t p
   if (fLoop==2) c.SetType(100);
   if (!AcceptCluster(&c)) return;
 
-  TClonesArray * arr = fRowCl->GetArray();
-  AliTPCclusterMI * cl = new ((*arr)[fNcluster]) AliTPCclusterMI(c);
+  // 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;
@@ -705,6 +724,7 @@ void AliTPCclustererMI::Digits2Clusters()
     FillRow();
     fRowCl->GetArray()->Clear();    
     nclusters+=fNcluster;    
+
     delete[] fBins;
     delete[] fSigBins;
   }  
@@ -736,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();
@@ -769,14 +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
-    //check the presence of the calibration
-    if (!noiseROC ||!pedestalROC ) {
-      AliError(Form("Missing calibration per sector\t%d\n",fSector));
-      continue;
-    }
     Int_t nRows = 0;
     Int_t nDDLs = 0, indexDDL = 0;
     if (fSector < kNIS) {
@@ -792,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)
@@ -804,14 +835,13 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
       allNSigBins[iRow] = 0;
     }
     
-    // Loas the raw data for corresponding DDLs
-    rawReader->Reset();
-    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()));
@@ -940,6 +970,7 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
              Double_t gx[3]={x[0],x[1],x[2]};
              trafo.RotatedGlobal2Global(fSector,gx);
              
+              if (AliTPCReconstructor::StreamLevel()>0) {
              (*fDebugStreamer)<<"Digits"<<
                "sec="<<fSector<<
                "row="<<iRow<<
@@ -953,6 +984,7 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
                "gy="<<gx[1]<<
                "gz="<<gx[2]<<
                "\n";
+             }
            }
          }
        }
@@ -978,12 +1010,14 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
       fNSigBins = allNSigBins[fRow];
 
       FindClusters(noiseROC);
+
       FillRow();
-      fRowCl->GetArray()->Clear();    
-      nclusters += fNcluster;    
+      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];
@@ -993,12 +1027,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);
-  }else{
-    Info("Digits2Clusters", "Event\t%d\tNumber of found clusters : %d\n",*(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)
@@ -1055,15 +1093,18 @@ void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
 
 Bool_t AliTPCclustererMI::AcceptCluster(AliTPCclusterMI *cl){
   //
-  // Currently hack to filter digital noise (13.06.2008)
+  // 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;
-
 }
 
 
@@ -1161,7 +1202,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]<<
@@ -1180,6 +1222,7 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
     "RMSCalib="<<rmsCalib<<
     "PedCalib="<<pedestalCalib<<
     "\n";
+    }
   //
   // fill pedestal histogram
   //
@@ -1198,6 +1241,7 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
   //
   // Big signals dumping
   //    
+  if (AliTPCReconstructor::StreamLevel()>0) {
   if (max-median>kMin &&maxPos>AliTPCReconstructor::GetRecoParam()->GetFirstBin()) 
     (*fDebugStreamer)<<"SignalB"<<     // pads with signal
       "TimeStamp="<<fTimeStamp<<
@@ -1218,6 +1262,7 @@ Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t
       "RMS09="<<rms09<<
       "\n";
   delete graph;  
+  }
 
   delete [] dsignal;
   delete [] dtime;