]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDClusterFinder.cxx
PMD DA informations : satya
[u/mrichter/AliRoot.git] / PMD / AliPMDClusterFinder.cxx
index 6d838d8e83ca8fe8cb4e4151e934c9ce611cdd1d..4d9a77a140e71081a0dd6afda2b8ad74f3b11c3e 100644 (file)
 #include "AliPMDcluster.h"
 #include "AliPMDrecpoint1.h"
 #include "AliPMDrechit.h"
-#include "AliPMDisocell.h"
 #include "AliPMDRawStream.h"
 #include "AliPMDCalibData.h"
 #include "AliPMDPedestal.h"
 #include "AliPMDddldata.h"
 #include "AliPMDHotData.h"
+#include "AliPMDNoiseCut.h"
+#include "AliPMDddlinfoData.h"
 #include "AliPMDRecoParam.h"
+#include "AliRecoParam.h"
 #include "AliPMDReconstructor.h"
 
 #include "AliDAQ.h"
@@ -63,6 +65,8 @@ AliPMDClusterFinder::AliPMDClusterFinder():
   fCalibGain(GetCalibGain()),
   fCalibPed(GetCalibPed()),
   fCalibHot(GetCalibHot()),
+  fNoiseCut(GetNoiseCut()),
+  fDdlinfo(GetDdlinfoData()),
   fRecoParam(0x0),
   fTreeD(0),
   fTreeR(0),
@@ -71,8 +75,7 @@ AliPMDClusterFinder::AliPMDClusterFinder():
   fRechits(new TClonesArray("AliPMDrechit", 1000)),
   fNpoint(0),
   fNhit(0),
-  fDetNo(0),
-  fEcut(0.)
+  fDetNo(0)
 {
 //
 // Constructor
@@ -85,6 +88,8 @@ AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
   fCalibGain(GetCalibGain()),
   fCalibPed(GetCalibPed()),
   fCalibHot(GetCalibHot()),
+  fNoiseCut(GetNoiseCut()),
+  fDdlinfo(GetDdlinfoData()),
   fRecoParam(0x0),
   fTreeD(0),
   fTreeR(0),
@@ -93,8 +98,7 @@ AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
   fRechits(new TClonesArray("AliPMDrechit", 1000)),
   fNpoint(0),
   fNhit(0),
-  fDetNo(0),
-  fEcut(0.)
+  fDetNo(0)
 {
 //
 // Constructor
@@ -108,6 +112,8 @@ AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder):
   fCalibGain(GetCalibGain()),
   fCalibPed(GetCalibPed()),
   fCalibHot(GetCalibHot()),
+  fNoiseCut(GetNoiseCut()),
+  fDdlinfo(GetDdlinfoData()),
   fRecoParam(0x0),
   fTreeD(0),
   fTreeR(0),
@@ -116,8 +122,7 @@ AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder):
   fRechits(NULL),
   fNpoint(0),
   fNhit(0),
-  fDetNo(0),
-  fEcut(0.)
+  fDetNo(0)
 {
   // copy constructor
   AliError("Copy constructor not allowed");
@@ -149,206 +154,25 @@ AliPMDClusterFinder::~AliPMDClusterFinder()
 }
 // ------------------------------------------------------------------------- //
 
