Pedestal subtraction implemented
authorbnandi <bnandi@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Jul 2007 13:53:46 +0000 (13:53 +0000)
committerbnandi <bnandi@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Jul 2007 13:53:46 +0000 (13:53 +0000)
PMD/AliPMDCalibData.cxx
PMD/AliPMDCalibData.h
PMD/AliPMDCalibrator.cxx
PMD/AliPMDCalibrator.h
PMD/AliPMDClusterFinder.cxx
PMD/AliPMDClusterFinder.h
PMD/AliPMDDigitizer.cxx
PMD/AliPMDDigitizer.h
PMD/PMDbaseLinkDef.h
PMD/libPMDbase.pkg

index 940a23d..8bbcc51 100644 (file)
@@ -47,14 +47,19 @@ AliPMDCalibData::AliPMDCalibData(const AliPMDCalibData& calibda) :
   SetName(calibda.GetName());
   SetTitle(calibda.GetName());
   Reset();
-  for(Int_t det=0;det<2;det++){
-    for(Int_t smn=0;smn<24;smn++) {
-      for(Int_t row=0;row<96;row++) {
-       for(Int_t col=0;col<96;col++) {
-         fGainFact[det][smn][row][col]=calibda.GetGainFact(det,smn,row,col);
-       }
+  for(Int_t det = 0; det < kDet; det++)
+  {
+      for(Int_t smn = 0; smn < kModule; smn++)
+      {
+         for(Int_t row = 0; row < kRow; row++)
+         {
+             for(Int_t col = 0; col < kCol; col++)
+             {
+                 fGainFact[det][smn][row][col] = 
+                     calibda.GetGainFact(det,smn,row,col);
+             }
+         }
       }
-    }
   }
 }
 // ----------------------------------------------------------------- //
@@ -64,14 +69,19 @@ AliPMDCalibData &AliPMDCalibData::operator =(const AliPMDCalibData& calibda)
   SetName(calibda.GetName());
   SetTitle(calibda.GetName());
   Reset();
-  for(Int_t det=0;det<2;det++){
-    for(Int_t smn=0;smn<24;smn++) {
-      for(Int_t row=0;row<96;row++) {
-       for(Int_t col=0;col<96;col++) {
-         fGainFact[det][smn][row][col]=calibda.GetGainFact(det,smn,row,col);
-       }
+  for(Int_t det = 0; det < kDet; det++)
+  {
+      for(Int_t smn = 0; smn < kModule; smn++)
+      {
+         for(Int_t row = 0; row < kRow; row++)
+         {
+             for(Int_t col = 0; col < kCol; col++)
+             {
+                 fGainFact[det][smn][row][col] = 
+                     calibda.GetGainFact(det,smn,row,col);
+             }
+         }
       }
-    }
   }
   return *this;
 }
@@ -83,15 +93,20 @@ AliPMDCalibData::~AliPMDCalibData()
 // ----------------------------------------------------------------- //
 void AliPMDCalibData::Reset()
 {
-  //memset(fgainfact ,1,2*24*96*96*sizeof(Float_t));
-  for(Int_t det=0;det<2;det++){
-    for(Int_t smn=0;smn<24;smn++) {
-      for(Int_t row=0;row<96;row++) {
-       for(Int_t col=0;col<96;col++) {
-         fGainFact[det][smn][row][col]=1.0;
-       }
+  //memset(fgainfact ,1,2*24*48*96*sizeof(Float_t));
+
+  for(Int_t det = 0; det < kDet; det++)
+  {
+      for(Int_t smn = 0; smn < kModule; smn++)
+      {
+         for(Int_t row = 0; row < kRow; row++)
+         {
+             for(Int_t col = 0; col < kCol; col++)
+             {
+                 fGainFact[det][smn][row][col] = 1.0;
+             }
+         }
       }
-    }
   }
 }
 // ----------------------------------------------------------------- //
@@ -109,15 +124,16 @@ void AliPMDCalibData::SetGainFact(Int_t det, Int_t smn, Int_t row, Int_t col, Fl
 void AliPMDCalibData::Print(Option_t *) const
 {
   printf("\n ######gain factors for each cells are ####\n");
-  for(Int_t det=0;det<2;det++)
+  for(Int_t det = 0; det < kDet; det++)
     {
-      for(Int_t smn=0;smn<24;smn++)
+      for(Int_t smn = 0; smn < kModule; smn++)
        {
-         for(Int_t row=0;row<96;row++)
+         for(Int_t row = 0; row < kRow; row++)
            {
-             for(Int_t col=0;col<96; col++)
+             for(Int_t col = 0; col < kCol; col++)
                {
-                 printf("%4.1f",fGainFact[det][smn][row][col]);
+                 printf("Gain[%d,%d,%d,%d]= %4.1f \n",det,smn,row,col,
+                        fGainFact[det][smn][row][col]);
                }
              printf("\n");
            }
index ebb47d2..5e4e614 100644 (file)
@@ -23,9 +23,16 @@ class AliPMDCalibData: public TNamed
   virtual void Print(Option_t *) const;
   
  protected:
-  
-  Float_t fGainFact[2][24][96][96];
 
-  ClassDef(AliPMDCalibData,1) // calibration class for gainfactors
+  enum
+      {
+         kDet = 2,        // Number of plane
+         kModule = 24,    // Modules per plane
+         kRow    = 48,    // Maximum row
+         kCol    = 96     // Maximum Column
+      };
+  Float_t fGainFact[kDet][kModule][kRow][kCol];
+
+  ClassDef(AliPMDCalibData,2) // calibration class for gainfactors
 };
 #endif
index 95b5b18..71609a8 100644 (file)
 
 ClassImp(AliPMDCalibrator)
 
-const Int_t kDet =2;
-const Int_t kMaxSMN = 24;
-const Int_t kMaxRow =96;
-const Int_t kMaxCol =96;
+//const Int_t kDet    = 2;
+//const Int_t kMaxSMN = 24;
+//const Int_t kMaxRow = 48;
+//const Int_t kMaxCol = 96;
 
 AliPMDCalibrator::AliPMDCalibrator():
-  fCalibData(new AliPMDCalibData())
+  fCalibGain(new AliPMDCalibData())
 {
   // Standard Constructor
-  for(Int_t d=0;d<2;d++)
+  for(Int_t idet = 0; idet < kDet; idet++)
     {
-      for(Int_t i=0;i<24;i++)
+      for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
        {
-         fHsmIso[d][i] = NULL ;
-         for(Int_t j=0;j<96;j++)
+         fHsmIso[idet][ismn] = NULL ;
+         for(Int_t jrow = 0; jrow < kMaxRow; jrow++)
            {
-             for(Int_t k=0;k<96;k++)
+             for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
                {
-                 fGainFact[d][i][j][k] = 0.0;
-                 fHadcIso[d][i][j][k]  = NULL;
+                 fGainFact[idet][ismn][jrow][kcol] = 0.0;
+                 fHadcIso[idet][ismn][jrow][kcol]  = NULL;
                }
            }
        }
@@ -69,19 +69,19 @@ AliPMDCalibrator::AliPMDCalibrator():
 }
 // ------------------------------------------------------------------------ //
 AliPMDCalibrator::AliPMDCalibrator(const AliPMDCalibrator &pmdcalibrator):
-  fCalibData(new AliPMDCalibData())
+  fCalibGain(new AliPMDCalibData())
 {
-  for(Int_t d=0;d<2;d++)
+  for(Int_t idet = 0; idet < 2; idet++)
     {
-      for(Int_t i=0;i<24;i++)
+      for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
        {
-         fHsmIso[d][i] = pmdcalibrator.fHsmIso[d][i] ;
-         for(Int_t j=0;j<96;j++)
+         fHsmIso[idet][ismn] = pmdcalibrator.fHsmIso[idet][ismn] ;
+         for(Int_t jrow = 0; jrow < kMaxRow; jrow++)
            {
-             for(Int_t k=0;k<96;k++)
+             for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
                {
-                 fGainFact[d][i][j][k] = pmdcalibrator.fGainFact[d][i][j][k];
-                 fHadcIso[d][i][j][k]  = pmdcalibrator.fHadcIso[d][i][j][k];
+                 fGainFact[idet][ismn][jrow][kcol] = pmdcalibrator.fGainFact[idet][ismn][jrow][kcol];
+                 fHadcIso[idet][ismn][jrow][kcol]  = pmdcalibrator.fHadcIso[idet][ismn][jrow][kcol];
                }
            }
        }
@@ -93,19 +93,19 @@ AliPMDCalibrator &AliPMDCalibrator::operator=(const AliPMDCalibrator &pmdcalibra
 {
   if(this != &pmdcalibrator)
     {
-      for(Int_t d=0;d<2;d++)
+      for(Int_t idet = 0; idet < kDet; idet++)
        {
-         for(Int_t i=0;i<24;i++)
+         for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
            {
-             fHsmIso[d][i] = pmdcalibrator.fHsmIso[d][i] ;
-             for(Int_t j=0;j<96;j++)
+             fHsmIso[idet][ismn] = pmdcalibrator.fHsmIso[idet][ismn] ;
+             for(Int_t jrow = 0; jrow < kMaxRow;jrow++)
                {
-                 for(Int_t k=0;k<96;k++)
+                 for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
                    {
-                     fGainFact[d][i][j][k] =
-                       pmdcalibrator.fGainFact[d][i][j][k];
-                     fHadcIso[d][i][j][k]  =
-                       pmdcalibrator.fHadcIso[d][i][j][k];
+                     fGainFact[idet][ismn][jrow][kcol] =
+                       pmdcalibrator.fGainFact[idet][ismn][jrow][kcol];
+                     fHadcIso[idet][ismn][jrow][kcol]  =
+                       pmdcalibrator.fHadcIso[idet][ismn][jrow][kcol];
                    }
                }
            }
@@ -119,7 +119,7 @@ AliPMDCalibrator::~AliPMDCalibrator()
   // dtor
   if(fHsmIso)  delete fHsmIso ;
   if(fHadcIso) delete fHadcIso ;
-  delete fCalibData;
+  delete fCalibGain;
 }
 // ------------------------------------------------------------------------ //
 
@@ -139,8 +139,8 @@ void AliPMDCalibrator::Init()
   char hnameiso[120];
   char htitle1[120];
 
-  for(Int_t d=0;d<2;d++) {
-    for(Int_t i1=0; i1<kMaxSMN;i1++) {
+  for(Int_t d = 0; d < kDet; d++) {
+    for(Int_t i1 = 0; i1 < kMaxSMN; i1++) {
       sprintf(hname,"det_%d_iso_sm_%2d",d,i1);
       sprintf(hname24,"det_%d_iso_sm_%2d",d,i1);
       fHsmIso[d][i1]= new TH1F(hname,hname24,100,0,1000);
@@ -205,25 +205,6 @@ void AliPMDCalibrator::CalculateIsoCell()
   AliPMDRawStream stream(&reader);
   while(reader.NextEvent())
     {
-      // printf("In CalculateIsoCell before while(stream.Next()), ...\n");
-      
-      /*
-      while(stream.Next())
-       {
-         Int_t idet = stream.GetDetector();
-         Int_t ismn = stream.GetSMN();
-         Int_t ichno = stream.GetChannel();
-         Int_t irow = stream.GetRow();
-         Int_t icol = stream.GetColumn();
-         Int_t isig = stream.GetSignal();
-         
-         if (isig>0)
-           {
-             d1[idet][ismn][irow][icol] = isig;
-             ch[idet][ismn][irow][icol] = ichno;
-           }
-       }
-      */
       // New PMD Reader is plugged in
       
       for (Int_t iddl = 0; iddl < kDDL; iddl++)
@@ -301,23 +282,24 @@ void AliPMDCalibrator::CalculateIsoCell()
            }
        } //event loop
     }
-  Double_t histMean[2][24];
-  Double_t isoMean[2][24][96][96];
-  for(Int_t d1=0;d1<2;d1++)
+  Double_t histMean[kDet][kMaxSMN];
+  Double_t isoMean[kDet][kMaxSMN][kMaxRow][kMaxCol];
+
+  for(Int_t d1 = 0; d1 < kDet; d1++)
     {
-      for(Int_t i1=0;i1<24;i1++)
+      for(Int_t i1 = 0; i1 < kMaxSMN; i1++)
        {
          histMean[d1][i1]= fHsmIso[d1][i1]->GetMean();
-         for(Int_t j1=0;j1<96;j1++)
+         for(Int_t j1 = 0; j1 < kMaxRow; j1++)
            {
-             for(Int_t k1=0;k1<96;k1++)
+             for(Int_t k1 = 0; k1 < kMaxCol; k1++)
                {
                  isoMean[d1][i1][j1][k1]=fHadcIso[d1][i1][j1][k1]->GetMean();
                  if(isoMean[d1][i1][j1][k1]>0.0 && histMean[d1][i1]>0.0)
                    {
                      fGainFact[d1][i1][j1][k1]=isoMean[d1][i1][k1][j1]/histMean[d1][i1];
-                     Float_t gain=fGainFact[d1][i1][j1][k1];
-                     fCalibData->SetGainFact(d1,i1,j1,k1,gain);
+                     Float_t gain = fGainFact[d1][i1][j1][k1];
+                     fCalibGain->SetGainFact(d1,i1,j1,k1,gain);
                    }                              
                }
            }
@@ -342,7 +324,7 @@ Bool_t AliPMDCalibrator::Store()
   //fCalibData->Print(0);
   //printf("\n\n\n fCalibData\n");
   
-  Bool_t result = man->Put(fCalibData,id,&md);
+  Bool_t result = man->Put(fCalibGain,id,&md);
 
   return result;
 }
index 23b09d5..2b9849f 100644 (file)
@@ -23,11 +23,20 @@ class AliPMDCalibrator
   Bool_t Store();
   
  private:
-  Float_t fGainFact[2][24][96][96];
-  TH1F *fHsmIso[2][24];             //histos of isolated cell modulewise
-  TH1F *fHadcIso[2][24][96][96];    // histos of isolated cells cellwise
-  AliPMDCalibData *fCalibData;
 
-ClassDef(AliPMDCalibrator,2)        // description 
+  enum
+      {
+         kDet = 2,      // Number of Planes
+         kMaxSMN = 24,  // Number of Modules
+         kMaxRow = 48,  // Number of Rows
+         kMaxCol = 96   // Number of Columns
+      };
+  Float_t fGainFact[kDet][kMaxSMN][kMaxRow][kMaxCol];
+  TH1F *fHsmIso[kDet][kMaxSMN];     //histos of isolated cell modulewise
+  TH1F *fHadcIso[kDet][kMaxSMN][kMaxRow][kMaxCol];    // histos of isolated cells cellwise
+
+  AliPMDCalibData *fCalibGain;
+
+ClassDef(AliPMDCalibrator,3)        // description 
 };
 #endif // AliPMDCALIBRATOR_H
index cc5ed7d..298b7ce 100644 (file)
@@ -41,6 +41,7 @@
 #include "AliPMDrechit.h"
 #include "AliPMDRawStream.h"
 #include "AliPMDCalibData.h"
+#include "AliPMDPedestal.h"
 #include "AliPMDddldata.h"
 
 #include "AliDAQ.h"
@@ -54,7 +55,8 @@ ClassImp(AliPMDClusterFinder)
 AliPMDClusterFinder::AliPMDClusterFinder():
   fRunLoader(0),
   fPMDLoader(0),
-  fCalibData(GetCalibData()),
+  fCalibGain(GetCalibGain()),
+  fCalibPed(GetCalibPed()),
   fTreeD(0),
   fTreeR(0),
   fDigits(new TClonesArray("AliPMDdigit", 1000)),
@@ -73,7 +75,8 @@ AliPMDClusterFinder::AliPMDClusterFinder():
 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
   fRunLoader(runLoader),
   fPMDLoader(runLoader->GetLoader("PMDLoader")),
-  fCalibData(GetCalibData()),
+  fCalibGain(GetCalibGain()),
+  fCalibPed(GetCalibPed()),
   fTreeD(0),
   fTreeR(0),
   fDigits(new TClonesArray("AliPMDdigit", 1000)),
@@ -93,7 +96,8 @@ AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder):
   TObject(finder),
   fRunLoader(0),
   fPMDLoader(0),
-  fCalibData(GetCalibData()),
+  fCalibGain(GetCalibGain()),
+  fCalibPed(GetCalibPed()),
   fTreeD(0),
   fTreeR(0),
   fDigits(NULL),
@@ -201,7 +205,7 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
          adc    = pmddigit->GetADC();
          
          // CALIBRATION
-         Float_t gain = fCalibData->GetGainFact(det,smn,xpos,ypos);
+         Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
          // printf("adc = %d gain = %f\n",adc,gain);
          
          adc = adc*gain;
@@ -305,12 +309,21 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
          xpos   = pmddigit->GetRow();
          ypos   = pmddigit->GetColumn();
          adc    = pmddigit->GetADC();
-         
+
+         // Pedestal Subtraction
+         Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
+         Int_t   pedrms1    = (Int_t) pedmeanrms%1000;
+         Float_t pedrms     = (Float_t)pedrms1/10.;
+         Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
+         //printf("%f %f\n",pedmean, pedrms);
+
+         Float_t adc1 = adc - (pedmean + 3.0*pedrms);
+
          // CALIBRATION
-         Float_t gain = fCalibData->GetGainFact(det,smn,xpos,ypos);
+         Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
          // printf("adc = %d gain = %f\n",adc,gain);
-         
-         adc = adc*gain;
+
+         adc = adc1*gain;
 
          //Int_t trno   = pmddigit->GetTrackNumber();
          fCellADC[xpos][ypos] = (Double_t) adc;
@@ -445,9 +458,19 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
          Int_t col = pmdddl->GetColumn();
          Int_t sig = pmdddl->GetSignal();
 
-         Float_t sig1 = (Float_t) sig;
+         // Pedestal Subtraction
+         Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
+         Int_t   pedrms1    = (Int_t) pedmeanrms%1000;
+         Float_t pedrms     = (Float_t)pedrms1/10.;
+         Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
+
+         //printf("%f %f\n",pedmean, pedrms);
+
+         // Float_t sig1 = (Float_t) sig;
+         Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
+
          // CALIBRATION
-         Float_t gain = fCalibData->GetGainFact(det,smn,row,col);
+         Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
          //printf("sig = %d gain = %f\n",sig,gain);
          sig = (Int_t) (sig1*gain);
 
@@ -673,9 +696,18 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
          Int_t col = pmdddl->GetColumn();
          Int_t sig = pmdddl->GetSignal();
 
-         Float_t sig1 = (Float_t) sig;
+         // Pedestal Subtraction
+         Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
+         Int_t   pedrms1    = (Int_t) pedmeanrms%1000;
+         Float_t pedrms     = (Float_t)pedrms1/10.;
+         Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
+
+         //printf("%f %f\n",pedmean, pedrms);
+
+         //Float_t sig1 = (Float_t) sig;
+         Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
          // CALIBRATION
-         Float_t gain = fCalibData->GetGainFact(det,smn,row,col);
+         Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
 
          //printf("sig = %d gain = %f\n",sig,gain);
          sig = (Int_t) (sig1*gain);
@@ -910,12 +942,12 @@ void AliPMDClusterFinder::UnLoadClusters()
 }
 // ------------------------------------------------------------------------- //
 
-AliPMDCalibData* AliPMDClusterFinder::GetCalibData() const
+AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
 {
   // The run number will be centralized in AliCDBManager,
   // you don't need to set it here!
   // Added by ZA
-  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
   
   if(!entry)  AliFatal("Calibration object retrieval failed! ");
   
@@ -926,3 +958,21 @@ AliPMDCalibData* AliPMDClusterFinder::GetCalibData() const
   
   return calibdata;
 }
+
+// ------------------------------------------------------------------------- //
+
+AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
+{
+  // The run number will be centralized in AliCDBManager,
+  // you don't need to set it here!
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
+  
+  if(!entry) AliFatal("Pedestal object retrieval failed!");
+    
+  AliPMDPedestal *pedestal = 0;
+  if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
+  
+  if (!pedestal)  AliFatal("No pedestal data from pedestal database !");
+  
+  return pedestal;
+}
index d0db18a..7881fb0 100644 (file)
@@ -19,6 +19,7 @@ class AliLoader;
 class AliRunLoader;
 class AliRawReader;
 class AliPMDCalibData;
+class AliPMDPedestal;
 
 class AliPMDClusterFinder : public TObject
 {
@@ -46,13 +47,15 @@ class AliPMDClusterFinder : public TObject
   void UnLoad();
   void UnLoadClusters();
 
-  AliPMDCalibData *GetCalibData() const;
+  AliPMDCalibData *GetCalibGain() const;
+  AliPMDPedestal  *GetCalibPed() const;
 
  protected:
   AliRunLoader *fRunLoader; // Pointer to Run Loader
   AliLoader    *fPMDLoader; // Pointer to specific detector loader
 
-  AliPMDCalibData *fCalibData;  //! calibration data
+  AliPMDCalibData *fCalibGain;  //! Gain calibration data
+  AliPMDPedestal  *fCalibPed;   //! Pedestal calibration data
 
   TTree        *fTreeD;     // Digits tree
   TTree        *fTreeR;     // Reconstructed points
@@ -70,7 +73,7 @@ class AliPMDClusterFinder : public TObject
   static const Int_t fgkCol = 96; // Total number of cols in one unitmodule
   Double_t fCellADC[fgkRow][fgkCol]; // Array containing individual cell ADC
 
-  ClassDef(AliPMDClusterFinder,11) // To run PMD clustering
+  ClassDef(AliPMDClusterFinder,12) // To run PMD clustering
 };
 #endif
 
index 52bd108..2a48811 100644 (file)
@@ -54,6 +54,7 @@
 #include "AliPMDsdigit.h"
 #include "AliPMDdigit.h"
 #include "AliPMDCalibData.h"
+#include "AliPMDPedestal.h"
 #include "AliPMDDigitizer.h"
 
 
@@ -64,7 +65,8 @@ AliPMDDigitizer::AliPMDDigitizer() :
   fPMDHit(0),
   fPMD(0),
   fPMDLoader(0),
-  fCalibData(GetCalibData()),
+  fCalibGain(GetCalibGain()),
+  fCalibPed(GetCalibPed()),
   fSDigits(0),
   fDigits(0),
   fCell(0),
@@ -90,7 +92,6 @@ AliPMDDigitizer::AliPMDDigitizer() :
        }
     }
 
-
 }
 //____________________________________________________________________________
 AliPMDDigitizer::AliPMDDigitizer(const AliPMDDigitizer& digitizer):
@@ -99,7 +100,8 @@ AliPMDDigitizer::AliPMDDigitizer(const AliPMDDigitizer& digitizer):
   fPMDHit(0),
   fPMD(0),
   fPMDLoader(0),
-  fCalibData(GetCalibData()),
+  fCalibGain(GetCalibGain()),
+  fCalibPed(GetCalibPed()),
   fSDigits(0),
   fDigits(0),
   fCell(0),
@@ -127,7 +129,8 @@ AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager):
   fPMDHit(0),
   fPMD(0),
   fPMDLoader(0),
-  fCalibData(GetCalibData()),
+  fCalibGain(GetCalibGain()),
+  fCalibPed(GetCalibPed()),
   fSDigits(new TClonesArray("AliPMDsdigit", 1000)),
   fDigits(new TClonesArray("AliPMDdigit", 1000)),
   fCell(0),
@@ -719,7 +722,20 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
                      {
                          adc = 0.;
                      }
-                     AddDigit(trno,detno,ism,jrow,kcol,adc);
+
+                     // Pedestal Decalibration
+                     Int_t   pedmeanrms = 
+                         fCalibPed->GetPedMeanRms(idet,ism,jrow,kcol);
+                     Int_t   pedrms1    = (Int_t) pedmeanrms%1000;
+                     Float_t pedrms     = (Float_t)pedrms1/10.;
+                     Float_t pedmean    = 
+                         (Float_t) (pedmeanrms - pedrms1)/1000.0;
+                     //printf("%f %f\n",pedmean, pedrms);
+                     if (adc > 0.)
+                     {
+                         adc += (pedmean + 3.0*pedrms);
+                         AddDigit(trno,detno,ism,jrow,kcol,adc);
+                     }
                  }
              } // column loop
          } // row    loop
@@ -788,6 +804,7 @@ void AliPMDDigitizer::SDigits2Digits(Int_t ievt)
 
          MeV2ADC(edep,adc);
 
+         
          // To decalibrte the adc values
          //
          Float_t gain1 = Gain(det,smn,irow,icol);
@@ -800,8 +817,18 @@ void AliPMDDigitizer::SDigits2Digits(Int_t ievt)
          {
              adc = 0.;
          }
+         // Pedestal Decalibration
+         Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,irow,icol);
+         Int_t   pedrms1    = (Int_t) pedmeanrms%1000;
+         Float_t pedrms     = (Float_t)pedrms1/10.;
+         Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
+         //printf("%f %f\n",pedmean, pedrms);
+         if(adc > 0.)
+         {
+             adc += (pedmean + 3.0*pedrms);
+             AddDigit(trno,det,smn,irow,icol,adc);
+         }
 
-         AddDigit(trno,det,smn,irow,icol,adc);
        }
       treeD->Fill();
       ResetDigit();
@@ -875,10 +902,12 @@ void AliPMDDigitizer::Exec(Option_t *option)
                  if (deltaE > 0.)
                    {
                      MeV2ADC(deltaE,adc);
+
                       //
-                     // To decalibrte the adc values
+                     // Gain decalibration
                      //
                      Float_t gain1 = Gain(idet,ism,jrow,kcol);
+
                      if (gain1 != 0.)
                      {
                          Int_t adcDecalib = (Int_t)(adc/gain1);
@@ -888,8 +917,20 @@ void AliPMDDigitizer::Exec(Option_t *option)
                      {
                          adc = 0.;
                      }
+                     // Pedestal Decalibration
+                     Int_t   pedmeanrms = 
+                         fCalibPed->GetPedMeanRms(idet,ism,jrow,kcol);
+                     Int_t   pedrms1    = (Int_t) pedmeanrms%1000;
+                     Float_t pedrms     = (Float_t)pedrms1/10.;
+                     Float_t pedmean    = 
+                         (Float_t) (pedmeanrms - pedrms1)/1000.0;
+                     //printf("%f %f\n",pedmean, pedrms);
+                     if (adc > 0.)
+                     {
+                         adc += (pedmean + 3.0*pedrms);
+                         AddDigit(trno,detno,ism,jrow,kcol,adc);
+                     }
 
-                     AddDigit(trno,detno,ism,jrow,kcol,adc);
                    }
                } // column loop
            } // row    loop
@@ -1311,23 +1352,23 @@ Float_t AliPMDDigitizer::Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const
   //cout<<" I am here in gain "<<fCalibData<< "smn,row, col "<<smn
   //<<" "<<row<<" "<<col<<endl;
 
-  if(!fCalibData) {
+  if(!fCalibGain) {
     AliError("No calibration data loaded from CDB!!!");
     return 1;
   }
 
   Float_t GainFact;
-  GainFact = fCalibData->GetGainFact(det,smn,row,col);
+  GainFact = fCalibGain->GetGainFact(det,smn,row,col);
   return GainFact;
 }
 //----------------------------------------------------------------------
-AliPMDCalibData* AliPMDDigitizer::GetCalibData() const
+AliPMDCalibData* AliPMDDigitizer::GetCalibGain() const
 {
   // The run number will be centralized in AliCDBManager,
   // you don't need to set it here!
   // Added this method by ZA
   // Cleaned up by Alberto
-  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
   
   if(!entry) AliFatal("Calibration object retrieval failed!");
   
@@ -1338,3 +1379,20 @@ AliPMDCalibData* AliPMDDigitizer::GetCalibData() const
   
   return calibdata;
 }
+//----------------------------------------------------------------------
+AliPMDPedestal* AliPMDDigitizer::GetCalibPed() const
+{
+  // The run number will be centralized in AliCDBManager,
+  // you don't need to set it here!
+
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
+  
+  if(!entry) AliFatal("Pedestal object retrieval failed!");
+  
+  AliPMDPedestal *pedestal=0;
+  if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
+  
+  if (!pedestal)  AliFatal("No pedestal data from calibration database !");
+  
+  return pedestal;
+}
index 4fdc918..a7987fd 100644 (file)
@@ -36,6 +36,7 @@ class AliPMDcell;
 class AliPMDsdigit;
 class AliPMDdigit;
 class AliPMDCalibData;
+class AliPMDPedestal;
 
 class AliPMDDigitizer:public AliDigitizer
 {
@@ -70,7 +71,8 @@ class AliPMDDigitizer:public AliDigitizer
 
   Float_t  Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const;
 
-  AliPMDCalibData *GetCalibData() const;
+  AliPMDCalibData *GetCalibGain() const;
+  AliPMDPedestal  *GetCalibPed() const;
 
  protected:
   AliRunLoader *fRunLoader;  //! Pointer to Run Loader
@@ -79,7 +81,8 @@ class AliPMDDigitizer:public AliDigitizer
                              // and Hits containers 
   AliLoader    *fPMDLoader;  //! Pointer to specific detector loader
 
-  AliPMDCalibData *fCalibData;  //! calibration data
+  AliPMDCalibData *fCalibGain;  //! Gain calibration data
+  AliPMDPedestal  *fCalibPed;   //! Pedestal calibration data
 
   TClonesArray *fSDigits;    //! List of summable digits
   TClonesArray *fDigits;     //! List of digits
@@ -101,8 +104,7 @@ class AliPMDDigitizer:public AliDigitizer
   Int_t   fPRETrackNo[fgkTotUM][fgkRow][fgkCol]; //! PRE Array containing track number
   Int_t   fCPVTrackNo[fgkTotUM][fgkRow][fgkCol]; //! CPV Array containing track number
 
-
-  ClassDef(AliPMDDigitizer,6)    // To digitize PMD Hits
+  ClassDef(AliPMDDigitizer,7)    // To digitize PMD Hits
 };
 #endif
 
index ae76467..0f0f7b0 100644 (file)
@@ -19,4 +19,5 @@
 #pragma link C++ class  AliPMDCalibrator+;
 #pragma link C++ class  AliPMDPreprocessor+;
 #pragma link C++ class  AliPMDRawToSDigits+;
+#pragma link C++ class  AliPMDPedestal+;
 #endif
index ea87bd0..559b7e5 100644 (file)
@@ -1,7 +1,7 @@
 #-*- Mode: Makefile -*-
 # $Id$
 
-SRCS:= AliPMDLoader.cxx AliPMDdigit.cxx AliPMDBlockHeader.cxx AliPMDDspHeader.cxx AliPMDPatchBusHeader.cxx AliPMDddldata.cxx AliPMDRawStream.cxx AliPMDCalibData.cxx AliPMDCalibrator.cxx AliPMDPreprocessor.cxx AliPMDRawToSDigits.cxx
+SRCS:= AliPMDLoader.cxx AliPMDdigit.cxx AliPMDBlockHeader.cxx AliPMDDspHeader.cxx AliPMDPatchBusHeader.cxx AliPMDddldata.cxx AliPMDRawStream.cxx AliPMDCalibData.cxx AliPMDCalibrator.cxx AliPMDPreprocessor.cxx AliPMDRawToSDigits.cxx AliPMDPedestal.cxx
 
 HDRS:= $(SRCS:.cxx=.h)