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