]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New internal coordinates in digitizer and consistent detector numbering scheme in...
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Mar 2007 14:52:30 +0000 (14:52 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Mar 2007 14:52:30 +0000 (14:52 +0000)
TRD/AliTRDCalibra.cxx
TRD/AliTRDcalibDB.cxx
TRD/AliTRDcalibDB.h
TRD/AliTRDdigitizer.cxx
TRD/AliTRDdigitizer.h
TRD/AliTRDgeometry.cxx
TRD/AliTRDgeometry.h
TRD/AliTRDpadPlane.cxx
TRD/AliTRDpadPlane.h
TRD/AliTRDv1.cxx

index b25b43d699e7580c69877e3fa9ccf5f88499637c..2a10d617af73ecec1a3eab3157b3d610077a8c87 100644 (file)
@@ -2018,7 +2018,7 @@ Bool_t AliTRDCalibra::UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t)
   Int_t    row        = padplane->GetPadRowNumber(pos[2]);
   Double_t offsetz    = padplane->GetPadRowOffset(row,pos[2]);
   Double_t offsettilt = padplane->GetTiltOffset(offsetz);
-  Int_t    col        = padplane->GetPadColNumber(pos[1] + offsettilt,offsetz);
+  Int_t    col        = padplane->GetPadColNumber(pos[1] + offsettilt);
   
   // See if we are not near a masked pad
   if (!IsPadOn(detector,col,row)) {
index f456cf47b51f18b6016d2233dc41af7ac96f2d62..dcd296592d391327d629a1f89884eefda4670015 100644 (file)
@@ -357,6 +357,49 @@ Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
   return calChamber->GetValue(det) * roc->GetValue(col,row);
 
 }
+//_____________________________________________________________________________
+AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
+{
+  //
+  // Returns the Vdrift calibration object for a given ROC
+  // containing one number per pad 
+  //
+  
+  const AliTRDCalPad     *calPad     = dynamic_cast<const AliTRDCalPad *> 
+                                       (GetCachedCDBObject(kIDVdriftPad));
+  if (!calPad) {
+    return 0;
+  }
+
+  AliTRDCalROC           *roc        = calPad->GetCalROC(det);
+  if (!roc) {
+    return 0;
+  }
+  else {
+    return roc;
+  }
+
+}
+
+//_____________________________________________________________________________
+const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
+{
+  //
+  // Returns the Vdrift calibration object
+  // containing one number per detector
+  //
+  
+  const AliTRDCalDet     *calChamber = dynamic_cast<const AliTRDCalDet *> 
+                                       (GetCachedCDBObject(kIDVdriftChamber));
+  if (!calChamber) {
+    return 0;
+  }
+  else {
+    return calChamber;
+  }
+
+}
 
 //_____________________________________________________________________________
 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
@@ -402,7 +445,7 @@ Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
   return calChamber->GetValue(det) + roc->GetValue(col,row);
 
 }
-
 //_____________________________________________________________________________
 AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
 {
index 8f7f72c7eea080768f4ba24765cf65ea091a2846..cf169c25c7c0e441333f938a03f1a4e9fdf65b7d 100644 (file)
@@ -37,6 +37,8 @@ class AliTRDcalibDB : public TObject {
 
   Float_t                    GetVdrift(Int_t det, Int_t col, Int_t row);
   Float_t                    GetVdriftAverage(Int_t det);
+        AliTRDCalROC        *GetVdriftROC(Int_t det);
+  const AliTRDCalDet        *GetVdriftDet();
 
   Float_t                    GetT0(Int_t det, Int_t col, Int_t row);
   Float_t                    GetT0Average(Int_t det);
index 3fee836db9fb526dfeb0a15cd75e70d84072a24d..04fc6fe5beebe3b0662d2a54faaecd7569f3a0cc 100644 (file)
@@ -74,6 +74,9 @@
 #include "AliTRDSimParam.h"
 #include "AliTRDCommonParam.h"
 
+#include "Cal/AliTRDCalROC.h"
+#include "Cal/AliTRDCalDet.h"
+
 ClassImp(AliTRDdigitizer)
 
 //_____________________________________________________________________________
@@ -317,7 +320,7 @@ AliTRDdigitizer::~AliTRDdigitizer()
 
   if (fMasks) {
     delete [] fMasks;
-    fMasks = 0;
+    fMasks       = 0;
   }
 
   if (fTimeStruct1) {
@@ -710,10 +713,13 @@ Bool_t AliTRDdigitizer::MakeDigits()
   // Number of track dictionary arrays
   const Int_t kNDict     = AliTRDdigitsManager::kNDict;
 
-  // Half the width of the amplification region
-  const Float_t kAmWidth = AliTRDgeometry::AmThick() / 2.0;
+  // Width of the amplification region
+  const Float_t kAmWidth = AliTRDgeometry::AmThick();
   // Width of the drift region
   const Float_t kDrWidth = AliTRDgeometry::DrThick();
+  // Drift + amplification region 
+  const Float_t kDrMin   =          - 0.5 * kAmWidth;
+  const Float_t kDrMax   = kDrWidth + 0.5 * kAmWidth;
   
   Int_t    iRow;
   Int_t    iCol;
@@ -730,8 +736,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
   Int_t    timeBinTRFend   = 1;
 
   Double_t pos[3];
-  Double_t rot[3];
-  Double_t xyz[3];
+  Double_t loc[3];
   Double_t padSignal[kNpad];
   Double_t signalOld[kNpad];
 
@@ -741,46 +746,46 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   AliTRDpadPlane   *padPlane = 0;
 
+  AliTRDCalROC     *calVdriftROC          = 0;
+  Float_t           calVdriftDetValue     = 0.0;
+  AliTRDCalROC     *calT0ROC              = 0;
+  Float_t           calT0DetValue         = 0.0;
+  AliTRDCalROC     *calGainFactorROC      = 0;
+  Float_t           calGainFactorDetValue = 0.0;
+
   if (!gGeoManager) {
     AliFatal("No geometry manager!");
   }
 
+  if (!fGeo) {
+    AliError("No geometry defined");
+    return kFALSE;
+  }
+  fGeo->ReadGeoMatrices();
+
   AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
-    AliError("Could not get simulation parameters");
+    AliFatal("Could not get simulation parameters");
     return kFALSE;
   }
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common parameterss");
+    AliFatal("Could not get common parameterss");
     return kFALSE;
   }
-  
-  // Create a container for the amplitudes
-  AliTRDsegmentArray *signalsArray = new AliTRDsegmentArray("AliTRDdataArrayF"
-                                                           ,AliTRDgeometry::Ndet());
 
-  AliTRDcalibDBcalibration = AliTRDcalibDB::Instance();
+  AliTRDcalibDB     *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
     AliFatal("Could not get calibration object");  
     return kFALSE;
   }
 
