]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDgeometry.cxx
Adding statistical function (Marian)
[u/mrichter/AliRoot.git] / TRD / AliTRDgeometry.cxx
index 22e64a99baa6b44649997c51e82888944ea361c4..f62e2253d86f7e76ccb553424f3fc6676ac88da1 100644 (file)
@@ -45,108 +45,118 @@ ClassImp(AliTRDgeometry)
   //
   // The geometry constants
   //
-  const Int_t   AliTRDgeometry::fgkNsect   = kNsect;
-  const Int_t   AliTRDgeometry::fgkNplan   = kNplan;
-  const Int_t   AliTRDgeometry::fgkNcham   = kNcham;
-  const Int_t   AliTRDgeometry::fgkNdet    = kNdet;
+  const Int_t    AliTRDgeometry::fgkNsect     = kNsect;
+  const Int_t    AliTRDgeometry::fgkNplan     = kNplan;
+  const Int_t    AliTRDgeometry::fgkNcham     = kNcham;
+  const Int_t    AliTRDgeometry::fgkNdet      = kNdet;
 
   //
   // Dimensions of the detector
   //
 
   // Parameter of the BTRD mother volumes 
-  const Float_t AliTRDgeometry::fgkSheight =  77.9; 
-  const Float_t AliTRDgeometry::fgkSwidth1 =  94.881; 
-  const Float_t AliTRDgeometry::fgkSwidth2 = 122.353;
-  const Float_t AliTRDgeometry::fgkSlength = 751.0;
+  const Float_t  AliTRDgeometry::fgkSheight   =  77.9; 
+  const Float_t  AliTRDgeometry::fgkSwidth1   =  94.881; 
+  const Float_t  AliTRDgeometry::fgkSwidth2   = 122.353;
+  const Float_t  AliTRDgeometry::fgkSlength   = 751.0;
 
   // The super module side plates
-  const Float_t AliTRDgeometry::fgkSMpltT  =   0.2;
+  const Float_t  AliTRDgeometry::fgkSMpltT    =   0.2;
 
   // Height of different chamber parts
   // Radiator
-  const Float_t AliTRDgeometry::fgkCraH    =   4.8; 
+  const Float_t  AliTRDgeometry::fgkCraH      =   4.8; 
   // Drift region
-  const Float_t AliTRDgeometry::fgkCdrH    =   3.0;
+  const Float_t  AliTRDgeometry::fgkCdrH      =   3.0;
   // Amplification region
-  const Float_t AliTRDgeometry::fgkCamH    =   0.7;
+  const Float_t  AliTRDgeometry::fgkCamH      =   0.7;
   // Readout
-  const Float_t AliTRDgeometry::fgkCroH    =   2.316;
+  const Float_t  AliTRDgeometry::fgkCroH      =   2.316;
   // Total height
-  const Float_t AliTRDgeometry::fgkCH      = AliTRDgeometry::fgkCraH
-                                           + AliTRDgeometry::fgkCdrH
-                                           + AliTRDgeometry::fgkCamH
-                                           + AliTRDgeometry::fgkCroH;  
+  const Float_t  AliTRDgeometry::fgkCH        = AliTRDgeometry::fgkCraH
+                                              + AliTRDgeometry::fgkCdrH
+                                              + AliTRDgeometry::fgkCamH
+                                              + AliTRDgeometry::fgkCroH;  
 
   // Vertical spacing of the chambers
-  const Float_t AliTRDgeometry::fgkVspace  =   1.784;
+  const Float_t  AliTRDgeometry::fgkVspace    =   1.784;
   // Horizontal spacing of the chambers
-  const Float_t AliTRDgeometry::fgkHspace  =   2.0;
+  const Float_t  AliTRDgeometry::fgkHspace    =   2.0;
   // Radial distance of the first ROC to the outer plates of the SM
-  const Float_t AliTRDgeometry::fgkVrocsm  =   1.2;
+  const Float_t  AliTRDgeometry::fgkVrocsm    =   1.2;
 
   // Thicknesses of different parts of the chamber frame
   // Lower aluminum frame
