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