AliPhysics  8417398 (8417398)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliCalorimeterUtils.cxx
Go to the documentation of this file.
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 
16 // --- ROOT system ---
17 #include <TGeoManager.h>
18 #include <TH2F.h>
19 #include <TCanvas.h>
20 #include <TStyle.h>
21 #include <TPad.h>
22 #include <TFile.h>
23 #include <TParticle.h>
24 
25 // --- ANALYSIS system ---
26 #include "AliCalorimeterUtils.h"
27 #include "AliESDEvent.h"
28 #include "AliMCEvent.h"
29 #include "AliStack.h"
30 #include "AliAODPWG4Particle.h"
31 #include "AliVCluster.h"
32 #include "AliVCaloCells.h"
33 #include "AliAODCaloCluster.h"
34 #include "AliOADBContainer.h"
35 #include "AliAnalysisManager.h"
36 #include "AliAODMCParticle.h"
37 #include "AliLog.h"
38 
39 // --- Detector ---
40 #include "AliEMCALGeometry.h"
41 #include "AliPHOSGeoUtils.h"
42 
43 #include "AliFiducialCut.h" // Needed for detector flag enum kEMCAL, kPHOS
44 
48 
49 
50 //____________________________________________
52 //____________________________________________
54 TObject(), fDebug(0),
55 fEMCALGeoName(""),
56 fPHOSGeoName (""),
57 fEMCALGeo(0x0), fPHOSGeo(0x0),
58 fEMCALGeoMatrixSet(kFALSE), fPHOSGeoMatrixSet(kFALSE),
59 fLoadEMCALMatrices(kFALSE), fLoadPHOSMatrices(kFALSE),
60 fRemoveBadChannels(kFALSE), fPHOSBadChannelMap(0x0),
61 fNCellsFromPHOSBorder(0),
62 fNMaskCellColumns(0), fMaskCellColumns(0x0),
63 fRecalibration(kFALSE), fRunDependentCorrection(kFALSE),
64 fPHOSRecalibrationFactors(), fEMCALRecoUtils(new AliEMCALRecoUtils),
65 fRecalculatePosition(kFALSE), fCorrectELinearity(kFALSE),
66 fRecalculateMatching(kFALSE),
67 fCutR(20), fCutZ(20),
68 fCutEta(20), fCutPhi(20),
69 fLocMaxCutE(0), fLocMaxCutEDiff(0),
70 fPlotCluster(0), fOADBSet(kFALSE),
71 fOADBForEMCAL(kFALSE), fOADBForPHOS(kFALSE),
72 fOADBFilePathEMCAL(""), fOADBFilePathPHOS(""),
73 fImportGeometryFromFile(0), fImportGeometryFilePath(""),
74 fNSuperModulesUsed(0), fRunNumber(0),
75 fMCECellClusFracCorrOn(0), fMCECellClusFracCorrParam()
76 {
78  for(Int_t i = 0; i < 22; i++) fEMCALMatrix[i] = 0 ;
79  for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix [i] = 0 ;
80 }
81 
82 //_________________________________________
83 // Destructor.
84 //_________________________________________
86 {
87  //if(fPHOSGeo) delete fPHOSGeo ;
88  if(fEMCALGeo) delete fEMCALGeo ;
89 
91 {
92  fPHOSBadChannelMap->Clear();
93  delete fPHOSBadChannelMap;
94  }
95 
97 {
100  }
101 
102  if(fEMCALRecoUtils) delete fEMCALRecoUtils ;
103  if(fNMaskCellColumns) delete [] fMaskCellColumns;
104 }
105 
106 //____________________________________________________
109 //____________________________________________________
110 void AliCalorimeterUtils::AccessOADB(AliVEvent* event)
111 {
112  // Set it only once
113  if(fOADBSet) return ;
114 
115  if(fRunNumber <= 0) fRunNumber = event->GetRunNumber() ; // take the run number from the event itself
116  TString pass = GetPass();
117 
118  // EMCAL
119  if(fOADBForEMCAL)
120  {
121  AliInfo(Form("Get AODB parameters from EMCAL in %s for run %d, and <%s>",fOADBFilePathEMCAL.Data(),fRunNumber,pass.Data()));
122 
123  Int_t nSM = fEMCALGeo->GetNumberOfSuperModules();
124 
125  // Bad map
127  {
128  AliOADBContainer *contBC=new AliOADBContainer("");
129  contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fOADBFilePathEMCAL.Data()),"AliEMCALBadChannels");
130 
131  TObjArray *arrayBC=(TObjArray*)contBC->GetObject(fRunNumber);
132 
133  if(arrayBC)
134  {
136  AliInfo("Remove EMCAL bad cells");
137 
138  for (Int_t i=0; i<nSM; ++i)
139  {
140  TH2I *hbm = GetEMCALChannelStatusMap(i);
141 
142  if (hbm)
143  delete hbm;
144 
145  hbm=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
146 
147  if (!hbm)
148  {
149  AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
150  continue;
151  }
152 
153  hbm->SetDirectory(0);
155 
156  } // loop
157  } else AliInfo("Do NOT remove EMCAL bad channels\n"); // run array
158 
159  delete contBC;
160  } // Remove bad
161 
162  // Energy Recalibration
163  if(fRecalibration)
164  {
165  AliOADBContainer *contRF=new AliOADBContainer("");
166 
167  contRF->InitFromFile(Form("%s/EMCALRecalib.root",fOADBFilePathEMCAL.Data()),"AliEMCALRecalib");
168 
169  TObjArray *recal=(TObjArray*)contRF->GetObject(fRunNumber);
170 
171  if(recal)
172  {
173  TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
174 
175  if(recalpass)
176  {
177  TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
178 
179  if(recalib)
180  {
181  AliInfo("Recalibrate EMCAL");
182  for (Int_t i=0; i < nSM; ++i)
183  {
185 
186  if (h)
187  delete h;
188 
189  h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
190 
191  if (!h)
192  {
193  AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
194  continue;
195  }
196 
197  h->SetDirectory(0);
198 
200  } // SM loop
201  } else AliInfo("Do NOT recalibrate EMCAL, no params object array"); // array ok
202  } else AliInfo("Do NOT recalibrate EMCAL, no params for pass"); // array pass ok
203  } else AliInfo("Do NOT recalibrate EMCAL, no params for run"); // run number array ok
204 
205  delete contRF;
206  // once set, apply run dependent corrections if requested
207  //fEMCALRecoUtils->SetRunDependentCorrections(fRunNumber);
208 
209  } // Recalibration on
210 
211  // Energy Recalibration, apply on top of previous calibration factors
213  {
214  AliOADBContainer *contRFTD=new AliOADBContainer("");
215 
216  contRFTD->InitFromFile(Form("%s/EMCALTemperatureCorrCalib.root",fOADBFilePathEMCAL.Data()),"AliEMCALRunDepTempCalibCorrections");
217 
218  TH1S *htd=(TH1S*)contRFTD->GetObject(fRunNumber);
219 
220  //If it did not exist for this run, get closes one
221  if (!htd)
222  {
223  AliWarning(Form("No TemperatureCorrCalib Objects for run: %d",fRunNumber));
224  // let's get the closest fRunNumber instead then..
225  Int_t lower = 0;
226  Int_t ic = 0;
227  Int_t maxEntry = contRFTD->GetNumberOfEntries();
228 
229  while ( (ic < maxEntry) && (contRFTD->UpperLimit(ic) < fRunNumber) )
230  {
231  lower = ic;
232  ic++;
233  }
234 
235  Int_t closest = lower;
236  if ( (ic<maxEntry) &&
237  (contRFTD->LowerLimit(ic)-fRunNumber) < (fRunNumber - contRFTD->UpperLimit(lower)) )
238  {
239  closest = ic;
240  }
241 
242  AliWarning(Form("TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRFTD->LowerLimit(closest)));
243  htd = (TH1S*) contRFTD->GetObjectByIndex(closest);
244  }
245 
246  if(htd)
247  {
248  AliInfo("Recalibrate (Temperature) EMCAL");
249 
250  for (Int_t ism=0; ism<nSM; ++ism)
251  {
252  for (Int_t icol=0; icol<48; ++icol)
253  {
254  for (Int_t irow=0; irow<24; ++irow)
255  {
256  Float_t factor = GetEMCALChannelRecalibrationFactor(ism,icol,irow);
257 
258  Int_t absID = fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol); // original calibration factor
259  factor *= htd->GetBinContent(absID) / 10000. ; // correction dependent on T
260 
261  //printf("\t ism %d, icol %d, irow %d,absID %d, corrA %2.3f, corrB %2.3f, corrAB %2.3f\n",ism, icol, irow, absID,
262  // GetEMCALChannelRecalibrationFactor(ism,icol,irow) , htd->GetBinContent(absID) / 10000., factor);
263 
264  SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
265  } // columns
266  } // rows
267  } // SM loop
268  } else AliInfo("Do NOT recalibrate EMCAL with T variations, no params TH1");
269 
270  delete contRFTD;
271  } // Run by Run T calibration
272 
273  // Time Recalibration
274  if(fEMCALRecoUtils->IsTimeRecalibrationOn())
275  {
276  AliOADBContainer *contTRF=new AliOADBContainer("");
277 
278  contTRF->InitFromFile(Form("%s/EMCALTimeCalib.root",fOADBFilePathEMCAL.Data()),"AliEMCALTimeCalib");
279 
280  TObjArray *trecal=(TObjArray*)contTRF->GetObject(fRunNumber);
281 
282  if(trecal)
283  {
284  TString passM = pass;
285  if(pass=="spc_calo") passM = "pass3";
286  TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passM);
287 
288  if(trecalpass)
289  {
290  AliInfo("Time Recalibrate EMCAL");
291  for (Int_t ibc = 0; ibc < 4; ++ibc)
292  {
294 
295  if (h)
296  delete h;
297 
298  h = (TH1F*)trecalpass->FindObject(Form("hAllTimeAvBC%d",ibc));
299 
300  if (!h)
301  {
302  AliError(Form("Could not load hAllTimeAvBC%d",ibc));
303  continue;
304  }
305 
306  h->SetDirectory(0);
307 
309  } // bunch crossing loop
310  } else AliInfo("Do NOT recalibrate time EMCAL, no params for pass"); // array pass ok
311  } else AliInfo("Do NOT recalibrate time EMCAL, no params for run"); // run number array ok
312 
313  delete contTRF;
314  } // Time Recalibration on
315 
316  // Time L1 phase racalibration
317  if(fEMCALRecoUtils->IsL1PhaseInTimeRecalibrationOn()) {
318  Bool_t useDefault=kFALSE;
319  AliOADBContainer *contTRF=new AliOADBContainer("");
320  contTRF->InitFromFile(Form("%s/EMCALTimeL1PhaseCalib.root",fOADBFilePathEMCAL.Data()),"AliEMCALTimeL1PhaseCalib");
321  TObjArray *trecal=(TObjArray*)contTRF->GetObject(fRunNumber);
322  if(!trecal) {
323  AliError(Form("Do NOT recalibrate time EMCAL. No params for run %d. Default used.",fRunNumber)); // run number array ok
324  trecal=(TObjArray*)contTRF->GetObject(0);
325  if(!trecal) {
326  AliFatal(Form("No params for run %d. No default params.",fRunNumber));
327  return;
328  }
329  useDefault=kTRUE;
330  }
331 
332  TString passM = pass;
333  if(useDefault) passM = "pass1";
334  else if(pass=="muon_calo_pass1") passM = "muon_calo_pass1";
335  else if(pass=="muon_calo_pass2") passM = "muon_calo_pass2";
336 
337  TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passM);
338  if(!trecalpass) {
339  if(useDefault){
340  AliFatal("No defaults params pass1.");
341  return;
342  }
343  AliInfo("Do NOT recalibrate time EMCAL, no params for pass"); // array pass ok
344  //use default
345  trecal->Delete();
346  trecal=(TObjArray*)contTRF->GetObject(0);
347  if(!trecal) {
348  AliFatal(Form("No params for run %d. No default params.",fRunNumber));
349  return;
350  }
351  useDefault=kTRUE;
352  trecalpass=(TObjArray*)trecal->FindObject("pass1");
353  if(!trecalpass) {
354  AliFatal("No defaults params pass1.");
355  return;
356  }
357  //end use default
358  }
359  AliInfo("Time L1 phase Recalibrate EMCAL");
361  if (h) delete h;
362  h = (TH1C*)trecalpass->FindObject(Form("h%d",fRunNumber));
363  if (!h) AliError(Form("Could not load h%d",fRunNumber));
364  h->SetDirectory(0);
366 
367  delete contTRF;
368  }//End of Time L1 phase racalibration
369 
370  }// EMCAL
371 
372  // PHOS
373  if(fOADBForPHOS)
374  {
375  AliInfo(Form("Get AODB parameters from PHOS in %s for run %d, and <%s>",fOADBFilePathPHOS.Data(),fRunNumber,pass.Data()));
376 
377  // Bad map
379  {
380  AliOADBContainer badmapContainer(Form("phosBadMap"));
381  TString fileName="$ALICE_PHYSICS/OADB/PHOS/PHOSBadMaps.root";
382  badmapContainer.InitFromFile(Form("%s/PHOSBadMaps.root",fOADBFilePathPHOS.Data()),"phosBadMap");
383 
384  //Use a fixed run number from year 2010, this year not available yet.
385  TObjArray *maps = (TObjArray*)badmapContainer.GetObject(139000,"phosBadMap");
386  if(!maps)
387  {
388  AliInfo(Form("Can not read PHOS bad map for run %d",fRunNumber)) ;
389  }
390  else
391  {
392  AliInfo(Form("Setting PHOS bad map with name %s",maps->GetName())) ;
393 
394  for(Int_t mod = 1; mod < 5; mod++)
395  {
396  TH2I *hbmPH = GetPHOSChannelStatusMap(mod);
397 
398  if(hbmPH)
399  delete hbmPH ;
400 
401  hbmPH = (TH2I*)maps->At(mod);
402 
403  if(hbmPH) hbmPH->SetDirectory(0);
404 
405  SetPHOSChannelStatusMap(mod-1,hbmPH);
406 
407  } // modules loop
408  } // maps exist
409  } // Remove bad channels
410  } // PHOS
411 
412  // Parameters already set once, so do not it again
413  fOADBSet = kTRUE;
414 }
415 
416 //_____________________________________________________________
419 //_____________________________________________________________
420 void AliCalorimeterUtils::AccessGeometry(AliVEvent* inputEvent)
421 {
422  // First init the geometry, a priory not done before
423  if(fRunNumber <=0 ) fRunNumber = inputEvent->GetRunNumber() ;
424 
425  InitPHOSGeometry ();
427 
428  //Get the EMCAL transformation geometry matrices from ESD
430  {
432  {
433  AliInfo("Load user defined EMCAL geometry matrices");
434 
435  // OADB if available
436  AliOADBContainer emcGeoMat("AliEMCALgeo");
437  emcGeoMat.InitFromFile(Form("%s/EMCALlocal2master.root",fOADBFilePathEMCAL.Data()),"AliEMCALgeo");
438  TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(fRunNumber,"EmcalMatrices");
439 
440  for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
441  {
442  if (!fEMCALMatrix[mod]) // Get it from OADB
443  {
444  AliDebug(1,Form("EMCAL matrices SM %d, %p", mod,((TGeoHMatrix*) matEMCAL->At(mod))));
445  //((TGeoHMatrix*) matEMCAL->At(mod))->Print();
446 
447  fEMCALMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ;
448  }
449 
450  if(fEMCALMatrix[mod])
451  {
452  if(fDebug > 1)
453  fEMCALMatrix[mod]->Print();
454 
455  fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ;
456  }
457  else if(gGeoManager)
458  {
459  AliWarning(Form("Set matrix for SM %d from gGeoManager",mod));
460  fEMCALGeo->SetMisalMatrix(fEMCALGeo->GetMatrixForSuperModuleFromGeoManager(mod),mod) ;
461  }
462  else
463  {
464  AliError(Form("Alignment atrix for SM %d is not available",mod));
465  }
466  } // SM loop
467 
468  fEMCALGeoMatrixSet = kTRUE;//At least one, so good
469 
470  } // Load matrices
471  else if (!gGeoManager)
472  {
473  AliDebug(1,"Load EMCAL misalignment matrices");
474  if(!strcmp(inputEvent->GetName(),"AliESDEvent"))
475  {
476  for(Int_t mod = 0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
477  {
478  //printf("Load ESD matrix %d, %p\n",mod,((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod));
479  if(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod))
480  {
481  fEMCALGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod),mod) ;
482  }
483  }// loop over super modules
484 
485  fEMCALGeoMatrixSet = kTRUE;//At least one, so good
486 
487  }//ESD as input
488  else
489  {
490  AliDebug(1,"Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file");
491  }//AOD as input
492  }//Get matrix from data
493  else if(gGeoManager)
494  {
495  fEMCALGeoMatrixSet = kTRUE;
496  }
497  }//EMCAL geo && no geoManager
498 
499  //Get the PHOS transformation geometry matrices from ESD
501  {
503  {
504  AliInfo("Load user defined PHOS geometry matrices");
505 
506  // OADB if available
507  AliOADBContainer geomContainer("phosGeo");
508  geomContainer.InitFromFile(Form("%s/PHOSGeometry.root",fOADBFilePathPHOS.Data()),"PHOSRotationMatrixes");
509  TObjArray *matPHOS = (TObjArray*)geomContainer.GetObject(139000,"PHOSRotationMatrixes");
510 
511  for(Int_t mod = 0 ; mod < 5 ; mod++)
512  {
513  if (!fPHOSMatrix[mod]) // Get it from OADB
514  {
515  AliDebug(1,Form("PHOS matrices module %d, %p",mod,((TGeoHMatrix*) matPHOS->At(mod))));
516  //((TGeoHMatrix*) matPHOS->At(mod))->Print();
517 
518  fPHOSMatrix[mod] = (TGeoHMatrix*) matPHOS->At(mod) ;
519  }
520 
521  // Set it, if it exists
522  if(fPHOSMatrix[mod])
523  {
524  if(fDebug > 1 )
525  fPHOSMatrix[mod]->Print();
526 
527  fPHOSGeo->SetMisalMatrix(fPHOSMatrix[mod],mod) ;
528  }
529  }// SM loop
530 
531  fPHOSGeoMatrixSet = kTRUE;//At least one, so good
532 
533  }//Load matrices
534  else if (!gGeoManager)
535  {
536  AliDebug(1,"Load PHOS misalignment matrices.");
537  if(!strcmp(inputEvent->GetName(),"AliESDEvent"))
538  {
539  for(Int_t mod = 0; mod < 5; mod++)
540  {
541  if( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod))
542  {
543  //printf("PHOS: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod));
544  fPHOSGeo->SetMisalMatrix( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod),mod) ;
545  }
546  } // loop over modules
547 
548  fPHOSGeoMatrixSet = kTRUE; //At least one so good
549  } // ESD as input
550  else
551  {
552  AliDebug(1,"Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file");
553  } // AOD as input
554  } // get matrix from data
555  else if(gGeoManager)
556  {
557  fPHOSGeoMatrixSet = kTRUE;
558  }
559  }//PHOS geo and geoManager was not set
560 }
561 
562 //______________________________________________________________________________________
565 //______________________________________________________________________________________
566 Bool_t AliCalorimeterUtils::AreNeighbours(Int_t calo, Int_t absId1, Int_t absId2 ) const
567 {
568  Bool_t areNeighbours = kFALSE ;
569 
570  Int_t iRCU1 = -1, irow1 = -1, icol1 = -1;
571  Int_t iRCU2 = -1, irow2 = -1, icol2 = -1;
572 
573  Int_t rowdiff = 0, coldiff = 0;
574 
575  Int_t nSupMod1 = GetModuleNumberCellIndexes(absId1, calo, icol1, irow1, iRCU1);
576  Int_t nSupMod2 = GetModuleNumberCellIndexes(absId2, calo, icol2, irow2, iRCU2);
577 
578  if(calo==AliFiducialCut::kEMCAL && nSupMod1!=nSupMod2)
579  {
580  // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2-1
581  // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0
582  if(nSupMod1%2) icol1+=AliEMCALGeoParams::fgkEMCALCols;
583  else icol2+=AliEMCALGeoParams::fgkEMCALCols;
584  }
585 
586  rowdiff = TMath::Abs( irow1 - irow2 ) ;
587  coldiff = TMath::Abs( icol1 - icol2 ) ;
588 
589  //if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
590  if ((coldiff + rowdiff == 1 ))
591  areNeighbours = kTRUE ;
592 
593  return areNeighbours;
594 }
595 
596 //_________________________________________________________________________________________
599 //_________________________________________________________________________________________
600 Bool_t AliCalorimeterUtils::IsClusterSharedByTwoSuperModules(const AliEMCALGeometry * geom,
601  AliVCluster* cluster)
602 {
603  Int_t iSupMod = -1;
604  Int_t iSM0 = -1;
605  Int_t iTower = -1;
606  Int_t iIphi = -1;
607  Int_t iIeta = -1;
608  Int_t iphi = -1;
609  Int_t ieta = -1;
610 
611  for(Int_t iDigit = 0; iDigit < cluster->GetNCells(); iDigit++)
612  {
613  // Get from the absid the supermodule, tower and eta/phi numbers
614  geom->GetCellIndex(cluster->GetCellAbsId(iDigit),iSupMod,iTower,iIphi,iIeta);
615  geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
616 
617  // Check if there are cells of different SM
618  if (iDigit == 0 ) iSM0 = iSupMod;
619  else if(iSupMod != iSM0)
620  {
621  if(iSupMod > 11 && iSupMod < 18)
622  AliWarning(Form("Cluster shared in 2 DCal: SM%d, SM%d??",iSupMod,iSM0));
623 
624  return kTRUE;
625  }
626  }
627 
628  return kFALSE;
629 }
630 
631 //______________________________________________________________________________
634 //______________________________________________________________________________
635 Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliVCluster* cluster,
636  AliVCaloCells* cells) const
637 {
638  //If the distance to the border is 0 or negative just exit accept all clusters
639 
640  if ( cells->GetType()==AliVCaloCells::kEMCALCell && fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder() <= 0 ) return kTRUE;
641 
642  if ( cells->GetType()==AliVCaloCells::kPHOSCell && fNCellsFromPHOSBorder <= 0 ) return kTRUE;
643 
644  Int_t absIdMax = -1;
645  Float_t ampMax = -1;
646 
647  for(Int_t i = 0; i < cluster->GetNCells() ; i++)
648  {
649  Int_t absId = cluster->GetCellAbsId(i) ;
650  Float_t amp = cells->GetCellAmplitude(absId);
651 
652  if(amp > ampMax)
653  {
654  ampMax = amp;
655  absIdMax = absId;
656  }
657  }
658 
659  AliDebug(1,Form("Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f",
660  absIdMax, ampMax, cluster->E()));
661 
662  if ( absIdMax == -1 ) return kFALSE;
663 
664  // Check if the cell is close to the borders:
665  Bool_t okrow = kFALSE;
666  Bool_t okcol = kFALSE;
667 
668  if ( cells->GetType() == AliVCaloCells::kEMCALCell )
669  {
670  // It should be the same as AliEMCALRecoUtils::CheckCellFiducialRegion()
671  // Why not calling it?
672 
673  Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
674 
675  fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
676 
677  fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
678 
679  if(iSM < 0 || iphi < 0 || ieta < 0 )
680  {
681  AliFatal(Form("Negative value for super module: %d, or cell ieta: %d, or cell iphi: %d, check EMCAL geometry name",iSM,ieta,iphi));
682  }
683 
684  // Check rows/phi
685  Int_t nborder = fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder();
686 
687  if ( iSM < 10 || (iSM > 11 && iSM < 18) ) // Full EMCal (SM0-9) and DCal 2/3 (SM12-17)
688  {
689  if(iphi >= nborder && iphi < 24-nborder) okrow = kTRUE;
690  }
691  else // 1/3 SMs (SM10-11, SM18-19)
692  {
693  if(iphi >= nborder && iphi < 8-nborder) okrow = kTRUE;
694  }
695 
696  // Check columns/eta
697 
698  // Remove all borders if IsEMCALNoBorderAtEta0 or DCal SMs(12-17)
699  if(!fEMCALRecoUtils->IsEMCALNoBorderAtEta0() || (iSM > 11 && iSM < 18))
700  {
701  if(ieta > nborder && ieta < 48-nborder) okcol =kTRUE;
702  }
703  else // Do not remove borders close at eta = 0 for Full EMCal SMs and 1/3 EMCal
704  {
705  if ( iSM%2 == 0 )
706  {
707  if(ieta >= nborder) okcol = kTRUE;
708  }
709  else
710  {
711  if(ieta < 48-nborder) okcol = kTRUE;
712  }
713  } // eta 0 not checked
714 
715  AliDebug(1,Form("EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ? ok row %d, ok column %d",
716  nborder, ieta, iphi, iSM,okrow,okcol));
717 
718  }//EMCAL
719  else if ( cells->GetType() == AliVCaloCells::kPHOSCell )
720  {
721  Int_t relId[4];
722  Int_t irow = -1, icol = -1;
723  fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
724 
725  if (relId[1] != 0 ) return kFALSE; // skip CPV only PHOS
726 
727  irow = relId[2];
728  icol = relId[3];
729  //imod = relId[0]-1;
730 
731  if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
732  if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
733 
734  AliDebug(1,Form("PHOS Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ? ok row %d, ok column %d",
735  fNCellsFromPHOSBorder, icol, irow, relId[0]-1,okrow,okcol));
736  }//PHOS
737 
738  if (okcol && okrow) return kTRUE;
739  else return kFALSE;
740 }
741 
742 //________________________________________________________________________________________________________
745 //________________________________________________________________________________________________________
746 Bool_t AliCalorimeterUtils::ClusterContainsBadChannel(Int_t calorimeter, UShort_t* cellList, Int_t nCells)
747 {
748  if (!fRemoveBadChannels) return kFALSE;
749 
750  //printf("fEMCALBadChannelMap %p, fPHOSBadChannelMap %p \n",fEMCALBadChannelMap,fPHOSBadChannelMap);
751  if(calorimeter == AliFiducialCut::kEMCAL && !fEMCALRecoUtils->GetEMCALChannelStatusMap(0)) return kFALSE;
752  if(calorimeter == AliFiducialCut::kPHOS && !fPHOSBadChannelMap) return kFALSE;
753 
754  Int_t icol = -1;
755  Int_t irow = -1;
756  Int_t imod = -1;
757  for(Int_t iCell = 0; iCell<nCells; iCell++)
758  {
759  // Get the column and row
760  if ( calorimeter == AliFiducialCut::kEMCAL )
761  {
762  return fEMCALRecoUtils->ClusterContainsBadChannel((AliEMCALGeometry*)fEMCALGeo,cellList,nCells);
763  }
764  else if ( calorimeter == AliFiducialCut::kPHOS )
765  {
766  Int_t relId[4];
767  fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId);
768 
769  if (relId[1] != 0 ) return kTRUE; // skip CPV only PHOS
770 
771  irow = relId[2];
772  icol = relId[3];
773  imod = relId[0]-1;
774 
775  if ( fPHOSBadChannelMap->GetEntries() <= imod ) continue;
776 
777  //printf("PHOS bad channels imod %d, icol %d, irow %d\n",imod, irow, icol);
778  if ( GetPHOSChannelStatus(imod, irow, icol) ) return kTRUE;
779  }
780  else return kFALSE;
781  } // cell cluster loop
782 
783  return kFALSE;
784 }
785 
786 //_______________________________________________________________
788 //_______________________________________________________________
790 {
791  clus->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(clus));
792 }
793 
794 //_______________________________________________________________
802 //______________________________________________________________________________
803 void AliCalorimeterUtils::GetEMCALSubregion(AliVCluster * clus, AliVCaloCells * cells,
804  Int_t & regEta, Int_t & regPhi) const
805 {
806  regEta = regPhi = -1 ;
807 
808  if(!clus->IsEMCAL()) return ;
809 
810  Int_t icol = -1, irow = -1, iRCU = -1;
811  Float_t clusterFraction = 0;
812 
813  Int_t absId = GetMaxEnergyCell(cells,clus,clusterFraction);
814 
815  Int_t sm = GetModuleNumberCellIndexes(absId,AliFiducialCut::kEMCAL,icol,irow,iRCU);
816 
817  // Shift by 48 to for impair SM
818  if( sm%2 == 1) icol+=AliEMCALGeoParams::fgkEMCALCols;
819 
820  // Avoid borders
821  if(icol < 2 || icol > 93 || irow < 2 || irow > 21) return;
822 
823  //
824  // Eta regions
825  //
826 
827  // Region 0: center of SM ~0.18<|eta|<0.55
828  if ( icol > 9 && icol < 34 ) regEta = 0;
829  else if ( icol > 62 && icol < 87 ) regEta = 0;
830 
831  // Region 3: frames ~0.1<|eta|<~0.22 ~0.51<|eta|<0.62
832 
833  else if ( icol <= 9 && icol >= 5 ) regEta = 3;
834  else if ( icol <= 38 && icol >= 34 ) regEta = 3;
835  else if ( icol <= 62 && icol >= 58 ) regEta = 3;
836  else if ( icol <= 91 && icol >= 87 ) regEta = 3;
837 
838  // Region 1: |eta| < ~0.15
839 
840  else if ( icol < 58 && icol > 38 ) regEta = 1 ;
841 
842  // Region 2: |eta| > ~0.6
843 
844  else regEta = 2 ;
845 
846  //
847  // Phi regions
848  //
849 
850  if ( irow >= 2 && irow <= 5 ) regPhi = 0; // External
851  else if ( irow >= 18 && irow <= 21 ) regPhi = 0; // External
852  else if ( irow >= 6 && irow <= 9 ) regPhi = 1; // Mid
853  else if ( irow >= 14 && irow <= 17 ) regPhi = 1; // Mid
854  else regPhi = 2; //10-13 Central
855 
856 }
857 
858 //________________________________________________________________________________________
860 //________________________________________________________________________________________
861 Int_t AliCalorimeterUtils::GetMaxEnergyCell(AliVCaloCells * cells,
862  AliVCluster * clu,
863  Float_t & clusterFraction) const
864 {
865  if( !clu || !cells )
866  {
867  AliInfo("Cluster or cells pointer is null!");
868  return -1;
869  }
870 
871  Double_t eMax =-1.;
872  Double_t eTot = 0.;
873  Double_t eCell =-1.;
874  Float_t fraction = 1.;
875  Float_t recalFactor = 1.;
876  Int_t cellAbsId =-1 , absId =-1 ;
877  Int_t iSupMod =-1 , ieta =-1 , iphi = -1, iRCU = -1;
878 
879  Int_t calo = AliFiducialCut::kEMCAL;
880  if(clu->IsPHOS()) calo = AliFiducialCut::kPHOS ;
881 
882  for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++)
883  {
884  cellAbsId = clu->GetCellAbsId(iDig);
885 
886  fraction = clu->GetCellAmplitudeFraction(iDig);
887  if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
888 
889  iSupMod = GetModuleNumberCellIndexes(cellAbsId, calo, ieta, iphi, iRCU);
890 
891  if(IsRecalibrationOn())
892  {
893  if(calo == AliFiducialCut::kEMCAL)
894  recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi);
895  else
896  recalFactor = GetPHOSChannelRecalibrationFactor (iSupMod,iphi,ieta);
897  }
898 
899  eCell = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor;
900 
901  if(eCell > eMax)
902  {
903  eMax = eCell;
904  absId = cellAbsId;
905  }
906 
907  eTot+=eCell;
908 
909  }// cell loop
910 
911  if(eTot > 0.1)
912  clusterFraction = (eTot-eMax)/eTot; //Do not use cluster energy in case it was corrected for non linearity.
913  else
914  clusterFraction =1.;
915 
916  return absId;
917 }
918 
919 //___________________________________________________________________________________
923 //___________________________________________________________________________________
924 AliVTrack * AliCalorimeterUtils::GetMatchedTrack(AliVCluster* cluster,
925  AliVEvent* event, Int_t index) const
926 {
927  AliVTrack *track = 0x0;
928 
929  //
930  // EMCAL case only when matching is recalculated
931  //
932  if(cluster->IsEMCAL() && IsRecalculationOfClusterTrackMatchingOn())
933  {
934  Int_t trackIndex = fEMCALRecoUtils->GetMatchedTrackIndex(cluster->GetID());
935  //printf("track index %d, cluster ID %d \n ",trackIndex,cluster->GetID());
936 
937  if(trackIndex < 0 )
938  AliInfo(Form("Wrong track index %d, from recalculation", trackIndex));
939  else
940  track = dynamic_cast<AliVTrack*> (event->GetTrack(trackIndex));
941 
942  return track ;
943  }
944 
945  //
946  // Normal case, get info from ESD or AOD
947  //
948 
949  // No tracks matched
950  if( cluster->GetNTracksMatched() < 1 ) return 0x0;
951 
952  // At least one match
953  Int_t iTrack = 0; // only one match for AODs with index 0.
954 
955  // ESDs
956  if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName())))
957  {
958  if( index >= 0 ) iTrack = index;
959  else iTrack = ((AliESDCaloCluster*)cluster)->GetTracksMatched()->At(0); //cluster->GetTrackMatchedIndex();
960 
961  track = dynamic_cast<AliVTrack*> ( event->GetTrack(iTrack) );
962  }
963  else // AODs
964  {
965  if( index > 0 ) iTrack = index;
966 
967  track = dynamic_cast<AliVTrack*>( cluster->GetTrackMatched(iTrack) );
968  }
969 
970  return track ;
971 }
972 
977 Float_t AliCalorimeterUtils::GetMCECellClusFracCorrection(Float_t eCell, Float_t eCluster) const
978 {
979  if( eCluster <= 0 || eCluster < eCell )
980  {
981  AliWarning(Form("Bad values eCell=%f, eCluster %f",eCell,eCluster));
982  return 1;
983  }
984 
985  Float_t frac = eCell / eCluster;
986 
987  Float_t correction = fMCECellClusFracCorrParam[0] +
988  TMath::Exp( frac*fMCECellClusFracCorrParam[2]+fMCECellClusFracCorrParam[1] ) +
989  fMCECellClusFracCorrParam[3]/TMath::Sqrt(frac);
990 
991 // printf("AliCalorimeterUtils::GetMCECellClusFracCorrection(eCell=%f, eCluster %f, frac %f) = %f\n",eCell, eCluster, frac, correction);
992 // printf("\t %2.2f + TMath::Exp( %2.3f*%2.2f + %2.2f ) + %2.2f/TMath::Sqrt(%2.3f)) = %f\n",
993 // fMCECellClusFracCorrParam[0],frac,fMCECellClusFracCorrParam[2],fMCECellClusFracCorrParam[1],fMCECellClusFracCorrParam[3], frac, correction);
994 
995  return correction;
996 }
997 
998 //_____________________________________________________________________________________________________
1000 //_____________________________________________________________________________________________________
1001 Int_t AliCalorimeterUtils::GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent * inputEvent) const
1002 {
1003  Int_t absId = -1;
1004 
1005  if(particle->GetDetectorTag()==AliFiducialCut::kEMCAL)
1006  {
1007  fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
1008 
1009  AliDebug(2,Form("EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d",
1010  particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId)));
1011 
1012  return fEMCALGeo->GetSuperModuleNumber(absId) ;
1013  } // EMCAL
1014  else if ( particle->GetDetectorTag() == AliFiducialCut::kPHOS )
1015  {
1016  // In case we use the MC reader, the input are TParticles,
1017  // in this case use the corresponing method in PHOS Geometry to get the particle.
1018  if(strcmp(inputEvent->ClassName(), "AliMCEvent") == 0 )
1019  {
1020  Int_t mod =-1;
1021  Double_t z = 0., x=0.;
1022  TParticle* primary = 0x0;
1023  AliStack * stack = ((AliMCEvent*)inputEvent)->Stack();
1024 
1025  if(stack)
1026  {
1027  primary = stack->Particle(particle->GetCaloLabel(0));
1028  }
1029  else
1030  {
1031  AliFatal("Stack not available, stop!");
1032  }
1033 
1034  if(primary)
1035  {
1036  fPHOSGeo->ImpactOnEmc(primary,mod,z,x) ;
1037  }
1038  else
1039  {
1040  AliFatal("Primary not available, stop!");
1041  }
1042  return mod;
1043  }
1044  // Input are ESDs or AODs, get the PHOS module number like this.
1045  else
1046  {
1047  //FIXME
1048  //AliVCluster *cluster = inputEvent->GetCaloCluster(particle->GetCaloLabel(0));
1049  //return GetModuleNumber(cluster);
1050  //MEFIX
1051  return -1;
1052  }
1053  } // PHOS
1054 
1055  return -1;
1056 }
1057 
1058 //_____________________________________________________________________
1060 //_____________________________________________________________________
1061 Int_t AliCalorimeterUtils::GetModuleNumber(AliVCluster * cluster) const
1062 {
1063  if(!cluster)
1064  {
1065  AliDebug(1,"AliCalorimeterUtils::GetModuleNumber() - NUL Cluster, please check!!!");
1066 
1067  return -1;
1068  }
1069 
1070  if ( cluster->GetNCells() <= 0 ) return -1;
1071 
1072  Int_t absId = cluster->GetCellAbsId(0);
1073 
1074  if ( absId < 0 ) return -1;
1075 
1076  if( cluster->IsEMCAL() )
1077  {
1078  AliDebug(2,Form("EMCAL absid %d, SuperModule %d",absId, fEMCALGeo->GetSuperModuleNumber(absId)));
1079 
1080  return fEMCALGeo->GetSuperModuleNumber(absId) ;
1081  } // EMCAL
1082  else if ( cluster->IsPHOS() )
1083  {
1084  Int_t relId[4];
1085  fPHOSGeo->AbsToRelNumbering(absId,relId);
1086 
1087  if (relId[1] != 0 ) return -1; // skip CPV only PHOS
1088 
1089  AliDebug(2,Form("PHOS absid %d Module %d",absId, relId[0]-1));
1090 
1091  return relId[0]-1;
1092  } // PHOS
1093 
1094  return -1;
1095 }
1096 
1097 //___________________________________________________________________________________________________
1099 //___________________________________________________________________________________________________
1101  Int_t & icol, Int_t & irow, Int_t & iRCU) const
1102 {
1103  Int_t imod = -1;
1104 
1105  if ( absId < 0 ) return -1 ;
1106 
1107  if ( calo == AliFiducialCut::kEMCAL )
1108  {
1109  Int_t iTower = -1, iIphi = -1, iIeta = -1;
1110  fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
1111  fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
1112 
1113  if(imod < 0 || irow < 0 || icol < 0 )
1114  {
1115  AliFatal(Form("Negative value for super module: %d, or cell icol: %d, or cell irow: %d, check EMCAL geometry name",imod,icol,irow));
1116  }
1117 
1118  // In case of DCal C side, shift columns to match offline/online numbering
1119  // when calculating the DDL for Run2
1120  // See AliEMCALRawUtils::Digits2Raw and Raw2Digits.
1121  Int_t ico2 = icol ;
1122  if ( imod == 13 || imod == 15 || imod == 17 ) ico2 += 16;
1123 
1124  // RCU / DDL
1125  if(imod < 10 || (imod > 11 && imod < 18)) // (EMCAL Full || DCAL 2/3)
1126  {
1127  // RCU0 / DDL0
1128  if ( 0 <= irow && irow < 8 ) iRCU = 0; // first cable row
1129  else if ( 8 <= irow && irow < 16 &&
1130  0 <= ico2 && ico2 < 24 ) iRCU = 0; // first half;
1131  //second cable row
1132 
1133  // RCU1 / DDL1
1134  else if ( 8 <= irow && irow < 16 &&
1135  24 <= ico2 && ico2 < 48 ) iRCU = 1; // second half;
1136  //second cable row
1137  else if ( 16 <= irow && irow < 24 ) iRCU = 1; // third cable row
1138 
1139  if ( imod%2 == 1 ) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
1140  }
1141  else
1142  {
1143  // 1/3 SM have one single SRU, just assign RCU/DDL 0
1144  iRCU = 0 ;
1145  }
1146 
1147  if ( iRCU < 0 )
1148  AliFatal(Form("Wrong EMCAL RCU number = %d", iRCU));
1149 
1150  return imod ;
1151  } // EMCAL
1152  else // PHOS
1153  {
1154  Int_t relId[4];
1155  fPHOSGeo->AbsToRelNumbering(absId,relId);
1156 
1157  if (relId[1] != 0 ) return -1; // skip CPV only PHOS
1158 
1159  irow = relId[2];
1160  icol = relId[3];
1161  imod = relId[0]-1;
1162  iRCU= (Int_t)(relId[2]-1)/16 ;
1163 
1164  //Int_t iBranch= (Int_t)(relid[3]-1)/28 ; //0 to 1
1165 
1166  if ( iRCU >= 4 )
1167  AliFatal(Form("Wrong PHOS RCU number = %d", iRCU));
1168 
1169  return imod;
1170  } // PHOS
1171 
1172  return -1;
1173 }
1174 
1175 //___________________________________________________________________________________________________
1178 //___________________________________________________________________________________________________
1180  Int_t & icol , Int_t & irow , Int_t & iRCU,
1181  Int_t & icolAbs, Int_t & irowAbs) const
1182 {
1183  Int_t imod = GetModuleNumberCellIndexes(absId, calo, icol, irow,iRCU);
1184 
1185  icolAbs = icol;
1186  irowAbs = irow;
1187 
1188  //
1189  // PHOS
1190  //
1191  if(calo == AliFiducialCut::kPHOS)
1192  {
1193  irowAbs = irow + 64 * imod;
1194 
1195  return imod;
1196  }
1197  //
1198  // EMCal/DCal
1199  //
1200  else
1201  {
1202  //
1203  // Shift collumns in even SM
1204  Int_t shiftEta = 48;
1205 
1206  // Shift collumn even more due to smaller acceptance of DCal collumns
1207  if ( imod > 11 && imod < 18) shiftEta+=48/3;
1208 
1209  icolAbs = (imod % 2) ? icol + shiftEta : icol;
1210 
1211  //
1212  // Shift rows per sector
1213  irowAbs = irow + 24 * Int_t(imod / 2);
1214 
1215  // Shift row less due to smaller acceptance of SM 10 and 11 to count DCal rows
1216  if ( imod > 11 && imod < 20) irowAbs -= (2*24 / 3);
1217 
1218  return imod ;
1219  }
1220 }
1221 
1222 
1223 //___________________________________________________________________________________________
1225 //___________________________________________________________________________________________
1226 Int_t AliCalorimeterUtils::GetNumberOfLocalMaxima(AliVCluster* cluster, AliVCaloCells* cells)
1227 {
1228  const Int_t nc = cluster->GetNCells();
1229 
1230  Int_t absIdList[nc];
1231  Float_t maxEList[nc];
1232 
1233  Int_t nMax = GetNumberOfLocalMaxima(cluster, cells, absIdList, maxEList);
1234 
1235  return nMax;
1236 }
1237 
1238 //___________________________________________________________________________________________
1240 //___________________________________________________________________________________________
1241 Int_t AliCalorimeterUtils::GetNumberOfLocalMaxima(AliVCluster* cluster, AliVCaloCells* cells,
1242  Int_t *absIdList, Float_t *maxEList)
1243 {
1244  Int_t iDigitN = 0 ;
1245  Int_t iDigit = 0 ;
1246  Int_t absId1 = -1 ;
1247  Int_t absId2 = -1 ;
1248  const Int_t nCells = cluster->GetNCells();
1249 
1250  Float_t eCluster = RecalibrateClusterEnergy(cluster, cells);// recalculate cluster energy, avoid non lin correction.
1251 
1252  Float_t simuTotWeight = 0;
1254  {
1255  simuTotWeight = RecalibrateClusterEnergyWeightCell(cluster, cells,eCluster);// same but apply a weight
1256  simuTotWeight/= eCluster;
1257  }
1258 
1260  if(!cluster->IsEMCAL()) calorimeter = AliFiducialCut::kPHOS;
1261 
1262  //printf("cluster : ncells %d \n",nCells);
1263 
1264  Float_t emax = 0;
1265  Int_t idmax =-1;
1266  for(iDigit = 0; iDigit < nCells ; iDigit++)
1267  {
1268  absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit] ;
1269  Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1270  RecalibrateCellAmplitude(en,calorimeter,absIdList[iDigit]);
1271 
1273  en*=GetMCECellClusFracCorrection(en,eCluster)/simuTotWeight;
1274 
1275  if( en > emax )
1276  {
1277  emax = en ;
1278  idmax = absIdList[iDigit] ;
1279  }
1280  //Int_t icol = -1, irow = -1, iRCU = -1;
1281  //Int_t sm = GetModuleNumberCellIndexes(absIdList[iDigit], calorimeter, icol, irow, iRCU) ;
1282  //printf("\t cell %d, id %d, sm %d, col %d, row %d, e %f\n", iDigit, absIdList[iDigit], sm, icol, irow, en );
1283  }
1284 
1285  for(iDigit = 0 ; iDigit < nCells; iDigit++)
1286  {
1287  if( absIdList[iDigit] >= 0 )
1288  {
1289  absId1 = cluster->GetCellsAbsId()[iDigit];
1290 
1291  Float_t en1 = cells->GetCellAmplitude(absId1);
1292  RecalibrateCellAmplitude(en1,calorimeter,absId1);
1293 
1295  en1*=GetMCECellClusFracCorrection(en1,eCluster)/simuTotWeight;
1296 
1297  //printf("%d : absIDi %d, E %f\n",iDigit, absId1,en1);
1298 
1299  for(iDigitN = 0; iDigitN < nCells; iDigitN++)
1300  {
1301  absId2 = cluster->GetCellsAbsId()[iDigitN] ;
1302 
1303  if(absId2==-1 || absId2==absId1) continue;
1304 
1305  //printf("\t %d : absIDj %d\n",iDigitN, absId2);
1306 
1307  Float_t en2 = cells->GetCellAmplitude(absId2);
1308  RecalibrateCellAmplitude(en2,calorimeter,absId2);
1309 
1311  en2*=GetMCECellClusFracCorrection(en2,eCluster)/simuTotWeight;
1312 
1313  //printf("\t %d : absIDj %d, E %f\n",iDigitN, absId2,en2);
1314 
1315  if ( AreNeighbours(calorimeter, absId1, absId2) )
1316  {
1317  // printf("\t \t Neighbours \n");
1318  if ( en1 > en2 )
1319  {
1320  absIdList[iDigitN] = -1 ;
1321  //printf("\t \t indexN %d not local max\n",iDigitN);
1322  // but may be digit too is not local max ?
1323  if(en1 < en2 + fLocMaxCutEDiff) {
1324  //printf("\t \t index %d not local max cause locMaxCutEDiff\n",iDigit);
1325  absIdList[iDigit] = -1 ;
1326  }
1327  }
1328  else
1329  {
1330  absIdList[iDigit] = -1 ;
1331  //printf("\t \t index %d not local max\n",iDigitN);
1332  // but may be digitN too is not local max ?
1333  if(en1 > en2 - fLocMaxCutEDiff)
1334  {
1335  absIdList[iDigitN] = -1 ;
1336  //printf("\t \t indexN %d not local max cause locMaxCutEDiff\n",iDigit);
1337  }
1338  }
1339  } // if Are neighbours
1340  //else printf("\t \t NOT Neighbours \n");
1341  } // while digitN
1342  } // slot not empty
1343  } // while digit
1344 
1345  iDigitN = 0 ;
1346  for(iDigit = 0; iDigit < nCells; iDigit++)
1347  {
1348  if( absIdList[iDigit] >= 0 )
1349  {
1350  absIdList[iDigitN] = absIdList[iDigit] ;
1351 
1352  Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1353  RecalibrateCellAmplitude(en,calorimeter,absIdList[iDigit]);
1354 
1356  en*=GetMCECellClusFracCorrection(en,eCluster)/simuTotWeight;
1357 
1358  if(en < fLocMaxCutE) continue; // Maxima only with seed energy at least
1359 
1360  maxEList[iDigitN] = en ;
1361 
1362  //printf("Local max %d, id %d, en %f\n", iDigit,absIdList[iDigitN],en);
1363  iDigitN++ ;
1364  }
1365  }
1366 
1367  if ( iDigitN == 0 )
1368  {
1369  AliDebug(1,Form("No local maxima found, assign highest energy cell as maxima, id %d, en cell %2.2f, en cluster %2.2f",
1370  idmax,emax,cluster->E()));
1371  iDigitN = 1 ;
1372  maxEList[0] = emax ;
1373  absIdList[0] = idmax ;
1374  }
1375 
1376 
1377  AliDebug(1,Form("In cluster E %2.2f (wth non lin. %2.2f), M02 %2.2f, M20 %2.2f, N maxima %d",
1378  cluster->E(),eCluster, cluster->GetM02(),cluster->GetM20(), iDigitN));
1379 
1380 // if(fDebug > 1) for(Int_t imax = 0; imax < iDigitN; imax++)
1381 // {
1382 // printf(" \t i %d, absId %d, Ecell %f\n",imax,absIdList[imax],maxEList[imax]);
1383 // }
1384 
1385  return iDigitN ;
1386 }
1387 
1388 //____________________________________
1390 //____________________________________
1392 {
1393  if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1394  {
1395  AliError("AliCalorimeterUtils::GetPass() - Pointer to tree = 0, returning null");
1396  return TString("");
1397  }
1398 
1399  if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1400  {
1401  AliError("AliCalorimeterUtils::GetPass() - Null pointer input file, returning null");
1402  return TString("");
1403  }
1404 
1405  TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1406  if (pass.Contains("ass1")) return TString("pass1");
1407  else if (pass.Contains("ass2")) return TString("pass2");
1408  else if (pass.Contains("ass3")) return TString("pass3");
1409  else if (pass.Contains("ass4")) return TString("pass4");
1410  else if (pass.Contains("ass5")) return TString("pass5");
1411  else if (pass.Contains("LHC11c") && pass.Contains("spc_calo") ) return TString("spc_calo");
1412  else if (pass.Contains("calo") || pass.Contains("high_lumi"))
1413  {
1414  AliInfo("Path contains <calo> or <high-lumi>, set as <pass1>");
1415  return TString("pass1");
1416  }
1417  else if (pass.Contains("LHC14a1a"))
1418  {
1419  AliInfo("Check that Energy calibration was enabled for this MC production in the tender, clusterizer or here!!");
1420 
1421  return TString("LHC14a1a");
1422  }
1423 
1424  // No condition fullfilled, give a default value
1425  AliInfo("Pass number string not found");
1426  return TString("");
1427 }
1428 
1429 //________________________________________
1431 //________________________________________
1433 {
1434  fEMCALGeoName = "";
1435  fPHOSGeoName = "";
1436 
1437  fEMCALGeoMatrixSet = kFALSE;
1438  fPHOSGeoMatrixSet = kFALSE;
1439 
1440  fRemoveBadChannels = kFALSE;
1441 
1443 
1444  fLocMaxCutE = 0.1 ;
1445  fLocMaxCutEDiff = 0.0 ;
1446 
1447  // fMaskCellColumns = new Int_t[fNMaskCellColumns];
1448  // fMaskCellColumns[0] = 6 ; fMaskCellColumns[1] = 7 ; fMaskCellColumns[2] = 8 ;
1449  // fMaskCellColumns[3] = 35; fMaskCellColumns[4] = 36; fMaskCellColumns[5] = 37;
1450  // fMaskCellColumns[6] = 12+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[7] = 13+AliEMCALGeoParams::fgkEMCALCols;
1451  // fMaskCellColumns[8] = 40+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[9] = 41+AliEMCALGeoParams::fgkEMCALCols;
1452  // fMaskCellColumns[10]= 42+AliEMCALGeoParams::fgkEMCALCols;
1453 
1454  fOADBSet = kFALSE;
1455  fOADBForEMCAL = kTRUE ;
1456  fOADBForPHOS = kFALSE;
1457 
1458  fOADBFilePathEMCAL = "$ALICE_PHYSICS/OADB/EMCAL" ;
1459  fOADBFilePathPHOS = "$ALICE_PHYSICS/OADB/PHOS" ;
1460 
1461  fImportGeometryFromFile = kTRUE;
1463 
1464  fNSuperModulesUsed = 22;
1465 
1466  fMCECellClusFracCorrParam[0] = 0.78;
1467  fMCECellClusFracCorrParam[1] =-1.8;
1468  fMCECellClusFracCorrParam[2] =-6.3;
1469  fMCECellClusFracCorrParam[3] = 0.014;
1470 }
1471 
1472 //_____________________________________________________
1474 //_____________________________________________________
1476 {
1477  AliDebug(1,"Init bad channel map");
1478 
1479  // In order to avoid rewriting the same histograms
1480  Bool_t oldStatus = TH1::AddDirectoryStatus();
1481  TH1::AddDirectory(kFALSE);
1482 
1483  fPHOSBadChannelMap = new TObjArray(5);
1484  for (int i = 0; i < 5; i++)fPHOSBadChannelMap->Add(new TH2I(Form("PHOS_BadMap_mod%d",i),
1485  Form("PHOS_BadMap_mod%d",i),
1486  64, 0, 64, 56, 0, 56));
1487 
1488  fPHOSBadChannelMap->SetOwner(kTRUE);
1489  fPHOSBadChannelMap->Compress();
1490 
1491  //In order to avoid rewriting the same histograms
1492  TH1::AddDirectory(oldStatus);
1493 }
1494 
1495 //______________________________________________________
1497 //______________________________________________________
1499 {
1500  AliDebug(1,"Init recalibration map");
1501 
1502  // In order to avoid rewriting the same histograms
1503  Bool_t oldStatus = TH1::AddDirectoryStatus();
1504  TH1::AddDirectory(kFALSE);
1505 
1506  fPHOSRecalibrationFactors = new TObjArray(5);
1507  for (int i = 0; i < 5; i++)
1508  {
1509  fPHOSRecalibrationFactors->Add(new TH2F(Form("PHOSRecalFactors_Mod%d",i),
1510  Form("PHOSRecalFactors_Mod%d",i),
1511  64, 0, 64, 56, 0, 56));
1512  }
1513 
1514  // Init the histograms with 1
1515  for (Int_t m = 0; m < 5; m++)
1516  {
1517  for (Int_t i = 0; i < 56; i++)
1518  {
1519  for (Int_t j = 0; j < 64; j++)
1520  {
1522  }
1523  }
1524  }
1525 
1526  fPHOSRecalibrationFactors->SetOwner(kTRUE);
1527  fPHOSRecalibrationFactors->Compress();
1528 
1529  // In order to avoid rewriting the same histograms
1530  TH1::AddDirectory(oldStatus);
1531 }
1532 
1537 {
1538  if (fEMCALGeo) return;
1539 
1540  AliDebug(1,Form(" for run=%d",fRunNumber));
1541 
1542  if(fEMCALGeoName=="")
1543  {
1544  fEMCALGeo = AliEMCALGeometry::GetInstanceFromRunNumber(fRunNumber);
1545  AliInfo(Form("Get EMCAL geometry name to <%s> for run %d",fEMCALGeo->GetName(),fRunNumber));
1546  }
1547  else
1548  {
1549  fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName);
1550  AliInfo(Form("Set EMCAL geometry name to <%s>",fEMCALGeoName.Data()));
1551  }
1552 
1553  // Init geometry, I do not like much to do it like this ...
1554  if(fImportGeometryFromFile && !gGeoManager)
1555  {
1556  if(fImportGeometryFilePath=="") // If not specified, set location depending on run number
1557  {
1558  // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
1559  if (fRunNumber < 140000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2010.root";
1560  else if(fRunNumber < 171000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2011.root";
1561  else if(fRunNumber < 198000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2012.root"; // 2012-2013
1562  else fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2015.root"; // >= 2015
1563  }
1564 
1565  AliInfo(Form("Import %s",fImportGeometryFilePath.Data()));
1566 
1567  TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
1568  }
1569  else if (!gGeoManager) AliInfo("Careful!, gGeoManager not loaded, load misalign matrices");
1570 }
1571 
1576 {
1577  if (fPHOSGeo) return;
1578 
1579  AliDebug(1,Form(" for run=%d",fRunNumber));
1580 
1581  if(fPHOSGeoName=="") fPHOSGeoName = "PHOSgeo";
1582 
1583  fPHOSGeo = new AliPHOSGeoUtils(fPHOSGeoName);
1584 
1585  //if (!gGeoManager) AliInfo("Careful!, gGeoManager not loaded, load misalign matrices");
1586 }
1587 
1588 //______________________________________________________________________________________________
1589 // Check that a MC ESD is in the calorimeter acceptance
1590 //______________________________________________________________________________________________
1591 Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, TParticle* particle)
1592 {
1593  if(!particle || (calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS)) return kFALSE ;
1594 
1595  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1597  {
1598  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1599  return kFALSE ;
1600  }
1601 
1602  if(calo == AliFiducialCut::kPHOS )
1603  {
1604  Int_t mod = 0 ;
1605  Double_t x = 0, z = 0 ;
1606  return GetPHOSGeometry()->ImpactOnEmc( particle, mod, z, x);
1607  }
1608  else if(calo == AliFiducialCut::kEMCAL)
1609  {
1610  Int_t absID = 0 ;
1611  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(),absID);
1612  if(ok)
1613  {
1614  Int_t icol = -1, irow = -1, iRCU = -1;
1615  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1616  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1617  if(status > 0) ok = kFALSE;
1618  }
1619 
1620  return ok ;
1621  }
1622 
1623  return kFALSE ;
1624 }
1625 
1626 //______________________________________________________________________________________________________
1628 //______________________________________________________________________________________________________
1629 Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, AliAODMCParticle* particle)
1630 {
1631  if(!particle || (calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS)) return kFALSE ;
1632 
1633  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1635  {
1636  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1637  return kFALSE ;
1638  }
1639 
1640  Float_t phi = particle->Phi();
1641  if(phi < 0) phi+=TMath::TwoPi();
1642 
1643  if(calo == AliFiducialCut::kPHOS )
1644  {
1645  Int_t mod = 0 ;
1646  Double_t x = 0, z = 0 ;
1647  Double_t vtx[]={ particle->Xv(), particle->Yv(), particle->Zv() } ;
1648  return GetPHOSGeometry()->ImpactOnEmc(vtx, particle->Theta(), phi, mod, z, x) ;
1649  }
1650  else if(calo == AliFiducialCut::kEMCAL)
1651  {
1652  Int_t absID = 0 ;
1653  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),phi,absID);
1654  if(ok)
1655  {
1656  Int_t icol = -1, irow = -1, iRCU = -1;
1657  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1658  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1659  if(status > 0) ok = kFALSE;
1660  }
1661 
1662  return ok ;
1663  }
1664 
1665  return kFALSE ;
1666 }
1667 
1668 //_____________________________________________________________________________________________________
1669 // Check that a TLorentzVector is in the calorimeter acceptance, give the cell number where it hit.
1670 //_____________________________________________________________________________________________________
1671 Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, Float_t eta, Float_t theta,
1672  Float_t phiOrg, Int_t & absID)
1673 {
1674  if(calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS) return kFALSE ;
1675 
1676  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1678  {
1679  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1680  return kFALSE ;
1681  }
1682 
1683  Float_t phi = phiOrg;
1684  if(phi < 0) phi+=TMath::TwoPi();
1685 
1686  if(calo == AliFiducialCut::kPHOS )
1687  {
1688  Int_t mod = 0 ;
1689  Double_t x = 0, z = 0 ;
1690  Double_t vtx[]={0,0,0} ;
1691  return GetPHOSGeometry()->ImpactOnEmc(vtx, theta, phi, mod, z, x) ;
1692  }
1693  else if(calo == AliFiducialCut::kEMCAL)
1694  {
1695  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(eta,phi,absID);
1696  if(ok)
1697  {
1698  Int_t icol = -1, irow = -1, iRCU = -1;
1699  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1700  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1701  if(status > 0) ok = kFALSE;
1702  }
1703 
1704  return ok ;
1705  }
1706 
1707  return kFALSE ;
1708 }
1709 
1710 //_______________________________________________________________________
1713 //_______________________________________________________________________
1714 Bool_t AliCalorimeterUtils::MaskFrameCluster(Int_t iSM, Int_t ieta) const
1715 {
1716  Int_t icol = ieta;
1717  if ( iSM%2 ) icol+=48; // Impair SM, shift index [0-47] to [48-96]
1718 
1720  {
1721  for (Int_t imask = 0; imask < fNMaskCellColumns; imask++)
1722  {
1723  if(icol==fMaskCellColumns[imask]) return kTRUE;
1724  }
1725  }
1726 
1727  return kFALSE;
1728 }
1729 
1730 //_________________________________________________________
1732 //_________________________________________________________
1733 void AliCalorimeterUtils::Print(const Option_t * opt) const
1734 {
1735  if(! opt)
1736  return;
1737 
1738  printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
1739  printf("Remove Clusters with bad channels? %d\n",fRemoveBadChannels);
1740  printf("Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
1741  fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(), fNCellsFromPHOSBorder);
1742  if(fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) printf("Do not remove EMCAL clusters at Eta = 0\n");
1743  printf("Recalibrate Clusters? %d, run by run %d\n",fRecalibration,fRunDependentCorrection);
1744  printf("Recalculate Clusters Position? %d\n",fRecalculatePosition);
1745  printf("Recalculate Clusters Energy? %d\n",fCorrectELinearity);
1746  printf("Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",fCutR,fCutZ);
1747 
1748  printf("Recalibrate time? %d, With L1 phase run by run? %d\n",IsTimeRecalibrationOn(),IsL1PhaseInTimeRecalibrationOn());
1749 
1750  printf("Loc. Max. E > %2.2f\n", fLocMaxCutE);
1751  printf("Loc. Max. E Diff > %2.2f\n", fLocMaxCutEDiff);
1752 
1753  printf(" \n") ;
1754 }
1755 
1756 //_____________________________________________________________________________________________
1758 //_____________________________________________________________________________________________
1759 void AliCalorimeterUtils::RecalibrateCellAmplitude(Float_t & amp, Int_t calo, Int_t id) const
1760 {
1761  Int_t icol = -1; Int_t irow = -1; Int_t iRCU = -1;
1762  Int_t nModule = GetModuleNumberCellIndexes(id,calo, icol, irow, iRCU);
1763 
1764  if (IsRecalibrationOn())
1765  {
1766  if(calo == AliFiducialCut::kPHOS)
1767  {
1768  amp *= GetPHOSChannelRecalibrationFactor(nModule,icol,irow);
1769  }
1770  else
1771  {
1772  amp *= GetEMCALChannelRecalibrationFactor(nModule,icol,irow);
1773  }
1774  }
1775 }
1776 
1777 //____________________________________________________________________________________________________
1779 //____________________________________________________________________________________________________
1780 void AliCalorimeterUtils::RecalibrateCellTime(Double_t & time, Int_t calo, Int_t id, Int_t bc) const
1781 {
1783  {
1784  GetEMCALRecoUtils()->RecalibrateCellTime(id,bc,time);
1785  }
1786 }
1787 
1788 
1789 //____________________________________________________________________________________________________
1791 //____________________________________________________________________________________________________
1792 void AliCalorimeterUtils::RecalibrateCellTimeL1Phase(Double_t & time, Int_t calo, Int_t iSM, Int_t bunchCrossNumber) const
1793 {
1795  {
1796  GetEMCALRecoUtils()->RecalibrateCellTimeL1Phase(iSM, bunchCrossNumber, time);
1797  }
1798 }
1799 
1800 
1801 //__________________________________________________________________________
1803 //__________________________________________________________________________
1804 Float_t AliCalorimeterUtils::RecalibrateClusterEnergy(AliVCluster * cluster,
1805  AliVCaloCells * cells)
1806 {
1807  // Initialize some used variables
1808  Float_t frac = 0., energy = 0.;
1809 
1810  if(cells)
1811  {
1812  //Get the cluster number of cells and list of absId, check what kind of cluster do we have.
1813 
1814  UShort_t * index = cluster->GetCellsAbsId() ;
1815  Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1816 
1817  Int_t ncells = cluster->GetNCells();
1818 
1819  Int_t calo = AliFiducialCut::kEMCAL;
1820  if(cluster->IsPHOS()) calo = AliFiducialCut::kPHOS ;
1821 
1822  // Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
1823  for(Int_t icell = 0; icell < ncells; icell++)
1824  {
1825  Int_t absId = index[icell];
1826 
1827  frac = fraction[icell];
1828  if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
1829 
1830  Float_t amp = cells->GetCellAmplitude(absId);
1831  RecalibrateCellAmplitude(amp,calo, absId);
1832 
1833  AliDebug(2,Form("Recalibrate cell: calo <%d>, cell fraction %f, cell energy: before cal %f; after cal %f",
1834  calo,frac,cells->GetCellAmplitude(absId),amp));
1835 
1836  energy += amp*frac;
1837  }
1838 
1839  AliDebug(1,Form("Energy before %f, after %f",cluster->E(),energy));
1840 
1841  } // cells available
1842  else
1843  {
1844  AliFatal("Cells pointer does not exist!");
1845  }
1846 
1847  return energy;
1848 }
1849 
1850 //_______________________________________________________________________________________________________
1853 //_______________________________________________________________________________________________________
1855  AliVCaloCells * cells, Float_t energyOrg)
1856 {
1857  //Initialize some used variables
1858  Float_t frac = 0., energy = 0.;
1859 
1860  if(cells)
1861  {
1862  // Get the cluster number of cells and list of absId, check what kind of cluster do we have.
1863 
1864  UShort_t * index = cluster->GetCellsAbsId() ;
1865  Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1866 
1867  Int_t ncells = cluster->GetNCells();
1868 
1869  Int_t calo = AliFiducialCut::kEMCAL;
1870  if(cluster->IsPHOS()) calo = AliFiducialCut::kPHOS ;
1871 
1872  // Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
1873  for(Int_t icell = 0; icell < ncells; icell++)
1874  {
1875  Int_t absId = index[icell];
1876 
1877  frac = fraction[icell];
1878  if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
1879 
1880  Float_t amp = cells->GetCellAmplitude(absId);
1881  RecalibrateCellAmplitude(amp,calo, absId);
1882 
1883  amp*=GetMCECellClusFracCorrection(amp,energyOrg);
1884 
1885  AliDebug(2,Form("Recalibrate cell: calo <%d>, cell fraction %f, cell energy %f",
1886  calo,frac,cells->GetCellAmplitude(absId)));
1887 
1888  energy += amp*frac;
1889  }
1890 
1891  AliDebug(1,Form("Energy before %f, after %f",cluster->E(),energy));
1892  } // cells available
1893  else
1894  {
1895  AliFatal("Cells pointer does not exist!");
1896  }
1897 
1898  return energy;
1899 }
1900 
1901 //__________________________________________________________________________________________
1904 //__________________________________________________________________________________________
1905 void AliCalorimeterUtils::RecalculateClusterPosition(AliVCaloCells* cells, AliVCluster* clu)
1906 {
1907  fEMCALRecoUtils->RecalculateClusterPosition((AliEMCALGeometry*)fEMCALGeo, cells,clu);
1908 }
1909 
1910 //________________________________________________________________________________
1916 //________________________________________________________________________________
1918  TObjArray* clusterArray)
1919 {
1920  if (!fRecalculateMatching) return ;
1921 
1922  fEMCALRecoUtils->FindMatches(event,clusterArray,fEMCALGeo) ;
1923 
1924  Float_t dZ = 2000;
1925  Float_t dR = 2000;
1926 
1927  Int_t nClusters = event->GetNumberOfCaloClusters();
1928  if(clusterArray) nClusters = clusterArray->GetEntriesFast();
1929 
1930  AliVCluster * clus = 0;
1931 
1932  for (Int_t iclus = 0; iclus < nClusters ; iclus++)
1933  {
1934  if ( clusterArray ) clus = (AliVCluster*) clusterArray->At(iclus) ;
1935  else clus = event->GetCaloCluster(iclus) ;
1936 
1937  if (!clus->IsEMCAL()) continue ;
1938 
1939  //
1940  // Put track residuals in cluster
1941  //
1942  fEMCALRecoUtils->GetMatchedResiduals(clus->GetID(),dZ,dR);
1943 
1944  if ( TMath::Abs(clus->GetTrackDx()) < 500 )
1945  AliDebug(2,Form("Residuals (Old, New): z (%2.4f,%2.4f), x (%2.4f,%2.4f)\n",
1946  clus->GetTrackDz(),dZ,clus->GetTrackDx(),dR));
1947 
1948  clus->SetTrackDistance(dR,dZ);
1949 
1950  //
1951  // Remove old matches in cluster
1952  //
1953  if(clus->GetNTracksMatched() > 0)
1954  {
1955  if(!strcmp("AliESDCaloCluster",Form("%s",clus->ClassName())))
1956  {
1957  TArrayI arrayTrackMatched(0);
1958  ((AliESDCaloCluster*)clus)->AddTracksMatched(arrayTrackMatched);
1959  }
1960  else
1961  {
1962  for(Int_t iTrack = 0; iTrack < clus->GetNTracksMatched(); iTrack++)
1963  {
1964  ((AliAODCaloCluster*)clus)->RemoveTrackMatched((TObject*)((AliAODCaloCluster*)clus)->GetTrackMatched(iTrack));
1965  }
1966  }
1967  }
1968 
1969  //
1970  // Now put first track index in cluster.
1971  //
1972  Int_t trackIndex = fEMCALRecoUtils->GetMatchedTrackIndex(iclus);
1973  if ( trackIndex >= 0 )
1974  {
1975  if(!strcmp("AliESDCaloCluster",Form("%s",clus->ClassName())))
1976  {
1977  TArrayI arrayTrackMatched(1);
1978  arrayTrackMatched[0] = trackIndex;
1979  ((AliESDCaloCluster*)clus)->AddTracksMatched(arrayTrackMatched);
1980  }
1981  else
1982  {
1983  ((AliAODCaloCluster*)clus)->AddTrackMatched((TObject*)event->GetTrack(trackIndex));
1984  }
1985  }
1986 
1987  } // cluster loop
1988 }
1989 
1990 //___________________________________________________________________________
2003 //___________________________________________________________________________
2004 void AliCalorimeterUtils::SplitEnergy(Int_t absId1, Int_t absId2,
2005  AliVCluster* cluster,
2006  AliVCaloCells* cells,
2007  //Float_t & e1, Float_t & e2,
2008  AliAODCaloCluster* cluster1,
2009  AliAODCaloCluster* cluster2,
2010  Int_t nMax, Int_t eventNumber)
2011 {
2012  TH2F* hClusterMap = 0 ;
2013  TH2F* hClusterLocMax = 0 ;
2014  TH2F* hCluster1 = 0 ;
2015  TH2F* hCluster2 = 0 ;
2016 
2017  if(fPlotCluster)
2018  {
2019  hClusterMap = new TH2F("hClusterMap","Cluster Map",48,0,48,24,0,24);
2020  hClusterLocMax = new TH2F("hClusterLocMax","Cluster 2 highest local maxima",48,0,48,24,0,24);
2021  hCluster1 = new TH2F("hCluster1","Cluster 1",48,0,48,24,0,24);
2022  hCluster2 = new TH2F("hCluster2","Cluster 2",48,0,48,24,0,24);
2023  hClusterMap ->SetXTitle("column");
2024  hClusterMap ->SetYTitle("row");
2025  hClusterLocMax ->SetXTitle("column");
2026  hClusterLocMax ->SetYTitle("row");
2027  hCluster1 ->SetXTitle("column");
2028  hCluster1 ->SetYTitle("row");
2029  hCluster2 ->SetXTitle("column");
2030  hCluster2 ->SetYTitle("row");
2031  }
2032 
2034  if(cluster->IsPHOS())
2035  {
2036  calorimeter = AliFiducialCut::kPHOS;
2037  AliWarning("Not supported for PHOS yet");
2038  return;
2039  }
2040 
2041  const Int_t ncells = cluster->GetNCells();
2042  Int_t absIdList[ncells];
2043 
2044  Float_t e1 = 0, e2 = 0 ;
2045  Int_t icol = -1, irow = -1, iRCU = -1, sm = -1;
2046  Float_t eCluster = 0;
2047  Float_t minCol = 100, minRow = 100, maxCol = -1, maxRow = -1;
2048  for(Int_t iDigit = 0; iDigit < ncells; iDigit++ )
2049  {
2050  absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit];
2051 
2052  Float_t ec = cells->GetCellAmplitude(absIdList[iDigit]);
2053  RecalibrateCellAmplitude(ec,calorimeter, absIdList[iDigit]);
2054  eCluster+=ec;
2055 
2056  if(fPlotCluster)
2057  {
2058  //printf("iDigit %d, absId %d, Ecell %f\n",iDigit,absIdList[iDigit], cells->GetCellAmplitude(absIdList[iDigit]));
2059  sm = GetModuleNumberCellIndexes(absIdList[iDigit], calorimeter, icol, irow, iRCU) ;
2060  if(sm > -1 && sm < 12) // just to avoid compilation warning
2061  {
2062  if(icol > maxCol) maxCol = icol;
2063  if(icol < minCol) minCol = icol;
2064  if(irow > maxRow) maxRow = irow;
2065  if(irow < minRow) minRow = irow;
2066  hClusterMap->Fill(icol,irow,ec);
2067  }
2068  }
2069  }
2070 
2071  // Init counters and variables
2072  Int_t ncells1 = 1 ;
2073  UShort_t absIdList1[9] ;
2074  Double_t fracList1 [9] ;
2075  absIdList1[0] = absId1 ;
2076  fracList1 [0] = 1. ;
2077 
2078  Float_t ecell1 = cells->GetCellAmplitude(absId1);
2079  RecalibrateCellAmplitude(ecell1, calorimeter, absId1);
2080  e1 = ecell1;
2081 
2082  Int_t ncells2 = 1 ;
2083  UShort_t absIdList2[9] ;
2084  Double_t fracList2 [9] ;
2085  absIdList2[0] = absId2 ;
2086  fracList2 [0] = 1. ;
2087 
2088  Float_t ecell2 = cells->GetCellAmplitude(absId2);
2089  RecalibrateCellAmplitude(ecell2, calorimeter, absId2);
2090  e2 = ecell2;
2091 
2092  if(fPlotCluster)
2093  {
2094  Int_t icol1 = -1, irow1 = -1, icol2 = -1, irow2 = -1;
2095  sm = GetModuleNumberCellIndexes(absId1, calorimeter, icol1, irow1, iRCU) ;
2096  hClusterLocMax->Fill(icol1,irow1,ecell1);
2097  sm = GetModuleNumberCellIndexes(absId2, calorimeter, icol2, irow2, iRCU) ;
2098  hClusterLocMax->Fill(icol2,irow2,ecell2);
2099  }
2100 
2101  // Very rough way to share the cluster energy
2102  Float_t eRemain = (eCluster-ecell1-ecell2)/2;
2103  Float_t shareFraction1 = ecell1/eCluster+eRemain/eCluster;
2104  Float_t shareFraction2 = ecell2/eCluster+eRemain/eCluster;
2105 
2106  for(Int_t iDigit = 0; iDigit < ncells; iDigit++)
2107  {
2108  Int_t absId = absIdList[iDigit];
2109 
2110  if ( absId==absId1 || absId==absId2 || absId < 0 ) continue;
2111 
2112  Float_t ecell = cells->GetCellAmplitude(absId);
2113  RecalibrateCellAmplitude(ecell, calorimeter, absId);
2114 
2115  if(AreNeighbours(calorimeter, absId1,absId ))
2116  {
2117  absIdList1[ncells1]= absId;
2118 
2119  if(AreNeighbours(calorimeter, absId2,absId ))
2120  {
2121  fracList1[ncells1] = shareFraction1;
2122  e1 += ecell*shareFraction1;
2123  }
2124  else
2125  {
2126  fracList1[ncells1] = 1.;
2127  e1 += ecell;
2128  }
2129 
2130  ncells1++;
2131 
2132  } // neigbour to cell1
2133 
2134  if(AreNeighbours(calorimeter, absId2,absId ))
2135  {
2136  absIdList2[ncells2]= absId;
2137 
2138  if(AreNeighbours(calorimeter, absId1,absId ))
2139  {
2140  fracList2[ncells2] = shareFraction2;
2141  e2 += ecell*shareFraction2;
2142  }
2143  else
2144  {
2145  fracList2[ncells2] = 1.;
2146  e2 += ecell;
2147  }
2148 
2149  ncells2++;
2150 
2151  } // neigbour to cell2
2152  }
2153 
2154  AliDebug(1,Form("N Local Max %d, Cluster energy = %f, Ecell1 = %f, Ecell2 = %f, Enew1 = %f, Enew2 = %f, Remain %f, \n ncells %d, ncells1 %d, ncells2 %d, f1 %f, f2 %f, sum f12 = %f",
2155  nMax, eCluster,ecell1,ecell2,e1,e2,eCluster-e1-e2,ncells,ncells1,ncells2,shareFraction1,shareFraction2,shareFraction1+shareFraction2));
2156 
2157  cluster1->SetE(e1);
2158  cluster2->SetE(e2);
2159 
2160  cluster1->SetNCells(ncells1);
2161  cluster2->SetNCells(ncells2);
2162 
2163  cluster1->SetCellsAbsId(absIdList1);
2164  cluster2->SetCellsAbsId(absIdList2);
2165 
2166  cluster1->SetCellsAmplitudeFraction(fracList1);
2167  cluster2->SetCellsAmplitudeFraction(fracList2);
2168 
2169  // Correct linearity
2170  CorrectClusterEnergy(cluster1) ;
2171  CorrectClusterEnergy(cluster2) ;
2172 
2173  if(calorimeter==AliFiducialCut::kEMCAL)
2174  {
2175  GetEMCALRecoUtils()->RecalculateClusterPosition(GetEMCALGeometry(), cells, cluster1);
2176  GetEMCALRecoUtils()->RecalculateClusterPosition(GetEMCALGeometry(), cells, cluster2);
2177  }
2178 
2179  if(fPlotCluster)
2180  {
2181  //printf("Cells of cluster1: ");
2182  for(Int_t iDigit = 0; iDigit < ncells1; iDigit++ )
2183  {
2184  //printf(" %d ",absIdList1[iDigit]);
2185 
2186  sm = GetModuleNumberCellIndexes(absIdList1[iDigit], calorimeter, icol, irow, iRCU) ;
2187 
2188  Float_t ecell = cells->GetCellAmplitude(absIdList1[iDigit]);
2189  RecalibrateCellAmplitude(ecell, calorimeter, absIdList1[iDigit]);
2190 
2191  if( AreNeighbours(calorimeter, absId2,absIdList1[iDigit]) && absId1!=absIdList1[iDigit])
2192  hCluster1->Fill(icol,irow,ecell*shareFraction1);
2193  else
2194  hCluster1->Fill(icol,irow,ecell);
2195  }
2196 
2197  //printf(" \n ");
2198  //printf("Cells of cluster2: ");
2199 
2200  for(Int_t iDigit = 0; iDigit < ncells2; iDigit++ )
2201  {
2202  //printf(" %d ",absIdList2[iDigit]);
2203 
2204  sm = GetModuleNumberCellIndexes(absIdList2[iDigit], calorimeter, icol, irow, iRCU) ;
2205 
2206  Float_t ecell = cells->GetCellAmplitude(absIdList2[iDigit]);
2207  RecalibrateCellAmplitude(ecell, calorimeter, absIdList2[iDigit]);
2208 
2209  if( AreNeighbours(calorimeter, absId1,absIdList2[iDigit]) && absId2!=absIdList2[iDigit])
2210  hCluster2->Fill(icol,irow,ecell*shareFraction2);
2211  else
2212  hCluster2->Fill(icol,irow,ecell);
2213  }
2214  //printf(" \n ");
2215 
2216  gStyle->SetPadRightMargin(0.1);
2217  gStyle->SetPadLeftMargin(0.1);
2218  gStyle->SetOptStat(0);
2219  gStyle->SetOptFit(000000);
2220 
2221  if(maxCol-minCol > maxRow-minRow)
2222  {
2223  maxRow+= maxCol-minCol;
2224  }
2225  else
2226  {
2227  maxCol+= maxRow-minRow;
2228  }
2229 
2230  TCanvas * c= new TCanvas("canvas", "canvas", 4000, 4000) ;
2231  c->Divide(2,2);
2232  c->cd(1);
2233  gPad->SetGridy();
2234  gPad->SetGridx();
2235  gPad->SetLogz();
2236  hClusterMap ->SetAxisRange(minCol, maxCol,"X");
2237  hClusterMap ->SetAxisRange(minRow, maxRow,"Y");
2238  hClusterMap ->Draw("colz TEXT");
2239  c->cd(2);
2240  gPad->SetGridy();
2241  gPad->SetGridx();
2242  gPad->SetLogz();
2243  hClusterLocMax ->SetAxisRange(minCol, maxCol,"X");
2244  hClusterLocMax ->SetAxisRange(minRow, maxRow,"Y");
2245  hClusterLocMax ->Draw("colz TEXT");
2246  c->cd(3);
2247  gPad->SetGridy();
2248  gPad->SetGridx();
2249  gPad->SetLogz();
2250  hCluster1 ->SetAxisRange(minCol, maxCol,"X");
2251  hCluster1 ->SetAxisRange(minRow, maxRow,"Y");
2252  hCluster1 ->Draw("colz TEXT");
2253  c->cd(4);
2254  gPad->SetGridy();
2255  gPad->SetGridx();
2256  gPad->SetLogz();
2257  hCluster2 ->SetAxisRange(minCol, maxCol,"X");
2258  hCluster2 ->SetAxisRange(minRow, maxRow,"Y");
2259  hCluster2 ->Draw("colz TEXT");
2260 
2261  if(eCluster > 6 )c->Print(Form("clusterFigures/Event%d_E%1.0f_nMax%d_NCell1_%d_NCell2_%d.eps",
2262  eventNumber,cluster->E(),nMax,ncells1,ncells2));
2263 
2264  delete c;
2265  delete hClusterMap;
2266  delete hClusterLocMax;
2267  delete hCluster1;
2268  delete hCluster2;
2269  }
2270 }
2271 
Bool_t fRecalculatePosition
Recalculate cluster position.
AliEMCALGeometry * fEMCALGeo
! EMCAL geometry pointer.
void InitPHOSRecalibrationFactors()
Init PHOS recalibration factors.
Bool_t IsRecalculationOfClusterTrackMatchingOn() const
TGeoHMatrix * fEMCALMatrix[22]
Geometry matrices with alignments.
Int_t GetPHOSChannelStatus(Int_t imod, Int_t iCol, Int_t iRow) const
Float_t fLocMaxCutEDiff
Local maxima cut, when aggregating cells, next can be a bit higher.
TGeoHMatrix * fPHOSMatrix[5]
Geometry matrices with alignments.
Bool_t ClusterContainsBadChannel(Int_t calo, UShort_t *cellList, Int_t nCells)
AliPHOSGeoUtils * fPHOSGeo
! PHOS geometry pointer.
AliEMCALRecoUtils * GetEMCALRecoUtils() const
void SetEMCALL1PhaseInTimeRecalibrationForAllSM(TObjArray *map)
TString fileName
void SwitchOnDistToBadChannelRecalculation()
AliPHOSGeoUtils * GetPHOSGeometry() const
Bool_t fOADBForEMCAL
Get calibration from OADB for EMCAL.
Float_t GetPHOSChannelRecalibrationFactor(Int_t imod, Int_t iCol, Int_t iRow) const
void RecalculateClusterTrackMatching(AliVEvent *event, TObjArray *clusterArray=0x0)
Float_t fLocMaxCutE
Local maxima cut must have more than this energy.
Float_t GetMCECellClusFracCorrection(Float_t eCell, Float_t eCluster) const
void SetEMCALChannelStatusMap(Int_t iSM, TH2I *h)
Bool_t fRunDependentCorrection
Switch on or off the recalibration dependent on T.
TObjArray * fPHOSRecalibrationFactors
Array of histograms with map of recalibration factors, PHOS.
TString fEMCALGeoName
Name of geometry to use for EMCAL.
TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const
Bool_t fRecalibration
Switch on or off the recalibration.
Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM, Int_t iCol, Int_t iRow) const
TH1F * GetEMCALChannelTimeRecalibrationFactors(Int_t bc) const
const TString calorimeter
Definition: anaM.C:35
Int_t fDebug
Debugging level.
TH1C * GetEMCALL1PhaseInTimeRecalibrationForAllSM() const
Bool_t IsRecalibrationOn() const
Bool_t IsMCParticleInCalorimeterAcceptance(Int_t calo, TParticle *particle)
virtual void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
Int_t GetModuleNumber(AliAODPWG4Particle *particle, AliVEvent *inputEvent) const
Get the EMCAL/PHOS module number that corresponds to this particle.
Bool_t fLoadEMCALMatrices
Matrices set from configuration, not get from geometry.root or from ESDs/AODs.
AliEMCALGeometry * GetEMCALGeometry() const
Bool_t IsL1PhaseInTimeRecalibrationOn() const
Bool_t fRecalculateMatching
Recalculate cluster position.
Bool_t MaskFrameCluster(Int_t iSM, Int_t ieta) const
Bool_t fOADBForPHOS
Get calibration from OADB for PHOS.
Int_t * fMaskCellColumns
List of masked cells collumn index.
Bool_t fRemoveBadChannels
Check the channel status provided and remove clusters with bad channels.
void InitPHOSBadChannelStatusMap()
Init PHOS bad channels map.
AliCalorimeterUtils()
Constructor. Initialize parameters.
virtual void InitParameters()
Initialize the parameters of the analysis.
Int_t fNMaskCellColumns
Number of masked columns.
Bool_t IsClusterSharedByTwoSuperModules(const AliEMCALGeometry *geom, AliVCluster *cluster)
Int_t GetNumberOfLocalMaxima(AliVCluster *cluster, AliVCaloCells *cells)
Find the number of local maxima in cluster.
Float_t fMCECellClusFracCorrParam[4]
Parameters for the function correcting the weight of the cells in the cluster.
Bool_t fEMCALGeoMatrixSet
Check if the transformation matrix is set for EMCAL.
TH2I * GetPHOSChannelStatusMap(Int_t imod) const
void SetEMCALChannelRecalibrationFactor(Int_t iSM, Int_t iCol, Int_t iRow, Double_t c=1)
TString GetPass()
Get passx from filename.
energy
void RecalculateClusterPosition(AliVCaloCells *cells, AliVCluster *clu)
Bool_t fImportGeometryFromFile
Import geometry settings in geometry.root file.
Bool_t fCorrectELinearity
Correct cluster energy linearity.
Bool_t fPHOSGeoMatrixSet
Check if the transformation matrix is set for PHOS.
TString fOADBFilePathPHOS
Default path $ALICE_PHYSICS/OADB/PHOS, if needed change.
void CorrectClusterEnergy(AliVCluster *cl)
Correct cluster energy non linearity.
Float_t fCutZ
dZ cut on matching (EMCAL/PHOS).
Bool_t fLoadPHOSMatrices
Matrices set from configuration, not get from geometry.root or from ESDs/AODs.
void SetPHOSChannelStatusMap(Int_t imod, TH2I *h)
Int_t fNCellsFromPHOSBorder
Number of cells from PHOS border the cell with maximum amplitude has to be.
AliVTrack * GetMatchedTrack(AliVCluster *cluster, AliVEvent *event, Int_t index=-1) const
void RecalibrateCellTimeL1Phase(Double_t &time, Int_t calo, Int_t iSM, Int_t bunchCrossNumber) const
Recalculate time L1 phase shift if time recalibration available for EMCAL.
Bool_t fMCECellClusFracCorrOn
Correct or not the weight of cells in cluster.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Int_t fNSuperModulesUsed
Number of supermodules to be used in analysis, can be different than the real geo, to be used at initialization of histograms.
TString fImportGeometryFilePath
Path fo geometry.root file.
Bool_t fPlotCluster
Plot cluster in splitting method.
Int_t fRunNumber
Run number of the data, take it from data itself unless set by user.
void RecalibrateCellAmplitude(Float_t &amp, Int_t calo, Int_t absId) const
Recalculate cell energy if recalibration factor.
void SetEMCALChannelTimeRecalibrationFactors(TObjArray *map)
Bool_t IsPHOSGeoMatrixSet() const
Bool_t IsTimeRecalibrationOn() const
Bool_t fOADBSet
AODB parameters already set.
TObjArray * fPHOSBadChannelMap
Array of histograms with map of bad channels, PHOS.
TString fPHOSGeoName
Name of geometry to use for PHOS.
Bool_t AreNeighbours(Int_t calo, Int_t absId1, Int_t absId2) const
Int_t GetEMCALChannelStatus(Int_t iSM, Int_t iCol, Int_t iRow) const
Bool_t IsEMCALGeoMatrixSet() const
Class with utils specific to calorimeter clusters/cells.
void AccessGeometry(AliVEvent *inputEvent)
AliEMCALRecoUtils * fEMCALRecoUtils
EMCAL utils for cluster rereconstruction.
void SetEMCALChannelRecalibrationFactors(Int_t iSM, TH2F *h)
void AccessOADB(AliVEvent *event)
TString fOADBFilePathEMCAL
Default path $ALICE_PHYSICS/OADB/EMCAL, if needed change.
void RecalibrateCellTime(Double_t &time, Int_t calo, Int_t absId, Int_t bunchCrossNumber) const
Recalculate time if time recalibration available for EMCAL not ready for PHOS.
Int_t GetMaxEnergyCell(AliVCaloCells *cells, AliVCluster *clu, Float_t &fraction) const
For a given CaloCluster, it gets the absId of the cell with maximum energy deposit.
Float_t fCutR
dR cut on matching (PHOS).
Float_t RecalibrateClusterEnergyWeightCell(AliVCluster *cluster, AliVCaloCells *cells, Float_t energyOrg)
void SplitEnergy(Int_t absId1, Int_t absId2, AliVCluster *cluster, AliVCaloCells *cells, AliAODCaloCluster *cluster1, AliAODCaloCluster *cluster2, Int_t nMax, Int_t eventNumber=0)
Int_t GetModuleNumberCellIndexes(Int_t absId, Int_t calo, Int_t &icol, Int_t &irow, Int_t &iRCU) const
Get the EMCAL/PHOS module, columns, row and RCU/DDL number that corresponds to this absId...
TH2I * GetEMCALChannelStatusMap(Int_t iSM) const
void SetPHOSChannelRecalibrationFactor(Int_t imod, Int_t iCol, Int_t iRow, Double_t c=1)
Float_t RecalibrateClusterEnergy(AliVCluster *cluster, AliVCaloCells *cells)
Recalibrate the cluster energy, considering the recalibration map and the energy of the cells that co...
void GetEMCALSubregion(AliVCluster *clus, AliVCaloCells *cells, Int_t &regEta, Int_t &regPhi) const
Bool_t CheckCellFiducialRegion(AliVCluster *cluster, AliVCaloCells *cells) const
Int_t GetModuleNumberCellIndexesAbsCaloMap(Int_t absId, Int_t calo, Int_t &icol, Int_t &irow, Int_t &iRCU, Int_t &icolAbs, Int_t &irowAbs) const