]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDdigitizer.cxx
Fixing coverity 17819
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitizer.cxx
index 0e6a67fb9e46eff76eae71da26229294c79abd86..9bdc9d0fdae293fc2fde80d82626d2814849e72e 100644 (file)
@@ -47,7 +47,7 @@
 #include "AliRunLoader.h"
 #include "AliLoader.h"
 #include "AliConfig.h"
-#include "AliRunDigitizer.h"
+#include "AliDigitizationInput.h"
 #include "AliRunLoader.h"
 #include "AliLoader.h"
 #include "AliLog.h"
@@ -70,6 +70,7 @@
 
 #include "Cal/AliTRDCalROC.h"
 #include "Cal/AliTRDCalDet.h"
+#include "Cal/AliTRDCalOnlineGainTableROC.h"
 
 ClassImp(AliTRDdigitizer)
 
@@ -118,9 +119,9 @@ AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title)
 }
 
 //_____________________________________________________________________________
-AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager
+AliTRDdigitizer::AliTRDdigitizer(AliDigitizationInput* digInput
                                , const Text_t *name, const Text_t *title)
-  :AliDigitizer(manager,name,title)
+  :AliDigitizer(digInput,name,title)
   ,fRunLoader(0)
   ,fDigitsManager(0)
   ,fSDigitsManager(0)
@@ -141,8 +142,8 @@ AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager
 }
 
 //_____________________________________________________________________________
-AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager)
-  :AliDigitizer(manager,"AliTRDdigitizer","TRD digitizer")
+AliTRDdigitizer::AliTRDdigitizer(AliDigitizationInput* digInput)
+  :AliDigitizer(digInput,"AliTRDdigitizer","TRD digitizer")
   ,fRunLoader(0)
   ,fDigitsManager(0)
   ,fSDigitsManager(0)
@@ -261,7 +262,7 @@ void AliTRDdigitizer::Copy(TObject &d) const
 }
 
 //_____________________________________________________________________________
-void AliTRDdigitizer::Exec(const Option_t * const option)
+void AliTRDdigitizer::Digitize(const Option_t* option)
 {
   //
   // Executes the merging
@@ -284,26 +285,26 @@ void AliTRDdigitizer::Exec(const Option_t * const option)
     AliDebug(1,"AliRun object found on file.");
   }
   else {
-    inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
+    inrl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(0));
     inrl->LoadgAlice();
     gAlice = inrl->GetAliRun();
     if (!gAlice) {
-      AliError("Could not find AliRun object.")
+      AliError("Could not find AliRun object.");
       return;
     }
   }
                                                                            
-  Int_t nInput = fManager->GetNinputs();
+  Int_t nInput = fDigInput->GetNinputs();
   fMasks       = new Int_t[nInput];
   for (iInput = 0; iInput < nInput; iInput++) {
-    fMasks[iInput] = fManager->GetMask(iInput);
+    fMasks[iInput] = fDigInput->GetMask(iInput);
   }
 
   //
   // Initialization
   //
 
-  AliRunLoader *orl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+  AliRunLoader *orl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
 
   if (InitDetector()) {
 
@@ -336,7 +337,7 @@ void AliTRDdigitizer::Exec(const Option_t * const option)
     AliDebug(1,Form("Add input stream %d",iInput));
 
     // Check if the input tree exists
-    inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
+    inrl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(iInput));
     AliLoader *gime = inrl->GetLoader("TRDLoader");
 
     TTree *treees = gime->TreeS();
@@ -357,7 +358,7 @@ void AliTRDdigitizer::Exec(const Option_t * const option)
     sdigitsManager = new AliTRDdigitsManager();
     sdigitsManager->SetSDigits(kTRUE);
     
