+ fAODFilterMask = 32;
+ fAODHybridTracks = kFALSE;
+
+ fCutEtaPhiSum = kTRUE;
+ fCutEtaPhiSeparate = kFALSE;
+
+ fCutR = 0.05;
+ fCutEta = 0.025;
+ fCutPhi = 0.05;
+
+ fClusterWindow = 100;
+ fMass = 0.139;
+
+ fStepSurface = 20.;
+ fStepCluster = 5.;
+ fTrackCutsType = kLooseCut;
+
+ fCutMinTrackPt = 0;
+ fCutMinNClusterTPC = -1;
+ fCutMinNClusterITS = -1;
+
+ fCutMaxChi2PerClusterTPC = 1e10;
+ fCutMaxChi2PerClusterITS = 1e10;
+
+ fCutRequireTPCRefit = kFALSE;
+ fCutRequireITSRefit = kFALSE;
+ fCutAcceptKinkDaughters = kFALSE;
+
+ fCutMaxDCAToVertexXY = 1e10;
+ fCutMaxDCAToVertexZ = 1e10;
+ fCutDCAToVertex2D = kFALSE;
+
+ fCutRequireITSStandAlone = kFALSE; //MARCEL
+ fCutRequireITSpureSA = kFALSE; //Marcel
+
+ //Misalignment matrices
+ for(Int_t i = 0; i < 15 ; i++)
+ {
+ fMisalTransShift[i] = 0.;
+ fMisalRotShift[i] = 0.;
+ }
+
+ //Non linearity
+ for(Int_t i = 0; i < 7 ; i++) fNonLinearityParams[i] = 0.;
+
+ //For kBeamTestCorrected case, but default is no correction
+ fNonLinearityParams[0] = 0.99078;
+ fNonLinearityParams[1] = 0.161499;
+ fNonLinearityParams[2] = 0.655166;
+ fNonLinearityParams[3] = 0.134101;
+ fNonLinearityParams[4] = 163.282;
+ fNonLinearityParams[5] = 23.6904;
+ fNonLinearityParams[6] = 0.978;
+
+ //For kPi0GammaGamma case
+ //fNonLinearityParams[0] = 0.1457/0.1349766/1.038;
+ //fNonLinearityParams[1] = -0.02024/0.1349766/1.038;
+ //fNonLinearityParams[2] = 1.046;
+
+ //Cluster energy smearing
+ fSmearClusterEnergy = kFALSE;
+ fSmearClusterParam[0] = 0.07; // * sqrt E term
+ fSmearClusterParam[1] = 0.00; // * E term
+ fSmearClusterParam[2] = 0.00; // constant
+}
+
+//_____________________________________________________
+void AliEMCALRecoUtils::InitEMCALRecalibrationFactors()
+{
+ //Init EMCAL recalibration factors
+ AliDebug(2,"AliCalorimeterUtils::InitEMCALRecalibrationFactors()");
+ //In order to avoid rewriting the same histograms
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
+
+ fEMCALRecalibrationFactors = new TObjArray(12);
+ for (int i = 0; i < 12; i++)
+ fEMCALRecalibrationFactors->Add(new TH2F(Form("EMCALRecalFactors_SM%d",i),
+ Form("EMCALRecalFactors_SM%d",i), 48, 0, 48, 24, 0, 24));
+ //Init the histograms with 1
+ for (Int_t sm = 0; sm < 12; sm++)
+ {
+ for (Int_t i = 0; i < 48; i++)
+ {
+ for (Int_t j = 0; j < 24; j++)
+ {
+ SetEMCALChannelRecalibrationFactor(sm,i,j,1.);
+ }
+ }
+ }
+
+ fEMCALRecalibrationFactors->SetOwner(kTRUE);
+ fEMCALRecalibrationFactors->Compress();
+
+ //In order to avoid rewriting the same histograms
+ TH1::AddDirectory(oldStatus);
+}
+
+//_________________________________________________________
+void AliEMCALRecoUtils::InitEMCALTimeRecalibrationFactors()
+{
+ //Init EMCAL recalibration factors
+ AliDebug(2,"AliCalorimeterUtils::InitEMCALRecalibrationFactors()");
+ //In order to avoid rewriting the same histograms
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
+
+ fEMCALTimeRecalibrationFactors = new TObjArray(4);
+ for (int i = 0; i < 4; i++)
+ fEMCALTimeRecalibrationFactors->Add(new TH1F(Form("hAllTimeAvBC%d",i),
+ Form("hAllTimeAvBC%d",i),
+ 48*24*12,0.,48*24*12) );
+ //Init the histograms with 1
+ for (Int_t bc = 0; bc < 4; bc++)
+ {
+ for (Int_t i = 0; i < 48*24*12; i++)
+ SetEMCALChannelTimeRecalibrationFactor(bc,i,0.);
+ }
+
+ fEMCALTimeRecalibrationFactors->SetOwner(kTRUE);
+ fEMCALTimeRecalibrationFactors->Compress();
+
+ //In order to avoid rewriting the same histograms
+ TH1::AddDirectory(oldStatus);
+}
+
+//____________________________________________________
+void AliEMCALRecoUtils::InitEMCALBadChannelStatusMap()
+{
+ //Init EMCAL bad channels map
+ AliDebug(2,"AliEMCALRecoUtils::InitEMCALBadChannelStatusMap()");
+ //In order to avoid rewriting the same histograms
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
+
+ fEMCALBadChannelMap = new TObjArray(12);
+ //TH2F * hTemp = new TH2I("EMCALBadChannelMap","EMCAL SuperModule bad channel map", 48, 0, 48, 24, 0, 24);
+ for (int i = 0; i < 12; i++)
+ {
+ fEMCALBadChannelMap->Add(new TH2I(Form("EMCALBadChannelMap_Mod%d",i),Form("EMCALBadChannelMap_Mod%d",i), 48, 0, 48, 24, 0, 24));
+ }
+
+ fEMCALBadChannelMap->SetOwner(kTRUE);
+ fEMCALBadChannelMap->Compress();
+
+ //In order to avoid rewriting the same histograms
+ TH1::AddDirectory(oldStatus);
+}
+
+//____________________________________________________________________________
+void AliEMCALRecoUtils::RecalibrateClusterEnergy(const AliEMCALGeometry* geom,
+ AliVCluster * cluster,
+ AliVCaloCells * cells,
+ const Int_t bc)
+{
+ // Recalibrate the cluster energy and Time, considering the recalibration map
+ // and the energy of the cells and time that compose the cluster.
+ // bc= bunch crossing number returned by esdevent->GetBunchCrossNumber();
+
+ if(!cluster)
+ {
+ AliInfo("Cluster pointer null!");
+ return;
+ }
+
+ //Get the cluster number of cells and list of absId, check what kind of cluster do we have.
+ UShort_t * index = cluster->GetCellsAbsId() ;
+ Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
+ Int_t ncells = cluster->GetNCells();
+
+ //Initialize some used variables
+ Float_t energy = 0;
+ Int_t absId =-1;
+ Int_t icol =-1, irow =-1, imod=1;
+ Float_t factor = 1, frac = 0;
+ Int_t absIdMax = -1;
+ Float_t emax = 0;
+
+ //Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
+ for(Int_t icell = 0; icell < ncells; icell++)
+ {
+ absId = index[icell];
+ frac = fraction[icell];
+ if(frac < 1e-5) frac = 1; //in case of EMCAL, this is set as 0 since unfolding is off
+
+ if(!fCellsRecalibrated && IsRecalibrationOn())
+ {
+ // Energy
+ Int_t iTower = -1, iIphi = -1, iIeta = -1;
+ geom->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
+ if(fEMCALRecalibrationFactors->GetEntries() <= imod) continue;
+ geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
+ factor = GetEMCALChannelRecalibrationFactor(imod,icol,irow);
+
+ AliDebug(2,Form("AliEMCALRecoUtils::RecalibrateClusterEnergy - recalibrate cell: module %d, col %d, row %d, cell fraction %f,recalibration factor %f, cell energy %f\n",
+ imod,icol,irow,frac,factor,cells->GetCellAmplitude(absId)));
+
+ }
+
+ energy += cells->GetCellAmplitude(absId)*factor*frac;
+
+ if(emax < cells->GetCellAmplitude(absId)*factor*frac)
+ {
+ emax = cells->GetCellAmplitude(absId)*factor*frac;
+ absIdMax = absId;
+ }
+ }
+
+ AliDebug(2,Form("AliEMCALRecoUtils::RecalibrateClusterEnergy - Energy before %f, after %f \n",cluster->E(),energy));
+
+ cluster->SetE(energy);
+
+ // Recalculate time of cluster
+ Double_t timeorg = cluster->GetTOF();
+
+ Double_t time = cells->GetCellTime(absIdMax);
+ if(!fCellsRecalibrated && IsTimeRecalibrationOn())
+ RecalibrateCellTime(absIdMax,bc,time);
+
+ cluster->SetTOF(time);
+
+ AliDebug(2,Form("AliEMCALRecoUtils::RecalibrateClusterEnergy - Time before %f, after %f \n",timeorg,cluster->GetTOF()));
+}
+
+//_____________________________________________________________
+void AliEMCALRecoUtils::RecalibrateCells(AliVCaloCells * cells,
+ const Int_t bc)
+{
+ // Recalibrate the cells time and energy, considering the recalibration map and the energy
+ // of the cells that compose the cluster.
+ // bc= bunch crossing number returned by esdevent->GetBunchCrossNumber();
+
+ if(!IsRecalibrationOn() && !IsTimeRecalibrationOn() && !IsBadChannelsRemovalSwitchedOn()) return;
+
+ if(!cells)
+ {
+ AliInfo("Cells pointer null!");
+ return;
+ }
+
+ Short_t absId =-1;
+ Bool_t accept = kFALSE;
+ Float_t ecell = 0;
+ Double_t tcell = 0;
+ Double_t ecellin = 0;
+ Double_t tcellin = 0;
+ Int_t mclabel = -1;
+ Double_t efrac = 0;
+
+ Int_t nEMcell = cells->GetNumberOfCells() ;
+ for (Int_t iCell = 0; iCell < nEMcell; iCell++)
+ {
+ cells->GetCell( iCell, absId, ecellin, tcellin, mclabel, efrac );
+
+ accept = AcceptCalibrateCell(absId, bc, ecell ,tcell ,cells);
+ if(!accept)
+ {
+ ecell = 0;
+ tcell = -1;
+ }
+
+ //Set new values
+ cells->SetCell(iCell,absId,ecell, tcell, mclabel, efrac);
+ }
+
+ fCellsRecalibrated = kTRUE;
+}
+
+//_______________________________________________________________________________________________________
+void AliEMCALRecoUtils::RecalibrateCellTime(const Int_t absId, const Int_t bc, Double_t & celltime) const
+{
+ // Recalibrate time of cell with absID considering the recalibration map
+ // bc= bunch crossing number returned by esdevent->GetBunchCrossNumber();
+
+ if(!fCellsRecalibrated && IsTimeRecalibrationOn() && bc >= 0)
+ {
+ celltime -= GetEMCALChannelTimeRecalibrationFactor(bc%4,absId)*1.e-9; ;
+ }
+}
+
+//______________________________________________________________________________
+void AliEMCALRecoUtils::RecalculateClusterPosition(const AliEMCALGeometry *geom,
+ AliVCaloCells* cells,
+ AliVCluster* clu)
+{
+ //For a given CaloCluster recalculates the position for a given set of misalignment shifts and puts it again in the CaloCluster.
+
+ if(!clu)
+ {
+ AliInfo("Cluster pointer null!");
+ return;
+ }
+
+ if (fPosAlgo==kPosTowerGlobal) RecalculateClusterPositionFromTowerGlobal( geom, cells, clu);
+ else if(fPosAlgo==kPosTowerIndex) RecalculateClusterPositionFromTowerIndex ( geom, cells, clu);
+ else AliDebug(2,"Algorithm to recalculate position not selected, do nothing.");
+}
+
+//_____________________________________________________________________________________________
+void AliEMCALRecoUtils::RecalculateClusterPositionFromTowerGlobal(const AliEMCALGeometry *geom,
+ AliVCaloCells* cells,
+ AliVCluster* clu)
+{
+ // For a given CaloCluster recalculates the position for a given set of misalignment shifts and puts it again in the CaloCluster.
+ // The algorithm is a copy of what is done in AliEMCALRecPoint
+
+ Double_t eCell = 0.;
+ Float_t fraction = 1.;
+ Float_t recalFactor = 1.;
+
+ Int_t absId = -1;