LCOV - code coverage report
Current view: top level - PMD/PMDrec - AliPMDClusterFinder.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 296 376 78.7 %
Date: 2016-06-14 17:26:59 Functions: 17 27 63.0 %

          Line data    Source code
       1             : /***************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       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             :  **************************************************************************/
      15             : 
      16             : //-----------------------------------------------------//
      17             : //                                                     //
      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)     // 
      22             : //                                                     //
      23             : //-----------------------------------------------------//
      24             : 
      25             : #include <Riostream.h>
      26             : #include <TTree.h>
      27             : #include <TObjArray.h>
      28             : #include <TClonesArray.h>
      29             : #include <TSystem.h>
      30             : 
      31             : #include "AliLog.h"
      32             : #include "AliRunLoader.h"
      33             : #include "AliLoader.h"
      34             : #include "AliRawReader.h"
      35             : 
      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 "AliPMDNoiseCut.h"
      49             : #include "AliPMDddlinfoData.h"
      50             : #include "AliPMDRecoParam.h"
      51             : #include "AliRecoParam.h"
      52             : #include "AliPMDReconstructor.h"
      53             : 
      54             : #include "AliDAQ.h"
      55             : #include "AliCDBManager.h"
      56             : #include "AliCDBEntry.h"
      57             : 
      58             : 
      59             : 
      60          12 : ClassImp(AliPMDClusterFinder)
      61             : 
      62           2 : AliPMDClusterFinder::AliPMDClusterFinder():
      63           2 :   fRunLoader(0),
      64           2 :   fPMDLoader(0),
      65           4 :   fCalibGain(GetCalibGain()),
      66           4 :   fCalibPed(GetCalibPed()),
      67           4 :   fCalibHot(GetCalibHot()),
      68           4 :   fNoiseCut(GetNoiseCut()),
      69           4 :   fDdlinfo(GetDdlinfoData()),
      70           2 :   fRecoParam(0x0),
      71           2 :   fTreeD(0),
      72           2 :   fTreeR(0),
      73           6 :   fDigits(new TClonesArray("AliPMDdigit", 1000)),
      74           6 :   fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
      75           6 :   fRechits(new TClonesArray("AliPMDrechit", 1000)),
      76           2 :   fNpoint(0),
      77           2 :   fNhit(0),
      78           2 :   fDetNo(0)
      79          10 : {
      80             : //
      81             : // Constructor
      82             : //
      83           4 : }
      84             : // ------------------------------------------------------------------------- //
      85           0 : AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
      86           0 :   fRunLoader(runLoader),
      87           0 :   fPMDLoader(runLoader->GetLoader("PMDLoader")),
      88           0 :   fCalibGain(GetCalibGain()),
      89           0 :   fCalibPed(GetCalibPed()),
      90           0 :   fCalibHot(GetCalibHot()),
      91           0 :   fNoiseCut(GetNoiseCut()),
      92           0 :   fDdlinfo(GetDdlinfoData()),
      93           0 :   fRecoParam(0x0),
      94           0 :   fTreeD(0),
      95           0 :   fTreeR(0),
      96           0 :   fDigits(new TClonesArray("AliPMDdigit", 1000)),
      97           0 :   fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
      98           0 :   fRechits(new TClonesArray("AliPMDrechit", 1000)),
      99           0 :   fNpoint(0),
     100           0 :   fNhit(0),
     101           0 :   fDetNo(0)
     102           0 : {
     103             : //
     104             : // Constructor
     105             : //
     106           0 : }
     107             : // ------------------------------------------------------------------------- //
     108             : AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder):
     109           0 :   TObject(finder),
     110           0 :   fRunLoader(0),
     111           0 :   fPMDLoader(0),
     112           0 :   fCalibGain(GetCalibGain()),
     113           0 :   fCalibPed(GetCalibPed()),
     114           0 :   fCalibHot(GetCalibHot()),
     115           0 :   fNoiseCut(GetNoiseCut()),
     116           0 :   fDdlinfo(GetDdlinfoData()),
     117           0 :   fRecoParam(0x0),
     118           0 :   fTreeD(0),
     119           0 :   fTreeR(0),
     120           0 :   fDigits(NULL),
     121           0 :   fRecpoints(NULL),
     122           0 :   fRechits(NULL),
     123           0 :   fNpoint(0),
     124           0 :   fNhit(0),
     125           0 :   fDetNo(0)
     126           0 : {
     127             :   // copy constructor
     128           0 :   AliError("Copy constructor not allowed");
     129           0 : }
     130             : // ------------------------------------------------------------------------- //
     131             : AliPMDClusterFinder &AliPMDClusterFinder::operator=(const AliPMDClusterFinder & /*finder*/)
     132             : {
     133             :  // assignment op
     134           0 :   AliError("Assignment Operator not allowed");
     135           0 :   return *this;
     136             : }
     137             : // ------------------------------------------------------------------------- //
     138             : AliPMDClusterFinder::~AliPMDClusterFinder()
     139           8 : {
     140             :   // Destructor
     141           2 :   if (fDigits)
     142             :     {
     143           2 :       fDigits->Clear();
     144             :     }
     145           2 :   if (fRecpoints)
     146             :     {
     147           2 :       fRecpoints->Clear();
     148             :     }
     149           2 :   if (fRechits)
     150             :     {
     151           2 :       fRechits->Clear();
     152             :     }
     153             : 
     154           4 : }
     155             : // ------------------------------------------------------------------------- //
     156             : 
     157             : void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree,
     158             :                                            TTree *clustersTree, Int_t gRecoMode)
     159             : {
     160             :   // Converts digits to recpoints after running clustering
     161             :   // algorithm on CPV plane and PREshower plane
     162             :   //
     163             :   // This algorithm is called during the reconstruction from digits
     164             : 
     165             :   Int_t    det  = 0, smn = 0;
     166             :   Int_t    xpos = 0, ypos = 0;
     167             :   Int_t    ismn = 0;
     168             :   Int_t    idet = 0;
     169             :   Float_t  adc  = 0.;
     170           8 :   Float_t  clusdata[6] = {0.,0.,0.,0.,0.,0.};
     171             : 
     172             :   AliPMDcluster *pmdcl = 0x0;
     173             : 
     174           4 :   TObjArray *pmdcont = new TObjArray();
     175             : 
     176           8 :   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
     177             : 
     178             :   // Fetch the reco param object
     179             : 
     180           4 :   fRecoParam = AliPMDReconstructor::GetRecoParam();
     181           4 :   if(fRecoParam == 0x0)
     182             :     {
     183           0 :        AliFatal("No Reco Param found for PMD!!!");
     184           0 :     }
     185             : 
     186             : 
     187             :   AliPMDdigit  *pmddigit;
     188           4 :   TBranch *branch = digitsTree->GetBranch("PMDDigit");
     189           4 :   branch->SetAddress(&fDigits);
     190             : 
     191           4 :   ResetRecpoint();
     192             : 
     193             :   Int_t bufsize = 16000;
     194           4 :   TBranch * branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize); 
     195           4 :   TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize); 
     196             : 
     197           4 :   Int_t nmodules = (Int_t) digitsTree->GetEntries();
     198             : 
     199         392 :   for (Int_t imodule = 0; imodule < nmodules; imodule++)
     200             :     {
     201             : 
     202             :       Int_t totADCMod = 0;
     203         192 :       ResetCellADC();
     204         192 :       digitsTree->GetEntry(imodule); 
     205         192 :       Int_t nentries = fDigits->GetLast();
     206         744 :       for (Int_t ient = 0; ient < nentries+1; ient++)
     207             :         {
     208         180 :           pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient);
     209             :           
     210         180 :           det    = pmddigit->GetDetector();
     211         180 :           smn    = pmddigit->GetSMNumber();
     212         180 :           xpos   = pmddigit->GetRow();
     213         180 :           ypos   = pmddigit->GetColumn();
     214         180 :           adc    = pmddigit->GetADC();
     215             : 
     216         180 :           if(det < 0 || det > 1)
     217             :             {
     218           0 :               AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
     219           0 :               continue; 
     220             :             }
     221         180 :           if(smn == -1 || smn > 23)
     222             :             {
     223           0 :               AliError(Form("*MODULE NUMBER WRONG %d *",smn));
     224           0 :               continue; 
     225             :             }
     226             : 
     227         180 :           if(xpos < 0 || xpos > 47 || ypos < 0 || ypos > 95)
     228             :             {
     229           0 :               AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
     230             :                             xpos, ypos));
     231           0 :               continue; 
     232             :             }
     233             :           
     234             :           // Pedestal Subtraction
     235         180 :           Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos);
     236         180 :           Int_t   pedrms1    = (Int_t) pedmeanrms%100;
     237         180 :           Float_t pedrms     = (Float_t)pedrms1/10.;
     238         180 :           Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
     239             :           //printf("%f %f\n",pedmean, pedrms);
     240             : 
     241         180 :           Float_t adc1 = adc - (pedmean + 3.0*pedrms);
     242             : 
     243             :           // Hot cell - set the cell adc = 0
     244         180 :           Float_t hotflag = fCalibHot->GetHotChannel(det,smn,xpos,ypos);
     245         180 :           if (hotflag == 1.) adc1 = 0;
     246             : 
     247             :           // CALIBRATION
     248         180 :           Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos);
     249             :           // printf("adc = %d gain = %f\n",adc,gain);
     250             : 
     251         180 :           adc = adc1*gain;
     252             : 
     253         180 :           fCellTrack[xpos][ypos] = pmddigit->GetTrackNumber();
     254         180 :           fCellPid[xpos][ypos] = pmddigit->GetTrackPid();
     255         180 :           fCellADC[xpos][ypos] = (Double_t) adc;
     256             : 
     257         180 :           totADCMod += (Int_t) adc;
     258             : 
     259         180 :         }
     260             : 
     261             :       idet = det;
     262             :       ismn = smn;
     263             : 
     264         335 :       if (totADCMod <= 0) continue;
     265             : 
     266             :       // Set the minimum noise cut per module before clustering
     267             : 
     268             :       // Int_t imod = idet*24 + ismn;
     269             : 
     270             : 
     271             :       // Int_t cluspar = fRecoParam->GetPbPbParam()->GetClusteringParam();
     272          49 :       AliPMDRecoParam * par = fRecoParam->GetPPParam();
     273          49 :       Int_t cluspar = par->GetClusteringParam();
     274          98 :       delete par;
     275             : 
     276             :       // Int_t cluspar = fRecoParam->GetCosmicParam()->GetClusteringParam();
     277             :       
     278             :       //_______________________________________________________// 
     279             :       //Added to switch Refine and crude Clustering - satya//
     280             :       // temporary solution - will be sorted out later
     281             :       /*cluspar = 1;
     282             :       static AliPMDRecoParam *reconp = NULL;
     283             :       reconp = (AliPMDRecoParam*)AliPMDReconstructor::GetRecoParam();
     284             :       if(!reconp) {
     285             :         cluspar = 1;
     286             :       } 
     287             :       else { 
     288             :         
     289             :       if( reconp->GetClusteringParam() == 1) 
     290             :         cluspar = 1;
     291             :       if( reconp->GetClusteringParam() == 2) 
     292             :         cluspar = 2;
     293             :         }
     294             : 
     295             :       */
     296             :       cluspar = gRecoMode;
     297             :       //_______________________________________________________// 
     298             :       
     299          49 :       pmdclust->SetClusteringParam(cluspar);
     300             : 
     301             :       Float_t encut = 4.;
     302          49 :       pmdclust->SetEdepCut(encut);
     303          49 :       pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
     304             :       
     305          49 :       Int_t nentries1 = pmdcont->GetEntries();
     306             : 
     307         147 :       AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
     308             : 
     309         270 :       for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
     310             :         {
     311          86 :           pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
     312          86 :           idet        = pmdcl->GetDetector();
     313          86 :           ismn        = pmdcl->GetSMN();
     314          86 :           clusdata[0] = pmdcl->GetClusX();
     315          86 :           clusdata[1] = pmdcl->GetClusY();
     316          86 :           clusdata[2] = pmdcl->GetClusADC();
     317          86 :           clusdata[3] = pmdcl->GetClusCells();
     318          86 :           clusdata[4] = pmdcl->GetClusSigmaX();
     319          86 :           clusdata[5] = pmdcl->GetClusSigmaY();
     320             : 
     321          86 :           AddRecPoint(idet,ismn,clusdata);
     322             : 
     323          86 :           Int_t ncell = (Int_t) clusdata[3];
     324          86 :           if (ncell > 19) ncell = 19;
     325         524 :           for(Int_t ihit = 0; ihit < ncell; ihit++)
     326             :             {
     327         176 :               Int_t celldataX = pmdcl->GetClusCellX(ihit);
     328         176 :               Int_t celldataY = pmdcl->GetClusCellY(ihit);
     329         176 :               Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
     330         176 :               Int_t celldataPid   = pmdcl->GetClusCellPid(ihit);
     331         176 :               Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
     332         176 :               AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
     333             :             }
     334          86 :           branch2->Fill();
     335          86 :           ResetRechit();
     336             :         }
     337          49 :       pmdcont->Delete();
     338             : 
     339          49 :       branch1->Fill();
     340          49 :       ResetRecpoint();
     341             : 
     342          49 :     } // modules
     343             : 
     344             : 
     345           4 :   ResetCellADC();
     346             : 
     347             :   //   delete the pointers
     348           8 :   delete pmdclust;
     349           8 :   delete pmdcont;
     350           4 : }
     351             : // ------------------------------------------------------------------------- //
     352             : 
     353             : void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
     354             :                                            TTree *clustersTree, Int_t gRecoMode)
     355             : {
     356             :   // Converts RAW data to recpoints after running clustering
     357             :   // algorithm on CPV and PREshower plane
     358             :   //
     359             :   // This method is called at the time of reconstruction from RAW data
     360             : 
     361             : 
     362             :   AliPMDddldata *pmdddl = 0x0;
     363             :   AliPMDcluster *pmdcl  = 0x0;
     364             : 
     365           8 :   Float_t  clusdata[6];
     366           4 :   TObjArray pmdddlcont;
     367             : 
     368           8 :   TObjArray *pmdcont = new TObjArray();
     369             : 
     370          12 :   AliPMDClustering *pmdclust = new AliPMDClusteringV1();
     371             : 
     372             :   // access the ddlinfo database to fetch  the no of modules per DDL
     373             : 
     374           4 :   Int_t moduleddl[6] = {0,0,0,0,0,0};
     375             : 
     376          56 :   for(Int_t jddl = 0; jddl < 6; jddl++)
     377             :     {
     378          48 :       moduleddl[jddl] = fDdlinfo->GetNoOfModulePerDdl(jddl);
     379             :     }
     380             : 
     381             :   // Set the minimum noise cut per module before clustering
     382             : 
     383           8 :   fRecoParam = AliPMDReconstructor::GetRecoParam();
     384             : 
     385           4 :   if(fRecoParam == 0x0)
     386             :     {
     387           0 :        AliFatal("No Reco Param found for PMD!!!");
     388             :     }
     389             : 
     390           4 :   ResetRecpoint();
     391             : 
     392             :   Int_t bufsize = 16000;
     393           4 :   TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize); 
     394             : 
     395           4 :   TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize); 
     396             : 
     397             :   const Int_t kRow = 48;
     398             :   const Int_t kCol = 96;
     399             : 
     400             :   Int_t idet = 0;
     401             :   Int_t iSMN = 0;
     402             : 
     403             :   Int_t indexDDL = -1;
     404           4 :   AliPMDRawStream pmdinput(rawReader);
     405             : 
     406          56 :   while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
     407             :     {
     408          16 :       iSMN = moduleddl[indexDDL];
     409             : 
     410             :       Int_t ***precpvADC;
     411          32 :       precpvADC = new int **[iSMN];
     412         608 :       for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow];
     413         416 :       for (Int_t i=0; i<iSMN;i++)
     414             :         {
     415       28032 :           for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol];
     416             :         }
     417         416 :       for (Int_t i = 0; i < iSMN; i++)
     418             :         {
     419       18816 :           for (Int_t j = 0; j < kRow; j++)
     420             :             {
     421     1787904 :               for (Int_t k = 0; k < kCol; k++)
     422             :                 {
     423      884736 :                   precpvADC[i][j][k] = 0;
     424             :                 }
     425             :             }
     426             :         }
     427          16 :       ResetCellADC();
     428             : 
     429             :       Int_t indexsmn = 0;
     430          16 :       Int_t ientries = pmdddlcont.GetEntries();
     431         392 :       for (Int_t ient = 0; ient < ientries; ient++)
     432             :         {
     433         180 :           pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
     434             :           
     435         180 :           Int_t det = pmdddl->GetDetector();
     436         180 :           Int_t smn = pmdddl->GetSMN();
     437             :           //Int_t mcm = pmdddl->GetMCM();
     438             :           //Int_t chno = pmdddl->GetChannel();
     439         180 :           Int_t row = pmdddl->GetRow();
     440         180 :           Int_t col = pmdddl->GetColumn();
     441         180 :           Int_t sig = pmdddl->GetSignal();
     442             : 
     443             : 
     444         180 :           if(det < 0 || det > 1)
     445             :             {
     446           0 :               AliError(Form("*CPV/PRE NUMBER WRONG %d *",det));
     447           0 :               continue; 
     448             :             }
     449         180 :           if(smn < 0 || smn > 23)
     450             :             {
     451           0 :               AliError(Form("*MODULE NUMBER WRONG %d *",smn));
     452           0 :               continue; 
     453             :             }
     454         180 :           if(row < 0 || row > 47 || col < 0 || col > 95)
     455             :             {
     456           0 :               AliError(Form("*Row %d and Column NUMBER %d NOT Valid *",
     457             :                             row, col));
     458             : 
     459           0 :               continue; 
     460             :             }
     461             : 
     462             :           // Pedestal Subtraction
     463         180 :           Int_t   pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col);
     464         180 :           Int_t   pedrms1    = (Int_t) pedmeanrms%100;
     465         180 :           Float_t pedrms     = (Float_t)pedrms1/10.;
     466         180 :           Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
     467             : 
     468             :           //printf("%f %f\n",pedmean, pedrms);
     469             : 
     470             :           // Float_t sig1 = (Float_t) sig;
     471         180 :           Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms);
     472             : 
     473             :           // Hot cell - set the cell adc = 0
     474         180 :           Float_t hotflag = fCalibHot->GetHotChannel(det,smn,row,col);
     475         180 :           if (hotflag == 1.) sig1 = 0;
     476             : 
     477             :           // CALIBRATION
     478         180 :           Float_t gain = fCalibGain->GetGainFact(det,smn,row,col);
     479             :           //printf("sig = %d gain = %f\n",sig,gain);
     480         180 :           sig = (Int_t) (sig1*gain);
     481             : 
     482         180 :           if (indexDDL == 0)
     483             :             {
     484         106 :               if (det != 0)
     485           0 :                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
     486             :                               indexDDL, det));
     487         106 :               if (iSMN == 6)
     488             :                 {
     489             :                   indexsmn = smn;
     490           0 :                 }
     491         106 :               else if (iSMN == 12)
     492             :                 {
     493         106 :                   if (smn < 6)
     494          84 :                     indexsmn = smn;
     495          22 :                   else if (smn >= 18 && smn < 24)
     496          22 :                     indexsmn = smn-12;
     497             :                 }
     498             :             }
     499          74 :           else if (indexDDL >= 1 && indexDDL < 4)
     500             :             {
     501          14 :               if (det != 0)
     502           0 :                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
     503             :                               indexDDL, det));
     504          14 :               indexsmn = smn - indexDDL * 6;
     505          14 :             }
     506          60 :           else if (indexDDL == 4)
     507             :             {
     508          34 :               if (det != 1)
     509           0 :                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
     510             :                               indexDDL, det));
     511          34 :               if (smn < 6)
     512             :                 {
     513             :                   indexsmn = smn;
     514          34 :                 }
     515           0 :               else if (smn >= 18 && smn < 24)
     516             :                 {
     517           0 :                   indexsmn = smn - 12;
     518           0 :                 }
     519             :             }
     520          26 :           else if (indexDDL == 5)
     521             :             {
     522          26 :               if (det != 1)
     523           0 :                 AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *",
     524             :                               indexDDL, det));
     525          26 :               if (smn >= 6 && smn < 18)
     526             :                 {
     527          26 :                   indexsmn = smn - 6;
     528          26 :                 }
     529             :             }         
     530             : 
     531         180 :           precpvADC[indexsmn][row][col] = sig;
     532         180 :         }
     533             :       
     534          16 :       pmdddlcont.Delete();
     535             : 
     536             :       Int_t totAdcMod = 0;
     537             : 
     538             :       Int_t ismn = 0;
     539         416 :       for (indexsmn = 0; indexsmn < iSMN; indexsmn++)
     540             :         {
     541         192 :           ResetCellADC();
     542             :           totAdcMod = 0;
     543       18816 :           for (Int_t irow = 0; irow < kRow; irow++)
     544             :             {
     545     1787904 :               for (Int_t icol = 0; icol < kCol; icol++)
     546             :                 {
     547      884736 :                   fCellTrack[irow][icol] = -1;
     548      884736 :                   fCellPid[irow][icol]   = -1;
     549             : 
     550      884736 :                   fCellADC[irow][icol] = 
     551      884736 :                     (Double_t) precpvADC[indexsmn][irow][icol];
     552      884736 :                   totAdcMod += precpvADC[indexsmn][irow][icol];
     553             :                 } // row
     554             :             }     // col
     555             :           
     556         192 :           if (indexDDL == 0)
     557             :             {
     558          48 :               if (iSMN == 6)
     559             :                 {
     560             :                   ismn = indexsmn;
     561           0 :                 }
     562          48 :               else if (iSMN == 12)
     563             :                 {
     564             :                   
     565          48 :                   if (indexsmn < 6)
     566          24 :                     ismn = indexsmn;
     567          24 :                   else if (indexsmn >= 6 && indexsmn < 12)
     568          24 :                     ismn = indexsmn + 12;
     569             :                 }
     570             :               idet = 0;
     571          48 :             }
     572         144 :           else if (indexDDL >= 1 && indexDDL < 4)
     573             :             {
     574          48 :               ismn = indexsmn + indexDDL * 6;
     575             :               idet = 0;
     576          48 :             }
     577          96 :           else if (indexDDL == 4)
     578             :             {
     579          48 :               if (indexsmn < 6)
     580             :                 {
     581             :                   ismn = indexsmn;
     582          24 :                 }
     583          24 :               else if (indexsmn >= 6 && indexsmn < 12)
     584             :                 {
     585          24 :                   ismn = indexsmn + 12;
     586          24 :                 }
     587             :               idet = 1;
     588          48 :             }
     589          48 :           else if (indexDDL == 5)
     590             :             {
     591          48 :               ismn = indexsmn + 6;
     592             :               idet = 1;
     593          48 :             }
     594             : 
     595         192 :           if (totAdcMod <= 0) continue;
     596             : 
     597          49 :           Int_t imod = idet*24 + ismn;
     598             : 
     599             :           // Int_t cluspar = fRecoParam->GetPbPbParam()->GetClusteringParam();
     600          49 :           AliPMDRecoParam * par = fRecoParam->GetPPParam();
     601          49 :            Int_t cluspar = par->GetClusteringParam();
     602          98 :            delete par;
     603             :           // Int_t cluspar = fRecoParam->GetCosmicParam()->GetClusteringParam();
     604             : 
     605             :           //_______________________________________________________// 
     606             :           //Added to switch Refine and crude Clustering - satya//
     607             :           // temporary solution - will be sorted out later
     608             :           /* cluspar = 1;
     609             :           static AliPMDRecoParam *reconp = NULL;
     610             :           reconp = (AliPMDRecoParam*)AliPMDReconstructor::GetRecoParam();
     611             :           if(!reconp) {
     612             :             cluspar = 1;
     613             :           } 
     614             :           else { 
     615             :             if( reconp->GetClusteringParam() == 1) 
     616             :               cluspar = 1;
     617             :             if( reconp->GetClusteringParam() == 2) 
     618             :               cluspar = 2;
     619             :           }*/
     620             : 
     621             : 
     622             :           cluspar = gRecoMode; // permanent solution
     623             : 
     624             :           //_______________________________________________________// 
     625             : 
     626          49 :           pmdclust->SetClusteringParam(cluspar);
     627          49 :           Float_t encut = fNoiseCut->GetNoiseCut(imod);
     628             : 
     629          49 :           pmdclust->SetEdepCut(encut);
     630          49 :           pmdclust->DoClust(idet,ismn,fCellTrack,fCellPid,fCellADC,pmdcont);
     631             : 
     632          49 :           Int_t nentries1 = pmdcont->GetEntries();
     633             : 
     634         245 :           AliDebug(1,Form("Total number of clusters/module = %d",nentries1));
     635             : 
     636         270 :           for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
     637             :             {
     638          86 :               pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
     639          86 :               idet        = pmdcl->GetDetector();
     640          86 :               ismn        = pmdcl->GetSMN();
     641         172 :               clusdata[0] = pmdcl->GetClusX();
     642         172 :               clusdata[1] = pmdcl->GetClusY();
     643         172 :               clusdata[2] = pmdcl->GetClusADC();
     644         172 :               clusdata[3] = pmdcl->GetClusCells();
     645         172 :               clusdata[4] = pmdcl->GetClusSigmaX();
     646         172 :               clusdata[5] = pmdcl->GetClusSigmaY();
     647             : 
     648          86 :               AddRecPoint(idet,ismn,clusdata);
     649             : 
     650          86 :               Int_t ncell = (Int_t) clusdata[3];
     651          86 :               if (ncell > 19) ncell = 19;
     652         524 :               for(Int_t ihit = 0; ihit < ncell; ihit++)
     653             :                 {
     654         176 :                   Int_t celldataX = pmdcl->GetClusCellX(ihit);
     655         176 :                   Int_t celldataY = pmdcl->GetClusCellY(ihit);
     656         176 :                   Int_t celldataTr = pmdcl->GetClusCellTrack(ihit);
     657         176 :                   Int_t celldataPid   = pmdcl->GetClusCellPid(ihit);
     658         176 :                   Float_t celldataAdc = pmdcl->GetClusCellAdc(ihit);
     659         176 :                   AddRecHit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
     660             :                 }
     661          86 :               branch2->Fill();
     662          86 :               ResetRechit();
     663             : 
     664             :             }
     665          49 :           pmdcont->Delete();
     666             : 
     667          49 :           branch1->Fill();
     668          49 :           ResetRecpoint();
     669             : 
     670             : 
     671          49 :         } // smn
     672             : 
     673         416 :       for (Int_t i=0; i<iSMN; i++)
     674             :         {
     675       37248 :           for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j];
     676             :         }
     677         800 :       for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
     678          32 :       delete [] precpvADC;
     679             : 
     680             :     } // DDL Loop
     681             : 
     682             :   
     683           4 :   ResetCellADC();
     684             :   
     685             :   //   delete the pointers
     686           8 :   delete pmdclust;
     687           8 :   delete pmdcont;
     688           4 : }
     689             : // ------------------------------------------------------------------------- //
     690             : void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
     691             : {
     692             :   // Add Reconstructed points
     693             :   //
     694         344 :   TClonesArray &lrecpoints = *fRecpoints;
     695             :   AliPMDrecpoint1 *newrecpoint;
     696         172 :   newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
     697         172 :   new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
     698         344 :   delete newrecpoint;
     699         172 : }
     700             : // ------------------------------------------------------------------------- //
     701             : void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY,
     702             :                                     Int_t celldataTr, Int_t celldataPid,
     703             :                                     Float_t celldataAdc)
     704             : {
     705             :   // Add associated cell hits to the Reconstructed points
     706             :   //
     707         704 :   TClonesArray &lrechits = *fRechits;
     708             :   AliPMDrechit *newrechit;
     709         352 :   newrechit = new AliPMDrechit(celldataX, celldataY, celldataTr, celldataPid, celldataAdc);
     710         352 :   new(lrechits[fNhit++]) AliPMDrechit(newrechit);
     711         704 :   delete newrechit;
     712         352 : }
     713             : // ------------------------------------------------------------------------- //
     714             : void AliPMDClusterFinder::ResetCellADC()
     715             : {
     716             :   // Reset the individual cell ADC value to zero
     717             :   //
     718       40392 :   for(Int_t irow = 0; irow < fgkRow; irow++)
     719             :     {
     720     3799296 :       for(Int_t icol = 0; icol < fgkCol; icol++)
     721             :         {
     722     1880064 :           fCellTrack[irow][icol] = -1;
     723     1880064 :           fCellPid[irow][icol]   = -1;
     724     1880064 :           fCellADC[irow][icol]   = 0.;
     725             :         }
     726             :     }
     727         408 : }
     728             : // ------------------------------------------------------------------------- //
     729             : void AliPMDClusterFinder::ResetRecpoint()
     730             : {
     731             :   // Clear the list of reconstructed points
     732         212 :   fNpoint = 0;
     733         212 :   if (fRecpoints) fRecpoints->Clear();
     734         106 : }
     735             : // ------------------------------------------------------------------------- //
     736             : void AliPMDClusterFinder::ResetRechit()
     737             : {
     738             :   // Clear the list of reconstructed points
     739         344 :   fNhit = 0;
     740         344 :   if (fRechits) fRechits->Clear();
     741         172 : }
     742             : // ------------------------------------------------------------------------- //
     743             : void AliPMDClusterFinder::Load()
     744             : {
     745             :   // Load all the *.root files
     746             :   //
     747           0 :   fPMDLoader->LoadDigits("READ");
     748           0 :   fPMDLoader->LoadRecPoints("recreate");
     749           0 : }
     750             : // ------------------------------------------------------------------------- //
     751             : void AliPMDClusterFinder::LoadClusters()
     752             : {
     753             :   // Load all the *.root files
     754             :   //
     755           0 :   fPMDLoader->LoadRecPoints("recreate");
     756           0 : }
     757             : // ------------------------------------------------------------------------- //
     758             : void AliPMDClusterFinder::UnLoad()
     759             : {
     760             :   // Unload all the *.root files
     761             :   //
     762           0 :   fPMDLoader->UnloadDigits();
     763           0 :   fPMDLoader->UnloadRecPoints();
     764           0 : }
     765             : // ------------------------------------------------------------------------- //
     766             : void AliPMDClusterFinder::UnLoadClusters()
     767             : {
     768             :   // Unload all the *.root files
     769             :   //
     770           0 :   fPMDLoader->UnloadRecPoints();
     771           0 : }
     772             : // ------------------------------------------------------------------------- //
     773             : AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const
     774             : {
     775             :   // The run number will be centralized in AliCDBManager,
     776             :   // you don't need to set it here!
     777             :   // Added by ZA
     778           6 :   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain");
     779             :   
     780           2 :   if(!entry)  AliFatal("Calibration object retrieval failed! ");
     781             :   
     782             :   AliPMDCalibData *calibdata=0;
     783           4 :   if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
     784             :   
     785           2 :   if (!calibdata)  AliFatal("No calibration data from calibration database !");
     786             :   
     787           2 :   return calibdata;
     788           0 : }
     789             : // ------------------------------------------------------------------------- //
     790             : AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const
     791             : {
     792             :   // The run number will be centralized in AliCDBManager,
     793             :   // you don't need to set it here!
     794           6 :   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped");
     795             :   
     796           2 :   if(!entry) AliFatal("Pedestal object retrieval failed!");
     797             :     
     798             :   AliPMDPedestal *pedestal = 0;
     799           4 :   if (entry) pedestal = (AliPMDPedestal*) entry->GetObject();
     800             :   
     801           2 :   if (!pedestal)  AliFatal("No pedestal data from pedestal database !");
     802             :   
     803           2 :   return pedestal;
     804           0 : }
     805             : //--------------------------------------------------------------------//
     806             : AliPMDHotData* AliPMDClusterFinder::GetCalibHot() const
     807             : {
     808             :   // The run number will be centralized in AliCDBManager,
     809             :   // you don't need to set it here!
     810           6 :   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Hot");
     811             :   
     812           2 :   if(!entry) AliFatal("HotData object retrieval failed!");
     813             :   
     814             :   AliPMDHotData *hot = 0;
     815           4 :   if (entry) hot = (AliPMDHotData*) entry->GetObject();
     816             :   
     817           2 :   if (!hot)  AliFatal("No hot data from  database !");
     818             :   
     819           2 :   return hot;
     820           0 : }
     821             : //--------------------------------------------------------------------//
     822             : AliPMDNoiseCut* AliPMDClusterFinder::GetNoiseCut() const
     823             : {
     824             :   // The run number will be centralized in AliCDBManager,
     825             :   // you don't need to set it here!
     826           6 :   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/NoiseCut");
     827             :   
     828           2 :   if(!entry) AliFatal("Noisecut object retrieval failed!");
     829             :   
     830             :   AliPMDNoiseCut *ncut = 0;
     831           4 :   if (entry) ncut = (AliPMDNoiseCut*) entry->GetObject();
     832             :   
     833           2 :   if (!ncut)  AliFatal("No noise cut data from  database !");
     834             :   
     835           2 :   return ncut;
     836           0 : }
     837             : //--------------------------------------------------------------------//
     838             : AliPMDddlinfoData* AliPMDClusterFinder::GetDdlinfoData() const
     839             : {
     840             :   // The run number will be centralized in AliCDBManager,
     841             :   // you don't need to set it here!
     842           6 :   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ddlinfo");
     843             :   
     844           2 :   if(!entry) AliFatal("ddlinfo object retrieval failed!");
     845             :   
     846             :   AliPMDddlinfoData *ddlinfo = 0;
     847           4 :   if (entry) ddlinfo = (AliPMDddlinfoData*) entry->GetObject();
     848             :   
     849           2 :   if (!ddlinfo)  AliFatal("No ddl info data from  database !");
     850             :   
     851           2 :   return ddlinfo;
     852           0 : }
     853             :   

Generated by: LCOV version 1.11