-void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
-{
-  // Converts digits to recpoints after running clustering
-  // algorithm on CPV plane and PREshower plane
-  //
-
-  Int_t    det = 0,smn = 0;
-  Int_t    xpos,ypos;
-  Float_t  adc;
-  Int_t    ismn;
-  Int_t    idet;
-  Float_t  clusdata[6];
-
-  AliPMDisocell *pmdiso = 0x0;
-
-  TObjArray *pmdcont = new TObjArray();
-  TObjArray *pmdisocell = new TObjArray();
-
-  AliPMDClustering *pmdclust = new AliPMDClusteringV1();
-
-  // fetch the recoparam object from database
-  fRecoParam = AliPMDReconstructor::GetRecoParam();
-
-  if(fRecoParam == 0x0)
-    {
-       AliFatal("No Reco Param found for PMD!!!");
-    }
-
-
-  fRunLoader->GetEvent(ievt);
-
-
-  fTreeD = fPMDLoader->TreeD();
-  if (fTreeD == 0x0)
-    {
-      AliFatal("AliPMDClusterFinder: Can not get TreeD");
-
-    }
-  AliPMDdigit  *pmddigit;
-  TBranch *branch = fTreeD->GetBranch("PMDDigit");
-  branch->SetAddress(&fDigits);
-
-  ResetRecpoint();
-
-  fTreeR = fPMDLoader->TreeR();
-  if (fTreeR == 0x0)
-    {
-      fPMDLoader->MakeTree("R");
-      fTreeR = fPMDLoader->TreeR();
-    }
-
-  Int_t bufsize = 16000;
-  TBranch * branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); 
-  TBranch * branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); 
-
-  Int_t nmodules = (Int_t) fTreeD->GetEntries();
-
-  for (Int_t imodule = 0; imodule < nmodules; imodule++)
-    {
-      ResetCellADC();
-      fTreeD->GetEntry(imodule); 
-      Int_t nentries = fDigits->GetLast();
-      for (Int_t ient = 0; ient < nentries+1; ient++)
-       {
-         pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
-         
-         det    = pmddigit->GetDetector();
-         smn    = pmddigit->GetSMNumber();
-         xpos   = pmddigit->GetRow();
-         ypos   = pmddigit->GetColumn();
-         adc    = pmddigit->GetADC();
-         if(xpos < 0 || xpos > 48 || ypos < 0 || ypos > 96)
-           {
-             AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
-                             xpos, ypos));
-             continue; 
-           }
-
-         // Hot cell - set the cell adc = 0
-         Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
-         if (hotflag == 1) adc = 0;
-         // CALIBRATION
-         Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
-         // printf("adc = %d gain = %f\n",adc,gain);
-         
-         adc = adc*gain;
-
-         //Int_t trno   = pmddigit->GetTrackNumber();
-         fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
-         fCellPid[xpos][ypos]   = pmddigit->GetTrackPid();
-         fCellADC[xpos][ypos]   = (Double_t) adc;
-       }
-
-      idet = det;
-      ismn = smn;
-
-      // Set the minimum noise cut per module before clustering
-
-      Int_t imod = idet*24 + ismn;
-      fEcut = fRecoParam->GetNoiseCut(imod);   // default
-      // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
-      // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
-      // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
-
-      pmdclust->SetEdepCut(fEcut);
-
-
-      pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
-                       pmdisocell,pmdcont);
-
-      Int_t nentries1 = pmdcont->GetEntries();
-
-      AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
-
-      for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
-       {
-         AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
-         idet        = pmdcl->GetDetector();
-         ismn        = pmdcl->GetSMN();
-         clusdata[0] = pmdcl->GetClusX();
-         clusdata[1] = pmdcl->GetClusY();
-         clusdata[2] = pmdcl->GetClusADC();
-         clusdata[3] = pmdcl->GetClusCells();
-         clusdata[4] = pmdcl->GetClusSigmaX();
-         clusdata[5] = pmdcl->GetClusSigmaY();
-
-         AddRecPoint(idet,ismn,clusdata);
-
-         Int_t ncell = (Int_t) clusdata[3];
-         for(Int_t ihit = 0; ihit < ncell; ihit++)
-           {
-             Int_t celldataX = pmdcl->GetClusCellX(ihit);
-             Int_t celldataY = pmdcl->GetClusCellY(ihit);
-             Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
-             Int_t celldataPid   = pmdcl->GetClusCellPid(ihit);
-             Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
-             AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
-           }
-         branch2->Fill();
-         ResetRechit();
-       }
-      pmdcont->Delete();
-
-         // Added single isolated cell for offline gain calibration
-         nentries1 = pmdisocell->GetEntries();
-         AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
-         
-         for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
-           {
-             pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
-             idet = pmdiso->GetDetector();
-             ismn = pmdiso->GetSmn();
-             clusdata[0] = (Float_t) pmdiso->GetRow();
-             clusdata[1] = (Float_t) pmdiso->GetCol();
-             clusdata[2] = pmdiso->GetADC();
-             clusdata[3] = 1.;
-             clusdata[4] = -99.;
-             clusdata[5] = -99.;
-      
-             AddRecPoint(idet,ismn,clusdata);
-           }
-         pmdisocell->Delete();
-      
-      branch1->Fill();
-      ResetRecpoint();
-
-    } // modules
-
-  ResetCellADC();
-  fPMDLoader = fRunLoader->GetLoader("PMDLoader");  
-  fPMDLoader->WriteRecPoints("OVERWRITE");
-
-  //   delete the pointers
-  delete pmdclust;
-  delete pmdcont;
-  delete pmdisocell;
-    
-}
-// ------------------------------------------------------------------------- //
-
 void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
