]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDClustering.cxx
Fixed violations
[u/mrichter/AliRoot.git] / PMD / AliPMDClustering.cxx
index 55f587e750c2f30a9914db4d4ee052e9a1cd141a..fb7c9c7ba9f02a13c920b118c5bc53477063aea3 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.                  *
+ **************************************************************************/
+
 //-----------------------------------------------------//
 //                                                     //
 //  Source File : PMDClustering.cxx, Version 00        //
 
 #include <TNtuple.h>
 #include <TObjArray.h>
-#include "AliPMDContainer.h"
 #include "AliPMDcluster.h"
 #include "AliPMDClustering.h"
 #include <stdio.h>
 
 ClassImp(AliPMDClustering)
 
+const double AliPMDClustering::pi=3.141593;
+const double AliPMDClustering::sqrth=0.8660254;  // sqrth = sqrt(3.)/2.
+
+
 AliPMDClustering::AliPMDClustering()
 {
-  fMessage = 0;
+  fDebug  = 0;
+  fCutoff = 0;
   for(int i = 0; i < ndimx; i++)
     {
       for(int j = 0; j < ndimy; j++)
@@ -56,8 +75,7 @@ AliPMDClustering::~AliPMDClustering()
 
 }
 
-//void AliPMDClustering::DoClust(int idet, int isup, double d1[72][72], AliPMDContainer *pmdc)
-void AliPMDClustering::DoClust(int idet, int isup, double d1[72][72], TObjArray *pmdcont)
+void AliPMDClustering::DoClust(double celladc[48][96], TObjArray *pmdcont)
 {
 
   AliPMDcluster *pmdcl = 0;
@@ -68,55 +86,47 @@ void AliPMDClustering::DoClust(int idet, int isup, double d1[72][72], TObjArray
 
   const float twobysqrt3 = 1.1547; // 2./sqrt(3.)
 
-  //  if (fMessage == 1)
-    {
-      cout << " supermodule no. " << idet << " " << isup << endl;
-    }
 
   for (i = 0; i < ndimx; i++)
     {
       for (j = 0; j < ndimy; j++)
        {
-         d[i][j] = d1[i][j];
+         d[i][j] = celladc[i][j];
        }
     }
-  order(idet); // order the data
-  cutoff=400.; // cutoff used to discard cells having ener. dep. 
+  order(); // order the data
+  cutoff = fCutoff; // cutoff used to discard cells having ener. dep. 
   ave=0.; 
   nmx1=-1;
-
+  
   for(j=0;j<nmx; j++)
     {
       i1 = iord[0][j];
       i2 = iord[1][j];
       if (d[i1][i2] > 0.) {ave=ave+d[i1][i2];}
-      if (d[i1][i2] >= cutoff ) nmx1 = nmx1 + 1;
+      if (d[i1][i2] > cutoff ) nmx1 = nmx1 + 1;
     }
   // nmx1 --- number of cells having ener dep >= cutoff
-  if (fMessage == 1)
+  if (fDebug == 1)
     {
       cout << " nmx1 " << nmx1 << endl;
     }
   ave=ave/nmx1;
-  if (fMessage == 1)
+  if (fDebug == 1)
     {
       cout <<"nmx " << nmx << " nmx1 " << nmx1<< " ave "<<ave<<
        " cutoff " << cutoff << endl;
     }
-
-  incr = crclust(ave, cutoff, nmx1, idet);
-
-  refclust(incr, i, idet);
-  if (fMessage == 1)
+  
+  incr = crclust(ave, cutoff, nmx1);
+  
+  refclust(incr);
+  
+  if (fDebug == 1)
     {
-      if(idet == 0)cout <<" supermodule ( pmd ) = "<< isup <<" done "
-                       <<endl;
-      if(idet == 1)cout <<" supermodule ( cpv ) = "<< isup <<" done "
-                       <<endl;
       cout << "clno " << clno << endl;
     }
-
-
+  
   for(i1=0; i1<clno; i1++)
     {
       float clu_xc    = (float) clusters[0][i1];
@@ -128,21 +138,20 @@ void AliPMDClustering::DoClust(int idet, int isup, double d1[72][72], TObjArray
       float clu_y0 = twobysqrt3*clu_yc;
       float clu_x0 = clu_xc - clu_y0/2.;
 
-      clusdata[0] = clu_cells;
-      clusdata[1] = clu_x0;
-      clusdata[2] = clu_y0;
-      clusdata[3] = clu_adc;
+      clusdata[0] = clu_x0;
+      clusdata[1] = clu_y0;
+      clusdata[2] = clu_adc;
+      clusdata[3] = clu_cells;
       clusdata[4] = clu_rad;
       
       pmdcl = new AliPMDcluster(clusdata);
       pmdcont->Add(pmdcl);
     }
-
   delete pmdcl;
 
 }
 
-void AliPMDClustering::order(int idet)
+void AliPMDClustering::order()
 {
   // using simple sort
   double dd[nmx], adum;// matrix d converted into 
@@ -173,14 +182,127 @@ void AliPMDClustering::order(int idet)
   }
   // store the sorted information in iord for later use
   for(i=0; i<nmx; i++){
-    j=iord1[i]; i2=j/ndimx; 
-    i1=j-i2*ndimx; 
+    j  = iord1[i];
+    i2 = j/ndimx; 
+    i1 = j-i2*ndimx; 
     iord[0][i]=i1; 
     iord[1][i]=i2;
   }
 }
+  
+int AliPMDClustering::crclust(double ave, double cutoff, int nmx1)
+{
+  int i,j,k,id1,id2,icl, numcell, clust[2][5000];
+  int jd1,jd2, icell, cellcount;
+  static int neibx[6]={1,0,-1,-1,0,1}, neiby[6]={0,1,1,0,-1,-1};
+  // neibx and neiby define ( incremental ) (i,j) for the neighbours of a 
+  // cell. There are six neighbours.
+  // cellcount --- total number of cells having nonzero ener dep
+  // numcell --- number of cells in a given supercluster
+  //ofstream ofl0("cells_loc",ios::out);
+  // initialize infocl[2][ndimx][ndimy] 
 
-void AliPMDClustering::refclust(int incr, int supmod, int idet)
+  if (fDebug == 1)
+    {
+      printf(" *** Inside crclust **  nmx = %d nmx1 = %d ndimx = %d ndimy = %d ave = %f cutoff = %f\n",
+            nmx,nmx1,ndimx,ndimy,ave,cutoff);
+    }
+  for (j=0; j < ndimx; j++){
+    for(k=0; k < ndimy; k++){
+      infocl[0][j][k] = 0; 
+      infocl[1][j][k] = 0;
+    }
+  }
+  for(i=0; i < nmx; i++){
+    infcl[0][i] = -1;
+    id1=iord[0][i]; 
+    id2=iord[1][i];
+    if(d[id1][id2] <= cutoff){infocl[0][id1][id2]=-1;}
+  }
+  // ---------------------------------------------------------------
+  // crude clustering begins. Start with cell having largest adc 
+  // count and loop over the cells in descending order of adc count
+  // ---------------------------------------------------------------
+  icl=-1;
+  cellcount=-1;
+  for(icell=0; icell <= nmx1; icell++){
+    id1=iord[0][icell]; 
+    id2=iord[1][icell]; 
+    if(infocl[0][id1][id2] == 0 ){
+      // ---------------------------------------------------------------
+      // icl -- cluster #, numcell -- # of cells in it, clust -- stores 
+      // coordinates of the cells in a cluster, infocl[0][i1][i2] is 1 for 
+      // primary and 2 for secondary cells, 
+      // infocl[1][i1][i2] stores cluster #
+      // ---------------------------------------------------------------
+      icl=icl+1; 
+      numcell=0; 
+      cellcount=cellcount+1;
+      infocl[0][id1][id2]=1; 
+      infocl[1][id1][id2]=icl;
+      infcl[0][cellcount]=icl; 
+      infcl[1][cellcount]=id1; 
+      infcl[2][cellcount]=id2;
+
+
+      clust[0][numcell]=id1;
+      clust[1][numcell]=id2;
+      for(i=1; i<5000; i++)clust[0][i]=0;
+      // ---------------------------------------------------------------
+      // check for adc count in neib. cells. If ne 0 put it in this clust
+      // ---------------------------------------------------------------
+      for(i=0; i<6; i++){
+       jd1=id1+neibx[i]; 
+       jd2=id2+neiby[i];
+       if( (jd1 >= 0 && jd1 < ndimx) && (jd2 >= 0 && jd2 < ndimy) && 
+           infocl[0][jd1][jd2] == 0){
+         numcell=numcell+1;
+         infocl[0][jd1][jd2]=2; 
+         infocl[1][jd1][jd2]=icl;
+         clust[0][numcell]=jd1;
+         clust[1][numcell]=jd2;
+         cellcount=cellcount+1;
+         infcl[0][cellcount]=icl; 
+         infcl[1][cellcount]=jd1; 
+         infcl[2][cellcount]=jd2;
+       }
+      }
+      // ---------------------------------------------------------------
+      // check adc count for neighbour's neighbours recursively and 
+      // if nonzero, add these to the cluster.
+      // ---------------------------------------------------------------
+      for(i=1;i < 5000;i++){
+       if(clust[0][i] != 0){
+         id1=clust[0][i]; 
+         id2=clust[1][i];
+         for(j=0; j<6 ; j++){
+           jd1=id1+neibx[j]; 
+           jd2=id2+neiby[j];
+           if( (jd1 >= 0 && jd1 < ndimx) && (jd2 >= 0 && jd2 < ndimy) && 
+               infocl[0][jd1][jd2] == 0 ){
+             infocl[0][jd1][jd2]=2; 
+             infocl[1][jd1][jd2]=icl;
+             numcell=numcell+1; 
+             clust[0][numcell]=jd1;
+             clust[1][numcell]=jd2;
+             cellcount=cellcount+1;
+             infcl[0][cellcount]=icl; 
+             infcl[1][cellcount]=jd1; 
+             infcl[2][cellcount]=jd2;
+           }
+         }
+       }
+      }
+    }
+  }
+  //  for(icell=0; icell<=cellcount; icell++){
+  //    ofl0 << infcl[0][icell] << " " << infcl[1][icell] << " " << 
+  //      infcl[2][icell] << endl;
+  //  }
+  return cellcount;
+}
+
+void AliPMDClustering::refclust(int incr)
 {
   int i, j, k, i1, i2, id, icl, ncl[4500], iord[4500], itest; 
   int ihld;
@@ -202,7 +324,7 @@ void AliPMDClustering::refclust(int incr, int supmod, int idet)
     if(infcl[0][i] != nsupcl){ nsupcl=nsupcl+1; }
     ncl[nsupcl]=ncl[nsupcl]+1;
   }
-  if (fMessage == 1)
+  if (fDebug == 1)
     {
       cout << " # of cells " <<incr+1 << " # of superclusters " << nsupcl+1
           << endl;
@@ -252,6 +374,7 @@ void AliPMDClustering::refclust(int incr, int supmod, int idet)
       //ofl1 << icl << " " << clusters[0][clno] << " " << clusters[1][clno]
       //   << " " << clusters[2][clno] << " " <<clusters[3][clno] <<endl; 
     }else{
+
       id=id+1; 
       iord[0]=0;
       // super-cluster of more than two cells - broken up into smaller 
@@ -265,6 +388,7 @@ void AliPMDClustering::refclust(int incr, int supmod, int idet)
       z[0]=d[i1][i2];
       iord[0]=0;
       for(j=1;j<=ncl[i];j++){
+
        id=id+1;
        i1=infcl[1][id]; 
        i2=infcl[2][id];
@@ -286,6 +410,8 @@ void AliPMDClustering::refclust(int incr, int supmod, int idet)
          }
        }
       }
+
+
       // compute the number of Gaussians and their centers ( first 
       // guess ) 
       // centers must be separated by cells having smaller ener. dep.
@@ -383,10 +509,8 @@ void AliPMDClustering::refclust(int incr, int supmod, int idet)
       }
     }
   }
