LCOV - code coverage report
Current view: top level - HMPID/HMPIDrec - AliHMPIDReconstructor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 88 97 90.7 %
Date: 2016-06-14 17:26:59 Functions: 7 7 100.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             : // HMPID base class to reconstruct an event
      17             : //.
      18             : //.
      19             : //.
      20             : #include "AliHMPIDReconstructor.h" //class header
      21             : #include "AliHMPID.h"              //Reconstruct() 
      22             : #include "AliHMPIDCluster.h"       //Dig2Clu()
      23             : #include "AliHMPIDPid.h"           //FillEsd() 
      24             : #include "AliHMPIDParam.h"         //FillEsd() 
      25             : #include <AliCDBEntry.h>           //ctor
      26             : #include <AliCDBManager.h>         //ctor
      27             : #include <AliESDEvent.h>           //FillEsd()
      28             : #include <AliRawReader.h>          //Reconstruct() for raw digits
      29             : #include <AliLog.h>                //
      30             : #include "AliHMPIDRawStream.h"     //ConvertDigits()
      31             : #include "AliHMPIDRecoParamV1.h"     //ctor
      32             : #include <TVirtualFitter.h> 
      33          12 : ClassImp(AliHMPIDReconstructor)
      34             : 
      35             : Int_t AliHMPIDReconstructor::fgStreamLevel = 0;        // stream (debug) level
      36             : 
      37             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      38           4 : AliHMPIDReconstructor::AliHMPIDReconstructor():AliReconstructor(),fDaqSig(0),fDig(0),fClu(0)
      39          10 : {
      40             : //
      41             : //ctor
      42             : //
      43           2 :   AliHMPIDParam::Instance();                                                        //geometry loaded for reconstruction
      44             : 
      45           6 :   fClu=new TObjArray(AliHMPIDParam::kMaxCh+1); fClu->SetOwner(kTRUE);
      46           6 :   fDig=new TObjArray(AliHMPIDParam::kMaxCh+1); fDig->SetOwner(kTRUE);
      47             :   
      48          32 :   for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){ 
      49          42 :     fDig->AddAt(new TClonesArray("AliHMPIDDigit",24000),i);
      50          28 :     TClonesArray *pClus = new TClonesArray("AliHMPIDCluster",24000);
      51          14 :     pClus->SetUniqueID(i);
      52          14 :     fClu->AddAt(pClus,i);
      53             :   }
      54             :  
      55           8 :   AliCDBEntry *pDaqSigEnt =AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig");  //contains TObjArray of TObjArray 14 TMatrixF sigmas values for pads 
      56           4 :   if(pDaqSigEnt) fDaqSig = (TObjArray*)pDaqSigEnt->GetObject();
      57           0 :   else AliFatal("No pedestals from DAQ!");
      58          32 :   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){                  //chambers loop 
      59          70 :     AliDebug(1,Form("DaqSigCut successfully loaded for chamber %i -> %i ",iCh,(Int_t)fDaqSig->At(iCh)->GetUniqueID()));
      60             :   }
      61           4 : }//AliHMPIDReconstructor
      62             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      63             : void AliHMPIDReconstructor::Dig2Clu(TObjArray *pDigAll,TObjArray *pCluAll,Int_t *pUserCut,Bool_t isTryUnfold)
      64             : {
      65             : // Finds all clusters for a given digits list provided not empty. Currently digits list is a list of all digits for a single chamber.
      66             : // Puts all found clusters in separate lists, one per clusters. 
      67             : // Arguments: pDigAll     - list of digits for all chambers 
      68             : //            pCluAll     - list of clusters for all chambers
      69             : //            isTryUnfold - flag to choose between CoG and Mathieson fitting  
      70             : //  Returns: none    
      71             : 
      72           8 :   TMatrixF padMap(AliHMPIDParam::kMinPx,AliHMPIDParam::kMaxPcx,AliHMPIDParam::kMinPy,AliHMPIDParam::kMaxPcy);  //pads map for single chamber 0..159 x 0..143 
      73             :   
      74         128 :   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){                  //chambers loop 
      75         112 :     TClonesArray *pDigCur=(TClonesArray*)pDigAll->At(iCh);                                //get list of digits for current chamber
      76         126 :     if(pDigCur->GetEntriesFast()==0) continue;                                            //no digits for current chamber
      77             :   
      78          42 :     padMap=(Float_t)-1;                                                                   //reset map to -1 (means no digit for this pad)  
      79          84 :     TClonesArray *pCluCur=(TClonesArray*)pCluAll->At(iCh);                                //get list of clusters for current chamber
      80             :     
      81        2862 :     for(Int_t iDig=0;iDig<pDigCur->GetEntriesFast();iDig++){                              //digits loop to fill pads map
      82        1824 :       AliHMPIDDigit *pDig= (AliHMPIDDigit*)pDigCur->At(iDig);                             //get current digit
      83        3648 :       padMap( pDig->PadChX(), pDig->PadChY() )=iDig;                                      //fill the map, (padx,pady) cell takes digit index
      84             :     }//digits loop to fill digits map 
      85             :     
      86          42 :     AliHMPIDCluster clu;                                                                  //tmp cluster to be used as current
      87        2862 :     for(Int_t iDig=0;iDig<pDigCur->GetEntriesFast();iDig++){                              //digits loop for current chamber
      88        1824 :       AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCur->At(iDig);                              //take current digit
      89        4136 :       if(!(pDig=UseDig(pDig->PadChX(),pDig->PadChY(),pDigCur,&padMap))) continue;         //this digit is already taken in FormClu(), go after next digit
      90         424 :       FormClu(&clu,pDig,pDigCur,&padMap);                                                 //form cluster starting from this digit by recursion
      91         424 :       clu.Solve(pCluCur,pUserCut,isTryUnfold);                                 //solve this cluster and add all unfolded clusters to provided list  
      92         424 :       clu.Reset();                                                                        //empty current cluster
      93         424 :     }//digits loop for current chamber
      94          42 :   }//chambers loop
      95           8 : }//Dig2Clu()
      96             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      97             : void  AliHMPIDReconstructor::FormClu(AliHMPIDCluster *pClu,AliHMPIDDigit *pDig,TClonesArray *pDigLst,TMatrixF *pDigMap)
      98             : {
      99             : // Forms the initial cluster as a combination of all adjascent digits. Starts from the given digit then calls itself recursevly  for all neighbours.
     100             : // Arguments: pClu - pointer to cluster being formed
     101             : //   Returns: none   
     102        1824 :   pClu->DigAdd(pDig);//take this digit in cluster
     103             : 
     104         912 :   Int_t cnt=0,cx[4],cy[4];
     105             :   
     106        1823 :   if(pDig->PadPcX() != AliHMPIDParam::kMinPx){cx[cnt]=pDig->PadChX()-1; cy[cnt]=pDig->PadChY()  ;cnt++;}       //left
     107        1822 :   if(pDig->PadPcX() != AliHMPIDParam::kMaxPx){cx[cnt]=pDig->PadChX()+1; cy[cnt]=pDig->PadChY()  ;cnt++;}       //right
     108        1815 :   if(pDig->PadPcY() != AliHMPIDParam::kMinPy){cx[cnt]=pDig->PadChX()  ; cy[cnt]=pDig->PadChY()-1;cnt++;}       //down
     109        1799 :   if(pDig->PadPcY() != AliHMPIDParam::kMaxPy){cx[cnt]=pDig->PadChX()  ; cy[cnt]=pDig->PadChY()+1;cnt++;}       //up
     110             :   
     111        9046 :   for (Int_t i=0;i<cnt;i++){//neighbours loop
     112        4099 :     if((pDig=UseDig(cx[i],cy[i],pDigLst,pDigMap))) FormClu(pClu,pDig,pDigLst,pDigMap);   //check if this neighbour pad fired and mark it as taken  
     113             :   }//neighbours loop  
     114         912 : }//FormClu()
     115             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     116             : void AliHMPIDReconstructor::Reconstruct(TTree *pDigTree,TTree *pCluTree)const
     117             : {
     118             : //Invoked  by AliReconstruction to convert digits to clusters i.e. reconstruct simulated data
     119             : //Arguments: pDigTree - pointer to Digit tree
     120             : //           pCluTree - poitner to Cluster tree
     121             : //  Returns: none    
     122          32 :   AliDebug(1,"Start.");
     123         128 :   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
     124          56 :     pCluTree->Branch(Form("HMPID%d",iCh),&((*fClu)[iCh]),7);
     125          56 :     pDigTree->SetBranchAddress(Form("HMPID%d",iCh),&((*fDig)[iCh]));
     126             :   }   
     127             :   
     128           8 :   Int_t pUserCut[7];
     129             :   
     130           8 :    if(AliHMPIDReconstructor::GetRecoParam()) {
     131         128 :     for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
     132          56 :       pUserCut[iCh] = AliHMPIDReconstructor::GetRecoParam()->GetHmpUserCut(iCh);
     133         168 :       AliDebug(1,Form("UserCut successfully loaded (from AliHMPIDRecoParamV1) for chamber %i -> %i ",iCh,pUserCut[iCh]));
     134             :     }
     135           8 :   }
     136             :   else {
     137           0 :     for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
     138           0 :       pUserCut[iCh] = 4;                                                                             // minimal requirement for sigma cut
     139           0 :       AliDebug(1,Form("UserCut loaded from defaults for chamber %i -> %i ",iCh,pUserCut[iCh]));
     140           0 :       AliDebug(1,Form("Cannot get AliHMPIDRecoParamV1!"));
     141             :       }
     142             :     }  
     143           8 :   TVirtualFitter* fitter = TVirtualFitter::GetFitter();
     144          11 :   delete fitter;
     145           8 :   fitter = TVirtualFitter::Fitter(0,3*6); // create a new fitter to avoid interferrence with others
     146           8 :   pDigTree->GetEntry(0);
     147           8 :   Dig2Clu(fDig,fClu,pUserCut);     //cluster finder 
     148           8 :   pCluTree->Fill();                //fill tree for current event
     149          16 :   delete fitter;
     150         128 :   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
     151          56 :     fDig->At(iCh)->Clear();
     152          56 :     fClu->At(iCh)->Clear();
     153             :   }
     154             :   
     155             :   
     156          24 :   AliDebug(1,"Stop.");      
     157           8 : }//Reconstruct(for simulated digits)
     158             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     159             : void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)const
     160             : {
     161             : //Invoked  by AliReconstruction to convert raw digits from DDL files to digits
     162             : //Arguments: pRR - ALICE raw reader pointer
     163             : //           pDigTree - pointer to Digit tree
     164             : //  Returns: none    
     165          16 :   AliDebug(1,"Start.");
     166             : //  Int_t digcnt=0;
     167             :   
     168           4 :   Int_t iDigCnt[7]={0,0,0,0,0,0,0};
     169             : 
     170          64 :   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
     171          28 :     pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]));
     172             :   }
     173             :     
     174           4 :   Int_t pUserCut[7];
     175             :   
     176           4 :    if(AliHMPIDReconstructor::GetRecoParam()) {
     177          64 :     for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
     178          28 :       pUserCut[iCh] = AliHMPIDReconstructor::GetRecoParam()->GetHmpUserCut(iCh);
     179          84 :       AliDebug(1,Form("UserCut successfully loaded (from AliHMPIDRecoParamV1) for chamber %i -> %i ",iCh,pUserCut[iCh]));
     180             :     }
     181           4 :   }
     182             :   else {
     183           0 :     for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
     184           0 :       pUserCut[iCh] = 4;                                                                             // minimal requirement for sigma cut
     185           0 :       AliDebug(1,Form("UserCut loaded from defaults for chamber %i -> %i ",iCh,pUserCut[iCh]));
     186           0 :       AliDebug(1,Form("Cannot get AliHMPIDRecoParamV1!"));
     187             :       }
     188             :     }  
     189             :       
     190           4 :   AliHMPIDRawStream stream(pRR);    
     191             :   
     192         180 :   while(stream.Next())
     193             :   {
     194          56 :     Int_t ch = AliHMPIDParam::DDL2C(stream.GetDDLNumber());
     195        1174 :     for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) {
     196         531 :       AliHMPIDDigit dig(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]);
     197        1212 :       if(!IsDigSurvive(pUserCut,&dig)) continue; 
     198        1524 :       new((*((TClonesArray*)fDig->At(ch)))[iDigCnt[ch]++]) AliHMPIDDigit(dig); //add this digit to the tmp list 
     199         912 :     }
     200             :   }
     201             :   
     202           4 :   pDigTree->Fill();
     203             :   
     204         120 :   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++)fDig->At(iCh)->Clear();
     205             :   
     206             :   
     207          20 :   AliDebug(1,"Stop.");
     208           4 : }//Reconstruct digits from raw digits
     209             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Generated by: LCOV version 1.11