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