-  if (simParam->TRFOn()) {
-    timeBinTRFend = ((Int_t) (simParam->GetTRFhi() 
-                  * 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");
-    return kFALSE;
-  }
-
-  AliDebug(1,"Start creating digits.");
+  AliDebug(1,"Start creating digits");
+  
+  // Create a container for the amplitudes
+  AliTRDsegmentArray *signalsArray = new AliTRDsegmentArray("AliTRDdataArrayF"
+                                                           ,AliTRDgeometry::Ndet());
 
   AliLoader *gimme = fRunLoader->GetLoader("TRDLoader");
   if (!gimme->TreeH()) {
@@ -792,7 +797,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
     return kFALSE;
   }
   fTRD->SetTreeAddress();
-  
+
   // Get the number of entries in the hit tree
   // (Number of primary particles creating a hit somewhere)
   Int_t nTrack = (Int_t) hitTree->GetEntries();
@@ -806,12 +811,23 @@ Bool_t AliTRDdigitizer::MakeDigits()
   else {
     AliDebug(1,"Constant drift velocity in drift cells.");
   }
-  
+  if (simParam->TRFOn()) {
+    timeBinTRFend = ((Int_t) (simParam->GetTRFhi() 
+                  * commonParam->GetSamplingFrequency())) - 1;
+    AliDebug(1,Form("Sample the TRF up to bin %d",timeBinTRFend));
+  }
+
+  // Get the detector wise calibration objects
+  const AliTRDCalDet *calVdriftDet     = calibration->GetVdriftDet();  
+  const AliTRDCalDet *calT0Det         = calibration->GetT0Det();  
+  const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();  
+
   Int_t   detectorOld  = -1;
   Int_t   countHits    =  0;
  
   Int_t   nTimeTotal   = calibration->GetNumberOfTimeBins();
   Float_t samplingRate = commonParam->GetSamplingFrequency();
+  Float_t elAttachProp = simParam->GetElAttachProp() / 100.0; 
 
   // Loop through all entries in the tree
   for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
@@ -841,7 +857,6 @@ Bool_t AliTRDdigitizer::MakeDigits()
       Int_t   detector = hit->GetDetector();
       Int_t   plane    = fGeo->GetPlane(detector);
       Int_t   chamber  = fGeo->GetChamber(detector);
-      Float_t time0    = AliTRDgeometry::GetTime0(plane);
       padPlane         = commonParam->GetPadPlane(plane,chamber);
       Float_t row0     = padPlane->GetRow0();
       Int_t   nRowMax  = padPlane->GetNrows();
@@ -886,55 +901,64 @@ Bool_t AliTRDdigitizer::MakeDigits()
             if (fCompress) dictionary[iDict]->Expand();
           }
         }      
+
+       // Get the calibration objects
+       calVdriftROC      = calibration->GetVdriftROC(detector);
+        calVdriftDetValue = calVdriftDet->GetValue(detector);
+       calT0ROC          = calibration->GetT0ROC(detector);
+        calT0DetValue     = calT0Det->GetValue(detector);
+
         detectorOld = detector;
+
       }
 
-      // Rotate the sectors on top of each other       
-      // by using the geoManager
-      Double_t aaa[3];
-      gGeoManager->MasterToLocal(pos,aaa);
+      // Go to the local coordinate system:
+      // loc[0] - row  direction in amplification or driftvolume
+      // loc[1] - col  direction in amplification or driftvolume
+      // loc[2] - time direction in amplification or driftvolume
+      gGeoManager->MasterToLocal(pos,loc);
+      // Now the real local coordinate system of the ROC
+      // row direction:    locR 
+      // column direction: locC
+      // time direction:   locT
+      // locR and locC are identical to the coordinates of the corresponding
+      // volumina of the drift or amplification region.
+      // locT is defined relative to the wire plane (i.e. middle of amplification
+      // region), meaming locT = 0, and is negative for hits coming from the
+      // drift region. 
+      Double_t locR = loc[0];
+      Double_t locC = loc[1];
+      Double_t locT = loc[2];
       if (inDrift) {
-        aaa[2] = time0 - (kDrWidth / 2.0 + kAmWidth) + aaa[2];
+       // locT relative to middle of amplification region
+        locT = locT - kDrWidth/2.0 - kAmWidth/2.0;
       } 
