]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDdigitizer.cxx
fix problem with fXpos11 in LoadXPos (Philippe C., thanks to Christian)
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitizer.cxx
index 110ce18cfb8b6c663e5be9c546f3c7444a531d13..9767950f3bf2739f490f6c061840d19076da9519 100644 (file)
@@ -395,21 +395,21 @@ void AliTRDdigitizer::Exec(Option_t *option)
   TString optionString = option;
   if (optionString.Contains("deb")) {
     AliLog::SetClassDebugLevel("AliTRDdigitizer",1);
-    AliInfo("Called with debug option\n");
+    AliInfo("Called with debug option");
   }
 
   // The AliRoot file is already connected by the manager
   AliRunLoader *inrl;
   
   if (gAlice) {
-    AliDebug(1,"AliRun object found on file.\n");
+    AliDebug(1,"AliRun object found on file.");
   }
   else {
     inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
     inrl->LoadgAlice();
     gAlice = inrl->GetAliRun();
     if (!gAlice) {
-      AliError("Could not find AliRun object.\n")
+      AliError("Could not find AliRun object.")
       return;
     }
   }
@@ -454,7 +454,7 @@ void AliTRDdigitizer::Exec(Option_t *option)
  
   for (iInput = 0; iInput < nInput; iInput++) {
 
-    AliDebug(1,Form("Add input stream %d\n",iInput));
+    AliDebug(1,Form("Add input stream %d",iInput));
 
     // Check if the input tree exists
     inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
@@ -470,7 +470,7 @@ void AliTRDdigitizer::Exec(Option_t *option)
     }
     
     if (treees == 0x0) {
-      AliError(Form("Input stream %d does not exist\n",iInput));
+      AliError(Form("Input stream %d does not exist",iInput));
       return;
     } 
 
@@ -491,17 +491,17 @@ void AliTRDdigitizer::Exec(Option_t *option)
   }
 
   // Convert the s-digits to normal digits
-  AliDebug(1,"Do the conversion\n");
+  AliDebug(1,"Do the conversion");
   SDigits2Digits();
 
   // Store the digits
-  AliDebug(1,"Write the digits\n");
+  AliDebug(1,"Write the digits");
   fDigitsManager->WriteDigits();
 
   // Write parameters
   orl->CdGAFile();
 
-  AliDebug(1,"Done\n");
+  AliDebug(1,"Done");
 
   DeleteSDigitsManager();
 
@@ -533,10 +533,10 @@ Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent)
   gAlice = fRunLoader->GetAliRun();
   
   if (gAlice) {
-    AliDebug(1,"AliRun object found on file.\n");
+    AliDebug(1,"AliRun object found on file.");
   }
   else {
-    AliError("Could not find AliRun object.\n");
+    AliError("Could not find AliRun object.");
     return kFALSE;
   }
 
@@ -595,10 +595,10 @@ Bool_t AliTRDdigitizer::Open(AliRunLoader *runLoader, Int_t nEvent)
   gAlice = fRunLoader->GetAliRun();
   
   if (gAlice) {
-    AliDebug(1,"AliRun object found on file.\n");
+    AliDebug(1,"AliRun object found on file.");
   }
   else {
-    AliError("Could not find AliRun object.\n");
+    AliError("Could not find AliRun object.");
     return kFALSE;
   }
 
@@ -646,17 +646,17 @@ Bool_t AliTRDdigitizer::InitDetector()
   // Get the pointer to the detector class and check for version 1
   fTRD = (AliTRD *) gAlice->GetDetector("TRD");
   if (!fTRD) {
-    AliFatal("No TRD module found\n");
+    AliFatal("No TRD module found");
     exit(1);
   }
   if (fTRD->IsVersion() != 1) {
-    AliFatal("TRD must be version 1 (slow simulator)\n");
+    AliFatal("TRD must be version 1 (slow simulator)");
     exit(1);
   }
 
   // Get the geometry
   fGeo = fTRD->GetGeometry();
-  AliDebug(1,Form("Geometry version %d\n",fGeo->IsVersion()));
+  AliDebug(1,Form("Geometry version %d",fGeo->IsVersion()));
 
   // Create a digits manager
   delete fDigitsManager;
@@ -747,13 +747,13 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
-    AliError("Could not get simulation parameters\n");
+    AliError("Could not get simulation parameters");
     return kFALSE;
   }
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common parameterss\n");
+    AliError("Could not get common parameterss");
     return kFALSE;
   }
   
