+//_______________________________________________________________________
+Bool_t AliEMCALRecoUtils::IsExoticCell(const Int_t absID, AliVCaloCells* cells, const Int_t bc)
+{
+ // Look to cell neighbourhood and reject if it seems exotic
+ // Do before recalibrating the cells
+ if(!fRejectExoticCells) return kFALSE;
+
+ AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
+
+ Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
+ geom->GetCellIndex(absID,imod,iTower,iIphi,iIeta);
+ geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
+
+ //Get close cells index, energy and time, not in corners
+ Int_t absID1 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi+1, ieta);
+ Int_t absID2 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi-1, ieta);
+ Int_t absID3 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, ieta+1);
+ Int_t absID4 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, ieta-1);
+
+ Float_t ecell = 0, ecell1 = 0, ecell2 = 0, ecell3 = 0, ecell4 = 0;
+ Double_t tcell = 0, tcell1 = 0, tcell2 = 0, tcell3 = 0, tcell4 = 0;
+ Bool_t accept = 0, accept1 = 0, accept2 = 0, accept3 = 0, accept4 = 0;
+
+ accept = AcceptCalibrateCell(absID, bc, ecell ,tcell ,cells);
+
+ if(!accept) return kTRUE; // reject this cell
+
+ if(ecell < fExoticCellMinAmplitude) return kFALSE; // do not reject low energy cells
+
+ accept1 = AcceptCalibrateCell(absID1,bc, ecell1,tcell1,cells);
+ accept2 = AcceptCalibrateCell(absID2,bc, ecell2,tcell2,cells);
+ accept3 = AcceptCalibrateCell(absID3,bc, ecell3,tcell3,cells);
+ accept4 = AcceptCalibrateCell(absID4,bc, ecell4,tcell4,cells);
+
+ /*
+ printf("Cell absID %d \n",absID);
+ printf("\t accept1 %d, accept2 %d, accept3 %d, accept4 %d\n",
+ accept1,accept2,accept3,accept4);
+ printf("\t id %d: id1 %d, id2 %d, id3 %d, id4 %d\n",
+ absID,absID1,absID2,absID3,absID4);
+ printf("\t e %f: e1 %f, e2 %f, e3 %f, e4 %f\n",
+ ecell,ecell1,ecell2,ecell3,ecell4);
+ printf("\t t %f: t1 %f, t2 %f, t3 %f, t4 %f;\n dt1 %f, dt2 %f, dt3 %f, dt4 %f\n",
+ tcell*1.e9,tcell1*1.e9,tcell2*1.e9,tcell3*1.e9,tcell4*1.e9,
+ TMath::Abs(tcell-tcell1)*1.e9, TMath::Abs(tcell-tcell2)*1.e9, TMath::Abs(tcell-tcell3)*1.e9, TMath::Abs(tcell-tcell4)*1.e9);
+ */
+
+ if(TMath::Abs(tcell-tcell1)*1.e9 > fExoticCellDiffTime) ecell1 = 0 ;
+ if(TMath::Abs(tcell-tcell2)*1.e9 > fExoticCellDiffTime) ecell2 = 0 ;
+ if(TMath::Abs(tcell-tcell3)*1.e9 > fExoticCellDiffTime) ecell3 = 0 ;
+ if(TMath::Abs(tcell-tcell4)*1.e9 > fExoticCellDiffTime) ecell4 = 0 ;
+
+ Float_t eCross = ecell1+ecell2+ecell3+ecell4;
+
+ //printf("\t eCell %f, eCross %f, 1-eCross/eCell %f\n",ecell,eCross,1-eCross/ecell);
+
+ if(1-eCross/ecell > fExoticCellFraction) {
+ AliDebug(2,Form("AliEMCALRecoUtils::IsExoticCell() - EXOTIC CELL id %d, eCell %f, eCross %f, 1-eCross/eCell %f\n",absID,ecell,eCross,1-eCross/ecell));
+ return kTRUE;
+ }
+
+ return kFALSE;
+
+}
+
+//_________________________________________________
+Bool_t AliEMCALRecoUtils::IsExoticCluster(AliVCluster *cluster, AliVCaloCells *cells, const Int_t bc) {
+ // Check if the cluster highest energy tower is exotic
+
+ if(!cluster){
+ AliInfo("Cluster pointer null!");
+ return kFALSE;
+ }
+
+ if(!fRejectExoticCluster) return kFALSE;
+
+ // Get highest energy tower
+ AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance();
+ Int_t iSupMod = -1, absId = -1, ieta = -1, iphi = -1;
+ Bool_t shared = kFALSE;
+ GetMaxEnergyCell(geom, cells, cluster, absId, iSupMod, ieta, iphi, shared);
+
+ return IsExoticCell(absId,cells,bc);
+
+}
+
+//__________________________________________________
+Float_t AliEMCALRecoUtils::SmearClusterEnergy(AliVCluster* cluster) {
+
+ //In case of MC analysis, smear energy to match resolution/calibration in real data
+
+ if(!cluster){
+ AliInfo("Cluster pointer null!");
+ return 0;
+ }
+
+ Float_t energy = cluster->E() ;
+ Float_t rdmEnergy = energy ;
+ if(fSmearClusterEnergy){
+ rdmEnergy = fRandom.Gaus(energy,fSmearClusterParam[0] * TMath::Sqrt(energy) +
+ fSmearClusterParam[1] * energy +
+ fSmearClusterParam[2] );
+ AliDebug(2, Form("Energy: original %f, smeared %f\n", energy, rdmEnergy));
+ }
+
+ return rdmEnergy ;
+
+}
+