-      else {
-        aaa[2] = time0 + aaa[2];
-      }
-      aaa[1] = row0 + padPlane->GetLengthRim() + fGeo->RpadW() 
-             - 0.5 * fGeo->GetChamberLength(plane,chamber) 
-             + aaa[1];
-      rot[0] = aaa[2];
-      rot[1] = aaa[0];
-      rot[2] = aaa[1];
 
-      // The driftlength. It is negative if the hit is between pad plane and anode wires.
-      Double_t driftlength = time0 - rot[0];
+      // The driftlength (w/o diffusion yet !).
+      // It is negative if the hit is between pad plane and anode wires.
+      Double_t driftlength = -1.0 * locT;
 
       // Loop over all electrons of this hit
       // TR photons produce hits with negative charge
       Int_t nEl = ((Int_t) TMath::Abs(q));
       for (Int_t iEl = 0; iEl < nEl; iEl++) {
 
-        xyz[0] = rot[0];
-        xyz[1] = rot[1];
-        xyz[2] = rot[2];
-
        // Stupid patch to take care of TR photons that are absorbed
        // outside the chamber volume. A real fix would actually need
        // a more clever implementation of the TR hit generation
         if (q < 0.0) {
-         if ((xyz[2] < padPlane->GetRowEnd()) ||
-              (xyz[2] > padPlane->GetRow0())) {
+         if ((locR < padPlane->GetRowEnd()) ||
+              (locR > padPlane->GetRow0())) {
             if (iEl == 0) {
-              AliDebug(2,Form("Hit outside of sensitive volume, row (z=%f, row0=%f, rowE=%f)"
-                             ,xyz[2],padPlane->GetRow0(),padPlane->GetRowEnd()));
+              AliDebug(2,Form("Hit outside of sensitive volume, row (z=%f, row0=%f, rowE=%f)\n"
+                             ,locR,padPlane->GetRow0(),padPlane->GetRowEnd()));
            }
             continue;
          }
-          Float_t tt = driftlength + kAmWidth;
-          if ((tt < 0.0) || 
-              (tt > kDrWidth + 2.0*kAmWidth)) {
+          if ((driftlength < kDrMin) ||
+              (driftlength > kDrMax)) {
             if (iEl == 0) {
-              AliDebug(2,Form("Hit outside of sensitive volume, time (Q = %d)"
+              AliDebug(2,Form("Hit outside of sensitive volume, time (Q = %d)\n"
                              ,((Int_t) q)));
            }
             continue;
@@ -943,19 +967,19 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
         // Get row and col of unsmeared electron to retrieve drift velocity
         // The pad row (z-direction)
-        Int_t    rowE         = padPlane->GetPadRowNumber(xyz[2]);
+        Int_t    rowE         = padPlane->GetPadRowNumber(locR);
         if (rowE < 0) continue;
-        Double_t rowOffset    = padPlane->GetPadRowOffset(rowE,xyz[2]);
+        Double_t rowOffset    = padPlane->GetPadRowOffset(rowE,locR);
 
         // The pad column (rphi-direction)
        Double_t offsetTilt   = padPlane->GetTiltOffset(rowOffset);
-        Int_t    colE         = padPlane->GetPadColNumber(xyz[1]+offsetTilt,rowOffset);
+        Int_t    colE         = padPlane->GetPadColNumber(locC+offsetTilt);
         if (colE < 0) continue;          
-        Double_t colOffset    = padPlane->GetPadColOffset(colE,xyz[1]+offsetTilt);
+        Double_t colOffset    = padPlane->GetPadColOffset(colE,locC+offsetTilt);
 
-        Float_t driftvelocity = calibration->GetVdrift(detector,colE,rowE);
+        Float_t driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
                     
-        // Normalised drift length
+        // Normalized drift length
         Double_t absdriftlength = TMath::Abs(driftlength);
         if (commonParam->ExBOn()) {
           absdriftlength /= TMath::Sqrt(GetLorentzFactor(driftvelocity));
@@ -963,51 +987,57 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
         // Electron attachment
         if (simParam->ElAttachOn()) {
-          if (gRandom->Rndm() < (absdriftlength * elAttachProp)) continue;
+          if (gRandom->Rndm() < (absdriftlength * elAttachProp)) {
+            continue;
+         }
         }
           
         // Apply the diffusion smearing
         if (simParam->DiffusionOn()) {
-          if (!(Diffusion(driftvelocity,absdriftlength,xyz))) continue;
+          if (!(Diffusion(driftvelocity,absdriftlength,locR,locC,locT))) {
+            continue;
+         }
         }
 
         // Apply E x B effects (depends on drift direction)
         if (commonParam->ExBOn()) { 
-          if (!(ExB(driftvelocity,driftlength,xyz))) continue;
+          if (!(ExB(driftvelocity,driftlength,locR))) {
+            continue;
+         }
         }
 
         // The electron position after diffusion and ExB in pad coordinates.
         // The pad row (z-direction)
-        rowE       = padPlane->GetPadRowNumber(xyz[2]);
+        rowE       = padPlane->GetPadRowNumber(locR);
         if (rowE < 0) continue;
-        rowOffset  = padPlane->GetPadRowOffset(rowE,xyz[2]);
+        rowOffset  = padPlane->GetPadRowOffset(rowE,locR);
 
         // The pad column (rphi-direction)
         offsetTilt = padPlane->GetTiltOffset(rowOffset);
-        colE       = padPlane->GetPadColNumber(xyz[1]+offsetTilt,rowOffset);
+        colE       = padPlane->GetPadColNumber(locC+offsetTilt);
         if (colE < 0) continue;         
-        colOffset  = padPlane->GetPadColOffset(colE,xyz[1]+offsetTilt);
+        colOffset  = padPlane->GetPadColOffset(colE,locC+offsetTilt);
          
         // 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);
+        driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
+        Float_t t0    = calT0DetValue     + calT0ROC->GetValue(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;
         if (simParam->TimeStructOn()) {
-         // Get z-position with respect to anode wire:
-          Double_t Z  =  row0 - xyz[2] + simParam->GetAnodeWireOffset();
+         // Get z-position with respect to anode wire
+          Double_t Z  =  row0 - locR + simParam->GetAnodeWireOffset();
          Z -= ((Int_t)(2 * Z)) / 2.0;
          if (Z > 0.25) {
             Z  = 0.5 - Z;
          }
          // Use drift time map (GARFIELD)
-          drifttime = TimeStruct(driftvelocity,time0-xyz[0]+kAmWidth,Z);
+          drifttime = TimeStruct(driftvelocity,0.5*kAmWidth-1.0*locT,Z);
         } 
         else {
          // Use constant drift velocity
-          drifttime = TMath::Abs(time0 - xyz[0]) / driftvelocity;
+          drifttime = -1.0 * locT / driftvelocity;
         }
 
         // Apply the gas gain including fluctuations
@@ -1023,6 +1053,8 @@ Bool_t AliTRDdigitizer::MakeDigits()
          // in units of pad width
          Double_t dist = (colOffset - 0.5*padPlane->GetColSize(colE))
                         / padPlane->GetColSize(colE);
+         // This is still the fixed parametrization, i.e. not dependent on
+         // calibration values !!!!
           if (!(calibration->PadResponse(signal,dist,plane,padSignal))) continue;
        }
         else {
@@ -1045,9 +1077,9 @@ Bool_t AliTRDdigitizer::MakeDigits()
        // Sample the time response inside the drift region
        // + additional time bins before and after.
         // The sampling is done always in the middle of the time bin
-        for (Int_t iTimeBin = TMath::Max(timeBinTruncated, 0);
-             iTimeBin < TMath::Min(timeBinTruncated+timeBinTRFend,nTimeTotal);
-            iTimeBin++) {
+        for (Int_t iTimeBin = TMath::Max(timeBinTruncated,0)
+            ;iTimeBin < TMath::Min(timeBinTruncated+timeBinTRFend,nTimeTotal)
+           ;iTimeBin++) {
 
          // Apply the time response
           Double_t timeResponse = 1.0;
@@ -1110,6 +1142,12 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   AliDebug(1,Form("Finished analyzing %d hits",countHits));
 
+  //____________________________________________________________________
+  //
+  // Create (s)digits
+  //____________________________________________________________________
+  //
+
   // The coupling factor
   Double_t coupling = simParam->GetPadCoupling() 
                     * simParam->GetTimeCoupling();
@@ -1164,13 +1202,19 @@ Bool_t AliTRDdigitizer::MakeDigits()
         (!calibration->IsChamberMasked(iDet))    &&
         ( fGeo->GetSMstatus(sector))) {
 
+      // Get the calibration objects
+      calGainFactorROC      = calibration->GetGainFactorROC(iDet);
+      calGainFactorDetValue = calGainFactorDet->GetValue(iDet);
+
       // Create the digits for this chamber
       for (iRow  = 0; iRow  <  nRowMax;   iRow++ ) {
         for (iCol  = 0; iCol  <  nColMax;   iCol++ ) {
 
           // Check whether pad is masked
          // Bridged pads are not considered yet!!!
-          if (calibration->IsPadMasked(iDet,iCol,iRow)) continue;
+          if (calibration->IsPadMasked(iDet,iCol,iRow)) {
+            continue;
+         }
 
          // Create summable digits
           if (fSDigits) {
@@ -1188,17 +1232,19 @@ Bool_t AliTRDdigitizer::MakeDigits()
          // Create normal digits
           else {
 
+            Float_t padgain = calGainFactorDetValue 
+                            * calGainFactorROC->GetValue(iCol,iRow);
+            if (padgain <= 0) {
+              AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow));
+            }
+
             for (iTime = 0; iTime < nTimeTotal; iTime++) {         
 
               Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime);
 
               // Pad and time coupling
               signalAmp *= coupling;
-
-              Float_t padgain = calibration->GetGainFactor(iDet,iCol,iRow);
-              if (padgain <= 0) {
-                AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow));
-              }
+             // Gain factors
              signalAmp *= padgain;
 
               // Add the noise, starting from minus ADC baseline in electrons
@@ -1277,9 +1323,9 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   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));
+                                                           ,totalSizeDict0
+                                                           ,totalSizeDict1
+                                                           ,totalSizeDict2));
 
   return kTRUE;
 
@@ -1325,21 +1371,24 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
   Int_t iCol;
   Int_t iTime;
 
-  AliTRDSimParam *simParam = AliTRDSimParam::Instance();
+  AliTRDCalROC *calGainFactorROC      = 0;
+  Float_t       calGainFactorDetValue = 0.0;
+
+  AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
-    AliError("Could not get simulation parameters");
+    AliFatal("Could not get simulation parameters");
     return kFALSE;
   }
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common parameters");
+    AliFatal("Could not get common parameters");
     return kFALSE;
   }
   
-  AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
+  AliTRDcalibDB     *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
-    AliError("Could not get calibration object");
+    AliFatal("Could not get calibration object");
     return kFALSE;
   }
     
@@ -1360,6 +1409,9 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
   AliTRDdataArrayI *digitsOut;
   AliTRDdataArrayI *dictionaryIn[kNDict];
   AliTRDdataArrayI *dictionaryOut[kNDict];
+
+  // Get the detector wise calibration objects
+  const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();  
   
   // Loop through the detectors
   for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) {
@@ -1389,26 +1441,34 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
         (!calibration->IsChamberMasked(iDet))    &&
         ( fGeo->GetSMstatus(sector))) {
 
+      // Get the calibration objects
+      calGainFactorROC      = calibration->GetGainFactorROC(iDet);
+      calGainFactorDetValue = calGainFactorDet->GetValue(iDet);
+
       for (iRow  = 0; iRow  <  nRowMax;   iRow++ ) {
         for (iCol  = 0; iCol  <  nColMax;   iCol++ ) {
 
           // Check whether pad is masked
          // Bridged pads are not considered yet!!!
-          if (calibration->IsPadMasked(iDet,iCol,iRow)) continue;
+          if (calibration->IsPadMasked(iDet,iCol,iRow)) {
+            continue;
+         }
+
+          Float_t padgain = calGainFactorDetValue 
+                          * calGainFactorROC->GetValue(iCol,iRow);
+          if (padgain <= 0) {
+            AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow));
+          }
 
-            for (iTime = 0; iTime < nTimeTotal; iTime++) {
+          for (iTime = 0; iTime < nTimeTotal; iTime++) {
 
            // Scale s-digits to normal digits
             Double_t signal = (Double_t) digitsIn->GetDataUnchecked(iRow,iCol,iTime);
             signal         *= sDigitsScale;
-           // 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",padgain,iDet,iCol,iRow));
-            }
-            signal *= padgain;
             // Pad and time coupling
             signal *= coupling;
+           // Gain factors
+            signal *= padgain;
             // Add the noise, starting from minus ADC baseline in electrons
             Double_t baselineEl = adcBaseline * (adcInRange / adcOutRange) / convert;
             signal  = TMath::Max((Double_t) gRandom->Gaus(signal,noise),-baselineEl);
@@ -1480,19 +1540,19 @@ Bool_t AliTRDdigitizer::MergeSDigits()
 
   AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
-    AliError("Could not get simulation parameters");
+    AliFatal("Could not get simulation parameters");
     return kFALSE;
   }
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common parameters");
+    AliFatal("Could not get common parameters");
     return kFALSE;
   }
   
   AliTRDcalibDB     *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
-    AliError("Could not get calibration object");
+    AliFatal("Could not get calibration object");
     return kFALSE;
   }
   
@@ -1658,7 +1718,7 @@ void AliTRDdigitizer::InitOutput(Int_t iEvent)
     return;  
   }
 
-  AliLoaderloader = fRunLoader->GetLoader("TRDLoader");
+  AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
   if (!loader) {
     AliError("Can not get TRD loader from Run Loader");
     return;
@@ -1788,13 +1848,10 @@ void AliTRDdigitizer::SampleTimeStruct(Float_t vdrift)
   // Drift Time data calculated with Garfield (by C.Lippmann)
   //
   
-  // TODO make caching proper, if same timing structure is selected: do not update timestructs!
-  
-  // Noting to do
+  // Nothing to do
   if (vdrift == fTimeLastVdrift) {
     return;
   }
-
   fTimeLastVdrift = vdrift;
   
   // Drift time maps are saved for some drift velocity values (in drift region):
@@ -2527,19 +2584,19 @@ void AliTRDdigitizer::RecalcDiffusion(Float_t vdrift)
 
   AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
-    AliError("Could not get simulation parameters");
+    AliFatal("Could not get simulation parameters");
     return;
   }
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common parameters");
+    AliFatal("Could not get common parameters");
     return;
   }
   
   AliTRDcalibDB     *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
