1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 //_________________________________________________________________________
18 // Class utility for Calorimeter specific selection methods ///
22 //-- Author: Gustavo Conesa (LPSC-Grenoble)
23 //////////////////////////////////////////////////////////////////////////////
26 // --- ROOT system ---
27 #include "TGeoManager.h"
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"
40 ClassImp(AliCalorimeterUtils)
43 //____________________________________________________________________________
44 AliCalorimeterUtils::AliCalorimeterUtils() :
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),fRecalibration(kFALSE),
53 fEMCALRecalibrationFactors(new TObjArray()), fPHOSRecalibrationFactors(new TObjArray())
57 //Initialize parameters
61 //____________________________________________________________________________
62 AliCalorimeterUtils::AliCalorimeterUtils(const AliCalorimeterUtils & calo) :
63 TObject(calo), fDebug(calo.fDebug),
64 fEMCALGeoName(calo.fEMCALGeoName), fPHOSGeoName(calo.fPHOSGeoName),
65 fEMCALGeo(new AliEMCALGeoUtils(*calo.fEMCALGeo)),
66 fPHOSGeo(new AliPHOSGeoUtils(*calo.fPHOSGeo)),
67 fEMCALGeoMatrixSet(calo.fEMCALGeoMatrixSet),
68 fPHOSGeoMatrixSet(calo.fPHOSGeoMatrixSet),
69 fRemoveBadChannels(calo.fRemoveBadChannels),
70 fEMCALBadChannelMap(new TObjArray(*calo.fEMCALBadChannelMap)),
71 fPHOSBadChannelMap(new TObjArray(*calo.fPHOSBadChannelMap)),
72 fNCellsFromEMCALBorder(calo.fNCellsFromEMCALBorder),
73 fNCellsFromPHOSBorder(calo.fNCellsFromPHOSBorder),
74 fNoEMCALBorderAtEta0(calo.fNoEMCALBorderAtEta0),
75 fRecalibration(calo.fRecalibration),
76 fEMCALRecalibrationFactors(new TObjArray(*calo.fEMCALRecalibrationFactors)),
77 fPHOSRecalibrationFactors(new TObjArray(*calo.fEMCALRecalibrationFactors))
83 //_________________________________
84 AliCalorimeterUtils::~AliCalorimeterUtils() {
87 //if(fPHOSGeo) delete fPHOSGeo ;
88 if(fEMCALGeo) delete fEMCALGeo ;
90 if(fEMCALBadChannelMap) {
91 fEMCALBadChannelMap->Clear();
92 delete fEMCALBadChannelMap;
94 if(fPHOSBadChannelMap) {
95 fPHOSBadChannelMap->Clear();
96 delete fPHOSBadChannelMap;
99 if(fEMCALRecalibrationFactors) {
100 fEMCALRecalibrationFactors->Clear();
101 delete fEMCALRecalibrationFactors;
103 if(fPHOSRecalibrationFactors) {
104 fPHOSRecalibrationFactors->Clear();
105 delete fPHOSRecalibrationFactors;
110 //_______________________________________________________________
111 Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliAODCaloCluster* cluster, AliAODCaloCells* cells) const {
112 // Given the list of AbsId of the cluster, get the maximum cell and
113 // check if there are fNCellsFromBorder from the calorimeter border
115 //If the distance to the border is 0 or negative just exit accept all clusters
116 if(cells->GetType()==AliAODCaloCells::kEMCAL && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
117 if(cells->GetType()==AliAODCaloCells::kPHOS && fNCellsFromPHOSBorder <= 0 ) return kTRUE;
119 //Find cells with maximum amplitude
122 for(Int_t i = 0; i < cluster->GetNCells() ; i++){
123 Int_t absId = cluster->GetCellAbsId(i) ;
124 Float_t amp = cells->GetCellAmplitude(absId);
132 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n",
133 absIdMax, ampMax, cluster->E());
135 if(absIdMax==-1) return kFALSE;
137 //Check if the cell is close to the borders:
138 Bool_t okrow = kFALSE;
139 Bool_t okcol = kFALSE;
141 if(cells->GetType()==AliAODCaloCells::kEMCAL){
143 Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
144 fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
145 fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
149 if(iphi >= fNCellsFromEMCALBorder && iphi < 24-fNCellsFromEMCALBorder) okrow =kTRUE;
152 if(iphi >= fNCellsFromEMCALBorder && iphi < 12-fNCellsFromEMCALBorder) okrow =kTRUE;
156 if(!fNoEMCALBorderAtEta0){
157 if(ieta > fNCellsFromEMCALBorder && ieta < 48-fNCellsFromEMCALBorder) okcol =kTRUE;
161 if(ieta >= fNCellsFromEMCALBorder) okcol = kTRUE;
164 if(ieta < 48-fNCellsFromEMCALBorder) okcol = kTRUE;
169 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?",
170 fNCellsFromEMCALBorder, ieta, iphi, iSM);
171 if (okcol && okrow ) printf(" YES \n");
172 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
175 else if(cells->GetType()==AliAODCaloCells::kPHOS){
177 Int_t irow = -1, icol = -1;
178 fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
182 if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
183 if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
186 printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d?",
187 fNCellsFromPHOSBorder, icol, irow, relId[0]-1);
188 if (okcol && okrow ) printf(" YES \n");
189 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
193 if (okcol && okrow) return kTRUE;
198 //_______________________________________________________________
199 Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliESDCaloCluster* cluster, AliESDCaloCells* cells) const {
200 // Given the list of AbsId of the cluster, get the maximum cell and
201 // check if there are fNCellsFromBorder from the calorimeter border
203 //If the distance to the border is 0 or negative just exit accept all clusters
204 if(cells->GetType()==AliESDCaloCells::kEMCALCell && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
205 if(cells->GetType()==AliESDCaloCells::kPHOSCell && fNCellsFromPHOSBorder <= 0 ) return kTRUE;
207 //Find cell with maximum amplitude
210 for(Int_t i = 0; i < cluster->GetNCells() ; i++){
211 Int_t absId = cluster->GetCellAbsId(i) ;
212 Float_t amp = cells->GetCellAmplitude(absId);
220 printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n",
221 absIdMax, ampMax, cluster->E());
222 if(absIdMax==-1) return kFALSE;
224 //Check if the cell is close to the borders:
225 Bool_t okrow = kFALSE;
226 Bool_t okcol = kFALSE;
228 if(cells->GetType()==AliESDCaloCells::kEMCALCell){
230 Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
231 fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
232 fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
236 if(iphi >= fNCellsFromEMCALBorder && iphi < 24-fNCellsFromEMCALBorder) okrow =kTRUE;
239 if(iphi >= fNCellsFromEMCALBorder && iphi < 12-fNCellsFromEMCALBorder) okrow =kTRUE;
243 if(!fNoEMCALBorderAtEta0){
244 if(ieta > fNCellsFromEMCALBorder && ieta < 48-fNCellsFromEMCALBorder) okcol =kTRUE;
248 if(ieta >= fNCellsFromEMCALBorder) okcol = kTRUE;
251 if(ieta < 48-fNCellsFromEMCALBorder) okcol = kTRUE;
256 printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?",
257 fNCellsFromEMCALBorder, ieta, iphi, iSM);
258 if (okcol && okrow ) printf(" YES \n");
259 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
262 else if(cells->GetType()==AliESDCaloCells::kPHOSCell){
264 Int_t irow = -1, icol = -1;
265 fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
269 if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
270 if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
273 printf("AliCalorimeterUtils::CheckCellFiducialRegion(ESD) - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d ?",
274 fNCellsFromPHOSBorder, icol, irow,relId[0]-1);
275 if (okcol && okrow ) printf(" YES \n");
276 else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
280 if (okcol && okrow) return kTRUE;
286 //_________________________________________________________________________________________________________
287 Bool_t AliCalorimeterUtils::ClusterContainsBadChannel(TString calorimeter,UShort_t* cellList, Int_t nCells){
288 // Check that in the cluster cells, there is no bad channel of those stored
289 // in fEMCALBadChannelMap or fPHOSBadChannelMap
291 if (!fRemoveBadChannels) return kFALSE;
293 if(calorimeter == "EMCAL" && !fEMCALBadChannelMap->GetEntries()) return kFALSE;
294 if(calorimeter == "PHOS" && !fPHOSBadChannelMap ->GetEntries()) return kFALSE;
299 for(Int_t iCell = 0; iCell<nCells; iCell++){
301 //Get the column and row
302 if(calorimeter == "EMCAL"){
303 Int_t iTower = -1, iIphi = -1, iIeta = -1;
304 fEMCALGeo->GetCellIndex(cellList[iCell],imod,iTower,iIphi,iIeta);
305 if(fEMCALBadChannelMap->GetEntries() <= imod) continue;
306 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
307 if(GetEMCALChannelStatus(imod, icol, irow))return kTRUE;
309 else if(calorimeter=="PHOS"){
311 fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId);
315 if(fPHOSBadChannelMap->GetEntries() <= imod)continue;
316 if(GetPHOSChannelStatus(imod, icol, irow)) return kTRUE;
320 }// cell cluster loop
326 //____________________________________________________________________________________________________________________________________________________
327 Int_t AliCalorimeterUtils::GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent * inputEvent) const
329 //Get the EMCAL/PHOS module number that corresponds to this particle
332 if(particle->GetDetector()=="EMCAL"){
333 fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
335 printf("AliCalorimeterUtils::GetModuleNumber(PWG4AOD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
336 particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
337 return fEMCALGeo->GetSuperModuleNumber(absId) ;
339 else if(particle->GetDetector()=="PHOS"){
340 if(!strcmp(inputEvent->GetName(),"AliESDEvent")) {
341 AliESDCaloCluster *cluster = ((AliESDEvent*)inputEvent)->GetCaloCluster(particle->GetCaloLabel(0));
342 return GetModuleNumber(cluster);
345 AliAODCaloCluster *cluster = ((AliAODEvent*)inputEvent)->GetCaloCluster(particle->GetCaloLabel(0));
346 return GetModuleNumber(cluster);
353 //____________________________________________________________________________________________________________________________________________________
354 Int_t AliCalorimeterUtils::GetModuleNumber(AliAODCaloCluster * cluster) const
356 //Get the EMCAL/PHOS module number that corresponds to this cluster, input are AODs
358 Double_t v[]={0.,0.,0.}; //not necessary to pass the real vertex.
359 cluster->GetMomentum(lv,v);
360 Float_t phi = lv.Phi();
361 if(phi < 0) phi+=TMath::TwoPi();
363 if(cluster->IsEMCALCluster()){
364 fEMCALGeo->GetAbsCellIdFromEtaPhi(lv.Eta(),phi, absId);
366 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
367 lv.Eta(), phi*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
368 return fEMCALGeo->GetSuperModuleNumber(absId) ;
370 else if(cluster->IsPHOSCluster()) {
372 if ( cluster->GetNCells() > 0) {
373 absId = cluster->GetCellAbsId(0);
375 printf("AliCalorimeterUtils::GetModuleNumber(AOD) - PHOS: cluster eta %f, phi %f, e %f, absId %d\n",
376 lv.Eta(), phi*TMath::RadToDeg(), lv.E(), absId);
381 fPHOSGeo->AbsToRelNumbering(absId,relId);
383 printf("AliCalorimeterUtils::GetModuleNumber(AOD) - PHOS: Module %d\n",relId[0]-1);
392 //____________________________________________________________________________________________________________________________________________________
393 Int_t AliCalorimeterUtils::GetModuleNumber(AliESDCaloCluster * cluster) const
395 //Get the EMCAL/PHOS module number that corresponds to this cluster, input are ESDs
397 Double_t v[]={0.,0.,0.}; //not necessary to pass the real vertex.
398 cluster->GetMomentum(lv,v);
399 Float_t phi = lv.Phi();
400 if(phi < 0) phi+=TMath::TwoPi();
402 if(cluster->IsEMCAL()){
403 fEMCALGeo->GetAbsCellIdFromEtaPhi(lv.Eta(),phi, absId);
405 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
406 lv.Eta(), phi*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
407 return fEMCALGeo->GetSuperModuleNumber(absId) ;
409 else if(cluster->IsPHOS()){
411 if ( cluster->GetNCells() > 0) {
412 absId = cluster->GetCellAbsId(0);
414 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - PHOS: cluster eta %f, phi %f, e %f, absId %d\n",
415 lv.Eta(), phi*TMath::RadToDeg(), lv.E(), absId);
420 fPHOSGeo->AbsToRelNumbering(absId,relId);
422 printf("AliCalorimeterUtils::GetModuleNumber(ESD) - PHOS: Module %d\n",relId[0]-1);
432 //_____________________________________________________________________________________________________________
433 Int_t AliCalorimeterUtils::GetModuleNumberCellIndexes(const Int_t absId, const TString calo, Int_t & icol, Int_t & irow, Int_t & iRCU) const
435 //Get the EMCAL/PHOS module, columns, row and RCU number that corresponds to this absId
439 Int_t iTower = -1, iIphi = -1, iIeta = -1;
440 fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
441 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
444 if (0<=irow&&irow<8) iRCU=0; // first cable row
445 else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half;
448 else if(8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half;
450 else if(16<=irow&&irow<24) iRCU=1; // third cable row
452 if (imod%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
454 printf("AliCalorimeterUtils::GetModuleNumberCellIndexes() - Wrong EMCAL RCU number = %d\n", iRCU);
462 fPHOSGeo->AbsToRelNumbering(absId,relId);
466 iRCU= (Int_t)(relId[2]-1)/16 ;
467 //Int_t iBranch= (Int_t)(relid[3]-1)/28 ; //0 to 1
469 printf("AliCalorimeterUtils::GetModuleNumberCellIndexes() - Wrong PHOS RCU number = %d\n", iRCU);
479 //_______________________________________________________________
480 //void AliCalorimeterUtils::Init()
482 // //Init reader. Method to be called in AliAnaPartCorrMaker
484 // fEMCALBadChannelMap->SetName(Form("EMCALBadMap_%s",fTaskName.Data()));
485 // fPHOSBadChannelMap->SetName(Form("PHOSBadMap_%s",fTaskName.Data()));
488 //_______________________________________________________________
489 void AliCalorimeterUtils::InitParameters()
491 //Initialize the parameters of the analysis.
492 fEMCALGeoName = "EMCAL_COMPLETE";
493 fPHOSGeoName = "PHOSgeo";
495 if(gGeoManager) {// geoManager was set
496 if(fDebug > 2)printf("AliCalorimeterUtils::InitParameters() - Geometry manager available\n");
497 fEMCALGeoMatrixSet = kTRUE;
498 fPHOSGeoMatrixSet = kTRUE;
501 fEMCALGeoMatrixSet = kFALSE;
502 fPHOSGeoMatrixSet = kFALSE;
505 fRemoveBadChannels = kFALSE;
507 fNCellsFromEMCALBorder = 0;
508 fNCellsFromPHOSBorder = 0;
509 fNoEMCALBorderAtEta0 = kFALSE;
512 //________________________________________________________________
513 void AliCalorimeterUtils::InitEMCALBadChannelStatusMap(){
514 //Init EMCAL bad channels map
515 if(fDebug > 0 )printf("AliCalorimeterUtils::InitEMCALBadChannelStatusMap()\n");
516 //In order to avoid rewriting the same histograms
517 Bool_t oldStatus = TH1::AddDirectoryStatus();
518 TH1::AddDirectory(kFALSE);
520 //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));
521 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));
523 fEMCALBadChannelMap->SetOwner(kTRUE);
524 fEMCALBadChannelMap->Compress();
526 //In order to avoid rewriting the same histograms
527 TH1::AddDirectory(oldStatus);
530 //________________________________________________________________
531 void AliCalorimeterUtils::InitPHOSBadChannelStatusMap(){
532 //Init PHOS bad channels map
533 if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSBadChannelStatusMap()\n");
534 //In order to avoid rewriting the same histograms
535 Bool_t oldStatus = TH1::AddDirectoryStatus();
536 TH1::AddDirectory(kFALSE);
537 //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));
538 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));
540 fPHOSBadChannelMap->SetOwner(kTRUE);
541 fPHOSBadChannelMap->Compress();
543 //In order to avoid rewriting the same histograms
544 TH1::AddDirectory(oldStatus);
547 //________________________________________________________________
548 void AliCalorimeterUtils::InitEMCALRecalibrationFactors(){
549 //Init EMCAL recalibration factors
550 if(fDebug > 0 )printf("AliCalorimeterUtils::InitEMCALRecalibrationFactors()\n");
551 //In order to avoid rewriting the same histograms
552 Bool_t oldStatus = TH1::AddDirectoryStatus();
553 TH1::AddDirectory(kFALSE);
555 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));
556 //Init the histograms with 1
557 for (Int_t sm = 0; sm < 12; sm++) {
558 for (Int_t i = 0; i < 48; i++) {
559 for (Int_t j = 0; j < 24; j++) {
560 SetEMCALChannelRecalibrationFactor(sm,i,j,1.);
564 fEMCALRecalibrationFactors->SetOwner(kTRUE);
565 fEMCALRecalibrationFactors->Compress();
567 //In order to avoid rewriting the same histograms
568 TH1::AddDirectory(oldStatus);
571 //________________________________________________________________
572 void AliCalorimeterUtils::InitPHOSRecalibrationFactors(){
573 //Init EMCAL recalibration factors
574 if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSRecalibrationFactors()\n");
575 //In order to avoid rewriting the same histograms
576 Bool_t oldStatus = TH1::AddDirectoryStatus();
577 TH1::AddDirectory(kFALSE);
578 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));
579 //Init the histograms with 1
580 for (Int_t m = 0; m < 5; m++) {
581 for (Int_t i = 0; i < 56; i++) {
582 for (Int_t j = 0; j < 64; j++) {
583 SetPHOSChannelRecalibrationFactor(m,i,j,1.);
587 fPHOSRecalibrationFactors->SetOwner(kTRUE);
588 fPHOSRecalibrationFactors->Compress();
590 //In order to avoid rewriting the same histograms
591 TH1::AddDirectory(oldStatus);
595 //________________________________________________________________
596 void AliCalorimeterUtils::InitEMCALGeometry()
598 //Initialize EMCAL geometry if it did not exist previously
600 fEMCALGeo = new AliEMCALGeoUtils(fEMCALGeoName);
602 printf("AliCalorimeterUtils::InitEMCALGeometry()");
603 if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices");
609 //________________________________________________________________
610 void AliCalorimeterUtils::InitPHOSGeometry()
612 //Initialize PHOS geometry if it did not exist previously
614 fPHOSGeo = new AliPHOSGeoUtils(fPHOSGeoName);
616 printf("AliCalorimeterUtils::InitPHOSGeometry()");
617 if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices");
623 //________________________________________________________________
624 void AliCalorimeterUtils::Print(const Option_t * opt) const
627 //Print some relevant parameters set for the analysis
631 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
632 printf("Remove Clusters with bad channels? %d\n",fRemoveBadChannels);
633 printf("Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
634 fNCellsFromEMCALBorder, fNCellsFromPHOSBorder);
635 if(fNoEMCALBorderAtEta0) printf("Do not remove EMCAL clusters at Eta = 0\n");
636 printf("Recalibrate Clusters? %d\n",fRecalibration);
641 //________________________________________________________________
642 Float_t AliCalorimeterUtils::RecalibrateClusterEnergy(AliESDCaloCluster * cluster, AliESDCaloCells * cells){
643 // Recalibrate the cluster energy, considering the recalibration map and the energy of the cells that compose the cluster.
647 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(ESD) - Cells pointer does not exist, stop!");
650 //Get the cluster number of cells and list of absId, check what kind of cluster do we have.
651 UShort_t * index = cluster->GetCellsAbsId() ;
652 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
653 Int_t ncells = cluster->GetNCells();
654 TString calo = "EMCAL";
655 if(cluster->IsPHOS()) calo = "PHOS";
656 //Initialize some used variables
659 Int_t icol = -1, irow = -1, iRCU = -1, module=1;
660 Float_t factor = 1, frac = 0;
662 //Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
663 for(Int_t icell = 0; icell < ncells; icell++){
664 absId = index[icell];
665 frac = fraction[icell];
666 if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
667 module = GetModuleNumberCellIndexes(absId,calo,icol,irow,iRCU);
668 if(cluster->IsPHOS()) factor = GetPHOSChannelRecalibrationFactor (module,icol,irow);
669 else factor = GetEMCALChannelRecalibrationFactor(module,icol,irow);
671 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(ESD) - recalibrate cell: %s, module %d, col %d, row %d, cell fraction %f, recalibration factor %f, cell energy %f\n",
672 calo.Data(),module,icol,irow,frac,factor,cells->GetCellAmplitude(absId));
674 energy += cells->GetCellAmplitude(absId)*factor*frac;
678 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(ESD) - Energy before %f, after %f\n",cluster->E(),energy);
684 //________________________________________________________________
685 Float_t AliCalorimeterUtils::RecalibrateClusterEnergy(AliAODCaloCluster * cluster, AliAODCaloCells * cells){
686 // Recalibrate the cluster energy, considering the recalibration map and the energy of the cells that compose the cluster.
690 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(AOD) - Cells pointer does not exist, stop!");
694 //Get the cluster number of cells and list of absId, check what kind of cluster do we have.
695 UShort_t * index = cluster->GetCellsAbsId() ;
696 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
697 Int_t ncells = cluster->GetNCells();
698 TString calo = "EMCAL";
699 if(cluster->IsPHOSCluster()) calo = "PHOS";
701 //Initialize some used variables
704 Int_t icol = -1, irow = -1, iRCU = -1, module=1;
705 Float_t factor = 1, frac = 0;
707 //Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
708 for(Int_t icell = 0; icell < ncells; icell++){
709 absId = index[icell];
710 frac = fraction[icell];
711 if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
712 module = GetModuleNumberCellIndexes(absId,calo,icol,irow,iRCU);
713 if(cluster->IsPHOSCluster()) factor = GetPHOSChannelRecalibrationFactor (module,icol,irow);
714 else factor = GetEMCALChannelRecalibrationFactor(module,icol,irow);
716 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(ESD) - recalibrate cell: %s, module %d, col %d, row %d, cell fraction %f,recalibration factor %f, cell energy %f\n",
717 calo.Data(),module,icol,irow,frac,factor,cells->GetCellAmplitude(absId));
719 energy += cells->GetCellAmplitude(absId)*factor*frac;
723 printf("AliCalorimeterUtils::RecalibrateClusterEnergy(ESD) - Energy before %f, after %f\n",cluster->E(),energy);
730 //________________________________________________________________
731 void AliCalorimeterUtils::SetGeometryTransformationMatrices(AliVEvent* inputEvent)
733 //Set the calorimeters transformation matrices
735 //Get the EMCAL transformation geometry matrices from ESD
736 if (!gGeoManager && fEMCALGeo) {//&& !fEMCALGeoMatrixSet) { FIXME
738 printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load EMCAL misalignment matrices. \n");
739 if(!strcmp(inputEvent->GetName(),"AliESDEvent")) {
740 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
741 if(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod)) {
742 //printf("EMCAL: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod));
743 fEMCALGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod),mod) ;
744 fEMCALGeoMatrixSet = kTRUE;//At least one, so good
746 }// loop over super modules
750 printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
752 }//EMCAL geo && no geoManager
754 //Get the PHOS transformation geometry matrices from ESD
755 if (!gGeoManager && fPHOSGeo && !fPHOSGeoMatrixSet) {
757 printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load PHOS misalignment matrices. \n");
758 if(!strcmp(inputEvent->GetName(),"AliESDEvent")) {
759 for(Int_t mod=0; mod < 5; mod++){
760 if(((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod)) {
761 //printf("PHOS: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod));
762 fPHOSGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod),mod) ;
763 fPHOSGeoMatrixSet = kTRUE; //At least one so good
765 }// loop over modules
769 printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n");
771 }//PHOS geo and geoManager was not set