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 "AliPMDRawStream.h"
44 #include "AliPMDCalibData.h"
45 #include "AliPMDPedestal.h"
46 #include "AliPMDddldata.h"
47 #include "AliPMDHotData.h"
48 #include "AliPMDRecoParam.h"
49 #include "AliPMDReconstructor.h"
52 #include "AliCDBManager.h"
53 #include "AliCDBEntry.h"
57 ClassImp(AliPMDClusterFinder)
59 AliPMDClusterFinder::AliPMDClusterFinder():
62 fCalibGain(GetCalibGain()),
63 fCalibPed(GetCalibPed()),
64 fCalibHot(GetCalibHot()),
68 fDigits(new TClonesArray("AliPMDdigit", 1000)),
69 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
70 fRechits(new TClonesArray("AliPMDrechit", 1000)),
80 // ------------------------------------------------------------------------- //
81 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
82 fRunLoader(runLoader),
83 fPMDLoader(runLoader->GetLoader("PMDLoader")),
84 fCalibGain(GetCalibGain()),
85 fCalibPed(GetCalibPed()),
86 fCalibHot(GetCalibHot()),
90 fDigits(new TClonesArray("AliPMDdigit", 1000)),
91 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
92 fRechits(new TClonesArray("AliPMDrechit", 1000)),
102 // ------------------------------------------------------------------------- //
103 AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder):
107 fCalibGain(GetCalibGain()),
108 fCalibPed(GetCalibPed()),
109 fCalibHot(GetCalibHot()),
122 AliError("Copy constructor not allowed");
124 // ------------------------------------------------------------------------- //
125 AliPMDClusterFinder &AliPMDClusterFinder::operator=(const AliPMDClusterFinder & /*finder*/)
128 AliError("Assignment Operator not allowed");
131 // ------------------------------------------------------------------------- //
132 AliPMDClusterFinder::~AliPMDClusterFinder()
149 // ------------------------------------------------------------------------- //
151 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
153 // Converts digits to recpoints after running clustering
154 // algorithm on CPV plane and PREshower plane
157 Int_t det = 0,smn = 0;
164 TObjArray *pmdcont = new TObjArray();
166 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
168 // fetch the recoparam object from database
169 fRecoParam = AliPMDReconstructor::GetRecoParam();
171 if(fRecoParam == 0x0)
173 AliFatal("No Reco Param found for PMD!!!");
177 fRunLoader->GetEvent(ievt);
180 fTreeD = fPMDLoader->TreeD();
183 AliFatal("AliPMDClusterFinder: Can not get TreeD");
186 AliPMDdigit *pmddigit;
187 TBranch *branch = fTreeD->GetBranch("PMDDigit");
188 branch->SetAddress(&fDigits);
192 fTreeR = fPMDLoader->TreeR();
195 fPMDLoader->MakeTree("R");
196 fTreeR = fPMDLoader->TreeR();
199 Int_t bufsize = 16000;
200 TBranch * branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
201 TBranch * branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
203 Int_t nmodules = (Int_t) fTreeD->GetEntries();
205 for (Int_t imodule = 0; imodule < nmodules; imodule++)
208 fTreeD->GetEntry(imodule);
209 Int_t nentries = fDigits->GetLast();
210 for (Int_t ient = 0; ient < nentries+1; ient++)
212 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
214 det = pmddigit->GetDetector();
215 smn = pmddigit->GetSMNumber();
216 xpos = pmddigit->GetRow();
217 ypos = pmddigit->GetColumn();
218 adc = pmddigit->GetADC();
219 if(xpos < 0 || xpos > 48 || ypos < 0 || ypos > 96)
221 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
226 // Hot cell - set the cell adc = 0
227 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
228 if (hotflag == 1) adc = 0;
230 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
231 // printf("adc = %d gain = %f\n",adc,gain);
235 //Int_t trno = pmddigit->GetTrackNumber();
236 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
237 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
238 fCellADC[xpos][ypos] = (Double_t) adc;
244 // Set the minimum noise cut per module before clustering
246 Int_t imod = idet*24 + ismn;
247 fEcut = fRecoParam->GetNoiseCut(imod); // default
248 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
249 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
250 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
252 pmdclust->SetEdepCut(fEcut);
253 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
255 Int_t nentries1 = pmdcont->GetEntries();
257 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
259 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
261 AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
262 idet = pmdcl->GetDetector();
263 ismn = pmdcl->GetSMN();
264 clusdata[0] = pmdcl->GetClusX();
265 clusdata[1] = pmdcl->GetClusY();
266 clusdata[2] = pmdcl->GetClusADC();
267 clusdata[3] = pmdcl->GetClusCells();
268 clusdata[4] = pmdcl->GetClusSigmaX();
269 clusdata[5] = pmdcl->GetClusSigmaY();
271 AddRecPoint(idet,ismn,clusdata);
273 Int_t ncell = (Int_t) clusdata[3];
274 for(Int_t ihit = 0; ihit < ncell; ihit++)
276 Int_t celldataX = pmdcl->GetClusCellX(ihit);
277 Int_t celldataY = pmdcl->GetClusCellY(ihit);
278 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
279 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
280 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
281 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
294 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
295 fPMDLoader->WriteRecPoints("OVERWRITE");
297 // delete the pointers
301 // ------------------------------------------------------------------------- //
303 void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
306 // Converts digits to recpoints after running clustering
307 // algorithm on CPV plane and PREshower plane
309 // This algorithm is called during the reconstruction from digits
311 Int_t det = 0,smn = 0;
318 AliPMDcluster *pmdcl = 0x0;
320 TObjArray *pmdcont = new TObjArray();
322 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
324 // Fetch the reco param object
326 fRecoParam = AliPMDReconstructor::GetRecoParam();
327 if(fRecoParam == 0x0)
329 AliFatal("No Reco Param found for PMD!!!");
333 AliPMDdigit *pmddigit;
334 TBranch *branch = digitsTree->GetBranch("PMDDigit");
335 branch->SetAddress(&fDigits);
339 Int_t bufsize = 16000;
340 TBranch * branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
341 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
343 Int_t nmodules = (Int_t) digitsTree->GetEntries();
345 for (Int_t imodule = 0; imodule < nmodules; imodule++)
350 digitsTree->GetEntry(imodule);
351 Int_t nentries = fDigits->GetLast();
352 for (Int_t ient = 0; ient < nentries+1; ient++)
354 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
356 det = pmddigit->GetDetector();
357 smn = pmddigit->GetSMNumber();
358 xpos = pmddigit->GetRow();
359 ypos = pmddigit->GetColumn();
360 adc = pmddigit->GetADC();
362 if(det < 0 || det > 1)
364 AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
367 if(smn == -1 || smn > 23)
369 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
373 if(xpos < 0 || xpos > 47 || ypos < 0 || ypos > 95)
375 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
380 // Pedestal Subtraction
381 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
382 Int_t pedrms1 = (Int_t) pedmeanrms%100;
383 Float_t pedrms = (Float_t)pedrms1/10.;
384 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
385 //printf("%f %f\n",pedmean, pedrms);
387 Float_t adc1 = adc - (pedmean + 3.0*pedrms);
389 // Hot cell - set the cell adc = 0
390 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
391 if (hotflag == 1.) adc1 = 0;
394 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
395 // printf("adc = %d gain = %f\n",adc,gain);
399 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
400 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
401 fCellADC[xpos][ypos] = (Double_t) adc;
403 totADCMod += (Int_t) adc;
410 if (totADCMod <= 0) continue;
412 // Set the minimum noise cut per module before clustering
414 Int_t imod = idet*24 + ismn;
415 fEcut = fRecoParam->GetNoiseCut(imod); // default
416 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
417 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
418 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
421 pmdclust->SetEdepCut(fEcut);
422 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
424 Int_t nentries1 = pmdcont->GetEntries();
426 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
428 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
430 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
431 idet = pmdcl->GetDetector();
432 ismn = pmdcl->GetSMN();
433 clusdata[0] = pmdcl->GetClusX();
434 clusdata[1] = pmdcl->GetClusY();
435 clusdata[2] = pmdcl->GetClusADC();
436 clusdata[3] = pmdcl->GetClusCells();
437 clusdata[4] = pmdcl->GetClusSigmaX();
438 clusdata[5] = pmdcl->GetClusSigmaY();
440 AddRecPoint(idet,ismn,clusdata);
442 Int_t ncell = (Int_t) clusdata[3];
443 if (ncell > 19) ncell = 19;
444 for(Int_t ihit = 0; ihit < ncell; ihit++)
446 Int_t celldataX = pmdcl->GetClusCellX(ihit);
447 Int_t celldataY = pmdcl->GetClusCellY(ihit);
448 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
449 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
450 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
451 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
466 // delete the pointers
470 // ------------------------------------------------------------------------- //
472 void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
475 // Converts RAW data to recpoints after running clustering
476 // algorithm on CPV and PREshower plane
478 // This method is called at the time of reconstruction from RAW data
481 AliPMDddldata *pmdddl = 0x0;
482 AliPMDcluster *pmdcl = 0x0;
485 TObjArray pmdddlcont;
487 TObjArray *pmdcont = new TObjArray();
489 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
491 // open the ddl file info to know the module
492 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
493 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
496 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
497 if(!infileddl) AliError("Could not read the ddl info file");
504 for(Int_t jddl = 0; jddl < 6; jddl++)
506 if (infileddl.eof()) break;
507 infileddl >> ddlno >> modulePerDDL;
508 moduleddl[jddl] = modulePerDDL;
510 if (modulePerDDL == 0) continue;
511 for (Int_t im = 0; im < modulePerDDL; im++)
519 // Set the minimum noise cut per module before clustering
521 fRecoParam = AliPMDReconstructor::GetRecoParam();
523 if(fRecoParam == 0x0)
525 AliFatal("No Reco Param found for PMD!!!");
530 Int_t bufsize = 16000;
531 TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
533 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
535 const Int_t kRow = 48;
536 const Int_t kCol = 96;
542 AliPMDRawStream pmdinput(rawReader);
544 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
546 iSMN = moduleddl[indexDDL];
549 precpvADC = new int **[iSMN];
550 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
551 for (Int_t i=0; i<iSMN;i++)
553 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
555 for (Int_t i = 0; i < iSMN; i++)
557 for (Int_t j = 0; j < kRow; j++)
559 for (Int_t k = 0; k < kCol; k++)
561 precpvADC[i][j][k] = 0;
568 Int_t ientries = pmdddlcont.GetEntries();
569 for (Int_t ient = 0; ient < ientries; ient++)
571 pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
573 Int_t det = pmdddl->GetDetector();
574 Int_t smn = pmdddl->GetSMN();
575 //Int_t mcm = pmdddl->GetMCM();
576 //Int_t chno = pmdddl->GetChannel();
577 Int_t row = pmdddl->GetRow();
578 Int_t col = pmdddl->GetColumn();
579 Int_t sig = pmdddl->GetSignal();
582 if(det < 0 || det > 1)
584 AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
587 if(smn < 0 || smn > 23)
589 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
592 if(row < 0 || row > 47 || col < 0 || col > 95)
594 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
601 // Pedestal Subtraction
602 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
603 Int_t pedrms1 = (Int_t) pedmeanrms%100;
604 Float_t pedrms = (Float_t)pedrms1/10.;
605 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
607 //printf("%f %f\n",pedmean, pedrms);
609 // Float_t sig1 = (Float_t) sig;
610 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
613 // Hot cell - set the cell adc = 0
614 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
615 if (hotflag == 1.) sig1 = 0;
618 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
619 //printf("sig = %d gain = %f\n",sig,gain);
620 sig = (Int_t) (sig1*gain);
625 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
635 else if (smn >= 18 && smn < 24)
639 else if (indexDDL >= 1 && indexDDL < 4)
642 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
644 indexsmn = smn - indexDDL * 6;
646 else if (indexDDL == 4)
649 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
655 else if (smn >= 18 && smn < 24)
660 else if (indexDDL == 5)
663 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
665 if (smn >= 6 && smn < 18)
671 precpvADC[indexsmn][row][col] = sig;
679 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
683 for (Int_t irow = 0; irow < kRow; irow++)
685 for (Int_t icol = 0; icol < kCol; icol++)
687 fCellTrack[irow][icol] = -1;
688 fCellPid[irow][icol] = -1;
690 fCellADC[irow][icol] =
691 (Double_t) precpvADC[indexsmn][irow][icol];
692 totAdcMod += precpvADC[indexsmn][irow][icol];
707 else if (indexsmn >= 6 && indexsmn < 12)
708 ismn = indexsmn + 12;
712 else if (indexDDL >= 1 && indexDDL < 4)
714 ismn = indexsmn + indexDDL * 6;
717 else if (indexDDL == 4)
723 else if (indexsmn >= 6 && indexsmn < 12)
725 ismn = indexsmn + 12;
729 else if (indexDDL == 5)
735 if (totAdcMod <= 0) continue;
737 Int_t imod = idet*24 + ismn;
739 fEcut = fRecoParam->GetNoiseCut(imod); // default
740 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
741 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
742 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
745 pmdclust->SetEdepCut(fEcut);
746 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
748 Int_t nentries1 = pmdcont->GetEntries();
750 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
752 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
754 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
755 idet = pmdcl->GetDetector();
756 ismn = pmdcl->GetSMN();
757 clusdata[0] = pmdcl->GetClusX();
758 clusdata[1] = pmdcl->GetClusY();
759 clusdata[2] = pmdcl->GetClusADC();
760 clusdata[3] = pmdcl->GetClusCells();
761 clusdata[4] = pmdcl->GetClusSigmaX();
762 clusdata[5] = pmdcl->GetClusSigmaY();
764 AddRecPoint(idet,ismn,clusdata);
766 Int_t ncell = (Int_t) clusdata[3];
767 if (ncell > 19) ncell = 19;
768 for(Int_t ihit = 0; ihit < ncell; ihit++)
770 Int_t celldataX = pmdcl->GetClusCellX(ihit);
771 Int_t celldataY = pmdcl->GetClusCellY(ihit);
772 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
773 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
774 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
775 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
789 for (Int_t i=0; i<iSMN; i++)
791 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
793 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
801 // delete the pointers
805 // ------------------------------------------------------------------------- //
807 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
809 // Converts RAW data to recpoints after running clustering
810 // algorithm on CPV and PREshower plane
815 TObjArray pmdddlcont;
817 AliPMDcluster *pmdcl = 0x0;
819 TObjArray *pmdcont = new TObjArray();
821 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
823 // open the ddl file info to know the module
824 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
825 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
828 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
829 if(!infileddl) AliError("Could not read the ddl info file");
836 for(Int_t jddl = 0; jddl < 6; jddl++)
838 if (infileddl.eof()) break;
839 infileddl >> ddlno >> modulePerDDL;
840 moduleddl[jddl] = modulePerDDL;
842 if (modulePerDDL == 0) continue;
843 for (Int_t im = 0; im < modulePerDDL; im++)
851 // Set the minimum noise cut per module before clustering
853 fRecoParam = AliPMDReconstructor::GetRecoParam();
855 if(fRecoParam == 0x0)
857 AliFatal("No Reco Param found for PMD!!!");
861 fRunLoader->GetEvent(ievt);
865 fTreeR = fPMDLoader->TreeR();
868 fPMDLoader->MakeTree("R");
869 fTreeR = fPMDLoader->TreeR();
871 Int_t bufsize = 16000;
872 TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
873 TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
875 const Int_t kRow = 48;
876 const Int_t kCol = 96;
881 AliPMDRawStream pmdinput(rawReader);
884 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
887 iSMN = moduleddl[indexDDL];
890 precpvADC = new int **[iSMN];
891 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
892 for (Int_t i=0; i<iSMN;i++)
894 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
896 for (Int_t i = 0; i < iSMN; i++)
898 for (Int_t j = 0; j < kRow; j++)
900 for (Int_t k = 0; k < kCol; k++)
902 precpvADC[i][j][k] = 0;
909 Int_t ientries = pmdddlcont.GetEntries();
910 for (Int_t ient = 0; ient < ientries; ient++)
912 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
914 Int_t det = pmdddl->GetDetector();
915 Int_t smn = pmdddl->GetSMN();
916 //Int_t mcm = pmdddl->GetMCM();
917 //Int_t chno = pmdddl->GetChannel();
918 Int_t row = pmdddl->GetRow();
919 Int_t col = pmdddl->GetColumn();
920 Int_t sig = pmdddl->GetSignal();
921 if(row < 0 || row > 48 || col < 0 || col > 96)
923 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
927 // Pedestal Subtraction
928 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
929 Int_t pedrms1 = (Int_t) pedmeanrms%100;
930 Float_t pedrms = (Float_t)pedrms1/10.;
931 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
932 //printf("%f %f\n",pedmean, pedrms);
933 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
935 // Hot cell - set the cell adc = 0
936 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
937 if (hotflag == 1) sig1 = 0;
940 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
942 //printf("sig = %d gain = %f\n",sig,gain);
943 sig = (Int_t) (sig1*gain);
948 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
958 else if (smn >= 18 && smn < 24)
962 else if (indexDDL >= 1 && indexDDL < 4)
965 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
967 indexsmn = smn - indexDDL * 6;
969 else if (indexDDL == 4)
972 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
978 else if (smn >= 18 && smn < 24)
983 else if (indexDDL == 5)
986 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
988 if (smn >= 6 && smn < 18)
994 precpvADC[indexsmn][row][col] = sig;
1001 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
1004 for (Int_t irow = 0; irow < kRow; irow++)
1006 for (Int_t icol = 0; icol < kCol; icol++)
1008 fCellTrack[irow][icol] = -1;
1009 fCellPid[irow][icol] = -1;
1010 fCellADC[irow][icol] =
1011 (Double_t) precpvADC[indexsmn][irow][icol];
1022 else if (iSMN == 12)
1027 else if (indexsmn >= 6 && indexsmn < 12)
1028 ismn = indexsmn + 12;
1032 else if (indexDDL >= 1 && indexDDL < 4)
1034 ismn = indexsmn + indexDDL * 6;
1037 else if (indexDDL == 4)
1043 else if (indexsmn >= 6 && indexsmn < 12)
1045 ismn = indexsmn + 12;
1049 else if (indexDDL == 5)
1051 ismn = indexsmn + 6;
1055 Int_t imod = idet*24 + ismn;
1056 fEcut = fRecoParam->GetNoiseCut(imod); // default
1057 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
1058 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
1059 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
1061 pmdclust->SetEdepCut(fEcut);
1063 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
1065 Int_t nentries1 = pmdcont->GetEntries();
1067 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
1069 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1071 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
1072 idet = pmdcl->GetDetector();
1073 ismn = pmdcl->GetSMN();
1074 clusdata[0] = pmdcl->GetClusX();
1075 clusdata[1] = pmdcl->GetClusY();
1076 clusdata[2] = pmdcl->GetClusADC();
1077 clusdata[3] = pmdcl->GetClusCells();
1078 clusdata[4] = pmdcl->GetClusSigmaX();
1079 clusdata[5] = pmdcl->GetClusSigmaY();
1081 AddRecPoint(idet,ismn,clusdata);
1083 Int_t ncell = (Int_t) clusdata[3];
1084 for(Int_t ihit = 0; ihit < ncell; ihit++)
1086 Int_t celldataX = pmdcl->GetClusCellX(ihit);
1087 Int_t celldataY = pmdcl->GetClusCellY(ihit);
1088 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
1089 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
1090 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
1091 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
1105 for (Int_t i=0; i<iSMN; i++)
1107 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
1109 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
1116 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
1117 fPMDLoader->WriteRecPoints("OVERWRITE");
1119 // delete the pointers
1123 // ------------------------------------------------------------------------- //
1124 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
1128 // ------------------------------------------------------------------------- //
1129 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
1131 // Add Reconstructed points
1133 TClonesArray &lrecpoints = *fRecpoints;
1134 AliPMDrecpoint1 *newrecpoint;
1135 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
1136 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
1139 // ------------------------------------------------------------------------- //
1140 void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY,
1141 Int_t celldataTr, Int_t celldataPid,
1142 Float_t celldataAdc)
1144 // Add associated cell hits to the Reconstructed points
1146 TClonesArray &lrechits = *fRechits;
1147 AliPMDrechit *newrechit;
1148 newrechit = new AliPMDrechit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
1149 new(lrechits[fNhit++]) AliPMDrechit(newrechit);
1152 // ------------------------------------------------------------------------- //
1153 void AliPMDClusterFinder::ResetCellADC()
1155 // Reset the individual cell ADC value to zero
1157 for(Int_t irow = 0; irow < fgkRow; irow++)
1159 for(Int_t icol = 0; icol < fgkCol; icol++)
1161 fCellTrack[irow][icol] = -1;
1162 fCellPid[irow][icol] = -1;
1163 fCellADC[irow][icol] = 0.;
1167 // ------------------------------------------------------------------------- //
1168 void AliPMDClusterFinder::ResetRecpoint()
1170 // Clear the list of reconstructed points
1172 if (fRecpoints) fRecpoints->Clear();
1174 // ------------------------------------------------------------------------- //
1175 void AliPMDClusterFinder::ResetRechit()
1177 // Clear the list of reconstructed points
1179 if (fRechits) fRechits->Clear();
1181 // ------------------------------------------------------------------------- //
1182 void AliPMDClusterFinder::Load()
1184 // Load all the *.root files
1186 fPMDLoader->LoadDigits("READ");
1187 fPMDLoader->LoadRecPoints("recreate");
1189 // ------------------------------------------------------------------------- //
1190 void AliPMDClusterFinder::LoadClusters()
1192 // Load all the *.root files
1194 fPMDLoader->LoadRecPoints("recreate");
1196 // ------------------------------------------------------------------------- //
1197 void AliPMDClusterFinder::UnLoad()
1199 // Unload all the *.root files
1201 fPMDLoader->UnloadDigits();
1202 fPMDLoader->UnloadRecPoints();
1204 // ------------------------------------------------------------------------- //
1205 void AliPMDClusterFinder::UnLoadClusters()
1207 // Unload all the *.root files
1209 fPMDLoader->UnloadRecPoints();
1211 // ------------------------------------------------------------------------- //
1212 AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
1214 // The run number will be centralized in AliCDBManager,
1215 // you don't need to set it here!
1217 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
1219 if(!entry) AliFatal("Calibration object retrieval failed! ");
1221 AliPMDCalibData *calibdata=0;
1222 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
1224 if (!calibdata) AliFatal("No calibration data from calibration database !");
1228 // ------------------------------------------------------------------------- //
1229 AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
1231 // The run number will be centralized in AliCDBManager,
1232 // you don't need to set it here!
1233 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
1235 if(!entry) AliFatal("Pedestal object retrieval failed!");
1237 AliPMDPedestal *pedestal = 0;
1238 if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
1240 if (!pedestal) AliFatal("No pedestal data from pedestal database !");
1244 //--------------------------------------------------------------------//
1245 AliPMDHotData* AliPMDClusterFinder::GetCalibHot() const
1247 // The run number will be centralized in AliCDBManager,
1248 // you don't need to set it here!
1249 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Hot");
1251 if(!entry) AliFatal("HotData object retrieval failed!");
1253 AliPMDHotData *hot = 0;
1254 if (entry) hot = (AliPMDHotData*) entry->GetObject();
1256 if (!hot) AliFatal("No hot data from database !");