]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDclusterizerV1.cxx
Speed up database access in AliTRDclusterizerV1::Transform()
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterizerV1.cxx
index 6f8f68f09fb2a7842ca81f3b1db7ee0b91d29cfa..459342e48cf1f364444802f7581dc8e2eff98893 100644 (file)
@@ -45,6 +45,9 @@
 #include "AliTRDCommonParam.h"
 #include "AliTRDcluster.h"
 
+#include "Cal/AliTRDCalROC.h"
+#include "Cal/AliTRDCalDet.h"
+
 ClassImp(AliTRDclusterizerV1)
 
 //_____________________________________________________________________________
@@ -177,10 +180,14 @@ Bool_t AliTRDclusterizerV1::MakeClusters()
 
   // Get the geometry
   AliTRDgeometry *geo            = AliTRDgeometry::GetGeometry(fRunLoader);  
+  if (!geo) {
+    AliWarning("Loading default TRD geometry!");
+    geo = new AliTRDgeometry();
+  }
 
   AliTRDcalibDB  *calibration    = AliTRDcalibDB::Instance();
   if (!calibration) {
-    AliError("No AliTRDcalibDB instance available\n");
+    AliFatal("No AliTRDcalibDB instance available\n");
     return kFALSE;  
   }
   
@@ -202,13 +209,18 @@ Bool_t AliTRDclusterizerV1::MakeClusters()
     return kFALSE;
   }
 
-  // ADC threshols
+  // ADC thresholds
   Float_t ADCthreshold   = simParam->GetADCthreshold();
   // Threshold value for the maximum
   Float_t maxThresh      = recParam->GetClusMaxThresh();
   // Threshold value for the digit signal
   Float_t sigThresh      = recParam->GetClusSigThresh();
 
+  // Detector wise calibration object for t0
+  const AliTRDCalDet *calT0Det         = calibration->GetT0Det();
+  // Detector wise calibration object for the gain factors
+  const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
+
   // Iteration limit for unfolding procedure
   const Float_t kEpsilon = 0.01;             
   const Int_t   kNclus   = 3;  
@@ -261,6 +273,15 @@ Bool_t AliTRDclusterizerV1::MakeClusters()
 
         AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham);
 
+       // Calibration object with pad wise values for t0
+        AliTRDCalROC *calT0ROC              = calibration->GetT0ROC(idet);
+       // Calibration object with pad wise values for the gain factors
+        AliTRDCalROC *calGainFactorROC      = calibration->GetGainFactorROC(idet);
+        // Calibration value for chamber wise t0
+        Float_t       calT0DetValue         = calT0Det->GetValue(idet);
+        // Calibration value for chamber wise gain factor
+        Float_t       calGainFactorDetValue = calGainFactorDet->GetValue(idet);
+
         Int_t nClusters      = 0;
         Int_t nClusters2pad  = 0;
         Int_t nClusters3pad  = 0;
@@ -271,8 +292,13 @@ Bool_t AliTRDclusterizerV1::MakeClusters()
        // Apply the gain and the tail cancelation via digital filter
         AliTRDdataArrayF *digitsOut = new AliTRDdataArrayF(digitsIn->GetNrow()
                                                           ,digitsIn->GetNcol()
-                                                          ,digitsIn->GetNtime());
-        Transform(digitsIn,digitsOut,idet,nRowMax,nColMax,nTimeTotal,ADCthreshold);
+                                                          ,digitsIn->GetNtime()); 
+        Transform(digitsIn
+                 ,digitsOut
+                 ,nRowMax,nColMax,nTimeTotal
+                 ,ADCthreshold
+                 ,calGainFactorROC
+                 ,calGainFactorDetValue);
 
        // Input digits are not needed any more
         digitsIn->Compress(1,0);
