#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++)
{
fCoord[0][i][j] = i+j/2.;
fCoord[1][i][j] = fgkSqroot3by2*j;
+ fEdepCell[i][j] = 0;
}
}
}
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];
// 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
//
}
}
// 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++)
{
// 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;
for(i=0; i<4500; i++){ncl[i]=-1;}
for(i=0; i<incr; i++){
if(fInfcl[0][i] != nsupcl){ nsupcl=nsupcl+1; }
+ if (nsupcl > 4500) {
+ 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++){
// one cell super-clusters --> single cluster
// cluster center at the centyer of the cell
// cluster radius = half cell dimension
+ if (fClno >= 5000) {
+ AliWarning("RefClust: Too many clusters! more than 5000");
+ return;
+ }
fClno = fClno + 1;
i1 = fInfcl[1][id];
i2 = fInfcl[2][id];
// cluster radius == half cell dimension
id = id + 1;
icl = icl+1;
+ if (fClno >= 5000) {
+ AliWarning("RefClust: Too many clusters! more than 5000");
+ return;
+ }
fClno = fClno+1;
i1 = fInfcl[1][id];
i2 = fInfcl[2][id];
}
}
for(j=0; j<=ig; j++){
+ if (fClno >= 5000) {
+ AliWarning("RefClust: Too many clusters! more than 5000");
+ return;
+ }
fClno = fClno + 1;
fClusters[0][fClno] = xc[j];
fClusters[1][fClno] = yc[j];
{
// 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];
}
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);
sum=sum1;
}
}
- }
+// }
for(j=0; j<=nclust; j++){
*(&xc+j)=xxc[j];
*(&yc+j)=yyc[j];
cm = 16777213./16777216.;
}
else{
- cout << " wrong initialization " << endl;
+ AliWarning("Wrong initialization");
}
}
else{
fCutoff = decut;
}
// ------------------------------------------------------------------------ //
-void AliPMDClustering::SetDebug(Int_t idebug)
-{
- fDebug = idebug;
-}