]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDclusterizer.cxx
Update of the VZERO offline trigger: 1. New slewing correction with only 2 parameters...
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterizer.cxx
index 4cb3915e9f2010efdba267436c1bf3fff6fdbe8a..3f06fa88c265d2d6e46589c11095b471c4e79bf0 100644 (file)
@@ -453,23 +453,29 @@ Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
       ioArray->AddLast(c);
     }
     fClusterTree->Fill();
+    ioArray->Clear();
   } else {
-    
-    Int_t detOld = -1;
+    Int_t detOld = -1, nw(0);
     for (Int_t i = 0; i < nRecPoints; i++) {
       AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i);
       if(c->GetDetector() != detOld){
+        nw += ioArray->GetEntriesFast();
         fClusterTree->Fill();
         ioArray->Clear();
         detOld = c->GetDetector();
       } 
       ioArray->AddLast(c);
     }
+    if(ioArray->GetEntriesFast()){
+      nw += ioArray->GetEntriesFast();
+      fClusterTree->Fill();
+      ioArray->Clear();
+    }
+    AliDebug(2, Form("Clusters FOUND[%d] WRITTEN[%d] STATUS[%s]", nRecPoints, nw, nw==nRecPoints?"OK":"FAILED"));
   }
   delete ioArray;
 
   return kTRUE;  
-
 }
 
 //_____________________________________________________________________________
@@ -610,6 +616,7 @@ Bool_t AliTRDclusterizer::MakeClusters()
     fDigitsManager->RemoveDictionaries(i);      
     fDigitsManager->ClearIndexes(i);  
   }
+  fReconstructor->SetDigitsParam(fDigitsManager->GetDigitsParam());
   
   if(fReconstructor->IsWritingClusters()) WriteClusters(-1);
 
@@ -660,10 +667,12 @@ Bool_t AliTRDclusterizer::Raw2ClustersChamber(AliRawReader *rawReader)
   else
     fRawStream->SetReader(rawReader);
 
-  if(fReconstructor->IsHLT())
+  if(fReconstructor->IsHLT()){
     fRawStream->SetSharedPadReadout(kFALSE);
+    fRawStream->SetNoErrorWarning();
+  }
 
-  AliInfo(Form("Stream version: %s", fRawStream->IsA()->GetName()));
+  AliDebug(1,Form("Stream version: %s", fRawStream->IsA()->GetName()));
   
   Int_t det    = 0;
   while ((det = fRawStream->NextChamber(fDigitsManager,fTrackletContainer)) >= 0){
@@ -677,6 +686,7 @@ Bool_t AliTRDclusterizer::Raw2ClustersChamber(AliRawReader *rawReader)
     if (!fReconstructor->IsWritingTracklets()) continue;
     if (*(fTrackletContainer[0]) > 0 || *(fTrackletContainer[1]) > 0) WriteTracklets(det);
   }
+  fReconstructor->SetDigitsParam(fDigitsManager->GetDigitsParam());
   
   if (fTrackletContainer){
     delete [] fTrackletContainer[0];
@@ -690,6 +700,8 @@ Bool_t AliTRDclusterizer::Raw2ClustersChamber(AliRawReader *rawReader)
   if(!TestBit(knewDM)){
     delete fDigitsManager;
     fDigitsManager = NULL;
+    delete fRawStream;
+    fRawStream = NULL;
   }
 
   AliInfo(Form("Number of found clusters : %d", fNoOfClusters)); 
@@ -791,6 +803,8 @@ Bool_t AliTRDclusterizer::MakeClusters(Int_t det)
     return kFALSE;
   }
 
+  AliDebug(2, Form("Det[%d] @ Sec[%d] Stk[%d] Ly[%d]", fDet, isector, istack, fLayer));
+
   // TRD space point transformation
   fTransform->SetDetector(det);
 
@@ -805,6 +819,14 @@ Bool_t AliTRDclusterizer::MakeClusters(Int_t det)
   //Int_t nRowMax    = fDigits->GetNrow();
   fTimeTotal = fDigits->GetNtime();
 
+  // Check consistency between OCDB and raw data
+  Int_t nTimeOCDB = calibration->GetNumberOfTimeBinsDCS();
+  if ((nTimeOCDB  >         -1) &&
+      (fTimeTotal != nTimeOCDB)) {
+    AliError(Form("Number of timebins does not match OCDB value (RAW[%d] OCDB[%d])"
+                ,fTimeTotal,calibration->GetNumberOfTimeBinsDCS()));
+  }
+
   // Detector wise calibration object for the gain factors
   const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
   // Calibration object with pad wise values for the gain factors
