AliPhysics  f05a842 (f05a842)
 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 // Based on elements of AliEMCALTenderSupply:
9 
10 #include <TClonesArray.h>
11 #include <TGeoGlobalMagField.h>
12 #include <TGeoManager.h>
13 #include <TInterpreter.h>
14 #include <TObjArray.h>
15 #include <TROOT.h>
16 #include <TTree.h>
17 #include "AliAODMCParticle.h"
18 #include "AliEMCALAfterBurnerUF.h"
19 #include "AliEMCALDigit.h"
20 #include "AliEMCALGeometry.h"
21 #include "AliEMCALRecParam.h"
22 #include "AliEMCALRecParam.h"
23 #include "AliEMCALRecPoint.h"
24 #include "AliMagF.h"
25 #include "AliOADBContainer.h"
26 
28 
32 
33 // Actually registers the class with the base class
35 
36 //________________________________________________________________________
38  AliEmcalCorrectionComponent("AliEmcalCorrectionCellBadChannel")
39  ,fCellEnergyDistBefore(0)
40  ,fCellEnergyDistAfter(0)
41 {
42  // Default constructor
43  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
44 }
45 
46 //________________________________________________________________________
48 {
49  // Destructor
50 }
51 
52 //________________________________________________________________________
54 {
55  // Initialization
56  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
58  // Do base class initializations and if it fails -> bail out
59  //AliAnalysisTaskEmcal::ExecOnce();
60  //if (!fInitialized) return;
61 
62  AliWarning("Init EMCAL cell bad channel removal");
63 
64  GetProperty("createHistos", fCreateHisto);
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  // init reco utils
74  if (!fRecoUtils)
75  fRecoUtils = new AliEMCALRecoUtils;
76 
77  // missalignment function -- TO DO: do we need this?
78  fRecoUtils->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);
79 
80  return kTRUE;
81 }
82 
83 //________________________________________________________________________
85 {
86  // Run
87  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
89 
90  if (!fEvent) {
91  AliError("Event ptr = 0, returning");
92  return kFALSE;
93  }
94 
95  // Initialising parameters once per run number
96 
97  if (RunChanged())
98  {
99  fRun = fEvent->GetRunNumber();
100  AliWarning(Form("Run changed, initializing parameters for %d", fRun));
101  if (dynamic_cast<AliAODEvent*>(fEvent)) {
102  AliWarning("=============================================================");
103  AliWarning("=== Running on AOD is not equivalent to running on ESD! ===");
104  AliWarning("=============================================================");
105  }
106 
107  // init geometry if not already done
108  fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(fRun);
109  if (!fGeom)
110  {
111  AliFatal("Can not create geometry");
112  return kFALSE;
113  }
114 
115  // init bad channels
116  Int_t fInitBC = InitBadChannels();
117  if (fInitBC==0)
118  AliError("InitBadChannels returned false, returning");
119  if (fInitBC==1)
120  AliWarning("InitBadChannels OK");
121  if (fInitBC>1)
122  AliWarning(Form("No external hot channel set: %d - %s", fEvent->GetRunNumber(), fFilepass.Data()));
123 
124  //AliDebug(1, Form("%s",fRecoUtils->Print("")));
125  }
126 
127  // CONFIGURE THE RECO UTILS -------------------------------------------------
128 
129  fRecoUtils->SwitchOnBadChannelsRemoval();
130 
131  // START PROCESSING ---------------------------------------------------------
132  // Test if cells present
133  if (fCaloCells->GetNumberOfCells()<=0)
134  {
135  AliWarning(Form("Number of EMCAL cells = %d, returning", fCaloCells->GetNumberOfCells()));
136  return kFALSE;
137  }
138 
139  // mark the cells not recalibrated
140  fRecoUtils->ResetCellsCalibrated();
141 
142  if(fCreateHisto)
143  FillCellQA(fCellEnergyDistBefore); // "before" QA
144 
145  // CELL RECALIBRATION -------------------------------------------------------
146  // update cell objects
147  UpdateCells();
148 
149  if(fCreateHisto)
150  FillCellQA(fCellEnergyDistAfter); // "after" QA
151 
152  return kTRUE;
153 }
154 
155 //_____________________________________________________
157 {
158  // Initialising bad channel maps
159 
160  if (!fEvent)
161  return 0;
162 
163  AliInfo("Initialising Bad channel map");
164 
165  // init default maps first
166  if (!fRecoUtils->GetEMCALBadChannelStatusMapArray())
167  fRecoUtils->InitEMCALBadChannelStatusMap() ;
168 
169  Int_t runBC = fEvent->GetRunNumber();
170 
171  AliOADBContainer *contBC = new AliOADBContainer("");
172  if (fBasePath!="")
173  { //if fBasePath specified in the ->SetBasePath()
174  AliInfo(Form("Loading Bad Channels OADB from given path %s",fBasePath.Data()));
175 
176  TFile *fbad=new TFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"read");
177  if (!fbad || fbad->IsZombie())
178  {
179  AliFatal(Form("EMCALBadChannels.root was not found in the path provided: %s",fBasePath.Data()));
180  return 0;
181  }
182 
183  if (fbad) delete fbad;
184 
185  contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"AliEMCALBadChannels");
186  }
187  else
188  { // Else choose the one in the $ALICE_PHYSICS directory
189  AliInfo("Loading Bad Channels OADB from $ALICE_PHYSICS/OADB/EMCAL");
190 
191  TFile *fbad=new TFile("$ALICE_PHYSICS/OADB/EMCAL/EMCALBadChannels.root","read");
192  if (!fbad || fbad->IsZombie())
193  {
194  AliFatal("$ALICE_PHYSICS/OADB/EMCAL/EMCALBadChannels.root was not found");
195  return 0;
196  }
197 
198  if (fbad) delete fbad;
199 
200  contBC->InitFromFile("$ALICE_PHYSICS/OADB/EMCAL/EMCALBadChannels.root","AliEMCALBadChannels");
201  }
202 
203  TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
204  if (!arrayBC)
205  {
206  AliError(Form("No external hot channel set for run number: %d", runBC));
207  delete contBC;
208  return 2;
209  }
210 
211  Int_t sms = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
212  for (Int_t i=0; i<sms; ++i)
213  {
214  TH2I *h = fRecoUtils->GetEMCALChannelStatusMap(i);
215  if (h)
216  delete h;
217  h=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
218 
219  if (!h)
220  {
221  AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
222  continue;
223  }
224  h->SetDirectory(0);
225  fRecoUtils->SetEMCALChannelStatusMap(i,h);
226  }
227 
228  delete contBC;
229 
230  return 1;
231 }
AliEMCALGeometry * fGeom
!geometry object
AliVCaloCells * fCaloCells
! pointer to calo cells
AliEMCALRecoUtils * fRecoUtils
! pointer to reco utils
int Int_t
Definition: External.C:63
void GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.
static RegisterCorrectionComponent< AliEmcalCorrectionCellBadChannel > reg
TList * fOutput
! list of output histograms
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
bool Bool_t
Definition: External.C:53