-    AliRunLoader *rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
+    AliRunLoader *rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(iInput));
     AliLoader *gimme = rl->GetLoader("TRDLoader");
     if (!gimme->TreeS()) 
       {
@@ -617,6 +618,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   Float_t **hits = new Float_t*[kNdet];
   Int_t    *nhit = new Int_t[kNdet];
+  memset(nhit,0,kNdet*sizeof(Int_t));
 
   AliTRDarraySignal *signals = 0x0;
 
@@ -652,8 +654,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
   for (Int_t det = 0; det < kNdet; det++) {
 
     // Detectors that are switched off, not installed, etc.
-    if (( calibration->IsChamberInstalled(det)) &&
-       (!calibration->IsChamberMasked(det))    &&
+    if ((!calibration->IsChamberNoData(det))    &&
         ( fGeo->ChamberInGeometry(det))         &&
         (nhit[det] > 0)) {
 
@@ -668,6 +669,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
         signals = 0x0;
         return kFALSE;
       }
+
       // Convert the detector signals to digits or s-digits
       if (!ConvertSignals(det,signals)) {
        AliError(Form("Conversion of signals failed for detector=%d",det));
@@ -689,7 +691,8 @@ Bool_t AliTRDdigitizer::MakeDigits()
   } // for: detector
 
   if (!fSDigits) {
-    if (AliDataLoader *trklLoader = AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets")) {
+    if (AliDataLoader *trklLoader 
+          = AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets")) {
       if (trklLoader->Tree())
         trklLoader->WriteData("OVERWRITE");
     }
@@ -720,11 +723,10 @@ Bool_t AliTRDdigitizer::SortHits(Float_t **hits, Int_t *nhit)
   Int_t    nhitTrk  = 0;
 
   Int_t   *lhit     = new Int_t[kNdet];
+  memset(lhit,0,kNdet*sizeof(Int_t));
 
   for (Int_t det = 0; det < kNdet; det++) {
-    lhit[det] = 0;
-    nhit[det] = 0;
-    hits[det] = 0;
+    hits[det] = 0x0;
   }
 
   AliLoader *gimme = fRunLoader->GetLoader("TRDLoader");
@@ -873,6 +875,8 @@ Bool_t AliTRDdigitizer::ConvertHits(Int_t det
   AliTRDCalROC       *calT0ROC          = 0;
   Float_t             calT0DetValue     = 0.0;
   const AliTRDCalDet *calT0Det          = calibration->GetT0Det();  
+  Double_t            calExBDetValue    = 0.0;
+  const AliTRDCalDet *calExBDet         = calibration->GetExBDet();
 
   if (simParam->TRFOn()) {
     timeBinTRFend = ((Int_t) (simParam->GetTRFhi() 
@@ -922,6 +926,7 @@ Bool_t AliTRDdigitizer::ConvertHits(Int_t det
     calVdriftDetValue = calVdriftDet->GetValue(det);
     calT0ROC          = calibration->GetT0ROC(det);
     calT0DetValue     = calT0Det->GetValue(det);
+    calExBDetValue    = calExBDet->GetValue(det);
 
     // Go to the local coordinate system:
     // loc[0] - col  direction in amplification or driftvolume
@@ -970,7 +975,7 @@ Bool_t AliTRDdigitizer::ConvertHits(Int_t det
     Float_t  driftvelocity  = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
     Double_t absdriftlength = TMath::Abs(driftlength);
     if (commonParam->ExBOn()) {
-      absdriftlength /= TMath::Sqrt(GetLorentzFactor(driftvelocity));
+      absdriftlength /= TMath::Sqrt(1.0 / (1.0 + calExBDetValue*calExBDetValue));
     }
 
     // Loop over all electrons of this hit
@@ -1000,16 +1005,14 @@ Bool_t AliTRDdigitizer::ConvertHits(Int_t det
           
       // Apply the diffusion smearing
       if (simParam->DiffusionOn()) {
-        if (!(Diffusion(driftvelocity,absdriftlength,locR,locC,locT))) {
+        if (!(Diffusion(driftvelocity,absdriftlength,calExBDetValue,locR,locC,locT))) {
           continue;
        }
       }
 
       // Apply E x B effects (depends on drift direction)
-      if (commonParam->ExBOn()) { 
-        if (!(ExB(driftvelocity,driftlength,locC))) {
-          continue;
-       }
+      if (commonParam->ExBOn()) {
+        locC = locC + calExBDetValue * driftlength;
       }
 
       // The electron position after diffusion and ExB in pad coordinates.
@@ -1242,9 +1245,9 @@ Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals)
     return kFALSE;
   }
 
-  // The gainfactor calibration objects
+  // The gain factor calibration objects
   const AliTRDCalDet *calGainFactorDet      = calibration->GetGainFactorDet();  
-  AliTRDCalROC       *calGainFactorROC      = 0;
+  AliTRDCalROC       *calGainFactorROC      = 0x0;
   Float_t             calGainFactorDetValue = 0.0;
 
   AliTRDarrayADC     *digits = 0x0;
@@ -1278,13 +1281,18 @@ 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++ ) {
 
       // Check whether pad is masked
       // Bridged pads are not considered yet!!!
-      if (calibration->IsPadMasked(det,col,row) || calibration->IsPadNotConnected(det,col,row)) {
+      if (calibration->IsPadMasked(det,col,row) || 
+          calibration->IsPadNotConnected(det,col,row)) {
         continue;
       }
 
@@ -1896,6 +1904,7 @@ void AliTRDdigitizer::InitOutput(Int_t iEvent)
   
 //_____________________________________________________________________________
 Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t absdriftlength
+                               , Double_t exbvalue
                                , Double_t &lRow, Double_t &lCol, Double_t &lTime)
 {
   //
@@ -1912,8 +1921,14 @@ Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t absdriftlength
     Float_t sigmaT    = driftSqrt * diffT;
     Float_t sigmaL    = driftSqrt * diffL;
     lRow  = gRandom->Gaus(lRow ,sigmaT);
-    lCol  = gRandom->Gaus(lCol ,sigmaT * GetLorentzFactor(vdrift));
-    lTime = gRandom->Gaus(lTime,sigmaL * GetLorentzFactor(vdrift));
+    if (AliTRDCommonParam::Instance()->ExBOn()) {
+      lCol  = gRandom->Gaus(lCol ,sigmaT * 1.0 / (1.0 + exbvalue*exbvalue));
+      lTime = gRandom->Gaus(lTime,sigmaL * 1.0 / (1.0 + exbvalue*exbvalue));
+    }
+    else {
+      lCol  = gRandom->Gaus(lCol ,sigmaT);
+      lTime = gRandom->Gaus(lTime,sigmaL);
+    }
 
     return 1;
 
@@ -1925,40 +1940,7 @@ Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t absdriftlength
   }
 
 }
-
-//_____________________________________________________________________________
-Float_t AliTRDdigitizer::GetLorentzFactor(Float_t vd)
-{
-  //
-  // Returns the Lorentz factor
-  //
-
-  Double_t omegaTau      = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
-  Double_t lorentzFactor = 1.0;
-  if (AliTRDCommonParam::Instance()->ExBOn()) {
-    lorentzFactor = 1.0 / (1.0 + omegaTau*omegaTau);
-  }
-
-  return lorentzFactor;
-
-}
   
-//_____________________________________________________________________________
-Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t &lCol)
-{
-  //
-  // Applies E x B effects to the position of a single electron.
-  // Depends on signed drift length.
-  //
-
-  lCol = lCol 
-       + AliTRDCommonParam::Instance()->GetOmegaTau(vdrift) 
-       * driftlength;
-
-  return 1;
-
-}
-
 //_____________________________________________________________________________
 void AliTRDdigitizer::RunDigitalProcessing(Int_t det)
 {