1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
18 // EMCAL tender, apply corrections to EMCAL clusters and do track matching. //
20 // Author: Deepa Thomas (Utrecht University) //
21 // Later mods/rewrite: Jiri Kral (University of Jyvaskyla) //
22 // S. Aiola, C. Loizides : Make it work for AODs //
24 ///////////////////////////////////////////////////////////////////////////////
29 #include <TInterpreter.h>
30 #include <TObjArray.h>
31 #include <TClonesArray.h>
32 #include <TGeoGlobalMagField.h>
33 #include "AliEMCALAfterBurnerUF.h"
34 #include "AliEMCALClusterizer.h"
35 #include "AliEMCALClusterizerNxN.h"
36 #include "AliEMCALClusterizerv1.h"
37 #include "AliEMCALClusterizerv2.h"
38 #include "AliEMCALDigit.h"
39 #include "AliEMCALGeometry.h"
40 #include "AliEMCALRecParam.h"
41 #include "AliEMCALRecParam.h"
42 #include "AliEMCALRecPoint.h"
43 #include "AliEMCALRecoUtils.h"
44 #include "AliEMCALTenderSupply.h"
45 #include "AliESDCaloCluster.h"
47 #include "AliOADBContainer.h"
48 #include "AliAODEvent.h"
49 #include "AliAnalysisManager.h"
50 #include "AliESDEvent.h"
52 #include "AliTender.h"
54 ClassImp(AliEMCALTenderSupply)
56 AliEMCALTenderSupply::AliEMCALTenderSupply() :
66 ,fNonLinearThreshold(-1)
67 ,fReCalibCluster(kFALSE)
69 ,fCalibrateEnergy(kFALSE)
70 ,fCalibrateTime(kFALSE)
71 ,fDoNonLinearity(kFALSE)
72 ,fBadCellRemove(kFALSE)
73 ,fRejectExoticCells(kFALSE)
74 ,fRejectExoticClusters(kFALSE)
75 ,fClusterBadChannelCheck(kFALSE)
76 ,fRecalClusPos(kFALSE)
78 ,fNCellsFromEMCALBorder(-1)
79 ,fRecalDistToBadChannels(kFALSE)
80 ,fRecalShowerShape(kFALSE)
83 ,fGetPassFromFileName(kTRUE)
88 ,fCutEtaPhiSeparate(kFALSE)
93 ,fReClusterize(kFALSE)
95 ,fGeomMatrixSet(kFALSE)
96 ,fLoadGeomMatrices(kFALSE)
98 ,fDoTrackMatch(kFALSE)
99 ,fDoUpdateOnly(kFALSE)
103 ,fMisalignSurvey(kdefault)
104 ,fExoticCellFraction(-1)
105 ,fExoticCellDiffTime(-1)
106 ,fExoticCellMinAmplitude(-1)
107 ,fSetCellMCLabelFromCluster(kFALSE)
109 // Default constructor.
111 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ;
114 //_____________________________________________________
115 AliEMCALTenderSupply::AliEMCALTenderSupply(const char *name, const AliTender *tender) :
116 AliTenderSupply(name,tender)
125 ,fNonLinearThreshold(-1)
126 ,fReCalibCluster(kFALSE)
128 ,fCalibrateEnergy(kFALSE)
129 ,fCalibrateTime(kFALSE)
130 ,fDoNonLinearity(kFALSE)
131 ,fBadCellRemove(kFALSE)
132 ,fRejectExoticCells(kFALSE)
133 ,fRejectExoticClusters(kFALSE)
134 ,fClusterBadChannelCheck(kFALSE)
135 ,fRecalClusPos(kFALSE)
137 ,fNCellsFromEMCALBorder(-1)
138 ,fRecalDistToBadChannels(kFALSE)
139 ,fRecalShowerShape(kFALSE)
142 ,fGetPassFromFileName(kTRUE)
146 ,fCutEtaPhiSum(kTRUE)
147 ,fCutEtaPhiSeparate(kFALSE)
152 ,fReClusterize(kFALSE)
154 ,fGeomMatrixSet(kFALSE)
155 ,fLoadGeomMatrices(kFALSE)
157 ,fDoTrackMatch(kFALSE)
158 ,fDoUpdateOnly(kFALSE)
162 ,fMisalignSurvey(kdefault)
163 ,fExoticCellFraction(-1)
164 ,fExoticCellDiffTime(-1)
165 ,fExoticCellMinAmplitude(-1)
166 ,fSetCellMCLabelFromCluster(kFALSE)
170 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ;
173 //_____________________________________________________
174 AliEMCALTenderSupply::AliEMCALTenderSupply(const char *name, AliAnalysisTaskSE *task) :
175 AliTenderSupply(name)
184 ,fNonLinearThreshold(-1)
185 ,fReCalibCluster(kFALSE)
187 ,fCalibrateEnergy(kFALSE)
188 ,fCalibrateTime(kFALSE)
189 ,fDoNonLinearity(kFALSE)
190 ,fBadCellRemove(kFALSE)
191 ,fRejectExoticCells(kFALSE)
192 ,fRejectExoticClusters(kFALSE)
193 ,fClusterBadChannelCheck(kFALSE)
194 ,fRecalClusPos(kFALSE)
196 ,fNCellsFromEMCALBorder(-1)
197 ,fRecalDistToBadChannels(kFALSE)
198 ,fRecalShowerShape(kFALSE)
201 ,fGetPassFromFileName(kTRUE)
205 ,fCutEtaPhiSum(kTRUE)
206 ,fCutEtaPhiSeparate(kFALSE)
211 ,fReClusterize(kFALSE)
213 ,fGeomMatrixSet(kFALSE)
214 ,fLoadGeomMatrices(kFALSE)
216 ,fDoTrackMatch(kFALSE)
217 ,fDoUpdateOnly(kFALSE)
221 ,fMisalignSurvey(kdefault)
222 ,fExoticCellFraction(-1)
223 ,fExoticCellDiffTime(-1)
224 ,fExoticCellMinAmplitude(-1)
225 ,fSetCellMCLabelFromCluster(kFALSE)
227 // Named constructor.
229 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ;
232 //_____________________________________________________
233 AliEMCALTenderSupply::~AliEMCALTenderSupply()
237 if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode())
239 delete fEMCALRecoUtils;
244 fDigitsArr->Clear("C");
254 //_____________________________________________________
255 void AliEMCALTenderSupply::SetDefaults()
257 // Set default settings.
259 SwitchOnBadCellRemove();
260 SwitchOnExoticCellRemove();
261 SwitchOnCalibrateEnergy();
262 SwitchOnCalibrateTime();
263 SwitchOnUpdateCell();
264 SwitchOnReclustering();
265 SwitchOnClusterBadChannelCheck();
266 SwitchOnClusterExoticChannelCheck();
267 SwitchOnTrackMatch();
270 //_____________________________________________________
271 Bool_t AliEMCALTenderSupply::RunChanged() const
275 return (fTender && fTender->RunChanged()) || (fTask && fRun != fTask->InputEvent()->GetRunNumber());
278 //_____________________________________________________
279 void AliEMCALTenderSupply::Init()
281 // Initialise EMCAL tender.
284 AliWarning("Init EMCAL Tender supply");
286 if (fConfigName.Length()>0 && gROOT->LoadMacro(fConfigName) >=0) {
287 AliDebug(1, Form("Loading settings from macro %s", fConfigName.Data()));
288 AliEMCALTenderSupply *tender = (AliEMCALTenderSupply*)gInterpreter->ProcessLine("ConfigEMCALTenderSupply()");
289 fDebugLevel = tender->fDebugLevel;
290 fEMCALGeoName = tender->fEMCALGeoName;
291 fEMCALRecoUtils = tender->fEMCALRecoUtils;
292 fConfigName = tender->fConfigName;
293 fNonLinearFunc = tender->fNonLinearFunc;
294 fNonLinearThreshold = tender->fNonLinearThreshold;
295 fReCalibCluster = tender->fReCalibCluster;
296 fUpdateCell = tender->fUpdateCell;
297 fRecalClusPos = tender->fRecalClusPos;
298 fCalibrateEnergy = tender->fCalibrateEnergy;
299 fCalibrateTime = tender->fCalibrateTime;
300 fFiducial = tender->fFiducial;
301 fNCellsFromEMCALBorder = tender->fNCellsFromEMCALBorder;
302 fRecalDistToBadChannels = tender->fRecalDistToBadChannels;
303 fRecalShowerShape = tender->fRecalShowerShape;
304 fClusterBadChannelCheck = tender->fClusterBadChannelCheck;
305 fBadCellRemove = tender->fBadCellRemove;
306 fRejectExoticCells = tender->fRejectExoticCells;
307 fRejectExoticClusters = tender->fRejectExoticClusters;
308 fMass = tender->fMass;
309 fStep = tender->fStep;
310 fCutEtaPhiSum = tender->fCutEtaPhiSum;
311 fCutEtaPhiSeparate = tender->fCutEtaPhiSeparate;
312 fRcut = tender->fRcut;
313 fEtacut = tender->fEtacut;
314 fPhicut = tender->fPhicut;
315 fReClusterize = tender->fReClusterize;
316 fLoadGeomMatrices = tender->fLoadGeomMatrices;
317 fRecParam = tender->fRecParam;
318 fDoNonLinearity = tender->fDoNonLinearity;
319 fDoTrackMatch = tender->fDoTrackMatch;
320 fDoUpdateOnly = tender->fDoUpdateOnly;
321 fMisalignSurvey = tender->fMisalignSurvey;
322 fExoticCellFraction = tender->fExoticCellFraction;
323 fExoticCellDiffTime = tender->fExoticCellDiffTime;
324 fExoticCellMinAmplitude = tender->fExoticCellMinAmplitude;
326 for(Int_t i = 0; i < 12; i++)
327 fEMCALMatrix[i] = tender->fEMCALMatrix[i] ;
331 AliInfo( "Emcal Tender settings: ======================================" );
332 AliInfo( "------------ Switches --------------------------" );
333 AliInfo( Form( "BadCellRemove : %d", fBadCellRemove ));
334 AliInfo( Form( "ExoticCellRemove : %d", fRejectExoticCells ));
335 AliInfo( Form( "CalibrateEnergy : %d", fCalibrateEnergy ));
336 AliInfo( Form( "CalibrateTime : %d", fCalibrateTime ));
337 AliInfo( Form( "UpdateCell : %d", fUpdateCell ));
338 AliInfo( Form( "DoUpdateOnly : %d", fDoUpdateOnly ));
339 AliInfo( Form( "Reclustering : %d", fReClusterize ));
340 AliInfo( Form( "ClusterBadChannelCheck : %d", fClusterBadChannelCheck ));
341 AliInfo( Form( "ClusterExoticChannelCheck : %d", fRejectExoticClusters ));
342 AliInfo( Form( "CellFiducialRegion : %d", fFiducial ));
343 AliInfo( Form( "ReCalibrateCluster : %d", fReCalibCluster ));
344 AliInfo( Form( "RecalculateClusPos : %d", fRecalClusPos ));
345 AliInfo( Form( "RecalShowerShape : %d", fRecalShowerShape ));
346 AliInfo( Form( "NonLinearityCorrection : %d", fDoNonLinearity ));
347 AliInfo( Form( "RecalDistBadChannel : %d", fRecalDistToBadChannels ));
348 AliInfo( Form( "TrackMatch : %d", fDoTrackMatch ));
349 AliInfo( "------------ Variables -------------------------" );
350 AliInfo( Form( "DebugLevel : %d", fDebugLevel ));
351 AliInfo( Form( "BasePath : %s", fBasePath.Data() ));
352 AliInfo( Form( "ConfigFileName : %s", fConfigName.Data() ));
353 AliInfo( Form( "EMCALGeometryName : %s", fEMCALGeoName.Data() ));
354 AliInfo( Form( "NonLinearityFunction : %d", fNonLinearFunc ));
355 AliInfo( Form( "NonLinearityThreshold : %d", fNonLinearThreshold ));
356 AliInfo( Form( "MisalignmentMatrixSurvey : %d", fMisalignSurvey ));
357 AliInfo( Form( "NumberOfCellsFromEMCALBorder : %d", fNCellsFromEMCALBorder ));
358 AliInfo( Form( "RCut : %f", fRcut ));
359 AliInfo( Form( "Mass : %f", fMass ));
360 AliInfo( Form( "Step : %f", fStep ));
361 AliInfo( Form( "EtaCut : %f", fEtacut ));
362 AliInfo( Form( "PhiCut : %f", fPhicut ));
363 AliInfo( Form( "ExoticCellFraction : %f", fExoticCellFraction ));
364 AliInfo( Form( "ExoticCellDiffTime : %f", fExoticCellDiffTime ));
365 AliInfo( Form( "ExoticCellMinAmplitude : %f", fExoticCellMinAmplitude ));
366 AliInfo( "=============================================================" );
372 fEMCALRecoUtils = new AliEMCALRecoUtils;
374 // init geometry if requested
375 if (fEMCALGeoName.Length()>0)
376 fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ;
379 fDigitsArr = new TClonesArray("AliEMCALDigit",1000);
381 // initialising non-linearity parameters
382 if( fNonLinearThreshold != -1 )
383 fEMCALRecoUtils->SetNonLinearityThreshold(fNonLinearThreshold);
384 if( fNonLinearFunc != -1 )
385 fEMCALRecoUtils->SetNonLinearityFunction(fNonLinearFunc);
387 // missalignment function
388 fEMCALRecoUtils->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);
391 // do not do the eta0 fiducial cut
392 if( fNCellsFromEMCALBorder != -1 )
393 fEMCALRecoUtils->SetNumberOfCellsFromEMCALBorder(fNCellsFromEMCALBorder);
394 fEMCALRecoUtils->SwitchOnNoFiducialBorderInEMCALEta0();
396 // exotic cell rejection
397 if( fExoticCellFraction != -1 )
398 fEMCALRecoUtils->SetExoticCellFractionCut( fExoticCellFraction );
399 if( fExoticCellDiffTime != -1 )
400 fEMCALRecoUtils->SetExoticCellDiffTimeCut( fExoticCellDiffTime );
401 if( fExoticCellMinAmplitude != -1 )
402 fEMCALRecoUtils->SetExoticCellMinAmplitudeCut( fExoticCellMinAmplitude );
404 // setting track matching parameters ... mass, step size and residual cut
406 fEMCALRecoUtils->SetMass(fMass);
408 fEMCALRecoUtils->SetStep(fStep);
410 // spatial cut based on separate eta/phi or common processing
412 fEMCALRecoUtils->SwitchOnCutEtaPhiSum();
414 fEMCALRecoUtils->SetCutR(fRcut);
415 } else if (fCutEtaPhiSeparate) {
416 fEMCALRecoUtils->SwitchOnCutEtaPhiSeparate();
418 fEMCALRecoUtils->SetCutEta(fEtacut);
420 fEMCALRecoUtils->SetCutPhi(fPhicut);
424 //_____________________________________________________
425 AliVEvent* AliEMCALTenderSupply::GetEvent()
427 // Return the event pointer.
430 return fTender->GetEvent();
433 return fTask->InputEvent();
439 //_____________________________________________________
440 void AliEMCALTenderSupply::ProcessEvent()
444 AliVEvent *event = GetEvent();
447 AliError("Event ptr = 0, returning");
451 // Initialising parameters once per run number
454 AliWarning( "Run changed, initializing parameters" );
455 fRun = event->GetRunNumber();
457 // init geometry if not already done
458 if (fEMCALGeoName.Length()==0) {
459 fEMCALGeoName = "EMCAL_FIRSTYEARV1";
461 fEMCALGeoName = "EMCAL_COMPLETEV1";
464 fEMCALGeoName = "EMCAL_COMPLETE12SMV1";
466 fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName);
468 AliFatal(Form("Can not create geometry: %s", fEMCALGeoName.Data()));
474 if (fGetPassFromFileName)
477 // define what recalib parameters are needed for various switches
478 // this is based on implementation in AliEMCALRecoUtils
479 Bool_t needRecoParam = fReClusterize;
480 Bool_t needBadChannels = fBadCellRemove | fClusterBadChannelCheck | fRecalDistToBadChannels | fReClusterize;
481 Bool_t needRecalib = fCalibrateEnergy | fReClusterize;
482 Bool_t needTimecalib = fCalibrateTime | fReClusterize;
483 Bool_t needMisalign = fRecalClusPos | fReClusterize;
484 Bool_t needClusterizer = fReClusterize;
486 // initiate reco params with some defaults
487 // will not overwrite, if those have been provided by user
489 Int_t initRC = InitRecParam();
492 AliInfo("Defaults reco params loaded.");
494 AliWarning("User defined reco params.");
498 if( needBadChannels ){
499 Int_t fInitBC = InitBadChannels();
501 AliError("InitBadChannels returned false, returning");
503 AliWarning("InitBadChannels OK");
505 AliWarning(Form("No external hot channel set: %d - %s", event->GetRunNumber(), fFilepass.Data()));
508 // init recalibration factors
511 Int_t fInitRecalib = InitRecalib();
513 AliError("InitRecalib returned false, returning");
515 AliWarning("InitRecalib OK");
517 AliWarning(Form("No recalibration available: %d - %s", event->GetRunNumber(), fFilepass.Data()));
519 Int_t fInitRunDepRecalib = InitRunDepRecalib();
520 if (fInitRunDepRecalib==0)
521 AliError("InitrunDepRecalib returned false, returning");
522 if (fInitRunDepRecalib==1)
523 AliWarning("InitRecalib OK");
524 if (fInitRunDepRecalib>1)
525 AliWarning(Form("No Temperature recalibration available: %d - %s", event->GetRunNumber(), fFilepass.Data()));
531 // init time calibration
533 Int_t initTC = InitTimeCalibration();
535 AliError("InitTimeCalibration returned false, returning");
537 AliWarning("InitTimeCalib OK");
539 AliWarning(Form("No external time calibration set: %d - %s", event->GetRunNumber(), fFilepass.Data()));
542 // init misalignment matrix
544 if (!InitMisalignMatrix())
545 AliError("InitMisalignmentMatrix returned false, returning");
547 AliWarning("InitMisalignMatrix OK");
551 if( needClusterizer ) {
552 if (!InitClusterization())
553 AliError("InitClusterization returned false, returning");
555 AliWarning("InitClusterization OK");
559 fEMCALRecoUtils->Print("");
562 // disable implied switches -------------------------------------------------
563 // AliEMCALRecoUtils or clusterizer functions alredy include some
564 // recalibration so based on those implied callibration te switches
565 // here are disabled to avoid duplication
567 // clusterizer does cluster energy recalibration, position recomputation
570 fReCalibCluster = kFALSE;
571 fRecalClusPos = kFALSE;
572 fRecalShowerShape = kFALSE;
575 // CONFIGURE THE RECO UTILS -------------------------------------------------
576 // configure the reco utils
577 // this option does energy recalibration
578 if( fCalibrateEnergy )
579 fEMCALRecoUtils->SwitchOnRecalibration();
581 fEMCALRecoUtils->SwitchOffRecalibration();
583 // allows time calibration
585 fEMCALRecoUtils->SwitchOnTimeRecalibration();
587 fEMCALRecoUtils->SwitchOffTimeRecalibration();
589 // allows to zero bad cells
591 fEMCALRecoUtils->SwitchOnBadChannelsRemoval();
593 fEMCALRecoUtils->SwitchOffBadChannelsRemoval();
595 // distance to bad channel recalibration
596 if( fRecalDistToBadChannels )
597 fEMCALRecoUtils->SwitchOnDistToBadChannelRecalculation();
599 fEMCALRecoUtils->SwitchOffDistToBadChannelRecalculation();
601 // exclude exotic cells
602 if( fRejectExoticCells )
603 fEMCALRecoUtils->SwitchOnRejectExoticCell();
605 fEMCALRecoUtils->SwitchOffRejectExoticCell();
607 // exclude clusters with exotic cells
608 if( fRejectExoticClusters )
609 fEMCALRecoUtils->SwitchOnRejectExoticCluster();
611 fEMCALRecoUtils->SwitchOffRejectExoticCluster();
613 // TODO: not implemented switches
614 // SwitchOnClusterEnergySmearing
615 // SwitchOnRunDepCorrection
617 // START PROCESSING ---------------------------------------------------------
618 // Test if cells present
619 AliVCaloCells *cells= event->GetEMCALCells();
620 if (cells->GetNumberOfCells()<=0)
623 AliWarning(Form("Number of EMCAL cells = %d, returning", cells->GetNumberOfCells()));
628 AliInfo(Form("Re-calibrate cluster %d\n",fReCalibCluster));
630 // mark the cells not recalibrated in case of selected
631 // time, energy recalibration or bad channel removal
632 if( fCalibrateEnergy || fCalibrateTime || fBadCellRemove )
633 fEMCALRecoUtils->ResetCellsCalibrated();
635 // CELL RECALIBRATION -------------------------------------------------------
636 // cell objects will be updated
637 // the cell calibrations are also processed locally any time those are needed
638 // in case that the cell objects are not to be updated here for later use
642 // includes exotic cell check in the UpdateCells function - is not provided
646 // switch off recalibrations so those are not done multiple times
647 // this is just for safety, the recalibrated flag of cell object
648 // should not allow for farther processing anyways
649 fEMCALRecoUtils->SwitchOffRecalibration();
650 fEMCALRecoUtils->SwitchOffTimeRecalibration();
656 // RECLUSTERIZATION ---------------------------------------------------------
664 // Store good clusters
665 TClonesArray *clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters"));
667 clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters"));
669 AliWarning(Form("No cluster array, number of cells in event = %d, returning", cells->GetNumberOfCells()));
673 // PROCESS SINGLE CLUSTER RECALIBRATION -------------------------------------
674 // now go through clusters one by one and process separate correction
675 // as those were defined or not
676 Int_t nclusters = clusArr->GetEntriesFast();
677 for (Int_t icluster=0; icluster < nclusters; ++icluster)
679 AliVCluster *clust = static_cast<AliVCluster*>(clusArr->At(icluster));
682 if (!clust->IsEMCAL())
685 // REMOVE CLUSTERS WITH BAD CELLS -----------------------------
686 if( fClusterBadChannelCheck )
688 // careful, the the ClusterContainsBadChannel is dependent on
689 // SwitchOnBadChannelsRemoval, switching it ON automatically
690 // and returning to original value after processing
691 Bool_t badRemoval = fEMCALRecoUtils->IsBadChannelsRemovalSwitchedOn();
692 fEMCALRecoUtils->SwitchOnBadChannelsRemoval();
694 Bool_t badResult = fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo, clust->GetCellsAbsId(), clust->GetNCells());
696 // switch the bad channels removal back
698 fEMCALRecoUtils->SwitchOffBadChannelsRemoval();
702 delete clusArr->RemoveAt(icluster);
703 continue; //TODO is it really needed to remove it? Or should we flag it?
707 // REMOVE EXOTIC CLUSTERS -------------------------------------
708 // does process local cell recalibration energy and time without replacing
709 // the global cell values, in case of no cell recalib done yet
710 if( fRejectExoticClusters )
712 // careful, the IsExoticCluster is dependent on
713 // SwitchOnRejectExoticCell, switching it ON automatically
714 // and returning to original value after processing
715 Bool_t exRemoval = fEMCALRecoUtils->IsRejectExoticCell();
716 fEMCALRecoUtils->SwitchOnRejectExoticCell();
718 // get bunch crossing
719 Int_t bunchCrossNo = event->GetBunchCrossNumber();
721 Bool_t exResult = fEMCALRecoUtils->IsExoticCluster(clust, cells, bunchCrossNo );
723 // switch the exotic channels removal back
725 fEMCALRecoUtils->SwitchOffRejectExoticCell();
729 delete clusArr->RemoveAt(icluster);
730 continue; //TODO is it really needed to remove it? Or should we flag it?
734 // FIDUCIAL CUT -----------------------------------------------
737 // depends on SetNumberOfCellsFromEMCALBorder
738 // SwitchOnNoFiducialBorderInEMCALEta0
739 if (!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, clust, cells)){
740 delete clusArr->RemoveAt(icluster);
741 continue; //TODO it would be nice to store the distance
745 // CLUSTER ENERGY ---------------------------------------------
746 // does process local cell recalibration energy and time without replacing
747 // the global cell values, in case of no cell recalib done yet
748 if( fReCalibCluster ) {
749 fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, clust, cells);
750 if (clust->E() < 1e-9) {
751 delete clusArr->RemoveAt(icluster);
756 // CLUSTER POSITION -------------------------------------------
757 // does process local cell energy recalibration, if enabled and cells
758 // not calibrated yet
760 fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, cells, clust);
762 // SHOWER SHAPE -----------------------------------------------
763 if( fRecalShowerShape )
764 fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, cells, clust);
766 // NONLINEARITY -----------------------------------------------
767 if( fDoNonLinearity )
769 Float_t correctedEnergy = fEMCALRecoUtils->CorrectClusterEnergyLinearity(clust);
770 clust->SetE(correctedEnergy);
773 // DISTANCE TO BAD CHANNELS -----------------------------------
774 if( fRecalDistToBadChannels )
775 fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, cells, clust);
783 // TRACK MATCHING -----------------------------------------------------------
784 if (!TGeoGlobalMagField::Instance()->GetField()) {
785 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event);
787 esd->InitMagneticField();
789 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(event);
790 Double_t curSol = 30000*aod->GetMagneticField()/5.00668;
791 Double_t curDip = 6000 *aod->GetMuonMagFieldScale();
792 AliMagF *field = AliMagF::CreateFieldMap(curSol,curDip);
793 TGeoGlobalMagField::Instance()->SetField(field);
797 fEMCALRecoUtils->FindMatches(event,0x0,fEMCALGeo);
798 fEMCALRecoUtils->SetClusterMatchedToTrack(event);
799 fEMCALRecoUtils->SetTracksMatchedToCluster(event);
802 //_____________________________________________________
803 Bool_t AliEMCALTenderSupply::InitMisalignMatrix()
805 // Initialising misalignment matrices
807 AliVEvent *event = GetEvent();
814 AliInfo("Misalignment matrix already set");
819 AliInfo("Initialising misalignment matrix");
821 if (fLoadGeomMatrices) {
822 for(Int_t mod=0; mod < fEMCALGeo->GetNumberOfSuperModules(); ++mod)
824 if (fEMCALMatrix[mod]){
826 fEMCALMatrix[mod]->Print();
827 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod);
830 fGeomMatrixSet = kTRUE;
834 Int_t runGM = event->GetRunNumber();
837 if(fMisalignSurvey == kdefault)
838 { //take default alignment corresponding to run no
839 AliOADBContainer emcalgeoCont(Form("emcal"));
840 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
841 mobj=(TObjArray*)emcalgeoCont.GetObject(runGM,"EmcalMatrices");
844 if(fMisalignSurvey == kSurveybyS)
845 { //take alignment at sector level
846 if (runGM <= 140000) { //2010 data
847 AliOADBContainer emcalgeoCont(Form("emcal2010"));
848 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
849 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10");
851 else if (runGM>140000)
852 { // 2011 LHC11a pass1 data
853 AliOADBContainer emcalgeoCont(Form("emcal2011"));
854 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
855 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byS");
859 if(fMisalignSurvey == kSurveybyM)
860 { //take alignment at module level
861 if (runGM <= 140000) { //2010 data
862 AliOADBContainer emcalgeoCont(Form("emcal2010"));
863 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
864 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10");
866 else if (runGM>140000)
867 { // 2011 LHC11a pass1 data
868 AliOADBContainer emcalgeoCont(Form("emcal2011"));
869 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
870 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byM");
876 AliFatal("Geometry matrix array not found");
880 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
882 fEMCALMatrix[mod] = (TGeoHMatrix*) mobj->At(mod);
883 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod);
884 fEMCALMatrix[mod]->Print();
890 //_____________________________________________________
891 Int_t AliEMCALTenderSupply::InitBadChannels()
893 // Initialising bad channel maps
895 AliVEvent *event = GetEvent();
901 AliInfo("Initialising Bad channel map");
903 // init default maps first
904 if( !fEMCALRecoUtils->GetEMCALBadChannelStatusMapArray() )
905 fEMCALRecoUtils->InitEMCALBadChannelStatusMap() ;
907 Int_t runBC = event->GetRunNumber();
909 AliOADBContainer *contBC = new AliOADBContainer("");
911 { //if fBasePath specified in the ->SetBasePath()
912 if (fDebugLevel>0) AliInfo(Form("Loading Bad Channels OADB from given path %s",fBasePath.Data()));
914 TFile *fbad=new TFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"read");
915 if (!fbad || fbad->IsZombie())
917 AliFatal(Form("EMCALBadChannels.root was not found in the path provided: %s",fBasePath.Data()));
921 if (fbad) delete fbad;
923 contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"AliEMCALBadChannels");
926 { // Else choose the one in the $ALICE_ROOT directory
927 if (fDebugLevel>0) AliInfo("Loading Bad Channels OADB from $ALICE_ROOT/OADB/EMCAL");
929 TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","read");
930 if (!fbad || fbad->IsZombie())
932 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root was not found");
936 if (fbad) delete fbad;
938 contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","AliEMCALBadChannels");
941 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
944 AliError(Form("No external hot channel set for run number: %d", runBC));
948 Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
949 for (Int_t i=0; i<sms; ++i)
951 TH2I *h = fEMCALRecoUtils->GetEMCALChannelStatusMap(i);
954 h=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
958 AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
962 fEMCALRecoUtils->SetEMCALChannelStatusMap(i,h);
967 //_____________________________________________________
968 Int_t AliEMCALTenderSupply::InitRecalib()
970 // Initialising recalibration factors.
972 AliVEvent *event = GetEvent();
978 AliInfo("Initialising recalibration factors");
980 // init default maps first
981 if( !fEMCALRecoUtils->GetEMCALRecalibrationFactorsArray() )
982 fEMCALRecoUtils->InitEMCALRecalibrationFactors() ;
984 Int_t runRC = event->GetRunNumber();
986 AliOADBContainer *contRF=new AliOADBContainer("");
988 { //if fBasePath specified in the ->SetBasePath()
989 if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data()));
991 TFile *fRecalib= new TFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"read");
992 if (!fRecalib || fRecalib->IsZombie())
994 AliFatal(Form("EMCALRecalib.root not found in %s",fBasePath.Data()));
998 if (fRecalib) delete fRecalib;
1000 contRF->InitFromFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"AliEMCALRecalib");
1003 { // Else choose the one in the $ALICE_ROOT directory
1004 if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL");
1006 TFile *fRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","read");
1007 if (!fRecalib || fRecalib->IsZombie())
1009 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root was not found");
1013 if (fRecalib) delete fRecalib;
1015 contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","AliEMCALRecalib");
1018 TObjArray *recal=(TObjArray*)contRF->GetObject(runRC);
1021 AliError(Form("No Objects for run: %d",runRC));
1025 TObjArray *recalpass=(TObjArray*)recal->FindObject(fFilepass);
1028 AliError(Form("No Objects for run: %d - %s",runRC,fFilepass.Data()));
1032 TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
1035 AliError(Form("No Recalib histos found for %d - %s",runRC,fFilepass.Data()));
1039 if (fDebugLevel>0) recalib->Print();
1041 Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
1042 for (Int_t i=0; i<sms; ++i)
1044 TH2F *h = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactors(i);
1047 h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
1050 AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
1054 fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
1059 //_____________________________________________________
1060 Int_t AliEMCALTenderSupply::InitRunDepRecalib()
1062 // Initialising recalibration factors.
1064 AliVEvent *event = GetEvent();
1070 AliInfo("Initialising recalibration factors");
1072 // init default maps first
1073 if( !fEMCALRecoUtils->GetEMCALRecalibrationFactorsArray() )
1074 fEMCALRecoUtils->InitEMCALRecalibrationFactors() ;
1076 Int_t runRC = event->GetRunNumber();
1078 AliOADBContainer *contRF=new AliOADBContainer("");
1080 { //if fBasePath specified in the ->SetBasePath()
1081 if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data()));
1083 TFile *fRunDepRecalib= new TFile(Form("%s/EMCALTemperatureCorrCalib.root",fBasePath.Data()),"read");
1084 if (!fRunDepRecalib || fRunDepRecalib->IsZombie())
1086 AliFatal(Form("EMCALTemperatureCorrCalib.root not found in %s",fBasePath.Data()));
1090 if (fRunDepRecalib) delete fRunDepRecalib;
1092 contRF->InitFromFile(Form("%s/EMCALTemperatureCorrCalib.root",fBasePath.Data()),"AliEMCALRunDepTempCalibCorrections");
1095 { // Else choose the one in the $ALICE_ROOT directory
1096 if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL");
1098 TFile *fRunDepRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root","read");
1099 if (!fRunDepRecalib || fRunDepRecalib->IsZombie())
1101 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root was not found");
1105 if (fRunDepRecalib) delete fRunDepRecalib;
1107 contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root","AliEMCALRunDepTempCalibCorrections");
1110 TH1S *rundeprecal=(TH1S*)contRF->GetObject(runRC);
1113 AliWarning(Form("No TemperatureCorrCalib Objects for run: %d",runRC));
1114 // let's get the closest runnumber instead then..
1117 Int_t maxEntry = contRF->GetNumberOfEntries();
1119 while ( (ic < maxEntry) && (contRF->UpperLimit(ic) < runRC) ) {
1124 Int_t closest = lower;
1125 if ( (ic<maxEntry) &&
1126 (contRF->LowerLimit(ic)-runRC) < (runRC - contRF->UpperLimit(lower)) ) {
1130 AliWarning(Form("TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRF->LowerLimit(closest)));
1131 rundeprecal = (TH1S*) contRF->GetObjectByIndex(closest);
1134 if (fDebugLevel>0) rundeprecal->Print();
1136 Int_t nSM = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
1138 for (Int_t ism=0; ism<nSM; ++ism)
1140 for (Int_t icol=0; icol<48; ++icol)
1142 for (Int_t irow=0; irow<24; ++irow)
1144 Float_t factor = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(ism,icol,irow);
1146 Int_t absID = fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol); // original calibration factor
1147 factor *= rundeprecal->GetBinContent(absID) / 10000. ; // correction dependent on T
1148 //printf("\t ism %d, icol %d, irow %d,absID %d, corrA %2.3f, corrB %2.3f, corrAB %2.3f\n",ism, icol, irow, absID,
1149 // GetEMCALChannelRecalibrationFactor(ism,icol,irow) , rundeprecal->GetBinContent(absID) / 10000., factor);
1150 fEMCALRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
1159 //_____________________________________________________
1160 Int_t AliEMCALTenderSupply::InitTimeCalibration()
1162 // Initialising bad channel maps
1163 AliVEvent *event = GetEvent();
1169 AliInfo("Initialising time calibration map");
1171 // init default maps first
1172 if ( !fEMCALRecoUtils->GetEMCALTimeRecalibrationFactorsArray() )
1173 fEMCALRecoUtils->InitEMCALTimeRecalibrationFactors() ;
1175 Int_t runBC = event->GetRunNumber();
1177 AliOADBContainer *contBC = new AliOADBContainer("");
1179 { //if fBasePath specified in the ->SetBasePath()
1180 if (fDebugLevel>0) AliInfo(Form("Loading time calibration OADB from given path %s",fBasePath.Data()));
1182 TFile *fbad=new TFile(Form("%s/EMCALTimeCalib.root",fBasePath.Data()),"read");
1183 if (!fbad || fbad->IsZombie())
1185 AliFatal(Form("EMCALTimeCalib.root was not found in the path provided: %s",fBasePath.Data()));
1189 if (fbad) delete fbad;
1191 contBC->InitFromFile(Form("%s/EMCALTimeCalib.root",fBasePath.Data()),"AliEMCALTimeCalib");
1194 { // Else choose the one in the $ALICE_ROOT directory
1195 if (fDebugLevel>0) AliInfo("Loading time calibration OADB from $ALICE_ROOT/OADB/EMCAL");
1197 TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root","read");
1198 if (!fbad || fbad->IsZombie())
1200 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root was not found");
1204 if (fbad) delete fbad;
1206 contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root","AliEMCALTimeCalib");
1209 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
1212 AliError(Form("No external time calibration set for run number: %d", runBC));
1216 // Here, it looks for a specific pass
1217 TObjArray *arrayBCpass=(TObjArray*)arrayBC->FindObject(fFilepass);
1220 AliError(Form("No external time calibration set for: %d -%s", runBC,fFilepass.Data()));
1224 if (fDebugLevel>0) arrayBCpass->Print();
1226 for( Int_t i = 0; i < 4; i++ )
1228 TH1F *h = fEMCALRecoUtils->GetEMCALChannelTimeRecalibrationFactors( i );
1232 h = (TH1F*)arrayBCpass->FindObject(Form("hAllTimeAvBC%d",i));
1236 AliError(Form("Can not get hAllTimeAvBC%d",i));
1240 fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactors(i,h);
1245 //_____________________________________________________
1246 void AliEMCALTenderSupply::UpdateCells()
1248 //Remove bad cells from the cell list
1249 //Recalibrate energy and time cells
1250 //This is required for later reclusterization
1252 AliVEvent *event = GetEvent();
1256 AliVCaloCells *cells = event->GetEMCALCells();
1257 Int_t bunchCrossNo = event->GetBunchCrossNumber();
1259 fEMCALRecoUtils->RecalibrateCells(cells, bunchCrossNo);
1261 // remove exotic cells - loop through cells and zero the exotic ones
1262 // just like with bad cell rejection in reco utils (inside RecalibrateCells)
1263 if( fRejectExoticCells )
1270 Bool_t isExot = kFALSE;
1272 // loop through cells
1273 Int_t nEMcell = cells->GetNumberOfCells() ;
1274 for (Int_t iCell = 0; iCell < nEMcell; iCell++)
1276 cells->GetCell( iCell, absId, ecell, tcell, mclabel, efrac );
1278 isExot = fEMCALRecoUtils->IsExoticCell( absId, cells, bunchCrossNo );
1281 cells->SetCell( iCell, absId, 0.0, -1.0, mclabel, efrac );
1283 } // reject exotic cells
1288 //_____________________________________________________
1289 TString AliEMCALTenderSupply::GetBeamType()
1291 // Get beam type : pp-AA-pA
1292 // ESDs have it directly, AODs get it from hardcoded run number ranges
1294 AliVEvent *event = GetEvent();
1297 AliError("Couldn't retrieve event!");
1303 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event);
1305 const AliESDRun *run = esd->GetESDRun();
1306 beamType = run->GetBeamType();
1310 Int_t runNumber = event->GetRunNumber();
1311 if ((runNumber >= 136851 && runNumber <= 139517) // LHC10h
1312 || (runNumber >= 166529 && runNumber <= 170593)) // LHC11h
1325 //_____________________________________________________
1326 Int_t AliEMCALTenderSupply::InitRecParam()
1328 // Init reco params if not yet exist (probably shipped by the user already)
1330 if( fRecParam != 0 )
1333 TString beamType = GetBeamType();
1335 // set some default reco params
1336 fRecParam = new AliEMCALRecParam();
1337 fRecParam->SetClusteringThreshold(0.100);
1338 fRecParam->SetMinECut(0.050);
1339 fRecParam->SetTimeCut(250);
1340 fRecParam->SetTimeMin(425);
1341 fRecParam->SetTimeMax(825);
1342 if ( beamType == "A-A") {
1343 fRecParam->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv2);
1346 fRecParam->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv1);
1352 //_____________________________________________________
1353 Bool_t AliEMCALTenderSupply::InitClusterization()
1355 // Initialing clusterization/unfolding algorithm and set all the needed parameters.
1357 AliVEvent *event = GetEvent();
1363 AliInfo(Form("Initialising reclustering parameters: Clusterizer type: %d",fRecParam->GetClusterizerFlag()));
1365 //---setup clusterizer
1367 // avoid deleting fDigitsArr
1368 fClusterizer->SetDigitsArr(0);
1369 delete fClusterizer;
1372 if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1373 fClusterizer = new AliEMCALClusterizerv1 (fEMCALGeo);
1374 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1375 fClusterizer = new AliEMCALClusterizerv2(fEMCALGeo);
1376 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
1378 AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(fEMCALGeo);
1379 clusterizer->SetNRowDiff(fRecParam->GetNRowDiff());
1380 clusterizer->SetNColDiff(fRecParam->GetNColDiff());
1381 fClusterizer = clusterizer;
1385 AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
1389 // Set the clustering parameters
1390 fClusterizer->SetECAClusteringThreshold( fRecParam->GetClusteringThreshold() );
1391 fClusterizer->SetECALogWeight ( fRecParam->GetW0() );
1392 fClusterizer->SetMinECut ( fRecParam->GetMinECut() );
1393 fClusterizer->SetUnfolding ( fRecParam->GetUnfold() );
1394 fClusterizer->SetECALocalMaxCut ( fRecParam->GetLocMaxCut() );
1395 fClusterizer->SetTimeCut ( fRecParam->GetTimeCut() );
1396 fClusterizer->SetTimeMin ( fRecParam->GetTimeMin() );
1397 fClusterizer->SetTimeMax ( fRecParam->GetTimeMax() );
1398 fClusterizer->SetInputCalibrated ( kTRUE );
1399 fClusterizer->SetJustClusters ( kTRUE );
1401 // In case of unfolding after clusterization is requested, set the corresponding parameters
1402 if (fRecParam->GetUnfold())
1404 for (Int_t i = 0; i < 8; ++i)
1406 fClusterizer->SetSSPars(i, fRecParam->GetSSPars(i));
1408 for (Int_t i = 0; i < 3; ++i)
1410 fClusterizer->SetPar5 (i, fRecParam->GetPar5(i));
1411 fClusterizer->SetPar6 (i, fRecParam->GetPar6(i));
1413 fClusterizer->InitClusterUnfolding();
1416 fClusterizer->SetDigitsArr(fDigitsArr);
1417 fClusterizer->SetOutput(0);
1418 fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
1422 //_____________________________________________________
1423 void AliEMCALTenderSupply::FillDigitsArray()
1425 // Fill digits from cells to a TClonesArray.
1427 AliVEvent *event = GetEvent();
1432 // In case of MC productions done before aliroot tag v5-02-Rev09
1433 // assing the cluster label to all the cells belonging to this cluster
1435 Int_t cellLabels[12672];
1436 if(fSetCellMCLabelFromCluster)
1438 for (Int_t i = 0; i < 12672; i++) cellLabels[i] = 0;
1440 Int_t nClusters = event->GetNumberOfCaloClusters();
1441 for (Int_t i = 0; i < nClusters; i++)
1443 AliVCluster *clus = event->GetCaloCluster(i);
1447 if(!clus->IsEMCAL()) continue ;
1449 Int_t label = clus->GetLabel();
1450 UShort_t * index = clus->GetCellsAbsId() ;
1452 for(Int_t icell=0; icell < clus->GetNCells(); icell++ )
1453 cellLabels[index[icell]] = label;
1458 fDigitsArr->Clear("C");
1459 AliVCaloCells *cells = event->GetEMCALCells();
1460 Int_t ncells = cells->GetNumberOfCells();
1461 for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell)
1463 Double_t cellAmplitude=0, cellTime=0, efrac = 0;
1464 Short_t cellNumber=0;
1467 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, mcLabel, efrac) != kTRUE)
1470 // Do not add if energy already too low (some cells set to 0 if bad channels)
1471 if (cellAmplitude < fRecParam->GetMinECut())
1474 // If requested, do not include exotic cells
1475 if (fEMCALRecoUtils->IsExoticCell(cellNumber,cells,event->GetBunchCrossNumber()))
1478 if(fSetCellMCLabelFromCluster) mcLabel = cellLabels[cellNumber];
1480 new((*fDigitsArr)[idigit]) AliEMCALDigit(mcLabel, mcLabel, cellNumber,
1481 (Float_t)cellAmplitude, (Float_t)cellTime,
1482 AliEMCALDigit::kHG,idigit, 0, 0, 1);
1487 //_____________________________________________________
1488 void AliEMCALTenderSupply::Clusterize()
1492 fClusterizer->Digits2Clusters("");
1495 //_____________________________________________________
1496 void AliEMCALTenderSupply::UpdateClusters()
1498 // Update ESD cluster list.
1500 AliVEvent *event = GetEvent();
1505 TClonesArray *clus = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters"));
1507 clus = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters"));
1510 AliError(" Null pointer to calo clusters array, returning");
1514 Int_t nents = clus->GetEntriesFast();
1515 for (Int_t i=0; i < nents; ++i)
1517 AliVCluster *c = dynamic_cast<AliVCluster*>(clus->At(i));
1521 delete clus->RemoveAt(i);
1526 RecPoints2Clusters(clus);
1529 //_____________________________________________________
1530 void AliEMCALTenderSupply::RecPoints2Clusters(TClonesArray *clus)
1532 // Convert AliEMCALRecoPoints to AliESDCaloClusters/AliAODCaloClusters.
1533 // Cluster energy, global position, cells and their amplitude fractions are restored.
1535 AliVEvent *event = GetEvent();
1540 Int_t ncls = fClusterArr->GetEntriesFast();
1541 for(Int_t i=0, nout=clus->GetEntriesFast(); i < ncls; ++i)
1543 AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
1545 Int_t ncellsTrue = 0;
1546 const Int_t ncells = recpoint->GetMultiplicity();
1547 UShort_t absIds[ncells];
1548 Double32_t ratios[ncells];
1549 Int_t *dlist = recpoint->GetDigitsList();
1550 Float_t *elist = recpoint->GetEnergiesList();
1551 for (Int_t c = 0; c < ncells; ++c)
1553 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c]));
1554 absIds[ncellsTrue] = digit->GetId();
1555 ratios[ncellsTrue] = elist[c]/digit->GetAmplitude();
1556 if (ratios[ncellsTrue] < 0.001)
1563 AliWarning("Skipping cluster with no cells");
1567 // calculate new cluster position
1569 recpoint->GetGlobalPosition(gpos);
1573 AliVCluster *c = static_cast<AliVCluster*>(clus->New(nout++));
1575 c->SetType(AliVCluster::kEMCALClusterv1);
1576 c->SetE(recpoint->GetEnergy());
1578 c->SetNCells(ncellsTrue);
1579 c->SetDispersion(recpoint->GetDispersion());
1580 c->SetEmcCpvDistance(-1); //not yet implemented
1581 c->SetChi2(-1); //not yet implemented
1582 c->SetTOF(recpoint->GetTime()) ; //time-of-flight
1583 c->SetNExMax(recpoint->GetNExMax()); //number of local maxima
1584 Float_t elipAxis[2];
1585 recpoint->GetElipsAxis(elipAxis);
1586 c->SetM02(elipAxis[0]*elipAxis[0]) ;
1587 c->SetM20(elipAxis[1]*elipAxis[1]) ;
1588 c->SetCellsAbsId(absIds);
1589 c->SetCellsAmplitudeFraction(ratios);
1592 AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(c);
1594 Int_t parentMult = 0;
1595 Int_t *parentList = recpoint->GetParents(parentMult);
1596 if (parentMult > 0) {
1597 TArrayI parents(parentMult, parentList);
1598 esdClus->AddLabels(parents);
1602 AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(c);
1604 Int_t parentMult = 0;
1605 Int_t *parentList = recpoint->GetParents(parentMult);
1606 aodClus->SetLabel(parentList, parentMult);
1612 //_____________________________________________________
1613 void AliEMCALTenderSupply::GetPass()
1615 // Get passx from filename
1617 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1618 fInputTree = mgr->GetTree();
1622 AliError("Pointer to tree = 0, returning");
1626 fInputFile = fInputTree->GetCurrentFile();
1628 AliError("Null pointer input file, returning");
1632 TString fname(fInputFile->GetName());
1633 if (fname.Contains("pass1")) fFilepass = TString("pass1");
1634 else if (fname.Contains("pass2")) fFilepass = TString("pass2");
1635 else if (fname.Contains("pass3")) fFilepass = TString("pass3");
1636 else if (fname.Contains("pass4")) fFilepass = TString("pass4");
1639 AliError(Form("Pass number string not found: %s", fname.Data()));