1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //-----------------------------------------------------//
18 // Date : August 05 2003 //
19 // This reads the file PMD.digits.root(TreeD), //
20 // calls the Clustering algorithm and stores the //
21 // clustering output in PMD.RecPoints.root(TreeR) //
23 //-----------------------------------------------------//
25 #include <Riostream.h>
27 #include <TObjArray.h>
28 #include <TClonesArray.h>
32 #include "AliRunLoader.h"
33 #include "AliLoader.h"
34 #include "AliRawReader.h"
36 #include "AliPMDdigit.h"
37 #include "AliPMDClusterFinder.h"
38 #include "AliPMDClustering.h"
39 #include "AliPMDClusteringV1.h"
40 #include "AliPMDcluster.h"
41 #include "AliPMDrecpoint1.h"
42 #include "AliPMDrechit.h"
43 #include "AliPMDisocell.h"
44 #include "AliPMDRawStream.h"
45 #include "AliPMDCalibData.h"
46 #include "AliPMDPedestal.h"
47 #include "AliPMDddldata.h"
48 #include "AliPMDHotData.h"
49 #include "AliPMDRecoParam.h"
50 #include "AliPMDReconstructor.h"
53 #include "AliCDBManager.h"
54 #include "AliCDBEntry.h"
58 ClassImp(AliPMDClusterFinder)
60 AliPMDClusterFinder::AliPMDClusterFinder():
63 fCalibGain(GetCalibGain()),
64 fCalibPed(GetCalibPed()),
65 fCalibHot(GetCalibHot()),
69 fDigits(new TClonesArray("AliPMDdigit", 1000)),
70 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
71 fRechits(new TClonesArray("AliPMDrechit", 1000)),
81 // ------------------------------------------------------------------------- //
82 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
83 fRunLoader(runLoader),
84 fPMDLoader(runLoader->GetLoader("PMDLoader")),
85 fCalibGain(GetCalibGain()),
86 fCalibPed(GetCalibPed()),
87 fCalibHot(GetCalibHot()),
91 fDigits(new TClonesArray("AliPMDdigit", 1000)),
92 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
93 fRechits(new TClonesArray("AliPMDrechit", 1000)),
103 // ------------------------------------------------------------------------- //
104 AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder):
108 fCalibGain(GetCalibGain()),
109 fCalibPed(GetCalibPed()),
110 fCalibHot(GetCalibHot()),
123 AliError("Copy constructor not allowed");
125 // ------------------------------------------------------------------------- //
126 AliPMDClusterFinder &AliPMDClusterFinder::operator=(const AliPMDClusterFinder & /*finder*/)
129 AliError("Assignment Operator not allowed");
132 // ------------------------------------------------------------------------- //
133 AliPMDClusterFinder::~AliPMDClusterFinder()
150 // ------------------------------------------------------------------------- //
152 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
154 // Converts digits to recpoints after running clustering
155 // algorithm on CPV plane and PREshower plane
158 Int_t det = 0,smn = 0;
165 AliPMDisocell *pmdiso = 0x0;
167 TObjArray *pmdcont = new TObjArray();
168 TObjArray *pmdisocell = new TObjArray();
170 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
172 // fetch the recoparam object from database
173 fRecoParam = AliPMDReconstructor::GetRecoParam();
175 if(fRecoParam == 0x0)
177 AliFatal("No Reco Param found for PMD!!!");
181 fRunLoader->GetEvent(ievt);
184 fTreeD = fPMDLoader->TreeD();
187 AliFatal("AliPMDClusterFinder: Can not get TreeD");
190 AliPMDdigit *pmddigit;
191 TBranch *branch = fTreeD->GetBranch("PMDDigit");
192 branch->SetAddress(&fDigits);
196 fTreeR = fPMDLoader->TreeR();
199 fPMDLoader->MakeTree("R");
200 fTreeR = fPMDLoader->TreeR();
203 Int_t bufsize = 16000;
204 TBranch * branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
205 TBranch * branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
207 Int_t nmodules = (Int_t) fTreeD->GetEntries();
209 for (Int_t imodule = 0; imodule < nmodules; imodule++)
212 fTreeD->GetEntry(imodule);
213 Int_t nentries = fDigits->GetLast();
214 for (Int_t ient = 0; ient < nentries+1; ient++)
216 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
218 det = pmddigit->GetDetector();
219 smn = pmddigit->GetSMNumber();
220 xpos = pmddigit->GetRow();
221 ypos = pmddigit->GetColumn();
222 adc = pmddigit->GetADC();
223 if(xpos < 0 || xpos > 48 || ypos < 0 || ypos > 96)
225 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
230 // Hot cell - set the cell adc = 0
231 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
232 if (hotflag == 1) adc = 0;
234 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
235 // printf("adc = %d gain = %f\n",adc,gain);
239 //Int_t trno = pmddigit->GetTrackNumber();
240 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
241 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
242 fCellADC[xpos][ypos] = (Double_t) adc;
248 // Set the minimum noise cut per module before clustering
250 Int_t imod = idet*24 + ismn;
251 fEcut = fRecoParam->GetNoiseCut(imod); // default
252 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
253 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
254 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
256 pmdclust->SetEdepCut(fEcut);
259 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
262 Int_t nentries1 = pmdcont->GetEntries();
264 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
266 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
268 AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
269 idet = pmdcl->GetDetector();
270 ismn = pmdcl->GetSMN();
271 clusdata[0] = pmdcl->GetClusX();
272 clusdata[1] = pmdcl->GetClusY();
273 clusdata[2] = pmdcl->GetClusADC();
274 clusdata[3] = pmdcl->GetClusCells();
275 clusdata[4] = pmdcl->GetClusSigmaX();
276 clusdata[5] = pmdcl->GetClusSigmaY();
278 AddRecPoint(idet,ismn,clusdata);
280 Int_t ncell = (Int_t) clusdata[3];
281 for(Int_t ihit = 0; ihit < ncell; ihit++)
283 Int_t celldataX = pmdcl->GetClusCellX(ihit);
284 Int_t celldataY = pmdcl->GetClusCellY(ihit);
285 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
286 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
287 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
288 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
295 // Added single isolated cell for offline gain calibration
296 nentries1 = pmdisocell->GetEntries();
297 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
299 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
301 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
302 idet = pmdiso->GetDetector();
303 ismn = pmdiso->GetSmn();
304 clusdata[0] = (Float_t) pmdiso->GetRow();
305 clusdata[1] = (Float_t) pmdiso->GetCol();
306 clusdata[2] = pmdiso->GetADC();
311 AddRecPoint(idet,ismn,clusdata);
313 pmdisocell->Delete();
321 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
322 fPMDLoader->WriteRecPoints("OVERWRITE");
324 // delete the pointers
330 // ------------------------------------------------------------------------- //
332 void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
335 // Converts digits to recpoints after running clustering
336 // algorithm on CPV plane and PREshower plane
338 // This algorithm is called during the reconstruction from digits
340 Int_t det = 0,smn = 0;
347 AliPMDcluster *pmdcl = 0x0;
348 AliPMDisocell *pmdiso = 0x0;
350 TObjArray *pmdcont = new TObjArray();
351 TObjArray *pmdisocell = new TObjArray();
352 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
354 // Fetch the reco param object
356 fRecoParam = AliPMDReconstructor::GetRecoParam();
357 if(fRecoParam == 0x0)
359 AliFatal("No Reco Param found for PMD!!!");
363 AliPMDdigit *pmddigit;
364 TBranch *branch = digitsTree->GetBranch("PMDDigit");
365 branch->SetAddress(&fDigits);
369 Int_t bufsize = 16000;
370 TBranch * branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
371 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
373 Int_t nmodules = (Int_t) digitsTree->GetEntries();
375 for (Int_t imodule = 0; imodule < nmodules; imodule++)
380 digitsTree->GetEntry(imodule);
381 Int_t nentries = fDigits->GetLast();
382 for (Int_t ient = 0; ient < nentries+1; ient++)
384 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
386 det = pmddigit->GetDetector();
387 smn = pmddigit->GetSMNumber();
388 xpos = pmddigit->GetRow();
389 ypos = pmddigit->GetColumn();
390 adc = pmddigit->GetADC();
391 if(xpos < 0 || xpos > 48 || ypos < 0 || ypos > 96)
393 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
398 // Pedestal Subtraction
399 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
400 Int_t pedrms1 = (Int_t) pedmeanrms%100;
401 Float_t pedrms = (Float_t)pedrms1/10.;
402 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
403 //printf("%f %f\n",pedmean, pedrms);
405 Float_t adc1 = adc - (pedmean + 3.0*pedrms);
407 // Hot cell - set the cell adc = 0
408 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
409 if (hotflag == 1) adc1 = 0;
412 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
413 // printf("adc = %d gain = %f\n",adc,gain);
417 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
418 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
419 fCellADC[xpos][ypos] = (Double_t) adc;
421 totADCMod += (Int_t) adc;
428 if (totADCMod <= 0) continue;
430 // Set the minimum noise cut per module before clustering
432 Int_t imod = idet*24 + ismn;
433 fEcut = fRecoParam->GetNoiseCut(imod); // default
434 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
435 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
436 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
439 pmdclust->SetEdepCut(fEcut);
441 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
444 Int_t nentries1 = pmdcont->GetEntries();
446 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
448 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
450 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
451 idet = pmdcl->GetDetector();
452 ismn = pmdcl->GetSMN();
453 clusdata[0] = pmdcl->GetClusX();
454 clusdata[1] = pmdcl->GetClusY();
455 clusdata[2] = pmdcl->GetClusADC();
456 clusdata[3] = pmdcl->GetClusCells();
457 clusdata[4] = pmdcl->GetClusSigmaX();
458 clusdata[5] = pmdcl->GetClusSigmaY();
460 AddRecPoint(idet,ismn,clusdata);
462 Int_t ncell = (Int_t) clusdata[3];
463 for(Int_t ihit = 0; ihit < ncell; ihit++)
465 Int_t celldataX = pmdcl->GetClusCellX(ihit);
466 Int_t celldataY = pmdcl->GetClusCellY(ihit);
467 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
468 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
469 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
470 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
477 // Added single isolated cell for offline gain calibration
478 nentries1 = pmdisocell->GetEntries();
479 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
481 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
483 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
484 idet = pmdiso->GetDetector();
485 ismn = pmdiso->GetSmn();
486 clusdata[0] = (Float_t) pmdiso->GetRow();
487 clusdata[1] = (Float_t) pmdiso->GetCol();
488 clusdata[2] = pmdiso->GetADC();
493 AddRecPoint(idet,ismn,clusdata);
495 pmdisocell->Delete();
505 // delete the pointers
510 // ------------------------------------------------------------------------- //
512 void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
515 // Converts RAW data to recpoints after running clustering
516 // algorithm on CPV and PREshower plane
518 // This method is called at the time of reconstruction from RAW data
521 AliPMDddldata *pmdddl = 0x0;
522 AliPMDcluster *pmdcl = 0x0;
523 AliPMDisocell *pmdiso = 0x0;
527 TObjArray pmdddlcont;
529 TObjArray *pmdcont = new TObjArray();
530 TObjArray *pmdisocell = new TObjArray();
532 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
534 // open the ddl file info to know the module
535 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
536 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
539 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
540 if(!infileddl) AliError("Could not read the ddl info file");
547 for(Int_t jddl = 0; jddl < 6; jddl++)
549 if (infileddl.eof()) break;
550 infileddl >> ddlno >> modulePerDDL;
551 moduleddl[jddl] = modulePerDDL;
553 if (modulePerDDL == 0) continue;
554 for (Int_t im = 0; im < modulePerDDL; im++)
562 // Set the minimum noise cut per module before clustering
564 fRecoParam = AliPMDReconstructor::GetRecoParam();
566 if(fRecoParam == 0x0)
568 AliFatal("No Reco Param found for PMD!!!");
573 Int_t bufsize = 16000;
574 TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
576 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
578 const Int_t kRow = 48;
579 const Int_t kCol = 96;
585 AliPMDRawStream pmdinput(rawReader);
587 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
589 iSMN = moduleddl[indexDDL];
592 precpvADC = new int **[iSMN];
593 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
594 for (Int_t i=0; i<iSMN;i++)
596 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
598 for (Int_t i = 0; i < iSMN; i++)
600 for (Int_t j = 0; j < kRow; j++)
602 for (Int_t k = 0; k < kCol; k++)
604 precpvADC[i][j][k] = 0;
611 Int_t ientries = pmdddlcont.GetEntries();
612 for (Int_t ient = 0; ient < ientries; ient++)
614 pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
616 Int_t det = pmdddl->GetDetector();
617 Int_t smn = pmdddl->GetSMN();
618 //Int_t mcm = pmdddl->GetMCM();
619 //Int_t chno = pmdddl->GetChannel();
620 Int_t row = pmdddl->GetRow();
621 Int_t col = pmdddl->GetColumn();
622 Int_t sig = pmdddl->GetSignal();
626 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
629 if(row < 0 || row > 48 || col < 0 || col > 96)
631 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
637 // Pedestal Subtraction
638 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
639 Int_t pedrms1 = (Int_t) pedmeanrms%100;
640 Float_t pedrms = (Float_t)pedrms1/10.;
641 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
643 //printf("%f %f\n",pedmean, pedrms);
645 // Float_t sig1 = (Float_t) sig;
646 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
648 // Hot cell - set the cell adc = 0
649 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
650 if (hotflag == 1) sig1 = 0;
653 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
654 //printf("sig = %d gain = %f\n",sig,gain);
655 sig = (Int_t) (sig1*gain);
660 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
670 else if (smn >= 18 && smn < 24)
674 else if (indexDDL >= 1 && indexDDL < 4)
677 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
679 indexsmn = smn - indexDDL * 6;
681 else if (indexDDL == 4)
684 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
690 else if (smn >= 18 && smn < 24)
695 else if (indexDDL == 5)
698 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
700 if (smn >= 6 && smn < 18)
706 precpvADC[indexsmn][row][col] = sig;
714 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
718 for (Int_t irow = 0; irow < kRow; irow++)
720 for (Int_t icol = 0; icol < kCol; icol++)
722 fCellTrack[irow][icol] = -1;
723 fCellPid[irow][icol] = -1;
725 fCellADC[irow][icol] =
726 (Double_t) precpvADC[indexsmn][irow][icol];
727 totAdcMod += precpvADC[indexsmn][irow][icol];
742 else if (indexsmn >= 6 && indexsmn < 12)
743 ismn = indexsmn + 12;
747 else if (indexDDL >= 1 && indexDDL < 4)
749 ismn = indexsmn + indexDDL * 6;
752 else if (indexDDL == 4)
758 else if (indexsmn >= 6 && indexsmn < 12)
760 ismn = indexsmn + 12;
764 else if (indexDDL == 5)
770 if (totAdcMod <= 0) continue;
772 Int_t imod = idet*24 + ismn;
774 fEcut = fRecoParam->GetNoiseCut(imod); // default
775 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
776 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
777 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
780 pmdclust->SetEdepCut(fEcut);
782 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
785 Int_t nentries1 = pmdcont->GetEntries();
787 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
789 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
791 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
792 idet = pmdcl->GetDetector();
793 ismn = pmdcl->GetSMN();
794 clusdata[0] = pmdcl->GetClusX();
795 clusdata[1] = pmdcl->GetClusY();
796 clusdata[2] = pmdcl->GetClusADC();
797 clusdata[3] = pmdcl->GetClusCells();
798 clusdata[4] = pmdcl->GetClusSigmaX();
799 clusdata[5] = pmdcl->GetClusSigmaY();
801 AddRecPoint(idet,ismn,clusdata);
803 Int_t ncell = (Int_t) clusdata[3];
804 for(Int_t ihit = 0; ihit < ncell; ihit++)
806 Int_t celldataX = pmdcl->GetClusCellX(ihit);
807 Int_t celldataY = pmdcl->GetClusCellY(ihit);
808 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
809 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
810 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
811 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
820 // Added single isolated cell for offline gain calibration
821 nentries1 = pmdisocell->GetEntries();
822 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
824 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
826 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
827 idet = pmdiso->GetDetector();
828 ismn = pmdiso->GetSmn();
829 clusdata[0] = (Float_t) pmdiso->GetRow();
830 clusdata[1] = (Float_t) pmdiso->GetCol();
831 clusdata[2] = pmdiso->GetADC();
836 AddRecPoint(idet,ismn,clusdata);
838 pmdisocell->Delete();
846 for (Int_t i=0; i<iSMN; i++)
848 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
850 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
858 // delete the pointers
864 // ------------------------------------------------------------------------- //
866 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
868 // Converts RAW data to recpoints after running clustering
869 // algorithm on CPV and PREshower plane
874 TObjArray pmdddlcont;
876 AliPMDcluster *pmdcl = 0x0;
877 AliPMDisocell *pmdiso = 0x0;
880 TObjArray *pmdcont = new TObjArray();
881 TObjArray *pmdisocell = new TObjArray();
883 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
885 // open the ddl file info to know the module
886 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
887 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
890 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
891 if(!infileddl) AliError("Could not read the ddl info file");
898 for(Int_t jddl = 0; jddl < 6; jddl++)
900 if (infileddl.eof()) break;
901 infileddl >> ddlno >> modulePerDDL;
902 moduleddl[jddl] = modulePerDDL;
904 if (modulePerDDL == 0) continue;
905 for (Int_t im = 0; im < modulePerDDL; im++)
913 // Set the minimum noise cut per module before clustering
915 fRecoParam = AliPMDReconstructor::GetRecoParam();
917 if(fRecoParam == 0x0)
919 AliFatal("No Reco Param found for PMD!!!");
923 fRunLoader->GetEvent(ievt);
927 fTreeR = fPMDLoader->TreeR();
930 fPMDLoader->MakeTree("R");
931 fTreeR = fPMDLoader->TreeR();
933 Int_t bufsize = 16000;
934 TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
935 TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
937 const Int_t kRow = 48;
938 const Int_t kCol = 96;
943 AliPMDRawStream pmdinput(rawReader);
946 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
949 iSMN = moduleddl[indexDDL];
952 precpvADC = new int **[iSMN];
953 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
954 for (Int_t i=0; i<iSMN;i++)
956 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
958 for (Int_t i = 0; i < iSMN; i++)
960 for (Int_t j = 0; j < kRow; j++)
962 for (Int_t k = 0; k < kCol; k++)
964 precpvADC[i][j][k] = 0;
972 Int_t ientries = pmdddlcont.GetEntries();
973 for (Int_t ient = 0; ient < ientries; ient++)
975 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
977 Int_t det = pmdddl->GetDetector();
978 Int_t smn = pmdddl->GetSMN();
979 //Int_t mcm = pmdddl->GetMCM();
980 //Int_t chno = pmdddl->GetChannel();
981 Int_t row = pmdddl->GetRow();
982 Int_t col = pmdddl->GetColumn();
983 Int_t sig = pmdddl->GetSignal();
984 if(row < 0 || row > 48 || col < 0 || col > 96)
986 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
990 // Pedestal Subtraction
991 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
992 Int_t pedrms1 = (Int_t) pedmeanrms%100;
993 Float_t pedrms = (Float_t)pedrms1/10.;
994 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
995 //printf("%f %f\n",pedmean, pedrms);
996 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
998 // Hot cell - set the cell adc = 0
999 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
1000 if (hotflag == 1) sig1 = 0;
1003 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
1005 //printf("sig = %d gain = %f\n",sig,gain);
1006 sig = (Int_t) (sig1*gain);
1011 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1017 else if (iSMN == 12)
1021 else if (smn >= 18 && smn < 24)
1025 else if (indexDDL >= 1 && indexDDL < 4)
1028 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1030 indexsmn = smn - indexDDL * 6;
1032 else if (indexDDL == 4)
1035 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1041 else if (smn >= 18 && smn < 24)
1043 indexsmn = smn - 12;
1046 else if (indexDDL == 5)
1049 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1051 if (smn >= 6 && smn < 18)
1057 precpvADC[indexsmn][row][col] = sig;
1061 pmdddlcont.Delete();
1064 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
1067 for (Int_t irow = 0; irow < kRow; irow++)
1069 for (Int_t icol = 0; icol < kCol; icol++)
1071 fCellTrack[irow][icol] = -1;
1072 fCellPid[irow][icol] = -1;
1073 fCellADC[irow][icol] =
1074 (Double_t) precpvADC[indexsmn][irow][icol];
1085 else if (iSMN == 12)
1090 else if (indexsmn >= 6 && indexsmn < 12)
1091 ismn = indexsmn + 12;
1095 else if (indexDDL >= 1 && indexDDL < 4)
1097 ismn = indexsmn + indexDDL * 6;
1100 else if (indexDDL == 4)
1106 else if (indexsmn >= 6 && indexsmn < 12)
1108 ismn = indexsmn + 12;
1112 else if (indexDDL == 5)
1114 ismn = indexsmn + 6;
1118 Int_t imod = idet*24 + ismn;
1119 fEcut = fRecoParam->GetNoiseCut(imod); // default
1120 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
1121 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
1122 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
1124 pmdclust->SetEdepCut(fEcut);
1126 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
1127 pmdisocell,pmdcont);
1129 Int_t nentries1 = pmdcont->GetEntries();
1131 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
1133 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1135 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
1136 idet = pmdcl->GetDetector();
1137 ismn = pmdcl->GetSMN();
1138 clusdata[0] = pmdcl->GetClusX();
1139 clusdata[1] = pmdcl->GetClusY();
1140 clusdata[2] = pmdcl->GetClusADC();
1141 clusdata[3] = pmdcl->GetClusCells();
1142 clusdata[4] = pmdcl->GetClusSigmaX();
1143 clusdata[5] = pmdcl->GetClusSigmaY();
1145 AddRecPoint(idet,ismn,clusdata);
1147 Int_t ncell = (Int_t) clusdata[3];
1148 for(Int_t ihit = 0; ihit < ncell; ihit++)
1150 Int_t celldataX = pmdcl->GetClusCellX(ihit);
1151 Int_t celldataY = pmdcl->GetClusCellY(ihit);
1152 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
1153 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
1154 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
1155 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
1163 // Added single isolated cell for offline gain calibration
1164 nentries1 = pmdisocell->GetEntries();
1165 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
1167 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1169 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
1170 idet = pmdiso->GetDetector();
1171 ismn = pmdiso->GetSmn();
1172 clusdata[0] = (Float_t) pmdiso->GetRow();
1173 clusdata[1] = (Float_t) pmdiso->GetCol();
1174 clusdata[2] = pmdiso->GetADC();
1179 AddRecPoint(idet,ismn,clusdata);
1181 pmdisocell->Delete();
1189 for (Int_t i=0; i<iSMN; i++)
1191 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
1193 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
1200 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
1201 fPMDLoader->WriteRecPoints("OVERWRITE");
1203 // delete the pointers
1208 // ------------------------------------------------------------------------- //
1209 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
1213 // ------------------------------------------------------------------------- //
1214 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
1216 // Add Reconstructed points
1218 TClonesArray &lrecpoints = *fRecpoints;
1219 AliPMDrecpoint1 *newrecpoint;
1220 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
1221 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
1224 // ------------------------------------------------------------------------- //
1225 void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY,
1226 Int_t celldataTr, Int_t celldataPid,
1227 Float_t celldataAdc)
1229 // Add associated cell hits to the Reconstructed points
1231 TClonesArray &lrechits = *fRechits;
1232 AliPMDrechit *newrechit;
1233 newrechit = new AliPMDrechit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
1234 new(lrechits[fNhit++]) AliPMDrechit(newrechit);
1237 // ------------------------------------------------------------------------- //
1238 void AliPMDClusterFinder::ResetCellADC()
1240 // Reset the individual cell ADC value to zero
1242 for(Int_t irow = 0; irow < fgkRow; irow++)
1244 for(Int_t icol = 0; icol < fgkCol; icol++)
1246 fCellTrack[irow][icol] = -1;
1247 fCellPid[irow][icol] = -1;
1248 fCellADC[irow][icol] = 0.;
1252 // ------------------------------------------------------------------------- //
1253 void AliPMDClusterFinder::ResetRecpoint()
1255 // Clear the list of reconstructed points
1257 if (fRecpoints) fRecpoints->Clear();
1259 // ------------------------------------------------------------------------- //
1260 void AliPMDClusterFinder::ResetRechit()
1262 // Clear the list of reconstructed points
1264 if (fRechits) fRechits->Clear();
1266 // ------------------------------------------------------------------------- //
1267 void AliPMDClusterFinder::Load()
1269 // Load all the *.root files
1271 fPMDLoader->LoadDigits("READ");
1272 fPMDLoader->LoadRecPoints("recreate");
1274 // ------------------------------------------------------------------------- //
1275 void AliPMDClusterFinder::LoadClusters()
1277 // Load all the *.root files
1279 fPMDLoader->LoadRecPoints("recreate");
1281 // ------------------------------------------------------------------------- //
1282 void AliPMDClusterFinder::UnLoad()
1284 // Unload all the *.root files
1286 fPMDLoader->UnloadDigits();
1287 fPMDLoader->UnloadRecPoints();
1289 // ------------------------------------------------------------------------- //
1290 void AliPMDClusterFinder::UnLoadClusters()
1292 // Unload all the *.root files
1294 fPMDLoader->UnloadRecPoints();
1296 // ------------------------------------------------------------------------- //
1297 AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
1299 // The run number will be centralized in AliCDBManager,
1300 // you don't need to set it here!
1302 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
1304 if(!entry) AliFatal("Calibration object retrieval failed! ");
1306 AliPMDCalibData *calibdata=0;
1307 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
1309 if (!calibdata) AliFatal("No calibration data from calibration database !");
1313 // ------------------------------------------------------------------------- //
1314 AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
1316 // The run number will be centralized in AliCDBManager,
1317 // you don't need to set it here!
1318 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
1320 if(!entry) AliFatal("Pedestal object retrieval failed!");
1322 AliPMDPedestal *pedestal = 0;
1323 if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
1325 if (!pedestal) AliFatal("No pedestal data from pedestal database !");
1329 //--------------------------------------------------------------------//
1330 AliPMDHotData* AliPMDClusterFinder::GetCalibHot() const
1332 // The run number will be centralized in AliCDBManager,
1333 // you don't need to set it here!
1334 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Hot");
1336 if(!entry) AliFatal("HotData object retrieval failed!");
1338 AliPMDHotData *hot = 0;
1339 if (entry) hot = (AliPMDHotData*) entry->GetObject();
1341 if (!hot) AliFatal("No hot data from database !");