-                                          TTree *clustersTree)
+                                          TTree *clustersTree, Int_t gRecoMode)
 {
   // Converts digits to recpoints after running clustering
   // algorithm on CPV plane and PREshower plane
   //
   // This algorithm is called during the reconstruction from digits
 
-  Int_t    det = 0,smn = 0;
-  Int_t    xpos,ypos;
-  Float_t  adc;
-  Int_t    ismn;
-  Int_t    idet;
-  Float_t  clusdata[6];
+  Int_t    det  = 0, smn = 0;
+  Int_t    xpos = 0, ypos = 0;
+  Int_t    ismn = 0;
+  Int_t    idet = 0;
+  Float_t  adc  = 0.;
+  Float_t  clusdata[6] = {0.,0.,0.,0.,0.,0.};
 
   AliPMDcluster *pmdcl = 0x0;
-  AliPMDisocell *pmdiso = 0x0;
 
   TObjArray *pmdcont = new TObjArray();
-  TObjArray *pmdisocell = new TObjArray();
+
   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
 
   // Fetch the reco param object
@@ -441,17 +265,42 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
 
       // Set the minimum noise cut per module before clustering
 
-      Int_t imod = idet*24 + ismn;
-      fEcut = fRecoParam->GetNoiseCut(imod);       // default
-      // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
-      // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
-      // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
+      // Int_t imod = idet*24 + ismn;
+
 
+      // Int_t cluspar = fRecoParam->GetPbPbParam()->GetClusteringParam();
+      AliPMDRecoParam * par = fRecoParam->GetPPParam();
+      Int_t cluspar = par->GetClusteringParam();
+      delete par;
+
+      // Int_t cluspar = fRecoParam->GetCosmicParam()->GetClusteringParam();
+      
+      //_______________________________________________________// 
+      //Added to switch Refine and crude Clustering - satya//
+      // temporary solution - will be sorted out later
+      /*cluspar = 1;
+      static AliPMDRecoParam *reconp = NULL;
+      reconp = (AliPMDRecoParam*)AliPMDReconstructor::GetRecoParam();
+      if(!reconp) {
+       cluspar = 1;
+      } 
+      else { 
+       
+      if( reconp->GetClusteringParam() == 1) 
+       cluspar = 1;
+      if( reconp->GetClusteringParam() == 2) 
+       cluspar = 2;
+       }
 
-      pmdclust->SetEdepCut(fEcut);
+      */
+      cluspar = gRecoMode;
+      //_______________________________________________________// 
+      
+      pmdclust->SetClusteringParam(cluspar);
 
-      pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
-                       pmdisocell,pmdcont);
+      Float_t encut = 4.;
+      pmdclust->SetEdepCut(encut);
+      pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
       
       Int_t nentries1 = pmdcont->GetEntries();
 
@@ -472,6 +321,7 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
          AddRecPoint(idet,ismn,clusdata);
 
          Int_t ncell = (Int_t) clusdata[3];
+         if (ncell > 19) ncell = 19;
          for(Int_t ihit = 0; ihit < ncell; ihit++)
            {
              Int_t celldataX = pmdcl->GetClusCellX(ihit);
@@ -486,26 +336,6 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
        }
       pmdcont->Delete();
 
-      // Added single isolated cell for offline gain calibration
-      nentries1 = pmdisocell->GetEntries();
-      AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
-      
-      for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
-       {
-         pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
-         idet = pmdiso->GetDetector();
-         ismn = pmdiso->GetSmn();
-         clusdata[0] = (Float_t) pmdiso->GetRow();
-         clusdata[1] = (Float_t) pmdiso->GetCol();
-         clusdata[2] = pmdiso->GetADC();
-         clusdata[3] = 1.;
-         clusdata[4] = -99.;
-         clusdata[5] = -99.;
-         
-         AddRecPoint(idet,ismn,clusdata);
-       }
-      pmdisocell->Delete();
-      
       branch1->Fill();
       ResetRecpoint();
 