@@ -763,24 +763,24 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
-    AliError("Could not get calibration object\n");  
+    AliError("Could not get calibration object");  
     return kFALSE;
   }
 
   if (simParam->TRFOn()) {
     timeBinTRFend = ((Int_t) (simParam->GetTRFhi() 
-                  * calibration->GetSamplingFrequency())) - 1;
-    AliDebug(1,Form("Sample the TRF up to bin %d\n",timeBinTRFend));
+                  * commonParam->GetSamplingFrequency())) - 1;
+    AliDebug(1,Form("Sample the TRF up to bin %d",timeBinTRFend));
   }
 
   Float_t elAttachProp = simParam->GetElAttachProp() / 100.0; 
 
   if (!fGeo) {
-    AliError("No geometry defined\n");
+    AliError("No geometry defined");
     return kFALSE;
   }
 
-  AliDebug(1,"Start creating digits.\n");
+  AliDebug(1,"Start creating digits.");
 
   AliLoader *gimme = fRunLoader->GetLoader("TRDLoader");
   if (!gimme->TreeH()) {
@@ -796,22 +796,22 @@ Bool_t AliTRDdigitizer::MakeDigits()
   // Get the number of entries in the hit tree
   // (Number of primary particles creating a hit somewhere)
   Int_t nTrack = (Int_t) hitTree->GetEntries();
-  AliDebug(1,Form("Found %d primary particles\n",nTrack));
-  AliDebug(1,Form("Sampling = %.0fMHz\n"        ,calibration->GetSamplingFrequency()));
-  AliDebug(1,Form("Gain     = %d\n"             ,((Int_t) simParam->GetGasGain())));
-  AliDebug(1,Form("Noise    = %d\n"             ,((Int_t) simParam->GetNoise())));
+  AliDebug(1,Form("Found %d primary particles",nTrack));
+  AliDebug(1,Form("Sampling = %.0fMHz"        ,commonParam->GetSamplingFrequency()));
+  AliDebug(1,Form("Gain     = %d"             ,((Int_t) simParam->GetGasGain())));
+  AliDebug(1,Form("Noise    = %d"             ,((Int_t) simParam->GetNoise())));
   if (simParam->TimeStructOn()) {
-    AliDebug(1,"Time Structure of drift cells implemented.\n");
+    AliDebug(1,"Time Structure of drift cells implemented.");
   } 
   else {
-    AliDebug(1,"Constant drift velocity in drift cells.\n");
+    AliDebug(1,"Constant drift velocity in drift cells.");
   }
   
   Int_t   detectorOld  = -1;
   Int_t   countHits    =  0;
  
   Int_t   nTimeTotal   = calibration->GetNumberOfTimeBins();
-  Float_t samplingRate = calibration->GetSamplingFrequency();
+  Float_t samplingRate = commonParam->GetSamplingFrequency();
 
   // Loop through all entries in the tree
   for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
@@ -839,6 +839,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
       pos[2]           = hit->Z();
       Int_t   track    = hit->Track();
       Int_t   detector = hit->GetDetector();
+      Float_t hittime  = hit->GetTime();
       Int_t   plane    = fGeo->GetPlane(detector);
       Int_t   chamber  = fGeo->GetChamber(detector);
       Float_t time0    = AliTRDgeometry::GetTime0(plane);
@@ -925,7 +926,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
          if ((xyz[2] < padPlane->GetRowEnd()) ||
               (xyz[2] > padPlane->GetRow0())) {
             if (iEl == 0) {
-              AliDebug(2,Form("Hit outside of sensitive volume, row (z=%f, row0=%f, rowE=%f)\n"
+              AliDebug(2,Form("Hit outside of sensitive volume, row (z=%f, row0=%f, rowE=%f)"
                              ,xyz[2],padPlane->GetRow0(),padPlane->GetRowEnd()));
            }
             continue;
@@ -934,7 +935,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
           if ((tt < 0.0) || 
               (tt > kDrWidth + 2.0*kAmWidth)) {
             if (iEl == 0) {
-              AliDebug(2,Form("Hit outside of sensitive volume, time (Q = %d)\n"
+              AliDebug(2,Form("Hit outside of sensitive volume, time (Q = %d)"
                              ,((Int_t) q)));
            }
             continue;
@@ -991,7 +992,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
         // Also re-retrieve drift velocity because col and row may have changed
         driftvelocity = calibration->GetVdrift(detector,colE,rowE);
         Float_t t0    = calibration->GetT0(detector,colE,rowE);
-          
+
         // Convert the position to drift time, using either constant drift velocity or
         // time structure of drift cells (non-isochronity, GARFIELD calculation).
        Double_t drifttime;
@@ -1003,11 +1004,13 @@ Bool_t AliTRDdigitizer::MakeDigits()
             Z  = 0.5 - Z;
          }
          // Use drift time map (GARFIELD)
-          drifttime = TimeStruct(driftvelocity,time0-xyz[0]+kAmWidth,Z);
+          drifttime = TimeStruct(driftvelocity,time0-xyz[0]+kAmWidth,Z)
+                    + hittime;
         } 
         else {
          // Use constant drift velocity
-          drifttime = TMath::Abs(time0 - xyz[0]) / driftvelocity;
+          drifttime = TMath::Abs(time0 - xyz[0]) / driftvelocity
+                    + hittime;
         }
 
         // Apply the gas gain including fluctuations
@@ -1108,7 +1111,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   } // Loop: primary tracks
 
-  AliDebug(1,Form("Finished analyzing %d hits\n",countHits));
+  AliDebug(1,Form("Finished analyzing %d hits",countHits));
 
   // The coupling factor
   Double_t coupling = simParam->GetPadCoupling() 
@@ -1171,8 +1174,6 @@ Bool_t AliTRDdigitizer::MakeDigits()
           // Check whether pad is masked
          // Bridged pads are not considered yet!!!
           if (calibration->IsPadMasked(iDet,iCol,iRow)) continue;
-          // Check whether MCM is masked
-          if (calibration->IsMCMMasked(iDet,iCol,iRow)) continue;
 
          // Create summable digits
           if (fSDigits) {
@@ -1199,7 +1200,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
               Float_t padgain = calibration->GetGainFactor(iDet,iCol,iRow);
               if (padgain <= 0) {
-                AliError(Form("Not a valid gain %f, %d %d %d\n",padgain,iDet,iCol,iRow));
+                AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow));
               }
              signalAmp *= padgain;
 
@@ -1232,7 +1233,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
             for (iTime = 0; iTime < nTimeTotal; iTime++) {   
               // Store the amplitude of the digit if above threshold
-              if (outADC[iTime] > simParam->GetADCthreshold()) {
+              if ( outADC[iTime] > ( simParam->GetADCbaseline() + simParam->GetADCthreshold() ) ) {
                 nDigits++;
                 digits->SetDataUnchecked(iRow,iCol,iTime,((Int_t) outADC[iTime]));
              }
@@ -1258,7 +1259,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
     if (nDigits > 0) {
       Float_t nPixel = nRowMax * nColMax * nTimeTotal;
-      AliDebug(1,Form("Found %d digits in detector %d (%3.0f).\n"
+      AliDebug(1,Form("Found %d digits in detector %d (%3.0f)."
                      ,nDigits,iDet
                      ,100.0 * ((Float_t) nDigits) / nPixel));
     }
@@ -1277,8 +1278,8 @@ Bool_t AliTRDdigitizer::MakeDigits()
     signalsArray = 0;
   }
 
-  AliDebug(1,Form("Total number of analyzed hits = %d\n",countHits));
-  AliDebug(1,Form("Total digits data size = %d, %d, %d, %d\n",totalSizeDigits
+  AliDebug(1,Form("Total number of analyzed hits = %d",countHits));
+  AliDebug(1,Form("Total digits data size = %d, %d, %d, %d",totalSizeDigits
                                                              ,totalSizeDict0
                                                              ,totalSizeDict1
                                                              ,totalSizeDict2));
@@ -1329,19 +1330,19 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
 
   AliTRDSimParam *simParam = AliTRDSimParam::Instance();
   if (!simParam) {
-    AliError("Could not get simulation parameters\n");
+    AliError("Could not get simulation parameters");
     return kFALSE;
   }
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common parameters\n");
+    AliError("Could not get common parameters");
     return kFALSE;
   }
   
   AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
-    AliError("Could not get calibration object\n");
+    AliError("Could not get calibration object");
     return kFALSE;
   }
     
@@ -1397,8 +1398,6 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
           // Check whether pad is masked
          // Bridged pads are not considered yet!!!
           if (calibration->IsPadMasked(iDet,iCol,iRow)) continue;
-          // Check whether MCM is masked
-          if (calibration->IsMCMMasked(iDet,iCol,iRow)) continue;
 
             for (iTime = 0; iTime < nTimeTotal; iTime++) {
 
@@ -1408,7 +1407,7 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
            // Apply the pad-by-pad gain factors
             Float_t padgain = calibration->GetGainFactor(iDet,iCol,iRow);
             if (padgain <= 0.0) {
-              AliError(Form("Not a valid gain %f, %d %d %d\n",padgain,iDet,iCol,iRow));
+              AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow));
             }
             signal *= padgain;
             // Pad and time coupling
@@ -1436,7 +1435,7 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
 
           for (iTime = 0; iTime < nTimeTotal; iTime++) {
             // Store the amplitude of the digit if above threshold
-            if (outADC[iTime] > adcThreshold) {
+            if (outADC[iTime] > (adcBaseline + adcThreshold)) {
               digitsOut->SetDataUnchecked(iRow,iCol,iTime,((Int_t) outADC[iTime]));
              // Copy the dictionary
               for (iDict = 0; iDict < kNDict; iDict++) { 
@@ -1484,19 +1483,19 @@ Bool_t AliTRDdigitizer::MergeSDigits()
 
   AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
-    AliError("Could not get simulation parameters\n");
+    AliError("Could not get simulation parameters");
     return kFALSE;
   }
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common parameters\n");
+    AliError("Could not get common parameters");
     return kFALSE;
   }
   
   AliTRDcalibDB     *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
-    AliError("Could not get calibration object\n");
+    AliError("Could not get calibration object");
     return kFALSE;
   }
   
@@ -1511,7 +1510,7 @@ Bool_t AliTRDdigitizer::MergeSDigits()
   // Get the first s-digits
   fSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->First();
   if (!fSDigitsManager) { 
-    AliError("No SDigits manager\n");
+    AliError("No SDigits manager");
     return kFALSE;
   }
 
@@ -1521,10 +1520,10 @@ Bool_t AliTRDdigitizer::MergeSDigits()
                         fSDigitsManagerList->After(fSDigitsManager);
 
   if (mergeSDigitsManager) {
-    AliDebug(1,Form("Merge %d input files.\n",fSDigitsManagerList->GetSize()));
+    AliDebug(1,Form("Merge %d input files.",fSDigitsManagerList->GetSize()));
   }
   else {
-    AliDebug(1,"Only one input file.\n");
+    AliDebug(1,"Only one input file.");
   }
 
   Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
@@ -1565,7 +1564,7 @@ Bool_t AliTRDdigitizer::MergeSDigits()
 
       if (doMerge) {
 
-        AliDebug(1,Form("Merge detector %d of input no.%d\n",iDet,iMerge+1));
+        AliDebug(1,Form("Merge detector %d of input no.%d",iDet,iMerge+1));
 
         for (Int_t iRow  = 0; iRow  <  nRowMax;   iRow++ ) {
           for (Int_t iCol  = 0; iCol  <  nColMax;   iCol++ ) {
@@ -1729,7 +1728,7 @@ Double_t AliTRDdigitizer::TimeStruct(Float_t vdrift, Double_t dist, Double_t z)
       (r1  > 37) || 
       (kz1 <  0) || 
       (kz1 > 10)) {
-    AliWarning(Form("Indices out of range: dist=%.2f, z=%.2f, r1=%d, kz1=%d\n"
+    AliWarning(Form("Indices out of range: dist=%.2f, z=%.2f, r1=%d, kz1=%d"
                    ,dist,z,r1,kz1));
   }
 
@@ -1813,11 +1812,11 @@ void AliTRDdigitizer::SampleTimeStruct(Float_t vdrift)
   fVDsmp[7] = 2.134;
 
   if      (vdrift < fVDsmp[0]) {
-    AliWarning(Form("Drift Velocity too small (%.3f<%.3f)\n",vdrift,fVDsmp[0]));
+    AliWarning(Form("Drift Velocity too small (%.3f<%.3f)",vdrift,fVDsmp[0]));
     vdrift = fVDsmp[0];
   } 
   else if (vdrift > fVDsmp[7]) {
-    AliWarning(Form("Drift Velocity too large (%.3f>%.3f)\n",vdrift,fVDsmp[6]));
+    AliWarning(Form("Drift Velocity too large (%.3f>%.3f)",vdrift,fVDsmp[6]));
     vdrift = fVDsmp[7];
   }
 
@@ -2531,19 +2530,19 @@ void AliTRDdigitizer::RecalcDiffusion(Float_t vdrift)
 
   AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
-    AliError("Could not get simulation parameters\n");
+    AliError("Could not get simulation parameters");
     return;
   }
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common parameters\n");
+    AliError("Could not get common parameters");
     return;
   }
   
   AliTRDcalibDB     *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
-    AliError("Could not get calibration object\n");
+    AliError("Could not get calibration object");
     return;
   }