]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliCalorimeterUtils.cxx
Changing the /tmp directory pointing to the sanbox earlier in the generated analysis...
[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"
c8fe2783 31#include "AliVEvent.h"
765d44e7 32#include "AliAODPWG4Particle.h"
c8fe2783 33#include "AliVCluster.h"
34#include "AliVCaloCells.h"
35#include "AliMixedEvent.h"
765d44e7 36
37
38ClassImp(AliCalorimeterUtils)
39
40
41//____________________________________________________________________________
42 AliCalorimeterUtils::AliCalorimeterUtils() :
43 TObject(), fDebug(0),
c8fe2783 44 fEMCALGeoName("EMCAL_FIRSTYEAR"),fPHOSGeoName("PHOSgeo"),
765d44e7 45 fEMCALGeo(0x0), fPHOSGeo(0x0),
46 fEMCALGeoMatrixSet(kFALSE), fPHOSGeoMatrixSet(kFALSE),
47 fRemoveBadChannels(kFALSE),
78219bac 48 fEMCALBadChannelMap(0x0),fPHOSBadChannelMap(0x0),
765d44e7 49 fNCellsFromEMCALBorder(0), fNCellsFromPHOSBorder(0),
09e819c9 50 fNoEMCALBorderAtEta0(kFALSE),fRecalibration(kFALSE),
78219bac 51 fEMCALRecalibrationFactors(), fPHOSRecalibrationFactors()
765d44e7 52{
53 //Ctor
54
55 //Initialize parameters
56 InitParameters();
57}
78219bac 58/*
765d44e7 59//____________________________________________________________________________
60AliCalorimeterUtils::AliCalorimeterUtils(const AliCalorimeterUtils & calo) :
61 TObject(calo), fDebug(calo.fDebug),
62 fEMCALGeoName(calo.fEMCALGeoName), fPHOSGeoName(calo.fPHOSGeoName),
63 fEMCALGeo(new AliEMCALGeoUtils(*calo.fEMCALGeo)),
64 fPHOSGeo(new AliPHOSGeoUtils(*calo.fPHOSGeo)),
65 fEMCALGeoMatrixSet(calo.fEMCALGeoMatrixSet),
66 fPHOSGeoMatrixSet(calo.fPHOSGeoMatrixSet),
67 fRemoveBadChannels(calo.fRemoveBadChannels),
68 fEMCALBadChannelMap(new TObjArray(*calo.fEMCALBadChannelMap)),
69 fPHOSBadChannelMap(new TObjArray(*calo.fPHOSBadChannelMap)),
70 fNCellsFromEMCALBorder(calo.fNCellsFromEMCALBorder),
71 fNCellsFromPHOSBorder(calo.fNCellsFromPHOSBorder),
09e819c9 72 fNoEMCALBorderAtEta0(calo.fNoEMCALBorderAtEta0),
73 fRecalibration(calo.fRecalibration),
74 fEMCALRecalibrationFactors(new TObjArray(*calo.fEMCALRecalibrationFactors)),
75 fPHOSRecalibrationFactors(new TObjArray(*calo.fEMCALRecalibrationFactors))
765d44e7 76{
77 // cpy ctor
78}
78219bac 79*/
765d44e7 80
81//_________________________________
82AliCalorimeterUtils::~AliCalorimeterUtils() {
83 //Dtor
84
4df35693 85 //if(fPHOSGeo) delete fPHOSGeo ;
765d44e7 86 if(fEMCALGeo) delete fEMCALGeo ;
87
88 if(fEMCALBadChannelMap) {
89 fEMCALBadChannelMap->Clear();
90 delete fEMCALBadChannelMap;
91 }
92 if(fPHOSBadChannelMap) {
93 fPHOSBadChannelMap->Clear();
94 delete fPHOSBadChannelMap;
95 }
96
09e819c9 97 if(fEMCALRecalibrationFactors) {
78219bac 98 fEMCALRecalibrationFactors->Clear();
99 delete fEMCALRecalibrationFactors;
09e819c9 100 }
101 if(fPHOSRecalibrationFactors) {
78219bac 102 fPHOSRecalibrationFactors->Clear();
103 delete fPHOSRecalibrationFactors;
09e819c9 104 }
105
765d44e7 106}
107
108//_______________________________________________________________
c8fe2783 109Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliVCluster* cluster, AliVCaloCells* cells, AliVEvent * event, Int_t iev) const {
110
765d44e7 111 // Given the list of AbsId of the cluster, get the maximum cell and
112 // check if there are fNCellsFromBorder from the calorimeter border
113
c8fe2783 114 //If the distance to the border is 0 or negative just exit accept all clusters
115 if(cells->GetType()==AliVCaloCells::kEMCALCell && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
116 if(cells->GetType()==AliVCaloCells::kPHOSCell && fNCellsFromPHOSBorder <= 0 ) return kTRUE;
765d44e7 117
c8fe2783 118 Int_t absIdMax = -1;
765d44e7 119 Float_t ampMax = -1;
c8fe2783 120
121 AliMixedEvent * mixEvent = dynamic_cast<AliMixedEvent*> (event);
122 Int_t nMixedEvents = 0 ;
123 Int_t * cellsCumul = NULL ;
124 Int_t numberOfCells = 0 ;
125 if (mixEvent){
126 nMixedEvents = mixEvent->GetNumberOfEvents() ;
127 if (cells->GetType()==AliVCaloCells::kEMCALCell) {
128 cellsCumul = mixEvent->GetEMCALCellsCumul() ;
129 numberOfCells = mixEvent->GetNumberOfEMCALCells() ;
130 }
131
132 else if (cells->GetType()==AliVCaloCells::kPHOSCell) {
133 cellsCumul = mixEvent->GetPHOSCellsCumul() ;
134 numberOfCells = mixEvent->GetNumberOfPHOSCells() ;
135 }
136 Int_t startCell = cellsCumul[iev] ;
137 Int_t endCell = (iev+1 < nMixedEvents)?cellsCumul[iev+1]:numberOfCells;
138 //Find cells with maximum amplitude
139 for(Int_t i = 0; i < cluster->GetNCells() ; i++){
140 Int_t absId = cluster->GetCellAbsId(i) ;
141 for (Int_t j = startCell; j < endCell ; j++) {
142 Short_t cellNumber;
143 Double_t amp ;
144 Double_t time;
145 cells->GetCell(j, cellNumber, amp, time) ;
146 if (absId == cellNumber) {
147 if(amp > ampMax){
148 ampMax = amp;
149 absIdMax = absId;
150 }
151 }
152 }
153 }
154 } else {
155 for(Int_t i = 0; i < cluster->GetNCells() ; i++){
156 Int_t absId = cluster->GetCellAbsId(i) ;
157 Float_t amp = cells->GetCellAmplitude(absId);
158 if(amp > ampMax){
159 ampMax = amp;
160 absIdMax = absId;
161 }
162 }
163 }
765d44e7 164
165 if(fDebug > 1)
166 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n",
167 absIdMax, ampMax, cluster->E());
168
169 if(absIdMax==-1) return kFALSE;
170
171 //Check if the cell is close to the borders:
172 Bool_t okrow = kFALSE;
173 Bool_t okcol = kFALSE;
174
c8fe2783 175 if(cells->GetType()==AliVCaloCells::kEMCALCell){
765d44e7 176
177 Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
178 fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
179 fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
180
181 //Check rows/phi
182 if(iSM < 10){
183 if(iphi >= fNCellsFromEMCALBorder && iphi < 24-fNCellsFromEMCALBorder) okrow =kTRUE;
184 }
185 else{
186 if(iphi >= fNCellsFromEMCALBorder && iphi < 12-fNCellsFromEMCALBorder) okrow =kTRUE;
187 }
188
189 //Check collumns/eta
190 if(!fNoEMCALBorderAtEta0){
191 if(ieta > fNCellsFromEMCALBorder && ieta < 48-fNCellsFromEMCALBorder) okcol =kTRUE;
192 }
193 else{
194 if(iSM%2==0){
195 if(ieta >= fNCellsFromEMCALBorder) okcol = kTRUE;
196 }
197 else {
198 if(ieta < 48-fNCellsFromEMCALBorder) okcol = kTRUE;
199 }
200 }//eta 0 not checked
201 if(fDebug > 1)
202 {
203 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?",
204 fNCellsFromEMCALBorder, ieta, iphi, iSM);
205 if (okcol && okrow ) printf(" YES \n");
206 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
207 }
208 }//EMCAL
c8fe2783 209 else if(cells->GetType()==AliVCaloCells::kPHOSCell){
765d44e7 210 Int_t relId[4];
211 Int_t irow = -1, icol = -1;
212 fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
213 irow = relId[2];
214 icol = relId[3];
215 //imod = relId[0]-1;
216 if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
217 if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
218 if(fDebug > 1)
219 {
220 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d?",
221 fNCellsFromPHOSBorder, icol, irow, relId[0]-1);
222 if (okcol && okrow ) printf(" YES \n");
223 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
224 }
225 }//PHOS
226
227 if (okcol && okrow) return kTRUE;
228 else return kFALSE;
229
230}
231
232//_______________________________________________________________
c8fe2783 233//Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliESDCaloCluster* cluster, AliESDCaloCells* cells) const {
234// // Given the list of AbsId of the cluster, get the maximum cell and
235// // check if there are fNCellsFromBorder from the calorimeter border
236//
237// //If the distance to the border is 0 or negative just exit accept all clusters
238// if(cells->GetType()==AliVCaloCells::kEMCALCell && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
239// if(cells->GetType()==AliVCaloCells::kPHOSCell && fNCellsFromPHOSBorder <= 0 ) return kTRUE;
240//
241// //Find cell with maximum amplitude
242// Int_t absIdMax = -1;
243// Float_t ampMax = -1;
244// for(Int_t i = 0; i < cluster->GetNCells() ; i++){
245// Int_t absId = cluster->GetCellAbsId(i) ;
246// Float_t amp = cells->GetCellAmplitude(absId);
247// if(amp > ampMax){
248// ampMax = amp;
249// absIdMax = absId;
250// }
251// }
252//
253// if(fDebug > 1)
254// printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n",
255// absIdMax, ampMax, cluster->E());
256// if(absIdMax==-1) return kFALSE;
257//
258// //Check if the cell is close to the borders:
259// Bool_t okrow = kFALSE;
260// Bool_t okcol = kFALSE;
261//
262// if(cells->GetType()==AliESDCaloCells::kEMCALCell){
263//
264// Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
265// fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
266// fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
267//
268// //Check rows/phi
269// if(iSM < 10){
270// if(iphi >= fNCellsFromEMCALBorder && iphi < 24-fNCellsFromEMCALBorder) okrow =kTRUE;
271// }
272// else{
273// if(iphi >= fNCellsFromEMCALBorder && iphi < 12-fNCellsFromEMCALBorder) okrow =kTRUE;
274// }
275//
276// //Check collumns/eta
277// if(!fNoEMCALBorderAtEta0){
278// if(ieta > fNCellsFromEMCALBorder && ieta < 48-fNCellsFromEMCALBorder) okcol =kTRUE;
279// }
280// else{
281// if(iSM%2==0){
282// if(ieta >= fNCellsFromEMCALBorder) okcol = kTRUE;
283// }
284// else {
285// if(ieta < 48-fNCellsFromEMCALBorder) okcol = kTRUE;
286// }
287// }//eta 0 not checked
288// if(fDebug > 1)
289// {
290// printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?",
291// fNCellsFromEMCALBorder, ieta, iphi, iSM);
292// if (okcol && okrow ) printf(" YES \n");
293// else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
294// }
295// }//EMCAL
296// else if(cells->GetType()==AliVCaloCells::kPHOSCell){
297// Int_t relId[4];
298// Int_t irow = -1, icol = -1;
299// fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
300// irow = relId[2];
301// icol = relId[3];
302// //imod = relId[0]-1;
303// if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
304// if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
305// if(fDebug > 1)
306// {
307// printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d ?",
308// fNCellsFromPHOSBorder, icol, irow,relId[0]-1);
309// if (okcol && okrow ) printf(" YES \n");
310// else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
311// }
312// }//PHOS
313//
314// if (okcol && okrow) return kTRUE;
315// else return kFALSE;
316//
317//}
318//
765d44e7 319
320//_________________________________________________________________________________________________________
321Bool_t AliCalorimeterUtils::ClusterContainsBadChannel(TString calorimeter,UShort_t* cellList, Int_t nCells){
322 // Check that in the cluster cells, there is no bad channel of those stored
323 // in fEMCALBadChannelMap or fPHOSBadChannelMap
324
325 if (!fRemoveBadChannels) return kFALSE;
36037088 326 //printf("fEMCALBadChannelMap %p, fPHOSBadChannelMap %p \n",fEMCALBadChannelMap,fPHOSBadChannelMap);
78219bac 327 if(calorimeter == "EMCAL" && !fEMCALBadChannelMap) return kFALSE;
328 if(calorimeter == "PHOS" && !fPHOSBadChannelMap) return kFALSE;
765d44e7 329
330 Int_t icol = -1;
331 Int_t irow = -1;
332 Int_t imod = -1;
333 for(Int_t iCell = 0; iCell<nCells; iCell++){
334
335 //Get the column and row
336 if(calorimeter == "EMCAL"){
337 Int_t iTower = -1, iIphi = -1, iIeta = -1;
338 fEMCALGeo->GetCellIndex(cellList[iCell],imod,iTower,iIphi,iIeta);
339 if(fEMCALBadChannelMap->GetEntries() <= imod) continue;
340 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
341 if(GetEMCALChannelStatus(imod, icol, irow))return kTRUE;
342 }
343 else if(calorimeter=="PHOS"){
344 Int_t relId[4];
345 fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId);
346 irow = relId[2];
347 icol = relId[3];
348 imod = relId[0]-1;
349 if(fPHOSBadChannelMap->GetEntries() <= imod)continue;
350 if(GetPHOSChannelStatus(imod, icol, irow)) return kTRUE;
351 }
352 else return kFALSE;
353
354 }// cell cluster loop
355
356 return kFALSE;
357
358}
359
360//____________________________________________________________________________________________________________________________________________________
361Int_t AliCalorimeterUtils::GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent * inputEvent) const
362{
363 //Get the EMCAL/PHOS module number that corresponds to this particle
364
365 Int_t absId = -1;
366 if(particle->GetDetector()=="EMCAL"){
367 fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
368 if(fDebug > 2)
369 printf("AliCalorimeterUtils::GetModuleNumber(PWG4AOD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
370 particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
371 return fEMCALGeo->GetSuperModuleNumber(absId) ;
372 }//EMCAL
373 else if(particle->GetDetector()=="PHOS"){
c8fe2783 374 AliVCluster *cluster = inputEvent->GetCaloCluster(particle->GetCaloLabel(0));
375 return GetModuleNumber(cluster);
765d44e7 376 }//PHOS
377
378 return -1;
379}
380
381//____________________________________________________________________________________________________________________________________________________
c8fe2783 382Int_t AliCalorimeterUtils::GetModuleNumber(AliVCluster * cluster) const
765d44e7 383{
384 //Get the EMCAL/PHOS module number that corresponds to this cluster, input are AODs
385 TLorentzVector lv;
386 Double_t v[]={0.,0.,0.}; //not necessary to pass the real vertex.
387 cluster->GetMomentum(lv,v);
388 Float_t phi = lv.Phi();
389 if(phi < 0) phi+=TMath::TwoPi();
390 Int_t absId = -1;
c8fe2783 391 if(cluster->IsEMCAL()){
765d44e7 392 fEMCALGeo->GetAbsCellIdFromEtaPhi(lv.Eta(),phi, absId);
393 if(fDebug > 2)
394 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
395 lv.Eta(), phi*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
396 return fEMCALGeo->GetSuperModuleNumber(absId) ;
397 }//EMCAL
c8fe2783 398 else if(cluster->IsPHOS()) {
765d44e7 399 Int_t relId[4];
400 if ( cluster->GetNCells() > 0) {
401 absId = cluster->GetCellAbsId(0);
402 if(fDebug > 2)
403 printf("AliCalorimeterUtils::GetModuleNumber(AOD) - PHOS: cluster eta %f, phi %f, e %f, absId %d\n",
404 lv.Eta(), phi*TMath::RadToDeg(), lv.E(), absId);
405 }
406 else return -1;
407
408 if ( absId >= 0) {
409 fPHOSGeo->AbsToRelNumbering(absId,relId);
410 if(fDebug > 2)
411 printf("AliCalorimeterUtils::GetModuleNumber(AOD) - PHOS: Module %d\n",relId[0]-1);
412 return relId[0]-1;
413 }
414 else return -1;
415 }//PHOS
416
417 return -1;
418}
419
765d44e7 420//_____________________________________________________________________________________________________________
421Int_t AliCalorimeterUtils::GetModuleNumberCellIndexes(const Int_t absId, const TString calo, Int_t & icol, Int_t & irow, Int_t & iRCU) const
422{
423 //Get the EMCAL/PHOS module, columns, row and RCU number that corresponds to this absId
424 Int_t imod = -1;
425 if ( absId >= 0) {
426 if(calo=="EMCAL"){
427 Int_t iTower = -1, iIphi = -1, iIeta = -1;
428 fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
429 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
430
431 //RCU0
432 if (0<=irow&&irow<8) iRCU=0; // first cable row
433 else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half;
434 //second cable row
435 //RCU1
436 else if(8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half;
437 //second cable row
438 else if(16<=irow&&irow<24) iRCU=1; // third cable row
439
440 if (imod%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
441 if (iRCU<0) {
442 printf("AliCalorimeterUtils::GetModuleNumberCellIndexes() - Wrong EMCAL RCU number = %d\n", iRCU);
443 abort();
444 }
445
446 return imod ;
447 }//EMCAL
448 else{//PHOS
449 Int_t relId[4];
450 fPHOSGeo->AbsToRelNumbering(absId,relId);
451 irow = relId[2];
452 icol = relId[3];
453 imod = relId[0]-1;
454 iRCU= (Int_t)(relId[2]-1)/16 ;
455 //Int_t iBranch= (Int_t)(relid[3]-1)/28 ; //0 to 1
456 if (iRCU >= 4) {
457 printf("AliCalorimeterUtils::GetModuleNumberCellIndexes() - Wrong PHOS RCU number = %d\n", iRCU);
458 abort();
459 }
460 return imod;
461 }//PHOS
462 }
463
464 return -1;
465}
466
467//_______________________________________________________________
468//void AliCalorimeterUtils::Init()
469//{
470// //Init reader. Method to be called in AliAnaPartCorrMaker
471//
472// fEMCALBadChannelMap->SetName(Form("EMCALBadMap_%s",fTaskName.Data()));
473// fPHOSBadChannelMap->SetName(Form("PHOSBadMap_%s",fTaskName.Data()));
474//}
475
476//_______________________________________________________________
477void AliCalorimeterUtils::InitParameters()
478{
479 //Initialize the parameters of the analysis.
c8fe2783 480 fEMCALGeoName = "EMCAL_FIRSTYEAR";
765d44e7 481 fPHOSGeoName = "PHOSgeo";
482
483 if(gGeoManager) {// geoManager was set
484 if(fDebug > 2)printf("AliCalorimeterUtils::InitParameters() - Geometry manager available\n");
485 fEMCALGeoMatrixSet = kTRUE;
486 fPHOSGeoMatrixSet = kTRUE;
487 }
488 else{
489 fEMCALGeoMatrixSet = kFALSE;
490 fPHOSGeoMatrixSet = kFALSE;
491 }
492
493 fRemoveBadChannels = kFALSE;
494
495 fNCellsFromEMCALBorder = 0;
496 fNCellsFromPHOSBorder = 0;
497 fNoEMCALBorderAtEta0 = kFALSE;
498}
499
500//________________________________________________________________
501void AliCalorimeterUtils::InitEMCALBadChannelStatusMap(){
502 //Init EMCAL bad channels map
503 if(fDebug > 0 )printf("AliCalorimeterUtils::InitEMCALBadChannelStatusMap()\n");
504 //In order to avoid rewriting the same histograms
505 Bool_t oldStatus = TH1::AddDirectoryStatus();
506 TH1::AddDirectory(kFALSE);
78219bac 507
508 fEMCALBadChannelMap = new TObjArray(12);
509 //TH2F * hTemp = new TH2I("EMCALBadChannelMap","EMCAL SuperModule bad channel map", 48, 0, 48, 24, 0, 24);
510 for (int i = 0; i < 12; i++) {
511 fEMCALBadChannelMap->Add(new TH2I(Form("EMCALBadChannelMap_Mod%d",i),Form("EMCALBadChannelMap_Mod%d",i), 48, 0, 48, 24, 0, 24));
512 //fEMCALBadChannelMap->Add((TH2I*)hTemp->Clone(Form("EMCALBadChannelMap_Mod%d",i)));
513 }
514
515 //delete hTemp;
765d44e7 516
517 fEMCALBadChannelMap->SetOwner(kTRUE);
518 fEMCALBadChannelMap->Compress();
78219bac 519
765d44e7 520 //In order to avoid rewriting the same histograms
521 TH1::AddDirectory(oldStatus);
522}
523
524//________________________________________________________________
525void AliCalorimeterUtils::InitPHOSBadChannelStatusMap(){
526 //Init PHOS bad channels map
527 if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSBadChannelStatusMap()\n");
528 //In order to avoid rewriting the same histograms
529 Bool_t oldStatus = TH1::AddDirectoryStatus();
530 TH1::AddDirectory(kFALSE);
78219bac 531
532 fPHOSBadChannelMap = new TObjArray(5);
765d44e7 533 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));
534
535 fPHOSBadChannelMap->SetOwner(kTRUE);
536 fPHOSBadChannelMap->Compress();
537
538 //In order to avoid rewriting the same histograms
539 TH1::AddDirectory(oldStatus);
540}
541
09e819c9 542//________________________________________________________________
543void AliCalorimeterUtils::InitEMCALRecalibrationFactors(){
544 //Init EMCAL recalibration factors
545 if(fDebug > 0 )printf("AliCalorimeterUtils::InitEMCALRecalibrationFactors()\n");
546 //In order to avoid rewriting the same histograms
547 Bool_t oldStatus = TH1::AddDirectoryStatus();
548 TH1::AddDirectory(kFALSE);
78219bac 549
550 fEMCALRecalibrationFactors = new TObjArray(12);
09e819c9 551 for (int i = 0; i < 12; i++) fEMCALRecalibrationFactors->Add(new TH2F(Form("EMCALRecalFactors_SM%d",i),Form("EMCALRecalFactors_SM%d",i), 48, 0, 48, 24, 0, 24));
552 //Init the histograms with 1
553 for (Int_t sm = 0; sm < 12; sm++) {
554 for (Int_t i = 0; i < 48; i++) {
555 for (Int_t j = 0; j < 24; j++) {
556 SetEMCALChannelRecalibrationFactor(sm,i,j,1.);
557 }
558 }
559 }
560 fEMCALRecalibrationFactors->SetOwner(kTRUE);
561 fEMCALRecalibrationFactors->Compress();
562
563 //In order to avoid rewriting the same histograms
564 TH1::AddDirectory(oldStatus);
565}
566
567//________________________________________________________________
568void AliCalorimeterUtils::InitPHOSRecalibrationFactors(){
569 //Init EMCAL recalibration factors
570 if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSRecalibrationFactors()\n");
571 //In order to avoid rewriting the same histograms
572 Bool_t oldStatus = TH1::AddDirectoryStatus();
573 TH1::AddDirectory(kFALSE);
78219bac 574
575 fPHOSRecalibrationFactors = new TObjArray(5);
09e819c9 576 for (int i = 0; i < 5; i++)fPHOSRecalibrationFactors->Add(new TH2F(Form("PHOSRecalFactors_Mod%d",i),Form("PHOSRecalFactors_Mod%d",i), 56, 0, 56, 64, 0, 64));
577 //Init the histograms with 1
578 for (Int_t m = 0; m < 5; m++) {
579 for (Int_t i = 0; i < 56; i++) {
580 for (Int_t j = 0; j < 64; j++) {
581 SetPHOSChannelRecalibrationFactor(m,i,j,1.);
582 }
583 }
584 }
585 fPHOSRecalibrationFactors->SetOwner(kTRUE);
586 fPHOSRecalibrationFactors->Compress();
587
588 //In order to avoid rewriting the same histograms
589 TH1::AddDirectory(oldStatus);
590}
591
592
765d44e7 593//________________________________________________________________
594void AliCalorimeterUtils::InitEMCALGeometry()
595{
596 //Initialize EMCAL geometry if it did not exist previously
597 if (!fEMCALGeo){
598 fEMCALGeo = new AliEMCALGeoUtils(fEMCALGeoName);
599 if(fDebug > 0){
600 printf("AliCalorimeterUtils::InitEMCALGeometry()");
601 if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices");
602 printf("\n");
603 }
604 }
605}
606
607//________________________________________________________________
608void AliCalorimeterUtils::InitPHOSGeometry()
609{
610 //Initialize PHOS geometry if it did not exist previously
611 if (!fPHOSGeo){
612 fPHOSGeo = new AliPHOSGeoUtils(fPHOSGeoName);
613 if(fDebug > 0){
614 printf("AliCalorimeterUtils::InitPHOSGeometry()");
615 if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices");
616 printf("\n");
617 }
618 }
619}
620
621//________________________________________________________________
622void AliCalorimeterUtils::Print(const Option_t * opt) const
623{
624
625 //Print some relevant parameters set for the analysis
626 if(! opt)
627 return;
628
629 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
630 printf("Remove Clusters with bad channels? %d\n",fRemoveBadChannels);
631 printf("Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
632 fNCellsFromEMCALBorder, fNCellsFromPHOSBorder);
633 if(fNoEMCALBorderAtEta0) printf("Do not remove EMCAL clusters at Eta = 0\n");
09e819c9 634 printf("Recalibrate Clusters? %d\n",fRecalibration);
765d44e7 635
636 printf(" \n") ;
637}
638
09e819c9 639//________________________________________________________________
c8fe2783 640Float_t AliCalorimeterUtils::RecalibrateClusterEnergy(AliVCluster * cluster, AliVCaloCells * cells){
09e819c9 641 // Recalibrate the cluster energy, considering the recalibration map and the energy of the cells that compose the cluster.
642 // ESD case
643
644 if(!cells) {
645 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(ESD) - Cells pointer does not exist, stop!");
646 abort();
647 }
648 //Get the cluster number of cells and list of absId, check what kind of cluster do we have.
649 UShort_t * index = cluster->GetCellsAbsId() ;
650 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
651 Int_t ncells = cluster->GetNCells();
652 TString calo = "EMCAL";
653 if(cluster->IsPHOS()) calo = "PHOS";
654 //Initialize some used variables
655 Float_t energy = 0;
656 Int_t absId = -1;
657 Int_t icol = -1, irow = -1, iRCU = -1, module=1;
658 Float_t factor = 1, frac = 0;
659
660 //Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
661 for(Int_t icell = 0; icell < ncells; icell++){
662 absId = index[icell];
663 frac = fraction[icell];
664 if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
665 module = GetModuleNumberCellIndexes(absId,calo,icol,irow,iRCU);
666 if(cluster->IsPHOS()) factor = GetPHOSChannelRecalibrationFactor (module,icol,irow);
667 else factor = GetEMCALChannelRecalibrationFactor(module,icol,irow);
668 if(fDebug>2)
669 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(ESD) - recalibrate cell: %s, module %d, col %d, row %d, cell fraction %f, recalibration factor %f, cell energy %f\n",
670 calo.Data(),module,icol,irow,frac,factor,cells->GetCellAmplitude(absId));
671
672 energy += cells->GetCellAmplitude(absId)*factor*frac;
673 }
674
675 if(fDebug>1)
676 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(ESD) - Energy before %f, after %f\n",cluster->E(),energy);
677
678 return energy;
09e819c9 679}
680
765d44e7 681//________________________________________________________________
682void AliCalorimeterUtils::SetGeometryTransformationMatrices(AliVEvent* inputEvent)
683{
684 //Set the calorimeters transformation matrices
685
686 //Get the EMCAL transformation geometry matrices from ESD
36037088 687 if (!gGeoManager && fEMCALGeo && !fEMCALGeoMatrixSet) {
765d44e7 688 if(fDebug > 1)
689 printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load EMCAL misalignment matrices. \n");
690 if(!strcmp(inputEvent->GetName(),"AliESDEvent")) {
691 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
c8fe2783 692 if(inputEvent->GetEMCALMatrix(mod)) {
765d44e7 693 //printf("EMCAL: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod));
c8fe2783 694 fEMCALGeo->SetMisalMatrix(inputEvent->GetEMCALMatrix(mod),mod) ;
765d44e7 695 fEMCALGeoMatrixSet = kTRUE;//At least one, so good
696 }
697 }// loop over super modules
698 }//ESD as input
699 else {
700 if(fDebug > 1)
701 printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
702 }//AOD as input
703 }//EMCAL geo && no geoManager
704
705 //Get the PHOS transformation geometry matrices from ESD
706 if (!gGeoManager && fPHOSGeo && !fPHOSGeoMatrixSet) {
707 if(fDebug > 1)
708 printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load PHOS misalignment matrices. \n");
709 if(!strcmp(inputEvent->GetName(),"AliESDEvent")) {
710 for(Int_t mod=0; mod < 5; mod++){
c8fe2783 711 if(inputEvent->GetPHOSMatrix(mod)) {
765d44e7 712 //printf("PHOS: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod));
c8fe2783 713 fPHOSGeo->SetMisalMatrix(inputEvent->GetPHOSMatrix(mod),mod) ;
765d44e7 714 fPHOSGeoMatrixSet = kTRUE; //At least one so good
715 }
716 }// loop over modules
717 }//ESD as input
718 else {
719 if(fDebug > 1)
720 printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
721 }//AOD as input
722 }//PHOS geo and geoManager was not set
723
724}
725