@@ -517,12 +347,11 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
   //   delete the pointers
   delete pmdclust;
   delete pmdcont;
-  delete pmdisocell;
 }
 // ------------------------------------------------------------------------- //
 
 void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
-                                          TTree *clustersTree)
+                                          TTree *clustersTree, Int_t gRecoMode)
 {
   // Converts RAW data to recpoints after running clustering
   // algorithm on CPV and PREshower plane
@@ -532,45 +361,23 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
 
   AliPMDddldata *pmdddl = 0x0;
   AliPMDcluster *pmdcl  = 0x0;
-  AliPMDisocell *pmdiso = 0x0;
-
 
   Float_t  clusdata[6];
   TObjArray pmdddlcont;
 
   TObjArray *pmdcont = new TObjArray();
-  TObjArray *pmdisocell = new TObjArray();
 
   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
 
-  // open the ddl file info to know the module
-  TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
-  ddlinfofileName += "/PMD/PMD_ddl_info.dat";
-  
-  ifstream infileddl;
-  infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
-  if(!infileddl) AliError("Could not read the ddl info file");
+  // access the ddlinfo database to fetch  the no of modules per DDL
 
-  Int_t ddlno;
-  Int_t modno;
-  Int_t modulePerDDL;
-  Int_t moduleddl[6];
+  Int_t moduleddl[6] = {0,0,0,0,0,0};
 
   for(Int_t jddl = 0; jddl < 6; jddl++)
     {
-      if (infileddl.eof()) break;
-      infileddl >> ddlno >> modulePerDDL;
-      moduleddl[jddl] = modulePerDDL;
-
-      if (modulePerDDL == 0) continue;
-      for (Int_t im = 0; im < modulePerDDL; im++)
-       {
-         infileddl >> modno;
-       }
+      moduleddl[jddl] = fDdlinfo->GetNoOfModulePerDdl(jddl);
     }
 
-  infileddl.close();
-
   // Set the minimum noise cut per module before clustering
 
   fRecoParam = AliPMDReconstructor::GetRecoParam();
@@ -652,7 +459,6 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
              continue; 
            }
 
-
          // Pedestal Subtraction
          Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
          Int_t   pedrms1    = (Int_t) pedmeanrms%100;
@@ -664,7 +470,6 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
          // Float_t sig1 = (Float_t) sig;
          Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
 
-
          // Hot cell - set the cell adc = 0
          Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
          if (hotflag == 1.) sig1 = 0;
@@ -791,16 +596,38 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
 
          Int_t imod = idet*24 + ismn;
 
-         fEcut = fRecoParam->GetNoiseCut(imod);       // default
-         // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
-         // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
-         // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
+         // Int_t cluspar = fRecoParam->GetPbPbParam()->GetClusteringParam();
+         AliPMDRecoParam * par = fRecoParam->GetPPParam();
+          Int_t cluspar = par->GetClusteringParam();
+          delete par;
+         // Int_t cluspar = fRecoParam->GetCosmicParam()->GetClusteringParam();
+
+         //_______________________________________________________// 
+         //Added to switch Refine and crude Clustering - satya//
+         // temporary solution - will be sorted out later
+         /* cluspar = 1;
+         static AliPMDRecoParam *reconp = NULL;
+         reconp = (AliPMDRecoParam*)AliPMDReconstructor::GetRecoParam();
+         if(!reconp) {
+           cluspar = 1;
+         } 
+         else { 
+           if( reconp->GetClusteringParam() == 1) 
+             cluspar = 1;
+           if( reconp->GetClusteringParam() == 2) 
+             cluspar = 2;
+         }*/
+
+
+         cluspar = gRecoMode; // permanent solution
 
+         //_______________________________________________________// 
 
-         pmdclust->SetEdepCut(fEcut);
+         pmdclust->SetClusteringParam(cluspar);
+         Float_t encut = fNoiseCut->GetNoiseCut(imod);
 
