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