AliPhysics  a4b41ad (a4b41ad)
 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,1); // for absIds, first is in col 1, module/tower ordering map ...
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 //________________________________________________________________________________________
927 //________________________________________________________________________________________
929  Int_t & rowDiff, Int_t & colDiff) const
930 {
931  rowDiff = -100;
932  colDiff = -100;
933 
934  if(absId1 == absId2) return kFALSE;
935 
936  // Check if in same SM, if not for sure not same TCard
937  Int_t sm1 = fEMCALGeo->GetSuperModuleNumber(absId1);
938  Int_t sm2 = fEMCALGeo->GetSuperModuleNumber(absId2);
939  if ( sm1 != sm2 ) return kFALSE ;
940 
941  // Get the column and row of each absId
942  Int_t iTower = -1, iIphi = -1, iIeta = -1;
943 
944  Int_t col1, row1;
945  fEMCALGeo->GetCellIndex(absId1,sm1,iTower,iIphi,iIeta);
946  fEMCALGeo->GetCellPhiEtaIndexInSModule(sm1,iTower,iIphi, iIeta,row1,col1);
947 
948  Int_t col2, row2;
949  fEMCALGeo->GetCellIndex(absId2,sm2,iTower,iIphi,iIeta);
950  fEMCALGeo->GetCellPhiEtaIndexInSModule(sm2,iTower,iIphi, iIeta,row2,col2);
951 
952  Int_t row0 = Int_t(row1-row1%8);
953  Int_t col0 = Int_t(col1-col1%2);
954 
955  Int_t rowDiff0 = row2-row0;
956  Int_t colDiff0 = col2-col0;
957 
958  rowDiff = row1-row2;
959  colDiff = col1-col2;
960 
961  // TCard is made by 2x8 towers
962  if ( colDiff0 >=0 && colDiff0 < 2 && rowDiff0 >=0 && rowDiff0 < 8 )
963  {
964 
965 // printf("\t absId (%d,%d), sm %d; col (%d,%d), colDiff %d; row (%d,%d),rowDiff %d\n",
966 // absId1 , absId2, sm1,
967 // col1, col2, colDiff,
968 // row1, row2, rowDiff);
969  return kTRUE ;
970  }
971  else
972  return kFALSE;
973 }
974 
975 
976 //________________________________________________________________________________________
978 //________________________________________________________________________________________
980  AliVCluster * clu,
981  Float_t & clusterFraction) const
982 {
983  if( !clu || !cells )
984  {
985  AliInfo("Cluster or cells pointer is null!");
986  return -1;
987  }
988 
989  Double_t eMax =-1.;
990  Double_t eTot = 0.;
991  Double_t eCell =-1.;
992  Float_t fraction = 1.;
993  Float_t recalFactor = 1.;
994  Int_t cellAbsId =-1 , absId =-1 ;
995  Int_t iSupMod =-1 , ieta =-1 , iphi = -1, iRCU = -1;
996 
998  if(clu->IsPHOS()) calo = AliFiducialCut::kPHOS ;
999 
1000  for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++)
1001  {
1002  cellAbsId = clu->GetCellAbsId(iDig);
1003 
1004  fraction = clu->GetCellAmplitudeFraction(iDig);
1005  if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
1006 
1007  iSupMod = GetModuleNumberCellIndexes(cellAbsId, calo, ieta, iphi, iRCU);
1008 
1009  if(IsRecalibrationOn())
1010  {
1011  if(calo == AliFiducialCut::kEMCAL)
1012  recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi);
1013  else
1014  recalFactor = GetPHOSChannelRecalibrationFactor (iSupMod,iphi,ieta);
1015  }
1016 
1017  eCell = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor;
1018 
1019  if(eCell > eMax)
1020  {
1021  eMax = eCell;
1022  absId = cellAbsId;
1023  }
1024 
1025  eTot+=eCell;
1026 
1027  }// cell loop
1028 
1029  if(eTot > 0.1)
1030  clusterFraction = (eTot-eMax)/eTot; //Do not use cluster energy in case it was corrected for non linearity.
1031  else
1032  clusterFraction =1.;
1033 
1034  return absId;
1035 }
1036 
1037 //___________________________________________________________________________________
1041 //___________________________________________________________________________________
1042 AliVTrack * AliCalorimeterUtils::GetMatchedTrack(AliVCluster* cluster,
1043  AliVEvent* event, Int_t index) const
1044 {
1045  AliVTrack *track = 0x0;
1046 
1047  //
1048  // EMCAL case only when matching is recalculated
1049  //
1050  if(cluster->IsEMCAL() && IsRecalculationOfClusterTrackMatchingOn())
1051  {
1052  Int_t trackIndex = fEMCALRecoUtils->GetMatchedTrackIndex(cluster->GetID());
1053  //printf("track index %d, cluster ID %d \n ",trackIndex,cluster->GetID());
1054 
1055  if(trackIndex < 0 )
1056  AliInfo(Form("Wrong track index %d, from recalculation", trackIndex));
1057  else
1058  track = dynamic_cast<AliVTrack*> (event->GetTrack(trackIndex));
1059 
1060  return track ;
1061  }
1062 
1063  //
1064  // Normal case, get info from ESD or AOD
1065  //
1066 
1067  // No tracks matched
1068  if( cluster->GetNTracksMatched() < 1 ) return 0x0;
1069 
1070  // At least one match
1071  Int_t iTrack = 0; // only one match for AODs with index 0.
1072 
1073  // ESDs
1074  if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName())))
1075  {
1076  if( index >= 0 ) iTrack = index;
1077  else iTrack = ((AliESDCaloCluster*)cluster)->GetTracksMatched()->At(0); //cluster->GetTrackMatchedIndex();
1078 
1079  track = dynamic_cast<AliVTrack*> ( event->GetTrack(iTrack) );
1080  }
1081  else // AODs
1082  {
1083  if( index > 0 ) iTrack = index;
1084 
1085  track = dynamic_cast<AliVTrack*>( cluster->GetTrackMatched(iTrack) );
1086  }
1087 
1088  return track ;
1089 }
1090 
1096 {
1097  if( eCluster <= 0 || eCluster < eCell )
1098  {
1099  AliWarning(Form("Bad values eCell=%f, eCluster %f",eCell,eCluster));
1100  return 1;
1101  }
1102 
1103  Float_t frac = eCell / eCluster;
1104 
1105  Float_t correction = fMCECellClusFracCorrParam[0] +
1106  TMath::Exp( frac*fMCECellClusFracCorrParam[2]+fMCECellClusFracCorrParam[1] ) +
1107  fMCECellClusFracCorrParam[3]/TMath::Sqrt(frac);
1108 
1109 // printf("AliCalorimeterUtils::GetMCECellClusFracCorrection(eCell=%f, eCluster %f, frac %f) = %f\n",eCell, eCluster, frac, correction);
1110 // printf("\t %2.2f + TMath::Exp( %2.3f*%2.2f + %2.2f ) + %2.2f/TMath::Sqrt(%2.3f)) = %f\n",
1111 // fMCECellClusFracCorrParam[0],frac,fMCECellClusFracCorrParam[2],fMCECellClusFracCorrParam[1],fMCECellClusFracCorrParam[3], frac, correction);
1112 
1113  return correction;
1114 }
1115 
1116 //_____________________________________________________________________________________________________
1118 //_____________________________________________________________________________________________________
1119 Int_t AliCalorimeterUtils::GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent * inputEvent) const
1120 {
1121  Int_t absId = -1;
1122 
1123  if(particle->GetDetectorTag()==AliFiducialCut::kEMCAL)
1124  {
1125  fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
1126 
1127  AliDebug(2,Form("EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d",
1128  particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId)));
1129 
1130  return fEMCALGeo->GetSuperModuleNumber(absId) ;
1131  } // EMCAL
1132  else if ( particle->GetDetectorTag() == AliFiducialCut::kPHOS )
1133  {
1134  // In case we use the MC reader, the input are TParticles,
1135  // in this case use the corresponing method in PHOS Geometry to get the particle.
1136  if(strcmp(inputEvent->ClassName(), "AliMCEvent") == 0 )
1137  {
1138  Int_t mod =-1;
1139  Double_t z = 0., x=0.;
1140  TParticle* primary = 0x0;
1141  AliStack * stack = ((AliMCEvent*)inputEvent)->Stack();
1142 
1143  if(stack)
1144  {
1145  primary = stack->Particle(particle->GetCaloLabel(0));
1146  }
1147  else
1148  {
1149  AliFatal("Stack not available, stop!");
1150  }
1151 
1152  if(primary)
1153  {
1154  fPHOSGeo->ImpactOnEmc(primary,mod,z,x) ;
1155  }
1156  else
1157  {
1158  AliFatal("Primary not available, stop!");
1159  }
1160  return mod;
1161  }
1162  // Input are ESDs or AODs, get the PHOS module number like this.
1163  else
1164  {
1165  //FIXME
1166  //AliVCluster *cluster = inputEvent->GetCaloCluster(particle->GetCaloLabel(0));
1167  //return GetModuleNumber(cluster);
1168  //MEFIX
1169  return -1;
1170  }
1171  } // PHOS
1172 
1173  return -1;
1174 }
1175 
1176 //_____________________________________________________________________
1178 //_____________________________________________________________________
1179 Int_t AliCalorimeterUtils::GetModuleNumber(AliVCluster * cluster) const
1180 {
1181  if(!cluster)
1182  {
1183  AliDebug(1,"AliCalorimeterUtils::GetModuleNumber() - NUL Cluster, please check!!!");
1184 
1185  return -1;
1186  }
1187 
1188  if ( cluster->GetNCells() <= 0 ) return -1;
1189 
1190  Int_t absId = cluster->GetCellAbsId(0);
1191 
1192  if ( absId < 0 ) return -1;
1193 
1194  if( cluster->IsEMCAL() )
1195  {
1196  AliDebug(2,Form("EMCAL absid %d, SuperModule %d",absId, fEMCALGeo->GetSuperModuleNumber(absId)));
1197 
1198  return fEMCALGeo->GetSuperModuleNumber(absId) ;
1199  } // EMCAL
1200  else if ( cluster->IsPHOS() )
1201  {
1202  Int_t relId[4];
1203  fPHOSGeo->AbsToRelNumbering(absId,relId);
1204 
1205  if (relId[1] != 0 ) return -1; // skip CPV only PHOS
1206 
1207  AliDebug(2,Form("PHOS absid %d Module %d",absId, relId[0]-1));
1208 
1209  return relId[0]-1;
1210  } // PHOS
1211 
1212  return -1;
1213 }
1214 
1215 //___________________________________________________________________________________________________
1217 //___________________________________________________________________________________________________
1219  Int_t & icol, Int_t & irow, Int_t & iRCU) const
1220 {
1221  Int_t imod = -1;
1222 
1223  if ( absId < 0 ) return -1 ;
1224 
1225  if ( calo == AliFiducialCut::kEMCAL )
1226  {
1227  Int_t iTower = -1, iIphi = -1, iIeta = -1;
1228  fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
1229  fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
1230 
1231  if(imod < 0 || irow < 0 || icol < 0 )
1232  {
1233  AliFatal(Form("Negative value for super module: %d, or cell icol: %d, or cell irow: %d, check EMCAL geometry name",imod,icol,irow));
1234  }
1235 
1236  // In case of DCal C side, shift columns to match offline/online numbering
1237  // when calculating the DDL for Run2
1238  // See AliEMCALRawUtils::Digits2Raw and Raw2Digits.
1239  Int_t ico2 = icol ;
1240  if ( imod == 13 || imod == 15 || imod == 17 ) ico2 += 16;
1241 
1242  // RCU / DDL
1243  if(imod < 10 || (imod > 11 && imod < 18)) // (EMCAL Full || DCAL 2/3)
1244  {
1245  // RCU0 / DDL0
1246  if ( 0 <= irow && irow < 8 ) iRCU = 0; // first cable row
1247  else if ( 8 <= irow && irow < 16 &&
1248  0 <= ico2 && ico2 < 24 ) iRCU = 0; // first half;
1249  //second cable row
1250 
1251  // RCU1 / DDL1
1252  else if ( 8 <= irow && irow < 16 &&
1253  24 <= ico2 && ico2 < 48 ) iRCU = 1; // second half;
1254  //second cable row
1255  else if ( 16 <= irow && irow < 24 ) iRCU = 1; // third cable row
1256 
1257  if ( imod%2 == 1 ) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
1258  }
1259  else
1260  {
1261  // 1/3 SM have one single SRU, just assign RCU/DDL 0
1262  iRCU = 0 ;
1263  }
1264 
1265  if ( iRCU < 0 )
1266  AliFatal(Form("Wrong EMCAL RCU number = %d", iRCU));
1267 
1268  return imod ;
1269  } // EMCAL
1270  else // PHOS
1271  {
1272  Int_t relId[4];
1273  fPHOSGeo->AbsToRelNumbering(absId,relId);
1274 
1275  if (relId[1] != 0 ) return -1; // skip CPV only PHOS
1276 
1277  irow = relId[2];
1278  icol = relId[3];
1279  imod = relId[0]-1;
1280  iRCU= (Int_t)(relId[2]-1)/16 ;
1281 
1282  //Int_t iBranch= (Int_t)(relid[3]-1)/28 ; //0 to 1
1283 
1284  if ( iRCU >= 4 )
1285  AliFatal(Form("Wrong PHOS RCU number = %d", iRCU));
1286 
1287  return imod;
1288  } // PHOS
1289 
1290  return -1;
1291 }
1292 
1293 //___________________________________________________________________________________________________
1296 //___________________________________________________________________________________________________
1298  Int_t & icol , Int_t & irow , Int_t & iRCU,
1299  Int_t & icolAbs, Int_t & irowAbs) const
1300 {
1301  Int_t imod = GetModuleNumberCellIndexes(absId, calo, icol, irow,iRCU);
1302 
1303  icolAbs = icol;
1304  irowAbs = irow;
1305 
1306  //
1307  // PHOS
1308  //
1309  if(calo == AliFiducialCut::kPHOS)
1310  {
1311  irowAbs = irow + 64 * imod;
1312 
1313  return imod;
1314  }
1315  //
1316  // EMCal/DCal
1317  //
1318  else
1319  {
1320  //
1321  // Shift collumns in even SM
1322  Int_t shiftEta = 48;
1323 
1324  // Shift collumn even more due to smaller acceptance of DCal collumns
1325  if ( imod > 11 && imod < 18) shiftEta+=48/3;
1326 
1327  icolAbs = (imod % 2) ? icol + shiftEta : icol;
1328 
1329  //
1330  // Shift rows per sector
1331  irowAbs = irow + 24 * Int_t(imod / 2);
1332 
1333  // Shift row less due to smaller acceptance of SM 10 and 11 to count DCal rows
1334  if ( imod > 11 && imod < 20) irowAbs -= (2*24 / 3);
1335 
1336  return imod ;
1337  }
1338 }
1339 
1340 
1341 //___________________________________________________________________________________________
1343 //___________________________________________________________________________________________
1344 Int_t AliCalorimeterUtils::GetNumberOfLocalMaxima(AliVCluster* cluster, AliVCaloCells* cells)
1345 {
1346  const Int_t nc = cluster->GetNCells();
1347 
1348  Int_t absIdList[nc];
1349  Float_t maxEList[nc];
1350 
1351  Int_t nMax = GetNumberOfLocalMaxima(cluster, cells, absIdList, maxEList);
1352 
1353  return nMax;
1354 }
1355 
1356 //___________________________________________________________________________________________
1358 //___________________________________________________________________________________________
1359 Int_t AliCalorimeterUtils::GetNumberOfLocalMaxima(AliVCluster* cluster, AliVCaloCells* cells,
1360  Int_t *absIdList, Float_t *maxEList)
1361 {
1362  Int_t iDigitN = 0 ;
1363  Int_t iDigit = 0 ;
1364  Int_t absId1 = -1 ;
1365  Int_t absId2 = -1 ;
1366  const Int_t nCells = cluster->GetNCells();
1367 
1368  Float_t eCluster = RecalibrateClusterEnergy(cluster, cells);// recalculate cluster energy, avoid non lin correction.
1369 
1370  Float_t simuTotWeight = 0;
1372  {
1373  simuTotWeight = RecalibrateClusterEnergyWeightCell(cluster, cells,eCluster);// same but apply a weight
1374  simuTotWeight/= eCluster;
1375  }
1376 
1378  if(!cluster->IsEMCAL()) calorimeter = AliFiducialCut::kPHOS;
1379 
1380  //printf("cluster : ncells %d \n",nCells);
1381 
1382  Float_t emax = 0;
1383  Int_t idmax =-1;
1384  for(iDigit = 0; iDigit < nCells ; iDigit++)
1385  {
1386  absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit] ;
1387  Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1388  RecalibrateCellAmplitude(en,calorimeter,absIdList[iDigit]);
1389 
1391  en*=GetMCECellClusFracCorrection(en,eCluster)/simuTotWeight;
1392 
1393  if( en > emax )
1394  {
1395  emax = en ;
1396  idmax = absIdList[iDigit] ;
1397  }
1398  //Int_t icol = -1, irow = -1, iRCU = -1;
1399  //Int_t sm = GetModuleNumberCellIndexes(absIdList[iDigit], calorimeter, icol, irow, iRCU) ;
1400  //printf("\t cell %d, id %d, sm %d, col %d, row %d, e %f\n", iDigit, absIdList[iDigit], sm, icol, irow, en );
1401  }
1402 
1403  for(iDigit = 0 ; iDigit < nCells; iDigit++)
1404  {
1405  if( absIdList[iDigit] >= 0 )
1406  {
1407  absId1 = cluster->GetCellsAbsId()[iDigit];
1408 
1409  Float_t en1 = cells->GetCellAmplitude(absId1);
1410  RecalibrateCellAmplitude(en1,calorimeter,absId1);
1411 
1413  en1*=GetMCECellClusFracCorrection(en1,eCluster)/simuTotWeight;
1414 
1415  //printf("%d : absIDi %d, E %f\n",iDigit, absId1,en1);
1416 
1417  for(iDigitN = 0; iDigitN < nCells; iDigitN++)
1418  {
1419  absId2 = cluster->GetCellsAbsId()[iDigitN] ;
1420 
1421  if(absId2==-1 || absId2==absId1) continue;
1422 
1423  //printf("\t %d : absIDj %d\n",iDigitN, absId2);
1424 
1425  Float_t en2 = cells->GetCellAmplitude(absId2);
1426  RecalibrateCellAmplitude(en2,calorimeter,absId2);
1427 
1429  en2*=GetMCECellClusFracCorrection(en2,eCluster)/simuTotWeight;
1430 
1431  //printf("\t %d : absIDj %d, E %f\n",iDigitN, absId2,en2);
1432 
1433  if ( AreNeighbours(calorimeter, absId1, absId2) )
1434  {
1435  // printf("\t \t Neighbours \n");
1436  if ( en1 > en2 )
1437  {
1438  absIdList[iDigitN] = -1 ;
1439  //printf("\t \t indexN %d not local max\n",iDigitN);
1440  // but may be digit too is not local max ?
1441  if(en1 < en2 + fLocMaxCutEDiff) {
1442  //printf("\t \t index %d not local max cause locMaxCutEDiff\n",iDigit);
1443  absIdList[iDigit] = -1 ;
1444  }
1445  }
1446  else
1447  {
1448  absIdList[iDigit] = -1 ;
1449  //printf("\t \t index %d not local max\n",iDigitN);
1450  // but may be digitN too is not local max ?
1451  if(en1 > en2 - fLocMaxCutEDiff)
1452  {
1453  absIdList[iDigitN] = -1 ;
1454  //printf("\t \t indexN %d not local max cause locMaxCutEDiff\n",iDigit);
1455  }
1456  }
1457  } // if Are neighbours
1458  //else printf("\t \t NOT Neighbours \n");
1459  } // while digitN
1460  } // slot not empty
1461  } // while digit
1462 
1463  iDigitN = 0 ;
1464  for(iDigit = 0; iDigit < nCells; iDigit++)
1465  {
1466  if( absIdList[iDigit] >= 0 )
1467  {
1468  absIdList[iDigitN] = absIdList[iDigit] ;
1469 
1470  Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1471  RecalibrateCellAmplitude(en,calorimeter,absIdList[iDigit]);
1472 
1474  en*=GetMCECellClusFracCorrection(en,eCluster)/simuTotWeight;
1475 
1476  if(en < fLocMaxCutE) continue; // Maxima only with seed energy at least
1477 
1478  maxEList[iDigitN] = en ;
1479 
1480  //printf("Local max %d, id %d, en %f\n", iDigit,absIdList[iDigitN],en);
1481  iDigitN++ ;
1482  }
1483  }
1484 
1485  if ( iDigitN == 0 )
1486  {
1487  AliDebug(1,Form("No local maxima found, assign highest energy cell as maxima, id %d, en cell %2.2f, en cluster %2.2f",
1488  idmax,emax,cluster->E()));
1489  iDigitN = 1 ;
1490  maxEList[0] = emax ;
1491  absIdList[0] = idmax ;
1492  }
1493 
1494 
1495  AliDebug(1,Form("In cluster E %2.2f (wth non lin. %2.2f), M02 %2.2f, M20 %2.2f, N maxima %d",
1496  cluster->E(),eCluster, cluster->GetM02(),cluster->GetM20(), iDigitN));
1497 
1498 // if(fDebug > 1) for(Int_t imax = 0; imax < iDigitN; imax++)
1499 // {
1500 // printf(" \t i %d, absId %d, Ecell %f\n",imax,absIdList[imax],maxEList[imax]);
1501 // }
1502 
1503  return iDigitN ;
1504 }
1505 
1506 //____________________________________
1508 //____________________________________
1510 {
1511  if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1512  {
1513  AliError("AliCalorimeterUtils::GetPass() - Pointer to tree = 0, returning null");
1514  return TString("");
1515  }
1516 
1517  if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1518  {
1519  AliError("AliCalorimeterUtils::GetPass() - Null pointer input file, returning null");
1520  return TString("");
1521  }
1522 
1523  TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1524  if (pass.Contains("ass1")) return TString("pass1");
1525  else if (pass.Contains("ass2")) return TString("pass2");
1526  else if (pass.Contains("ass3")) return TString("pass3");
1527  else if (pass.Contains("ass4")) return TString("pass4");
1528  else if (pass.Contains("ass5")) return TString("pass5");
1529  else if (pass.Contains("LHC11c") && pass.Contains("spc_calo") ) return TString("spc_calo");
1530  else if (pass.Contains("calo") || pass.Contains("high_lumi"))
1531  {
1532  AliInfo("Path contains <calo> or <high-lumi>, set as <pass1>");
1533  return TString("pass1");
1534  }
1535  else if (pass.Contains("LHC14a1a"))
1536  {
1537  AliInfo("Check that Energy calibration was enabled for this MC production in the tender, clusterizer or here!!");
1538 
1539  return TString("LHC14a1a");
1540  }
1541 
1542  // No condition fullfilled, give a default value
1543  AliInfo("Pass number string not found");
1544  return TString("");
1545 }
1546 
1547 //________________________________________
1549 //________________________________________
1551 {
1552  fEMCALGeoName = "";
1553  fPHOSGeoName = "";
1554 
1555  fEMCALGeoMatrixSet = kFALSE;
1556  fPHOSGeoMatrixSet = kFALSE;
1557 
1558  fRemoveBadChannels = kFALSE;
1559 
1561 
1562  fLocMaxCutE = 0.1 ;
1563  fLocMaxCutEDiff = 0.0 ;
1564 
1565  // fMaskCellColumns = new Int_t[fNMaskCellColumns];
1566  // fMaskCellColumns[0] = 6 ; fMaskCellColumns[1] = 7 ; fMaskCellColumns[2] = 8 ;
1567  // fMaskCellColumns[3] = 35; fMaskCellColumns[4] = 36; fMaskCellColumns[5] = 37;
1568  // fMaskCellColumns[6] = 12+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[7] = 13+AliEMCALGeoParams::fgkEMCALCols;
1569  // fMaskCellColumns[8] = 40+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[9] = 41+AliEMCALGeoParams::fgkEMCALCols;
1570  // fMaskCellColumns[10]= 42+AliEMCALGeoParams::fgkEMCALCols;
1571 
1572  fOADBSet = kFALSE;
1573  fOADBForEMCAL = kTRUE ;
1574  fOADBForPHOS = kFALSE;
1575 
1576  fOADBFilePathEMCAL = "$ALICE_PHYSICS/OADB/EMCAL" ;
1577  fOADBFilePathPHOS = "$ALICE_PHYSICS/OADB/PHOS" ;
1578 
1579  fImportGeometryFromFile = kTRUE;
1581 
1582  fNSuperModulesUsed = 22;
1583 
1584  fMCECellClusFracCorrParam[0] = 0.78;
1585  fMCECellClusFracCorrParam[1] =-1.8;
1586  fMCECellClusFracCorrParam[2] =-6.3;
1587  fMCECellClusFracCorrParam[3] = 0.014;
1588 }
1589 
1590 //_____________________________________________________
1592 //_____________________________________________________
1594 {
1595  AliDebug(1,"Init bad channel map");
1596 
1597  // In order to avoid rewriting the same histograms
1598  Bool_t oldStatus = TH1::AddDirectoryStatus();
1599  TH1::AddDirectory(kFALSE);
1600 
1601  fPHOSBadChannelMap = new TObjArray(5);
1602  for (int i = 0; i < 5; i++)fPHOSBadChannelMap->Add(new TH2I(Form("PHOS_BadMap_mod%d",i),
1603  Form("PHOS_BadMap_mod%d",i),
1604  64, 0, 64, 56, 0, 56));
1605 
1606  fPHOSBadChannelMap->SetOwner(kTRUE);
1607  fPHOSBadChannelMap->Compress();
1608 
1609  //In order to avoid rewriting the same histograms
1610  TH1::AddDirectory(oldStatus);
1611 }
1612 
1613 //______________________________________________________
1615 //______________________________________________________
1617 {
1618  AliDebug(1,"Init recalibration map");
1619 
1620  // In order to avoid rewriting the same histograms
1621  Bool_t oldStatus = TH1::AddDirectoryStatus();
1622  TH1::AddDirectory(kFALSE);
1623 
1625  for (int i = 0; i < 5; i++)
1626  {
1627  fPHOSRecalibrationFactors->Add(new TH2F(Form("PHOSRecalFactors_Mod%d",i),
1628  Form("PHOSRecalFactors_Mod%d",i),
1629  64, 0, 64, 56, 0, 56));
1630  }
1631 
1632  // Init the histograms with 1
1633  for (Int_t m = 0; m < 5; m++)
1634  {
1635  for (Int_t i = 0; i < 56; i++)
1636  {
1637  for (Int_t j = 0; j < 64; j++)
1638  {
1640  }
1641  }
1642  }
1643 
1644  fPHOSRecalibrationFactors->SetOwner(kTRUE);
1645  fPHOSRecalibrationFactors->Compress();
1646 
1647  // In order to avoid rewriting the same histograms
1648  TH1::AddDirectory(oldStatus);
1649 }
1650 
1655 {
1656  if (fEMCALGeo) return;
1657 
1658  AliDebug(1,Form(" for run=%d",fRunNumber));
1659 
1660  if(fEMCALGeoName=="")
1661  {
1662  fEMCALGeo = AliEMCALGeometry::GetInstanceFromRunNumber(fRunNumber);
1663  AliInfo(Form("Get EMCAL geometry name to <%s> for run %d",fEMCALGeo->GetName(),fRunNumber));
1664  }
1665  else
1666  {
1667  fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName);
1668  AliInfo(Form("Set EMCAL geometry name to <%s>",fEMCALGeoName.Data()));
1669  }
1670 
1671  // Init geometry, I do not like much to do it like this ...
1672  if(fImportGeometryFromFile && !gGeoManager)
1673  {
1674  if(fImportGeometryFilePath=="") // If not specified, set location depending on run number
1675  {
1676  // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
1677  if (fRunNumber < 140000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2010.root";
1678  else if(fRunNumber < 171000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2011.root";
1679  else if(fRunNumber < 198000) fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2012.root"; // 2012-2013
1680  else fImportGeometryFilePath = "$ALICE_PHYSICS/OADB/EMCAL/geometry_2015.root"; // >= 2015
1681  }
1682 
1683  AliInfo(Form("Import %s",fImportGeometryFilePath.Data()));
1684 
1685  TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
1686  }
1687  else if (!gGeoManager) AliInfo("Careful!, gGeoManager not loaded, load misalign matrices");
1688 }
1689 
1694 {
1695  if (fPHOSGeo) return;
1696 
1697  AliDebug(1,Form(" for run=%d",fRunNumber));
1698 
1699  if(fPHOSGeoName=="") fPHOSGeoName = "PHOSgeo";
1700 
1701  fPHOSGeo = new AliPHOSGeoUtils(fPHOSGeoName);
1702 
1703  //if (!gGeoManager) AliInfo("Careful!, gGeoManager not loaded, load misalign matrices");
1704 }
1705 
1706 //______________________________________________________________________________________________
1707 // Check that a MC ESD is in the calorimeter acceptance
1708 //______________________________________________________________________________________________
1710 {
1711  if(!particle || (calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS)) return kFALSE ;
1712 
1713  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1715  {
1716  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1717  return kFALSE ;
1718  }
1719 
1720  if(calo == AliFiducialCut::kPHOS )
1721  {
1722  Int_t mod = 0 ;
1723  Double_t x = 0, z = 0 ;
1724  return GetPHOSGeometry()->ImpactOnEmc( particle, mod, z, x);
1725  }
1726  else if(calo == AliFiducialCut::kEMCAL)
1727  {
1728  Int_t absID = 0 ;
1729  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(),absID);
1730  if(ok)
1731  {
1732  Int_t icol = -1, irow = -1, iRCU = -1;
1733  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1734  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1735  if(status > 0) ok = kFALSE;
1736  }
1737 
1738  return ok ;
1739  }
1740 
1741  return kFALSE ;
1742 }
1743 
1744 //______________________________________________________________________________________________________
1746 //______________________________________________________________________________________________________
1748 {
1749  if(!particle || (calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS)) return kFALSE ;
1750 
1751  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1753  {
1754  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1755  return kFALSE ;
1756  }
1757 
1758  Float_t phi = particle->Phi();
1759  if(phi < 0) phi+=TMath::TwoPi();
1760 
1761  if(calo == AliFiducialCut::kPHOS )
1762  {
1763  Int_t mod = 0 ;
1764  Double_t x = 0, z = 0 ;
1765  Double_t vtx[]={ particle->Xv(), particle->Yv(), particle->Zv() } ;
1766  return GetPHOSGeometry()->ImpactOnEmc(vtx, particle->Theta(), phi, mod, z, x) ;
1767  }
1768  else if(calo == AliFiducialCut::kEMCAL)
1769  {
1770  Int_t absID = 0 ;
1771  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),phi,absID);
1772  if(ok)
1773  {
1774  Int_t icol = -1, irow = -1, iRCU = -1;
1775  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1776  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1777  if(status > 0) ok = kFALSE;
1778  }
1779 
1780  return ok ;
1781  }
1782 
1783  return kFALSE ;
1784 }
1785 
1786 //_____________________________________________________________________________________________________
1787 // Check that a TLorentzVector is in the calorimeter acceptance, give the cell number where it hit.
1788 //_____________________________________________________________________________________________________
1790  Float_t phiOrg, Int_t & absID)
1791 {
1792  if(calo!=AliFiducialCut::kEMCAL && calo!=AliFiducialCut::kPHOS) return kFALSE ;
1793 
1794  if( (!IsPHOSGeoMatrixSet () && calo == AliFiducialCut::kPHOS ) ||
1796  {
1797  AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1798  return kFALSE ;
1799  }
1800 
1801  Float_t phi = phiOrg;
1802  if(phi < 0) phi+=TMath::TwoPi();
1803 
1804  if(calo == AliFiducialCut::kPHOS )
1805  {
1806  Int_t mod = 0 ;
1807  Double_t x = 0, z = 0 ;
1808  Double_t vtx[]={0,0,0} ;
1809  return GetPHOSGeometry()->ImpactOnEmc(vtx, theta, phi, mod, z, x) ;
1810  }
1811  else if(calo == AliFiducialCut::kEMCAL)
1812  {
1813  Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(eta,phi,absID);
1814  if(ok)
1815  {
1816  Int_t icol = -1, irow = -1, iRCU = -1;
1817  Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU);
1818  Int_t status = GetEMCALChannelStatus(nModule,icol,irow);
1819  if(status > 0) ok = kFALSE;
1820  }
1821 
1822  return ok ;
1823  }
1824 
1825  return kFALSE ;
1826 }
1827 
1828 //_______________________________________________________________________
1831 //_______________________________________________________________________
1833 {
1834  Int_t icol = ieta;
1835  if ( iSM%2 ) icol+=48; // Impair SM, shift index [0-47] to [48-96]
1836 
1838  {
1839  for (Int_t imask = 0; imask < fNMaskCellColumns; imask++)
1840  {
1841  if(icol==fMaskCellColumns[imask]) return kTRUE;
1842  }
1843  }
1844 
1845  return kFALSE;
1846 }
1847 
1848 //_________________________________________________________
1850 //_________________________________________________________
1851 void AliCalorimeterUtils::Print(const Option_t * opt) const
1852 {
1853  if(! opt)
1854  return;
1855 
1856  printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
1857  printf("Remove Clusters with bad channels? %d\n",fRemoveBadChannels);
1858  printf("Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
1859  fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(), fNCellsFromPHOSBorder);
1860  if(fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) printf("Do not remove EMCAL clusters at Eta = 0\n");
1861  printf("Recalibrate Clusters? %d, run by run %d\n",fRecalibration,fRunDependentCorrection);
1862  printf("Recalculate Clusters Position? %d\n",fRecalculatePosition);
1863  printf("Recalculate Clusters Energy? %d\n",fCorrectELinearity);
1864  printf("Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",fCutR,fCutZ);
1865 
1866  printf("Recalibrate time? %d, With L1 phase run by run? %d\n",IsTimeRecalibrationOn(),IsL1PhaseInTimeRecalibrationOn());
1867 
1868  printf("Loc. Max. E > %2.2f\n", fLocMaxCutE);
1869  printf("Loc. Max. E Diff > %2.2f\n", fLocMaxCutEDiff);
1870 
1871  printf(" \n") ;
1872 }
1873 
1874 //_____________________________________________________________________________________________
1876 //_____________________________________________________________________________________________
1878 {
1879  Int_t icol = -1; Int_t irow = -1; Int_t iRCU = -1;
1880  Int_t nModule = GetModuleNumberCellIndexes(id,calo, icol, irow, iRCU);
1881 
1882  if (IsRecalibrationOn())
1883  {
1884  if(calo == AliFiducialCut::kPHOS)
1885  {
1886  amp *= GetPHOSChannelRecalibrationFactor(nModule,icol,irow);
1887  }
1888  else
1889  {
1890  amp *= GetEMCALChannelRecalibrationFactor(nModule,icol,irow);
1891  }
1892  }
1893 }
1894 
1895 //____________________________________________________________________________________________________
1897 //____________________________________________________________________________________________________
1899 {
1901  {
1902  GetEMCALRecoUtils()->RecalibrateCellTime(id,bc,time);
1903  }
1904 }
1905 
1906 
1907 //____________________________________________________________________________________________________
1909 //____________________________________________________________________________________________________
1910 void AliCalorimeterUtils::RecalibrateCellTimeL1Phase(Double_t & time, Int_t calo, Int_t iSM, Int_t bunchCrossNumber) const
1911 {
1913  {
1914  GetEMCALRecoUtils()->RecalibrateCellTimeL1Phase(iSM, bunchCrossNumber, time);
1915  }
1916 }
1917 
1918 
1919 //__________________________________________________________________________
1921 //__________________________________________________________________________
1923  AliVCaloCells * cells)
1924 {
1925  // Initialize some used variables
1926  Float_t frac = 0., energy = 0.;
1927 
1928  if(cells)
1929  {
1930  //Get the cluster number of cells and list of absId, check what kind of cluster do we have.
1931 
1932  UShort_t * index = cluster->GetCellsAbsId() ;
1933  Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1934 
1935  Int_t ncells = cluster->GetNCells();
1936 
1938  if(cluster->IsPHOS()) calo = AliFiducialCut::kPHOS ;
1939 
1940  // Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
1941  for(Int_t icell = 0; icell < ncells; icell++)
1942  {
1943  Int_t absId = index[icell];
1944 
1945  frac = fraction[icell];
1946  if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
1947 
1948  Float_t amp = cells->GetCellAmplitude(absId);
1949  RecalibrateCellAmplitude(amp,calo, absId);
1950 
1951  AliDebug(2,Form("Recalibrate cell: calo <%d>, cell fraction %f, cell energy: before cal %f; after cal %f",
1952  calo,frac,cells->GetCellAmplitude(absId),amp));
1953 
1954  energy += amp*frac;
1955  }
1956 
1957  AliDebug(1,Form("Energy before %f, after %f",cluster->E(),energy));
1958 
1959  } // cells available
1960  else
1961  {
1962  AliFatal("Cells pointer does not exist!");
1963  }
1964 
1965  return energy;
1966 }
1967 
1968 //_______________________________________________________________________________________________________
1971 //_______________________________________________________________________________________________________
1973  AliVCaloCells * cells, Float_t energyOrg)
1974 {
1975  //Initialize some used variables
1976  Float_t frac = 0., energy = 0.;
1977 
1978  if(cells)
1979  {
1980  // Get the cluster number of cells and list of absId, check what kind of cluster do we have.
1981 
1982  UShort_t * index = cluster->GetCellsAbsId() ;
1983  Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1984 
1985  Int_t ncells = cluster->GetNCells();
1986 
1988  if(cluster->IsPHOS()) calo = AliFiducialCut::kPHOS ;
1989 
1990  // Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
1991  for(Int_t icell = 0; icell < ncells; icell++)
1992  {
1993  Int_t absId = index[icell];
1994 
1995  frac = fraction[icell];
1996  if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used.
1997 
1998  Float_t amp = cells->GetCellAmplitude(absId);
1999  RecalibrateCellAmplitude(amp,calo, absId);
2000 
2001  amp*=GetMCECellClusFracCorrection(amp,energyOrg);
2002 
2003  AliDebug(2,Form("Recalibrate cell: calo <%d>, cell fraction %f, cell energy %f",
2004  calo,frac,cells->GetCellAmplitude(absId)));
2005 
2006  energy += amp*frac;
2007  }
2008 
2009  AliDebug(1,Form("Energy before %f, after %f",cluster->E(),energy));
2010  } // cells available
2011  else
2012  {
2013  AliFatal("Cells pointer does not exist!");
2014  }
2015 
2016  return energy;
2017 }
2018 
2019 //__________________________________________________________________________________________
2022 //__________________________________________________________________________________________
2023 void AliCalorimeterUtils::RecalculateClusterPosition(AliVCaloCells* cells, AliVCluster* clu)
2024 {
2025  fEMCALRecoUtils->RecalculateClusterPosition((AliEMCALGeometry*)fEMCALGeo, cells,clu);
2026 }
2027 
2028 //________________________________________________________________________________
2034 //________________________________________________________________________________
2036  TObjArray* clusterArray,
2037  AliMCEvent* mc)
2038 {
2039  if (!fRecalculateMatching) return ;
2040 
2041  fEMCALRecoUtils->FindMatches(event,clusterArray,fEMCALGeo,mc) ;
2042 
2043  Float_t dZ = 2000;
2044  Float_t dR = 2000;
2045 
2046  Int_t nClusters = event->GetNumberOfCaloClusters();
2047  if(clusterArray) nClusters = clusterArray->GetEntriesFast();
2048 
2049  AliVCluster * clus = 0;
2050 
2051  for (Int_t iclus = 0; iclus < nClusters ; iclus++)
2052  {
2053  if ( clusterArray ) clus = (AliVCluster*) clusterArray->At(iclus) ;
2054  else clus = event->GetCaloCluster(iclus) ;
2055 
2056  if (!clus->IsEMCAL()) continue ;
2057 
2058  //
2059  // Put track residuals in cluster
2060  //
2061  fEMCALRecoUtils->GetMatchedResiduals(clus->GetID(),dZ,dR);
2062 
2063  if ( TMath::Abs(clus->GetTrackDx()) < 500 )
2064  AliDebug(2,Form("Residuals (Old, New): z (%2.4f,%2.4f), x (%2.4f,%2.4f)\n",
2065  clus->GetTrackDz(),dZ,clus->GetTrackDx(),dR));
2066 
2067  clus->SetTrackDistance(dR,dZ);
2068 
2069  //
2070  // Remove old matches in cluster
2071  //
2072  if(clus->GetNTracksMatched() > 0)
2073  {
2074  if(!strcmp("AliESDCaloCluster",Form("%s",clus->ClassName())))
2075  {
2076  TArrayI arrayTrackMatched(0);
2077  ((AliESDCaloCluster*)clus)->AddTracksMatched(arrayTrackMatched);
2078  }
2079  else
2080  {
2081  for(Int_t iTrack = 0; iTrack < clus->GetNTracksMatched(); iTrack++)
2082  {
2083  ((AliAODCaloCluster*)clus)->RemoveTrackMatched((TObject*)((AliAODCaloCluster*)clus)->GetTrackMatched(iTrack));
2084  }
2085  }
2086  }
2087 
2088  //
2089  // Now put first track index in cluster.
2090  //
2091  Int_t trackIndex = fEMCALRecoUtils->GetMatchedTrackIndex(iclus);
2092  if ( trackIndex >= 0 )
2093  {
2094  if(!strcmp("AliESDCaloCluster",Form("%s",clus->ClassName())))
2095  {
2096  TArrayI arrayTrackMatched(1);
2097  arrayTrackMatched[0] = trackIndex;
2098  ((AliESDCaloCluster*)clus)->AddTracksMatched(arrayTrackMatched);
2099  }
2100  else
2101  {
2102  ((AliAODCaloCluster*)clus)->AddTrackMatched((TObject*)event->GetTrack(trackIndex));
2103  }
2104  }
2105 
2106  } // cluster loop
2107 }
2108 
2109 //___________________________________________________________________________
2122 //___________________________________________________________________________
2124  AliVCluster* cluster,
2125  AliVCaloCells* cells,
2126  //Float_t & e1, Float_t & e2,
2127  AliAODCaloCluster* cluster1,
2128  AliAODCaloCluster* cluster2,
2129  Int_t nMax, Int_t eventNumber)
2130 {
2131  TH2F* hClusterMap = 0 ;
2132  TH2F* hClusterLocMax = 0 ;
2133  TH2F* hCluster1 = 0 ;
2134  TH2F* hCluster2 = 0 ;
2135 
2136  if(fPlotCluster)
2137  {
2138  hClusterMap = new TH2F("hClusterMap","Cluster Map",48,0,48,24,0,24);
2139  hClusterLocMax = new TH2F("hClusterLocMax","Cluster 2 highest local maxima",48,0,48,24,0,24);
2140  hCluster1 = new TH2F("hCluster1","Cluster 1",48,0,48,24,0,24);
2141  hCluster2 = new TH2F("hCluster2","Cluster 2",48,0,48,24,0,24);
2142  hClusterMap ->SetXTitle("column");
2143  hClusterMap ->SetYTitle("row");
2144  hClusterLocMax ->SetXTitle("column");
2145  hClusterLocMax ->SetYTitle("row");
2146  hCluster1 ->SetXTitle("column");
2147  hCluster1 ->SetYTitle("row");
2148  hCluster2 ->SetXTitle("column");
2149  hCluster2 ->SetYTitle("row");
2150  }
2151 
2153  if(cluster->IsPHOS())
2154  {
2155  calorimeter = AliFiducialCut::kPHOS;
2156  AliWarning("Not supported for PHOS yet");
2157  return;
2158  }
2159 
2160  const Int_t ncells = cluster->GetNCells();
2161  Int_t absIdList[ncells];
2162 
2163  Float_t e1 = 0, e2 = 0 ;
2164  Int_t icol = -1, irow = -1, iRCU = -1, sm = -1;
2165  Float_t eCluster = 0;
2166  Float_t minCol = 100, minRow = 100, maxCol = -1, maxRow = -1;
2167  for(Int_t iDigit = 0; iDigit < ncells; iDigit++ )
2168  {
2169  absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit];
2170 
2171  Float_t ec = cells->GetCellAmplitude(absIdList[iDigit]);
2172  RecalibrateCellAmplitude(ec,calorimeter, absIdList[iDigit]);
2173  eCluster+=ec;
2174 
2175  if(fPlotCluster)
2176  {
2177  //printf("iDigit %d, absId %d, Ecell %f\n",iDigit,absIdList[iDigit], cells->GetCellAmplitude(absIdList[iDigit]));
2178  sm = GetModuleNumberCellIndexes(absIdList[iDigit], calorimeter, icol, irow, iRCU) ;
2179  if(sm > -1 && sm < 12) // just to avoid compilation warning
2180  {
2181  if(icol > maxCol) maxCol = icol;
2182  if(icol < minCol) minCol = icol;
2183  if(irow > maxRow) maxRow = irow;
2184  if(irow < minRow) minRow = irow;
2185  hClusterMap->Fill(icol,irow,ec);
2186  }
2187  }
2188  }
2189 
2190  // Init counters and variables
2191  Int_t ncells1 = 1 ;
2192  UShort_t absIdList1[9] ;
2193  Double_t fracList1 [9] ;
2194  absIdList1[0] = absId1 ;
2195  fracList1 [0] = 1. ;
2196 
2197  Float_t ecell1 = cells->GetCellAmplitude(absId1);
2198  RecalibrateCellAmplitude(ecell1, calorimeter, absId1);
2199  e1 = ecell1;
2200 
2201  Int_t ncells2 = 1 ;
2202  UShort_t absIdList2[9] ;
2203  Double_t fracList2 [9] ;
2204  absIdList2[0] = absId2 ;
2205  fracList2 [0] = 1. ;
2206 
2207  Float_t ecell2 = cells->GetCellAmplitude(absId2);
2208  RecalibrateCellAmplitude(ecell2, calorimeter, absId2);
2209  e2 = ecell2;
2210 
2211  if(fPlotCluster)
2212  {
2213  Int_t icol1 = -1, irow1 = -1, icol2 = -1, irow2 = -1;
2214  sm = GetModuleNumberCellIndexes(absId1, calorimeter, icol1, irow1, iRCU) ;
2215  hClusterLocMax->Fill(icol1,irow1,ecell1);
2216  sm = GetModuleNumberCellIndexes(absId2, calorimeter, icol2, irow2, iRCU) ;
2217  hClusterLocMax->Fill(icol2,irow2,ecell2);
2218  }
2219 
2220  // Very rough way to share the cluster energy
2221  Float_t eRemain = (eCluster-ecell1-ecell2)/2;
2222  Float_t shareFraction1 = ecell1/eCluster+eRemain/eCluster;
2223  Float_t shareFraction2 = ecell2/eCluster+eRemain/eCluster;
2224 
2225  for(Int_t iDigit = 0; iDigit < ncells; iDigit++)
2226  {
2227  Int_t absId = absIdList[iDigit];
2228 
2229  if ( absId==absId1 || absId==absId2 || absId < 0 ) continue;
2230 
2231  Float_t ecell = cells->GetCellAmplitude(absId);
2232  RecalibrateCellAmplitude(ecell, calorimeter, absId);
2233 
2234  if(AreNeighbours(calorimeter, absId1,absId ))
2235  {
2236  absIdList1[ncells1]= absId;
2237 
2238  if(AreNeighbours(calorimeter, absId2,absId ))
2239  {
2240  fracList1[ncells1] = shareFraction1;
2241  e1 += ecell*shareFraction1;
2242  }
2243  else
2244  {
2245  fracList1[ncells1] = 1.;
2246  e1 += ecell;
2247  }
2248 
2249  ncells1++;
2250 
2251  } // neigbour to cell1
2252 
2253  if(AreNeighbours(calorimeter, absId2,absId ))
2254  {
2255  absIdList2[ncells2]= absId;
2256 
2257  if(AreNeighbours(calorimeter, absId1,absId ))
2258  {
2259  fracList2[ncells2] = shareFraction2;
2260  e2 += ecell*shareFraction2;
2261  }
2262  else
2263  {
2264  fracList2[ncells2] = 1.;
2265  e2 += ecell;
2266  }
2267 
2268  ncells2++;
2269 
2270  } // neigbour to cell2
2271  }
2272 
2273  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",
2274  nMax, eCluster,ecell1,ecell2,e1,e2,eCluster-e1-e2,ncells,ncells1,ncells2,shareFraction1,shareFraction2,shareFraction1+shareFraction2));
2275 
2276  cluster1->SetE(e1);
2277  cluster2->SetE(e2);
2278 
2279  cluster1->SetNCells(ncells1);
2280  cluster2->SetNCells(ncells2);
2281 
2282  cluster1->SetCellsAbsId(absIdList1);
2283  cluster2->SetCellsAbsId(absIdList2);
2284 
2285  cluster1->SetCellsAmplitudeFraction(fracList1);
2286  cluster2->SetCellsAmplitudeFraction(fracList2);
2287 
2288  // Correct linearity
2289  CorrectClusterEnergy(cluster1) ;
2290  CorrectClusterEnergy(cluster2) ;
2291 
2292  if(calorimeter==AliFiducialCut::kEMCAL)
2293  {
2294  GetEMCALRecoUtils()->RecalculateClusterPosition(GetEMCALGeometry(), cells, cluster1);
2295  GetEMCALRecoUtils()->RecalculateClusterPosition(GetEMCALGeometry(), cells, cluster2);
2296  }
2297 
2298  if(fPlotCluster)
2299  {
2300  //printf("Cells of cluster1: ");
2301  for(Int_t iDigit = 0; iDigit < ncells1; iDigit++ )
2302  {
2303  //printf(" %d ",absIdList1[iDigit]);
2304 
2305  sm = GetModuleNumberCellIndexes(absIdList1[iDigit], calorimeter, icol, irow, iRCU) ;
2306 
2307  Float_t ecell = cells->GetCellAmplitude(absIdList1[iDigit]);
2308  RecalibrateCellAmplitude(ecell, calorimeter, absIdList1[iDigit]);
2309 
2310  if( AreNeighbours(calorimeter, absId2,absIdList1[iDigit]) && absId1!=absIdList1[iDigit])
2311  hCluster1->Fill(icol,irow,ecell*shareFraction1);
2312  else
2313  hCluster1->Fill(icol,irow,ecell);
2314  }
2315 
2316  //printf(" \n ");
2317  //printf("Cells of cluster2: ");
2318 
2319  for(Int_t iDigit = 0; iDigit < ncells2; iDigit++ )
2320  {
2321  //printf(" %d ",absIdList2[iDigit]);
2322 
2323  sm = GetModuleNumberCellIndexes(absIdList2[iDigit], calorimeter, icol, irow, iRCU) ;
2324 
2325  Float_t ecell = cells->GetCellAmplitude(absIdList2[iDigit]);
2326  RecalibrateCellAmplitude(ecell, calorimeter, absIdList2[iDigit]);
2327 
2328  if( AreNeighbours(calorimeter, absId1,absIdList2[iDigit]) && absId2!=absIdList2[iDigit])
2329  hCluster2->Fill(icol,irow,ecell*shareFraction2);
2330  else
2331  hCluster2->Fill(icol,irow,ecell);
2332  }
2333  //printf(" \n ");
2334 
2335  gStyle->SetPadRightMargin(0.1);
2336  gStyle->SetPadLeftMargin(0.1);
2337  gStyle->SetOptStat(0);
2338  gStyle->SetOptFit(000000);
2339 
2340  if(maxCol-minCol > maxRow-minRow)
2341  {
2342  maxRow+= maxCol-minCol;
2343  }
2344  else
2345  {
2346  maxCol+= maxRow-minRow;
2347  }
2348 
2349  TCanvas * c= new TCanvas("canvas", "canvas", 4000, 4000) ;
2350  c->Divide(2,2);
2351  c->cd(1);
2352  gPad->SetGridy();
2353  gPad->SetGridx();
2354  gPad->SetLogz();
2355  hClusterMap ->SetAxisRange(minCol, maxCol,"X");
2356  hClusterMap ->SetAxisRange(minRow, maxRow,"Y");
2357  hClusterMap ->Draw("colz TEXT");
2358  c->cd(2);
2359  gPad->SetGridy();
2360  gPad->SetGridx();
2361  gPad->SetLogz();
2362  hClusterLocMax ->SetAxisRange(minCol, maxCol,"X");
2363  hClusterLocMax ->SetAxisRange(minRow, maxRow,"Y");
2364  hClusterLocMax ->Draw("colz TEXT");
2365  c->cd(3);
2366  gPad->SetGridy();
2367  gPad->SetGridx();
2368  gPad->SetLogz();
2369  hCluster1 ->SetAxisRange(minCol, maxCol,"X");
2370  hCluster1 ->SetAxisRange(minRow, maxRow,"Y");
2371  hCluster1 ->Draw("colz TEXT");
2372  c->cd(4);
2373  gPad->SetGridy();
2374  gPad->SetGridx();
2375  gPad->SetLogz();
2376  hCluster2 ->SetAxisRange(minCol, maxCol,"X");
2377  hCluster2 ->SetAxisRange(minRow, maxRow,"Y");
2378  hCluster2 ->Draw("colz TEXT");
2379 
2380  if(eCluster > 6 )c->Print(Form("clusterFigures/Event%d_E%1.0f_nMax%d_NCell1_%d_NCell2_%d.eps",
2381  eventNumber,cluster->E(),nMax,ncells1,ncells2));
2382 
2383  delete c;
2384  delete hClusterMap;
2385  delete hClusterLocMax;
2386  delete hCluster1;
2387  delete hCluster2;
2388  }
2389 }
2390 
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.
Bool_t IsAbsIDsFromTCard(Int_t absId1, Int_t absId2, Int_t &rowDiff, Int_t &colDiff) const
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
energy
Definition: HFPtSpectrum.C:44
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.
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