]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALRecoUtils.cxx
Coverity fixes.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRecoUtils.cxx
index d683e0158e4260752add8ccaae644e1e38cba9e0..be1851bca346a59bb042ed911d3bc25bf8bbe59b 100644 (file)
@@ -46,6 +46,7 @@
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
 #include "AliEMCALTrack.h"
+#include "AliEMCALCalibTimeDepCorrection.h"
 
 ClassImp(AliEMCALRecoUtils)
   
@@ -54,13 +55,13 @@ AliEMCALRecoUtils::AliEMCALRecoUtils():
   fNonLinearityFunction (kNoCorrection), fParticleType(kPhoton),
   fPosAlgo(kUnchanged),fW0(4.),
   fRecalibration(kFALSE), fEMCALRecalibrationFactors(),
-  fRemoveBadChannels(kFALSE), fEMCALBadChannelMap(),
+  fRemoveBadChannels(kFALSE), fRecalDistToBadChannels(kFALSE), fEMCALBadChannelMap(),
   fNCellsFromEMCALBorder(0), fNoEMCALBorderAtEta0(kTRUE),
   fMatchedClusterIndex(0x0), fResidualZ(0x0), fResidualR(0x0), fCutR(20), fCutZ(20),
   fCutMinNClusterTPC(0), fCutMinNClusterITS(0), fCutMaxChi2PerClusterTPC(0), fCutMaxChi2PerClusterITS(0),
   fCutRequireTPCRefit(0), fCutRequireITSRefit(0), fCutAcceptKinkDaughters(0),
