]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliCalorimeterUtils.cxx
Changed default initialization values of fTrackDz / Dx to -999
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliCalorimeterUtils.cxx
CommitLineData
765d44e7 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15/* $Id: $ */
16
17//_________________________________________________________________________
18// Class utility for Calorimeter specific selection methods ///
19//
20//
21//
22//-- Author: Gustavo Conesa (LPSC-Grenoble)
23//////////////////////////////////////////////////////////////////////////////
24
25
26// --- ROOT system ---
27#include "TGeoManager.h"
28
29//---- ANALYSIS system ----
30#include "AliCalorimeterUtils.h"
31#include "AliAODEvent.h"
32#include "AliESDEvent.h"
33#include "AliAODPWG4Particle.h"
34#include "AliAODCaloCluster.h"
35#include "AliESDCaloCluster.h"
36#include "AliAODCaloCells.h"
37#include "AliESDCaloCells.h"
38
39
40ClassImp(AliCalorimeterUtils)
41
42
43//____________________________________________________________________________
44 AliCalorimeterUtils::AliCalorimeterUtils() :
45 TObject(), fDebug(0),
46 fEMCALGeoName("EMCAL_COMPLETE"),fPHOSGeoName("PHOSgeo"),
47 fEMCALGeo(0x0), fPHOSGeo(0x0),
48 fEMCALGeoMatrixSet(kFALSE), fPHOSGeoMatrixSet(kFALSE),
49 fRemoveBadChannels(kFALSE),
50 fEMCALBadChannelMap(new TObjArray()),fPHOSBadChannelMap(new TObjArray()),
51 fNCellsFromEMCALBorder(0), fNCellsFromPHOSBorder(0),
52 fNoEMCALBorderAtEta0(kFALSE)
53{
54 //Ctor
55
56 //Initialize parameters
57 InitParameters();
58}
59
60//____________________________________________________________________________
61AliCalorimeterUtils::AliCalorimeterUtils(const AliCalorimeterUtils & calo) :
62 TObject(calo), fDebug(calo.fDebug),
63 fEMCALGeoName(calo.fEMCALGeoName), fPHOSGeoName(calo.fPHOSGeoName),
64 fEMCALGeo(new AliEMCALGeoUtils(*calo.fEMCALGeo)),
65 fPHOSGeo(new AliPHOSGeoUtils(*calo.fPHOSGeo)),
66 fEMCALGeoMatrixSet(calo.fEMCALGeoMatrixSet),
67 fPHOSGeoMatrixSet(calo.fPHOSGeoMatrixSet),
68 fRemoveBadChannels(calo.fRemoveBadChannels),
69 fEMCALBadChannelMap(new TObjArray(*calo.fEMCALBadChannelMap)),
70 fPHOSBadChannelMap(new TObjArray(*calo.fPHOSBadChannelMap)),
71 fNCellsFromEMCALBorder(calo.fNCellsFromEMCALBorder),
72 fNCellsFromPHOSBorder(calo.fNCellsFromPHOSBorder),
73 fNoEMCALBorderAtEta0(calo.fNoEMCALBorderAtEta0)
74{
75 // cpy ctor
76}
77
78
79//_________________________________
80AliCalorimeterUtils::~AliCalorimeterUtils() {
81 //Dtor
82
4df35693 83 //if(fPHOSGeo) delete fPHOSGeo ;
765d44e7 84 if(fEMCALGeo) delete fEMCALGeo ;
85
86 if(fEMCALBadChannelMap) {
87 fEMCALBadChannelMap->Clear();
88 delete fEMCALBadChannelMap;
89 }
90 if(fPHOSBadChannelMap) {
91 fPHOSBadChannelMap->Clear();
92 delete fPHOSBadChannelMap;
93 }
94
95}
96
97//_______________________________________________________________
98Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliAODCaloCluster* cluster, AliAODCaloCells* cells) const {
99 // Given the list of AbsId of the cluster, get the maximum cell and
100 // check if there are fNCellsFromBorder from the calorimeter border
101
102 //If the distance to the border is 0 or negative just exit accept all clusters
103 if(cells->GetType()==AliAODCaloCells::kEMCAL && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
104 if(cells->GetType()==AliAODCaloCells::kPHOS && fNCellsFromPHOSBorder <= 0 ) return kTRUE;
105
106 //Find cells with maximum amplitude
107 Int_t absIdMax = -1;
108 Float_t ampMax = -1;
109 for(Int_t i = 0; i < cluster->GetNCells() ; i++){
110 Int_t absId = cluster->GetCellAbsId(i) ;
111 Float_t amp = cells->GetCellAmplitude(absId);
112 if(amp > ampMax){
113 ampMax = amp;
114 absIdMax = absId;
115 }
116 }
117
118 if(fDebug > 1)
119 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n",
120 absIdMax, ampMax, cluster->E());
121
122 if(absIdMax==-1) return kFALSE;
123
124 //Check if the cell is close to the borders:
125 Bool_t okrow = kFALSE;
126 Bool_t okcol = kFALSE;
127
128 if(cells->GetType()==AliAODCaloCells::kEMCAL){
129
130 Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
131 fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
132 fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
133
134 //Check rows/phi
135 if(iSM < 10){
136 if(iphi >= fNCellsFromEMCALBorder && iphi < 24-fNCellsFromEMCALBorder) okrow =kTRUE;
137 }
138 else{
139 if(iphi >= fNCellsFromEMCALBorder && iphi < 12-fNCellsFromEMCALBorder) okrow =kTRUE;
140 }
141
142 //Check collumns/eta
143 if(!fNoEMCALBorderAtEta0){
144 if(ieta > fNCellsFromEMCALBorder && ieta < 48-fNCellsFromEMCALBorder) okcol =kTRUE;
145 }
146 else{
147 if(iSM%2==0){
148 if(ieta >= fNCellsFromEMCALBorder) okcol = kTRUE;
149 }
150 else {
151 if(ieta < 48-fNCellsFromEMCALBorder) okcol = kTRUE;
152 }
153 }//eta 0 not checked
154 if(fDebug > 1)
155 {
156 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?",
157 fNCellsFromEMCALBorder, ieta, iphi, iSM);
158 if (okcol && okrow ) printf(" YES \n");
159 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
160 }
161 }//EMCAL
162 else if(cells->GetType()==AliAODCaloCells::kPHOS){
163 Int_t relId[4];
164 Int_t irow = -1, icol = -1;
165 fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
166 irow = relId[2];
167 icol = relId[3];
168 //imod = relId[0]-1;
169 if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
170 if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
171 if(fDebug > 1)
172 {
173 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d?",
174 fNCellsFromPHOSBorder, icol, irow, relId[0]-1);
175 if (okcol && okrow ) printf(" YES \n");
176 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
177 }
178 }//PHOS
179
180 if (okcol && okrow) return kTRUE;
181 else return kFALSE;
182
183}
184
185//_______________________________________________________________
186Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliESDCaloCluster* cluster, AliESDCaloCells* cells) const {
187 // Given the list of AbsId of the cluster, get the maximum cell and
188 // check if there are fNCellsFromBorder from the calorimeter border
189
190 //If the distance to the border is 0 or negative just exit accept all clusters
191 if(cells->GetType()==AliESDCaloCells::kEMCALCell && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
192 if(cells->GetType()==AliESDCaloCells::kPHOSCell && fNCellsFromPHOSBorder <= 0 ) return kTRUE;
193
194 //Find cell with maximum amplitude
195 Int_t absIdMax = -1;
196 Float_t ampMax = -1;
197 for(Int_t i = 0; i < cluster->GetNCells() ; i++){
198 Int_t absId = cluster->GetCellAbsId(i) ;
199 Float_t amp = cells->GetCellAmplitude(absId);
200 if(amp > ampMax){
201 ampMax = amp;
202 absIdMax = absId;
203 }
204 }
205
206 if(fDebug > 1)
207 printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n",
208 absIdMax, ampMax, cluster->E());
209 if(absIdMax==-1) return kFALSE;
210
211 //Check if the cell is close to the borders:
212 Bool_t okrow = kFALSE;
213 Bool_t okcol = kFALSE;
214
215 if(cells->GetType()==AliESDCaloCells::kEMCALCell){
216
217 Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
218 fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
219 fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
220
221 //Check rows/phi
222 if(iSM < 10){
223 if(iphi >= fNCellsFromEMCALBorder && iphi < 24-fNCellsFromEMCALBorder) okrow =kTRUE;
224 }
225 else{
226 if(iphi >= fNCellsFromEMCALBorder && iphi < 12-fNCellsFromEMCALBorder) okrow =kTRUE;
227 }
228
229 //Check collumns/eta
230 if(!fNoEMCALBorderAtEta0){
231 if(ieta > fNCellsFromEMCALBorder && ieta < 48-fNCellsFromEMCALBorder) okcol =kTRUE;
232 }
233 else{
234 if(iSM%2==0){
235 if(ieta >= fNCellsFromEMCALBorder) okcol = kTRUE;
236 }
237 else {
238 if(ieta < 48-fNCellsFromEMCALBorder) okcol = kTRUE;
239 }
240 }//eta 0 not checked
241 if(fDebug > 1)
242 {
243 printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?",
244 fNCellsFromEMCALBorder, ieta, iphi, iSM);
245 if (okcol && okrow ) printf(" YES \n");
246 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
247 }
248 }//EMCAL
249 else if(cells->GetType()==AliESDCaloCells::kPHOSCell){
250 Int_t relId[4];
251 Int_t irow = -1, icol = -1;
252 fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
253 irow = relId[2];
254 icol = relId[3];
255 //imod = relId[0]-1;
256 if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
257 if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
258 if(fDebug > 1)
259 {
260 printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d ?",
261 fNCellsFromPHOSBorder, icol, irow,relId[0]-1);
262 if (okcol && okrow ) printf(" YES \n");
263 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
264 }
265 }//PHOS
266
267 if (okcol && okrow) return kTRUE;
268 else return kFALSE;
269
270}
271
272
273//_________________________________________________________________________________________________________
274Bool_t AliCalorimeterUtils::ClusterContainsBadChannel(TString calorimeter,UShort_t* cellList, Int_t nCells){
275 // Check that in the cluster cells, there is no bad channel of those stored
276 // in fEMCALBadChannelMap or fPHOSBadChannelMap
277
278 if (!fRemoveBadChannels) return kFALSE;
279
280 if(calorimeter == "EMCAL" && !fEMCALBadChannelMap->GetEntries()) return kFALSE;
281 if(calorimeter == "PHOS" && !fPHOSBadChannelMap ->GetEntries()) return kFALSE;
282
283 Int_t icol = -1;
284 Int_t irow = -1;
285 Int_t imod = -1;
286 for(Int_t iCell = 0; iCell<nCells; iCell++){
287
288 //Get the column and row
289 if(calorimeter == "EMCAL"){
290 Int_t iTower = -1, iIphi = -1, iIeta = -1;
291 fEMCALGeo->GetCellIndex(cellList[iCell],imod,iTower,iIphi,iIeta);
292 if(fEMCALBadChannelMap->GetEntries() <= imod) continue;
293 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
294 if(GetEMCALChannelStatus(imod, icol, irow))return kTRUE;
295 }
296 else if(calorimeter=="PHOS"){
297 Int_t relId[4];
298 fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId);
299 irow = relId[2];
300 icol = relId[3];
301 imod = relId[0]-1;
302 if(fPHOSBadChannelMap->GetEntries() <= imod)continue;
303 if(GetPHOSChannelStatus(imod, icol, irow)) return kTRUE;
304 }
305 else return kFALSE;
306
307 }// cell cluster loop
308
309 return kFALSE;
310
311}
312
313//____________________________________________________________________________________________________________________________________________________
314Int_t AliCalorimeterUtils::GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent * inputEvent) const
315{
316 //Get the EMCAL/PHOS module number that corresponds to this particle
317
318 Int_t absId = -1;
319 if(particle->GetDetector()=="EMCAL"){
320 fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
321 if(fDebug > 2)
322 printf("AliCalorimeterUtils::GetModuleNumber(PWG4AOD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
323 particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
324 return fEMCALGeo->GetSuperModuleNumber(absId) ;
325 }//EMCAL
326 else if(particle->GetDetector()=="PHOS"){
327 if(!strcmp(inputEvent->GetName(),"AliESDEvent")) {
328 AliESDCaloCluster *cluster = ((AliESDEvent*)inputEvent)->GetCaloCluster(particle->GetCaloLabel(0));
329 return GetModuleNumber(cluster);
330 }//ESDs
331 else{
332 AliAODCaloCluster *cluster = ((AliAODEvent*)inputEvent)->GetCaloCluster(particle->GetCaloLabel(0));
333 return GetModuleNumber(cluster);
334 }//AODs
335 }//PHOS
336
337 return -1;
338}
339
340//____________________________________________________________________________________________________________________________________________________
341Int_t AliCalorimeterUtils::GetModuleNumber(AliAODCaloCluster * cluster) const
342{
343 //Get the EMCAL/PHOS module number that corresponds to this cluster, input are AODs
344 TLorentzVector lv;
345 Double_t v[]={0.,0.,0.}; //not necessary to pass the real vertex.
346 cluster->GetMomentum(lv,v);
347 Float_t phi = lv.Phi();
348 if(phi < 0) phi+=TMath::TwoPi();
349 Int_t absId = -1;
350 if(cluster->IsEMCALCluster()){
351 fEMCALGeo->GetAbsCellIdFromEtaPhi(lv.Eta(),phi, absId);
352 if(fDebug > 2)
353 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
354 lv.Eta(), phi*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
355 return fEMCALGeo->GetSuperModuleNumber(absId) ;
356 }//EMCAL
357 else if(cluster->IsPHOSCluster()) {
358 Int_t relId[4];
359 if ( cluster->GetNCells() > 0) {
360 absId = cluster->GetCellAbsId(0);
361 if(fDebug > 2)
362 printf("AliCalorimeterUtils::GetModuleNumber(AOD) - PHOS: cluster eta %f, phi %f, e %f, absId %d\n",
363 lv.Eta(), phi*TMath::RadToDeg(), lv.E(), absId);
364 }
365 else return -1;
366
367 if ( absId >= 0) {
368 fPHOSGeo->AbsToRelNumbering(absId,relId);
369 if(fDebug > 2)
370 printf("AliCalorimeterUtils::GetModuleNumber(AOD) - PHOS: Module %d\n",relId[0]-1);
371 return relId[0]-1;
372 }
373 else return -1;
374 }//PHOS
375
376 return -1;
377}
378
379//____________________________________________________________________________________________________________________________________________________
380Int_t AliCalorimeterUtils::GetModuleNumber(AliESDCaloCluster * cluster) const
381{
382 //Get the EMCAL/PHOS module number that corresponds to this cluster, input are ESDs
383 TLorentzVector lv;
384 Double_t v[]={0.,0.,0.}; //not necessary to pass the real vertex.
385 cluster->GetMomentum(lv,v);
386 Float_t phi = lv.Phi();
387 if(phi < 0) phi+=TMath::TwoPi();
388 Int_t absId = -1;
389 if(cluster->IsEMCAL()){
390 fEMCALGeo->GetAbsCellIdFromEtaPhi(lv.Eta(),phi, absId);
391 if(fDebug > 2)
392 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
393 lv.Eta(), phi*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
394 return fEMCALGeo->GetSuperModuleNumber(absId) ;
395 }//EMCAL
396 else if(cluster->IsPHOS()){
397 Int_t relId[4];
398 if ( cluster->GetNCells() > 0) {
399 absId = cluster->GetCellAbsId(0);
400 if(fDebug > 2)
401 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - PHOS: cluster eta %f, phi %f, e %f, absId %d\n",
402 lv.Eta(), phi*TMath::RadToDeg(), lv.E(), absId);
403 }
404 else return -1;
405
406 if ( absId >= 0) {
407 fPHOSGeo->AbsToRelNumbering(absId,relId);
408 if(fDebug > 2)
409 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - PHOS: Module %d\n",relId[0]-1);
410 return relId[0]-1;
411 }
412 else return -1;
413 }//PHOS
414
415 return -1;
416}
417
418
419//_____________________________________________________________________________________________________________
420Int_t AliCalorimeterUtils::GetModuleNumberCellIndexes(const Int_t absId, const TString calo, Int_t & icol, Int_t & irow, Int_t & iRCU) const
421{
422 //Get the EMCAL/PHOS module, columns, row and RCU number that corresponds to this absId
423 Int_t imod = -1;
424 if ( absId >= 0) {
425 if(calo=="EMCAL"){
426 Int_t iTower = -1, iIphi = -1, iIeta = -1;
427 fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
428 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
429
430 //RCU0
431 if (0<=irow&&irow<8) iRCU=0; // first cable row
432 else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half;
433 //second cable row
434 //RCU1
435 else if(8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half;
436 //second cable row
437 else if(16<=irow&&irow<24) iRCU=1; // third cable row
438
439 if (imod%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
440 if (iRCU<0) {
441 printf("AliCalorimeterUtils::GetModuleNumberCellIndexes() - Wrong EMCAL RCU number = %d\n", iRCU);
442 abort();
443 }
444
445 return imod ;
446 }//EMCAL
447 else{//PHOS
448 Int_t relId[4];
449 fPHOSGeo->AbsToRelNumbering(absId,relId);
450 irow = relId[2];
451 icol = relId[3];
452 imod = relId[0]-1;
453 iRCU= (Int_t)(relId[2]-1)/16 ;
454 //Int_t iBranch= (Int_t)(relid[3]-1)/28 ; //0 to 1
455 if (iRCU >= 4) {
456 printf("AliCalorimeterUtils::GetModuleNumberCellIndexes() - Wrong PHOS RCU number = %d\n", iRCU);
457 abort();
458 }
459 return imod;
460 }//PHOS
461 }
462
463 return -1;
464}
465
466//_______________________________________________________________
467//void AliCalorimeterUtils::Init()
468//{
469// //Init reader. Method to be called in AliAnaPartCorrMaker
470//
471// fEMCALBadChannelMap->SetName(Form("EMCALBadMap_%s",fTaskName.Data()));
472// fPHOSBadChannelMap->SetName(Form("PHOSBadMap_%s",fTaskName.Data()));
473//}
474
475//_______________________________________________________________
476void AliCalorimeterUtils::InitParameters()
477{
478 //Initialize the parameters of the analysis.
479 fEMCALGeoName = "EMCAL_COMPLETE";
480 fPHOSGeoName = "PHOSgeo";
481
482 if(gGeoManager) {// geoManager was set
483 if(fDebug > 2)printf("AliCalorimeterUtils::InitParameters() - Geometry manager available\n");
484 fEMCALGeoMatrixSet = kTRUE;
485 fPHOSGeoMatrixSet = kTRUE;
486 }
487 else{
488 fEMCALGeoMatrixSet = kFALSE;
489 fPHOSGeoMatrixSet = kFALSE;
490 }
491
492 fRemoveBadChannels = kFALSE;
493
494 fNCellsFromEMCALBorder = 0;
495 fNCellsFromPHOSBorder = 0;
496 fNoEMCALBorderAtEta0 = kFALSE;
497}
498
499//________________________________________________________________
500void AliCalorimeterUtils::InitEMCALBadChannelStatusMap(){
501 //Init EMCAL bad channels map
502 if(fDebug > 0 )printf("AliCalorimeterUtils::InitEMCALBadChannelStatusMap()\n");
503 //In order to avoid rewriting the same histograms
504 Bool_t oldStatus = TH1::AddDirectoryStatus();
505 TH1::AddDirectory(kFALSE);
506
507 //for (int i = 0; i < 12; i++) fEMCALBadChannelMap->Add(new TH2I(Form("EMCALBadChannelMap_SM%d_%s",i,fTaskName.Data()),Form("EMCALBadChannelMap_SM%d",i), 48, 0, 48, 24, 0, 24));
508 for (int i = 0; i < 12; i++) fEMCALBadChannelMap->Add(new TH2I(Form("EMCALBadChannelMap_SM%d",i),Form("EMCALBadChannelMap_SM%d",i), 48, 0, 48, 24, 0, 24));
509
510 fEMCALBadChannelMap->SetOwner(kTRUE);
511 fEMCALBadChannelMap->Compress();
512
513 //In order to avoid rewriting the same histograms
514 TH1::AddDirectory(oldStatus);
515}
516
517//________________________________________________________________
518void AliCalorimeterUtils::InitPHOSBadChannelStatusMap(){
519 //Init PHOS bad channels map
520 if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSBadChannelStatusMap()\n");
521 //In order to avoid rewriting the same histograms
522 Bool_t oldStatus = TH1::AddDirectoryStatus();
523 TH1::AddDirectory(kFALSE);
524 //for (int i = 0; i < 5; i++)fPHOSBadChannelMap->Add(new TH2I(Form("PHOSBadChannelMap_Mod%d_%s",i,fTaskName.Data()),Form("PHOSBadChannelMap_Mod%d",i), 56, 0, 56, 64, 0, 64));
525 for (int i = 0; i < 5; i++)fPHOSBadChannelMap->Add(new TH2I(Form("PHOSBadChannelMap_Mod%d",i),Form("PHOSBadChannelMap_Mod%d",i), 56, 0, 56, 64, 0, 64));
526
527 fPHOSBadChannelMap->SetOwner(kTRUE);
528 fPHOSBadChannelMap->Compress();
529
530 //In order to avoid rewriting the same histograms
531 TH1::AddDirectory(oldStatus);
532}
533
534//________________________________________________________________
535void AliCalorimeterUtils::InitEMCALGeometry()
536{
537 //Initialize EMCAL geometry if it did not exist previously
538 if (!fEMCALGeo){
539 fEMCALGeo = new AliEMCALGeoUtils(fEMCALGeoName);
540 if(fDebug > 0){
541 printf("AliCalorimeterUtils::InitEMCALGeometry()");
542 if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices");
543 printf("\n");
544 }
545 }
546}
547
548//________________________________________________________________
549void AliCalorimeterUtils::InitPHOSGeometry()
550{
551 //Initialize PHOS geometry if it did not exist previously
552 if (!fPHOSGeo){
553 fPHOSGeo = new AliPHOSGeoUtils(fPHOSGeoName);
554 if(fDebug > 0){
555 printf("AliCalorimeterUtils::InitPHOSGeometry()");
556 if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices");
557 printf("\n");
558 }
559 }
560}
561
562//________________________________________________________________
563void AliCalorimeterUtils::Print(const Option_t * opt) const
564{
565
566 //Print some relevant parameters set for the analysis
567 if(! opt)
568 return;
569
570 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
571 printf("Remove Clusters with bad channels? %d\n",fRemoveBadChannels);
572 printf("Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
573 fNCellsFromEMCALBorder, fNCellsFromPHOSBorder);
574 if(fNoEMCALBorderAtEta0) printf("Do not remove EMCAL clusters at Eta = 0\n");
575
576 printf(" \n") ;
577}
578
579//________________________________________________________________
580void AliCalorimeterUtils::SetGeometryTransformationMatrices(AliVEvent* inputEvent)
581{
582 //Set the calorimeters transformation matrices
583
584 //Get the EMCAL transformation geometry matrices from ESD
585 if (!gGeoManager && fEMCALGeo) {//&& !fEMCALGeoMatrixSet) { FIXME
586 if(fDebug > 1)
587 printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load EMCAL misalignment matrices. \n");
588 if(!strcmp(inputEvent->GetName(),"AliESDEvent")) {
589 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
590 if(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod)) {
591 //printf("EMCAL: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod));
592 fEMCALGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod),mod) ;
593 fEMCALGeoMatrixSet = kTRUE;//At least one, so good
594 }
595 }// loop over super modules
596 }//ESD as input
597 else {
598 if(fDebug > 1)
599 printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
600 }//AOD as input
601 }//EMCAL geo && no geoManager
602
603 //Get the PHOS transformation geometry matrices from ESD
604 if (!gGeoManager && fPHOSGeo && !fPHOSGeoMatrixSet) {
605 if(fDebug > 1)
606 printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load PHOS misalignment matrices. \n");
607 if(!strcmp(inputEvent->GetName(),"AliESDEvent")) {
608 for(Int_t mod=0; mod < 5; mod++){
609 if(((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod)) {
610 //printf("PHOS: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod));
611 fPHOSGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod),mod) ;
612 fPHOSGeoMatrixSet = kTRUE; //At least one so good
613 }
614 }// loop over modules
615 }//ESD as input
616 else {
617 if(fDebug > 1)
618 printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
619 }//AOD as input
620 }//PHOS geo and geoManager was not set
621
622}
623