-
 }
 
-
 void AliPMDClustering::gaussfit(int ncell, int nclust, double &x, double &y ,double &z, double &xc, double &yc, double &zc, double &rc)
 {
   int i, j, i1, i2, jmax, novar, idd, jj;
@@ -504,111 +628,6 @@ double AliPMDClustering::Dist(double x1, double y1, double x2, double y2)
   return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
 }
 
-  
-int AliPMDClustering::crclust(double ave, double cutoff, int nmx1, int idet)
-{
-  int i,j,k,id1,id2,icl, numcell, clust[2][5000];
-  int jd1,jd2, icell, cellcount;
-  static int neibx[6]={1,0,-1,-1,0,1}, neiby[6]={0,1,1,0,-1,-1};
-  // neibx and neiby define ( incremental ) (i,j) for the neighbours of a 
-  // cell. There are six neighbours.
-  // cellcount --- total number of cells having nonzero ener dep
-  // numcell --- number of cells in a given supercluster
-  //ofstream ofl0("cells_loc",ios::out);
-  // initialize infocl[2][ndimx][ndimy] 
-  for (j=0; j < 72; j++){
-    for(k=0; k < 72; k++){
-      infocl[0][j][k] = 0; 
-      infocl[1][j][k] = 0;
-    }
-  }
-  for(i=0; i < nmx; i++){
-    infcl[0][i] = -1;
-    id1=iord[0][i]; 
-    id2=iord[1][i];
-    if(d[id1][id2] <= cutoff){infocl[0][id1][id2]=-1;}
-  }
-  // ---------------------------------------------------------------
-  // crude clustering begins. Start with cell having largest adc 
-  // count and loop over the cells in descending order of adc count
-  // ---------------------------------------------------------------
-  icl=-1;
-  cellcount=-1;
-  for(icell=0; icell <= nmx1; icell++){
-    id1=iord[0][icell]; 
-    id2=iord[1][icell]; 
-    if(infocl[0][id1][id2] == 0 ){
-      // ---------------------------------------------------------------
-      // icl -- cluster #, numcell -- # of cells in it, clust -- stores 
-      // coordinates of the cells in a cluster, infocl[0][i1][i2] is 1 for 
-      // primary and 2 for secondary cells, 
-      // infocl[1][i1][i2] stores cluster #
-      // ---------------------------------------------------------------
-      icl=icl+1; 
-      numcell=0; 
-      cellcount=cellcount+1;
-      infocl[0][id1][id2]=1; 
-      infocl[1][id1][id2]=icl;
-      infcl[0][cellcount]=icl; 
-      infcl[1][cellcount]=id1; 
-      infcl[2][cellcount]=id2;
-      clust[0][numcell]=id1;
-      clust[1][numcell]=id2;
-      for(i=1; i<5000; i++)clust[0][i]=0;
-      // ---------------------------------------------------------------
-      // check for adc count in neib. cells. If ne 0 put it in this clust
-      // ---------------------------------------------------------------
-      for(i=0; i<6; i++){
-       jd1=id1+neibx[i]; 
-       jd2=id2+neiby[i];
-       if( (jd1 >= 0 && jd1 < 72) && (jd2 >= 0 && jd2 < 72) && 
-           infocl[0][jd1][jd2] == 0){
-         numcell=numcell+1;
-         infocl[0][jd1][jd2]=2; 
-         infocl[1][jd1][jd2]=icl;
-         clust[0][numcell]=jd1;
-         clust[1][numcell]=jd2;
-         cellcount=cellcount+1;
-         infcl[0][cellcount]=icl; 
-         infcl[1][cellcount]=jd1; 
-         infcl[2][cellcount]=jd2;
-       }
-      }
-      // ---------------------------------------------------------------
-      // check adc count for neighbour's neighbours recursively and 
-      // if nonzero, add these to the cluster.
-      // ---------------------------------------------------------------
-      for(i=1;i < 5000;i++){
-       if(clust[0][i] != 0){
-         id1=clust[0][i]; 
-         id2=clust[1][i];
-         for(j=0; j<6 ; j++){
-           jd1=id1+neibx[j]; 
-           jd2=id2+neiby[j];
-           if( (jd1 >= 0 && jd1 < 72) && (jd2 >= 0 && jd2 < 72) && 
-               infocl[0][jd1][jd2] == 0 ){
-             infocl[0][jd1][jd2]=2; 
-             infocl[1][jd1][jd2]=icl;
-             numcell=numcell+1; 
-             clust[0][numcell]=jd1;
-             clust[1][numcell]=jd2;
-             cellcount=cellcount+1;
-             infcl[0][cellcount]=icl; 
-             infcl[1][cellcount]=jd1; 
-             infcl[2][cellcount]=jd2;
-           }
-         }
-       }
-      }
-    }
-  }
-  //  for(icell=0; icell<=cellcount; icell++){
-  //    ofl0 << infcl[0][icell] << " " << infcl[1][icell] << " " << 
-  //      infcl[2][icell] << endl;
-  //  }
-  return cellcount;
-}
-
 double AliPMDClustering::ranmar()
 {
   /*                                   C==========================C*/
@@ -676,145 +695,11 @@ double AliPMDClustering::ranmar()
 
 }   
 