-  const Float_t AliTRDgeometry::fgkCalT    =   0.4;
+  const Float_t  AliTRDgeometry::fgkCalT      =   0.4;
   // Lower Wacosit frame sides
-  const Float_t AliTRDgeometry::fgkCclsT   =   0.21;
+  const Float_t  AliTRDgeometry::fgkCclsT     =   0.21;
   // Lower Wacosit frame front
-  const Float_t AliTRDgeometry::fgkCclfT   =   1.0;
+  const Float_t  AliTRDgeometry::fgkCclfT     =   1.0;
   // Thickness of glue around radiator
-  const Float_t AliTRDgeometry::fgkCglT    =   0.25;
+  const Float_t  AliTRDgeometry::fgkCglT      =   0.25;
   // Upper Wacosit frame
-  const Float_t AliTRDgeometry::fgkCcuT    =   0.9;
+  const Float_t  AliTRDgeometry::fgkCcuT      =   0.9;
   // Al frame of back panel
-  const Float_t AliTRDgeometry::fgkCauT    =   1.5;
+  const Float_t  AliTRDgeometry::fgkCauT      =   1.5;
   // Additional Al of the lower chamber frame
-  const Float_t AliTRDgeometry::fgkCalW    =   1.11;
+  const Float_t  AliTRDgeometry::fgkCalW      =   1.11;
 
   // Additional width of the readout chamber frames
-  const Float_t AliTRDgeometry::fgkCroW    =   0.9;
+  const Float_t  AliTRDgeometry::fgkCroW      =   0.9;
 
   // Difference of outer chamber width and pad plane width
-  const Float_t AliTRDgeometry::fgkCpadW   =   0.0;
-  const Float_t AliTRDgeometry::fgkRpadW   =   1.0;
+  const Float_t  AliTRDgeometry::fgkCpadW     =   0.0;
+  const Float_t  AliTRDgeometry::fgkRpadW     =   1.0;
 
   //
   // Thickness of the the material layers
   //
-  const Float_t AliTRDgeometry::fgkMyThick = 0.005;
-  const Float_t AliTRDgeometry::fgkRaThick = 0.3233;  
-  const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH;    
-  const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH;
-  const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick
-                                           + AliTRDgeometry::fgkAmThick;
-  const Float_t AliTRDgeometry::fgkWrThick = 0.0002;
-  const Float_t AliTRDgeometry::fgkCuThick = 0.0072; 
-  const Float_t AliTRDgeometry::fgkGlThick = 0.05;
-  const Float_t AliTRDgeometry::fgkSuThick = 0.0919; 
-  const Float_t AliTRDgeometry::fgkRcThick = 0.0058;
-  const Float_t AliTRDgeometry::fgkRpThick = 0.0632;
-  const Float_t AliTRDgeometry::fgkRoThick = 0.0028;
+  const Float_t  AliTRDgeometry::fgkMyThick   = 0.005;
+  const Float_t  AliTRDgeometry::fgkRaThick   = 0.3233;  
+  const Float_t  AliTRDgeometry::fgkDrThick   = AliTRDgeometry::fgkCdrH;    
+  const Float_t  AliTRDgeometry::fgkAmThick   = AliTRDgeometry::fgkCamH;
+  const Float_t  AliTRDgeometry::fgkXeThick   = AliTRDgeometry::fgkDrThick
+                                              + AliTRDgeometry::fgkAmThick;
+  const Float_t  AliTRDgeometry::fgkWrThick   = 0.0002;
+  const Float_t  AliTRDgeometry::fgkCuThick   = 0.0072; 
+  const Float_t  AliTRDgeometry::fgkGlThick   = 0.05;
+  const Float_t  AliTRDgeometry::fgkSuThick   = 0.0919; 
+  const Float_t  AliTRDgeometry::fgkRcThick   = 0.0058;
+  const Float_t  AliTRDgeometry::fgkRpThick   = 0.0632;
+  const Float_t  AliTRDgeometry::fgkRoThick   = 0.0028;
 
   //
   // Position of the material layers
   //
