6 #include "AliEMCALGeometry.h"
7 #include "AliOADBContainer.h"
8 #include "AliEMCALRecoUtils.h"
9 #include "AliAODEvent.h"
25 ,fCellEnergyDistBefore(0)
26 ,fCellEnergyDistAfter(0)
27 ,fUseAutomaticRecalib(1)
28 ,fUseAutomaticRunDepRecalib(1)
47 AliWarning(
"Init EMCAL cell recalibration");
56 fRecoUtils->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);
84 AliError(
"Event ptr = 0, returning");
97 AliDebug(2, Form(
"Number of EMCAL cells = %d, returning",
fCaloCells->GetNumberOfCells()));
131 AliInfo(
"Initialising recalibration factors");
134 if (!
fRecoUtils->GetEMCALRecalibrationFactorsArray())
139 AliOADBContainer *contRF=
new AliOADBContainer(
"");
142 AliInfo(Form(
"Loading Recalib OADB from given path %s",
fBasePath.Data()));
144 TFile *fRecalib=
new TFile(Form(
"%s/EMCALRecalib.root",
fBasePath.Data()),
"read");
145 if (!fRecalib || fRecalib->IsZombie())
147 AliFatal(Form(
"EMCALRecalib.root not found in %s",
fBasePath.Data()));
151 if (fRecalib)
delete fRecalib;
153 contRF->InitFromFile(Form(
"%s/EMCALRecalib.root",
fBasePath.Data()),
"AliEMCALRecalib");
157 AliInfo(
"Loading Recalib OADB from $ALICE_PHYSICS/OADB/EMCAL");
159 TFile *fRecalib=
new TFile(
"$ALICE_PHYSICS/OADB/EMCAL/EMCALRecalib.root",
"read");
160 if (!fRecalib || fRecalib->IsZombie())
162 AliFatal(
"$ALICE_PHYSICS/OADB/EMCAL/EMCALRecalib.root was not found");
166 if (fRecalib)
delete fRecalib;
168 contRF->InitFromFile(
"$ALICE_PHYSICS/OADB/EMCAL/EMCALRecalib.root",
"AliEMCALRecalib");
174 AliError(Form(
"No Objects for run: %d",runRC));
182 AliError(Form(
"No Objects for run: %d - %s",runRC,
fFilepass.Data()));
190 AliError(Form(
"No Recalib histos found for %d - %s",runRC,
fFilepass.Data()));
197 Int_t sms =
fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
198 for (
Int_t i=0; i<sms; ++i)
203 h = (
TH2F*)recalib->FindObject(Form(
"EMCALRecalFactors_SM%d",i));
206 AliError(Form(
"Could not load EMCALRecalFactors_SM%d",i));
210 fRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
226 AliInfo(
"Initialising recalibration factors");
229 if (!
fRecoUtils->GetEMCALRecalibrationFactorsArray())
234 AliOADBContainer *contRF=
new AliOADBContainer(
"");
237 AliInfo(Form(
"Loading Recalib OADB from given path %s",
fBasePath.Data()));
239 TFile *fRunDepRecalib=
new TFile(Form(
"%s/EMCALTemperatureCorrCalib.root",
fBasePath.Data()),
"read");
240 if (!fRunDepRecalib || fRunDepRecalib->IsZombie())
242 AliFatal(Form(
"EMCALTemperatureCorrCalib.root not found in %s",
fBasePath.Data()));
246 if (fRunDepRecalib)
delete fRunDepRecalib;
248 contRF->InitFromFile(Form(
"%s/EMCALTemperatureCorrCalib.root",
fBasePath.Data()),
"AliEMCALRunDepTempCalibCorrections");
252 AliInfo(
"Loading Recalib OADB from $ALICE_PHYSICS/OADB/EMCAL");
254 TFile *fRunDepRecalib=
new TFile(
"$ALICE_PHYSICS/OADB/EMCAL/EMCALTemperatureCorrCalib.root",
"read");
255 if (!fRunDepRecalib || fRunDepRecalib->IsZombie())
257 AliFatal(
"$ALICE_PHYSICS/OADB/EMCAL/EMCALTemperatureCorrCalib.root was not found");
261 if (fRunDepRecalib)
delete fRunDepRecalib;
263 contRF->InitFromFile(
"$ALICE_PHYSICS/OADB/EMCAL/EMCALTemperatureCorrCalib.root",
"AliEMCALRunDepTempCalibCorrections");
266 TH1S *rundeprecal=(TH1S*)contRF->GetObject(runRC);
270 AliWarning(Form(
"No TemperatureCorrCalib Objects for run: %d",runRC));
274 Int_t maxEntry = contRF->GetNumberOfEntries();
276 while ((ic < maxEntry) && (contRF->UpperLimit(ic) < runRC)) {
281 Int_t closest = lower;
283 (contRF->LowerLimit(ic)-runRC) < (runRC - contRF->UpperLimit(lower))) {
287 AliWarning(Form(
"TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRF->LowerLimit(closest)));
288 rundeprecal = (TH1S*) contRF->GetObjectByIndex(closest);
291 Int_t nSM =
fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
295 if(nSM > 12 && nbins < 12288)
297 AliError(Form(
"Total SM is %d but T corrections available for %d channels, skip Init of T recalibration factors",nSM,nbins));
306 for (
Int_t ism=0; ism<nSM; ++ism)
308 for (
Int_t icol=0; icol<48; ++icol)
310 for (
Int_t irow=0; irow<24; ++irow)
314 Int_t absID =
fGeom->GetAbsCellIdFromCellIndexes(ism, irow, icol);
315 factor *= rundeprecal->GetBinContent(absID) / 10000. ;
317 fRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
340 if (fInitRecalib==0) {
341 AliError(
"InitRecalib returned false, returning");
343 if (fInitRecalib==1) {
344 AliWarning(
"InitRecalib OK");
346 if (fInitRecalib>1) {
354 if (fInitRunDepRecalib==0) {
355 AliError(
"InitrunDepRecalib returned false, returning");
357 if (fInitRunDepRecalib==1) {
358 AliWarning(
"InitRecalib OK");
360 if (fInitRunDepRecalib>1) {
Energy calibration correction component in the EMCal correction framework.
AliEMCALGeometry * fGeom
! Geometry object
TH1F * fCellEnergyDistAfter
! cell energy distribution, after energy calibration
Bool_t fUseAutomaticRunDepRecalib
On by default the check in the OADB of the run dependent energy recalibration.
Int_t InitRunDepRecalib()
virtual void UserCreateOutputObjects()
AliVEvent * InputEvent() const
AliVCaloCells * fCaloCells
! Pointer to CaloCells
AliEMCALRecoUtils * fRecoUtils
Pointer to RecoUtils.
Bool_t fUseAutomaticRecalib
On by default the check in the OADB of the energy recalibration.
Base class for correction components in the EMCal correction framework.
static RegisterCorrectionComponent< AliEmcalCorrectionCellEnergy > reg
TString fBasePath
Base folder path to get root files.
TList * fOutput
! List of output histograms
Bool_t fCreateHisto
Flag to make some basic histograms.
TH1F * fCellEnergyDistBefore
! cell energy distribution, before energy calibration
virtual Bool_t Initialize()
virtual ~AliEmcalCorrectionCellEnergy()
AliEmcalCorrectionEventManager fEventManager
Minimal task which inherits from AliAnalysisTaskSE and manages access to the event.
void UserCreateOutputObjects()
virtual Bool_t CheckIfRunChanged()
AliEmcalCorrectionCellEnergy()
Bool_t CheckIfRunChanged()
TString fFilepass
Input data pass number.
bool GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.