+ Int_t indexsmn = 0;
+ Int_t ientries = pmdddlcont.GetEntries();
+ for (Int_t ient = 0; ient < ientries; ient++)
+ {
+ pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
+
+ Int_t det = pmdddl->GetDetector();
+ Int_t smn = pmdddl->GetSMN();
+ //Int_t mcm = pmdddl->GetMCM();
+ //Int_t chno = pmdddl->GetChannel();
+ Int_t row = pmdddl->GetRow();
+ Int_t col = pmdddl->GetColumn();
+ Int_t sig = pmdddl->GetSignal();
+
+
+ if(det < 0 || det > 1)
+ {
+ AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
+ continue;
+ }
+ if(smn < 0 || smn > 23)
+ {
+ AliError(Form("*MODULE NUMBER WRONG %d *",smn));
+ continue;
+ }
+ if(row < 0 || row > 47 || col < 0 || col > 95)
+ {
+ AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
+ row, col));
+
+ continue;
+ }
+
+ // Pedestal Subtraction
+ Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
+ Int_t pedrms1 = (Int_t) pedmeanrms%100;
+ Float_t pedrms = (Float_t)pedrms1/10.;
+ Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
+
+ //printf("%f %f\n",pedmean, pedrms);
+
+ // Float_t sig1 = (Float_t) sig;
+ Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
+
+ // Hot cell - set the cell adc = 0
+ Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
+ if (hotflag == 1.) sig1 = 0;
+
+ // CALIBRATION
+ Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
+ //printf("sig = %d gain = %f\n",sig,gain);
+ sig = (Int_t) (sig1*gain);
+
+ if (indexDDL == 0)
+ {
+ if (det != 0)
+ AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
+ indexDDL, det));
+ if (iSMN == 6)
+ {
+ indexsmn = smn;
+ }
+ else if (iSMN == 12)
+ {
+ if (smn < 6)
+ indexsmn = smn;
+ else if (smn >= 18 && smn < 24)
+ indexsmn = smn-12;
+ }
+ }
+ else if (indexDDL >= 1 && indexDDL < 4)
+ {
+ if (det != 0)
+ AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
+ indexDDL, det));
+ indexsmn = smn - indexDDL * 6;
+ }
+ else if (indexDDL == 4)
+ {
+ if (det != 1)
+ AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
+ indexDDL, det));
+ if (smn < 6)
+ {
+ indexsmn = smn;
+ }
+ else if (smn >= 18 && smn < 24)
+ {
+ indexsmn = smn - 12;
+ }
+ }
+ else if (indexDDL == 5)
+ {
+ if (det != 1)
+ AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
+ indexDDL, det));
+ if (smn >= 6 && smn < 18)
+ {
+ indexsmn = smn - 6;
+ }
+ }
+
+ precpvADC[indexsmn][row][col] = sig;
+ }
+
+ pmdddlcont.Delete();
+
+ Int_t totAdcMod = 0;
+
+ Int_t ismn = 0;
+ for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
+ {
+ ResetCellADC();
+ totAdcMod = 0;
+ for (Int_t irow = 0; irow < kRow; irow++)
+ {
+ for (Int_t icol = 0; icol < kCol; icol++)
+ {
+ fCellTrack[irow][icol] = -1;
+ fCellPid[irow][icol] = -1;
+
+ fCellADC[irow][icol] =
+ (Double_t) precpvADC[indexsmn][irow][icol];
+ totAdcMod += precpvADC[indexsmn][irow][icol];
+ } // row
+ } // col
+
+ if (indexDDL == 0)
+ {
+ if (iSMN == 6)
+ {
+ ismn = indexsmn;
+ }
+ else if (iSMN == 12)
+ {
+
+ if (indexsmn < 6)
+ ismn = indexsmn;
+ else if (indexsmn >= 6 && indexsmn < 12)
+ ismn = indexsmn + 12;
+ }
+ idet = 0;
+ }
+ else if (indexDDL >= 1 && indexDDL < 4)
+ {
+ ismn = indexsmn + indexDDL * 6;
+ idet = 0;
+ }
+ else if (indexDDL == 4)
+ {
+ if (indexsmn < 6)
+ {
+ ismn = indexsmn;
+ }
+ else if (indexsmn >= 6 && indexsmn < 12)
+ {
+ ismn = indexsmn + 12;
+ }
+ idet = 1;
+ }
+ else if (indexDDL == 5)
+ {
+ ismn = indexsmn + 6;
+ idet = 1;
+ }
+
+ if (totAdcMod <= 0) continue;
+
+ Int_t imod = idet*24 + ismn;
+
+ // Int_t cluspar = fRecoParam->GetPbPbParam()->GetClusteringParam();
+ AliPMDRecoParam * par = fRecoParam->GetPPParam();
+ Int_t cluspar = par->GetClusteringParam();
+ delete par;
+ // Int_t cluspar = fRecoParam->GetCosmicParam()->GetClusteringParam();
+
+ //_______________________________________________________//
+ //Added to switch Refine and crude Clustering - satya//
+ // temporary solution - will be sorted out later
+ /* cluspar = 1;
+ static AliPMDRecoParam *reconp = NULL;
+ reconp = (AliPMDRecoParam*)AliPMDReconstructor::GetRecoParam();
+ if(!reconp) {
+ cluspar = 1;
+ }
+ else {
+ if( reconp->GetClusteringParam() == 1)
+ cluspar = 1;
+ if( reconp->GetClusteringParam() == 2)
+ cluspar = 2;
+ }*/
+
+
+ cluspar = gRecoMode; // permanent solution
+
+ //_______________________________________________________//
+
+ pmdclust->SetClusteringParam(cluspar);
+ Float_t encut = fNoiseCut->GetNoiseCut(imod);
+
+ pmdclust->SetEdepCut(encut);
+ pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
+
+ Int_t nentries1 = pmdcont->GetEntries();
+
+ AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
+
+ for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
+ {
+ pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
+ idet = pmdcl->GetDetector();
+ ismn = pmdcl->GetSMN();
+ clusdata[0] = pmdcl->GetClusX();
+ clusdata[1] = pmdcl->GetClusY();
+ clusdata[2] = pmdcl->GetClusADC();
+ clusdata[3] = pmdcl->GetClusCells();
+ clusdata[4] = pmdcl->GetClusSigmaX();
+ clusdata[5] = pmdcl->GetClusSigmaY();
+
+ AddRecPoint(idet,ismn,clusdata);
+
+ Int_t ncell = (Int_t) clusdata[3];
+ if (ncell > 19) ncell = 19;
+ for(Int_t ihit = 0; ihit < ncell; ihit++)
+ {
+ Int_t celldataX = pmdcl->GetClusCellX(ihit);
+ Int_t celldataY = pmdcl->GetClusCellY(ihit);
+ Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
+ Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
+ Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
+ AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
+ }
+ branch2->Fill();
+ ResetRechit();
+
+ }
+ pmdcont->Delete();
+
+ branch1->Fill();
+ ResetRecpoint();
+
+
+ } // smn
+
+ for (Int_t i=0; i<iSMN; i++)
+ {
+ for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
+ }
+ for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
+ delete [] precpvADC;
+
+ } // DDL Loop
+
+
+ ResetCellADC();
+
+ // delete the pointers
+ delete pmdclust;
+ delete pmdcont;
+}
+// ------------------------------------------------------------------------- //
+void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)