]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDDigitizer.cxx
implementation of effc++
[u/mrichter/AliRoot.git] / PMD / AliPMDDigitizer.cxx
index 780d72e599bdf7d4dcac887d9545e4e7630994fd..7d76dbc590e9df95c296927506cba01faf8ca86c 100644 (file)
@@ -33,8 +33,6 @@
 
 #include "AliLog.h"
 #include "AliRun.h"
-#include "AliPMD.h"
-#include "AliPMDhit.h"
 #include "AliHit.h"
 #include "AliDetector.h"
 #include "AliRunLoader.h"
 #include "AliRunDigitizer.h"
 #include "AliDigitizer.h"
 #include "AliHeader.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
+#include "AliMC.h"
 
+#include "AliPMD.h"
+#include "AliPMDhit.h"
 #include "AliPMDcell.h"
 #include "AliPMDsdigit.h"
 #include "AliPMDdigit.h"
+#include "AliPMDCalibData.h"
 #include "AliPMDDigitizer.h"
-#include "AliMC.h"
+
 
 ClassImp(AliPMDDigitizer)
 
@@ -82,7 +87,25 @@ AliPMDDigitizer::AliPMDDigitizer() :
            }
        }
     }
+  fCalibData = GetCalibData();
+
+}
+//____________________________________________________________________________
+AliPMDDigitizer::AliPMDDigitizer(const AliPMDDigitizer& /*digitizer*/):
+  AliDigitizer(/* digitizer */)
+{
+  // copy constructor
+  AliError("Copy constructor not allowed ");
+  
+}
+//____________________________________________________________________________
 
+AliPMDDigitizer & AliPMDDigitizer::operator=(const AliPMDDigitizer& /*digitizer*/)
+{
+  // Assignment operator
+  AliError("Assignement operator not allowed ");
+
+  return *this;
 }
 //____________________________________________________________________________
 AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager) 
