]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDClustering.cxx
gain values initialised to -1
[u/mrichter/AliRoot.git] / PMD / AliPMDClustering.cxx
index dd0532677ca0b6751ce0fe08675ccd643b199286..f9c766413b22785318f5bec30124e1b1ca879b96 100644 (file)
 #include "Riostream.h"
 #include <TNtuple.h>
 #include <TObjArray.h>
+#include <stdio.h>
+
 #include "AliPMDcluster.h"
 #include "AliPMDClustering.h"
-#include <stdio.h>
+#include "AliLog.h"
 
 ClassImp(AliPMDClustering)
 
 const Double_t AliPMDClustering::fgkSqroot3by2=0.8660254;  // sqrt(3.)/2.
 
 AliPMDClustering::AliPMDClustering():
-  fDebug(0),
   fCutoff(0.0)
 {
   for(int i = 0; i < kNDIMX; i++)
@@ -108,28 +109,22 @@ void AliPMDClustering::DoClust(Int_t idet, Int_t ismn, Double_t celladc[48][96],
       if (fEdepCell[i1][i2] > cutoff ) nmx1 = nmx1 + 1;
     }
   // nmx1 --- number of cells having ener dep >= cutoff
-  if (fDebug == 1)
-    {
-      cout << " nmx1 " << nmx1 << endl;
-    }
+
+  AliDebug(1,Form("Number of cells having energy >= %f are %d",cutoff,nmx1));
 
   //  if (nmx1 == 0 | nmx1 == -1) return;
 
   if (nmx1 == 0) nmx1 = 1;
   ave=ave/nmx1;
-  if (fDebug == 1)
-    {
-      cout <<"kNMX " << kNMX << " nmx1 " << nmx1<< " ave "<<ave<<
-       " cutoff " << cutoff << endl;
-    }
 
+  AliDebug(1,Form("Number of cells in a SuperM = %d and Average = %f",
+                 kNMX,ave));
+          
   incr = CrClust(ave, cutoff, nmx1);
   RefClust(incr);
-  if (fDebug == 1)
-    {
-      cout << "fClno " << fClno << endl;
-    }
 
+  AliDebug(1,Form("Detector Plane = %d  Serial Module No = %d Number of clusters = %d",idet, ismn, fClno));
+  
   for(i1=0; i1<=fClno; i1++)
     {
       Float_t cluXC    = (Float_t) fClusters[0][i1];
@@ -158,10 +153,10 @@ void AliPMDClustering::Order()
   // Sorting algorithm
   // sorts the ADC values from higher to lower
   //
-  double dd[kNMX], adum;
+  double dd[kNMX];
   // matrix fEdepCell converted into
   // one dimensional array dd. adum a place holder for double
-  int i, j, i1, i2, iord1[kNMX], itst, idum;
+  int i, j, i1, i2, iord1[kNMX];
   // information of
   // ordering is stored in iord1, original array not ordered
   //
@@ -176,26 +171,28 @@ void AliPMDClustering::Order()
        }
     }
   // sort and store sorting information in iord1
