+
+//____________________________________________________________________________
+void AliPHOSClusterizerv1::SetDistancesToBadChannels()
+{
+ //For each EMC rec. point set the distance to the nearest bad crystal.
+ //Author: Boris Polichtchouk
+
+ if(!fgCalibData->GetNumOfEmcBadChannels()) return;
+
+ Int_t badIds[8000];
+ memset(badIds,0,8000*sizeof(Int_t));
+ fgCalibData->EmcBadChannelIds(badIds);
+
+ AliPHOSEmcRecPoint* rp;
+
+ TMatrixF gmat;
+ TVector3 gposRecPoint; // global (in ALICE frame) position of rec. point
+ TVector3 gposBadChannel; // global position of bad crystal
+ TVector3 dR;
+
+ Float_t dist,minDist;
+ Int_t relid[4]={0,0,0,0} ;
+ TVector3 lpos ;
+ for(Int_t iRP=0; iRP<fEMCRecPoints->GetEntries(); iRP++){
+ rp = (AliPHOSEmcRecPoint*)fEMCRecPoints->At(iRP);
+ //evaluate distance to border
+ relid[0]=rp->GetPHOSMod() ;
+ relid[2]=1 ;
+ relid[3]=1 ;
+ Float_t xcorner,zcorner;
+ fGeom->RelPosInModule(relid,xcorner,zcorner) ; //coordinate of the corner cell
+ rp->GetLocalPosition(lpos) ;
+ minDist = 2.2+TMath::Min(-xcorner-TMath::Abs(lpos.X()),-zcorner-TMath::Abs(lpos.Z())); //2.2 - crystal size
+ for(Int_t iBad=0; iBad<fgCalibData->GetNumOfEmcBadChannels(); iBad++) {
+ fGeom->AbsToRelNumbering(badIds[iBad],relid) ;
+ if(relid[0]!=rp->GetPHOSMod()) //We can not evaluate global position directly since
+ continue ; //bad channels can be in the module which does not exist in simulations.
+ rp->GetGlobalPosition(gposRecPoint,gmat);
+ fGeom->RelPosInAlice(badIds[iBad],gposBadChannel);
+ AliDebug(2,Form("BC position:[%.3f,%.3f,%.3f], RP position:[%.3f,%.3f,%.3f]. E=%.3f\n",
+ gposBadChannel.X(),gposBadChannel.Y(),gposBadChannel.Z(),
+ gposRecPoint.X(),gposRecPoint.Y(),gposRecPoint.Z(),rp->GetEnergy()));
+ dR = gposBadChannel-gposRecPoint;
+ dist = dR.Mag();
+ if(dist<minDist) minDist = dist;
+ }
+
+ rp->SetDistanceToBadCrystal(minDist);
+ }
+
+}
+//==================================================================================
+Float_t AliPHOSClusterizerv1::Calibrate(Float_t amp, Int_t absId) const{
+ // Calibrate EMC digit, i.e. multiply its Amp by a factor read from CDB
+
+ const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
+
+ //Determine rel.position of the cell absolute ID
+ Int_t relId[4];
+ geom->AbsToRelNumbering(absId,relId);
+ Int_t module=relId[0];
+ Int_t row =relId[2];
+ Int_t column=relId[3];
+ if(relId[1]){ //CPV
+ Float_t calibration = fgCalibData->GetADCchannelCpv(module,column,row);
+ return amp*calibration ;
+ }
+ else{ //EMC
+ Float_t calibration = fgCalibData->GetADCchannelEmc(module,column,row);
+ return amp*calibration ;
+ }
+}
+//==================================================================================
+Float_t AliPHOSClusterizerv1::CalibrateT(Float_t time, Int_t absId)const{
+ // Calibrate time in EMC digit
+
+ const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
+
+ //Determine rel.position of the cell absolute ID
+ Int_t relId[4];
+ geom->AbsToRelNumbering(absId,relId);
+ Int_t module=relId[0];
+ Int_t row =relId[2];
+ Int_t column=relId[3];
+ if(relId[1]){ //CPV
+ return 0. ;
+ }
+ else{ //EMC
+ time += fgCalibData->GetTimeShiftEmc(module,column,row);
+ return time ;
+ }
+}
+