]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDClusterFinder.cxx
Warning cleaned
[u/mrichter/AliRoot.git] / PMD / AliPMDClusterFinder.cxx
index 48dadf1d06e5bcafd4495d5a33302099ceb9a0b5..67b5d0f0fb83a66e56580a88845ed48e76e84dda 100644 (file)
@@ -1,3 +1,18 @@
+/***************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
 //-----------------------------------------------------//
 //                                                     //
 //           Date   : August 05 2003                   //
@@ -8,6 +23,7 @@
 //-----------------------------------------------------//
 
 #include <Riostream.h>
+#include <TMath.h>
 #include <TBRIK.h>
 #include <TNode.h>
 #include <TTree.h>
 
 
 ClassImp(AliPMDClusterFinder)
-//
-// Constructor
-//
+
 AliPMDClusterFinder::AliPMDClusterFinder()
 {
-  if (!fRecpoints) fRecpoints = new TClonesArray("AliPMDrecpoint", 1000);  
+//
+// Default Constructor
+//
+  if (!fRecpoints) fRecpoints = new TClonesArray("AliPMDrecpoint1", 1000);  
   fNpoint = 0;
 
-  for (Int_t i = 0; i < fTotSM; i++)
-    {
-      for (Int_t j = 0; j < fNCell; j++)
-       {
-         for (Int_t k = 0; k < fNCell; k++)
-           {
-             fCPV[i][j][k] = 0.; 
-             fPMD[i][j][k] = 0.; 
-           }
-       }
-    }
+  fDebug = 0;
+  fEcut  = 0.;
 
 }
 AliPMDClusterFinder::~AliPMDClusterFinder()
 {
+  // Destructor
   delete fRecpoints;
 }
-//
-// Member functions
-//
+
 void AliPMDClusterFinder::OpengAliceFile(Char_t *file, Option_t *option)
 {
-
+  // Loads galice.root file and corresponding header, kinematics
+  // hits and sdigits or digits depending on the option
+  //
   fRunLoader = AliRunLoader::Open(file,AliConfig::fgkDefaultEventFolderName,
                                  "UPDATE");
   
@@ -88,9 +97,9 @@ void AliPMDClusterFinder::OpengAliceFile(Char_t *file, Option_t *option)
       printf("<AliPMDdigitizer::Open> ");
       printf("Could not find AliRun object.\n");
     }
-  PMD  = (AliPMD*)gAlice->GetDetector("PMD");
-  pmdloader = fRunLoader->GetLoader("PMDLoader");
-  if (pmdloader == 0x0)
+  fPMD  = (AliPMD*)gAlice->GetDetector("PMD");
+  fPMDLoader = fRunLoader->GetLoader("PMDLoader");
+  if (fPMDLoader == 0x0)
     {
       cerr<<"OpengAlice : Can not find PMD or PMDLoader\n";
     }
@@ -99,50 +108,58 @@ void AliPMDClusterFinder::OpengAliceFile(Char_t *file, Option_t *option)
 
   if (cDR)
     {
-      pmdloader->LoadDigits("READ");
-      pmdloader->LoadRecPoints("recreate");
+      fPMDLoader->LoadDigits("READ");
+      fPMDLoader->LoadRecPoints("recreate");
     }
 }
 
 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
 {
-  Int_t    det,smn;
+  // Converts digits to recpoints after running clustering
+  // algorithm on CPV plane and PREshower plane
+  //
+  Int_t    det = 0,smn = 0;
   Int_t    cellno;
   Int_t    xpos,ypos;
   Float_t  adc;
-  Int_t    isup, ix, iy;
+  Int_t    isup;
   Int_t    idet;
-  Double_t d[72][72];
   Float_t  clusdata[7];
-  Int_t    fMessage = 1;
+
+  TObjArray *pmdcont = new TObjArray();
+  AliPMDcluster  *pmdcl  = new AliPMDcluster;
+  AliPMDClustering *pmdclust = new AliPMDClustering();
+  pmdclust->SetDebug(fDebug);
+  pmdclust->SetEdepCut(fEcut);
 
   fRunLoader->GetEvent(ievt);
   //cout << " ***** Beginning::Digits2RecPoints *****" << endl;
-  treeD = pmdloader->TreeD();
-  if (treeD == 0x0)
+  fTreeD = fPMDLoader->TreeD();
+  if (fTreeD == 0x0)
     {
       cout << " Can not get TreeD" << endl;
     }
   AliPMDdigit  *pmddigit;
-  TBranch *branch = treeD->GetBranch("PMDDigit");
+  TBranch *branch = fTreeD->GetBranch("PMDDigit");
   branch->SetAddress(&fDigits);
 
   ResetRecpoint();
-  treeR = pmdloader->TreeR();
-  if (treeR == 0x0)
+  fTreeR = fPMDLoader->TreeR();
+  if (fTreeR == 0x0)
     {
-      pmdloader->MakeTree("R");
-      treeR = pmdloader->TreeR();
+      fPMDLoader->MakeTree("R");
+      fTreeR = fPMDLoader->TreeR();
     }
 
   Int_t bufsize = 16000;
-  treeR->Branch("PMDRecpoint", &fRecpoints, bufsize); 
+  fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); 
 
-  Int_t nmodules = (Int_t) treeD->GetEntries();
+  Int_t nmodules = (Int_t) fTreeD->GetEntries();
   
   for (Int_t imodule = 0; imodule < nmodules; imodule++)
     {
-      treeD->GetEntry(imodule); 
+      ResetCellADC();
+      fTreeD->GetEntry(imodule); 
       Int_t nentries = fDigits->GetLast();
       for (Int_t ient = 0; ient < nentries+1; ient++)
        {
@@ -152,80 +169,44 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
          smn    = pmddigit->GetSMNumber();
          cellno = pmddigit->GetCellNumber();
          adc    = pmddigit->GetADC();
+         //Int_t trno   = pmddigit->GetTrackNumber();
 
-         ypos = cellno/fNCell;
-         xpos = cellno - ypos*fNCell;
-
-         if (det == 0)
-           {
-             fPMD[smn][xpos][ypos] = adc;
-           }
-         else if(det == 1)
-           {
-             fCPV[smn][xpos][ypos] = adc;
-           }
+         xpos = cellno/fCol;
+         ypos = cellno - xpos*fCol;
+         fCellADC[xpos][ypos] = (Double_t) adc;
        }
-    } // modules
-
-  //
-  // Clustering started
-  //
-
-  TObjArray *pmdcont = new TObjArray();
-
-  AliPMDcluster  *pmdcl  = new AliPMDcluster;
 
-  AliPMDClustering *pmdclust = new AliPMDClustering();
-  pmdclust->SetMessage(fMessage);
-  
-  for (idet = 0; idet < 2; idet++)
-    {
-      for (isup = 0; isup < fTotSM; isup++)
+      idet = det;
+      isup = smn;
+      pmdclust->DoClust(fCellADC,pmdcont);
+      
+      Int_t nentries1 = pmdcont->GetEntries();
+      cout << " nentries1 = " << nentries1 << endl;
+      for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
        {
-         for (ix = 0; ix < fNCell; ix++)
-           {
-             for (iy = 0; iy < fNCell; iy++)
-               {
-                 if (idet == 0)
-                   {
-                     d[ix][iy] = (Double_t) fPMD[isup][ix][iy];
-                   }
-                 else if (idet == 1)
-                   {
-                     d[ix][iy] = (Double_t) fCPV[isup][ix][iy];
-                   }
-                   
-               }
-           }
-         pmdclust->DoClust(idet,isup,d,pmdcont);
-         
-         Int_t nentries = pmdcont->GetEntries();
-         cout << " nentries = " << nentries << endl;
-         for (Int_t ient = 0; ient < nentries; ient++)
-           {
-             clusdata[0] = (Float_t) idet;
-             clusdata[1] = (Float_t) isup;
-             
-             pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient);
+         clusdata[0] = (Float_t) idet;
+         clusdata[1] = (Float_t) isup;
              
-             clusdata[2] = pmdcl->GetClusX();
-             clusdata[3] = pmdcl->GetClusY();
-             clusdata[4] = pmdcl->GetClusADC();
-             clusdata[5] = pmdcl->GetClusCells();
-             clusdata[6] = pmdcl->GetClusRadius();
+         pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
              
-             AddRecPoint(clusdata);
-           }
-         pmdcont->Clear();
+         clusdata[2] = pmdcl->GetClusX();
+         clusdata[3] = pmdcl->GetClusY();
+         clusdata[4] = pmdcl->GetClusADC();
+         clusdata[5] = pmdcl->GetClusCells();
+         clusdata[6] = pmdcl->GetClusRadius();
          
-         treeR->Fill();
-         ResetRecpoint();
-       }  // SuperModule
-    }  // Detector
-  
+         AddRecPoint(clusdata);
+       }
+      pmdcont->Clear();
+      
+      fTreeR->Fill();
+      ResetRecpoint();
+
+    } // modules
+
   ResetCellADC();
   
-  pmdloader->WriteRecPoints("OVERWRITE");
+  fPMDLoader->WriteRecPoints("OVERWRITE");
 
   //   delete the pointers
   delete pmdclust;
@@ -234,37 +215,48 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
   //  cout << " ***** End::Digits2RecPoints *****" << endl;
 }
 
+void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
+{
+  fEcut = ecut;
+}
+void AliPMDClusterFinder::SetDebug(Int_t idebug)
+{
+  fDebug = idebug;
+}
 
 void AliPMDClusterFinder::AddRecPoint(Float_t *clusdata)
 {
+  // Add Reconstructed points
+  //
   TClonesArray &lrecpoints = *fRecpoints;
-  AliPMDrecpoint *newrecpoint;
-  newrecpoint = new AliPMDrecpoint(clusdata);
-  new(lrecpoints[fNpoint++]) AliPMDrecpoint(newrecpoint);
+  AliPMDrecpoint1 *newrecpoint;
+  newrecpoint = new AliPMDrecpoint1(clusdata);
+  new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
   delete newrecpoint;
 }
 void AliPMDClusterFinder::ResetCellADC()
 {
-  for (Int_t i = 0; i < fTotSM; i++)
+  // Reset the individual cell ADC value to zero
+  //
+  for(Int_t irow = 0; irow < fRow; irow++)
     {
-      for (Int_t j = 0; j < fNCell; j++)
+      for(Int_t icol = 0; icol < fCol; icol++)
        {
-         for (Int_t k = 0; k < fNCell; k++)
-           {
-             fCPV[i][j][k] = 0.; 
-             fPMD[i][j][k] = 0.; 
-           }
+         fCellADC[irow][icol] = 0.;
        }
     }
 }
 
 void AliPMDClusterFinder::ResetRecpoint()
 {
+  // Clear the list of reconstructed points
   fNpoint = 0;
   if (fRecpoints) fRecpoints->Clear();
 }
 void AliPMDClusterFinder::UnLoad(Option_t *option)
 {
+  // Unload all the *.root files
+  //
   const char *cR = strstr(option,"R");
 
   fRunLoader->UnloadgAlice();
@@ -273,6 +265,6 @@ void AliPMDClusterFinder::UnLoad(Option_t *option)
 
   if (cR)
     {
-      pmdloader->UnloadDigits();
+      fPMDLoader->UnloadDigits();
     }
 }