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>
31 #include "AliRunLoader.h"
32 #include "AliLoader.h"
33 #include "AliRawReader.h"
35 #include "AliPMDdigit.h"
36 #include "AliPMDClusterFinder.h"
37 #include "AliPMDClustering.h"
38 #include "AliPMDClusteringV1.h"
39 #include "AliPMDcluster.h"
40 #include "AliPMDrecpoint1.h"
41 #include "AliPMDrechit.h"
42 #include "AliPMDisocell.h"
43 #include "AliPMDRawStream.h"
44 #include "AliPMDCalibData.h"
45 #include "AliPMDPedestal.h"
46 #include "AliPMDddldata.h"
47 #include "AliPMDRecoParam.h"
48 #include "AliPMDReconstructor.h"
51 #include "AliCDBManager.h"
52 #include "AliCDBEntry.h"
56 ClassImp(AliPMDClusterFinder)
58 AliPMDClusterFinder::AliPMDClusterFinder():
61 fCalibGain(GetCalibGain()),
62 fCalibPed(GetCalibPed()),
66 fDigits(new TClonesArray("AliPMDdigit", 1000)),
67 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
68 fRechits(new TClonesArray("AliPMDrechit", 1000)),
78 // ------------------------------------------------------------------------- //
79 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
80 fRunLoader(runLoader),
81 fPMDLoader(runLoader->GetLoader("PMDLoader")),
82 fCalibGain(GetCalibGain()),
83 fCalibPed(GetCalibPed()),
87 fDigits(new TClonesArray("AliPMDdigit", 1000)),
88 fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
89 fRechits(new TClonesArray("AliPMDrechit", 1000)),
99 // ------------------------------------------------------------------------- //
100 AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder):
104 fCalibGain(GetCalibGain()),
105 fCalibPed(GetCalibPed()),
118 AliError("Copy constructor not allowed");
120 // ------------------------------------------------------------------------- //
121 AliPMDClusterFinder &AliPMDClusterFinder::operator=(const AliPMDClusterFinder & /*finder*/)
124 AliError("Assignment Operator not allowed");
127 // ------------------------------------------------------------------------- //
128 AliPMDClusterFinder::~AliPMDClusterFinder()
145 // ------------------------------------------------------------------------- //
147 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
149 // Converts digits to recpoints after running clustering
150 // algorithm on CPV plane and PREshower plane
153 Int_t det = 0,smn = 0;
160 AliPMDisocell *pmdiso = 0x0;
162 TObjArray *pmdcont = new TObjArray();
163 TObjArray *pmdisocell = new TObjArray();
165 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
167 // fetch the recoparam object from database
168 fRecoParam = AliPMDReconstructor::GetRecoParam();
170 if(fRecoParam == 0x0)
172 AliFatal("No Reco Param found for PMD!!!");
176 fRunLoader->GetEvent(ievt);
179 fTreeD = fPMDLoader->TreeD();
182 AliFatal("AliPMDClusterFinder: Can not get TreeD");
185 AliPMDdigit *pmddigit;
186 TBranch *branch = fTreeD->GetBranch("PMDDigit");
187 branch->SetAddress(&fDigits);
191 fTreeR = fPMDLoader->TreeR();
194 fPMDLoader->MakeTree("R");
195 fTreeR = fPMDLoader->TreeR();
198 Int_t bufsize = 16000;
199 TBranch * branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
200 TBranch * branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
202 Int_t nmodules = (Int_t) fTreeD->GetEntries();
204 for (Int_t imodule = 0; imodule < nmodules; imodule++)
207 fTreeD->GetEntry(imodule);
208 Int_t nentries = fDigits->GetLast();
209 for (Int_t ient = 0; ient < nentries+1; ient++)
211 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
213 det = pmddigit->GetDetector();
214 smn = pmddigit->GetSMNumber();
215 xpos = pmddigit->GetRow();
216 ypos = pmddigit->GetColumn();
217 adc = pmddigit->GetADC();
218 if(xpos < 0 || xpos > 48 || ypos < 0 || ypos > 96)
220 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
225 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
226 // printf("adc = %d gain = %f\n",adc,gain);
230 //Int_t trno = pmddigit->GetTrackNumber();
231 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
232 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
233 fCellADC[xpos][ypos] = (Double_t) adc;
239 // Set the minimum noise cut per module before clustering
241 Int_t imod = idet*24 + ismn;
242 fEcut = fRecoParam->GetNoiseCut(imod); // default
243 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
244 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
245 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
247 pmdclust->SetEdepCut(fEcut);
250 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
253 Int_t nentries1 = pmdcont->GetEntries();
255 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
257 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
259 AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
260 idet = pmdcl->GetDetector();
261 ismn = pmdcl->GetSMN();
262 clusdata[0] = pmdcl->GetClusX();
263 clusdata[1] = pmdcl->GetClusY();
264 clusdata[2] = pmdcl->GetClusADC();
265 clusdata[3] = pmdcl->GetClusCells();
266 clusdata[4] = pmdcl->GetClusSigmaX();
267 clusdata[5] = pmdcl->GetClusSigmaY();
269 AddRecPoint(idet,ismn,clusdata);
271 Int_t ncell = (Int_t) clusdata[3];
272 for(Int_t ihit = 0; ihit < ncell; ihit++)
274 Int_t celldataX = pmdcl->GetClusCellX(ihit);
275 Int_t celldataY = pmdcl->GetClusCellY(ihit);
276 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
277 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
278 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
279 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
286 // Added single isolated cell for offline gain calibration
287 nentries1 = pmdisocell->GetEntries();
288 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
290 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
292 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
293 idet = pmdiso->GetDetector();
294 ismn = pmdiso->GetSmn();
295 clusdata[0] = (Float_t) pmdiso->GetRow();
296 clusdata[1] = (Float_t) pmdiso->GetCol();
297 clusdata[2] = pmdiso->GetADC();
302 AddRecPoint(idet,ismn,clusdata);
304 pmdisocell->Delete();
312 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
313 fPMDLoader->WriteRecPoints("OVERWRITE");
315 // delete the pointers
321 // ------------------------------------------------------------------------- //
323 void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
326 // Converts digits to recpoints after running clustering
327 // algorithm on CPV plane and PREshower plane
329 // This algorithm is called during the reconstruction from digits
331 Int_t det = 0,smn = 0;
338 AliPMDcluster *pmdcl = 0x0;
339 AliPMDisocell *pmdiso = 0x0;
341 TObjArray *pmdcont = new TObjArray();
342 TObjArray *pmdisocell = new TObjArray();
343 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
345 // Fetch the reco param object
347 fRecoParam = AliPMDReconstructor::GetRecoParam();
348 if(fRecoParam == 0x0)
350 AliFatal("No Reco Param found for PMD!!!");
354 AliPMDdigit *pmddigit;
355 TBranch *branch = digitsTree->GetBranch("PMDDigit");
356 branch->SetAddress(&fDigits);
360 Int_t bufsize = 16000;
361 TBranch * branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
362 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
364 Int_t nmodules = (Int_t) digitsTree->GetEntries();
366 for (Int_t imodule = 0; imodule < nmodules; imodule++)
371 digitsTree->GetEntry(imodule);
372 Int_t nentries = fDigits->GetLast();
373 for (Int_t ient = 0; ient < nentries+1; ient++)
375 pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
377 det = pmddigit->GetDetector();
378 smn = pmddigit->GetSMNumber();
379 xpos = pmddigit->GetRow();
380 ypos = pmddigit->GetColumn();
381 adc = pmddigit->GetADC();
382 if(xpos < 0 || xpos > 48 || ypos < 0 || ypos > 96)
384 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
389 // Pedestal Subtraction
390 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
391 Int_t pedrms1 = (Int_t) pedmeanrms%100;
392 Float_t pedrms = (Float_t)pedrms1/10.;
393 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
394 //printf("%f %f\n",pedmean, pedrms);
396 Float_t adc1 = adc - (pedmean + 3.0*pedrms);
399 Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
400 // printf("adc = %d gain = %f\n",adc,gain);
404 fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
405 fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
406 fCellADC[xpos][ypos] = (Double_t) adc;
408 totADCMod += (Int_t) adc;
415 if (totADCMod <= 0) continue;
417 // Set the minimum noise cut per module before clustering
419 Int_t imod = idet*24 + ismn;
420 fEcut = fRecoParam->GetNoiseCut(imod); // default
421 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
422 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
423 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
426 pmdclust->SetEdepCut(fEcut);
428 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
431 Int_t nentries1 = pmdcont->GetEntries();
433 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
435 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
437 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
438 idet = pmdcl->GetDetector();
439 ismn = pmdcl->GetSMN();
440 clusdata[0] = pmdcl->GetClusX();
441 clusdata[1] = pmdcl->GetClusY();
442 clusdata[2] = pmdcl->GetClusADC();
443 clusdata[3] = pmdcl->GetClusCells();
444 clusdata[4] = pmdcl->GetClusSigmaX();
445 clusdata[5] = pmdcl->GetClusSigmaY();
447 AddRecPoint(idet,ismn,clusdata);
449 Int_t ncell = (Int_t) clusdata[3];
450 for(Int_t ihit = 0; ihit < ncell; ihit++)
452 Int_t celldataX = pmdcl->GetClusCellX(ihit);
453 Int_t celldataY = pmdcl->GetClusCellY(ihit);
454 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
455 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
456 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
457 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
464 // Added single isolated cell for offline gain calibration
465 nentries1 = pmdisocell->GetEntries();
466 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
468 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
470 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
471 idet = pmdiso->GetDetector();
472 ismn = pmdiso->GetSmn();
473 clusdata[0] = (Float_t) pmdiso->GetRow();
474 clusdata[1] = (Float_t) pmdiso->GetCol();
475 clusdata[2] = pmdiso->GetADC();
480 AddRecPoint(idet,ismn,clusdata);
482 pmdisocell->Delete();
492 // delete the pointers
497 // ------------------------------------------------------------------------- //
499 void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
502 // Converts RAW data to recpoints after running clustering
503 // algorithm on CPV and PREshower plane
505 // This method is called at the time of reconstruction from RAW data
508 AliPMDddldata *pmdddl = 0x0;
509 AliPMDcluster *pmdcl = 0x0;
510 AliPMDisocell *pmdiso = 0x0;
514 TObjArray pmdddlcont;
516 TObjArray *pmdcont = new TObjArray();
517 TObjArray *pmdisocell = new TObjArray();
519 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
521 // Set the minimum noise cut per module before clustering
523 fRecoParam = AliPMDReconstructor::GetRecoParam();
525 if(fRecoParam == 0x0)
527 AliFatal("No Reco Param found for PMD!!!");
533 Int_t bufsize = 16000;
534 TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize);
536 TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize);
538 const Int_t kRow = 48;
539 const Int_t kCol = 96;
545 AliPMDRawStream pmdinput(rawReader);
547 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
553 else if (indexDDL >= 4)
558 precpvADC = new int **[iSMN];
559 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
560 for (Int_t i=0; i<iSMN;i++)
562 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
564 for (Int_t i = 0; i < iSMN; i++)
566 for (Int_t j = 0; j < kRow; j++)
568 for (Int_t k = 0; k < kCol; k++)
570 precpvADC[i][j][k] = 0;
577 Int_t ientries = pmdddlcont.GetEntries();
578 for (Int_t ient = 0; ient < ientries; ient++)
580 pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
582 Int_t det = pmdddl->GetDetector();
583 Int_t smn = pmdddl->GetSMN();
584 //Int_t mcm = pmdddl->GetMCM();
585 //Int_t chno = pmdddl->GetChannel();
586 Int_t row = pmdddl->GetRow();
587 Int_t col = pmdddl->GetColumn();
588 Int_t sig = pmdddl->GetSignal();
592 AliError(Form("*MODULE NUMBER WRONG %d *",smn));
595 if(row < 0 || row > 48 || col < 0 || col > 96)
597 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
602 // Pedestal Subtraction
603 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
604 Int_t pedrms1 = (Int_t) pedmeanrms%100;
605 Float_t pedrms = (Float_t)pedrms1/10.;
606 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
608 //printf("%f %f\n",pedmean, pedrms);
610 // Float_t sig1 = (Float_t) sig;
611 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
614 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
615 //printf("sig = %d gain = %f\n",sig,gain);
616 sig = (Int_t) (sig1*gain);
621 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
623 indexsmn = smn - indexDDL * 6;
625 else if (indexDDL == 4)
628 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
634 else if (smn >= 18 && smn < 24)
639 else if (indexDDL == 5)
642 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
644 if (smn >= 6 && smn < 12)
648 else if (smn >= 12 && smn < 18)
653 precpvADC[indexsmn][row][col] = sig;
661 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
665 for (Int_t irow = 0; irow < kRow; irow++)
667 for (Int_t icol = 0; icol < kCol; icol++)
669 fCellTrack[irow][icol] = -1;
670 fCellPid[irow][icol] = -1;
672 fCellADC[irow][icol] =
673 (Double_t) precpvADC[indexsmn][irow][icol];
674 totAdcMod += precpvADC[indexsmn][irow][icol];
680 ismn = indexsmn + indexDDL * 6;
683 else if (indexDDL == 4)
689 else if (indexsmn >= 6 && indexsmn < 12)
691 ismn = indexsmn + 12;
695 else if (indexDDL == 5)
701 else if (indexsmn >= 6 && indexsmn < 12)
708 if (totAdcMod <= 0) continue;
710 Int_t imod = idet*24 + ismn;
712 fEcut = fRecoParam->GetNoiseCut(imod); // default
713 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
714 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
715 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
718 pmdclust->SetEdepCut(fEcut);
720 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
723 Int_t nentries1 = pmdcont->GetEntries();
725 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
727 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
729 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
730 idet = pmdcl->GetDetector();
731 ismn = pmdcl->GetSMN();
732 clusdata[0] = pmdcl->GetClusX();
733 clusdata[1] = pmdcl->GetClusY();
734 clusdata[2] = pmdcl->GetClusADC();
735 clusdata[3] = pmdcl->GetClusCells();
736 clusdata[4] = pmdcl->GetClusSigmaX();
737 clusdata[5] = pmdcl->GetClusSigmaY();
739 AddRecPoint(idet,ismn,clusdata);
741 Int_t ncell = (Int_t) clusdata[3];
742 for(Int_t ihit = 0; ihit < ncell; ihit++)
744 Int_t celldataX = pmdcl->GetClusCellX(ihit);
745 Int_t celldataY = pmdcl->GetClusCellY(ihit);
746 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
747 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
748 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
749 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
758 // Added single isolated cell for offline gain calibration
759 nentries1 = pmdisocell->GetEntries();
760 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
762 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
764 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
765 idet = pmdiso->GetDetector();
766 ismn = pmdiso->GetSmn();
767 clusdata[0] = (Float_t) pmdiso->GetRow();
768 clusdata[1] = (Float_t) pmdiso->GetCol();
769 clusdata[2] = pmdiso->GetADC();
774 AddRecPoint(idet,ismn,clusdata);
776 pmdisocell->Delete();
784 for (Int_t i=0; i<iSMN; i++)
786 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
788 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
796 // delete the pointers
802 // ------------------------------------------------------------------------- //
804 void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
806 // Converts RAW data to recpoints after running clustering
807 // algorithm on CPV and PREshower plane
812 TObjArray pmdddlcont;
814 AliPMDcluster *pmdcl = 0x0;
815 AliPMDisocell *pmdiso = 0x0;
818 TObjArray *pmdcont = new TObjArray();
819 TObjArray *pmdisocell = new TObjArray();
821 AliPMDClustering *pmdclust = new AliPMDClusteringV1();
823 // Set the minimum noise cut per module before clustering
825 fRecoParam = AliPMDReconstructor::GetRecoParam();
827 if(fRecoParam == 0x0)
829 AliFatal("No Reco Param found for PMD!!!");
833 fRunLoader->GetEvent(ievt);
837 fTreeR = fPMDLoader->TreeR();
840 fPMDLoader->MakeTree("R");
841 fTreeR = fPMDLoader->TreeR();
843 Int_t bufsize = 16000;
844 TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
845 TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize);
847 const Int_t kRow = 48;
848 const Int_t kCol = 96;
853 AliPMDRawStream pmdinput(rawReader);
856 while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0) {
862 else if (indexDDL >= 4)
867 precpvADC = new int **[iSMN];
868 for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
869 for (Int_t i=0; i<iSMN;i++)
871 for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
873 for (Int_t i = 0; i < iSMN; i++)
875 for (Int_t j = 0; j < kRow; j++)
877 for (Int_t k = 0; k < kCol; k++)
879 precpvADC[i][j][k] = 0;
887 Int_t ientries = pmdddlcont.GetEntries();
888 for (Int_t ient = 0; ient < ientries; ient++)
890 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
892 Int_t det = pmdddl->GetDetector();
893 Int_t smn = pmdddl->GetSMN();
894 //Int_t mcm = pmdddl->GetMCM();
895 //Int_t chno = pmdddl->GetChannel();
896 Int_t row = pmdddl->GetRow();
897 Int_t col = pmdddl->GetColumn();
898 Int_t sig = pmdddl->GetSignal();
899 if(row < 0 || row > 48 || col < 0 || col > 96)
901 AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
905 // Pedestal Subtraction
906 Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
907 Int_t pedrms1 = (Int_t) pedmeanrms%100;
908 Float_t pedrms = (Float_t)pedrms1/10.;
909 Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0;
911 //printf("%f %f\n",pedmean, pedrms);
913 //Float_t sig1 = (Float_t) sig;
914 Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
916 Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
918 //printf("sig = %d gain = %f\n",sig,gain);
919 sig = (Int_t) (sig1*gain);
925 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
927 indexsmn = smn - indexDDL * 6;
929 else if (indexDDL == 4)
932 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
938 else if (smn >= 18 && smn < 24)
943 else if (indexDDL == 5)
946 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
948 if (smn >= 6 && smn < 12)
952 else if (smn >= 12 && smn < 18)
957 precpvADC[indexsmn][row][col] = sig;
964 for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
967 for (Int_t irow = 0; irow < kRow; irow++)
969 for (Int_t icol = 0; icol < kCol; icol++)
971 fCellTrack[irow][icol] = -1;
972 fCellPid[irow][icol] = -1;
973 fCellADC[irow][icol] =
974 (Double_t) precpvADC[indexsmn][irow][icol];
981 ismn = indexsmn + indexDDL * 6;
984 else if (indexDDL == 4)
990 else if (indexsmn >= 6 && indexsmn < 12)
992 ismn = indexsmn + 12;
996 else if (indexDDL == 5)
1000 ismn = indexsmn + 6;
1002 else if (indexsmn >= 6 && indexsmn < 12)
1004 ismn = indexsmn + 6;
1009 Int_t imod = idet*24 + ismn;
1010 fEcut = fRecoParam->GetNoiseCut(imod); // default
1011 // fEcut = fRecoParam->GetPbPbParam()->GetNoiseCut(imod);
1012 // fEcut = fRecoParam->GetPPParam()->GetNoiseCut(imod);
1013 // fEcut = fRecoParam->GetCosmicParam()->GetNoiseCut(imod);
1015 pmdclust->SetEdepCut(fEcut);
1017 pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,
1018 pmdisocell,pmdcont);
1020 Int_t nentries1 = pmdcont->GetEntries();
1022 AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
1024 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1026 pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
1027 idet = pmdcl->GetDetector();
1028 ismn = pmdcl->GetSMN();
1029 clusdata[0] = pmdcl->GetClusX();
1030 clusdata[1] = pmdcl->GetClusY();
1031 clusdata[2] = pmdcl->GetClusADC();
1032 clusdata[3] = pmdcl->GetClusCells();
1033 clusdata[4] = pmdcl->GetClusSigmaX();
1034 clusdata[5] = pmdcl->GetClusSigmaY();
1036 AddRecPoint(idet,ismn,clusdata);
1038 Int_t ncell = (Int_t) clusdata[3];
1039 for(Int_t ihit = 0; ihit < ncell; ihit++)
1041 Int_t celldataX = pmdcl->GetClusCellX(ihit);
1042 Int_t celldataY = pmdcl->GetClusCellY(ihit);
1043 Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
1044 Int_t celldataPid = pmdcl->GetClusCellPid(ihit);
1045 Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
1046 AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
1054 // Added single isolated cell for offline gain calibration
1055 nentries1 = pmdisocell->GetEntries();
1056 AliDebug(1,Form("Total number of isolated single cell clusters = %d",nentries1));
1058 for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
1060 pmdiso = (AliPMDisocell*)pmdisocell->UncheckedAt(ient1);
1061 idet = pmdiso->GetDetector();
1062 ismn = pmdiso->GetSmn();
1063 clusdata[0] = (Float_t) pmdiso->GetRow();
1064 clusdata[1] = (Float_t) pmdiso->GetCol();
1065 clusdata[2] = pmdiso->GetADC();
1070 AddRecPoint(idet,ismn,clusdata);
1072 pmdisocell->Delete();
1080 for (Int_t i=0; i<iSMN; i++)
1082 for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
1084 for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
1091 fPMDLoader = fRunLoader->GetLoader("PMDLoader");
1092 fPMDLoader->WriteRecPoints("OVERWRITE");
1094 // delete the pointers
1099 // ------------------------------------------------------------------------- //
1100 void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
1104 // ------------------------------------------------------------------------- //
1105 void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
1107 // Add Reconstructed points
1109 TClonesArray &lrecpoints = *fRecpoints;
1110 AliPMDrecpoint1 *newrecpoint;
1111 newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
1112 new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
1115 // ------------------------------------------------------------------------- //
1116 void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY,
1117 Int_t celldataTr, Int_t celldataPid,
1118 Float_t celldataAdc)
1120 // Add associated cell hits to the Reconstructed points
1122 TClonesArray &lrechits = *fRechits;
1123 AliPMDrechit *newrechit;
1124 newrechit = new AliPMDrechit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
1125 new(lrechits[fNhit++]) AliPMDrechit(newrechit);
1128 // ------------------------------------------------------------------------- //
1129 void AliPMDClusterFinder::ResetCellADC()
1131 // Reset the individual cell ADC value to zero
1133 for(Int_t irow = 0; irow < fgkRow; irow++)
1135 for(Int_t icol = 0; icol < fgkCol; icol++)
1137 fCellTrack[irow][icol] = -1;
1138 fCellPid[irow][icol] = -1;
1139 fCellADC[irow][icol] = 0.;
1143 // ------------------------------------------------------------------------- //
1144 void AliPMDClusterFinder::ResetRecpoint()
1146 // Clear the list of reconstructed points
1148 if (fRecpoints) fRecpoints->Clear();
1150 // ------------------------------------------------------------------------- //
1151 void AliPMDClusterFinder::ResetRechit()
1153 // Clear the list of reconstructed points
1155 if (fRechits) fRechits->Clear();
1157 // ------------------------------------------------------------------------- //
1158 void AliPMDClusterFinder::Load()
1160 // Load all the *.root files
1162 fPMDLoader->LoadDigits("READ");
1163 fPMDLoader->LoadRecPoints("recreate");
1165 // ------------------------------------------------------------------------- //
1166 void AliPMDClusterFinder::LoadClusters()
1168 // Load all the *.root files
1170 fPMDLoader->LoadRecPoints("recreate");
1172 // ------------------------------------------------------------------------- //
1173 void AliPMDClusterFinder::UnLoad()
1175 // Unload all the *.root files
1177 fPMDLoader->UnloadDigits();
1178 fPMDLoader->UnloadRecPoints();
1180 // ------------------------------------------------------------------------- //
1181 void AliPMDClusterFinder::UnLoadClusters()
1183 // Unload all the *.root files
1185 fPMDLoader->UnloadRecPoints();
1187 // ------------------------------------------------------------------------- //
1188 AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
1190 // The run number will be centralized in AliCDBManager,
1191 // you don't need to set it here!
1193 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
1195 if(!entry) AliFatal("Calibration object retrieval failed! ");
1197 AliPMDCalibData *calibdata=0;
1198 if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
1200 if (!calibdata) AliFatal("No calibration data from calibration database !");
1204 // ------------------------------------------------------------------------- //
1205 AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
1207 // The run number will be centralized in AliCDBManager,
1208 // you don't need to set it here!
1209 AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
1211 if(!entry) AliFatal("Pedestal object retrieval failed!");
1213 AliPMDPedestal *pedestal = 0;
1214 if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
1216 if (!pedestal) AliFatal("No pedestal data from pedestal database !");