AliPhysics  bf041da (bf041da)
 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 
1418  // No condition fullfilled, give a default value
1419  AliInfo("Pass number string not found");
1420  return TString("");
1421 }
1422 
1423 //________________________________________
1425 //________________________________________
1427 {
1428  fEMCALGeoName = "";
1429  fPHOSGeoName = "";
1430 
1431  fEMCALGeoMatrixSet = kFALSE;
1432  fPHOSGeoMatrixSet = kFALSE;
1433 
1434  fRemoveBadChannels = kFALSE;
1435 
1437 
1438  fLocMaxCutE = 0.1 ;
1439  fLocMaxCutEDiff = 0.0 ;
1440 
1441  // fMaskCellColumns = new Int_t[fNMaskCellColumns];
1442  // fMaskCellColumns[0] = 6 ; fMaskCellColumns[1] = 7 ; fMaskCellColumns[2] = 8 ;
1443  // fMaskCellColumns[3] = 35; fMaskCellColumns[4] = 36; fMaskCellColumns[5] = 37;
1444  // fMaskCellColumns[6] = 12+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[7] = 13+AliEMCALGeoParams::fgkEMCALCols;
1445  // fMaskCellColumns[8] = 40+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[9] = 41+AliEMCALGeoParams::fgkEMCALCols;
1446  // fMaskCellColumns[10]= 42+AliEMCALGeoParams::fgkEMCALCols;
1447 
1448  fOADBSet = kFALSE;
1449  fOADBForEMCAL = kTRUE ;
1450  fOADBForPHOS = kFALSE;
1451 
1452  fOADBFilePathEMCAL = "$ALICE_PHYSICS/OADB/EMCAL" ;
1453  fOADBFilePathPHOS = "$ALICE_PHYSICS/OADB/PHOS" ;
1454 
1455  fImportGeometryFromFile = kTRUE;
1457 
1458  fNSuperModulesUsed = 22;
1459 
1460  fMCECellClusFracCorrParam[0] = 0.78;
1461  fMCECellClusFracCorrParam[1] =-1.8;
1462  fMCECellClusFracCorrParam[2] =-6.3;
1463  fMCECellClusFracCorrParam[3] = 0.014;
1464 }
1465 
1466 //_____________________________________________________
1468 //_____________________________________________________
1470 {
1471  AliDebug(1,"Init bad channel map");
1472 
1473  // In order to avoid rewriting the same histograms
1474  Bool_t oldStatus = TH1::AddDirectoryStatus();
1475  TH1::AddDirectory(kFALSE);
1476 
1477  fPHOSBadChannelMap = new TObjArray(5);
1478  for (int i = 0; i < 5; i++)fPHOSBadChannelMap->Add(new TH2I(Form("PHOS_BadMap_mod%d",i),
1479  Form("PHOS_BadMap_mod%d",i),
1480  64, 0, 64, 56, 0, 56));
1481 
1482  fPHOSBadChannelMap->SetOwner(kTRUE);
1483  fPHOSBadChannelMap->Compress();
1484 
1485  //In order to avoid rewriting the same histograms
1486  TH1::AddDirectory(oldStatus);
1487 }
1488 
1489 //______________________________________________________
1491 //______________________________________________________
1493 {
1494  AliDebug(1,"Init recalibration map");
1495 
1496  // In order to avoid rewriting the same histograms
1497  Bool_t oldStatus = TH1::AddDirectoryStatus();
1498  TH1::AddDirectory(kFALSE);
1499 
1500  fPHOSRecalibrationFactors = new TObjArray(5);
1501  for (int i = 0; i < 5; i++)
1502  {
1503  fPHOSRecalibrationFactors->Add(new TH2F(Form("PHOSRecalFactors_Mod%d",i),
1504  Form("PHOSRecalFactors_Mod%d",i),
1505  64, 0, 64, 56, 0, 56));
1506  }
1507 
1508  // Init the histograms with 1
1509  for (Int_t m = 0; m < 5; m++)
1510  {
1511  for (Int_t i = 0; i < 56; i++)
1512  {
1513  for (Int_t j = 0; j < 64; j++)
1514  {
1516  }
1517  }
1518  }
1519 
1520  fPHOSRecalibrationFactors->SetOwner(kTRUE);
1521  fPHOSRecalibrationFactors->Compress();
1522 
1523  // In order to avoid rewriting the same histograms
1524  TH1::AddDirectory(oldStatus);
1525 }
1526 
1531 {
1532  if (fEMCALGeo) return;
1533 
1534  AliDebug(1,Form(" for run=%d",fRunNumber));
1535 
1536  if(fEMCALGeoName=="")
1537  {
1538  fEMCALGeo = AliEMCALGeometry::GetInstanceFromRunNumber(fRunNumber);
1539  AliInfo(Form("Get EMCAL geometry name to <%s> for run %d",fEMCALGeo->GetName(),fRunNumber));
1540  }
1541  else
1542  {
1543  fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName);
1544  AliInfo(Form("Set EMCAL geometry name to <%s>",fEMCALGeoName.Data()));
1545  }
1546 
1547  // Init geometry, I do not like much to do it like this ...
1548  if(fImportGeometryFromFile && !gGeoManager)
1549  {
1550  if(fImportGeometryFilePath=="") // If not specified, set location depending on run number
1551  {
1552  // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
1553  if (fRunNumber < 140000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2010.root";
1554  else if(fRunNumber < 171000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2011.root";
1555  else if(fRunNumber < 198000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2012.root"; // 2012-2013
1556  else fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2015.root"; // >= 2015
1557  }
1558 
1559  AliInfo(Form("Import %s",fImportGeometryFilePath.Data()));
1560 
1561  TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
1562  }
1563  else if (!gGeoManager) AliInfo("Careful!, gGeoManager not loaded, load misalign matrices");
1564 }
1565 
1570 {
1571  if (fPHOSGeo) return;
1572 
1573  AliDebug(1,Form(" for run=%d",fRunNumber));
1574 
1575  if(fPHOSGeoName=="") fPHOSGeoName = "PHOSgeo";
1576 
1577  fPHOSGeo = new AliPHOSGeoUtils(fPHOSGeoName);
1578 
1579  //if (!gGeoManager) AliInfo("Careful!, gGeoManager not loaded, load misalign matrices");
1580 }
1581 
1582 //______________________________________________________________________________________________
1583 // Check that a MC ESD is in the calorimeter acceptance
1584 //______________________________________________________________________________________________
1585 Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, TParticle* particle)
1586 {
1587  if(!particle || (calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS)) return kFALSE ;
1588 
1589  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1591  {
1592  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1593  return kFALSE ;
1594  }
1595 
1596  if(calo == AliFiducialCut::kPHOS )
1597  {
1598  Int_t mod = 0 ;
1599  Double_t x = 0, z = 0 ;
1600  return GetPHOSGeometry()->ImpactOnEmc( particle, mod, z, x);
1601  }
1602  else if(calo == AliFiducialCut::kEMCAL)
1603  {
1604  Int_t absID = 0 ;
1605  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(),absID);
1606  if(ok)
1607  {
1608  Int_t icol = -1, irow = -1, iRCU = -1;
1609  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1610  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1611  if(status > 0) ok = kFALSE;
1612  }
1613 
1614  return ok ;
1615  }
1616 
1617  return kFALSE ;
1618 }
1619 
1620 //______________________________________________________________________________________________________
1622 //______________________________________________________________________________________________________
1623 Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, AliAODMCParticle* particle)
1624 {
1625  if(!particle || (calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS)) return kFALSE ;
1626 
1627  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1629  {
1630  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1631  return kFALSE ;
1632  }
1633 
1634  Float_t phi = particle->Phi();
1635  if(phi < 0) phi+=TMath::TwoPi();
1636 
1637  if(calo == AliFiducialCut::kPHOS )
1638  {
1639  Int_t mod = 0 ;
1640  Double_t x = 0, z = 0 ;
1641  Double_t vtx[]={ particle->Xv(), particle->Yv(), particle->Zv() } ;
1642  return GetPHOSGeometry()->ImpactOnEmc(vtx, particle->Theta(), phi, mod, z, x) ;
1643  }
1644  else if(calo == AliFiducialCut::kEMCAL)
1645  {
1646  Int_t absID = 0 ;
1647  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),phi,absID);
1648  if(ok)
1649  {
1650  Int_t icol = -1, irow = -1, iRCU = -1;
1651  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1652  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1653  if(status > 0) ok = kFALSE;
1654  }
1655 
1656  return ok ;
1657  }
1658 
1659  return kFALSE ;
1660 }
1661 
1662 //_____________________________________________________________________________________________________
1663 // Check that a TLorentzVector is in the calorimeter acceptance, give the cell number where it hit.
1664 //_____________________________________________________________________________________________________
1665 Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, Float_t eta, Float_t theta,
1666  Float_t phiOrg, Int_t & absID)
1667 {
1668  if(calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS) return kFALSE ;
1669 
1670  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1672  {
1673  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1674  return kFALSE ;
1675  }
1676 
1677  Float_t phi = phiOrg;
1678  if(phi < 0) phi+=TMath::TwoPi();
1679 
1680  if(calo == AliFiducialCut::kPHOS )
1681  {
1682  Int_t mod = 0 ;
1683  Double_t x = 0, z = 0 ;
1684  Double_t vtx[]={0,0,0} ;
1685  return GetPHOSGeometry()->ImpactOnEmc(vtx, theta, phi, mod, z, x) ;
1686  }
1687  else if(calo == AliFiducialCut::kEMCAL)
1688  {
1689  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(eta,phi,absID);
1690  if(ok)
1691  {
1692  Int_t icol = -1, irow = -1, iRCU = -1;
1693  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1694  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1695  if(status > 0) ok = kFALSE;
1696  }
1697 
1698  return ok ;
1699  }
1700 
1701  return kFALSE ;
1702 }
1703 
1704 //_______________________________________________________________________
1707 //_______________________________________________________________________
1708 Bool_t AliCalorimeterUtils::MaskFrameCluster(Int_t iSM, Int_t ieta) const
1709 {
1710  Int_t icol = ieta;
1711  if ( iSM%2 ) icol+=48; // Impair SM, shift index [0-47] to [48-96]
1712 
1714  {
1715  for (Int_t imask = 0; imask < fNMaskCellColumns; imask++)
1716  {
1717  if(icol==fMaskCellColumns[imask]) return kTRUE;
1718  }
1719  }
1720 
1721  return kFALSE;
1722 }
1723 
1724 //_________________________________________________________
1726 //_________________________________________________________
1727 void AliCalorimeterUtils::Print(const Option_t * opt) const
1728 {
1729  if(! opt)
1730  return;
1731 
1732  printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
1733  printf("Remove Clusters with bad channels? %d\n",fRemoveBadChannels);
1734  printf("Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
1735  fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(), fNCellsFromPHOSBorder);
1736  if(fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) printf("Do not remove EMCAL clusters at Eta = 0\n");
1737  printf("Recalibrate Clusters? %d, run by run %d\n",fRecalibration,fRunDependentCorrection);
1738  printf("Recalculate Clusters Position? %d\n",fRecalculatePosition);
1739  printf("Recalculate Clusters Energy? %d\n",fCorrectELinearity);
1740  printf("Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",fCutR,fCutZ);
1741 
1742  printf("Recalibrate time? %d, With L1 phase run by run? %d\n",IsTimeRecalibrationOn(),IsL1PhaseInTimeRecalibrationOn());
1743 
1744  printf("Loc. Max. E > %2.2f\n", fLocMaxCutE);
1745  printf("Loc. Max. E Diff > %2.2f\n", fLocMaxCutEDiff);
1746 
1747  printf(" \n") ;
1748 }
1749 
1750 //_____________________________________________________________________________________________
1752 //_____________________________________________________________________________________________
1753 void AliCalorimeterUtils::RecalibrateCellAmplitude(Float_t & amp, Int_t calo, Int_t id) const
1754 {
1755  Int_t icol = -1; Int_t irow = -1; Int_t iRCU = -1;
1756  Int_t nModule = GetModuleNumberCellIndexes(id,calo, icol, irow, iRCU);
1757 
1758  if (IsRecalibrationOn())
1759  {
1760  if(calo == AliFiducialCut::kPHOS)
1761  {
1762  amp *= GetPHOSChannelRecalibrationFactor(nModule,icol,irow);
1763  }
1764  else
1765  {
1766  amp *= GetEMCALChannelRecalibrationFactor(nModule,icol,irow);
1767  }
1768  }
1769 }
1770 
1771 //____________________________________________________________________________________________________
1773 //____________________________________________________________________________________________________
1774 void AliCalorimeterUtils::RecalibrateCellTime(Double_t & time, Int_t calo, Int_t id, Int_t bc) const
1775 {
1777  {
1778  GetEMCALRecoUtils()->RecalibrateCellTime(id,bc,time);
1779  }
1780 }
1781 
1782 
1783 //____________________________________________________________________________________________________
1785 //____________________________________________________________________________________________________
1786 void AliCalorimeterUtils::RecalibrateCellTimeL1Phase(Double_t & time, Int_t calo, Int_t iSM, Int_t bunchCrossNumber) const
1787 {
1789  {
1790  GetEMCALRecoUtils()->RecalibrateCellTimeL1Phase(iSM, bunchCrossNumber, time);
1791  }
1792 }
1793 
1794 
1795 //__________________________________________________________________________
1797 //__________________________________________________________________________
1798 Float_t AliCalorimeterUtils::RecalibrateClusterEnergy(AliVCluster * cluster,
1799  AliVCaloCells * cells)
1800 {
1801  // Initialize some used variables
1802  Float_t frac = 0., energy = 0.;
1803 
1804  if(cells)
1805  {
1806  //Get the cluster number of cells and list of absId, check what kind of cluster do we have.
1807 
1808  UShort_t * index = cluster->GetCellsAbsId() ;
1809  Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1810 
1811  Int_t ncells = cluster->GetNCells();
1812 
1813  Int_t calo = AliFiducialCut::kEMCAL;
1814  if(cluster->IsPHOS()) calo = AliFiducialCut::kPHOS ;
1815 
1816  // Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
1817  for(Int_t icell = 0; icell < ncells; icell++)
1818  {
1819  Int_t absId = index[icell];
1820 
1821  frac = fraction[icell];
1822  if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
1823 
1824  Float_t amp = cells->GetCellAmplitude(absId);
1825  RecalibrateCellAmplitude(amp,calo, absId);
1826 
1827  AliDebug(2,Form("Recalibrate cell: calo <%d>, cell fraction %f, cell energy: before cal %f; after cal %f",
1828  calo,frac,cells->GetCellAmplitude(absId),amp));
1829 
1830  energy += amp*frac;
1831  }
1832 
1833  AliDebug(1,Form("Energy before %f, after %f",cluster->E(),energy));
1834 
1835  } // cells available
1836  else
1837  {
1838  AliFatal("Cells pointer does not exist!");
1839  }
1840 
1841  return energy;
1842 }
1843 
1844 //_______________________________________________________________________________________________________
1847 //_______________________________________________________________________________________________________
1849  AliVCaloCells * cells, Float_t energyOrg)
1850 {
1851  //Initialize some used variables
1852  Float_t frac = 0., energy = 0.;
1853 
1854  if(cells)
1855  {
1856  // Get the cluster number of cells and list of absId, check what kind of cluster do we have.
1857 
1858  UShort_t * index = cluster->GetCellsAbsId() ;
1859  Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1860 
1861  Int_t ncells = cluster->GetNCells();
1862 
1863  Int_t calo = AliFiducialCut::kEMCAL;
1864  if(cluster->IsPHOS()) calo = AliFiducialCut::kPHOS ;
1865 
1866  // Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
1867  for(Int_t icell = 0; icell < ncells; icell++)
1868  {
1869  Int_t absId = index[icell];
1870 
1871  frac = fraction[icell];
1872  if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
1873 
1874  Float_t amp = cells->GetCellAmplitude(absId);
1875  RecalibrateCellAmplitude(amp,calo, absId);
1876 
1877  amp*=GetMCECellClusFracCorrection(amp,energyOrg);
1878 
1879  AliDebug(2,Form("Recalibrate cell: calo <%d>, cell fraction %f, cell energy %f",
1880  calo,frac,cells->GetCellAmplitude(absId)));
1881 
1882  energy += amp*frac;
1883  }
1884 
1885  AliDebug(1,Form("Energy before %f, after %f",cluster->E(),energy));
1886  } // cells available
1887  else
1888  {
1889  AliFatal("Cells pointer does not exist!");
1890  }
1891 
1892  return energy;
1893 }
1894 
1895 //__________________________________________________________________________________________
1898 //__________________________________________________________________________________________
1899 void AliCalorimeterUtils::RecalculateClusterPosition(AliVCaloCells* cells, AliVCluster* clu)
1900 {
1901  fEMCALRecoUtils->RecalculateClusterPosition((AliEMCALGeometry*)fEMCALGeo, cells,clu);
1902 }
1903 
1904 //________________________________________________________________________________
1910 //________________________________________________________________________________
1912  TObjArray* clusterArray)
1913 {
1914  if (!fRecalculateMatching) return ;
1915 
1916  fEMCALRecoUtils->FindMatches(event,clusterArray,fEMCALGeo) ;
1917 
1918  Float_t dZ = 2000;
1919  Float_t dR = 2000;
1920 
1921  Int_t nClusters = event->GetNumberOfCaloClusters();
1922  if(clusterArray) nClusters = clusterArray->GetEntriesFast();
1923 
1924  AliVCluster * clus = 0;
1925 
1926  for (Int_t iclus = 0; iclus < nClusters ; iclus++)
1927  {
1928  if ( clusterArray ) clus = (AliVCluster*) clusterArray->At(iclus) ;
1929  else clus = event->GetCaloCluster(iclus) ;
1930 
1931  if (!clus->IsEMCAL()) continue ;
1932 
1933  //
1934  // Put track residuals in cluster
1935  //
1936  fEMCALRecoUtils->GetMatchedResiduals(clus->GetID(),dZ,dR);
1937 
1938  if ( TMath::Abs(clus->GetTrackDx()) < 500 )
1939  AliDebug(2,Form("Residuals (Old, New): z (%2.4f,%2.4f), x (%2.4f,%2.4f)\n",
1940  clus->GetTrackDz(),dZ,clus->GetTrackDx(),dR));
1941 
1942  clus->SetTrackDistance(dR,dZ);
1943 
1944  //
1945  // Remove old matches in cluster
1946  //
1947  if(clus->GetNTracksMatched() > 0)
1948  {
1949  if(!strcmp("AliESDCaloCluster",Form("%s",clus->ClassName())))
1950  {
1951  TArrayI arrayTrackMatched(0);
1952  ((AliESDCaloCluster*)clus)->AddTracksMatched(arrayTrackMatched);
1953  }
1954  else
1955  {
1956  for(Int_t iTrack = 0; iTrack < clus->GetNTracksMatched(); iTrack++)
1957  {
1958  ((AliAODCaloCluster*)clus)->RemoveTrackMatched((TObject*)((AliAODCaloCluster*)clus)->GetTrackMatched(iTrack));
1959  }
1960  }
1961  }
1962 
1963  //
1964  // Now put first track index in cluster.
1965  //
1966  Int_t trackIndex = fEMCALRecoUtils->GetMatchedTrackIndex(iclus);
1967  if ( trackIndex >= 0 )
1968  {
1969  if(!strcmp("AliESDCaloCluster",Form("%s",clus->ClassName())))
1970  {
1971  TArrayI arrayTrackMatched(1);
1972  arrayTrackMatched[0] = trackIndex;
1973  ((AliESDCaloCluster*)clus)->AddTracksMatched(arrayTrackMatched);
1974  }
1975  else
1976  {
1977  ((AliAODCaloCluster*)clus)->AddTrackMatched((TObject*)event->GetTrack(trackIndex));
1978  }
1979  }
1980 
1981  } // cluster loop
1982 }
1983 
1984 //___________________________________________________________________________
1997 //___________________________________________________________________________
1998 void AliCalorimeterUtils::SplitEnergy(Int_t absId1, Int_t absId2,
1999  AliVCluster* cluster,
2000  AliVCaloCells* cells,
2001  //Float_t & e1, Float_t & e2,
2002  AliAODCaloCluster* cluster1,
2003  AliAODCaloCluster* cluster2,
2004  Int_t nMax, Int_t eventNumber)
2005 {
2006  TH2F* hClusterMap = 0 ;
2007  TH2F* hClusterLocMax = 0 ;
2008  TH2F* hCluster1 = 0 ;
2009  TH2F* hCluster2 = 0 ;
2010 
2011  if(fPlotCluster)
2012  {
2013  hClusterMap = new TH2F("hClusterMap","Cluster Map",48,0,48,24,0,24);
2014  hClusterLocMax = new TH2F("hClusterLocMax","Cluster 2 highest local maxima",48,0,48,24,0,24);
2015  hCluster1 = new TH2F("hCluster1","Cluster 1",48,0,48,24,0,24);
2016  hCluster2 = new TH2F("hCluster2","Cluster 2",48,0,48,24,0,24);
2017  hClusterMap ->SetXTitle("column");
2018  hClusterMap ->SetYTitle("row");
2019  hClusterLocMax ->SetXTitle("column");
2020  hClusterLocMax ->SetYTitle("row");
2021  hCluster1 ->SetXTitle("column");
2022  hCluster1 ->SetYTitle("row");
2023  hCluster2 ->SetXTitle("column");
2024  hCluster2 ->SetYTitle("row");
2025  }
2026 
2028  if(cluster->IsPHOS())
2029  {
2030  calorimeter = AliFiducialCut::kPHOS;
2031  AliWarning("Not supported for PHOS yet");
2032  return;
2033  }
2034 
2035  const Int_t ncells = cluster->GetNCells();
2036  Int_t absIdList[ncells];
2037 
2038  Float_t e1 = 0, e2 = 0 ;
2039  Int_t icol = -1, irow = -1, iRCU = -1, sm = -1;
2040  Float_t eCluster = 0;
2041  Float_t minCol = 100, minRow = 100, maxCol = -1, maxRow = -1;
2042  for(Int_t iDigit = 0; iDigit < ncells; iDigit++ )
2043  {
2044  absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit];
2045 
2046  Float_t ec = cells->GetCellAmplitude(absIdList[iDigit]);
2047  RecalibrateCellAmplitude(ec,calorimeter, absIdList[iDigit]);
2048  eCluster+=ec;
2049 
2050  if(fPlotCluster)
2051  {
2052  //printf("iDigit %d, absId %d, Ecell %f\n",iDigit,absIdList[iDigit], cells->GetCellAmplitude(absIdList[iDigit]));
2053  sm = GetModuleNumberCellIndexes(absIdList[iDigit], calorimeter, icol, irow, iRCU) ;
2054  if(sm > -1 && sm < 12) // just to avoid compilation warning
2055  {
2056  if(icol > maxCol) maxCol = icol;
2057  if(icol < minCol) minCol = icol;
2058  if(irow > maxRow) maxRow = irow;
2059  if(irow < minRow) minRow = irow;
2060  hClusterMap->Fill(icol,irow,ec);
2061  }
2062  }
2063  }
2064 
2065  // Init counters and variables
2066  Int_t ncells1 = 1 ;
2067  UShort_t absIdList1[9] ;
2068  Double_t fracList1 [9] ;
2069  absIdList1[0] = absId1 ;
2070  fracList1 [0] = 1. ;
2071 
2072  Float_t ecell1 = cells->GetCellAmplitude(absId1);
2073  RecalibrateCellAmplitude(ecell1, calorimeter, absId1);
2074  e1 = ecell1;
2075 
2076  Int_t ncells2 = 1 ;
2077  UShort_t absIdList2[9] ;
2078  Double_t fracList2 [9] ;
2079  absIdList2[0] = absId2 ;
2080  fracList2 [0] = 1. ;
2081 
2082  Float_t ecell2 = cells->GetCellAmplitude(absId2);
2083  RecalibrateCellAmplitude(ecell2, calorimeter, absId2);
2084  e2 = ecell2;
2085 
2086  if(fPlotCluster)
2087  {
2088  Int_t icol1 = -1, irow1 = -1, icol2 = -1, irow2 = -1;
2089  sm = GetModuleNumberCellIndexes(absId1, calorimeter, icol1, irow1, iRCU) ;
2090  hClusterLocMax->Fill(icol1,irow1,ecell1);
2091  sm = GetModuleNumberCellIndexes(absId2, calorimeter, icol2, irow2, iRCU) ;
2092  hClusterLocMax->Fill(icol2,irow2,ecell2);
2093  }
2094 
2095  // Very rough way to share the cluster energy
2096  Float_t eRemain = (eCluster-ecell1-ecell2)/2;
2097  Float_t shareFraction1 = ecell1/eCluster+eRemain/eCluster;
2098  Float_t shareFraction2 = ecell2/eCluster+eRemain/eCluster;
2099 
2100  for(Int_t iDigit = 0; iDigit < ncells; iDigit++)
2101  {
2102  Int_t absId = absIdList[iDigit];
2103 
2104  if ( absId==absId1 || absId==absId2 || absId < 0 ) continue;
2105 
2106  Float_t ecell = cells->GetCellAmplitude(absId);
2107  RecalibrateCellAmplitude(ecell, calorimeter, absId);
2108 
2109  if(AreNeighbours(calorimeter, absId1,absId ))
2110  {
2111  absIdList1[ncells1]= absId;
2112 
2113  if(AreNeighbours(calorimeter, absId2,absId ))
2114  {
2115  fracList1[ncells1] = shareFraction1;
2116  e1 += ecell*shareFraction1;
2117  }
2118  else
2119  {
2120  fracList1[ncells1] = 1.;
2121  e1 += ecell;
2122  }
2123 
2124  ncells1++;
2125 
2126  } // neigbour to cell1
2127 
2128  if(AreNeighbours(calorimeter, absId2,absId ))
2129  {
2130  absIdList2[ncells2]= absId;
2131 
2132  if(AreNeighbours(calorimeter, absId1,absId ))
2133  {
2134  fracList2[ncells2] = shareFraction2;
2135  e2 += ecell*shareFraction2;
2136  }
2137  else
2138  {
2139  fracList2[ncells2] = 1.;
2140  e2 += ecell;
2141  }
2142 
2143  ncells2++;
2144 
2145  } // neigbour to cell2
2146  }
2147 
2148  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",
2149  nMax, eCluster,ecell1,ecell2,e1,e2,eCluster-e1-e2,ncells,ncells1,ncells2,shareFraction1,shareFraction2,shareFraction1+shareFraction2));
2150 
2151  cluster1->SetE(e1);
2152  cluster2->SetE(e2);
2153 
2154  cluster1->SetNCells(ncells1);
2155  cluster2->SetNCells(ncells2);
2156 
2157  cluster1->SetCellsAbsId(absIdList1);
2158  cluster2->SetCellsAbsId(absIdList2);
2159 
2160  cluster1->SetCellsAmplitudeFraction(fracList1);
2161  cluster2->SetCellsAmplitudeFraction(fracList2);
2162 
2163  // Correct linearity
2164  CorrectClusterEnergy(cluster1) ;
2165  CorrectClusterEnergy(cluster2) ;
2166 
2167  if(calorimeter==AliFiducialCut::kEMCAL)
2168  {
2169  GetEMCALRecoUtils()->RecalculateClusterPosition(GetEMCALGeometry(), cells, cluster1);
2170  GetEMCALRecoUtils()->RecalculateClusterPosition(GetEMCALGeometry(), cells, cluster2);
2171  }
2172 
2173  if(fPlotCluster)
2174  {
2175  //printf("Cells of cluster1: ");
2176  for(Int_t iDigit = 0; iDigit < ncells1; iDigit++ )
2177  {
2178  //printf(" %d ",absIdList1[iDigit]);
2179 
2180  sm = GetModuleNumberCellIndexes(absIdList1[iDigit], calorimeter, icol, irow, iRCU) ;
2181 
2182  Float_t ecell = cells->GetCellAmplitude(absIdList1[iDigit]);
2183  RecalibrateCellAmplitude(ecell, calorimeter, absIdList1[iDigit]);
2184 
2185  if( AreNeighbours(calorimeter, absId2,absIdList1[iDigit]) && absId1!=absIdList1[iDigit])
2186  hCluster1->Fill(icol,irow,ecell*shareFraction1);
2187  else
2188  hCluster1->Fill(icol,irow,ecell);
2189  }
2190 
2191  //printf(" \n ");
2192  //printf("Cells of cluster2: ");
2193 
2194  for(Int_t iDigit = 0; iDigit < ncells2; iDigit++ )
2195  {
2196  //printf(" %d ",absIdList2[iDigit]);
2197 
2198  sm = GetModuleNumberCellIndexes(absIdList2[iDigit], calorimeter, icol, irow, iRCU) ;
2199 
2200  Float_t ecell = cells->GetCellAmplitude(absIdList2[iDigit]);
2201  RecalibrateCellAmplitude(ecell, calorimeter, absIdList2[iDigit]);
2202 
2203  if( AreNeighbours(calorimeter, absId1,absIdList2[iDigit]) && absId2!=absIdList2[iDigit])
2204  hCluster2->Fill(icol,irow,ecell*shareFraction2);
2205  else
2206  hCluster2->Fill(icol,irow,ecell);
2207  }
2208  //printf(" \n ");
2209 
2210  gStyle->SetPadRightMargin(0.1);
2211  gStyle->SetPadLeftMargin(0.1);
2212  gStyle->SetOptStat(0);
2213  gStyle->SetOptFit(000000);
2214 
2215  if(maxCol-minCol > maxRow-minRow)
2216  {
2217  maxRow+= maxCol-minCol;
2218  }
2219  else
2220  {
2221  maxCol+= maxRow-minRow;
2222  }
2223 
2224  TCanvas * c= new TCanvas("canvas", "canvas", 4000, 4000) ;
2225  c->Divide(2,2);
2226  c->cd(1);
2227  gPad->SetGridy();
2228  gPad->SetGridx();
2229  gPad->SetLogz();
2230  hClusterMap ->SetAxisRange(minCol, maxCol,"X");
2231  hClusterMap ->SetAxisRange(minRow, maxRow,"Y");
2232  hClusterMap ->Draw("colz TEXT");
2233  c->cd(2);
2234  gPad->SetGridy();
2235  gPad->SetGridx();
2236  gPad->SetLogz();
2237  hClusterLocMax ->SetAxisRange(minCol, maxCol,"X");
2238  hClusterLocMax ->SetAxisRange(minRow, maxRow,"Y");
2239  hClusterLocMax ->Draw("colz TEXT");
2240  c->cd(3);
2241  gPad->SetGridy();
2242  gPad->SetGridx();
2243  gPad->SetLogz();
2244  hCluster1 ->SetAxisRange(minCol, maxCol,"X");
2245  hCluster1 ->SetAxisRange(minRow, maxRow,"Y");
2246  hCluster1 ->Draw("colz TEXT");
2247  c->cd(4);
2248  gPad->SetGridy();
2249  gPad->SetGridx();
2250  gPad->SetLogz();
2251  hCluster2 ->SetAxisRange(minCol, maxCol,"X");
2252  hCluster2 ->SetAxisRange(minRow, maxRow,"Y");
2253  hCluster2 ->Draw("colz TEXT");
2254 
2255  if(eCluster > 6 )c->Print(Form("clusterFigures/Event%d_E%1.0f_nMax%d_NCell1_%d_NCell2_%d.eps",
2256  eventNumber,cluster->E(),nMax,ncells1,ncells2));
2257 
2258  delete c;
2259  delete hClusterMap;
2260  delete hClusterLocMax;
2261  delete hCluster1;
2262  delete hCluster2;
2263  }
2264 }
2265 
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