LCOV - code coverage report
Current view: top level - PHOS/PHOSrec - AliPHOSAodCluster.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 109 0.9 %
Date: 2016-06-14 17:26:59 Functions: 1 14 7.1 %

          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             : //  AliAODCaloCluster extension for PHOS to recalculate cluster 
      18             : //  parameters in case of recalibration.
      19             : //*--
      20             : //*-- Author: Dmitri Peressounko (RRC KI)
      21             : 
      22             : 
      23             : // --- ROOT system ---
      24             : #include "TVector3.h"
      25             : #include "TMath.h"
      26             : 
      27             : // --- Standard library ---
      28             : 
      29             : // --- AliRoot header files ---
      30             : #include "AliLog.h" 
      31             : #include "AliPHOSGeometry.h" 
      32             : #include "AliPHOSPIDv1.h" 
      33             : #include "AliPHOSReconstructor.h" 
      34             : #include "AliPHOSAodCluster.h" 
      35             : #include "AliPHOSCalibData.h"
      36             : #include "AliAODCaloCells.h"
      37             : 
      38          20 : ClassImp(AliPHOSAodCluster)
      39             : 
      40             : //____________________________________________________________________________
      41             : AliPHOSAodCluster::AliPHOSAodCluster() : 
      42           0 :   AliAODCaloCluster(),fRecalibrated(0)
      43           0 : {
      44             :   // ctor
      45           0 : }
      46             : //____________________________________________________________________________
      47             : AliPHOSAodCluster::AliPHOSAodCluster(const AliAODCaloCluster & clu) : 
      48           0 :   AliAODCaloCluster(clu),fRecalibrated(0)
      49           0 : {
      50             :   // cpy ctor
      51           0 : }
      52             : 
      53             : //____________________________________________________________________________
      54             : AliPHOSAodCluster::~AliPHOSAodCluster()
      55           0 : {
      56             :   // dtor
      57           0 : }
      58             : //____________________________________________________________________________
      59             : void AliPHOSAodCluster::Recalibrate(AliPHOSCalibData * calibData,AliAODCaloCells *phsCells){
      60             :   //If not done yet, apply recalibration coefficients to energies list
      61             :   //NOTE that after recalibration fCellsAmpFraction contains not FRACTION but FULL energy 
      62             :   
      63           0 :   if(fRecalibrated)
      64             :    return ;
      65             :   
      66           0 :   if(!calibData)
      67             :     return ;
      68             : 
      69           0 :   AliPHOSGeometry * phosgeom =  AliPHOSGeometry::GetInstance() ;
      70           0 :   if(!phosgeom)
      71           0 :     AliFatal("AliPHOSGeometry was not contructed\n") ;
      72             :         
      73           0 :   Double32_t * cellsAmpFraction = GetCellsAmplitudeFraction(); 
      74             :         
      75           0 :   for(Int_t i=0; i < GetNCells(); i++){
      76           0 :     Int_t relId[4];
      77           0 :     phosgeom->AbsToRelNumbering(GetCellAbsId(i),relId) ;
      78           0 :     Int_t   module = relId[0];
      79           0 :     Int_t   column = relId[3];
      80           0 :     Int_t   row    = relId[2];
      81           0 :     Double_t energy = phsCells->GetCellAmplitude(GetCellAbsId(i)) ;
      82           0 :     cellsAmpFraction[i]*=energy*calibData->GetADCchannelEmc(module,column,row);
      83           0 :   }
      84             :         
      85           0 :   SetCellsAmplitudeFraction(cellsAmpFraction);
      86           0 :   fRecalibrated=kTRUE; 
      87           0 : }
      88             : //____________________________________________________________________________
      89             : void  AliPHOSAodCluster::EvalAll(Float_t logWeight, TVector3 &vtx){
      90             :     //If recalibrated - recalculate all cluster parameters
      91           0 :   if(!fRecalibrated)
      92             :     return ;
      93             : 
      94           0 :   EvalEnergy() ; //Energy should be evaluated first
      95           0 :   EvalCoord(logWeight, vtx) ;
      96             :   
      97           0 : }
      98             : //____________________________________________________________________________
      99             : void AliPHOSAodCluster::EvalEnergy(){
     100           0 :   if(!fRecalibrated) // no need to recalibrate
     101             :     return ;
     102             :     
     103             :   Float_t energy=0. ;
     104           0 :   for(Int_t iDigit=0; iDigit < GetNCells(); iDigit++) {
     105           0 :     energy+=GetCellAmplitudeFraction(iDigit) ;
     106             :   }
     107             :   
     108           0 :   SetE(energy);
     109             :   //Correct for nonlinearity later
     110             :    
     111           0 : }
     112             : //____________________________________________________________________________
     113             : void AliPHOSAodCluster::EnergyCorrection(){
     114             :   //apply nonlinearity correction same as in AliPHOSPIDv1.
     115           0 :   SetE(AliPHOSReconstructor::CorrectNonlinearity(E())) ;
     116           0 : }
     117             : //____________________________________________________________________________
     118             : void AliPHOSAodCluster::EvalPID(AliPHOSPIDv1 * /*pid*/){           
     119             :   //re-evaluate identification parameters
     120             : //  pid->CalculatePID(E(),GetDispersion(),GetEmcCpvDistance(),GetTOF(),GetPID()) ;  
     121             : //  pid->CalculatePID(E(),GetDispersion(),GetM20(),GetM02(),GetEmcCpvDistance(),GetTOF(),GetPID()) ;
     122           0 : }
     123             : //____________________________________________________________________________
     124             : void AliPHOSAodCluster::EvalCoord(Float_t logWeight, TVector3 &vtx)
     125             : {
     126             :   // Calculates new center of gravity in the local PHOS-module coordinates 
     127             :   // and tranfers into global ALICE coordinates
     128             :   // Calculates Dispersion and main axis
     129           0 :   if(!fRecalibrated) // no need to recalibrate
     130             :     return ;
     131             :  
     132             :   Float_t wtot = 0. ;
     133           0 :   Int_t relid[4] ;
     134             :   Int_t phosMod=0 ;
     135             :   Float_t xMean = 0. ;
     136             :   Float_t zMean = 0. ;
     137             : 
     138           0 :   AliPHOSGeometry * phosgeom =  AliPHOSGeometry::GetInstance() ;
     139           0 :   if(!phosgeom)
     140           0 :     AliFatal("AliPHOSGeometry was not contructed\n") ;
     141             : 
     142           0 :   for(Int_t iDigit=0; iDigit < GetNCells(); iDigit++) {
     143           0 :     Float_t xi ;
     144           0 :     Float_t zi ;
     145           0 :     phosgeom->AbsToRelNumbering(GetCellAbsId(iDigit), relid) ;
     146           0 :     phosgeom->RelPosInModule(relid, xi, zi);
     147           0 :     phosMod=relid[0] ;
     148           0 :     Double_t ei=GetCellAmplitudeFraction(iDigit) ;
     149           0 :     if (E() > 0 && ei > 0) {
     150           0 :       Float_t w = TMath::Max( 0., logWeight + TMath::Log(ei/E()) ) ;
     151           0 :       xMean+= xi * w ;
     152           0 :       zMean+= zi * w ;
     153           0 :       wtot += w ;
     154           0 :     }
     155             :     else
     156           0 :       AliError(Form("Wrong energy %f and/or amplitude %f\n", ei, E()));
     157           0 :   }
     158           0 :   if (wtot>0) {
     159           0 :     xMean /= wtot ;
     160           0 :     zMean /= wtot ;
     161           0 :   }
     162             : //  else
     163             : //    AliError(Form("Wrong weight %f\n", wtot));
     164             : 
     165             : 
     166             : // Calculates the dispersion and second momenta
     167             :   Double_t d=0. ;
     168             :   Double_t dxx  = 0.;
     169             :   Double_t dzz  = 0.;
     170             :   Double_t dxz  = 0.;
     171           0 :   for(Int_t iDigit=0; iDigit < GetNCells(); iDigit++) {
     172           0 :     Float_t xi ;
     173           0 :     Float_t zi ;
     174           0 :     phosgeom->AbsToRelNumbering(GetCellAbsId(iDigit), relid) ;
     175           0 :     phosgeom->RelPosInModule(relid, xi, zi);
     176           0 :     Double_t ei=GetCellAmplitudeFraction(iDigit) ;
     177           0 :     if (E() > 0 && ei > 0) {
     178           0 :       Float_t w = TMath::Max( 0., logWeight + TMath::Log(ei/E()) ) ;
     179           0 :       d += w*((xi-xMean)*(xi-xMean) + (zi-zMean)*(zi-zMean) ) ; 
     180           0 :       dxx  += w * xi * xi ;
     181           0 :       dzz  += w * zi * zi ;
     182           0 :       dxz  += w * xi * zi ; 
     183           0 :    }
     184             :     else
     185           0 :       AliError(Form("Wrong energy %f and/or amplitude %f\n", ei, E()));
     186           0 :   }
     187             :   
     188           0 :   if (wtot>0) {
     189           0 :     d /= wtot ;
     190           0 :     dxx /= wtot ;
     191           0 :     dzz /= wtot ;
     192           0 :     dxz /= wtot ;
     193           0 :     dxx -= xMean * xMean ;
     194           0 :     dzz -= zMean * zMean ;
     195           0 :     dxz -= xMean * zMean ;
     196           0 :     SetM02(0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz )) ;
     197           0 :     SetM20(0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ));
     198           0 :   }
     199             :   else{
     200             : //    AliError(Form("Wrong weight %f\n", wtot));
     201             :     d=0. ;
     202           0 :     SetM20(0.) ;
     203           0 :     SetM02(0.) ;
     204             :   }
     205             : 
     206           0 :   if (d>=0)
     207           0 :     SetDispersion(TMath::Sqrt(d)) ;
     208             :   else    
     209           0 :     SetDispersion(0) ;
     210             : 
     211             : 
     212             :   // Correction for the depth of the shower starting point (TDR p 127)  
     213             :   Float_t para = 0.925 ; 
     214             :   Float_t parb = 6.52 ; 
     215             : 
     216           0 :   TVector3 vInc ;
     217           0 :   phosgeom->GetIncidentVector(vtx,phosMod,xMean,zMean,vInc) ;
     218             : 
     219             :   Float_t depthx = 0.; 
     220             :   Float_t depthz = 0.;
     221           0 :   if (E()>0&&vInc.Y()!=0.) {
     222           0 :     depthx = ( para * TMath::Log(E()) + parb ) * vInc.X()/TMath::Abs(vInc.Y()) ;
     223           0 :     depthz = ( para * TMath::Log(E()) + parb ) * vInc.Z()/TMath::Abs(vInc.Y()) ;
     224           0 :   }
     225             :   else 
     226           0 :     AliError(Form("Wrong amplitude %f\n", E()));
     227             : 
     228           0 :   xMean-= depthx  ;
     229           0 :   zMean-= depthz  ;
     230             : 
     231             :   //Go to the global system
     232           0 :   TVector3 gps ;
     233           0 :   phosgeom->Local2Global(phosMod, xMean, zMean, gps) ;
     234           0 :   SetPositionAt(gps[0],0) ;
     235           0 :   SetPositionAt(gps[1],1) ;  
     236           0 :   SetPositionAt(gps[2],2) ;
     237           0 : }

Generated by: LCOV version 1.11