]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDdigitizer.cxx
- add protection against invalid sector/stack information in on-line track matching
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitizer.cxx
index 8774694712cad055d72a3d9e56b48d990c07e874..07413d5c161ba664b62a7b4fcd10703714f5a401 100644 (file)
@@ -197,8 +197,10 @@ AliTRDdigitizer::~AliTRDdigitizer()
 
   // s-digitsmanager will be deleted via list
   fSDigitsManager     = 0;
-  fSDigitsManagerList->Delete();
-  delete fSDigitsManagerList;
+  if (fSDigitsManagerList) {
+    fSDigitsManagerList->Delete();
+    delete fSDigitsManagerList;
+  }
   fSDigitsManagerList = 0;
 
   delete [] fMasks;
@@ -622,8 +624,26 @@ Bool_t AliTRDdigitizer::MakeDigits()
     fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
   }
   else {
+    // Get the OCDB values
+    Int_t nTB = calibration->GetNumberOfTimeBinsDCS();
+    if (nTB < 0) { // Currently -1 gets returned for "undefined" and "mixed",
+                   // one might go back to -1 undefined and -2 mixed?
+      AliError("No useful DCS information available for this run! Using standard values.");
+      // // We fall back to the standard OCDB object, 
+      // // cache the current run number..
+      // Long64_t run = calibration->GetRun();
+      // calibration->SetRun(0);
+      // nTB = calibration->GetNumberOfTimeBinsDCS();
+      // // ..to set it again
+      // calibration->SetRun(run);
+      // // If there's no standard OCDB object, we can still fail
+      // if (nTB < 0) {
+      //       AliFatal("No standard object found in the OCDB!");
+      // }
+      nTB = AliTRDSimParam::Instance()->GetNTimeBins();
+    }
     // Save the values for the raw data headers
-    fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(calibration->GetNumberOfTimeBinsDCS());
+    fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(nTB);
   }
 
   // Save the values for the raw data headers
