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();
392 if(det < 0 || det > 1)
394 AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
397 if(smn == -1 || smn > 23)
399 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
403 if(xpos < 0 || xpos > 47 || ypos < 0 || ypos > 95)
405 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
410 // Pedestal Subtraction
411 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
412 Int_t pedrms1 = (Int_t) pedmeanrms%100;
413 Float_t pedrms = (Float_t)pedrms1/10.;
414 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
415 //printf("%f %f\n",pedmean, pedrms);
417 Float_t adc1 = adc - (pedmean + 3.0*pedrms);
419 // Hot cell - set the cell adc = 0
420 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
421 if (hotflag == 1.) adc1 = 0;
424 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
425 // printf("adc = %d gain = %f\n",adc,gain);
429 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
430 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
431 fCellADC[xpos][ypos] = (Double_t) adc;
433 totADCMod += (Int_t) adc;
440 if (totADCMod <= 0) continue;
442 // Set the minimum noise cut per module before clustering
444 Int_t imod = idet*24 + ismn;
445 fEcut = fRecoParam->GetNoiseCut(imod); // default
446 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
447 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
448 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
451 pmdclust->SetEdepCut(fEcut);
453 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
456 Int_t nentries1 = pmdcont->GetEntries();
458 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
460 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
462 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
463 idet = pmdcl->GetDetector();
464 ismn = pmdcl->GetSMN();
465 clusdata[0] = pmdcl->GetClusX();
466 clusdata[1] = pmdcl->GetClusY();
467 clusdata[2] = pmdcl->GetClusADC();
468 clusdata[3] = pmdcl->GetClusCells();
469 clusdata[4] = pmdcl->GetClusSigmaX();
470 clusdata[5] = pmdcl->GetClusSigmaY();
472 AddRecPoint(idet,ismn,clusdata);
474 Int_t ncell = (Int_t) clusdata[3];
475 for(Int_t ihit = 0; ihit < ncell; ihit++)
477 Int_t celldataX = pmdcl->GetClusCellX(ihit);
478 Int_t celldataY = pmdcl->GetClusCellY(ihit);
479 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
480 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
481 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
482 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
489 // Added single isolated cell for offline gain calibration
490 nentries1 = pmdisocell->GetEntries();
491 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
493 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
495 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
496 idet = pmdiso->GetDetector();
497 ismn = pmdiso->GetSmn();
498 clusdata[0] = (Float_t) pmdiso->GetRow();
499 clusdata[1] = (Float_t) pmdiso->GetCol();
500 clusdata[2] = pmdiso->GetADC();
505 AddRecPoint(idet,ismn,clusdata);
507 pmdisocell->Delete();
517 // delete the pointers
522 // ------------------------------------------------------------------------- //
524 void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
527 // Converts RAW data to recpoints after running clustering
528 // algorithm on CPV and PREshower plane
530 // This method is called at the time of reconstruction from RAW data
533 AliPMDddldata *pmdddl = 0x0;
534 AliPMDcluster *pmdcl = 0x0;
535 AliPMDisocell *pmdiso = 0x0;
539 TObjArray pmdddlcont;
541 TObjArray *pmdcont = new TObjArray();
542 TObjArray *pmdisocell = new TObjArray();
544 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
546 // open the ddl file info to know the module
547 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
548 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
551 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
552 if(!infileddl) AliError("Could not read the ddl info file");
559 for(Int_t jddl = 0; jddl < 6; jddl++)
561 if (infileddl.eof()) break;
562 infileddl >> ddlno >> modulePerDDL;
563 moduleddl[jddl] = modulePerDDL;
565 if (modulePerDDL == 0) continue;
566 for (Int_t im = 0; im < modulePerDDL; im++)
574 // Set the minimum noise cut per module before clustering
576 fRecoParam = AliPMDReconstructor::GetRecoParam();
578 if(fRecoParam == 0x0)
580 AliFatal("No Reco Param found for PMD!!!");
585 Int_t bufsize = 16000;
586 TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
588 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
590 const Int_t kRow = 48;
591 const Int_t kCol = 96;
597 AliPMDRawStream pmdinput(rawReader);
599 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
601 iSMN = moduleddl[indexDDL];
604 precpvADC = new int **[iSMN];
605 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
606 for (Int_t i=0; i<iSMN;i++)
608 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
610 for (Int_t i = 0; i < iSMN; i++)
612 for (Int_t j = 0; j < kRow; j++)
614 for (Int_t k = 0; k < kCol; k++)
616 precpvADC[i][j][k] = 0;
623 Int_t ientries = pmdddlcont.GetEntries();
624 for (Int_t ient = 0; ient < ientries; ient++)
626 pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
628 Int_t det = pmdddl->GetDetector();
629 Int_t smn = pmdddl->GetSMN();
630 //Int_t mcm = pmdddl->GetMCM();
631 //Int_t chno = pmdddl->GetChannel();
632 Int_t row = pmdddl->GetRow();
633 Int_t col = pmdddl->GetColumn();
634 Int_t sig = pmdddl->GetSignal();
637 if(det < 0 || det > 1)
639 AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
642 if(smn < 0 || smn > 23)
644 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
647 if(row < 0 || row > 47 || col < 0 || col > 95)
649 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
656 // Pedestal Subtraction
657 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
658 Int_t pedrms1 = (Int_t) pedmeanrms%100;
659 Float_t pedrms = (Float_t)pedrms1/10.;
660 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
662 //printf("%f %f\n",pedmean, pedrms);
664 // Float_t sig1 = (Float_t) sig;
665 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
668 // Hot cell - set the cell adc = 0
669 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
670 if (hotflag == 1.) sig1 = 0;
673 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
674 //printf("sig = %d gain = %f\n",sig,gain);
675 sig = (Int_t) (sig1*gain);
680 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
690 else if (smn >= 18 && smn < 24)
694 else if (indexDDL >= 1 && indexDDL < 4)
697 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
699 indexsmn = smn - indexDDL * 6;
701 else if (indexDDL == 4)
704 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
710 else if (smn >= 18 && smn < 24)
715 else if (indexDDL == 5)
718 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
720 if (smn >= 6 && smn < 18)
726 precpvADC[indexsmn][row][col] = sig;
734 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
738 for (Int_t irow = 0; irow < kRow; irow++)
740 for (Int_t icol = 0; icol < kCol; icol++)
742 fCellTrack[irow][icol] = -1;
743 fCellPid[irow][icol] = -1;
745 fCellADC[irow][icol] =
746 (Double_t) precpvADC[indexsmn][irow][icol];
747 totAdcMod += precpvADC[indexsmn][irow][icol];
762 else if (indexsmn >= 6 && indexsmn < 12)
763 ismn = indexsmn + 12;
767 else if (indexDDL >= 1 && indexDDL < 4)
769 ismn = indexsmn + indexDDL * 6;
772 else if (indexDDL == 4)
778 else if (indexsmn >= 6 && indexsmn < 12)
780 ismn = indexsmn + 12;
784 else if (indexDDL == 5)
790 if (totAdcMod <= 0) continue;
792 Int_t imod = idet*24 + ismn;
794 fEcut = fRecoParam->GetNoiseCut(imod); // default
795 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
796 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
797 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
800 pmdclust->SetEdepCut(fEcut);
802 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
805 Int_t nentries1 = pmdcont->GetEntries();
807 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
809 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
811 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
812 idet = pmdcl->GetDetector();
813 ismn = pmdcl->GetSMN();
814 clusdata[0] = pmdcl->GetClusX();
815 clusdata[1] = pmdcl->GetClusY();
816 clusdata[2] = pmdcl->GetClusADC();
817 clusdata[3] = pmdcl->GetClusCells();
818 clusdata[4] = pmdcl->GetClusSigmaX();
819 clusdata[5] = pmdcl->GetClusSigmaY();
821 AddRecPoint(idet,ismn,clusdata);
823 Int_t ncell = (Int_t) clusdata[3];
824 for(Int_t ihit = 0; ihit < ncell; ihit++)
826 Int_t celldataX = pmdcl->GetClusCellX(ihit);
827 Int_t celldataY = pmdcl->GetClusCellY(ihit);
828 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
829 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
830 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
831 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
840 // Added single isolated cell for offline gain calibration
841 nentries1 = pmdisocell->GetEntries();
842 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
844 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
846 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
847 idet = pmdiso->GetDetector();
848 ismn = pmdiso->GetSmn();
849 clusdata[0] = (Float_t) pmdiso->GetRow();
850 clusdata[1] = (Float_t) pmdiso->GetCol();
851 clusdata[2] = pmdiso->GetADC();
856 AddRecPoint(idet,ismn,clusdata);
858 pmdisocell->Delete();
866 for (Int_t i=0; i<iSMN; i++)
868 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
870 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
878 // delete the pointers
884 // ------------------------------------------------------------------------- //
886 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
888 // Converts RAW data to recpoints after running clustering
889 // algorithm on CPV and PREshower plane
894 TObjArray pmdddlcont;
896 AliPMDcluster *pmdcl = 0x0;
897 AliPMDisocell *pmdiso = 0x0;
900 TObjArray *pmdcont = new TObjArray();
901 TObjArray *pmdisocell = new TObjArray();
903 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
905 // open the ddl file info to know the module
906 TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
907 ddlinfofileName += "/PMD/PMD_ddl_info.dat";
910 infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
911 if(!infileddl) AliError("Could not read the ddl info file");
918 for(Int_t jddl = 0; jddl < 6; jddl++)
920 if (infileddl.eof()) break;
921 infileddl >> ddlno >> modulePerDDL;
922 moduleddl[jddl] = modulePerDDL;
924 if (modulePerDDL == 0) continue;
925 for (Int_t im = 0; im < modulePerDDL; im++)
933 // Set the minimum noise cut per module before clustering
935 fRecoParam = AliPMDReconstructor::GetRecoParam();
937 if(fRecoParam == 0x0)
939 AliFatal("No Reco Param found for PMD!!!");
943 fRunLoader->GetEvent(ievt);
947 fTreeR = fPMDLoader->TreeR();
950 fPMDLoader->MakeTree("R");
951 fTreeR = fPMDLoader->TreeR();
953 Int_t bufsize = 16000;
954 TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
955 TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
957 const Int_t kRow = 48;
958 const Int_t kCol = 96;
963 AliPMDRawStream pmdinput(rawReader);
966 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
969 iSMN = moduleddl[indexDDL];
972 precpvADC = new int **[iSMN];
973 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
974 for (Int_t i=0; i<iSMN;i++)
976 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
978 for (Int_t i = 0; i < iSMN; i++)
980 for (Int_t j = 0; j < kRow; j++)
982 for (Int_t k = 0; k < kCol; k++)
984 precpvADC[i][j][k] = 0;
992 Int_t ientries = pmdddlcont.GetEntries();
993 for (Int_t ient = 0; ient < ientries; ient++)
995 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
997 Int_t det = pmdddl->GetDetector();
998 Int_t smn = pmdddl->GetSMN();
999 //Int_t mcm = pmdddl->GetMCM();
1000 //Int_t chno = pmdddl->GetChannel();
1001 Int_t row = pmdddl->GetRow();
1002 Int_t col = pmdddl->GetColumn();
1003 Int_t sig = pmdddl->GetSignal();
1004 if(row < 0 || row > 48 || col < 0 || col > 96)
1006 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
1010 // Pedestal Subtraction
1011 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
1012 Int_t pedrms1 = (Int_t) pedmeanrms%100;
1013 Float_t pedrms = (Float_t)pedrms1/10.;
1014 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
1015 //printf("%f %f\n",pedmean, pedrms);
1016 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
1018 // Hot cell - set the cell adc = 0
1019 Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
1020 if (hotflag == 1) sig1 = 0;
1023 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
1025 //printf("sig = %d gain = %f\n",sig,gain);
1026 sig = (Int_t) (sig1*gain);
1031 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1037 else if (iSMN == 12)
1041 else if (smn >= 18 && smn < 24)
1045 else if (indexDDL >= 1 && indexDDL < 4)
1048 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1050 indexsmn = smn - indexDDL * 6;
1052 else if (indexDDL == 4)
1055 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1061 else if (smn >= 18 && smn < 24)
1063 indexsmn = smn - 12;
1066 else if (indexDDL == 5)
1069 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
1071 if (smn >= 6 && smn < 18)
1077 precpvADC[indexsmn][row][col] = sig;
1081 pmdddlcont.Delete();
1084 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
1087 for (Int_t irow = 0; irow < kRow; irow++)
1089 for (Int_t icol = 0; icol < kCol; icol++)
1091 fCellTrack[irow][icol] = -1;
1092 fCellPid[irow][icol] = -1;
1093 fCellADC[irow][icol] =
1094 (Double_t) precpvADC[indexsmn][irow][icol];
1105 else if (iSMN == 12)
1110 else if (indexsmn >= 6 && indexsmn < 12)
1111 ismn = indexsmn + 12;
1115 else if (indexDDL >= 1 && indexDDL < 4)
1117 ismn = indexsmn + indexDDL * 6;
1120 else if (indexDDL == 4)
1126 else if (indexsmn >= 6 && indexsmn < 12)
1128 ismn = indexsmn + 12;
1132 else if (indexDDL == 5)
1134 ismn = indexsmn + 6;
1138 Int_t imod = idet*24 + ismn;
1139 fEcut = fRecoParam->GetNoiseCut(imod); // default
1140 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
1141 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
1142 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
1144 pmdclust->SetEdepCut(fEcut);
1146 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
1147 pmdisocell,pmdcont);
1149 Int_t nentries1 = pmdcont->GetEntries();
1151 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
1153 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1155 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
1156 idet = pmdcl->GetDetector();
1157 ismn = pmdcl->GetSMN();
1158 clusdata[0] = pmdcl->GetClusX();
1159 clusdata[1] = pmdcl->GetClusY();
1160 clusdata[2] = pmdcl->GetClusADC();
1161 clusdata[3] = pmdcl->GetClusCells();
1162 clusdata[4] = pmdcl->GetClusSigmaX();
1163 clusdata[5] = pmdcl->GetClusSigmaY();
1165 AddRecPoint(idet,ismn,clusdata);
1167 Int_t ncell = (Int_t) clusdata[3];
1168 for(Int_t ihit = 0; ihit < ncell; ihit++)
1170 Int_t celldataX = pmdcl->GetClusCellX(ihit);
1171 Int_t celldataY = pmdcl->GetClusCellY(ihit);
1172 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
1173 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
1174 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
1175 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
1183 // Added single isolated cell for offline gain calibration
1184 nentries1 = pmdisocell->GetEntries();
1185 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
1187 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1189 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
1190 idet = pmdiso->GetDetector();
1191 ismn = pmdiso->GetSmn();
1192 clusdata[0] = (Float_t) pmdiso->GetRow();
1193 clusdata[1] = (Float_t) pmdiso->GetCol();
1194 clusdata[2] = pmdiso->GetADC();
1199 AddRecPoint(idet,ismn,clusdata);
1201 pmdisocell->Delete();
1209 for (Int_t i=0; i<iSMN; i++)
1211 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
1213 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
1220 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
1221 fPMDLoader->WriteRecPoints("OVERWRITE");
1223 // delete the pointers
1228 // ------------------------------------------------------------------------- //
1229 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
1233 // ------------------------------------------------------------------------- //
1234 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
1236 // Add Reconstructed points
1238 TClonesArray &lrecpoints = *fRecpoints;
1239 AliPMDrecpoint1 *newrecpoint;
1240 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
1241 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
1244 // ------------------------------------------------------------------------- //
1245 void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY,
1246 Int_t celldataTr, Int_t celldataPid,
1247 Float_t celldataAdc)
1249 // Add associated cell hits to the Reconstructed points
1251 TClonesArray &lrechits = *fRechits;
1252 AliPMDrechit *newrechit;
1253 newrechit = new AliPMDrechit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
1254 new(lrechits[fNhit++]) AliPMDrechit(newrechit);
1257 // ------------------------------------------------------------------------- //
1258 void AliPMDClusterFinder::ResetCellADC()
1260 // Reset the individual cell ADC value to zero
1262 for(Int_t irow = 0; irow < fgkRow; irow++)
1264 for(Int_t icol = 0; icol < fgkCol; icol++)
1266 fCellTrack[irow][icol] = -1;
1267 fCellPid[irow][icol] = -1;
1268 fCellADC[irow][icol] = 0.;
1272 // ------------------------------------------------------------------------- //
1273 void AliPMDClusterFinder::ResetRecpoint()
1275 // Clear the list of reconstructed points
1277 if (fRecpoints) fRecpoints->Clear();
1279 // ------------------------------------------------------------------------- //
1280 void AliPMDClusterFinder::ResetRechit()
1282 // Clear the list of reconstructed points
1284 if (fRechits) fRechits->Clear();
1286 // ------------------------------------------------------------------------- //
1287 void AliPMDClusterFinder::Load()
1289 // Load all the *.root files
1291 fPMDLoader->LoadDigits("READ");
1292 fPMDLoader->LoadRecPoints("recreate");
1294 // ------------------------------------------------------------------------- //
1295 void AliPMDClusterFinder::LoadClusters()
1297 // Load all the *.root files
1299 fPMDLoader->LoadRecPoints("recreate");
1301 // ------------------------------------------------------------------------- //
1302 void AliPMDClusterFinder::UnLoad()
1304 // Unload all the *.root files
1306 fPMDLoader->UnloadDigits();
1307 fPMDLoader->UnloadRecPoints();
1309 // ------------------------------------------------------------------------- //
1310 void AliPMDClusterFinder::UnLoadClusters()
1312 // Unload all the *.root files
1314 fPMDLoader->UnloadRecPoints();
1316 // ------------------------------------------------------------------------- //
1317 AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
1319 // The run number will be centralized in AliCDBManager,
1320 // you don't need to set it here!
1322 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
1324 if(!entry) AliFatal("Calibration object retrieval failed! ");
1326 AliPMDCalibData *calibdata=0;
1327 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
1329 if (!calibdata) AliFatal("No calibration data from calibration database !");
1333 // ------------------------------------------------------------------------- //
1334 AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
1336 // The run number will be centralized in AliCDBManager,
1337 // you don't need to set it here!
1338 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
1340 if(!entry) AliFatal("Pedestal object retrieval failed!");
1342 AliPMDPedestal *pedestal = 0;
1343 if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
1345 if (!pedestal) AliFatal("No pedestal data from pedestal database !");
1349 //--------------------------------------------------------------------//
1350 AliPMDHotData* AliPMDClusterFinder::GetCalibHot() const
1352 // The run number will be centralized in AliCDBManager,
1353 // you don't need to set it here!
1354 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Hot");
1356 if(!entry) AliFatal("HotData object retrieval failed!");
1358 AliPMDHotData *hot = 0;
1359 if (entry) hot = (AliPMDHotData*) entry->GetObject();
1361 if (!hot) AliFatal("No hot data from database !");