@@ -282,19 +308,23 @@ Bool_t AliTRDclusterizerV1::MakeClusters()
          for ( col = 2;  col <  nColMax;    col++) {
             for (time = 0; time < nTimeTotal; time++) {
 
-              Float_t signalL = TMath::Abs(digitsOut->GetDataUnchecked(row,col  ,time));
               Float_t signalM = TMath::Abs(digitsOut->GetDataUnchecked(row,col-1,time));
-              Float_t signalR = TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time));
  
              // Look for the maximum
               if (signalM >= maxThresh) {
+
+                Float_t signalL = TMath::Abs(digitsOut->GetDataUnchecked(row,col  ,time));
+                Float_t signalR = TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time));
+
                 if ((TMath::Abs(signalL) <= signalM) && 
-                    (TMath::Abs(signalR) <= signalM)) {
-                 if ((TMath::Abs(signalL) + TMath::Abs(signalR)) > sigThresh) {
+                    (TMath::Abs(signalR) <  signalM)) {
+                 if ((TMath::Abs(signalL) >= sigThresh) ||
+                     (TMath::Abs(signalR) >= sigThresh)) {
                     // Maximum found, mark the position by a negative signal
                     digitsOut->SetDataUnchecked(row,col-1,time,-signalM);
                  }
                }
+
              }
 
             }
@@ -451,8 +481,9 @@ Bool_t AliTRDclusterizerV1::MakeClusters()
                 // Calculate the position and the error
                //              
 
-                // Correct for t0
-               Int_t    clusterTimeBin = TMath::Nint(time - calibration->GetT0(idet,col,row));
+                // Correct for t0 (sum of chamber and pad wise values !!!)
+                Float_t  calT0ROCValue  = calT0ROC->GetValue(col,row);
+               Int_t    clusterTimeBin = TMath::Nint(time - (calT0DetValue + calT0ROCValue));
                 Double_t colSize        = padPlane->GetColSize(col);
                 Double_t rowSize        = padPlane->GetRowSize(row);
 
@@ -653,9 +684,10 @@ Double_t AliTRDclusterizerV1::Unfold(Double_t eps, Int_t plane, Double_t *padSig
 //_____________________________________________________________________________
 void AliTRDclusterizerV1::Transform(AliTRDdataArrayI *digitsIn
                                  , AliTRDdataArrayF *digitsOut
-                                 , Int_t idet, Int_t nRowMax
-                                 , Int_t nColMax, Int_t nTimeTotal
-                                 , Float_t ADCthreshold)
+                                 , Int_t nRowMax, Int_t nColMax, Int_t nTimeTotal
+                                 , Float_t ADCthreshold
+                                 , AliTRDCalROC *calGainFactorROC
+                                 , Float_t calGainFactorDetValue)
 {
   //
   // Apply gain factor
@@ -671,30 +703,22 @@ void AliTRDclusterizerV1::Transform(AliTRDdataArrayI *digitsIn
     AliError("No AliTRDRecParam instance available\n");
     return;
   }
-  AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
-  if (!calibration) {
-    AliError("No AliTRDcalibDB instance available\n");
-    return;  
-  }
 
   Double_t *inADC  = new Double_t[nTimeTotal];  // ADC data before tail cancellation
   Double_t *outADC = new Double_t[nTimeTotal];  // ADC data after tail cancellation
 
-  AliDebug(1,Form("Tail cancellation (nExp = %d) for detector %d.\n"
-                ,recParam->GetTCnexp(),idet));
-
   for (iRow  = 0; iRow  <  nRowMax;   iRow++ ) {
     for (iCol  = 0; iCol  <  nColMax;   iCol++ ) {
 
+      Float_t  calGainFactorROCValue = calGainFactorROC->GetValue(iCol,iRow);
+      Double_t gain                  = calGainFactorDetValue 
+                                     * calGainFactorROCValue;
+
       for (iTime = 0; iTime < nTimeTotal; iTime++) {
 
        //
        // Add gain
        //
-       Double_t gain = calibration->GetGainFactor(idet,iCol,iRow);
-       if (gain == 0.0) {
-         AliError("Not a valid gain\n");
-       }
        inADC[iTime]   = digitsIn->GetDataUnchecked(iRow,iCol,iTime);
         inADC[iTime]  /= gain;
         outADC[iTime]  = inADC[iTime];