+ tr1pad[count] = digtr1[k];
+ tr2pad[count] = digtr2[k];
+ tr3pad[count] = digtr3[k];
+ tr4pad[count] = digtr4[k];
+
+ count++;
+ } // end for k
+ ndxmin = xpad[TMath::LocMin(nd,xpad)];
+ ndxmax = xpad[TMath::LocMax(nd,xpad)];
+ ndzmin = zpad[TMath::LocMin(nd,zpad)];
+ ndzmax = zpad[TMath::LocMax(nd,zpad)];
+ ndx = ndxmax - ndxmin+1;
+ ndz = ndzmax - ndzmin+1;
+
+ // calculate x and z coordinates of the center of the cluster
+ GetSeg()->GetPadCxz(digx[min],digz[min]-1,xdum, zdum);
+
+ if (ndx == 1) {
+ xcenter[i] = xdum;
+ }else{
+ xcenter[i] = 0.;
+ for (k=0;k<nd;k++) {
+ GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
+ xcenter[i] += (xdum / nd);
+ } // end for k
+ } // end if ndx
+
+ if (ndz == 1) {
+ zcenter[i] = zdum;
+ } else {
+ zcenter[i] = 0.;
+ for (k=0;k<nd;k++) {
+ GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
+ zcenter[i] += (zdum / nd);
+ } // end for k
+ } // end if ndz
+
+ // error on points in x and z directions
+
+ if (ndx == 1) {
+ errxcenter[i] = deltax / TMath::Sqrt(12.);
+ } else {
+ errxcenter[i] = 0.;
+ for (k=0;k<nd;k++){
+ GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
+ errxcenter[i] += ((xdum-xcenter[i])*(xdum-xcenter[i]))/
+ (nd*(nd-1));
+ } // end for k
+ errxcenter[i] = TMath::Sqrt(errxcenter[i]);
+ } // end if ndx
+ if (ndz == 1) {
+ deltaz = GetSeg()->Dpz(digz[min]);
+ errzcenter[i] = deltaz / TMath::Sqrt(12.);
+ } else {
+ errzcenter[i] = 0.;
+ for (k=0;k<nd;k++){
+ GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
+ errzcenter[i] += ((zdum-zcenter[i])*(zdum-zcenter[i]))/
+ (nd*(nd-1));
+ } // end for k
+ errzcenter[i] = TMath::Sqrt(errzcenter[i]);
+ } // end if ndz
+ // take three track numbers for the cluster
+ // choose the track numbers of the digit with higher signal
+ kmax = 0;
+ sigmax = 0;
+ for (k=0;k<nd;k++){
+ if(tr4pad[k] > sigmax){
+ sigmax = tr4pad[k];
+ kmax = k;
+ } // end if tr4pad[k]
+ } // end for k
+ if(sigmax != 0) {
+ tr1clus[i]= tr1pad[kmax];
+ tr2clus[i]= tr2pad[kmax];
+ tr3clus[i]= tr3pad[kmax];
+ } else {
+ tr1clus[i]= -2;
+ tr2clus[i]= -2;
+ tr3clus[i]= -2;
+ } // end if sigmax
+ } else {
+ // cluster with single digit
+ ndig= 1.;
+ ndx = 1;
+ ndz = 1;
+ GetSeg()->GetPadCxz(digx[min],digz[min]-1,xdum,zdum);
+ xcenter[i] = xdum;
+ zcenter[i] = zdum;
+ tr1clus[i]=digtr1[min];
+ tr2clus[i]=digtr2[min];
+ tr3clus[i]=digtr3[min];
+ deltaz = GetSeg()->Dpz(digz[min]);
+ errxcenter[i] = deltax / TMath::Sqrt(12.);
+ errzcenter[i] = deltaz / TMath::Sqrt(12.);
+ } // end if iclus[i]