]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDClusterFinder.cxx
isolated cell serach included in AliPMDClusteringV1 and kept in recpoints for offline...
[u/mrichter/AliRoot.git] / PMD / AliPMDClusterFinder.cxx
index 0b5a604c08ce37728f86aaaa2733e948d4e1aecc..5a92759229e9343b8e47e25db4c22cdff7253449 100644 (file)
@@ -39,6 +39,7 @@
 #include "AliPMDcluster.h"
 #include "AliPMDrecpoint1.h"
 #include "AliPMDrechit.h"
+#include "AliPMDisocell.h"
 #include "AliPMDRawStream.h"
 #include "AliPMDCalibData.h"
 #include "AliPMDPedestal.h"
@@ -134,6 +135,7 @@ AliPMDClusterFinder::~AliPMDClusterFinder()
     {
       fRechits->Clear();
     }
+
 }
 // ------------------------------------------------------------------------- //
 
@@ -150,7 +152,11 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
   Int_t    idet;
   Float_t  clusdata[6];
 
+  AliPMDisocell *pmdiso = 0x0;
+
   TObjArray *pmdcont = new TObjArray();
+  TObjArray *pmdisocell = new TObjArray();
+
   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
 
   pmdclust->SetEdepCut(fEcut);
@@ -197,7 +203,12 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
          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; 
+           }
          // CALIBRATION
          Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
          // printf("adc = %d gain = %f\n",adc,gain);
@@ -205,13 +216,17 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
          adc = adc*gain;
 
          //Int_t trno   = pmddigit->GetTrackNumber();
-         fCellADC[xpos][ypos] = (Double_t) adc;
+         fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
+         fCellPid[xpos][ypos]   = pmddigit->GetTrackPid();
+         fCellADC[xpos][ypos]   = (Double_t) adc;
        }
 
       idet = det;
       ismn = smn;
-      pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
-      
+      //pmdclust->DoClust(idet,ismn,fCellADC,pmdisocell,pmdcont);
+      pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
+                       pmdisocell,pmdcont);
+
       Int_t nentries1 = pmdcont->GetEntries();
 
       AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
@@ -235,12 +250,35 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
            {
              Int_t celldataX = pmdcl->GetClusCellX(ihit);
              Int_t celldataY = pmdcl->GetClusCellY(ihit);
-             AddRecHit(celldataX, celldataY);
+             Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
+             Int_t celldataPid   = pmdcl->GetClusCellPid(ihit);
+             AddRecHit(celldataX, celldataY, celldataTr, celldataPid);
+             //AddRecHit(celldataX, celldataY);
            }
          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();
@@ -254,6 +292,7 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
   //   delete the pointers
   delete pmdclust;
   delete pmdcont;
+  delete pmdisocell;
     
 }
 // ------------------------------------------------------------------------- //
@@ -264,6 +303,7 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
   // 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;
@@ -272,7 +312,11 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
   Int_t    idet;
   Float_t  clusdata[6];
 
+  AliPMDcluster *pmdcl = 0x0;
+  AliPMDisocell *pmdiso = 0x0;
+
   TObjArray *pmdcont = new TObjArray();
+  TObjArray *pmdisocell = new TObjArray();
   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
 
   pmdclust->SetEdepCut(fEcut);
@@ -291,6 +335,8 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
 
   for (Int_t imodule = 0; imodule < nmodules; imodule++)
     {
+
+      Int_t totADCMod = 0;
       ResetCellADC();
       digitsTree->GetEntry(imodule); 
       Int_t nentries = fDigits->GetLast();
@@ -303,10 +349,16 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
          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; 
+           }
+         
          // Pedestal Subtraction
          Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
-         Int_t   pedrms1    = (Int_t) pedmeanrms%1000;
+         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);
@@ -320,12 +372,21 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
          adc = adc1*gain;
 
          //Int_t trno   = pmddigit->GetTrackNumber();
+         fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
+         fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
          fCellADC[xpos][ypos] = (Double_t) adc;
+
+         totADCMod += (Int_t) adc;
+
        }
 
       idet = det;
       ismn = smn;
-      pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
+
+      if (totADCMod <= 0) continue;
+
+      pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
+                       pmdisocell,pmdcont);
       
       Int_t nentries1 = pmdcont->GetEntries();
 
@@ -333,7 +394,7 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
 
       for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
        {
-         AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
+         pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
          idet        = pmdcl->GetDetector();
          ismn        = pmdcl->GetSMN();
          clusdata[0] = pmdcl->GetClusX();
@@ -350,24 +411,47 @@ void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
            {
              Int_t celldataX = pmdcl->GetClusCellX(ihit);
              Int_t celldataY = pmdcl->GetClusCellY(ihit);
-             AddRecHit(celldataX, celldataY);
+             Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
+             Int_t celldataPid   = pmdcl->GetClusCellPid(ihit);
+             AddRecHit(celldataX, celldataY, celldataTr, celldataPid);
            }
          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();
 
   //   delete the pointers
   delete pmdclust;
   delete pmdcont;
-    
+  delete pmdisocell;
 }
 // ------------------------------------------------------------------------- //
 
@@ -377,13 +461,20 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
   // Converts RAW data to recpoints after running clustering
   // algorithm on CPV and PREshower plane
   //
-  // This method is called at the time of reconstruction
+  // This method is called at the time of reconstruction from RAW data
+
+
+  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();
 
   pmdclust->SetEdepCut(fEcut);