-void AliPMDClustering::ConvertL2G(int smnumber, double xcell, double ycell, double &xpos, double &ypos)
+void AliPMDClustering::SetEdepCut(Float_t decut)
 {
-  float xreal = -999., yreal = -999.;
-  float cell_rad=0.25, celldia_x=0.5, celldia_y=0.4330127;
-  float xcon, ycon;
-  float xoff1, xoff2, yoff=0.2886751, yoff3;
-  float xhex1 = -27.09375, yhex1 = -15.652584;
-  float xhex2 =  27.09375, yhex2 = -15.652584;
-  float xhex3 = 0.0, yhex3 = 31.285168;
-
-
-  double xcorner[27] =
-  {
-    9.435395, 45.560394,  81.685394, -8.627106,
-    27.497894, 63.622894, -26.689606,  9.435394,
-    45.560394, 9.435344,  -8.627106, -26.689556,
-    45.560345, 27.497894, 9.435445,   81.685341,
-    63.622894, 45.560444, -18.870789, -36.933388,
-    -54.995991, -36.933189, -54.995789, -73.058388,
-    -54.995586, -73.058189, -91.120789
-  };
-  
-  double ycorner[27] = 
-  {
-    -16.342583, -16.34258, -16.34258, -47.627750, -47.627750,
-    -47.627750, -78.912918, -78.912918, -78.912918, 16.342611,
-    47.627808, 78.913002, 16.342554, 47.627750, 78.912949,
-    16.342495, 47.627693, 78.912888, -0.000116, -31.285227,
-    -62.570335, 31.285110, 0.000000, -31.285110, 62.570335,
-    31.285227, 0.000116
-  };
-  if (smnumber<=8)
-    {
-      xcon  = xcorner[smnumber]+xhex1;
-      ycon  = ycorner[smnumber]+yhex1;
-      xoff1 = celldia_x+(ycell-1)*cell_rad;
-      xreal = xcon+xoff1+celldia_x*(xcell-1);
-      yreal = ycon+yoff+celldia_y*(ycell-1);
-    }
-
-  if (smnumber>8 && smnumber<=17)
-    {
-      xcon  = xcorner[smnumber]+xhex2;
-      ycon  = ycorner[smnumber]+yhex2;
-      xoff2 = celldia_x+(xcell-1)*cell_rad;
-      xreal = xcon-(xoff2+celldia_x*(ycell-1));
-      yreal = ycon+yoff+celldia_y*(xcell-1);
-    }          
-    
-  if (smnumber>17)
-    {
-      xcon  = xcorner[smnumber]+xhex3;
-      ycon  = ycorner[smnumber]+yhex3;
-      yoff3 = celldia_x * 0.8660254  + cell_rad * 0.57735027;
-      xreal = xcon+(ycell-xcell)*cell_rad;
-      yreal = ycon-(yoff3+(xcell+ycell-2)*celldia_y);
-    }
-
-  xpos = xreal;
-  ypos = yreal;
-}
-
-void AliPMDClustering::cell_pos(Int_t isup, Int_t j, int k, Float_t &xp, Float_t &yp){
-
-  /*
-    This converts PMD cluster or CELL coordinates
-    to Global coordinates.
-    Written by Prof. S.C. Phatak
-  */
-
-  Int_t i;
-  Float_t celldia = 0.5;
-  const Float_t pi = 3.14159;
-  const double sqrth=0.8660254;  // sqrth = sqrt(3.)/2.
-  /*
-    isup --> supermodule no ( 0 - 26 )
-    idet --> detector ( pmd or cpv : not required now )
-    j --> xpad ( goes from 1 to 72 )
-    k --> ypad ( goes from 1 to 72 )
-    xp --> global x coordinate
-    yp --> global y coordinate
-    
-    (xp0,yp0) corner positions of all supermodules in global
-    coordinate system. That is the origin
-    of the local ( supermodule ) coordinate system.
-*/ 
-  
-  Float_t xp0[27] = 
-  {
-    -17.9084, 18.2166, 54.3416, -35.9709, 0.154144, 
-    36.2791, -54.0334, -17.9084, 18.2166, 36.7791, 
-    18.7166, 0.654194, 72.9041, 54.8416, 36.7792, 
-    109.029, 90.9666, 72.9042, -18.8708, -36.9334, 
-    -54.996, -36.9332, -54.9958, -73.0584, -54.9956, 
-    -73.0582, -91.1208
-  };
-
-  Float_t yp0[27] = 
-  {
-    -32.1395, -32.1395, -32.1395, -63.4247, -63.4247, 
-    -63.4247, -94.7098, -94.7098, -94.7098, 0.545689, 
-    31.8309, 63.1161, 0.545632, 31.8308, 63.116, 
-    0.545573, 31.8308, 63.116, 31.5737, 0.288616, 
-    -30.9965, 62.859, 31.5738, 0.288733, 94.1442, 
-    62.8591, 31.574
-  };
-
-  /* 
-     angles of rotation for three sets of supermodules
-     The angle is same for first nine, next nine and last nine 
-     supermodules 
-  */
-  
-  Float_t th[3] = {0., -2.*pi/3., 2.*pi/3.};
-  Float_t xr, yr, xinit, yinit, cs, sn;
-  
-  /* 
-     xinit and yinit are coordinates of the cell in local coordinate system
-  */
-  
-  xinit = (j)*celldia+(k)/2.*celldia;
-  yinit = sqrth*(k)/2.;
-  i=isup/9;
-  cs=cos(th[i]);
-  sn=sin(th[i]);
-  //
-  // rotate first
-  //
-  xr=cs*xinit+sn*yinit;
-  yr=-sn*xinit+cs*yinit;
-  //
-  // then translate
-  //
-  xp=xr+xp0[isup];
-  yp=yr+yp0[isup];
-
+  fCutoff = decut;
 }
-void AliPMDClustering::SetMessage(Int_t imessage)
+void AliPMDClustering::SetDebug(Int_t idebug)
 {
-  fMessage = imessage;
+  fDebug = idebug;
 }