1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //_________________________________________________________________________
17 // AliESDCaloCluster extension for PHOS to recalculate cluster
18 // parameters in case of recalibration.
20 //*-- Author: Dmitri Peressounko (RRC KI)
23 // --- ROOT system ---
27 // --- Standard library ---
29 // --- AliRoot header files ---
31 #include "AliPHOSGeometry.h"
32 #include "AliPHOSPIDv1.h"
33 #include "AliPHOSReconstructor.h"
34 #include "AliPHOSEsdCluster.h"
35 #include "AliPHOSCalibData.h"
36 #include "AliESDCaloCells.h"
38 ClassImp(AliPHOSEsdCluster)
40 //____________________________________________________________________________
41 AliPHOSEsdCluster::AliPHOSEsdCluster() :
42 AliESDCaloCluster(),fRecalibrated(0)
46 //____________________________________________________________________________
47 AliPHOSEsdCluster::AliPHOSEsdCluster(const AliESDCaloCluster & clu) :
48 AliESDCaloCluster(clu),fRecalibrated(0)
53 //____________________________________________________________________________
54 AliPHOSEsdCluster::~AliPHOSEsdCluster()
58 //____________________________________________________________________________
59 void AliPHOSEsdCluster::Recalibrate(AliPHOSCalibData * calibData,AliESDCaloCells *phsCells){
60 //If not done yet, apply recalibration coefficients to energies list
61 //NOTE that after recalibration fCellsAmpFraction contains not FRACTION but FULL energy
69 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
71 AliFatal("AliPHOSGeometry was not contructed\n") ;
73 for(Int_t i=0; i<fNCells; i++){
75 phosgeom->AbsToRelNumbering(fCellsAbsId[i],relId) ;
76 Int_t module = relId[0];
77 Int_t column = relId[3];
79 Double_t energy = phsCells->GetCellAmplitude(fCellsAbsId[i]) ;
80 Double_t fr = fCellsAmpFraction[i] ;
81 fCellsAmpFraction[i]*=energy*calibData->GetADCchannelEmc(module,column,row);
82 printf(" mod=%d, col=%d, row=%d \n",module,column,row);
83 printf(" cell=%d, Amp=%f, E(i)=%f, Fr=%f, ci=%f \n",i,energy,fCellsAmpFraction[i],fr,calibData->GetADCchannelEmc(module,column,row)) ;
88 //____________________________________________________________________________
89 void AliPHOSEsdCluster::EvalAll(Float_t logWeight, TVector3 &vtx){
90 //If recalibrated - recalculate all cluster parameters
94 EvalEnergy() ; //Energy should be evaluated first
95 EvalCoord(logWeight, vtx) ;
98 //____________________________________________________________________________
99 void AliPHOSEsdCluster::EvalEnergy(){
100 if(!fRecalibrated) // no need to recalibrate
104 for(Int_t iDigit=0; iDigit<fNCells; iDigit++) {
105 fEnergy+=fCellsAmpFraction[iDigit] ;
107 //Correct for nonlinearity later
109 printf("fEnergy=0 \n") ;
110 printf("n Digits = %d \n",fNCells) ;
111 for(Int_t iDigit=0; iDigit<fNCells; iDigit++) {
112 printf("E(%d)=%f \n",iDigit,fCellsAmpFraction[iDigit]);
117 //____________________________________________________________________________
118 void AliPHOSEsdCluster::EnergyCorrection(){
119 //apply nonlinearity correction
120 fEnergy = AliPHOSReconstructor::CorrectNonlinearity(fEnergy) ;
122 //____________________________________________________________________________
123 void AliPHOSEsdCluster::EvalPID(AliPHOSPIDv1 * /*pid*/){
124 //re-evaluate identification parameters
125 // pid->CalculatePID(fEnergy,fDispersion,fEmcCpvDistance,tof,fPID) ;
126 // pid->CalculatePID(fEnergy,fDispersion,fM20,fM02,fEmcCpvDistance,tof,fPID) ;
128 //____________________________________________________________________________
129 void AliPHOSEsdCluster::EvalCoord(Float_t logWeight, TVector3 &vtx)
131 // Calculates new center of gravity in the local PHOS-module coordinates
132 // and tranfers into global ALICE coordinates
133 // Calculates Dispersion and main axis
134 if(!fRecalibrated) // no need to recalibrate
143 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
145 AliFatal("AliPHOSGeometry was not contructed\n") ;
147 for(Int_t iDigit=0; iDigit<fNCells; iDigit++) {
150 phosgeom->AbsToRelNumbering(fCellsAbsId[iDigit], relid) ;
151 phosgeom->RelPosInModule(relid, xi, zi);
153 Double_t ei=fCellsAmpFraction[iDigit] ;
154 if (fEnergy>0 && ei>0) {
155 Float_t w = TMath::Max( 0., logWeight + TMath::Log(ei/fEnergy) ) ;
161 AliError(Form("Wrong energy %f and/or amplitude %f\n", ei, fEnergy));
168 AliError(Form("Wrong weight %f\n", wtot));
171 // Calculates the dispersion and second momenta
176 for(Int_t iDigit=0; iDigit < fNCells; iDigit++) {
179 phosgeom->AbsToRelNumbering(fCellsAbsId[iDigit], relid) ;
180 phosgeom->RelPosInModule(relid, xi, zi);
181 Double_t ei=fCellsAmpFraction[iDigit] ;
182 if (fEnergy>0 && ei>0) {
183 Float_t w = TMath::Max( 0., logWeight + TMath::Log(ei/fEnergy) ) ;
184 d += w*((xi-xMean)*(xi-xMean) + (zi-zMean)*(zi-zMean) ) ;
190 AliError(Form("Wrong energy %f and/or amplitude %f\n", ei, fEnergy));
198 dxx -= xMean * xMean ;
199 dzz -= zMean * zMean ;
200 dxz -= xMean * zMean ;
201 fM02 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
202 fM20 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
205 AliError(Form("Wrong weight %f\n", wtot));
212 fDispersion = TMath::Sqrt(d) ;
217 // Correction for the depth of the shower starting point (TDR p 127)
218 Float_t para = 0.925 ;
219 Float_t parb = 6.52 ;
222 phosgeom->GetIncidentVector(vtx,phosMod,xMean,zMean,vInc) ;
226 if (fEnergy>0&&vInc.Y()!=0.) {
227 depthx = ( para * TMath::Log(fEnergy) + parb ) * vInc.X()/TMath::Abs(vInc.Y()) ;
228 depthz = ( para * TMath::Log(fEnergy) + parb ) * vInc.Z()/TMath::Abs(vInc.Y()) ;
231 AliError(Form("Wrong amplitude %f\n", fEnergy));
236 //Go to the global system
238 phosgeom->Local2Global(phosMod, xMean, zMean, gps) ;
239 fGlobalPos[0]=gps[0] ;
240 fGlobalPos[1]=gps[1] ;
241 fGlobalPos[2]=gps[2] ;