LCOV - code coverage report
Current view: top level - STEER/AOD - AliAODCaloCluster.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 65 216 30.1 %
Date: 2016-06-14 17:26:59 Functions: 11 22 50.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-2007, 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             : #include <TLorentzVector.h>
      17             : #include "AliLog.h"
      18             : #include "AliAODCaloCluster.h"
      19             : 
      20             : /// \cond CLASSIMP
      21         170 : ClassImp(AliAODCaloCluster) ;
      22             : /// \endcond
      23             : 
      24             : ///
      25             : /// Default constructor.
      26             : ///
      27             : //______________________________________________________________________________
      28             : AliAODCaloCluster::AliAODCaloCluster() : 
      29           2 :   AliAODCluster(),
      30           2 :   fDistToBadChannel(-999.),
      31           2 :   fDispersion(-1),
      32           2 :   fM20(0.),
      33           2 :   fM02(0.),
      34           2 :   fEmcCpvDistance(-999.),
      35           2 :   fTrackDx(-999),
      36           2 :   fTrackDz(-999),
      37           2 :   fNExMax(0), 
      38           2 :   fTOF(0.),
      39           2 :   fCoreEnergy(0.),
      40           2 :   fTracksMatched(),
      41           2 :   fNCells(0),
      42           2 :   fCellsAbsId(0x0),
      43           2 :   fCellsAmpFraction(0x0),
      44           2 :   fMCEnergyFraction(0.),
      45           2 :   fIsExotic(kFALSE),
      46           2 :   fCellsMCEdepFractionMap(0x0)
      47          10 : {
      48          24 :   for (Int_t i = 0; i <= kLastUserDefEnergy; i++) {
      49          10 :     fUserDefEnergy[i] = 1.;
      50             :   }
      51           4 : }
      52             : 
      53             : ///
      54             : /// Constructor.
      55             : ///
      56             : //______________________________________________________________________________
      57             : AliAODCaloCluster::AliAODCaloCluster(Int_t id,
      58             :                                      UInt_t nLabel,
      59             :                                      Int_t *label, 
      60             :                                      Double_t energy,
      61             :                                      Double_t x[3],
      62             :                                      Double_t pid[13],
      63             :                                      Char_t ttype,
      64             :                                      UInt_t selectInfo) :
      65           0 :   AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
      66           0 :   fDistToBadChannel(-999.),
      67           0 :   fDispersion(-1),
      68           0 :   fM20(0.),
      69           0 :   fM02(0.),
      70           0 :   fEmcCpvDistance(-999.),
      71           0 :   fTrackDx(-999),
      72           0 :   fTrackDz(-999),
      73           0 :   fNExMax(0),
      74           0 :   fTOF(0.),
      75           0 :   fCoreEnergy(0.),
      76           0 :   fTracksMatched(),
      77           0 :   fNCells(0),
      78           0 :   fCellsAbsId(0x0),
      79           0 :   fCellsAmpFraction(0x0),
      80           0 :   fMCEnergyFraction(0.),
      81           0 :   fIsExotic(kFALSE),
      82           0 :   fCellsMCEdepFractionMap(0x0)
      83           0 : {
      84           0 :   for (Int_t i = 0; i <= kLastUserDefEnergy; i++) {
      85           0 :     fUserDefEnergy[i] = 1.;
      86             :   }
      87           0 : }
      88             : 
      89             : ///
      90             : /// Constructor.
      91             : ///
      92             : //______________________________________________________________________________
      93             : AliAODCaloCluster::AliAODCaloCluster(Int_t id,
      94             :                                      UInt_t nLabel,
      95             :                                      Int_t *label, 
      96             :                                      Float_t energy,
      97             :                                      Float_t x[3],
      98             :                                      Float_t pid[13],
      99             :                                      Char_t ttype,
     100             :                                      UInt_t selectInfo) :
     101          43 :   AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
     102          43 :   fDistToBadChannel(-999.),
     103          43 :   fDispersion(-1),
     104          43 :   fM20(0.),
     105          43 :   fM02(0.),
     106          43 :   fEmcCpvDistance(-999.),
     107          43 :   fTrackDx(-999),
     108          43 :   fTrackDz(-999),
     109          43 :   fNExMax(0),
     110          43 :   fTOF(0.),
     111          43 :   fCoreEnergy(0.),
     112          43 :   fTracksMatched(),
     113          43 :   fNCells(0),
     114          43 :   fCellsAbsId(0x0),
     115          43 :   fCellsAmpFraction(0x0),
     116          43 :   fMCEnergyFraction(0.),
     117          43 :   fIsExotic(kFALSE),
     118          43 :   fCellsMCEdepFractionMap(0x0)
     119         215 : {
     120         516 :   for (Int_t i = 0; i <= kLastUserDefEnergy; i++) {
     121         215 :     fUserDefEnergy[i] = 1.;
     122             :   }
     123          86 : }
     124             : 
     125             : ///
     126             : /// Destructor.
     127             : ///
     128             : //______________________________________________________________________________
     129             : AliAODCaloCluster::~AliAODCaloCluster() 
     130         270 : {
     131         176 :   if(fCellsAmpFraction)       delete[] fCellsAmpFraction;       fCellsAmpFraction       = 0 ;
     132         176 :   if(fCellsAbsId)             delete[] fCellsAbsId;             fCellsAbsId             = 0 ;
     133         156 :   if(fCellsMCEdepFractionMap) delete[] fCellsMCEdepFractionMap; fCellsMCEdepFractionMap = 0 ;
     134         135 : }
     135             : 
     136             : ///
     137             : /// Clear array pointers.
     138             : ///
     139             : //______________________________________________________________________________
     140             : void AliAODCaloCluster::Clear(const Option_t*) 
     141             : {
     142           0 :   RemoveLabel();
     143           0 :   if(fCellsAmpFraction)       delete[] fCellsAmpFraction;       fCellsAmpFraction       = 0 ;
     144           0 :   if(fCellsAbsId)             delete[] fCellsAbsId;             fCellsAbsId             = 0 ;
     145           0 :   if(fCellsMCEdepFractionMap) delete[] fCellsMCEdepFractionMap; fCellsMCEdepFractionMap = 0 ;
     146           0 : }
     147             : 
     148             : ///
     149             : /// Copy constructor.
     150             : ///
     151             : //______________________________________________________________________________
     152             : AliAODCaloCluster::AliAODCaloCluster(const AliAODCaloCluster& clus) :
     153           0 :   AliAODCluster(clus),
     154           0 :   fDistToBadChannel(clus.fDistToBadChannel),
     155           0 :   fDispersion(clus.fDispersion),
     156           0 :   fM20(clus.fM20),
     157           0 :   fM02(clus.fM02),
     158           0 :   fEmcCpvDistance(clus.fEmcCpvDistance),
     159           0 :   fTrackDx(clus.fTrackDx),
     160           0 :   fTrackDz(clus.fTrackDz),
     161           0 :   fNExMax(clus.fNExMax),
     162           0 :   fTOF(clus.fTOF),
     163           0 :   fCoreEnergy(clus.fCoreEnergy),
     164           0 :   fTracksMatched(clus.fTracksMatched),
     165           0 :   fNCells(clus.fNCells),
     166           0 :   fCellsAbsId(0x0),
     167           0 :   fCellsAmpFraction(0x0),
     168           0 :   fMCEnergyFraction(clus.fMCEnergyFraction),
     169           0 :   fIsExotic(clus.fIsExotic),
     170           0 :   fCellsMCEdepFractionMap(0x0)
     171           0 : {
     172           0 :   if (clus.fNCells > 0) 
     173             :   {
     174           0 :     if(clus.fCellsAbsId)
     175             :     {
     176           0 :       fCellsAbsId = new UShort_t[clus.fNCells];
     177           0 :       for (Int_t i=0; i<clus.fNCells; i++)
     178           0 :         fCellsAbsId[i]=clus.fCellsAbsId[i];
     179           0 :     }
     180             :     
     181           0 :     if(clus.fCellsAmpFraction)
     182             :     {
     183           0 :       fCellsAmpFraction = new Double32_t[clus.fNCells];
     184           0 :       for (Int_t i=0; i<clus.fNCells; i++)
     185           0 :         fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
     186           0 :     }
     187             :     
     188           0 :     if(clus.fCellsMCEdepFractionMap)
     189             :     {
     190           0 :       fCellsMCEdepFractionMap = new UInt_t[clus.fNCells];
     191           0 :       for (Int_t i=0; i<clus.fNCells; i++) fCellsMCEdepFractionMap[i]=clus.fCellsMCEdepFractionMap[i];
     192           0 :     }
     193             :   }
     194             :   
     195           0 :   for (Int_t i = 0; i <= kLastUserDefEnergy; i++) 
     196           0 :     fUserDefEnergy[i] = clus.fUserDefEnergy[i];
     197             :   
     198           0 : }
     199             : 
     200             : ///
     201             : /// Assignment operator.
     202             : ///
     203             : //______________________________________________________________________________
     204             : AliAODCaloCluster& AliAODCaloCluster::operator=(const AliAODCaloCluster& clus)
     205             : {
     206           0 :   if(this!=&clus) 
     207             :   {
     208           0 :     AliAODCluster::operator=(clus);
     209             :     
     210           0 :     fDistToBadChannel = clus.fDistToBadChannel;
     211           0 :     fDispersion = clus.fDispersion;
     212           0 :     fM20 = clus.fM20;
     213           0 :     fM02 = clus.fM02;
     214           0 :     fEmcCpvDistance = clus.fEmcCpvDistance;
     215           0 :     fTrackDx=clus.fTrackDx;
     216           0 :     fTrackDz=clus.fTrackDz;
     217           0 :     fNExMax = clus.fNExMax;
     218           0 :     fTOF = clus.fTOF;
     219           0 :     fCoreEnergy = clus.fCoreEnergy;
     220           0 :     fTracksMatched = clus.fTracksMatched;
     221             :     
     222           0 :     fNCells= clus. fNCells;
     223             :     
     224             :     // delete anyway 
     225           0 :     if(fCellsAbsId)             delete [] fCellsAbsId;
     226           0 :     if(fCellsAmpFraction)       delete [] fCellsAmpFraction;
     227           0 :     if(fCellsMCEdepFractionMap) delete [] fCellsMCEdepFractionMap;
     228             :     
     229           0 :     if (clus.fNCells > 0) 
     230             :     {
     231           0 :       if(clus.fCellsAbsId)
     232             :       {
     233           0 :         fCellsAbsId = new UShort_t[clus.fNCells];
     234           0 :         for (Int_t i=0; i<clus.fNCells; i++)
     235           0 :           fCellsAbsId[i]=clus.fCellsAbsId[i];
     236           0 :       }
     237             :       
     238           0 :       if(clus.fCellsAmpFraction)
     239             :       {
     240           0 :         fCellsAmpFraction = new Double32_t[clus.fNCells];
     241           0 :         for (Int_t i=0; i<clus.fNCells; i++)
     242           0 :           fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
     243           0 :       }
     244             :       
     245           0 :       if(clus.fCellsMCEdepFractionMap)
     246             :       {
     247           0 :         fCellsMCEdepFractionMap = new UInt_t[clus.fNCells];
     248           0 :         for (Int_t i=0; i<clus.fNCells; i++) 
     249           0 :           fCellsMCEdepFractionMap[i]=clus.fCellsMCEdepFractionMap[i];
     250           0 :       }
     251             :     } // fNCells > 0
     252             :     
     253           0 :     fMCEnergyFraction = clus.fMCEnergyFraction;
     254           0 :     fIsExotic = clus.fIsExotic;
     255             :     
     256           0 :     for (Int_t i = 0; i <= kLastUserDefEnergy; i++) 
     257           0 :       fUserDefEnergy[i] = clus.fUserDefEnergy[i];
     258           0 :   }
     259             :   
     260           0 :   return *this;
     261             : }
     262             : 
     263             : ///
     264             : /// Checks if the given track contributed to this cluster.
     265             : ///
     266             : //_______________________________________________________________________
     267             : Bool_t AliAODCaloCluster::HasTrackMatched(TObject *trk) const
     268             : {
     269           0 :   TRefArrayIter iter(&fTracksMatched);
     270           0 :   while (TObject *track = iter.Next()) {
     271           0 :     if (trk == track) return kTRUE;
     272           0 :   }
     273           0 :   return kFALSE;
     274           0 : }
     275             : 
     276             : ///
     277             : /// Returns TLorentzVector with momentum of the cluster. Only valid for clusters 
     278             : /// identified as photons or pi0 (overlapped gamma) produced on the vertex
     279             : /// Vertex can be recovered with esd pointer doing:  
     280             : ///  " Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
     281             : ///
     282             : //_______________________________________________________________________
     283             : void AliAODCaloCluster::GetMomentum(TLorentzVector& p, const Double_t *vertex ) const
     284             : {
     285           0 :   Double32_t energy = E();
     286           0 :   Float_t    pos[3];
     287           0 :   GetPosition(pos);
     288             :   
     289           0 :   if(vertex){//calculate direction from vertex
     290           0 :     pos[0]-=vertex[0];
     291           0 :     pos[1]-=vertex[1];
     292           0 :     pos[2]-=vertex[2];
     293           0 :   }
     294             :   
     295           0 :   Double_t r = TMath::Sqrt(pos[0]*pos[0]+
     296           0 :                            pos[1]*pos[1]+
     297           0 :                            pos[2]*pos[2]   ) ; 
     298             :      
     299           0 :   if ( r > 0 ) 
     300           0 :     p.SetPxPyPzE( energy*pos[0]/r,  energy*pos[1]/r,  energy*pos[2]/r,  energy) ; 
     301             :   else
     302           0 :     AliInfo("Null cluster radius, momentum calculation not possible");
     303           0 : }
     304             : 
     305             : ///
     306             : /// Returns TLorentzVector with momentum of the cluster. Only valid for clusters 
     307             : /// identified as photons or pi0 (overlapped gamma) produced on the vertex
     308             : /// Uses the user defined energy t
     309             : /// Vertex can be recovered with esd pointer doing:  
     310             : ///  " Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
     311             : ///
     312             : //_______________________________________________________________________
     313             : void AliAODCaloCluster::GetMomentum(TLorentzVector& p, const Double_t *vertex, VCluUserDefEnergy_t t ) const
     314             : {
     315           0 :   Double32_t energy = GetUserDefEnergy(t);
     316           0 :   Float_t    pos[3];
     317           0 :   GetPosition(pos);
     318             :   
     319           0 :   if(vertex){//calculate direction from vertex
     320           0 :     pos[0]-=vertex[0];
     321           0 :     pos[1]-=vertex[1];
     322           0 :     pos[2]-=vertex[2];
     323           0 :   }
     324             :   
     325           0 :   Double_t r = TMath::Sqrt(pos[0]*pos[0]+
     326           0 :                            pos[1]*pos[1]+
     327           0 :                            pos[2]*pos[2]   ) ; 
     328             :   
     329           0 :   p.SetPxPyPzE( energy*pos[0]/r,  energy*pos[1]/r,  energy*pos[2]/r,  energy) ; 
     330           0 : }
     331             : 
     332             : ///
     333             : ///  Set the array of cell absolute Id. numbers. 
     334             : ///
     335             : //______________________________________________________________________________
     336             : void  AliAODCaloCluster::SetCellsAbsId(UShort_t *array)
     337             : {
     338          86 :     if (fNCells) {
     339          86 :       if(!fCellsAbsId)fCellsAbsId = new  UShort_t[fNCells];
     340         604 :       for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
     341          43 :     }
     342          43 : }
     343             : 
     344             : ///
     345             : ///  Set the array of cell amplitude fractions. 
     346             : ///  Cell can be shared between 2 clusters, here the fraction of energy
     347             : ///  assigned to each cluster is stored. Only in unfolded clusters.
     348             : ///
     349             : //______________________________________________________________________________
     350             : void  AliAODCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
     351             : {
     352          86 :     if (fNCells) {
     353          86 :       if(!fCellsAmpFraction)fCellsAmpFraction = new  Double32_t[fNCells];
     354         604 :       for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
     355          43 :     }
     356          43 : }
     357             : 
     358             : ///
     359             : /// \param cellIndex: position of cell in array fCellsAbsId
     360             : /// \param eDep: Filled float array with 4 entries, each is the fraction of deposited 
     361             : ///              energy by 4 most significant MC particles (GetLabels()) in a cell of the cluster.
     362             : /// In this method, the 4 fractions  stored in % values (0 to 100) 
     363             : /// in each bit of the integer fCellsMCEdepFractionMap[cellIndex] are unpacked. 
     364             : //______________________________________________________________________________
     365             : void  AliAODCaloCluster::GetCellMCEdepFractionArray(Int_t cellIndex, Float_t * eDep) const
     366             : { 
     367           0 :   if ( cellIndex >= fNCells || fNCells < 0 || !fCellsMCEdepFractionMap )
     368             :   {
     369           0 :     eDep[0] = eDep[1] = eDep[2] = eDep[3] = 0. ;
     370           0 :     return;
     371             :   }
     372             :   
     373           0 :   eDep[0] =  (fCellsMCEdepFractionMap[cellIndex]&0x000000ff)        / 100.;
     374           0 :   eDep[1] = ((fCellsMCEdepFractionMap[cellIndex]&0x0000ff00) >>  8) / 100.;
     375           0 :   eDep[2] = ((fCellsMCEdepFractionMap[cellIndex]&0x00ff0000) >> 16) / 100.;
     376           0 :   eDep[3] = ((fCellsMCEdepFractionMap[cellIndex]&0xff000000) >> 24) / 100.;  
     377           0 : }
     378             : 
     379             : ///
     380             : /// \param eDep: Float array with 4 entries, each is the fraction of deposited 
     381             : ///              energy by an MC particle in a cell of the cluster.
     382             : /// 
     383             : /// The MC particle must correspond one of the 4 first labels in GetLabels(). This method
     384             : /// packs the 4 floats into an integer, assigning each bit a value between 0 and 100
     385             : //______________________________________________________________________________
     386             : UInt_t  AliAODCaloCluster::PackMCEdepFraction(Float_t * eDep) const
     387             : { 
     388           0 :   UInt_t intEDep[4];
     389             :   
     390           0 :   for(Int_t i = 0; i < 4; i++)
     391           0 :     intEDep[i] = TMath::Nint(eDep[i]*100) ;
     392             :   
     393           0 :   UInt_t map = intEDep[0]|(intEDep[1]<<8)|(intEDep[2]<<16)|(intEDep[3]<<24);
     394             :   
     395           0 :   return map;
     396           0 : }
     397             : 
     398             : ///
     399             : /// Set the array with the fraction of deposited energy in a cell belonging to 
     400             : /// the cluster by a given primary  particle. Each entry of the array corresponds 
     401             : /// to the same entry in fCellsAbsId. Each entry is an integer where a maximum 
     402             : /// of 4 energy deposition fractions are encoded, each corresponding to the 
     403             : /// first 4 entries in GetLabels()
     404             : //______________________________________________________________________________
     405             : void  AliAODCaloCluster::SetCellsMCEdepFractionMap(UInt_t *array)
     406             : {
     407          86 :   if ( fNCells <= 0 || !array ) return; 
     408             :   
     409          33 :   fCellsMCEdepFractionMap = new  UInt_t[fNCells];
     410             :   
     411         260 :   for (Int_t i = 0; i < fNCells; i++) 
     412          97 :     fCellsMCEdepFractionMap[i] = array[i];
     413          43 : }
     414             : 
     415             : 
     416             : 

Generated by: LCOV version 1.11