-         pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
-                           pmdisocell,pmdcont);
+         pmdclust->SetEdepCut(encut);
+         pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
 
          Int_t nentries1 = pmdcont->GetEntries();
 
@@ -821,6 +648,7 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
              AddRecPoint(idet,ismn,clusdata);
 
              Int_t ncell = (Int_t) clusdata[3];
+             if (ncell > 19) ncell = 19;
              for(Int_t ihit = 0; ihit < ncell; ihit++)
                {
                  Int_t celldataX = pmdcl->GetClusCellX(ihit);
@@ -836,27 +664,6 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
            }
          pmdcont->Delete();
 
-
-         // Added single isolated cell for offline gain calibration
-         nentries1 = pmdisocell->GetEntries();
-         AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
-         
-         for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
-           {
-             pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
-             idet = pmdiso->GetDetector();
-             ismn = pmdiso->GetSmn();
-             clusdata[0] = (Float_t) pmdiso->GetRow();
-             clusdata[1] = (Float_t) pmdiso->GetCol();
-             clusdata[2] = pmdiso->GetADC();
-             clusdata[3] = 1.;
-             clusdata[4] = -99.;
-             clusdata[5] = -99.;
-      
-             AddRecPoint(idet,ismn,clusdata);
-           }
-         pmdisocell->Delete();
-         
          branch1->Fill();
          ResetRecpoint();
 
@@ -878,357 +685,6 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
   //   delete the pointers
   delete pmdclust;
   delete pmdcont;