@@ -437,7 +528,7 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
       Int_t ientries = pmdddlcont.GetEntries();
       for (Int_t ient = 0; ient < ientries; ient++)
        {
-         AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
+         pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
          
          Int_t det = pmdddl->GetDetector();
          Int_t smn = pmdddl->GetSMN();
@@ -447,9 +538,21 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
          Int_t col = pmdddl->GetColumn();
          Int_t sig = pmdddl->GetSignal();
 
+         if(smn == -1)
+           {
+             AliError(Form("*MODULE NUMBER WRONG %d *",smn));
+             continue; 
+           }
+         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%1000;
+         Int_t   pedrms1    = (Int_t) pedmeanrms%100;
          Float_t pedrms     = (Float_t)pedrms1/10.;
          Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
 
@@ -501,19 +604,25 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
          precpvADC[indexsmn][row][col] = sig;
        }
       
-      //pmdddlcont.Clear();
       pmdddlcont.Delete();
 
+      Int_t totAdcMod = 0;
+
       Int_t ismn = 0;
       for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
        {
          ResetCellADC();
+         totAdcMod = 0;
          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];
+                 totAdcMod += precpvADC[indexsmn][irow][icol];
                } // row
            }     // col
          
@@ -547,15 +656,20 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
              idet = 1;
            }
 
-         pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
+         if (totAdcMod <= 0) continue;
+
+
+         //pmdclust->DoClust(idet,ismn,fCellADC,pmdisocell,pmdcont);
+         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);
+             pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
              idet        = pmdcl->GetDetector();
              ismn        = pmdcl->GetSMN();
              clusdata[0] = pmdcl->GetClusX();
@@ -572,13 +686,37 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
                {
                  Int_t celldataX = pmdcl->GetClusCellX(ihit);
                  Int_t celldataY = pmdcl->GetClusCellY(ihit);
-                 AddRecHit(celldataX, celldataY);
+                 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
+                 Int_t celldataPid   = pmdcl->GetClusCellPid(ihit);
+                 AddRecHit(celldataX, celldataY, celldataTr, celldataPid);
+                 //AddRecHit(celldataX, celldataY);
                }
              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();
@@ -591,15 +729,17 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
          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;
+      delete [] precpvADC;
 
     } // DDL Loop
+
   
   ResetCellADC();
   
   //   delete the pointers
   delete pmdclust;
   delete pmdcont;
+  delete pmdisocell;
 
 }
 // ------------------------------------------------------------------------- //
@@ -611,8 +751,15 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
   //
 
   Float_t  clusdata[6];
+
   TObjArray pmdddlcont;
+
+  //AliPMDcluster *pmdcl  = 0x0;
+  AliPMDisocell *pmdiso  = 0x0;
+
+
   TObjArray *pmdcont = new TObjArray();
+  TObjArray *pmdisocell = new TObjArray();
 
   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
 
@@ -684,10 +831,15 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
          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%1000;
+         Int_t   pedrms1    = (Int_t) pedmeanrms%100;
          Float_t pedrms     = (Float_t)pedrms1/10.;
          Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
 
@@ -751,6 +903,8 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
            {
              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
@@ -787,7 +941,10 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
              idet = 1;
            }
 
-         pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
+         //pmdclust->DoClust(idet,ismn,fCellADC,pmdisocell,pmdcont);
+         pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
+                           pmdisocell,pmdcont);
+
          Int_t nentries1 = pmdcont->GetEntries();
 
          AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
@@ -812,13 +969,36 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
                {
                  Int_t celldataX = pmdcl->GetClusCellX(ihit);
                  Int_t celldataY = pmdcl->GetClusCellY(ihit);
-                 AddRecHit(celldataX, celldataY);
+                 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
+                 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
+                 AddRecHit(celldataX, celldataY, celldataTr, celldataPid);
+                 //AddRecHit(celldataX, celldataY);
                }
              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();
@@ -833,7 +1013,8 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
       for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
       delete precpvADC;
     } // DDL Loop
-  
+
+
   ResetCellADC();
   
   fPMDLoader = fRunLoader->GetLoader("PMDLoader");  
@@ -842,7 +1023,7 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
   //   delete the pointers
   delete pmdclust;
   delete pmdcont;
-
+  delete pmdisocell;
 }
 // ------------------------------------------------------------------------- //
 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
@@ -861,13 +1042,14 @@ void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
   delete newrecpoint;
 }
 // ------------------------------------------------------------------------- //
-void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY)
+void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY,
+                                   Int_t celldataTr, Int_t celldataPid)
 {
   // Add associated cell hits to the Reconstructed points
   //
   TClonesArray &lrechits = *fRechits;
   AliPMDrechit *newrechit;
-  newrechit = new AliPMDrechit(celldataX, celldataY);
+  newrechit = new AliPMDrechit(celldataX, celldataY, celldataTr, celldataPid);
   new(lrechits[fNhit++]) AliPMDrechit(newrechit);
   delete newrechit;
 }
@@ -880,12 +1062,13 @@ void AliPMDClusterFinder::ResetCellADC()
     {
       for(Int_t icol = 0; icol < fgkCol; icol++)
        {
-         fCellADC[irow][icol] = 0.;
+         fCellTrack[irow][icol] = -1;
+         fCellPid[irow][icol]   = -1;
+         fCellADC[irow][icol]   = 0.;
        }
     }
 }
 // ------------------------------------------------------------------------- //
-
 void AliPMDClusterFinder::ResetRecpoint()
 {
   // Clear the list of reconstructed points
@@ -930,7 +1113,6 @@ void AliPMDClusterFinder::UnLoadClusters()
   fPMDLoader->UnloadRecPoints();
 }
 // ------------------------------------------------------------------------- //
-
 AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
 {
   // The run number will be centralized in AliCDBManager,
@@ -947,9 +1129,7 @@ AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
   
   return calibdata;
 }
-
 // ------------------------------------------------------------------------- //
-
 AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
 {
   // The run number will be centralized in AliCDBManager,