+//_____________________________________________________
+Int_t AliEMCALTenderSupply::InitRunDepRecalib()
+{
+ // Initialising recalibration factors.
+
+ AliVEvent *event = GetEvent();
+
+ if (!event)
+ return 0;
+
+ if (fDebugLevel>0)
+ AliInfo("Initialising recalibration factors");
+
+ // init default maps first
+ if( !fEMCALRecoUtils->GetEMCALRecalibrationFactorsArray() )
+ fEMCALRecoUtils->InitEMCALRecalibrationFactors() ;
+
+ Int_t runRC = event->GetRunNumber();
+
+ AliOADBContainer *contRF=new AliOADBContainer("");
+ if (fBasePath!="")
+ { //if fBasePath specified in the ->SetBasePath()
+ if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data()));
+
+ TFile *fRunDepRecalib= new TFile(Form("%s/EMCALTemperatureCorrCalib.root",fBasePath.Data()),"read");
+ if (!fRunDepRecalib || fRunDepRecalib->IsZombie())
+ {
+ AliFatal(Form("EMCALTemperatureCorrCalib.root not found in %s",fBasePath.Data()));
+ return 0;
+ }
+
+ if (fRunDepRecalib) delete fRunDepRecalib;
+
+ contRF->InitFromFile(Form("%s/EMCALTemperatureCorrCalib.root",fBasePath.Data()),"AliEMCALRunDepTempCalibCorrections");
+ }
+ else
+ { // Else choose the one in the $ALICE_ROOT directory
+ if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL");
+
+ TFile *fRunDepRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root","read");
+ if (!fRunDepRecalib || fRunDepRecalib->IsZombie())
+ {
+ AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root was not found");
+ return 0;
+ }
+
+ if (fRunDepRecalib) delete fRunDepRecalib;
+
+ contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root","AliEMCALRunDepTempCalibCorrections");
+ }
+
+ TH1S *rundeprecal=(TH1S*)contRF->GetObject(runRC);
+ if (!rundeprecal)
+ {
+ AliError(Form("No Objects for run: %d",runRC));
+ return 2;
+ }
+
+ if (fDebugLevel>0) rundeprecal->Print();
+
+ Int_t nSM = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
+
+ for (Int_t ism=0; ism<nSM; ++ism)
+ {
+ for (Int_t icol=0; icol<48; ++icol)
+ {
+ for (Int_t irow=0; irow<24; ++irow)
+ {
+ Float_t factor = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(ism,icol,irow);
+
+ Int_t absID = fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol); // original calibration factor
+ factor *= rundeprecal->GetBinContent(absID) / 10000. ; // correction dependent on T
+ //printf("\t ism %d, icol %d, irow %d,absID %d, corrA %2.3f, corrB %2.3f, corrAB %2.3f\n",ism, icol, irow, absID,
+ // GetEMCALChannelRecalibrationFactor(ism,icol,irow) , rundeprecal->GetBinContent(absID) / 10000., factor);
+ fEMCALRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
+ } // columns
+ } // rows
+ } // SM loop
+
+ return 1;
+}
+
+
+//_____________________________________________________
+Int_t AliEMCALTenderSupply::InitTimeCalibration()
+{
+ // Initialising bad channel maps
+ AliVEvent *event = GetEvent();
+
+ if (!event)
+ return 0;
+
+ if (fDebugLevel>0)
+ AliInfo("Initialising time calibration map");
+
+ // init default maps first
+ if ( !fEMCALRecoUtils->GetEMCALTimeRecalibrationFactorsArray() )
+ fEMCALRecoUtils->InitEMCALTimeRecalibrationFactors() ;
+
+ Int_t runBC = event->GetRunNumber();
+
+ AliOADBContainer *contBC = new AliOADBContainer("");
+ if (fBasePath!="")
+ { //if fBasePath specified in the ->SetBasePath()
+ if (fDebugLevel>0) AliInfo(Form("Loading time calibration OADB from given path %s",fBasePath.Data()));
+
+ TFile *fbad=new TFile(Form("%s/EMCALTimeCalib.root",fBasePath.Data()),"read");
+ if (!fbad || fbad->IsZombie())
+ {
+ AliFatal(Form("EMCALTimeCalib.root was not found in the path provided: %s",fBasePath.Data()));
+ return 0;
+ }
+
+ if (fbad) delete fbad;
+
+ contBC->InitFromFile(Form("%s/EMCALTimeCalib.root",fBasePath.Data()),"AliEMCALTimeCalib");
+ }
+ else
+ { // Else choose the one in the $ALICE_ROOT directory
+ if (fDebugLevel>0) AliInfo("Loading time calibration OADB from $ALICE_ROOT/OADB/EMCAL");
+
+ TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root","read");
+ if (!fbad || fbad->IsZombie())
+ {
+ AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root was not found");
+ return 0;
+ }
+
+ if (fbad) delete fbad;
+
+ contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root","AliEMCALTimeCalib");
+ }
+
+ TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
+ if (!arrayBC)
+ {
+ AliError(Form("No external time calibration set for run number: %d", runBC));
+ return 2;
+ }
+
+ // Here, it looks for a specific pass
+ TObjArray *arrayBCpass=(TObjArray*)arrayBC->FindObject(fFilepass);
+ if (!arrayBCpass)
+ {
+ AliError(Form("No external time calibration set for: %d -%s", runBC,fFilepass.Data()));
+ return 2;
+ }
+
+ if (fDebugLevel>0) arrayBCpass->Print();
+
+ for( Int_t i = 0; i < 4; i++ )
+ {
+ TH1F *h = fEMCALRecoUtils->GetEMCALChannelTimeRecalibrationFactors( i );
+ if( h )
+ delete h;
+
+ h = (TH1F*)arrayBCpass->FindObject(Form("hAllTimeAvBC%d",i));
+
+ if (!h)
+ {
+ AliError(Form("Can not get hAllTimeAvBC%d",i));
+ continue;
+ }
+ h->SetDirectory(0);
+ fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactors(i,h);
+ }
+ return 1;
+}
+