-  delete pmdisocell;
-
-}
-// ------------------------------------------------------------------------- //
-
-void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
-{
-  // Converts RAW data to recpoints after running clustering
-  // algorithm on CPV and PREshower plane
-  //
-
-  Float_t  clusdata[6];
-
-  TObjArray pmdddlcont;
-
-  AliPMDcluster *pmdcl  = 0x0;
-  AliPMDisocell *pmdiso  = 0x0;
-
-
-  TObjArray *pmdcont = new TObjArray();
-  TObjArray *pmdisocell = new TObjArray();
-
-  AliPMDClustering *pmdclust = new AliPMDClusteringV1();
-
-  // open the ddl file info to know the module
-  TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
-  ddlinfofileName += "/PMD/PMD_ddl_info.dat";
-  
-  ifstream infileddl;
-  infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
-  if(!infileddl) AliError("Could not read the ddl info file");
-
-  Int_t ddlno;
-  Int_t modno;
-  Int_t modulePerDDL;
-  Int_t moduleddl[6];
-
-  for(Int_t jddl = 0; jddl < 6; jddl++)
-    {
-      if (infileddl.eof()) break;
-      infileddl >> ddlno >> modulePerDDL;
-      moduleddl[jddl] = modulePerDDL;
-
-      if (modulePerDDL == 0) continue;
-      for (Int_t im = 0; im < modulePerDDL; im++)
-       {
-         infileddl >> modno;
-       }
-    }
-
-  infileddl.close();
-
-  // Set the minimum noise cut per module before clustering
-
-  fRecoParam = AliPMDReconstructor::GetRecoParam();
-
-  if(fRecoParam == 0x0)
-    {
-       AliFatal("No Reco Param found for PMD!!!");
-    }
-
-
-  fRunLoader->GetEvent(ievt);
-
-  ResetRecpoint();
-
-  fTreeR = fPMDLoader->TreeR();
-  if (fTreeR == 0x0)
-    {
-      fPMDLoader->MakeTree("R");
-      fTreeR = fPMDLoader->TreeR();
-    }
-  Int_t bufsize = 16000;
-  TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); 
-  TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); 
-
-  const Int_t kRow = 48;
-  const Int_t kCol = 96;
-
-  Int_t idet = 0;
-  Int_t iSMN = 0;
-
-  AliPMDRawStream pmdinput(rawReader);
-  Int_t indexDDL = -1;
-
-  while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
-    {
-      
-      iSMN = moduleddl[indexDDL];
-
-      Int_t ***precpvADC;
-      precpvADC = new int **[iSMN];
-      for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
-      for (Int_t i=0; i<iSMN;i++)
-       {
-         for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
-       }
-      for (Int_t i = 0; i < iSMN; i++)
-       {
-         for (Int_t j = 0; j < kRow; j++)
-           {
-             for (Int_t k = 0; k < kCol; k++)
-               {
-                 precpvADC[i][j][k] = 0;
-               }
-           }
-       }
-      ResetCellADC();
-
-    
-      Int_t indexsmn = 0;
-      Int_t ientries = pmdddlcont.GetEntries();
-      for (Int_t ient = 0; ient < ientries; ient++)
-       {
-         AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
-         
-         Int_t det = pmdddl->GetDetector();
-         Int_t smn = pmdddl->GetSMN();
-         //Int_t mcm = pmdddl->GetMCM();
-         //Int_t chno = pmdddl->GetChannel();
-         Int_t row = pmdddl->GetRow();
-         Int_t col = pmdddl->GetColumn();
-         Int_t sig = pmdddl->GetSignal();
-         if(row < 0 || row > 48 || col < 0 || col > 96)
-           {
-             AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
-                             row, col));
-             continue; 
-           }
-         // Pedestal Subtraction
-         Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
-         Int_t   pedrms1    = (Int_t) pedmeanrms%100;
-         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 - (pedmean + 3.0*pedrms);
-
-         // Hot cell - set the cell adc = 0
-         Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
-         if (hotflag == 1) sig1 = 0;
-
-         // CALIBRATION
-         Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
-
-         //printf("sig = %d gain = %f\n",sig,gain);
-         sig = (Int_t) (sig1*gain);
-
-         if (indexDDL == 0)
-           {
-             if (det != 0)
-               AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
-                             indexDDL, det));
-             if (iSMN == 6)
-               {
-                 indexsmn = smn;
-               }
-             else if (iSMN == 12)
-               {
-                 if (smn < 6)
-                   indexsmn = smn;
-                 else if (smn >= 18 && smn < 24)
-                   indexsmn = smn-12;
-               }
-           }
-         else if (indexDDL >= 1 && indexDDL < 4)
-           {
-             if (det != 0)
-               AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
-                             indexDDL, det));
-             indexsmn = smn - indexDDL * 6;
-           }
-         else if (indexDDL == 4)
-           {
-             if (det != 1)
-               AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
-                             indexDDL, det));
-             if (smn < 6)
-               {
-                 indexsmn = smn;
-               }
-             else if (smn >= 18 && smn < 24)
-               {
-                 indexsmn = smn - 12;
-               }
-           }
-         else if (indexDDL == 5)
-           {
-             if (det != 1)
-               AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
-                             indexDDL, det));
-             if (smn >= 6 && smn < 18)
-               {
-                 indexsmn = smn - 6;
-               }
-           }         
-         
-         precpvADC[indexsmn][row][col] = sig;
-
-       }
-      
-      pmdddlcont.Delete();
-
-      Int_t ismn = 0;
-      for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
-       {
-         ResetCellADC();
-         for (Int_t irow = 0; irow < kRow; irow++)
-           {
-             for (Int_t icol = 0; icol < kCol; icol++)
-               {
-                 fCellTrack[irow][icol] = -1;
-                 fCellPid[irow][icol]   = -1;
-                 fCellADC[irow][icol] = 
-                   (Double_t) precpvADC[indexsmn][irow][icol];
-               } // row
-           }     // col
-
-
-         if (indexDDL == 0)
-           {
-             if (iSMN == 6)
-               {
-                 ismn = indexsmn;
-               }
-             else if (iSMN == 12)
-               {
-                 
-                 if (indexsmn < 6)
-                   ismn = indexsmn;
-                 else if (indexsmn >= 6 && indexsmn < 12)
-                   ismn = indexsmn + 12;
-               }
-             idet = 0;
-           }
-         else if (indexDDL >= 1 && indexDDL < 4)
-           {
-             ismn = indexsmn + indexDDL * 6;
-             idet = 0;
-           }
-         else if (indexDDL == 4)
-           {
-             if (indexsmn < 6)
-               {
-                 ismn = indexsmn;
-               }
-             else if (indexsmn >= 6 && indexsmn < 12)
-               {
-                 ismn = indexsmn + 12;
-               }
-             idet = 1;
-           }
-         else if (indexDDL == 5)
-           {
-             ismn = indexsmn + 6;
-             idet = 1;
-           }
-
-         Int_t imod = idet*24 + ismn;
-         fEcut = fRecoParam->GetNoiseCut(imod);       // default
-         // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
-         // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
-         // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
-
-         pmdclust->SetEdepCut(fEcut);
-
-         pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
-                           pmdisocell,pmdcont);
-
-         Int_t nentries1 = pmdcont->GetEntries();
-
-         AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
-
-         for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
-           {
-             pmdcl       = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
-             idet        = pmdcl->GetDetector();
-             ismn        = pmdcl->GetSMN();
-             clusdata[0] = pmdcl->GetClusX();
-             clusdata[1] = pmdcl->GetClusY();
-             clusdata[2] = pmdcl->GetClusADC();
-             clusdata[3] = pmdcl->GetClusCells();
-             clusdata[4] = pmdcl->GetClusSigmaX();
-             clusdata[5] = pmdcl->GetClusSigmaY();
-
-             AddRecPoint(idet,ismn,clusdata);
-
-             Int_t ncell = (Int_t) clusdata[3];
-             for(Int_t ihit = 0; ihit < ncell; ihit++)
-               {
-                 Int_t celldataX = pmdcl->GetClusCellX(ihit);
-                 Int_t celldataY = pmdcl->GetClusCellY(ihit);
-                 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
-                 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
-                 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
-                 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
-               }
-             branch2->Fill();
-             ResetRechit();
-
-           }
-         pmdcont->Delete();
-
-         // Added single isolated cell for offline gain calibration
-         nentries1 = pmdisocell->GetEntries();
-         AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
-         
-         for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
-           {
-             pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
-             idet = pmdiso->GetDetector();
-             ismn = pmdiso->GetSmn();
-             clusdata[0] = (Float_t) pmdiso->GetRow();
-             clusdata[1] = (Float_t) pmdiso->GetCol();
-             clusdata[2] = pmdiso->GetADC();
-             clusdata[3] = 1.;
-             clusdata[4] = -99.;
-             clusdata[5] = -99.;
-      
-             AddRecPoint(idet,ismn,clusdata);
-           }
-         pmdisocell->Delete();
-         
-         branch1->Fill();
-         ResetRecpoint();
-
-
-       } // smn
-
-      for (Int_t i=0; i<iSMN; i++)
-       {
-         for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
-       }
-      for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
-      delete precpvADC;
-    } // DDL Loop
-
-
-  ResetCellADC();
-  
-  fPMDLoader = fRunLoader->GetLoader("PMDLoader");  
-  fPMDLoader->WriteRecPoints("OVERWRITE");
-
-  //   delete the pointers
-  delete pmdclust;
-  delete pmdcont;
-  delete pmdisocell;
-}
-// ------------------------------------------------------------------------- //
-void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
-{
-  fEcut = ecut;
 }
 // ------------------------------------------------------------------------- //
 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