-    AliError("Could not get calibration object");
+    AliFatal("Could not get calibration object");
     return;
   }
   
@@ -2627,20 +2684,22 @@ Float_t AliTRDdigitizer::GetDiffusionT(Float_t vdrift)
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t driftlength, Double_t *xyz)
+Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t absdriftlength
+                               , Double_t &lRow, Double_t &lCol, Double_t &lTime)
 {
   //
-  // Applies the diffusion smearing to the position of a single electron
+  // Applies the diffusion smearing to the position of a single electron.
+  // Depends on absolute drift length.
   //
   
   RecalcDiffusion(vdrift);
 
-  Float_t driftSqrt = TMath::Sqrt(driftlength);
+  Float_t driftSqrt = TMath::Sqrt(absdriftlength);
   Float_t sigmaT    = driftSqrt * fDiffusionT;
   Float_t sigmaL    = driftSqrt * fDiffusionL;
-  xyz[0] = gRandom->Gaus(xyz[0],sigmaL * GetLorentzFactor(vdrift));
-  xyz[1] = gRandom->Gaus(xyz[1],sigmaT * GetLorentzFactor(vdrift));
-  xyz[2] = gRandom->Gaus(xyz[2],sigmaT);
+  lRow  = gRandom->Gaus(lRow ,sigmaT * GetLorentzFactor(vdrift));
+  lCol  = gRandom->Gaus(lCol ,sigmaT);
+  lTime = gRandom->Gaus(lTime,sigmaL * GetLorentzFactor(vdrift));
 
   return 1;
 
@@ -2660,17 +2719,16 @@ Float_t AliTRDdigitizer::GetLorentzFactor(Float_t vd)
 }
   
 //_____________________________________________________________________________
-Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t *xyz)
+Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t &lRow)
 {
   //
-  // Applies E x B effects to the position of a single electron
+  // Applies E x B effects to the position of a single electron.
+  // Depends on signed drift length.
   //
   
   RecalcDiffusion(vdrift);
-  
-  xyz[0] = xyz[0];
-  xyz[1] = xyz[1] + fOmegaTau * driftlength;
-  xyz[2] = xyz[2];
+
+  lRow = lRow + fOmegaTau * driftlength;
 
   return 1;
 
index a5f40cdd705820dcfbe446135e36de6e3e2430ac..c27a391aa498dc467328edf750e6e8d5c8382c56 100644 (file)
@@ -67,8 +67,9 @@ class AliTRDdigitizer : public AliDigitizer {
           Float_t  GetLorentzFactor(Float_t vdrift);
 
   virtual Double_t TimeStruct(Float_t vdrift, Double_t time, Double_t z);
-  virtual Int_t    Diffusion(Float_t vdrift, Double_t driftlength, Double_t *xyz);
-  virtual Int_t    ExB(Float_t vdrift, Double_t driftlength, Double_t *xyz);  
+  virtual Int_t    Diffusion(Float_t vdrift, Double_t absdriftlength
+                           , Double_t &lRow, Double_t &lCol, Double_t &lTime);
+  virtual Int_t    ExB(Float_t vdrift, Double_t driftlength, Double_t &lRow);
 
   AliTRDdigitsManager *Digits() const                   { return fDigitsManager;  }
   
index 7b18cee43b83e42d66004e34f924f8069ca2929b..b1548d185256f193b264876df12c6444a010d98a 100644 (file)
@@ -587,11 +587,11 @@ void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
 
       // Position the frames of the chambers in the TRD mother volume
       xpos  = 0.0;
-      ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.0;
+      ypos  = fClength[iplan][0] + fClength[iplan][1] + fClength[iplan][2]/2.0;
       for (Int_t ic = 0; ic < icham; ic++) {
-        ypos += fClength[iplan][ic];        
+        ypos -= fClength[iplan][ic];        
       }
-      ypos += fClength[iplan][icham]/2.0;
+      ypos -= fClength[iplan][icham]/2.0;
       zpos  = fgkVrocsm + fgkSMpltT + fgkCraH/2.0 + fgkCdrH/2.0 - fgkSheight/2.0 
             + iplan * (fgkCH + fgkVspace);
       // The lower aluminum frame, radiator + drift region
@@ -1043,11 +1043,11 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
       gMC->Gsvolu(cTagV,"BOX",idtmed[1302-1],parServ,kNparServ);
 
       xpos  = 0.0;
-      ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.0;
+      ypos  = fClength[iplan][0] + fClength[iplan][1] + fClength[iplan][2]/2.0;
       for (Int_t ic = 0; ic < icham; ic++) {
-        ypos += fClength[iplan][ic];        
+        ypos -= fClength[iplan][ic];        
       }
-      ypos += fClength[iplan][icham]/2.0;
+      ypos -= fClength[iplan][icham]/2.0;
       zpos  = fgkVrocsm + fgkSMpltT + fgkCH + fgkVspace/2.0 - fgkSheight/2.0 
             + iplan * (fgkCH + fgkVspace);
       zpos -= 0.742/2.0;
@@ -1536,7 +1536,13 @@ AliTRDgeometry *AliTRDgeometry::GetGeometry(AliRunLoader *runLoader)
 Bool_t AliTRDgeometry::ReadGeoMatrices()
 {
   //
-  // Read geo matrices from current gGeoManager for each TRD sector
+  // Read the geo matrices from the current gGeoManager for each TRD detector
+  //
+  // This fill three arrays of TGeoHMatrix, ordered by detector numbers 
+  // for fast access:
+  //   fMatrixArray:           Used for transformation local <-> global ???
+  //   fMatrixCorrectionArray: Used for transformation local <-> tracking system
+  //   fMatrixGeo:             Alignable objects
   //
 
   if (!gGeoManager) {
@@ -1546,11 +1552,11 @@ Bool_t AliTRDgeometry::ReadGeoMatrices()
   fMatrixArray           = new TObjArray(kNdet); 
   fMatrixCorrectionArray = new TObjArray(kNdet);
   fMatrixGeo             = new TObjArray(kNdet);
-  AliAlignObjAngles o;
 
   for (Int_t iLayer = AliAlignObj::kTRD1; iLayer <= AliAlignObj::kTRD6; iLayer++) {
     for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(iLayer); iModule++) {
 
+      // Find the path to the different alignable objects (ROCs)
       UShort_t     volid   = AliAlignObj::LayerToVolUID(iLayer,iModule);
       const char  *symname = AliAlignObj::SymName(volid);
       TGeoPNEntry *pne     = gGeoManager->GetAlignableEntry(symname);
@@ -1561,36 +1567,38 @@ Bool_t AliTRDgeometry::ReadGeoMatrices()
       if (!gGeoManager->cd(path)) {
         return kFALSE;
       }
-      TGeoHMatrix *m         = gGeoManager->GetCurrentMatrix();
-      Int_t        iLayerTRD = iLayer - AliAlignObj::kTRD1;
-      Int_t        isector   = Nsect() - 1 - (iModule/Ncham());
-      Int_t        ichamber  = Ncham() - 1 - (iModule%Ncham());
-      Int_t        lid       = GetDetector(iLayerTRD,ichamber,isector);    
-
-      //
-      // Local geo system z-x-y  to x-y--z 
-      //
-      fMatrixGeo->AddAt(new TGeoHMatrix(*m),lid);
-      
-      TGeoRotation mchange; 
-      mchange.RotateY(90); 
-      mchange.RotateX(90);
-
-      TGeoHMatrix gMatrix(mchange.Inverse());
-      gMatrix.MultiplyLeft(m);
-      fMatrixArray->AddAt(new TGeoHMatrix(gMatrix),lid); 
-
-      //
-      // Cluster transformation matrix
-      //
-      TGeoHMatrix  rotMatrix(mchange.Inverse());
-      rotMatrix.MultiplyLeft(m);
+
+      // Get the geo matrix of the current alignable object
+      // and add it to the corresponding list
+      TGeoHMatrix *matrix   = gGeoManager->GetCurrentMatrix();
+      Int_t        iplane   = iLayer - AliAlignObj::kTRD1;
+      Int_t        isector  = iModule / Ncham();
+      Int_t        ichamber = iModule % Ncham();
+      Int_t        idet     = GetDetector(iplane,ichamber,isector);
+      fMatrixGeo->AddAt(new TGeoHMatrix(* matrix),idet);
+
+      // Construct the geo matrix for the local <-> global transformation
+      // and add it to the corresponding list.
+      // In addition to the original geo matrix also a rotation of the
+      // kind z-x-y to x-y--z is applied.
+      TGeoRotation rotMatrixA;
+      rotMatrixA.RotateY(90); 
+      rotMatrixA.RotateX(90);
+      TGeoHMatrix matrixGlobal(rotMatrixA.Inverse());
+      matrixGlobal.MultiplyLeft(matrix);
+      fMatrixArray->AddAt(new TGeoHMatrix(matrixGlobal),idet);
+
+      // Construct the geo matrix for the cluster transformation
+      // and add it to the corresponding list.
+      // In addition to the original geo matrix also a rotation of the
+      // kind x-y--z to z-x-y and a rotation by the sector angle is applied.
       Double_t sectorAngle = 20.0 * (isector % 18) + 10.0;
-      TGeoHMatrix  rotSector;
+      TGeoHMatrix rotMatrixB(rotMatrixA.Inverse());
+      rotMatrixB.MultiplyLeft(matrix);
+      TGeoHMatrix rotSector;
       rotSector.RotateZ(sectorAngle);
-      rotMatrix.MultiplyLeft(&rotSector);      
-
-      fMatrixCorrectionArray->AddAt(new TGeoHMatrix(rotMatrix),lid);       
+      rotMatrixB.MultiplyLeft(&rotSector);      
+      fMatrixCorrectionArray->AddAt(new TGeoHMatrix(rotMatrixB),idet);
 
     }    
   }
index 95a543d1f5502f344a5d907aa99f08a53a7f8580..68641557434e32d85dfd77df33e2c2c3d6894f3a 100644 (file)
@@ -36,7 +36,7 @@ class AliTRDgeometry : public AliGeometry {
   virtual void     Init();
   virtual void     CreateGeometry(Int_t *idtmed);
   virtual Int_t    IsVersion()                                         { return 1;               }
-  virtual Bool_t   Impact(const TParticle) const                     { return kTRUE;           }
+  virtual Bool_t   Impact(const TParticle *) const                     { return kTRUE;           }
   virtual Bool_t   IsHole(Int_t /*p*/, Int_t /*c*/, Int_t /*s*/) const { return kFALSE;          }
 
   virtual Bool_t   Rotate(Int_t d, Double_t *pos, Double_t *rot) const;
@@ -72,8 +72,8 @@ class AliTRDgeometry : public AliGeometry {
           Float_t  GetChamberWidth(Int_t p) const                      { return fCwidth[p];      }
           Float_t  GetChamberLength(Int_t p, Int_t c) const            { return fClength[p][c];  }
 
-  virtual void     GetGlobal(const AliRecPoint*, TVector3&, TMatrixF& ) const { }; 
-  virtual void     GetGlobal(const AliRecPoint*, TVector3& ) const            { };
+  virtual void     GetGlobal(const AliRecPoint*, TVector3&, TMatrixF&) const { }; 
+  virtual void     GetGlobal(const AliRecPoint*, TVector3&) const            { };
  
   static  Double_t GetAlpha()                                          { return 2.0 
                                                                            * 3.14159265358979324 
@@ -219,8 +219,8 @@ class AliTRDgeometry : public AliGeometry {
   Float_t               fChamberUFboxd[3*kNdets][3];         //  [3] = x, y, z
   Float_t               fChamberUUboxd[3*kNdets][3];         // 
 
-  TObjArray            *fMatrixArray;                        //! Transformation Global to Local
-  TObjArray            *fMatrixCorrectionArray;              //! Transformation Cluster to  Tracking systerm
+  TObjArray            *fMatrixArray;                        //! Transformation global to local
+  TObjArray            *fMatrixCorrectionArray;              //! Transformation cluster to tracking system
   TObjArray            *fMatrixGeo;                          //! Geo matrices
 
   ClassDef(AliTRDgeometry,12)                                //  TRD geometry class
index 89cf7140b1ab28d1b41b08ff7d85dffa14474477..b21b379742d13015266137ab23881f8b60420b1f 100644 (file)
@@ -265,14 +265,9 @@ AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c)
   // Row direction
   //
   fPadRow = new Double_t[fNrows];
-  Double_t row = fGeo->GetChamberLength(p,0)
-              + fGeo->GetChamberLength(p,1)
-               + fGeo->GetChamberLength(p,2) / 2.0
+  Double_t row = fGeo->GetChamberLength(p,c) / 2.0
                - fGeo->RpadW()
                - fLengthRim;
-  for (Int_t ic = 0; ic < c; ic++) {
-    row -= fGeo->GetChamberLength(p,ic);
-  }
   for (Int_t ir = 0; ir < fNrows; ir++) {
     fPadRow[ir] = row;
     row -= fRowSpacing;
@@ -484,17 +479,16 @@ Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi
-                                   , Double_t /*rowOffset*/) const
+Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const
 {
   //
   // Finds the pad column number for a given global rphi-position
   //
 
-  Int_t    col    = 0;
-  Int_t    nabove = 0;
-  Int_t    nbelow = 0;
-  Int_t    middle = 0;
+  Int_t col    = 0;
+  Int_t nabove = 0;
+  Int_t nbelow = 0;
+  Int_t middle = 0;
 
   if ((rphi > GetCol0()  ) || 
       (rphi < GetColEnd())) {
index d9bcaf827cda6dec0d447c2cb8b4226167f748d7..8e44e0eb67881ce04f1a20a988eae70d9be1f9c4 100644 (file)
@@ -33,7 +33,7 @@ class AliTRDpadPlane : public TObject {
   virtual void       Copy(TObject &p) const;
 
   Int_t    GetPadRowNumber(Double_t z) const;
-  Int_t    GetPadColNumber(Double_t rphi, Double_t rowOffset) const;
+  Int_t    GetPadColNumber(Double_t rphi) const;
   Double_t GetTiltOffset(Double_t rowOffset) const 
                                              { return fTiltingTan * (rowOffset - 0.5*fLengthIPad); };
   Double_t GetPadRowOffset(Int_t row, Double_t z) const
index 4f4cd2fb6eabe814fbab48d2599c3e7e66cd54bc..aeacf8e3cafb63ee0dfaf9ab3374340f6f26f942 100644 (file)
@@ -496,7 +496,7 @@ void AliTRDv1::StepManagerGeant()
       cIdChamber[0]   = cIdCurrent[2];
       cIdChamber[1]   = cIdCurrent[3];
       Int_t idChamber = (atoi(cIdChamber) % kNdetsec);
-      cha = kNcham - ((Int_t) idChamber / kNplan) - 1;
+      cha = ((Int_t) idChamber / kNplan);
       pla = ((Int_t) idChamber % kNplan);
 
       // The detector number
@@ -742,7 +742,7 @@ void AliTRDv1::StepManagerErmilova()
       cIdChamber[0] = cIdCurrent[2];
       cIdChamber[1] = cIdCurrent[3];
       Int_t idChamber = (atoi(cIdChamber) % kNdetsec);
-      cha = kNcham - ((Int_t) idChamber / kNplan) - 1;
+      cha = ((Int_t) idChamber / kNplan);
       pla = ((Int_t) idChamber % kNplan);
 
       // The detector number
@@ -932,7 +932,7 @@ void AliTRDv1::StepManagerFixedStep()
   cIdChamber[0]   = cIdCurrent[2];
   cIdChamber[1]   = cIdCurrent[3];
   Int_t idChamber = (atoi(cIdChamber) % kNdetsec);
-  cha = kNcham - ((Int_t) idChamber / kNplan) - 1;
+  cha = ((Int_t) idChamber / kNplan);
   pla = ((Int_t) idChamber % kNplan);
 
   // The detector number