+void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
+{
+ // Converts RAW data to recpoints after running clustering
+ // algorithm on CPV and PREshower plane
+ //
+
+ Float_t clusdata[6];
+ TObjArray pmdddlcont;
+ TObjArray *pmdcont = new TObjArray();
+
+ AliPMDClustering *pmdclust = new AliPMDClusteringV1();
+
+ pmdclust->SetEdepCut(fEcut);
+
+ fRunLoader->GetEvent(ievt);
+
+ ResetRecpoint();
+
+ fTreeR = fPMDLoader->TreeR();
+ if (fTreeR == 0x0)
+ {
+ fPMDLoader->MakeTree("R");
+ fTreeR = fPMDLoader->TreeR();
+ }
+ Int_t bufsize = 16000;
+ TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
+ TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
+
+ const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
+ const Int_t kRow = 48;
+ const Int_t kCol = 96;
+
+ Int_t idet = 0;
+ Int_t iSMN = 0;
+
+ for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
+ {
+ if (indexDDL < 4)
+ {
+ iSMN = 6;
+ }
+ else if (indexDDL >= 4)
+ {
+ iSMN = 12;
+ }
+ Int_t ***precpvADC;
+ precpvADC = new int **[iSMN];
+ for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
+ for (Int_t i=0; i<iSMN;i++)
+ {
+ for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
+ }
+ for (Int_t i = 0; i < iSMN; i++)
+ {
+ for (Int_t j = 0; j < kRow; j++)
+ {
+ for (Int_t k = 0; k < kCol; k++)
+ {
+ precpvADC[i][j][k] = 0;
+ }
+ }
+ }
+ ResetCellADC();
+ rawReader->Reset();
+ rawReader->Select("PMD", indexDDL, indexDDL);
+
+ AliPMDRawStream pmdinput(rawReader);
+ pmdinput.DdlData(indexDDL,&pmdddlcont);
+
+ Int_t indexsmn = 0;
+ Int_t ientries = pmdddlcont.GetEntries();
+ for (Int_t ient = 0; ient < ientries; ient++)
+ {
+ AliPMDddldata *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();
+
+ Float_t sig1 = (Float_t) sig;
+ // CALIBRATION
+ Float_t gain = fCalibData->GetGainFact(det,smn,row,col);
+
+ //printf("sig = %d gain = %f\n",sig,gain);
+ sig = (Int_t) (sig1*gain);
+
+
+ if (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 < 12)
+ {
+ indexsmn = smn - 6;
+ }
+ else if (smn >= 12 && smn < 18)
+ {
+ indexsmn = smn - 6;
+ }
+ }
+ precpvADC[indexsmn][row][col] = sig;
+
+ }
+
+ pmdddlcont.Clear();
+
+ Int_t ismn = 0;
+ for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++)
+ {
+ ResetCellADC();
+ for (Int_t irow = 0; irow < kRow; irow++)
+ {
+ for (Int_t icol = 0; icol < kCol; icol++)
+ {
+ fCellADC[irow][icol] =
+ (Double_t) precpvADC[indexsmn][irow][icol];
+ } // row
+ } // col
+
+
+ if (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)
+ {
+ if (indexsmn < 6)
+ {
+ ismn = indexsmn + 6;
+ }
+ else if (indexsmn >= 6 && indexsmn < 12)
+ {
+ ismn = indexsmn + 6;
+ }
+ idet = 1;
+ }
+
+ pmdclust->DoClust(idet,ismn,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++)
+ {
+ AliPMDcluster *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];
+ for(Int_t ihit = 0; ihit < ncell; ihit++)
+ {
+ Int_t celldataX = pmdcl->GetClusCellX(ihit);
+ Int_t celldataY = pmdcl->GetClusCellY(ihit);
+ AddRecHit(celldataX, celldataY);
+ }
+ branch2->Fill();
+ ResetRechit();
+
+ }
+ pmdcont->Clear();
+
+ 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();
+
+ fPMDLoader = fRunLoader->GetLoader("PMDLoader");
+ fPMDLoader->WriteRecPoints("OVERWRITE");
+
+ // delete the pointers
+ delete pmdclust;
+ delete pmdcont;
+
+}
+// ------------------------------------------------------------------------- //
+void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
+{
+ fEcut = ecut;
+}
+// ------------------------------------------------------------------------- //
+void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)