@@ -896,6 +918,8 @@ Bool_t AliTRDclusterizer::IsMaximum(const MaxStruct &Max, UChar_t &padStatus, Sh
   if(!(status[0] | status[1] | status[2])) {//all pads are good
     if ((Signals[2] <= Signals[1]) && (Signals[0] <  Signals[1])) {
       if ((Signals[2] >= fSigThresh) || (Signals[0] >= fSigThresh)) {
+       if(Signals[0]<0)Signals[0]=0;
+       if(Signals[2]<0)Signals[2]=0;
         Float_t  noiseSumThresh = fMinLeftRightCutSigma
           * fCalNoiseDetValue
           * fCalNoiseROC->GetValue(Max.col, Max.row);
@@ -905,6 +929,8 @@ Bool_t AliTRDclusterizer::IsMaximum(const MaxStruct &Max, UChar_t &padStatus, Sh
       }
     }
   } else { // at least one of the pads is bad, and reject candidates with more than 1 problematic pad
+    if(Signals[0]<0)Signals[0]=0;
+    if(Signals[2]<0)Signals[2]=0;
     if (status[2] && (!(status[0] || status[1])) && Signals[1] > Signals[0] && Signals[0] >= fSigThresh) { 
       Signals[2]=0;
       SetPadStatus(status[2], padStatus);
@@ -1220,44 +1246,42 @@ void AliTRDclusterizer::TailCancelation()
   Double_t *inADC = new Double_t[fTimeTotal];  // ADC data before tail cancellation
   Double_t *outADC = new Double_t[fTimeTotal];  // ADC data after tail cancellation
 
-  fIndexes->ResetCounters();
   TTreeSRedirector *fDebugStream = fReconstructor->GetDebugStream(AliTRDrecoParam::kClusterizer);
+  Bool_t debugStreaming = fReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kClusterizer) > 7 && fReconstructor->IsDebugStreaming();
   while(fIndexes->NextRCIndex(iRow, iCol))
     {
       Bool_t corrupted = kFALSE;
+      if (fCalPadStatusROC->GetStatus(iCol, iRow)) corrupted = kTRUE;
+
+      // Save data into the temporary processing array and substract the baseline,
+      // since DeConvExp does not expect a baseline
       for (iTime = 0; iTime < fTimeTotal; iTime++) 
-        {        
-          // Apply gain gain factor
-          inADC[iTime]   = fDigits->GetData(iRow,iCol,iTime);
-          if (fCalPadStatusROC->GetStatus(iCol, iRow)) corrupted = kTRUE;
-          outADC[iTime]  = inADC[iTime];
-         if(fReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kClusterizer) > 7 && fReconstructor->IsDebugStreaming()){
-           (*fDebugStream) << "TailCancellation"
-                             << "col="  << iCol
-                             << "row="  << iRow
-                             << "time=" << iTime
-                             << "inADC=" << inADC[iTime]
-                             << "outADC=" << outADC[iTime]
-                             << "corrupted=" << corrupted
-                             << "\n";
-         }
-        }
+       inADC[iTime]   = fDigits->GetData(iRow,iCol,iTime)-fBaseline;
+          
+      if(debugStreaming){
+       for (iTime = 0; iTime < fTimeTotal; iTime++) 
+         (*fDebugStream) << "TailCancellation"
+                         << "col="  << iCol
+                         << "row="  << iRow
+                         << "time=" << iTime
+                         << "inADC=" << inADC[iTime]
+                         << "outADC=" << outADC[iTime]
+                         << "corrupted=" << corrupted
+                         << "\n";
+      }
+      
       if (!corrupted)
         {
           // Apply the tail cancelation via the digital filter
           // (only for non-coorupted pads)
          DeConvExp(&inADC[0],&outADC[0],fTimeTotal,fReconstructor->GetRecoParam() ->GetTCnexp());
         }
+      else memcpy(&outADC[0],&inADC[0],fTimeTotal*sizeof(inADC[0]));
 
-      for(iTime = 0; iTime < fTimeTotal; iTime++)//while (fIndexes->NextTbinIndex(iTime))
-        {
-          // Store the amplitude of the digit if above threshold
-          if (outADC[iTime] > 0)
-           fDigits->SetData(iRow,iCol,iTime,TMath::Nint(outADC[iTime]));
-         else
-           fDigits->SetData(iRow,iCol,iTime,0);
-        } // while itime
-
+      // Save tailcancalled data and add the baseline
+      for(iTime = 0; iTime < fTimeTotal; iTime++)
+       fDigits->SetData(iRow,iCol,iTime,(Short_t)(outADC[iTime] + fBaseline + 0.5));
+      
     } // while irow icol
 
   delete [] inADC;