-  //const Float_t AliTRDgeometry::fgkRaZpos  = -1.50;
-  const Float_t AliTRDgeometry::fgkRaZpos  =  0.0;
-  const Float_t AliTRDgeometry::fgkDrZpos  =  2.4;
-  const Float_t AliTRDgeometry::fgkAmZpos  =  0.0;
-  const Float_t AliTRDgeometry::fgkWrZpos  =  0.0;
-  const Float_t AliTRDgeometry::fgkCuZpos  = -0.9995;
-  const Float_t AliTRDgeometry::fgkGlZpos  = -0.5; 
-  const Float_t AliTRDgeometry::fgkSuZpos  =  0.0;
-  const Float_t AliTRDgeometry::fgkRcZpos  =  1.04;
-  const Float_t AliTRDgeometry::fgkRpZpos  =  1.0;
-  const Float_t AliTRDgeometry::fgkRoZpos  =  1.05;
+  const Float_t  AliTRDgeometry::fgkRaZpos    =  0.0;
+  const Float_t  AliTRDgeometry::fgkDrZpos    =  2.4;
+  const Float_t  AliTRDgeometry::fgkAmZpos    =  0.0;
+  const Float_t  AliTRDgeometry::fgkWrZpos    =  0.0;
+  const Float_t  AliTRDgeometry::fgkCuZpos    = -0.9995;
+  const Float_t  AliTRDgeometry::fgkGlZpos    = -0.5; 
+  const Float_t  AliTRDgeometry::fgkSuZpos    =  0.0;
+  const Float_t  AliTRDgeometry::fgkRcZpos    =  1.04;
+  const Float_t  AliTRDgeometry::fgkRpZpos    =  1.0;
+  const Float_t  AliTRDgeometry::fgkRoZpos    =  1.05;
+
+  const Int_t    AliTRDgeometry::fgkMCMmax    = 16;   
+  const Int_t    AliTRDgeometry::fgkMCMrow    = 4;   
+  const Int_t    AliTRDgeometry::fgkROBmaxC0  = 6; 
+  const Int_t    AliTRDgeometry::fgkROBmaxC1  = 8; 
+  const Int_t    AliTRDgeometry::fgkADCmax    = 21;   
+  const Int_t    AliTRDgeometry::fgkTBmax     = 60;   
+  const Int_t    AliTRDgeometry::fgkPadmax    = 18;   
+  const Int_t    AliTRDgeometry::fgkColmax    = 144;
+  const Int_t    AliTRDgeometry::fgkRowmaxC0  = 12;
+  const Int_t    AliTRDgeometry::fgkRowmaxC1  = 16;
 
   const Double_t AliTRDgeometry::fgkTime0Base = 300.65;
-  const Float_t  AliTRDgeometry::fgkTime0[6]  = { fgkTime0Base + 0 * (Cheight() + Cspace()), 
-                                                  fgkTime0Base + 1 * (Cheight() + Cspace()), 
-                                                  fgkTime0Base + 2 * (Cheight() + Cspace()), 
-                                                  fgkTime0Base + 3 * (Cheight() + Cspace()), 
-                                                  fgkTime0Base + 4 * (Cheight() + Cspace()), 
-                                                  fgkTime0Base + 5 * (Cheight() + Cspace()) };
+  const Float_t  AliTRDgeometry::fgkTime0[6]  = { fgkTime0Base + 0 * (Cheight() + Cspace()) 
+                                                , fgkTime0Base + 1 * (Cheight() + Cspace()) 
+                                                , fgkTime0Base + 2 * (Cheight() + Cspace()) 
+                                                , fgkTime0Base + 3 * (Cheight() + Cspace()) 
+                                                , fgkTime0Base + 4 * (Cheight() + Cspace()) 
+                                                , fgkTime0Base + 5 * (Cheight() + Cspace())};
 
 //_____________________________________________________________________________
 AliTRDgeometry::AliTRDgeometry()