-  fCutMaxDCAToVertexXY(0), fCutMaxDCAToVertexZ(0),fCutDCAToVertex2D(0),
-  fPIDUtils()
+  fCutMaxDCAToVertexXY(0), fCutMaxDCAToVertexZ(0),fCutDCAToVertex2D(0),fPIDUtils(),
+  fUseTimeCorrectionFactors(kFALSE),  fTimeCorrectionFactorsSet(kFALSE)
 {
 //
   // Constructor.
@@ -93,7 +94,8 @@ AliEMCALRecoUtils::AliEMCALRecoUtils(const AliEMCALRecoUtils & reco)
 : TNamed(reco), fNonLinearityFunction(reco.fNonLinearityFunction), 
   fParticleType(reco.fParticleType), fPosAlgo(reco.fPosAlgo), fW0(reco.fW0), 
   fRecalibration(reco.fRecalibration),fEMCALRecalibrationFactors(reco.fEMCALRecalibrationFactors),
-  fRemoveBadChannels(reco.fRemoveBadChannels),fEMCALBadChannelMap(reco.fEMCALBadChannelMap),
+  fRemoveBadChannels(reco.fRemoveBadChannels),fRecalDistToBadChannels(reco.fRecalDistToBadChannels),
+  fEMCALBadChannelMap(reco.fEMCALBadChannelMap),
   fNCellsFromEMCALBorder(reco.fNCellsFromEMCALBorder),fNoEMCALBorderAtEta0(reco.fNoEMCALBorderAtEta0),
   fMatchedClusterIndex(reco.fMatchedClusterIndex?new TArrayI(*reco.fMatchedClusterIndex):0x0),
   fResidualZ(reco.fResidualZ?new TArrayF(*reco.fResidualZ):0x0),
@@ -104,8 +106,8 @@ AliEMCALRecoUtils::AliEMCALRecoUtils(const AliEMCALRecoUtils & reco)
   fCutRequireTPCRefit(reco.fCutRequireTPCRefit), fCutRequireITSRefit(reco.fCutRequireITSRefit),
   fCutAcceptKinkDaughters(reco.fCutAcceptKinkDaughters),
   fCutMaxDCAToVertexXY(reco.fCutMaxDCAToVertexXY), fCutMaxDCAToVertexZ(reco.fCutMaxDCAToVertexZ),fCutDCAToVertex2D(reco.fCutDCAToVertex2D),
-  fPIDUtils(reco.fPIDUtils)
-
+  fPIDUtils(reco.fPIDUtils)
+  fUseTimeCorrectionFactors(reco.fUseTimeCorrectionFactors),  fTimeCorrectionFactorsSet(reco.fTimeCorrectionFactorsSet)
 {
   //Copy ctor
   
@@ -126,37 +128,41 @@ AliEMCALRecoUtils & AliEMCALRecoUtils::operator = (const AliEMCALRecoUtils & rec
   if(this == &reco)return *this;
   ((TNamed *)this)->operator=(reco);
 
-  fNonLinearityFunction  = reco.fNonLinearityFunction;
-  fParticleType          = reco.fParticleType;
-  fPosAlgo               = reco.fPosAlgo; 
-  fW0                    = reco.fW0;
-  fRecalibration         = reco.fRecalibration;
+  fNonLinearityFunction      = reco.fNonLinearityFunction;
+  fParticleType              = reco.fParticleType;
+  fPosAlgo                   = reco.fPosAlgo; 
+  fW0                        = reco.fW0;
+  fRecalibration             = reco.fRecalibration;
   fEMCALRecalibrationFactors = reco.fEMCALRecalibrationFactors;
-  fRemoveBadChannels     = reco.fRemoveBadChannels;
-  fEMCALBadChannelMap    = reco.fEMCALBadChannelMap;
-  fNCellsFromEMCALBorder = reco.fNCellsFromEMCALBorder;
-  fNoEMCALBorderAtEta0   = reco.fNoEMCALBorderAtEta0;
+  fRemoveBadChannels         = reco.fRemoveBadChannels;
+  fRecalDistToBadChannels    = reco.fRecalDistToBadChannels;
+  fEMCALBadChannelMap        = reco.fEMCALBadChannelMap;
+  fNCellsFromEMCALBorder     = reco.fNCellsFromEMCALBorder;
+  fNoEMCALBorderAtEta0       = reco.fNoEMCALBorderAtEta0;
 
 
   for(Int_t i = 0; i < 15 ; i++) {fMisalTransShift[i] = reco.fMisalTransShift[i]; fMisalRotShift[i] = reco.fMisalRotShift[i];}
   for(Int_t i = 0; i < 6  ; i++) fNonLinearityParams[i] = reco.fNonLinearityParams[i]; 
   
-  fCutR                  = reco.fCutR;
-  fCutZ                  = reco.fCutZ;
-
-  fCutMinNClusterTPC        = reco.fCutMinNClusterTPC;
-  fCutMinNClusterITS        = reco.fCutMinNClusterITS; 
-  fCutMaxChi2PerClusterTPC  = reco.fCutMaxChi2PerClusterTPC;
-  fCutMaxChi2PerClusterITS  = reco.fCutMaxChi2PerClusterITS;
-  fCutRequireTPCRefit       = reco.fCutRequireTPCRefit;
-  fCutRequireITSRefit       = reco.fCutRequireITSRefit;
-  fCutAcceptKinkDaughters   = reco.fCutAcceptKinkDaughters;
-  fCutMaxDCAToVertexXY      = reco.fCutMaxDCAToVertexXY;
-  fCutMaxDCAToVertexZ       = reco.fCutMaxDCAToVertexZ;
-  fCutDCAToVertex2D         = reco.fCutDCAToVertex2D;
-
-  fPIDUtils              = reco.fPIDUtils;
+  fCutR                      = reco.fCutR;
+  fCutZ                      = reco.fCutZ;
+
+  fCutMinNClusterTPC         = reco.fCutMinNClusterTPC;
+  fCutMinNClusterITS         = reco.fCutMinNClusterITS; 
+  fCutMaxChi2PerClusterTPC   = reco.fCutMaxChi2PerClusterTPC;
+  fCutMaxChi2PerClusterITS   = reco.fCutMaxChi2PerClusterITS;
+  fCutRequireTPCRefit        = reco.fCutRequireTPCRefit;
+  fCutRequireITSRefit        = reco.fCutRequireITSRefit;
+  fCutAcceptKinkDaughters    = reco.fCutAcceptKinkDaughters;
+  fCutMaxDCAToVertexXY       = reco.fCutMaxDCAToVertexXY;
+  fCutMaxDCAToVertexZ        = reco.fCutMaxDCAToVertexZ;
+  fCutDCAToVertex2D          = reco.fCutDCAToVertex2D;
+
+  fPIDUtils                  = reco.fPIDUtils;
   
+  fUseTimeCorrectionFactors  = reco.fUseTimeCorrectionFactors;
+  fTimeCorrectionFactorsSet  = reco.fTimeCorrectionFactorsSet;
+
   
   if(reco.fResidualR){
     // assign or copy construct
@@ -230,8 +236,9 @@ Bool_t AliEMCALRecoUtils::CheckCellFiducialRegion(AliEMCALGeometry* geom, AliVCl
   //If the distance to the border is 0 or negative just exit accept all clusters
        if(cells->GetType()==AliVCaloCells::kEMCALCell && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
   
-  Int_t absIdMax       = -1, iSM =-1, ieta = -1, iphi = -1;  
-  GetMaxEnergyCell(geom, cells, cluster, absIdMax,  iSM, ieta, iphi);
+  Int_t absIdMax       = -1, iSM =-1, ieta = -1, iphi = -1;
+  Bool_t shared = kFALSE;
+  GetMaxEnergyCell(geom, cells, cluster, absIdMax,  iSM, ieta, iphi, shared);
 
   AliDebug(2,Form("Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f, Ncells from border %d, EMCAL eta=0 %d\n", 
            absIdMax, cells->GetCellAmplitude(absIdMax), cluster->E(), fNCellsFromEMCALBorder, fNoEMCALBorderAtEta0));
@@ -321,35 +328,52 @@ Float_t AliEMCALRecoUtils::CorrectClusterEnergyLinearity(AliVCluster* cluster){
   switch (fNonLinearityFunction) {
       
     case kPi0MC:
+    {
       //Non-Linearity correction (from MC with function ([0]*exp(-[1]/E))+(([2]/([3]*2.*TMath::Pi())*exp(-(E-[4])^2/(2.*[3]^2)))))
-      //Double_t par0 = 1.001;
-      //Double_t par1 = -0.01264;
-      //Double_t par2 = -0.03632;
-      //Double_t par3 = 0.1798;
-      //Double_t par4 = -0.522;
+      //Double_t fNonLinearityParams[0] = 1.001;
+      //Double_t fNonLinearityParams[1] = -0.01264;
+      //Double_t fNonLinearityParams[2] = -0.03632;
+      //Double_t fNonLinearityParams[3] = 0.1798;
+      //Double_t fNonLinearityParams[4] = -0.522;
        energy /= (fNonLinearityParams[0]*exp(-fNonLinearityParams[1]/energy))+
                   ((fNonLinearityParams[2]/(fNonLinearityParams[3]*2.*TMath::Pi())*
                     exp(-(energy-fNonLinearityParams[4])*(energy-fNonLinearityParams[4])/(2.*fNonLinearityParams[3]*fNonLinearityParams[3]))));
       break;
+    }
       
     case kPi0GammaGamma:
-
+    {
       //Non-Linearity correction (from Olga Data with function p0+p1*exp(-p2*E))
-      //Double_t par0 = 0.1457;
-      //Double_t par1 = -0.02024;
-      //Double_t par2 = 1.046;
+      //Double_t fNonLinearityParams[0] = 1.04;
+      //Double_t fNonLinearityParams[1] = -0.1445;
+      //Double_t fNonLinearityParams[2] = 1.046;
       energy /= (fNonLinearityParams[0]+fNonLinearityParams[1]*exp(-fNonLinearityParams[2]*energy)); //Olga function
       break;
+    }
       
     case kPi0GammaConversion:
-      
+    {
       //Non-Linearity correction (Nicolas from Dimitri Data with function C*[1-a*exp(-b*E)])
-      //Double_t C = 0.139393/0.1349766;
-      //Double_t a = 0.0566186;
-      //Double_t b = 0.982133;
+      //fNonLinearityParams[0] = 0.139393/0.1349766;
+      //fNonLinearityParams[1] = 0.0566186;
+      //fNonLinearityParams[2] = 0.982133;
       energy /= fNonLinearityParams[0]*(1-fNonLinearityParams[1]*exp(-fNonLinearityParams[2]*energy));
       
       break;
+    }
+      
+    case kBeamTest:
+    {
+      //From beam test, Alexei's results, for different ZS thresholds
+      //                        th=30 MeV; th = 45 MeV; th = 75 MeV
+      //fNonLinearityParams[0] = 1.007;      1.003;      1.002 
+      //fNonLinearityParams[1] = 0.894;      0.719;      0.797 
+      //fNonLinearityParams[2] = 0.246;      0.334;      0.358 
+      //Rescale the param[0] with 1.03
+      energy /= fNonLinearityParams[0]/(1+fNonLinearityParams[1]*exp(-energy/fNonLinearityParams[2]));
+      
+      break;
+    }
       
     case kNoCorrection:
       AliDebug(2,"No correction on the energy\n");
@@ -367,7 +391,7 @@ Float_t  AliEMCALRecoUtils::GetDepth(const Float_t energy, const Int_t iParticle
   //Calculate shower depth for a given cluster energy and particle type
 
   // parameters 
-  Float_t x0    = 1.23;
+  Float_t x0    = 1.31;
   Float_t ecr   = 8;
   Float_t depth = 0;
   
@@ -411,7 +435,8 @@ Float_t  AliEMCALRecoUtils::GetDepth(const Float_t energy, const Int_t iParticle
 }
 
 //__________________________________________________
-void AliEMCALRecoUtils::GetMaxEnergyCell(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu, Int_t & absId,  Int_t& iSupMod, Int_t& ieta, Int_t& iphi)
+void AliEMCALRecoUtils::GetMaxEnergyCell(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu, 
+                                         Int_t & absId,  Int_t& iSupMod, Int_t& ieta, Int_t& iphi, Bool_t &shared)
 {
   //For a given CaloCluster gets the absId of the cell 
   //with maximum energy deposit.
@@ -425,15 +450,21 @@ void AliEMCALRecoUtils::GetMaxEnergyCell(AliEMCALGeometry *geom, AliVCaloCells*
   Int_t iTower  = -1;
   Int_t iIphi   = -1;
   Int_t iIeta   = -1;
+  Int_t iSupMod0= -1;
        //printf("---Max?\n");
   for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) {
     cellAbsId = clu->GetCellAbsId(iDig);
     fraction  = clu->GetCellAmplitudeFraction(iDig);
     //printf("a Cell %d, id, %d, amp %f, fraction %f\n",iDig,cellAbsId,cells->GetCellAmplitude(cellAbsId),fraction);
     if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
+    geom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta); 
+    geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
+    if(iDig==0) iSupMod0=iSupMod;
+    else if(iSupMod0!=iSupMod) {
+      shared = kTRUE;
+      //printf("AliEMCALRecoUtils::GetMaxEnergyCell() - SHARED CLUSTER\n");
+    }
     if(IsRecalibrationOn()) {
-      geom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta); 
-      geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
       recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi);
     }
     eCell  = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor;
@@ -463,7 +494,7 @@ void AliEMCALRecoUtils::InitEMCALRecalibrationFactors(){
        Bool_t oldStatus = TH1::AddDirectoryStatus();
        TH1::AddDirectory(kFALSE);
   
-       fEMCALRecalibrationFactors = new TObjArray(12);
+       fEMCALRecalibrationFactors = new TObjArray(10);
        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++) {
@@ -489,9 +520,9 @@ void AliEMCALRecoUtils::InitEMCALBadChannelStatusMap(){
        Bool_t oldStatus = TH1::AddDirectoryStatus();
        TH1::AddDirectory(kFALSE);
        
-       fEMCALBadChannelMap = new TObjArray(12);
+       fEMCALBadChannelMap = new TObjArray(10);
        //TH2F * hTemp = new  TH2I("EMCALBadChannelMap","EMCAL SuperModule bad channel map", 48, 0, 48, 24, 0, 24);
-       for (int i = 0; i < 12; i++) {
+       for (int i = 0; i < 10; i++) {
                fEMCALBadChannelMap->Add(new TH2I(Form("EMCALBadChannelMap_Mod%d",i),Form("EMCALBadChannelMap_Mod%d",i), 48, 0, 48, 24, 0, 24));
        }
        
@@ -570,9 +601,10 @@ void AliEMCALRecoUtils::RecalculateClusterPositionFromTowerGlobal(AliEMCALGeomet
   Float_t  weight = 0.,  totalWeight=0.;
   Float_t  newPos[3] = {0,0,0};
   Double_t pLocal[3], pGlobal[3];
-  
+  Bool_t shared = kFALSE;
+
   Float_t  clEnergy = clu->E(); //Energy already recalibrated previously
-  GetMaxEnergyCell(geom, cells, clu, absId,  iSupModMax, ieta, iphi);
+  GetMaxEnergyCell(geom, cells, clu, absId,  iSupModMax, ieta, iphi,shared);
   Double_t depth = GetDepth(clEnergy,fParticleType,iSupModMax) ;
   
   //printf("** Cluster energy %f, ncells %d, depth %f\n",clEnergy,clu->GetNCells(),depth);
@@ -645,9 +677,10 @@ void AliEMCALRecoUtils::RecalculateClusterPositionFromTowerIndex(AliEMCALGeometr
   Int_t iIphi   = -1, iIeta   = -1;
        Int_t iSupMod = -1, iSupModMax = -1;
   Int_t iphi = -1, ieta =-1;
-  
+  Bool_t shared = kFALSE;
+
   Float_t clEnergy = clu->E(); //Energy already recalibrated previously.
-  GetMaxEnergyCell(geom, cells, clu, absId,  iSupModMax, ieta, iphi);
+  GetMaxEnergyCell(geom, cells, clu, absId,  iSupModMax, ieta, iphi,shared);
   Float_t  depth = GetDepth(clEnergy,fParticleType,iSupMod) ;
 
   Float_t weight = 0., weightedCol = 0., weightedRow = 0., totalWeight=0.;
@@ -697,6 +730,82 @@ void AliEMCALRecoUtils::RecalculateClusterPositionFromTowerIndex(AliEMCALGeometr
   
 }
 
+//____________________________________________________________________________
+void AliEMCALRecoUtils::RecalculateClusterDistanceToBadChannel(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster){           
+       
+  //re-evaluate distance to bad channel with updated bad map
+  
+  if(!fRecalDistToBadChannels) return;
+  
+       //Get channels map of the supermodule where the cluster is.
+  Int_t absIdMax       = -1, iSupMod =-1, icolM = -1, irowM = -1;
+  Bool_t shared = kFALSE;
+  GetMaxEnergyCell(geom, cells, cluster, absIdMax,  iSupMod, icolM, irowM, shared);
+  TH2D* hMap  = (TH2D*)fEMCALBadChannelMap->At(iSupMod);
+
+  Int_t dRrow, dRcol;  
+       Float_t  minDist = 10000.;
+       Float_t  dist    = 0.;
+  
+  //Loop on tower status map 
+       for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){
+               for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){
+                       //Check if tower is bad.
+                       if(hMap->GetBinContent(icol,irow)==0) continue;
+      //printf("AliEMCALRecoUtils::RecalculateDistanceToBadChannels() - \n \t Bad channel in SM %d, col %d, row %d, \n \t Cluster max in col %d, row %d\n",
+      //       iSupMod,icol, irow, icolM,irowM);
+      
+      dRrow=TMath::Abs(irowM-irow);
+      dRcol=TMath::Abs(icolM-icol);
+      dist=TMath::Sqrt(dRrow*dRrow+dRcol*dRcol);
+                       if(dist < minDist){
+        //printf("MIN DISTANCE TO BAD %2.2f\n",dist);
+        minDist = dist;
+      }
+      
+               }
+       }
+  
+       //In case the cluster is shared by 2 SuperModules, need to check the map of the second Super Module
+       if (shared) {
+               TH2D* hMap2 = 0;
+               Int_t iSupMod2 = -1;
+    
+               //The only possible combinations are (0,1), (2,3) ... (8,9)
+               if(iSupMod%2) iSupMod2 = iSupMod-1;
+               else          iSupMod2 = iSupMod+1;
+               hMap2  = (TH2D*)fEMCALBadChannelMap->At(iSupMod2);
+    
+               //Loop on tower status map of second super module
+               for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){
+                       for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){
+                               //Check if tower is bad.
+                               if(hMap2->GetBinContent(icol,irow)==0) continue;
+                               //printf("AliEMCALRecoUtils::RecalculateDistanceToBadChannels(shared) - \n \t Bad channel in SM %d, col %d, row %d \n \t Cluster max in SM %d, col %d, row %d\n",
+          //     iSupMod2,icol, irow,iSupMod,icolM,irowM);
+        
+        dRrow=TMath::Abs(irow-irowM);
+        
+        if(iSupMod%2) {
+                                 dRcol=TMath::Abs(icol-(AliEMCALGeoParams::fgkEMCALCols+icolM));
+                               }
+        else {
+          dRcol=TMath::Abs(AliEMCALGeoParams::fgkEMCALCols+icol-icolM);
+                               }                    
+        
+                               dist=TMath::Sqrt(dRrow*dRrow+dRcol*dRcol);
+        if(dist < minDist) minDist = dist;        
+        
+                       }
+               }
+    
+       }// shared cluster in 2 SuperModules
+  
+  AliDebug(2,Form("Max cluster cell (SM,col,row)=(%d %d %d) - Distance to Bad Channel %2.2f",iSupMod, icolM, irowM, minDist));
+  cluster->SetDistanceToBadChannel(minDist);
+  
+}
+
 //____________________________________________________________________________
 void AliEMCALRecoUtils::RecalculateClusterPID(AliVCluster * cluster){           
        
@@ -917,6 +1026,7 @@ void AliEMCALRecoUtils::GetMatchedResiduals(Int_t index, Float_t &dR, Float_t &d
   }
   dR = fResidualR->At(FindMatchedPos(index));
   dZ = fResidualZ->At(FindMatchedPos(index));
+  //printf("dR %f, dZ %f\n",dR, dZ);
 }
 
 //__________________________________________________
@@ -1051,6 +1161,8 @@ void AliEMCALRecoUtils::InitTrackCuts()
   SetRequireITSRefit(kTRUE);
   SetMaxDCAToVertexZ(2);
   SetDCAToVertex2D(kFALSE);
+  SetMaxChi2PerClusterITS(); //which by default sets the value to 1e10.
+  SetMinNClustersITS();
 }
 
 //__________________________________________________
@@ -1079,3 +1191,33 @@ void AliEMCALRecoUtils::Print(const Option_t *) const
 
     
 }
+
+//__________________________________________________
+void AliEMCALRecoUtils::SetTimeDependentCorrections(Int_t runnumber){
+  //Get EMCAL time dependent corrections from file and put them in the recalibration histograms
+  //Do it only once and only if it is requested
+  
+  if(!fUseTimeCorrectionFactors) return;
+  if(fTimeCorrectionFactorsSet)  return;
+  
+  printf("AliEMCALRecoUtils::GetTimeDependentCorrections() - Get Correction Factors for Run number %d\n",runnumber);
+  AliEMCALCalibTimeDepCorrection  *corr =  new AliEMCALCalibTimeDepCorrection();
+  corr->ReadRootInfo(Form("CorrectionFiles/Run%d_Correction.root",runnumber));
+  
+  SwitchOnRecalibration();
+  for(Int_t ism = 0; ism < 4; ism++){
+    for(Int_t icol = 0; icol < 48; icol++){
+      for(Int_t irow = 0; irow < 24; irow++){
+        Float_t orgRecalFactor = GetEMCALChannelRecalibrationFactors(ism)->GetBinContent(icol,irow);
+        Float_t newRecalFactor = orgRecalFactor*corr->GetCorrection(ism, icol,irow,0);
+        GetEMCALChannelRecalibrationFactors(ism)->SetBinContent(icol,irow,newRecalFactor);
+        //printf("ism %d, icol %d, irow %d, corrections : org %f, time dep %f, final %f (org*time %f)\n",ism, icol, irow, 
+        //        orgRecalFactor, corr->GetCorrection(ism, icol,irow,0),
+        //       (GetEMCALChannelRecalibrationFactors(ism))->GetBinContent(icol,irow),newRecalFactor);
+      }
+    }
+  }
+   fTimeCorrectionFactorsSet = kTRUE;
+}
+