@@ -1362,4 +818,36 @@ AliPMDHotData* AliPMDClusterFinder::GetCalibHot() const
   
   return hot;
 }
+//--------------------------------------------------------------------//
+AliPMDNoiseCut* AliPMDClusterFinder::GetNoiseCut() const
+{
+  // The run number will be centralized in AliCDBManager,
+  // you don't need to set it here!
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/NoiseCut");
+  
+  if(!entry) AliFatal("Noisecut object retrieval failed!");
+  
+  AliPMDNoiseCut *ncut = 0;
+  if (entry) ncut = (AliPMDNoiseCut*) entry->GetObject();
+  
+  if (!ncut)  AliFatal("No noise cut data from  database !");
+  
+  return ncut;
+}
+//--------------------------------------------------------------------//
+AliPMDddlinfoData* AliPMDClusterFinder::GetDdlinfoData() const
+{
+  // The run number will be centralized in AliCDBManager,
+  // you don't need to set it here!
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ddlinfo");
+  
+  if(!entry) AliFatal("ddlinfo object retrieval failed!");
+  
+  AliPMDddlinfoData *ddlinfo = 0;
+  if (entry) ddlinfo = (AliPMDddlinfoData*) entry->GetObject();
+  
+  if (!ddlinfo)  AliFatal("No ddl info data from  database !");
+  
+  return ddlinfo;
+}