-  for(j=1; j < kNMX; j++)
-    {
-      itst = 0;
-      adum = dd[j];
-      idum = iord1[j];
-      for(i1=0; i1 < j ; i1++)
-       {
-         if(adum > dd[i1] && itst == 0)
-           {
-             itst = 1;
-             for(i2=j-1; i2 >= i1 ; i2=i2--)
-               {
-                 dd[i2+1]    = dd[i2];
-                 iord1[i2+1] = iord1[i2];
-               }
-             dd[i1]    = adum;
-             iord1[i1] = idum;
-           }
-       }
-    }
+//   for(j=1; j < kNMX; j++)
+//     {
+//       itst = 0;
+//       adum = dd[j];
+//       idum = iord1[j];
+//       for(i1=0; i1 < j ; i1++)
+//     {
+//       if(adum > dd[i1] && itst == 0)
+//         {
+//           itst = 1;
+//           for(i2=j-1; i2 >= i1 ; i2=i2--)
+//             {
+//               dd[i2+1]    = dd[i2];
+//               iord1[i2+1] = iord1[i2];
+//             }
+//           dd[i1]    = adum;
+//           iord1[i1] = idum;
+//         }
+//     }
+//     }
+
+  TMath::Sort(kNMX,dd,iord1); //PH Using much better algorithm...
   // store the sorted information in fIord for later use
   for(i=0; i<kNMX; i++)
     {
@@ -223,11 +220,8 @@ int AliPMDClustering::CrClust(double ave, double cutoff, int nmx1)
   // ofstream ofl0("cells_loc",ios::out);
   // initialize fInfocl[2][kNDIMX][kNDIMY]
 
-  if (fDebug == 1)
-    {
-      printf(" *** Inside CrClust **  kNMX = %d nmx1 = %d kNDIMX = %d kNDIMY = %d ave = %f cutoff = %f\n",
-            kNMX,nmx1,kNDIMX,kNDIMY,ave,cutoff);
-    }
+  AliDebug(1,Form("kNMX = %d nmx1 = %d kNDIMX = %d kNDIMY = %d ave = %f cutoff = %f",kNMX,nmx1,kNDIMX,kNDIMY,ave,cutoff));
+  
   for (j=0; j < kNDIMX; j++){
     for(k=0; k < kNDIMY; k++){
       fInfocl[0][j][k] = 0;
@@ -347,17 +341,16 @@ void AliPMDClustering::RefClust(int incr)
   for(i=0; i<incr; i++){
     if(fInfcl[0][i] != nsupcl){ nsupcl=nsupcl+1; }
     if (nsupcl > 4500) {
-      Error("RefClust", "Too many superclusters!");
+      AliWarning("RefClust: Too many superclusters!");
       nsupcl = 4500;
       break;
     }
     ncl[nsupcl]=ncl[nsupcl]+1;
   }
-  if (fDebug == 1)
-    {
-      cout << " # of cells " <<incr+1 << " # of superclusters " << nsupcl+1
-          << endl;
-    }
+
+  AliDebug(1,Form("Number of cells = %d Number of Superclusters = %d",
+                 incr+1,nsupcl+1));
+
   id=-1;
   icl=-1;
   for(i=0; i<nsupcl; i++){
@@ -368,7 +361,7 @@ void AliPMDClustering::RefClust(int incr)
       // cluster center at the centyer of the cell
       // cluster radius = half cell dimension
       if (fClno >= 5000) {
-       Error("RefClust", "Too many clusters!");
+       AliWarning("RefClust: Too many clusters! more than 5000");
        return;
       }
       fClno = fClno + 1;
@@ -388,7 +381,7 @@ void AliPMDClustering::RefClust(int incr)
       id   = id + 1;
       icl  = icl+1;
       if (fClno >= 5000) {
-       Error("RefClust", "Too many clusters!");
+       AliWarning("RefClust: Too many clusters! more than 5000");
        return;
       }
       fClno = fClno+1;
@@ -534,7 +527,7 @@ void AliPMDClustering::RefClust(int incr)
       }
       for(j=0; j<=ig; j++){
        if (fClno >= 5000) {
-         Error("RefClust", "Too many clusters!");
+         AliWarning("RefClust: Too many clusters! more than 5000");
          return;
        }
        fClno               = fClno + 1;
@@ -556,7 +549,7 @@ void AliPMDClustering::GaussFit(Int_t ncell, Int_t nclust, Double_t &x, Double_t
 {
   // Does gaussian fitting
   //
-  int i, j, i1, i2, jmax, novar, idd, jj;
+  int i, j, i1, i2, novar, idd, jj;
   double xx[4500], yy[4500], zz[4500], xxc[4500], yyc[4500];
   double a[4500], b[4500], c[4500], d[4500], ha[4500], hb[4500];
   double hc[4500], hd[4500], zzc[4500], rrc[4500];
@@ -618,9 +611,9 @@ void AliPMDClustering::GaussFit(Int_t ncell, Int_t nclust, Double_t &x, Double_t
     }
     sum=sum+(aint-zz[i1])*(aint-zz[i1])/str;
   }
-  jmax=nclust*1000;
-  if(nclust > 20)jmax=20000;
-  for(j=0; j<jmax; j++){
+//   jmax=nclust*1000;
+//   if(nclust > 20)jmax=20000;
+//   for(j=0; j<jmax; j++){
     str1=0.;
     for(i=0; i<=nclust; i++){
       a[i]=xxc[i]+0.6*(Ranmar()-0.5);
@@ -654,7 +647,7 @@ void AliPMDClustering::GaussFit(Int_t ncell, Int_t nclust, Double_t &x, Double_t
        sum=sum1;
       }
     }
-  }
+//   }
   for(j=0; j<=nclust; j++){
     *(&xc+j)=xxc[j];
     *(&yc+j)=yyc[j];
@@ -719,7 +712,7 @@ double AliPMDClustering::Ranmar() const
       cm = 16777213./16777216.;
     }
     else{
-      cout << " wrong initialization " << endl;
+      AliWarning("Wrong initialization");
     }
   }
   else{
@@ -743,7 +736,3 @@ void AliPMDClustering::SetEdepCut(Float_t decut)
   fCutoff = decut;
 }
 // ------------------------------------------------------------------------ //
-void AliPMDClustering::SetDebug(Int_t idebug)
-{
-  fDebug = idebug;
-}