]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSEsdCluster.cxx
effc++ warnings
[u/mrichter/AliRoot.git] / PHOS / AliPHOSEsdCluster.cxx
CommitLineData
7607cc90 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// AliESDCaloCluster 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 "AliPHOSEsdCluster.h"
34#include "AliPHOSCalibData.h"
35#include "AliESDCaloCells.h"
36
37ClassImp(AliPHOSEsdCluster)
38
39//____________________________________________________________________________
40AliPHOSEsdCluster::AliPHOSEsdCluster() :
41 AliESDCaloCluster(),fRecalibrated(0)
42{
43 // ctor
44}
45//____________________________________________________________________________
46AliPHOSEsdCluster::AliPHOSEsdCluster(const AliESDCaloCluster & clu) :
47 AliESDCaloCluster(clu),fRecalibrated(0)
48{
49 // cpy ctor
50}
51
52//____________________________________________________________________________
53AliPHOSEsdCluster::~AliPHOSEsdCluster()
54{
55 // dtor
56}
57//____________________________________________________________________________
58void AliPHOSEsdCluster::Recalibrate(AliPHOSCalibData * calibData,AliESDCaloCells *phsCells){
59 //If not done yet, apply recalibration coefficients to energies list
60 if(fRecalibrated)
61 return ;
62
63 if(!calibData)
64 return ;
65
66 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
67 if(!phosgeom)
68 AliFatal("AliPHOSGeometry was not contructed\n") ;
69
70 for(Int_t i=0; i<fNCells; i++){
71 Int_t relId[4];
72 phosgeom->AbsToRelNumbering(fCellsAbsId[i],relId) ;
73 Int_t module = relId[0];
74 Int_t column = relId[3];
75 Int_t row = relId[2];
76 Short_t pos ;
77 for(pos=0 ; pos<phsCells->GetNumberOfCells(); pos++){
78 if(fCellsAbsId[i]==phsCells->GetCellNumber(pos))
79 break ;
80 }
81 if(pos<phsCells->GetNumberOfCells()){
82 Double_t energy = phsCells->GetAmplitude(pos) ;
83 fCellsAmpFraction[i]*=calibData->GetADCchannelEmc (module,column,row);
84 }
85 else{
86 AliFatal(Form("Digit %d is not in Cell List\n",fDigitIndex->At(i))) ;
87 }
88 }
89 fRecalibrated=kTRUE;
90}
91//____________________________________________________________________________
92void AliPHOSEsdCluster::EvalAll(Float_t logWeight, TVector3 &vtx){
93 //If recalibrated - recalculate all cluster parameters
94 if(!fRecalibrated)
95 return ;
96
97 EvalEnergy() ; //Energy should be evaluated first
98 EvalCoord(logWeight, vtx) ;
99
100}
101//____________________________________________________________________________
102void AliPHOSEsdCluster::EvalEnergy(){
103 if(!fRecalibrated) // no need to recalibrate
104 return ;
105
106 fEnergy=0. ;
107 for(Int_t iDigit=0; iDigit<fNCells; iDigit++) {
108 fEnergy+=fCellsAmpFraction[iDigit] ;
109 }
110 //Correct for nonlinearity later
111
112}
113//____________________________________________________________________________
114void AliPHOSEsdCluster::EnergyCorrection(AliPHOSPIDv1 * pid){
115 //apply nonlinearity correction same as in AliPHOSPIDv1.
116 fEnergy = pid->GetCalibratedEnergy(fEnergy) ;
117}
118//____________________________________________________________________________
119void AliPHOSEsdCluster::EvalPID(AliPHOSPIDv1 * /*pid*/){
120 //re-evaluate identification parameters
121// pid->CalculatePID(fEnergy,fDispersion,fEmcCpvDistance,tof,fPID) ;
122// pid->CalculatePID(fEnergy,fDispersion,fM20,fM02,fEmcCpvDistance,tof,fPID) ;
123}
124//____________________________________________________________________________
125void AliPHOSEsdCluster::EvalCoord(Float_t logWeight, TVector3 &vtx)
126{
127 // Calculates new center of gravity in the local PHOS-module coordinates
128 // and tranfers into global ALICE coordinates
129 // Calculates Dispersion and main axis
130 if(!fRecalibrated) // no need to recalibrate
131 return ;
132
133 Float_t wtot = 0. ;
134 Int_t relid[4] ;
135 Int_t phosMod=0 ;
136 Float_t xMean = 0. ;
137 Float_t zMean = 0. ;
138
139 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
140 if(!phosgeom)
141 AliFatal("AliPHOSGeometry was not contructed\n") ;
142
143 for(Int_t iDigit=0; iDigit<fNCells; iDigit++) {
144 Float_t xi ;
145 Float_t zi ;
146 phosgeom->AbsToRelNumbering(fCellsAbsId[iDigit], relid) ;
147 phosgeom->RelPosInModule(relid, xi, zi);
148 phosMod=relid[0] ;
149 Double_t ei=fCellsAmpFraction[iDigit] ;
150 if (fEnergy>0 && ei>0) {
151 Float_t w = TMath::Max( 0., logWeight + TMath::Log(ei/fEnergy) ) ;
152 xMean+= xi * w ;
153 zMean+= zi * w ;
154 wtot += w ;
155 }
156 else
157 AliError(Form("Wrong energy %f and/or amplitude %f\n", ei, fEnergy));
158 }
159 if (wtot>0) {
160 xMean /= wtot ;
161 zMean /= wtot ;
162 }
163 else
164 AliError(Form("Wrong weight %f\n", wtot));
165
166
167// Calculates the dispersion and second momenta
168 Double_t d=0. ;
169 Double_t dxx = 0.;
170 Double_t dzz = 0.;
171 Double_t dxz = 0.;
172 for(Int_t iDigit=0; iDigit < fNCells; iDigit++) {
173 Int_t relid[4] ;
174 Float_t xi ;
175 Float_t zi ;
176 phosgeom->AbsToRelNumbering(fCellsAbsId[iDigit], relid) ;
177 phosgeom->RelPosInModule(relid, xi, zi);
178 Double_t ei=fCellsAmpFraction[iDigit] ;
179 if (fEnergy>0 && ei>0) {
180 Float_t w = TMath::Max( 0., logWeight + TMath::Log(ei/fEnergy) ) ;
181 d += w*((xi-xMean)*(xi-xMean) + (zi-zMean)*(zi-zMean) ) ;
182 dxx += w * xi * xi ;
183 dzz += w * zi * zi ;
184 dxz += w * xi * zi ;
185 }
186 else
187 AliError(Form("Wrong energy %f and/or amplitude %f\n", ei, fEnergy));
188 }
189
190 if (wtot>0) {
191 d /= wtot ;
192 dxx /= wtot ;
193 dzz /= wtot ;
194 dxz /= wtot ;
195 dxx -= xMean * xMean ;
196 dzz -= zMean * zMean ;
197 dxz -= xMean * zMean ;
198 fM02 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
199 fM20 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
200 }
201 else{
202 AliError(Form("Wrong weight %f\n", wtot));
203 d=0. ;
204 fM20=0. ;
205 fM02=0. ;
206 }
207
208 if (d>=0)
209 fDispersion = TMath::Sqrt(d) ;
210 else
211 fDispersion = 0 ;
212
213
214 // Correction for the depth of the shower starting point (TDR p 127)
215 Float_t para = 0.925 ;
216 Float_t parb = 6.52 ;
217
218 TVector3 vInc ;
219 phosgeom->GetIncidentVector(vtx,phosMod,xMean,zMean,vInc) ;
220
221 Float_t depthx = 0.;
222 Float_t depthz = 0.;
223 if (fEnergy>0&&vInc.Y()!=0.) {
224 depthx = ( para * TMath::Log(fEnergy) + parb ) * vInc.X()/TMath::Abs(vInc.Y()) ;
225 depthz = ( para * TMath::Log(fEnergy) + parb ) * vInc.Z()/TMath::Abs(vInc.Y()) ;
226 }
227 else
228 AliError(Form("Wrong amplitude %f\n", fEnergy));
229
230 xMean-= depthx ;
231 zMean-= depthz ;
232
233 //Go to the global system
234 TVector3 gps ;
235 phosgeom->Local2Global(phosMod, xMean, zMean, gps) ;
236 fGlobalPos[0]=gps[0] ;
237 fGlobalPos[1]=gps[1] ;
238 fGlobalPos[2]=gps[2] ;
239}