AliPhysics  db95e02 (db95e02)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalCorrectionCellBadChannel.cxx
Go to the documentation of this file.
1 // AliEmcalCorrectionCellBadChannel
2 //
3 
4 #include <TObjArray.h>
5 #include <TFile.h>
6 #include "AliEMCALGeometry.h"
7 #include "AliOADBContainer.h"
8 #include "AliEMCALRecoUtils.h"
9 #include "AliAODEvent.h"
10 
12 
16 
17 // Actually registers the class with the base class
19 
20 //________________________________________________________________________
22  AliEmcalCorrectionComponent("AliEmcalCorrectionCellBadChannel")
23  ,fCellEnergyDistBefore(0)
24  ,fCellEnergyDistAfter(0)
25 {
26  // Default constructor
27  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
28 }
29 
30 //________________________________________________________________________
32 {
33  // Destructor
34 }
35 
36 //________________________________________________________________________
38 {
39  // Initialization
40  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
42  // Do base class initializations and if it fails -> bail out
43  //AliAnalysisTaskEmcal::ExecOnce();
44  //if (!fInitialized) return;
45 
46  AliWarning("Init EMCAL cell bad channel removal");
47 
48  GetProperty("createHistos", fCreateHisto);
49 
50  // init reco utils
51  if (!fRecoUtils)
52  fRecoUtils = new AliEMCALRecoUtils;
53 
54  // missalignment function -- TODO: do we need this?
55  fRecoUtils->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);
56 
57  return kTRUE;
58 }
59 
60 //________________________________________________________________________
62 {
63  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
65 
66  if (fCreateHisto){
67  fCellEnergyDistBefore = new TH1F("hCellEnergyDistBefore","hCellEnergyDistBefore;E_cell",1000,0,10);
69  fCellEnergyDistAfter = new TH1F("hCellEnergyDistAfter","hCellEnergyDistAfter;E_cell",1000,0,10);
71  }
72 }
73 
74 //________________________________________________________________________
76 {
77  // Run
78  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
80 
81  if (!fEvent) {
82  AliError("Event ptr = 0, returning");
83  return kFALSE;
84  }
85 
86  // Initialising parameters once per run number
87 
88  if (RunChanged())
89  {
90  fRun = fEvent->GetRunNumber();
91  AliWarning(Form("Run changed, initializing parameters for %d", fRun));
92  if (dynamic_cast<AliAODEvent*>(fEvent)) {
93  AliWarning("=============================================================");
94  AliWarning("=== Running on AOD is not equivalent to running on ESD! ===");
95  AliWarning("=============================================================");
96  }
97 
98  // init geometry if not already done
99  fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(fRun);
100  if (!fGeom)
101  {
102  AliFatal("Can not create geometry");
103  return kFALSE;
104  }
105 
106  // init bad channels
107  Int_t fInitBC = InitBadChannels();
108  if (fInitBC==0)
109  AliError("InitBadChannels returned false, returning");
110  if (fInitBC==1)
111  AliWarning("InitBadChannels OK");
112  if (fInitBC>1)
113  AliWarning(Form("No external hot channel set: %d - %s", fEvent->GetRunNumber(), fFilepass.Data()));
114 
115  //AliDebug(1, Form("%s",fRecoUtils->Print("")));
116  }
117 
118  // CONFIGURE THE RECO UTILS -------------------------------------------------
119 
120  fRecoUtils->SwitchOnBadChannelsRemoval();
121 
122  // START PROCESSING ---------------------------------------------------------
123  // Test if cells present
124  if (fCaloCells->GetNumberOfCells()<=0)
125  {
126  AliWarning(Form("Number of EMCAL cells = %d, returning", fCaloCells->GetNumberOfCells()));
127  return kFALSE;
128  }
129 
130  // mark the cells not recalibrated
131  fRecoUtils->ResetCellsCalibrated();
132 
133  if(fCreateHisto)
134  FillCellQA(fCellEnergyDistBefore); // "before" QA
135 
136  // CELL RECALIBRATION -------------------------------------------------------
137  // update cell objects
138  UpdateCells();
139 
140  if(fCreateHisto)
141  FillCellQA(fCellEnergyDistAfter); // "after" QA
142 
143  return kTRUE;
144 }
145 
146 //_____________________________________________________
148 {
149  // Initialising bad channel maps
150 
151  if (!fEvent)
152  return 0;
153 
154  AliInfo("Initialising Bad channel map");
155 
156  // init default maps first
157  if (!fRecoUtils->GetEMCALBadChannelStatusMapArray())
158  fRecoUtils->InitEMCALBadChannelStatusMap() ;
159 
160  Int_t runBC = fEvent->GetRunNumber();
161 
162  AliOADBContainer *contBC = new AliOADBContainer("");
163  if (fBasePath!="")
164  { //if fBasePath specified in the ->SetBasePath()
165  AliInfo(Form("Loading Bad Channels OADB from given path %s",fBasePath.Data()));
166 
167  TFile *fbad=new TFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"read");
168  if (!fbad || fbad->IsZombie())
169  {
170  AliFatal(Form("EMCALBadChannels.root was not found in the path provided: %s",fBasePath.Data()));
171  return 0;
172  }
173 
174  if (fbad) delete fbad;
175 
176  contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"AliEMCALBadChannels");
177  }
178  else
179  { // Else choose the one in the $ALICE_PHYSICS directory
180  AliInfo("Loading Bad Channels OADB from $ALICE_PHYSICS/OADB/EMCAL");
181 
182  TFile *fbad=new TFile("$ALICE_PHYSICS/OADB/EMCAL/EMCALBadChannels.root","read");
183  if (!fbad || fbad->IsZombie())
184  {
185  AliFatal("$ALICE_PHYSICS/OADB/EMCAL/EMCALBadChannels.root was not found");
186  return 0;
187  }
188 
189  if (fbad) delete fbad;
190 
191  contBC->InitFromFile("$ALICE_PHYSICS/OADB/EMCAL/EMCALBadChannels.root","AliEMCALBadChannels");
192  }
193 
194  TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
195  if (!arrayBC)
196  {
197  AliError(Form("No external hot channel set for run number: %d", runBC));
198  delete contBC;
199  return 2;
200  }
201 
202  Int_t sms = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
203  for (Int_t i=0; i<sms; ++i)
204  {
205  TH2I *h = fRecoUtils->GetEMCALChannelStatusMap(i);
206  if (h)
207  delete h;
208  h=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
209 
210  if (!h)
211  {
212  AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
213  continue;
214  }
215  h->SetDirectory(0);
216  fRecoUtils->SetEMCALChannelStatusMap(i,h);
217  }
218 
219  delete contBC;
220 
221  return 1;
222 }
AliEMCALGeometry * fGeom
! Geometry object
AliVCaloCells * fCaloCells
! Pointer to CaloCells
AliEMCALRecoUtils * fRecoUtils
Pointer to RecoUtils.
int Int_t
Definition: External.C:63
Base class for correction components in the EMCal correction framework.
TH1F * fCellEnergyDistBefore
! cell energy distribution, before bad channel correction
static RegisterCorrectionComponent< AliEmcalCorrectionCellBadChannel > reg
TString fBasePath
Base folder path to get root files.
TH1F * fCellEnergyDistAfter
! cell energy distribution, after bad channel correction
AliVEvent * fEvent
! Pointer to event
TList * fOutput
! List of output histograms
Bool_t fCreateHisto
Flag to make some basic histograms.
Bad channel correction component in the EMCal correction framework.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
bool Bool_t
Definition: External.C:53
TString fFilepass
Input data pass number.
bool GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.