]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibraMode.cxx
Coverity fix
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraMode.cxx
index 1dfada6c9b400daae93ee6e2cf59f6eb41620887..21c73ffc3c6998f597dda7c450063f44104cca31 100644 (file)
 // AliTRDCalibraMode                                                             
 //                                                                             
 // This class is for the modes of the TRD calibration.        
-// The user has to choose with the functions SetNz and SetNrphi the precision of the calibration. 
+// The user has to choose with the functions SetNz and SetNrphi
+// the precision of the calibration. 
+// Author:
+//   R. Bailhache (R.Bailhache@gsi.de)
+//                            
 //Begin_Html
 /*
 <br>
 */
 //End_Html 
 //
-//                            
-// Author:
-//   R. Bailhache (R.Bailhache@gsi.de)
+//
+// Moreover two other more general granularities:
+// It can not work with AliTRDCalibraVector
+// 10 corresponds to per supermodule
+// 100 all together
 //                            
 //////////////////////////////////////////////////////////////////////////////////////
 
 #include "AliLog.h"
 
 #include "AliTRDCalibraMode.h"
-#include "AliTRDCommonParam.h"
+#include "AliTRDgeometry.h"
 
 ClassImp(AliTRDCalibraMode)
 
 //______________________________________________________________________________________
 AliTRDCalibraMode::AliTRDCalibraMode()
   :TObject()
+  ,fGeo(0)
 {
   //
   // Default constructor
@@ -89,12 +96,15 @@ AliTRDCalibraMode::AliTRDCalibraMode()
     fNfragRphi[i] = -1;
     fXbins[i]     = -1;
   }
-   
+  
+  fGeo = new AliTRDgeometry();
 }
 
 //______________________________________________________________________________________
 AliTRDCalibraMode::AliTRDCalibraMode(const AliTRDCalibraMode &c)
   :TObject(c)
+  ,fGeo(0)
 {
   //
   // Copy constructor
@@ -116,7 +126,13 @@ AliTRDCalibraMode::AliTRDCalibraMode(const AliTRDCalibraMode &c)
     fDetChamb2[k] = c.fDetChamb2[k];
   }
 
+  if (fGeo) {
+    delete fGeo;
+  }
+  fGeo = new AliTRDgeometry();
+
 }
+
 //____________________________________________________________________________________
 AliTRDCalibraMode::~AliTRDCalibraMode()
 {
@@ -124,6 +140,32 @@ AliTRDCalibraMode::~AliTRDCalibraMode()
   // AliTRDCalibraMode destructor
   //
 
+  if (fGeo) {
+    delete fGeo;
+  }
+
+}
+
+//_____________________________________________________________________________
+void AliTRDCalibraMode::SetPerSuperModule(Int_t i)
+{
+  //
+  // Set the mode of calibration group per supermodule
+  // 
+
+  fNz[i] = 10;
+  fNrphi[i] = 10; 
+}
+
+//_____________________________________________________________________________
+void AliTRDCalibraMode::SetAllTogether(Int_t i)
+{
+  //
+  // Set the mode of calibration group all together
+  // 
+
+  fNz[i] = 100;
+  fNrphi[i] = 100; 
 }
 
 //_____________________________________________________________________________
@@ -137,8 +179,8 @@ void AliTRDCalibraMode::SetNz(Int_t i, Short_t Nz)
       (Nz <  5)) {
     fNz[i] = Nz; 
   }
-  else { 
-    AliInfo("You have to choose between 0 and 4");
+  else {
+    AliInfo("You have to choose between 0 and 4.");
   }
 
 }
@@ -155,7 +197,7 @@ void AliTRDCalibraMode::SetNrphi(Int_t i, Short_t Nrphi)
     fNrphi[i] = Nrphi; 
   }
   else {
-    AliInfo("You have to choose between 0 and 6");
+    AliInfo("You have to choose between 0 and 6 or 10/100.");
   }
 
 }
@@ -172,10 +214,10 @@ void AliTRDCalibraMode::ModePadCalibration(Int_t iChamb, Int_t i)
   fNnZ[i]    = 0;
   fNnRphi[i] = 0;
   