@@ -101,6 +124,8 @@ AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager)
 {
   // ctor which should be used
 
+  fCalibData = GetCalibData();
+
   for (Int_t i = 0; i < fgkTotUM; i++)
     {
       for (Int_t j = 0; j < fgkRow; j++)
@@ -330,37 +355,41 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
              edep       = fPMDHit->GetEnergy();
              Int_t vol1 = fPMDHit->GetVolume(1); // Column
              Int_t vol2 = fPMDHit->GetVolume(2); // Row
-             Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
-             Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
+             Int_t vol7 = fPMDHit->GetVolume(7); // UnitModule
+             Int_t vol8 = fPMDHit->GetVolume(8); // SuperModule
+
 
              // -----------------------------------------//
+             // In new geometry after adding electronics //
              // For Super Module 1 & 2                   //
-             //  nrow = 96, ncol = 48                    //
-             // For Super Module 3 & 4                   //
              //  nrow = 48, ncol = 96                    //
+             // For Super Module 3 & 4                   //
+             //  nrow = 96, ncol = 48                    //
              // -----------------------------------------//
+
+
              
-             smnumber = (vol6-1)*6 + vol3;
+             smnumber = (vol8-1)*6 + vol7;
 
-             if (vol6 == 1 || vol6 == 2)
-               {
-                 xpad = vol1;
-                 ypad = vol2;
-               }
-             else if (vol6 == 3 || vol6 == 4)
+             if (vol8 == 1 || vol8 == 2)
                {
                  xpad = vol2;
                  ypad = vol1;
                }
+             else if (vol8 == 3 || vol8 == 4)
+               {
+                 xpad = vol1;
+                 ypad = vol2;
+               }
 
              AliDebug(2,Form("Zposition = %f Edeposition = %f",zPos,edep));
-             Float_t zposition = TMath::Abs(zPos);
-             if (zposition < fZPos)
+             //Float_t zposition = TMath::Abs(zPos);
+             if (zPos < fZPos)
                {
                  // CPV
                  fDetNo = 1;
                }
-             else if (zposition > fZPos)
+             else if (zPos > fZPos)
                {
                  // PMD
                  fDetNo = 0;
@@ -425,7 +454,6 @@ void AliPMDDigitizer::Hits2SDigits(Int_t ievt)
     }
   fPMDLoader->WriteSDigits("OVERWRITE");
   ResetCellADC();
-
 }
 //____________________________________________________________________________
 
@@ -567,42 +595,43 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
              xPos = fPMDHit->X();
              yPos = fPMDHit->Y();
              zPos = fPMDHit->Z();
-
              edep       = fPMDHit->GetEnergy();
              Int_t vol1 = fPMDHit->GetVolume(1); // Column
              Int_t vol2 = fPMDHit->GetVolume(2); // Row
-             Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
-             Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
+             Int_t vol7 = fPMDHit->GetVolume(7); // UnitModule
+             Int_t vol8 = fPMDHit->GetVolume(8); // SuperModule
+
 
              // -----------------------------------------//
+             // In new geometry after adding electronics //
              // For Super Module 1 & 2                   //
-             //  nrow = 96, ncol = 48                    //
-             // For Super Module 3 & 4                   //
              //  nrow = 48, ncol = 96                    //
+             // For Super Module 3 & 4                   //
+             //  nrow = 96, ncol = 48                    //
              // -----------------------------------------//
              
-             smnumber = (vol6-1)*6 + vol3;
+             smnumber = (vol8-1)*6 + vol7;
 
-             if (vol6 == 1 || vol6 == 2)
-               {
-                 xpad = vol1;
-                 ypad = vol2;
-               }
-             else if (vol6 == 3 || vol6 == 4)
+             if (vol8 == 1 || vol8 == 2)
                {
                  xpad = vol2;
                  ypad = vol1;
                }
+             else if (vol8 == 3 || vol8 == 4)
+               {
+                 xpad = vol1;
+                 ypad = vol2;
+               }
 
              AliDebug(2,Form("ZPosition = %f Edeposition = %d",zPos,edep));
-             Float_t zposition = TMath::Abs(zPos);
+             //Float_t zposition = TMath::Abs(zPos);
 
-             if (zposition < fZPos)
+             if (zPos < fZPos)
                {
                  // CPV
                  fDetNo = 1;
                }
-             else if (zposition > fZPos)
+             else if (zPos > fZPos)
                {
                  // PMD
                  fDetNo = 0;
@@ -632,11 +661,11 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
   TrackAssignment2Cell();
   ResetCell();
 
+  Float_t gain1;
   Float_t adc;
   Float_t deltaE = 0.;
   Int_t detno = 0;
   Int_t trno = 1;
-
   for (Int_t idet = 0; idet < 2; idet++)
     {
       for (Int_t ism = 0; ism < fgkTotUM; ism++)
@@ -647,13 +676,16 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
                {
                  if (idet == 0)
                    {
-                     deltaE = fPRE[ism][jrow][kcol];
+                     gain1 = Gain(idet,ism,jrow,kcol);
+
+                     deltaE = fPRE[ism][jrow][kcol]*gain1;
                      trno   = fPRETrackNo[ism][jrow][kcol];
                      detno = 0;
                    }
                  else if (idet == 1)
                    {
-                     deltaE = fCPV[ism][jrow][kcol];
+                     gain1 = Gain(idet,ism,jrow,kcol);
+                     deltaE = fCPV[ism][jrow][kcol]*gain1;
                      trno   = fCPVTrackNo[ism][jrow][kcol];
                      detno = 1;
                    }
@@ -671,7 +703,7 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
   
   fPMDLoader->WriteDigits("OVERWRITE");
   ResetCellADC();
-
+  
 }
 //____________________________________________________________________________
 
@@ -831,7 +863,6 @@ void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
   Int_t   itrackno, idet, ism;
   Int_t   ixp, iyp;
   Float_t edep;
-  
   Int_t nmodules = (Int_t) treeS->GetEntries();
   AliDebug(1,Form("Number of Modules in the treeS = %d",nmodules));
   AliDebug(1,Form("Track Offset = %d",troffset));
@@ -849,7 +880,6 @@ void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
          ixp       = pmdsdigit->GetRow();
          iyp       = pmdsdigit->GetColumn();
          edep      = pmdsdigit->GetCellEdep();
-
          if (idet == 0)
            {
              if (fPRE[ism][ixp][iyp] < edep)
@@ -1193,6 +1223,7 @@ void AliPMDDigitizer::ResetCellADC()
        }
     }
 }
+//------------------------------------------------------
 //____________________________________________________________________________
 
 void AliPMDDigitizer::UnLoad(Option_t *option)
@@ -1216,3 +1247,51 @@ void AliPMDDigitizer::UnLoad(Option_t *option)
       fPMDLoader->UnloadSDigits();
     }
 }
+
+//----------------------------------------------------------------------
+Float_t AliPMDDigitizer::Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const
+{
+  // returns of the gain of the cell
+  // Added this method by ZA
+
+  //cout<<" I am here in gain "<<fCalibData<< "smn,row, col "<<smn
+  //<<" "<<row<<" "<<col<<endl;
+
+  if(!fCalibData) {
+    AliError("No calibration data loaded from CDB!!!");
+    return 1;
+  }
+
+  Float_t GainFact;
+  GainFact = fCalibData->GetGainFact(det,smn,row,col);
+  printf("\t gain=%10.3f\n",GainFact);
+  return GainFact;
+}
+//----------------------------------------------------------------------
+AliPMDCalibData* AliPMDDigitizer::GetCalibData() const
+{
+  // The run number will be centralized in AliCDBManager,
+  // you don't need to set it here!
+  // Added this method by ZA
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
+  
+  if(!entry){
+    AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
+    
+    // this just remembers the actual default storage. No problem if it is null.
+    AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
+    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+    
+    entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
+    
+    // now reset the original default storage to AliCDBManager...
+    AliCDBManager::Instance()->SetDefaultStorage(origStorage);  
+  }
+  
+  AliPMDCalibData *calibdata=0;
+  if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
+  
+  if (!calibdata)  AliError("No calibration data from calibration database !");
+  
+  return calibdata;
+}