@@ -250,7 +260,7 @@ void AliTRDgeometry::Init()
   // The rotation matrix elements
   Float_t phi = 0.0;
   for (isect = 0; isect < fgkNsect; isect++) {
-    phi = -2.0 * TMath::Pi() /  (Float_t) fgkNsect * ((Float_t) isect + 0.5);
+    phi = 2.0 * TMath::Pi() /  (Float_t) fgkNsect * ((Float_t) isect + 0.5);
     fRotA11[isect] = TMath::Cos(phi);
     fRotA12[isect] = TMath::Sin(phi);
     fRotA21[isect] = TMath::Sin(phi);
@@ -577,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
@@ -1033,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;
@@ -1404,6 +1414,88 @@ Int_t AliTRDgeometry::GetSector(Int_t d) const
 
 }
 
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetPadRowFromMCM(Int_t irob, Int_t imcm) const
+{
+
+  // return on which row this mcm sits 
+
+  return fgkMCMrow*(irob/2) + imcm/fgkMCMrow;
+
+;
+}
+
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const
+{
+  //
+  // return which pad is connected to this adc channel.
+  //
+  // ADC channels 2 to 19 are connected directly to a pad via PASA.
+  // ADC channels 0, 1 and 20 are not connected to the PASA on this MCM.
+  // So the mapping (for MCM 0 on ROB 0 at least) is
+  //
+  // ADC channel  :   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
+  // Pad          :   x  x 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0  x
+  // Func. returns:  19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 -1
+  //
+  // Here we assume that 21 ADC channels are transmitted. Maybe it will only be
+  // 18 later on!!!
+  //
+  // This function maps also correctly the channels that cross from MCM to MCM
+  // (ADC channels 0, 1, 20).
+  //
+
+  return (17-(iadc-2)) + (imcm%fgkMCMrow)*fgkPadmax + GetRobSide(irob)*fgkColmax/2;
+
+}
+
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetMCMfromPad(Int_t irow, Int_t icol) const
+{
+
+  // return on which mcm this pad is
+
+  if ( irow < 0 || icol < 0 || irow > fgkRowmaxC1 || icol > fgkColmax ) return -1;
+
+  return (icol%(fgkColmax/2))/fgkPadmax + fgkMCMrow*(irow%fgkMCMrow);
+
+}
+
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetROBfromPad(Int_t irow, Int_t icol) const
+{
+
+  // return on which rob this pad is
+
+  return (irow/fgkMCMrow)*2 + GetColSide(icol);
+
+}
+
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetRobSide(Int_t irob) const
+{
+
+  // return on which side this rob sits (A side = 0, B side = 1)
+
+  if ( irob < 0 || irob >= fgkROBmaxC1 ) return -1;
+
+  return irob%2;
+
+}
+
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetColSide(Int_t icol) const
+{
+
+  // return on which side this column sits (A side = 0, B side = 1)
+
+  if ( icol < 0 || icol >= fgkColmax ) return -1;
+
+  return icol/(fgkColmax/2);
+
+}
+
 //_____________________________________________________________________________
 AliTRDgeometry *AliTRDgeometry::GetGeometry(AliRunLoader *runLoader)
 {
@@ -1427,8 +1519,10 @@ AliTRDgeometry *AliTRDgeometry::GetGeometry(AliRunLoader *runLoader)
 
   if (!geom) {
     // If it is not in the file, try to get it from the run loader 
-    AliTRD *trd = (AliTRD *) runLoader->GetAliRun()->GetDetector("TRD");
-    geom = trd->GetGeometry();
+    if (runLoader->GetAliRun()) {
+      AliTRD *trd = (AliTRD *) runLoader->GetAliRun()->GetDetector("TRD");
+      if (trd) geom = trd->GetGeometry();
+    }
   }
   if (!geom) {
     AliErrorGeneral("AliTRDgeometry::GetGeometry","Geometry not found");
@@ -1444,7 +1538,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) {
@@ -1454,11 +1554,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);
@@ -1469,36 +1569,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);
 
     }    
   }