-  if ((fNz[i] == 0) && (iChamb == 2)) {
+  if (((fNz[i] == 0) || (fNz[i] == 10) || (fNz[i] == 100)) && (iChamb == 2)) {
     fNnZ[i] = 12;
   }
-  if ((fNz[i] == 0) && (iChamb != 2)) {
+  if (((fNz[i] == 0) || (fNz[i] == 10) || (fNz[i] == 100)) && (iChamb != 2)) {
     fNnZ[i] = 16;
   }  
   if ((fNz[i] == 1) && (iChamb == 2)) {
@@ -197,7 +239,7 @@ void AliTRDCalibraMode::ModePadCalibration(Int_t iChamb, Int_t i)
     fNnZ[i] = 1;
   }
    
-  if (fNrphi[i] == 0) {
+  if ((fNrphi[i] == 0) || (fNrphi[i] == 10) || (fNrphi[i] == 100)) {
     fNnRphi[i] = 144;
   }
   if (fNrphi[i] == 1) {
@@ -222,7 +264,7 @@ void AliTRDCalibraMode::ModePadCalibration(Int_t iChamb, Int_t i)
 }
 
 //_____________________________________________________________________________________________
-Bool_t AliTRDCalibraMode::ModePadFragmentation(Int_t iPlane,Int_t iChamb, Int_t iSect, Int_t i)
+Bool_t AliTRDCalibraMode::ModePadFragmentation(Int_t iLayer,Int_t iStack, Int_t iSect, Int_t i)
 {
   //
   // Definition of the calibration mode
@@ -232,16 +274,10 @@ Bool_t AliTRDCalibraMode::ModePadFragmentation(Int_t iPlane,Int_t iChamb, Int_t
 
   fNfragZ[i]    = 0;
   fNfragRphi[i] = 0;
-  
-  AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
-  if (!parCom) {
-    AliInfo("Could not get CommonParam Manager");
-    return kFALSE;
-  }
 
   // A little geometry:
-  Int_t rowMax = parCom->GetRowMax(iPlane,iChamb,iSect);
-  Int_t colMax = parCom->GetColMax(iPlane);
+  Int_t rowMax = fGeo->GetRowMax(iLayer,iStack,iSect);
+  Int_t colMax = fGeo->GetColMax(iLayer);
   
   // The fragmentation
   if (fNnZ[i]    != 0) {
@@ -295,14 +331,28 @@ void AliTRDCalibraMode::CalculXBins(Int_t idect, Int_t i)
   fXbins[i] = 0;
   AliDebug(2, Form("detector: %d", idect));
 
+  // Total
+  if((fNz[i] == 100) && (fNrphi[i] == 100)) {
+    fXbins[i] = 0;
+    return; 
+  }
+
   // In which sector?
   Int_t sector = GetSector(idect);
-  fXbins[i] += sector*(6*fDetChamb2[i]+6*4*fDetChamb0[i]);
  
-  // In which chamber?
-  Int_t chamber = GetChamber(idect);
+  // First per supermodule
+  if((fNz[i] == 10) && (fNrphi[i] == 10)) {
+    fXbins[i] = sector;
+    return;
+  }
+  
+  fXbins[i] += sector*(6*fDetChamb2[i]+6*4*fDetChamb0[i]);
+
+  // In which stack?
+  Int_t stack = GetStack(idect);
   Int_t kc      = 0;
-  while (kc < chamber) {
+  while (kc < stack) {
     if (kc == 2) {
       fXbins[i] += 6 * fDetChamb2[i];
     }
@@ -312,13 +362,13 @@ void AliTRDCalibraMode::CalculXBins(Int_t idect, Int_t i)
     kc ++;
   }
   
-  // In which plane?
-  Int_t plane = GetPlane(idect);
-  if (chamber == 2) {
-    fXbins[i] += plane*fDetChamb2[i];
+  // In which layer?
+  Int_t layer = GetLayer(idect);
+  if (stack == 2) {
+    fXbins[i] += layer*fDetChamb2[i];
   }
   else {
-    fXbins[i] += plane*fDetChamb0[i];
+    fXbins[i] += layer*fDetChamb0[i];
   }
  
 }
@@ -360,7 +410,7 @@ void AliTRDCalibraMode::SetDetChamb2(Int_t i)
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDCalibraMode::GetPlane(Int_t d) const
+Int_t AliTRDCalibraMode::GetLayer(Int_t d) const
 {
   //
   // Reconstruct the plane number from the detector number
@@ -371,15 +421,15 @@ Int_t AliTRDCalibraMode::GetPlane(Int_t d) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDCalibraMode::GetChamber(Int_t d) const
+Int_t AliTRDCalibraMode::GetStack(Int_t d) const
 {
   //
-  // Reconstruct the chamber number from the detector number
+  // Reconstruct the stack number from the detector number
   //
 
-  Int_t fgkNplan = 6;
+  const Int_t kNlayer = 6;
 
-  return ((Int_t) (d % 30) / fgkNplan);
+  return ((Int_t) (d % 30) / kNlayer);
 
 }