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