@@ -646,7 +666,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
         (nhit[det] > 0)) {
 
       signals = new AliTRDarraySignal();
-         
+
       // Convert the hits of the current detector to detector signals
       if (!ConvertHits(det,hits[det],nhit[det],signals)) {
        AliError(Form("Conversion of hits failed for detector=%d",det));
@@ -1013,7 +1033,7 @@ Bool_t AliTRDdigitizer::ConvertHits(Int_t det
       colE       = padPlane->GetPadColNumber(locC+offsetTilt);
       if (colE < 0) continue;         
       colOffset  = padPlane->GetPadColOffset(colE,locC+offsetTilt);
-         
+
       // Also re-retrieve drift velocity because col and row may have changed
       driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
       Float_t t0    = calT0DetValue     + calT0ROC->GetValue(colE,rowE);
@@ -1171,7 +1191,7 @@ Bool_t AliTRDdigitizer::ConvertSignals(Int_t det, AliTRDarraySignal *signals)
   }
 
   // Compress the arrays
-  CompressOutputArrays(det);   
+  CompressOutputArrays(det);
 
   return kTRUE;
 
@@ -1237,7 +1257,7 @@ Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals)
   AliTRDCalROC       *calGainFactorROC      = 0x0;
   Float_t             calGainFactorDetValue = 0.0;
 
-  AliTRDarrayADC     *digits = 0x0;
+  AliTRDarrayADC     *digits                = 0x0;
 
   if (!signals) {
     AliError(Form("Signals array for detector %d does not exist\n",det));
@@ -1268,14 +1288,17 @@ Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals)
   calGainFactorROC      = calibration->GetGainFactorROC(det);
   calGainFactorDetValue = calGainFactorDet->GetValue(det);
 
-  // Get the online gain factors
-  //AliTRDCalOnlineGainTableROC *onlineGainFactorROC 
-  //  = calibration->GetOnlineGainTableROC(det);
-
   // Create the digits for this chamber
   for (row  = 0; row  <  nRowMax; row++ ) {
     for (col  = 0; col  <  nColMax; col++ ) {
 
+      // halfchamber masking
+      Int_t iMcm            = (Int_t)(col/18); // current group of 18 col pads
+      Int_t halfchamberside = (iMcm>3 ? 1 : 0); // 0=Aside, 1=Bside
+      // Halfchambers that are switched off, masked by calibration
+      if (calibration->IsHalfChamberNoData(det, halfchamberside)) 
+       continue;
+
       // Check whether pad is masked
       // Bridged pads are not considered yet!!!
       if (calibration->IsPadMasked(det,col,row) || 
@@ -1284,8 +1307,8 @@ Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals)
       }
 
       // The gain factors
-      Float_t padgain = calGainFactorDetValue 
-                      * calGainFactorROC->GetValue(col,row);
+      Float_t padgain    = calGainFactorDetValue 
+                         * calGainFactorROC->GetValue(col,row);
       if (padgain <= 0) {
         AliError(Form("Not a valid gain %f, %d %d %d",padgain,det,col,row));
       }
@@ -1368,12 +1391,20 @@ Bool_t AliTRDdigitizer::Signal2SDigits(Int_t det, AliTRDarraySignal *signals)
   // Create the sdigits for this chamber
   for (row  = 0; row  <  nRowMax; row++ ) {
     for (col  = 0; col  <  nColMax; col++ ) {
-      for (time = 0; time < nTimeTotal; time++) {         
+
+      // halfchamber masking
+      Int_t iMcm            = (Int_t)(col/18); // current group of 18 col pads
+      Int_t halfchamberside = (iMcm>3 ? 1 : 0); // 0=Aside, 1=Bside
+      // Halfchambers that are switched off, masked by calibration
+      if (calibration->IsHalfChamberNoData(det, halfchamberside))
+       continue;
+
+      for (time = 0; time < nTimeTotal; time++) {
         digits->SetData(row,col,time,signals->GetData(row,col,time));
       } // for: time
     } // for: col
   } // for: row
-  
+
   return kTRUE;
 
 }
@@ -1424,6 +1455,7 @@ Bool_t AliTRDdigitizer::Digits2SDigits(AliTRDdigitsManager * const manDig
   //                      / convert;
 
   // The gainfactor calibration objects
+  // Not used since these digits are supposed to be from real raw data
   //const AliTRDCalDet *calGainFactorDet      = calibration->GetGainFactorDet();  
   //AliTRDCalROC       *calGainFactorROC      = 0;
   //Float_t             calGainFactorDetValue = 0.0;
@@ -1942,21 +1974,21 @@ void AliTRDdigitizer::RunDigitalProcessing(Int_t det)
     return;
 
   //Call the methods in the mcm class using the temporary array as input  
-  for(Int_t rob = 0; rob < digits->GetNrow() / 2; rob++)
-  {
-    for(Int_t mcm = 0; mcm < 16; mcm++)
-    {
-      fMcmSim->Init(det, rob, mcm); 
-      fMcmSim->SetDataByPad(digits, fDigitsManager);
-      fMcmSim->Filter();
-      if (feeParam->GetTracklet()) {
-        fMcmSim->Tracklet();
-        fMcmSim->StoreTracklets();
+  // process the data in the same order as in hardware
+  for (Int_t side = 0; side <= 1; side++) {
+    for(Int_t rob = side; rob < digits->GetNrow() / 2; rob += 2) {
+      for(Int_t mcm = 0; mcm < 16; mcm++) {
+       fMcmSim->Init(det, rob, mcm);
+       fMcmSim->SetDataByPad(digits, fDigitsManager);
+       fMcmSim->Filter();
+       if (feeParam->GetTracklet()) {
+         fMcmSim->Tracklet();
+         fMcmSim->StoreTracklets();
+       }
+       fMcmSim->ZSMapping();
+       fMcmSim->WriteData(digits);
       }
-      fMcmSim->ZSMapping();
-      fMcmSim->WriteData(digits);
     }
   }
-
 }