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"
53 #include "AliAODMCParticle.h"
55 ClassImp(AliEMCALTenderSupply)
57 AliEMCALTenderSupply::AliEMCALTenderSupply() :
67 ,fNonLinearThreshold(-1)
68 ,fReCalibCluster(kFALSE)
70 ,fCalibrateEnergy(kFALSE)
71 ,fCalibrateTime(kFALSE)
72 ,fDoNonLinearity(kFALSE)
73 ,fBadCellRemove(kFALSE)
74 ,fRejectExoticCells(kFALSE)
75 ,fRejectExoticClusters(kFALSE)
76 ,fClusterBadChannelCheck(kFALSE)
77 ,fRecalClusPos(kFALSE)
79 ,fNCellsFromEMCALBorder(-1)
80 ,fRecalDistToBadChannels(kFALSE)
81 ,fRecalShowerShape(kFALSE)
84 ,fGetPassFromFileName(kTRUE)
89 ,fCutEtaPhiSeparate(kFALSE)
94 ,fReClusterize(kFALSE)
96 ,fGeomMatrixSet(kFALSE)
97 ,fLoadGeomMatrices(kFALSE)
99 ,fDoTrackMatch(kFALSE)
100 ,fDoUpdateOnly(kFALSE)
104 ,fMisalignSurvey(kdefault)
105 ,fExoticCellFraction(-1)
106 ,fExoticCellDiffTime(-1)
107 ,fExoticCellMinAmplitude(-1)
108 ,fSetCellMCLabelFromCluster(0)
110 ,fRemapMCLabelForAODs(0)
113 // Default constructor.
115 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ;
116 for(Int_t j = 0; j < 12672; j++) fOrgClusterCellId[j] = -1;
119 //_____________________________________________________
120 AliEMCALTenderSupply::AliEMCALTenderSupply(const char *name, const AliTender *tender) :
121 AliTenderSupply(name,tender)
130 ,fNonLinearThreshold(-1)
131 ,fReCalibCluster(kFALSE)
133 ,fCalibrateEnergy(kFALSE)
134 ,fCalibrateTime(kFALSE)
135 ,fDoNonLinearity(kFALSE)
136 ,fBadCellRemove(kFALSE)
137 ,fRejectExoticCells(kFALSE)
138 ,fRejectExoticClusters(kFALSE)
139 ,fClusterBadChannelCheck(kFALSE)
140 ,fRecalClusPos(kFALSE)
142 ,fNCellsFromEMCALBorder(-1)
143 ,fRecalDistToBadChannels(kFALSE)
144 ,fRecalShowerShape(kFALSE)
147 ,fGetPassFromFileName(kTRUE)
151 ,fCutEtaPhiSum(kTRUE)
152 ,fCutEtaPhiSeparate(kFALSE)
157 ,fReClusterize(kFALSE)
159 ,fGeomMatrixSet(kFALSE)
160 ,fLoadGeomMatrices(kFALSE)
162 ,fDoTrackMatch(kFALSE)
163 ,fDoUpdateOnly(kFALSE)
167 ,fMisalignSurvey(kdefault)
168 ,fExoticCellFraction(-1)
169 ,fExoticCellDiffTime(-1)
170 ,fExoticCellMinAmplitude(-1)
171 ,fSetCellMCLabelFromCluster(0)
173 ,fRemapMCLabelForAODs(0)
178 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ;
179 for(Int_t j = 0; j < 12672; j++) fOrgClusterCellId[j] = -1;
182 //_____________________________________________________
183 AliEMCALTenderSupply::AliEMCALTenderSupply(const char *name, AliAnalysisTaskSE *task) :
184 AliTenderSupply(name)
193 ,fNonLinearThreshold(-1)
194 ,fReCalibCluster(kFALSE)
196 ,fCalibrateEnergy(kFALSE)
197 ,fCalibrateTime(kFALSE)
198 ,fDoNonLinearity(kFALSE)
199 ,fBadCellRemove(kFALSE)
200 ,fRejectExoticCells(kFALSE)
201 ,fRejectExoticClusters(kFALSE)
202 ,fClusterBadChannelCheck(kFALSE)
203 ,fRecalClusPos(kFALSE)
205 ,fNCellsFromEMCALBorder(-1)
206 ,fRecalDistToBadChannels(kFALSE)
207 ,fRecalShowerShape(kFALSE)
210 ,fGetPassFromFileName(kTRUE)
214 ,fCutEtaPhiSum(kTRUE)
215 ,fCutEtaPhiSeparate(kFALSE)
220 ,fReClusterize(kFALSE)
222 ,fGeomMatrixSet(kFALSE)
223 ,fLoadGeomMatrices(kFALSE)
225 ,fDoTrackMatch(kFALSE)
226 ,fDoUpdateOnly(kFALSE)
230 ,fMisalignSurvey(kdefault)
231 ,fExoticCellFraction(-1)
232 ,fExoticCellDiffTime(-1)
233 ,fExoticCellMinAmplitude(-1)
234 ,fSetCellMCLabelFromCluster(0)
236 ,fRemapMCLabelForAODs(0)
238 // Named constructor.
240 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ;
241 for(Int_t j = 0; j < 12672; j++) fOrgClusterCellId[j] = -1;
244 //_____________________________________________________
245 AliEMCALTenderSupply::~AliEMCALTenderSupply()
249 if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode())
251 delete fEMCALRecoUtils;
256 fDigitsArr->Clear("C");
266 //_____________________________________________________
267 void AliEMCALTenderSupply::SetDefaults()
269 // Set default settings.
271 SwitchOnBadCellRemove();
272 SwitchOnExoticCellRemove();
273 SwitchOnCalibrateEnergy();
274 SwitchOnCalibrateTime();
275 SwitchOnUpdateCell();
276 SwitchOnReclustering();
277 SwitchOnClusterBadChannelCheck();
278 SwitchOnClusterExoticChannelCheck();
279 SwitchOnTrackMatch();
282 //_____________________________________________________
283 Bool_t AliEMCALTenderSupply::RunChanged() const
287 return (fTender && fTender->RunChanged()) || (fTask && fRun != fTask->InputEvent()->GetRunNumber());
290 //_____________________________________________________
291 void AliEMCALTenderSupply::Init()
293 // Initialise EMCAL tender.
296 AliWarning("Init EMCAL Tender supply");
298 if (fConfigName.Length()>0 && gROOT->LoadMacro(fConfigName) >=0) {
299 AliDebug(1, Form("Loading settings from macro %s", fConfigName.Data()));
300 AliEMCALTenderSupply *tender = (AliEMCALTenderSupply*)gInterpreter->ProcessLine("ConfigEMCALTenderSupply()");
301 fDebugLevel = tender->fDebugLevel;
302 fEMCALGeoName = tender->fEMCALGeoName;
303 fEMCALRecoUtils = tender->fEMCALRecoUtils;
304 fConfigName = tender->fConfigName;
305 fNonLinearFunc = tender->fNonLinearFunc;
306 fNonLinearThreshold = tender->fNonLinearThreshold;
307 fReCalibCluster = tender->fReCalibCluster;
308 fUpdateCell = tender->fUpdateCell;
309 fRecalClusPos = tender->fRecalClusPos;
310 fCalibrateEnergy = tender->fCalibrateEnergy;
311 fCalibrateTime = tender->fCalibrateTime;
312 fFiducial = tender->fFiducial;
313 fNCellsFromEMCALBorder = tender->fNCellsFromEMCALBorder;
314 fRecalDistToBadChannels = tender->fRecalDistToBadChannels;
315 fRecalShowerShape = tender->fRecalShowerShape;
316 fClusterBadChannelCheck = tender->fClusterBadChannelCheck;
317 fBadCellRemove = tender->fBadCellRemove;
318 fRejectExoticCells = tender->fRejectExoticCells;
319 fRejectExoticClusters = tender->fRejectExoticClusters;
320 fMass = tender->fMass;
321 fStep = tender->fStep;
322 fCutEtaPhiSum = tender->fCutEtaPhiSum;
323 fCutEtaPhiSeparate = tender->fCutEtaPhiSeparate;
324 fRcut = tender->fRcut;
325 fEtacut = tender->fEtacut;
326 fPhicut = tender->fPhicut;
327 fReClusterize = tender->fReClusterize;
328 fLoadGeomMatrices = tender->fLoadGeomMatrices;
329 fRecParam = tender->fRecParam;
330 fDoNonLinearity = tender->fDoNonLinearity;
331 fDoTrackMatch = tender->fDoTrackMatch;
332 fDoUpdateOnly = tender->fDoUpdateOnly;
333 fMisalignSurvey = tender->fMisalignSurvey;
334 fExoticCellFraction = tender->fExoticCellFraction;
335 fExoticCellDiffTime = tender->fExoticCellDiffTime;
336 fExoticCellMinAmplitude = tender->fExoticCellMinAmplitude;
338 for(Int_t i = 0; i < 12; i++)
339 fEMCALMatrix[i] = tender->fEMCALMatrix[i] ;
343 AliInfo( "Emcal Tender settings: ======================================" );
344 AliInfo( "------------ Switches --------------------------" );
345 AliInfo( Form( "BadCellRemove : %d", fBadCellRemove ));
346 AliInfo( Form( "ExoticCellRemove : %d", fRejectExoticCells ));
347 AliInfo( Form( "CalibrateEnergy : %d", fCalibrateEnergy ));
348 AliInfo( Form( "CalibrateTime : %d", fCalibrateTime ));
349 AliInfo( Form( "UpdateCell : %d", fUpdateCell ));
350 AliInfo( Form( "DoUpdateOnly : %d", fDoUpdateOnly ));
351 AliInfo( Form( "Reclustering : %d", fReClusterize ));
352 AliInfo( Form( "ClusterBadChannelCheck : %d", fClusterBadChannelCheck ));
353 AliInfo( Form( "ClusterExoticChannelCheck : %d", fRejectExoticClusters ));
354 AliInfo( Form( "CellFiducialRegion : %d", fFiducial ));
355 AliInfo( Form( "ReCalibrateCluster : %d", fReCalibCluster ));
356 AliInfo( Form( "RecalculateClusPos : %d", fRecalClusPos ));
357 AliInfo( Form( "RecalShowerShape : %d", fRecalShowerShape ));
358 AliInfo( Form( "NonLinearityCorrection : %d", fDoNonLinearity ));
359 AliInfo( Form( "RecalDistBadChannel : %d", fRecalDistToBadChannels ));
360 AliInfo( Form( "TrackMatch : %d", fDoTrackMatch ));
361 AliInfo( "------------ Variables -------------------------" );
362 AliInfo( Form( "DebugLevel : %d", fDebugLevel ));
363 AliInfo( Form( "BasePath : %s", fBasePath.Data() ));
364 AliInfo( Form( "ConfigFileName : %s", fConfigName.Data() ));
365 AliInfo( Form( "EMCALGeometryName : %s", fEMCALGeoName.Data() ));
366 AliInfo( Form( "NonLinearityFunction : %d", fNonLinearFunc ));
367 AliInfo( Form( "NonLinearityThreshold : %d", fNonLinearThreshold ));
368 AliInfo( Form( "MisalignmentMatrixSurvey : %d", fMisalignSurvey ));
369 AliInfo( Form( "NumberOfCellsFromEMCALBorder : %d", fNCellsFromEMCALBorder ));
370 AliInfo( Form( "RCut : %f", fRcut ));
371 AliInfo( Form( "Mass : %f", fMass ));
372 AliInfo( Form( "Step : %f", fStep ));
373 AliInfo( Form( "EtaCut : %f", fEtacut ));
374 AliInfo( Form( "PhiCut : %f", fPhicut ));
375 AliInfo( Form( "ExoticCellFraction : %f", fExoticCellFraction ));
376 AliInfo( Form( "ExoticCellDiffTime : %f", fExoticCellDiffTime ));
377 AliInfo( Form( "ExoticCellMinAmplitude : %f", fExoticCellMinAmplitude ));
378 AliInfo( "=============================================================" );
384 fEMCALRecoUtils = new AliEMCALRecoUtils;
386 // init geometry if requested
387 if (fEMCALGeoName.Length()>0)
388 fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ;
391 fDigitsArr = new TClonesArray("AliEMCALDigit",1000);
393 // initialising non-linearity parameters
394 if( fNonLinearThreshold != -1 )
395 fEMCALRecoUtils->SetNonLinearityThreshold(fNonLinearThreshold);
396 if( fNonLinearFunc != -1 )
397 fEMCALRecoUtils->SetNonLinearityFunction(fNonLinearFunc);
399 // missalignment function
400 fEMCALRecoUtils->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);
403 // do not do the eta0 fiducial cut
404 if( fNCellsFromEMCALBorder != -1 )
405 fEMCALRecoUtils->SetNumberOfCellsFromEMCALBorder(fNCellsFromEMCALBorder);
406 fEMCALRecoUtils->SwitchOnNoFiducialBorderInEMCALEta0();
408 // exotic cell rejection
409 if( fExoticCellFraction != -1 )
410 fEMCALRecoUtils->SetExoticCellFractionCut( fExoticCellFraction );
411 if( fExoticCellDiffTime != -1 )
412 fEMCALRecoUtils->SetExoticCellDiffTimeCut( fExoticCellDiffTime );
413 if( fExoticCellMinAmplitude != -1 )
414 fEMCALRecoUtils->SetExoticCellMinAmplitudeCut( fExoticCellMinAmplitude );
416 // setting track matching parameters ... mass, step size and residual cut
418 fEMCALRecoUtils->SetMass(fMass);
420 fEMCALRecoUtils->SetStep(fStep);
422 // spatial cut based on separate eta/phi or common processing
424 fEMCALRecoUtils->SwitchOnCutEtaPhiSum();
426 fEMCALRecoUtils->SetCutR(fRcut);
427 } else if (fCutEtaPhiSeparate) {
428 fEMCALRecoUtils->SwitchOnCutEtaPhiSeparate();
430 fEMCALRecoUtils->SetCutEta(fEtacut);
432 fEMCALRecoUtils->SetCutPhi(fPhicut);
436 //_____________________________________________________
437 AliVEvent* AliEMCALTenderSupply::GetEvent()
439 // Return the event pointer.
442 return fTender->GetEvent();
445 return fTask->InputEvent();
451 //_____________________________________________________
452 void AliEMCALTenderSupply::ProcessEvent()
456 AliVEvent *event = GetEvent();
459 AliError("Event ptr = 0, returning");
463 // Initialising parameters once per run number
466 AliWarning( "Run changed, initializing parameters" );
467 fRun = event->GetRunNumber();
469 // init geometry if not already done
470 if (fEMCALGeoName.Length()==0) {
471 fEMCALGeoName = "EMCAL_FIRSTYEARV1";
473 fEMCALGeoName = "EMCAL_COMPLETEV1";
476 fEMCALGeoName = "EMCAL_COMPLETE12SMV1";
478 fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName);
480 AliFatal(Form("Can not create geometry: %s", fEMCALGeoName.Data()));
486 if (fGetPassFromFileName)
489 // define what recalib parameters are needed for various switches
490 // this is based on implementation in AliEMCALRecoUtils
491 Bool_t needRecoParam = fReClusterize;
492 Bool_t needBadChannels = fBadCellRemove | fClusterBadChannelCheck | fRecalDistToBadChannels | fReClusterize;
493 Bool_t needRecalib = fCalibrateEnergy | fReClusterize;
494 Bool_t needTimecalib = fCalibrateTime | fReClusterize;
495 Bool_t needMisalign = fRecalClusPos | fReClusterize;
496 Bool_t needClusterizer = fReClusterize;
498 // initiate reco params with some defaults
499 // will not overwrite, if those have been provided by user
501 Int_t initRC = InitRecParam();
504 AliInfo("Defaults reco params loaded.");
506 AliWarning("User defined reco params.");
510 if( needBadChannels ){
511 Int_t fInitBC = InitBadChannels();
513 AliError("InitBadChannels returned false, returning");
515 AliWarning("InitBadChannels OK");
517 AliWarning(Form("No external hot channel set: %d - %s", event->GetRunNumber(), fFilepass.Data()));
520 // init recalibration factors
523 Int_t fInitRecalib = InitRecalib();
525 AliError("InitRecalib returned false, returning");
527 AliWarning("InitRecalib OK");
529 AliWarning(Form("No recalibration available: %d - %s", event->GetRunNumber(), fFilepass.Data()));
531 Int_t fInitRunDepRecalib = InitRunDepRecalib();
532 if (fInitRunDepRecalib==0)
533 AliError("InitrunDepRecalib returned false, returning");
534 if (fInitRunDepRecalib==1)
535 AliWarning("InitRecalib OK");
536 if (fInitRunDepRecalib>1)
537 AliWarning(Form("No Temperature recalibration available: %d - %s", event->GetRunNumber(), fFilepass.Data()));
543 // init time calibration
545 Int_t initTC = InitTimeCalibration();
547 AliError("InitTimeCalibration returned false, returning");
549 AliWarning("InitTimeCalib OK");
551 AliWarning(Form("No external time calibration set: %d - %s", event->GetRunNumber(), fFilepass.Data()));
554 // init misalignment matrix
556 if (!InitMisalignMatrix())
557 AliError("InitMisalignmentMatrix returned false, returning");
559 AliWarning("InitMisalignMatrix OK");
563 if( needClusterizer ) {
564 if (!InitClusterization())
565 AliError("InitClusterization returned false, returning");
567 AliWarning("InitClusterization OK");
571 fEMCALRecoUtils->Print("");
574 // disable implied switches -------------------------------------------------
575 // AliEMCALRecoUtils or clusterizer functions alredy include some
576 // recalibration so based on those implied callibration te switches
577 // here are disabled to avoid duplication
579 // clusterizer does cluster energy recalibration, position recomputation
582 fReCalibCluster = kFALSE;
583 fRecalClusPos = kFALSE;
584 fRecalShowerShape = kFALSE;
587 // CONFIGURE THE RECO UTILS -------------------------------------------------
588 // configure the reco utils
589 // this option does energy recalibration
590 if( fCalibrateEnergy )
591 fEMCALRecoUtils->SwitchOnRecalibration();
593 fEMCALRecoUtils->SwitchOffRecalibration();
595 // allows time calibration
597 fEMCALRecoUtils->SwitchOnTimeRecalibration();
599 fEMCALRecoUtils->SwitchOffTimeRecalibration();
601 // allows to zero bad cells
603 fEMCALRecoUtils->SwitchOnBadChannelsRemoval();
605 fEMCALRecoUtils->SwitchOffBadChannelsRemoval();
607 // distance to bad channel recalibration
608 if( fRecalDistToBadChannels )
609 fEMCALRecoUtils->SwitchOnDistToBadChannelRecalculation();
611 fEMCALRecoUtils->SwitchOffDistToBadChannelRecalculation();
613 // exclude exotic cells
614 if( fRejectExoticCells )
615 fEMCALRecoUtils->SwitchOnRejectExoticCell();
617 fEMCALRecoUtils->SwitchOffRejectExoticCell();
619 // exclude clusters with exotic cells
620 if( fRejectExoticClusters )
621 fEMCALRecoUtils->SwitchOnRejectExoticCluster();
623 fEMCALRecoUtils->SwitchOffRejectExoticCluster();
625 // TODO: not implemented switches
626 // SwitchOnClusterEnergySmearing
627 // SwitchOnRunDepCorrection
629 // START PROCESSING ---------------------------------------------------------
630 // Test if cells present
631 AliVCaloCells *cells= event->GetEMCALCells();
632 if (cells->GetNumberOfCells()<=0)
635 AliWarning(Form("Number of EMCAL cells = %d, returning", cells->GetNumberOfCells()));
640 AliInfo(Form("Re-calibrate cluster %d\n",fReCalibCluster));
642 // mark the cells not recalibrated in case of selected
643 // time, energy recalibration or bad channel removal
644 if( fCalibrateEnergy || fCalibrateTime || fBadCellRemove )
645 fEMCALRecoUtils->ResetCellsCalibrated();
647 // CELL RECALIBRATION -------------------------------------------------------
648 // cell objects will be updated
649 // the cell calibrations are also processed locally any time those are needed
650 // in case that the cell objects are not to be updated here for later use
654 // includes exotic cell check in the UpdateCells function - is not provided
658 // switch off recalibrations so those are not done multiple times
659 // this is just for safety, the recalibrated flag of cell object
660 // should not allow for farther processing anyways
661 fEMCALRecoUtils->SwitchOffRecalibration();
662 fEMCALRecoUtils->SwitchOffTimeRecalibration();
668 // RECLUSTERIZATION ---------------------------------------------------------
676 // Store good clusters
677 TClonesArray *clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters"));
679 clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters"));
681 AliWarning(Form("No cluster array, number of cells in event = %d, returning", cells->GetNumberOfCells()));
685 // PROCESS SINGLE CLUSTER RECALIBRATION -------------------------------------
686 // now go through clusters one by one and process separate correction
687 // as those were defined or not
688 Int_t nclusters = clusArr->GetEntriesFast();
689 for (Int_t icluster=0; icluster < nclusters; ++icluster)
691 AliVCluster *clust = static_cast<AliVCluster*>(clusArr->At(icluster));
694 if (!clust->IsEMCAL())
697 // REMOVE CLUSTERS WITH BAD CELLS -----------------------------
698 if( fClusterBadChannelCheck )
700 // careful, the the ClusterContainsBadChannel is dependent on
701 // SwitchOnBadChannelsRemoval, switching it ON automatically
702 // and returning to original value after processing
703 Bool_t badRemoval = fEMCALRecoUtils->IsBadChannelsRemovalSwitchedOn();
704 fEMCALRecoUtils->SwitchOnBadChannelsRemoval();
706 Bool_t badResult = fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo, clust->GetCellsAbsId(), clust->GetNCells());
708 // switch the bad channels removal back
710 fEMCALRecoUtils->SwitchOffBadChannelsRemoval();
714 delete clusArr->RemoveAt(icluster);
715 continue; //TODO is it really needed to remove it? Or should we flag it?
719 // REMOVE EXOTIC CLUSTERS -------------------------------------
720 // does process local cell recalibration energy and time without replacing
721 // the global cell values, in case of no cell recalib done yet
722 if( fRejectExoticClusters )
724 // careful, the IsExoticCluster is dependent on
725 // SwitchOnRejectExoticCell, switching it ON automatically
726 // and returning to original value after processing
727 Bool_t exRemoval = fEMCALRecoUtils->IsRejectExoticCell();
728 fEMCALRecoUtils->SwitchOnRejectExoticCell();
730 // get bunch crossing
731 Int_t bunchCrossNo = event->GetBunchCrossNumber();
733 Bool_t exResult = fEMCALRecoUtils->IsExoticCluster(clust, cells, bunchCrossNo );
735 // switch the exotic channels removal back
737 fEMCALRecoUtils->SwitchOffRejectExoticCell();
741 delete clusArr->RemoveAt(icluster);
742 continue; //TODO is it really needed to remove it? Or should we flag it?
746 // FIDUCIAL CUT -----------------------------------------------
749 // depends on SetNumberOfCellsFromEMCALBorder
750 // SwitchOnNoFiducialBorderInEMCALEta0
751 if (!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, clust, cells)){
752 delete clusArr->RemoveAt(icluster);
753 continue; //TODO it would be nice to store the distance
757 // CLUSTER ENERGY ---------------------------------------------
758 // does process local cell recalibration energy and time without replacing
759 // the global cell values, in case of no cell recalib done yet
760 if( fReCalibCluster ) {
761 fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, clust, cells);
762 if (clust->E() < 1e-9) {
763 delete clusArr->RemoveAt(icluster);
768 // CLUSTER POSITION -------------------------------------------
769 // does process local cell energy recalibration, if enabled and cells
770 // not calibrated yet
772 fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, cells, clust);
774 // SHOWER SHAPE -----------------------------------------------
775 if( fRecalShowerShape )
776 fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, cells, clust);
778 // NONLINEARITY -----------------------------------------------
779 if( fDoNonLinearity )
781 Float_t correctedEnergy = fEMCALRecoUtils->CorrectClusterEnergyLinearity(clust);
782 clust->SetE(correctedEnergy);
785 // DISTANCE TO BAD CHANNELS -----------------------------------
786 if( fRecalDistToBadChannels )
787 fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, cells, clust);
795 // TRACK MATCHING -----------------------------------------------------------
796 if (!TGeoGlobalMagField::Instance()->GetField()) {
797 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event);
799 esd->InitMagneticField();
801 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(event);
802 Double_t curSol = 30000*aod->GetMagneticField()/5.00668;
803 Double_t curDip = 6000 *aod->GetMuonMagFieldScale();
804 AliMagF *field = AliMagF::CreateFieldMap(curSol,curDip);
805 TGeoGlobalMagField::Instance()->SetField(field);
809 fEMCALRecoUtils->FindMatches(event,0x0,fEMCALGeo);
810 fEMCALRecoUtils->SetClusterMatchedToTrack(event);
811 fEMCALRecoUtils->SetTracksMatchedToCluster(event);
814 //_____________________________________________________
815 Bool_t AliEMCALTenderSupply::InitMisalignMatrix()
817 // Initialising misalignment matrices
819 AliVEvent *event = GetEvent();
826 AliInfo("Misalignment matrix already set");
831 AliInfo("Initialising misalignment matrix");
833 if (fLoadGeomMatrices) {
834 for(Int_t mod=0; mod < fEMCALGeo->GetNumberOfSuperModules(); ++mod)
836 if (fEMCALMatrix[mod]){
838 fEMCALMatrix[mod]->Print();
839 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod);
842 fGeomMatrixSet = kTRUE;
846 Int_t runGM = event->GetRunNumber();
849 if(fMisalignSurvey == kdefault)
850 { //take default alignment corresponding to run no
851 AliOADBContainer emcalgeoCont(Form("emcal"));
852 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
853 mobj=(TObjArray*)emcalgeoCont.GetObject(runGM,"EmcalMatrices");
856 if(fMisalignSurvey == kSurveybyS)
857 { //take alignment at sector level
858 if (runGM <= 140000) { //2010 data
859 AliOADBContainer emcalgeoCont(Form("emcal2010"));
860 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
861 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10");
863 else if (runGM>140000)
864 { // 2011 LHC11a pass1 data
865 AliOADBContainer emcalgeoCont(Form("emcal2011"));
866 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
867 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byS");
871 if(fMisalignSurvey == kSurveybyM)
872 { //take alignment at module level
873 if (runGM <= 140000) { //2010 data
874 AliOADBContainer emcalgeoCont(Form("emcal2010"));
875 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
876 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10");
878 else if (runGM>140000)
879 { // 2011 LHC11a pass1 data
880 AliOADBContainer emcalgeoCont(Form("emcal2011"));
881 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
882 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byM");
888 AliFatal("Geometry matrix array not found");
892 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
894 fEMCALMatrix[mod] = (TGeoHMatrix*) mobj->At(mod);
895 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod);
896 fEMCALMatrix[mod]->Print();
902 //_____________________________________________________
903 Int_t AliEMCALTenderSupply::InitBadChannels()
905 // Initialising bad channel maps
907 AliVEvent *event = GetEvent();
913 AliInfo("Initialising Bad channel map");
915 // init default maps first
916 if( !fEMCALRecoUtils->GetEMCALBadChannelStatusMapArray() )
917 fEMCALRecoUtils->InitEMCALBadChannelStatusMap() ;
919 Int_t runBC = event->GetRunNumber();
921 AliOADBContainer *contBC = new AliOADBContainer("");
923 { //if fBasePath specified in the ->SetBasePath()
924 if (fDebugLevel>0) AliInfo(Form("Loading Bad Channels OADB from given path %s",fBasePath.Data()));
926 TFile *fbad=new TFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"read");
927 if (!fbad || fbad->IsZombie())
929 AliFatal(Form("EMCALBadChannels.root was not found in the path provided: %s",fBasePath.Data()));
933 if (fbad) delete fbad;
935 contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"AliEMCALBadChannels");
938 { // Else choose the one in the $ALICE_ROOT directory
939 if (fDebugLevel>0) AliInfo("Loading Bad Channels OADB from $ALICE_ROOT/OADB/EMCAL");
941 TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","read");
942 if (!fbad || fbad->IsZombie())
944 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root was not found");
948 if (fbad) delete fbad;
950 contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","AliEMCALBadChannels");
953 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
956 AliError(Form("No external hot channel set for run number: %d", runBC));
960 Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
961 for (Int_t i=0; i<sms; ++i)
963 TH2I *h = fEMCALRecoUtils->GetEMCALChannelStatusMap(i);
966 h=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
970 AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
974 fEMCALRecoUtils->SetEMCALChannelStatusMap(i,h);
979 //_____________________________________________________
980 Int_t AliEMCALTenderSupply::InitRecalib()
982 // Initialising recalibration factors.
984 AliVEvent *event = GetEvent();
990 AliInfo("Initialising recalibration factors");
992 // init default maps first
993 if( !fEMCALRecoUtils->GetEMCALRecalibrationFactorsArray() )
994 fEMCALRecoUtils->InitEMCALRecalibrationFactors() ;
996 Int_t runRC = event->GetRunNumber();
998 AliOADBContainer *contRF=new AliOADBContainer("");
1000 { //if fBasePath specified in the ->SetBasePath()
1001 if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data()));
1003 TFile *fRecalib= new TFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"read");
1004 if (!fRecalib || fRecalib->IsZombie())
1006 AliFatal(Form("EMCALRecalib.root not found in %s",fBasePath.Data()));
1010 if (fRecalib) delete fRecalib;
1012 contRF->InitFromFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"AliEMCALRecalib");
1015 { // Else choose the one in the $ALICE_ROOT directory
1016 if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL");
1018 TFile *fRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","read");
1019 if (!fRecalib || fRecalib->IsZombie())
1021 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root was not found");
1025 if (fRecalib) delete fRecalib;
1027 contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","AliEMCALRecalib");
1030 TObjArray *recal=(TObjArray*)contRF->GetObject(runRC);
1033 AliError(Form("No Objects for run: %d",runRC));
1037 TObjArray *recalpass=(TObjArray*)recal->FindObject(fFilepass);
1040 AliError(Form("No Objects for run: %d - %s",runRC,fFilepass.Data()));
1044 TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
1047 AliError(Form("No Recalib histos found for %d - %s",runRC,fFilepass.Data()));
1051 if (fDebugLevel>0) recalib->Print();
1053 Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
1054 for (Int_t i=0; i<sms; ++i)
1056 TH2F *h = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactors(i);
1059 h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
1062 AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
1066 fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
1071 //_____________________________________________________
1072 Int_t AliEMCALTenderSupply::InitRunDepRecalib()
1074 // Initialising recalibration factors.
1076 AliVEvent *event = GetEvent();
1082 AliInfo("Initialising recalibration factors");
1084 // init default maps first
1085 if( !fEMCALRecoUtils->GetEMCALRecalibrationFactorsArray() )
1086 fEMCALRecoUtils->InitEMCALRecalibrationFactors() ;
1088 Int_t runRC = event->GetRunNumber();
1090 AliOADBContainer *contRF=new AliOADBContainer("");
1092 { //if fBasePath specified in the ->SetBasePath()
1093 if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data()));
1095 TFile *fRunDepRecalib= new TFile(Form("%s/EMCALTemperatureCorrCalib.root",fBasePath.Data()),"read");
1096 if (!fRunDepRecalib || fRunDepRecalib->IsZombie())
1098 AliFatal(Form("EMCALTemperatureCorrCalib.root not found in %s",fBasePath.Data()));
1102 if (fRunDepRecalib) delete fRunDepRecalib;
1104 contRF->InitFromFile(Form("%s/EMCALTemperatureCorrCalib.root",fBasePath.Data()),"AliEMCALRunDepTempCalibCorrections");
1107 { // Else choose the one in the $ALICE_ROOT directory
1108 if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL");
1110 TFile *fRunDepRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root","read");
1111 if (!fRunDepRecalib || fRunDepRecalib->IsZombie())
1113 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root was not found");
1117 if (fRunDepRecalib) delete fRunDepRecalib;
1119 contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root","AliEMCALRunDepTempCalibCorrections");
1122 TH1S *rundeprecal=(TH1S*)contRF->GetObject(runRC);
1125 AliWarning(Form("No TemperatureCorrCalib Objects for run: %d",runRC));
1126 // let's get the closest runnumber instead then..
1129 Int_t maxEntry = contRF->GetNumberOfEntries();
1131 while ( (ic < maxEntry) && (contRF->UpperLimit(ic) < runRC) ) {
1136 Int_t closest = lower;
1137 if ( (ic<maxEntry) &&
1138 (contRF->LowerLimit(ic)-runRC) < (runRC - contRF->UpperLimit(lower)) ) {
1142 AliWarning(Form("TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRF->LowerLimit(closest)));
1143 rundeprecal = (TH1S*) contRF->GetObjectByIndex(closest);
1146 if (fDebugLevel>0) rundeprecal->Print();
1148 Int_t nSM = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
1150 for (Int_t ism=0; ism<nSM; ++ism)
1152 for (Int_t icol=0; icol<48; ++icol)
1154 for (Int_t irow=0; irow<24; ++irow)
1156 Float_t factor = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(ism,icol,irow);
1158 Int_t absID = fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol); // original calibration factor
1159 factor *= rundeprecal->GetBinContent(absID) / 10000. ; // correction dependent on T
1161 fEMCALRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
1170 //_____________________________________________________
1171 Int_t AliEMCALTenderSupply::InitTimeCalibration()
1173 // Initialising bad channel maps
1174 AliVEvent *event = GetEvent();
1180 AliInfo("Initialising time calibration map");
1182 // init default maps first
1183 if ( !fEMCALRecoUtils->GetEMCALTimeRecalibrationFactorsArray() )
1184 fEMCALRecoUtils->InitEMCALTimeRecalibrationFactors() ;
1186 Int_t runBC = event->GetRunNumber();
1188 AliOADBContainer *contBC = new AliOADBContainer("");
1190 { //if fBasePath specified in the ->SetBasePath()
1191 if (fDebugLevel>0) AliInfo(Form("Loading time calibration OADB from given path %s",fBasePath.Data()));
1193 TFile *fbad=new TFile(Form("%s/EMCALTimeCalib.root",fBasePath.Data()),"read");
1194 if (!fbad || fbad->IsZombie())
1196 AliFatal(Form("EMCALTimeCalib.root was not found in the path provided: %s",fBasePath.Data()));
1200 if (fbad) delete fbad;
1202 contBC->InitFromFile(Form("%s/EMCALTimeCalib.root",fBasePath.Data()),"AliEMCALTimeCalib");
1205 { // Else choose the one in the $ALICE_ROOT directory
1206 if (fDebugLevel>0) AliInfo("Loading time calibration OADB from $ALICE_ROOT/OADB/EMCAL");
1208 TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root","read");
1209 if (!fbad || fbad->IsZombie())
1211 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root was not found");
1215 if (fbad) delete fbad;
1217 contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root","AliEMCALTimeCalib");
1220 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
1223 AliError(Form("No external time calibration set for run number: %d", runBC));
1227 // Here, it looks for a specific pass
1228 TObjArray *arrayBCpass=(TObjArray*)arrayBC->FindObject(fFilepass);
1231 AliError(Form("No external time calibration set for: %d -%s", runBC,fFilepass.Data()));
1235 if (fDebugLevel>0) arrayBCpass->Print();
1237 for( Int_t i = 0; i < 4; i++ )
1239 TH1F *h = fEMCALRecoUtils->GetEMCALChannelTimeRecalibrationFactors( i );
1243 h = (TH1F*)arrayBCpass->FindObject(Form("hAllTimeAvBC%d",i));
1247 AliError(Form("Can not get hAllTimeAvBC%d",i));
1251 fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactors(i,h);
1256 //_____________________________________________________
1257 void AliEMCALTenderSupply::UpdateCells()
1259 //Remove bad cells from the cell list
1260 //Recalibrate energy and time cells
1261 //This is required for later reclusterization
1263 AliVEvent *event = GetEvent();
1267 AliVCaloCells *cells = event->GetEMCALCells();
1268 Int_t bunchCrossNo = event->GetBunchCrossNumber();
1270 fEMCALRecoUtils->RecalibrateCells(cells, bunchCrossNo);
1272 // remove exotic cells - loop through cells and zero the exotic ones
1273 // just like with bad cell rejection in reco utils (inside RecalibrateCells)
1274 if( fRejectExoticCells )
1281 Bool_t isExot = kFALSE;
1283 // loop through cells
1284 Int_t nEMcell = cells->GetNumberOfCells() ;
1285 for (Int_t iCell = 0; iCell < nEMcell; iCell++)
1287 cells->GetCell( iCell, absId, ecell, tcell, mclabel, efrac );
1289 isExot = fEMCALRecoUtils->IsExoticCell( absId, cells, bunchCrossNo );
1292 cells->SetCell( iCell, absId, 0.0, -1.0, mclabel, efrac );
1294 } // reject exotic cells
1299 //_____________________________________________________
1300 TString AliEMCALTenderSupply::GetBeamType()
1302 // Get beam type : pp-AA-pA
1303 // ESDs have it directly, AODs get it from hardcoded run number ranges
1305 AliVEvent *event = GetEvent();
1308 AliError("Couldn't retrieve event!");
1314 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event);
1316 const AliESDRun *run = esd->GetESDRun();
1317 beamType = run->GetBeamType();
1321 Int_t runNumber = event->GetRunNumber();
1322 if ((runNumber >= 136851 && runNumber <= 139517) // LHC10h
1323 || (runNumber >= 166529 && runNumber <= 170593)) // LHC11h
1336 //_____________________________________________________
1337 Int_t AliEMCALTenderSupply::InitRecParam()
1339 // Init reco params if not yet exist (probably shipped by the user already)
1341 if( fRecParam != 0 )
1344 TString beamType = GetBeamType();
1346 // set some default reco params
1347 fRecParam = new AliEMCALRecParam();
1348 fRecParam->SetClusteringThreshold(0.100);
1349 fRecParam->SetMinECut(0.050);
1350 fRecParam->SetTimeCut(250);
1351 fRecParam->SetTimeMin(425);
1352 fRecParam->SetTimeMax(825);
1353 if ( beamType == "A-A") {
1354 fRecParam->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv2);
1357 fRecParam->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv1);
1363 //_____________________________________________________
1364 Bool_t AliEMCALTenderSupply::InitClusterization()
1366 // Initialing clusterization/unfolding algorithm and set all the needed parameters.
1368 AliVEvent *event = GetEvent();
1374 AliInfo(Form("Initialising reclustering parameters: Clusterizer type: %d",fRecParam->GetClusterizerFlag()));
1376 //---setup clusterizer
1378 // avoid deleting fDigitsArr
1379 fClusterizer->SetDigitsArr(0);
1380 delete fClusterizer;
1383 if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1384 fClusterizer = new AliEMCALClusterizerv1 (fEMCALGeo);
1385 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1386 fClusterizer = new AliEMCALClusterizerv2(fEMCALGeo);
1387 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
1389 AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(fEMCALGeo);
1390 clusterizer->SetNRowDiff(fRecParam->GetNRowDiff());
1391 clusterizer->SetNColDiff(fRecParam->GetNColDiff());
1392 fClusterizer = clusterizer;
1396 AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
1400 // Set the clustering parameters
1401 fClusterizer->SetECAClusteringThreshold( fRecParam->GetClusteringThreshold() );
1402 fClusterizer->SetECALogWeight ( fRecParam->GetW0() );
1403 fClusterizer->SetMinECut ( fRecParam->GetMinECut() );
1404 fClusterizer->SetUnfolding ( fRecParam->GetUnfold() );
1405 fClusterizer->SetECALocalMaxCut ( fRecParam->GetLocMaxCut() );
1406 fClusterizer->SetTimeCut ( fRecParam->GetTimeCut() );
1407 fClusterizer->SetTimeMin ( fRecParam->GetTimeMin() );
1408 fClusterizer->SetTimeMax ( fRecParam->GetTimeMax() );
1409 fClusterizer->SetInputCalibrated ( kTRUE );
1410 fClusterizer->SetJustClusters ( kTRUE );
1412 // In case of unfolding after clusterization is requested, set the corresponding parameters
1413 if (fRecParam->GetUnfold())
1415 for (Int_t i = 0; i < 8; ++i)
1417 fClusterizer->SetSSPars(i, fRecParam->GetSSPars(i));
1419 for (Int_t i = 0; i < 3; ++i)
1421 fClusterizer->SetPar5 (i, fRecParam->GetPar5(i));
1422 fClusterizer->SetPar6 (i, fRecParam->GetPar6(i));
1424 fClusterizer->InitClusterUnfolding();
1427 fClusterizer->SetDigitsArr(fDigitsArr);
1428 fClusterizer->SetOutput(0);
1429 fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
1433 //_____________________________________________________
1434 void AliEMCALTenderSupply::FillDigitsArray()
1436 // Fill digits from cells to a TClonesArray.
1438 AliVEvent *event = GetEvent();
1443 // In case of MC productions done before aliroot tag v5-02-Rev09
1444 // assing the cluster label to all the cells belonging to this cluster
1446 Int_t cellLabels[12672];
1447 if(fSetCellMCLabelFromCluster)
1449 for (Int_t i = 0; i < 12672; i++)
1451 cellLabels [i] = 0 ;
1452 fOrgClusterCellId[i] =-1 ;
1455 Int_t nClusters = event->GetNumberOfCaloClusters();
1456 for (Int_t i = 0; i < nClusters; i++)
1458 AliVCluster *clus = event->GetCaloCluster(i);
1462 if(!clus->IsEMCAL()) continue ;
1464 Int_t label = clus->GetLabel();
1465 UShort_t * index = clus->GetCellsAbsId() ;
1467 for(Int_t icell=0; icell < clus->GetNCells(); icell++ )
1469 cellLabels [index[icell]] = label;
1470 fOrgClusterCellId[index[icell]] = i ; // index of the original cluster
1475 fDigitsArr->Clear("C");
1476 AliVCaloCells *cells = event->GetEMCALCells();
1477 Int_t ncells = cells->GetNumberOfCells();
1478 for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell)
1480 Double_t cellAmplitude=0, cellTime=0, efrac = 0;
1481 Short_t cellNumber=0;
1484 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, mcLabel, efrac) != kTRUE)
1487 // Do not add if energy already too low (some cells set to 0 if bad channels)
1488 if (cellAmplitude < fRecParam->GetMinECut())
1491 // If requested, do not include exotic cells
1492 if (fEMCALRecoUtils->IsExoticCell(cellNumber,cells,event->GetBunchCrossNumber()))
1495 if ( fSetCellMCLabelFromCluster ) mcLabel = cellLabels[cellNumber];
1496 else if( fRemapMCLabelForAODs ) RemapMCLabelForAODs(mcLabel);
1498 if (mcLabel > 0 && efrac < 1e-6) efrac = 1;
1500 new((*fDigitsArr)[idigit]) AliEMCALDigit(mcLabel, mcLabel, cellNumber,
1501 (Float_t)cellAmplitude, (Float_t)cellTime,
1502 AliEMCALDigit::kHG,idigit, 0, 0, efrac*cellAmplitude);
1507 //_____________________________________________________
1508 void AliEMCALTenderSupply::Clusterize()
1512 fClusterizer->Digits2Clusters("");
1515 //_____________________________________________________
1516 void AliEMCALTenderSupply::UpdateClusters()
1518 // Update ESD cluster list.
1520 AliVEvent *event = GetEvent();
1525 TClonesArray *clus = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters"));
1527 clus = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters"));
1530 AliError(" Null pointer to calo clusters array, returning");
1534 // Before destroying the orignal list, assign to the rec points the MC labels
1535 // of the original clusters, if requested
1536 if( fSetCellMCLabelFromCluster == 2 ) SetClustersMCLabelFromOriginalClusters() ;
1538 Int_t nents = clus->GetEntriesFast();
1539 for (Int_t i=0; i < nents; ++i)
1541 AliVCluster *c = dynamic_cast<AliVCluster*>(clus->At(i));
1546 delete clus->RemoveAt(i);
1552 RecPoints2Clusters(clus);
1555 //_____________________________________________________
1556 void AliEMCALTenderSupply::RecPoints2Clusters(TClonesArray *clus)
1558 // Convert AliEMCALRecoPoints to AliESDCaloClusters/AliAODCaloClusters.
1559 // Cluster energy, global position, cells and their amplitude fractions are restored.
1561 AliVEvent *event = GetEvent();
1566 Int_t ncls = fClusterArr->GetEntriesFast();
1567 for(Int_t i=0, nout=clus->GetEntriesFast(); i < ncls; ++i)
1569 AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
1571 Int_t ncellsTrue = 0;
1572 const Int_t ncells = recpoint->GetMultiplicity();
1573 UShort_t absIds[ncells];
1574 Double32_t ratios[ncells];
1575 Int_t *dlist = recpoint->GetDigitsList();
1576 Float_t *elist = recpoint->GetEnergiesList();
1577 for (Int_t c = 0; c < ncells; ++c)
1579 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c]));
1580 absIds[ncellsTrue] = digit->GetId();
1581 ratios[ncellsTrue] = elist[c]/digit->GetAmplitude();
1582 if (ratios[ncellsTrue] < 0.001)
1589 AliWarning("Skipping cluster with no cells");
1593 // calculate new cluster position
1595 recpoint->GetGlobalPosition(gpos);
1599 AliVCluster *c = static_cast<AliVCluster*>(clus->New(nout++));
1601 c->SetType(AliVCluster::kEMCALClusterv1);
1602 c->SetE(recpoint->GetEnergy());
1604 c->SetNCells(ncellsTrue);
1605 c->SetDispersion(recpoint->GetDispersion());
1606 c->SetEmcCpvDistance(-1); //not yet implemented
1607 c->SetChi2(-1); //not yet implemented
1608 c->SetTOF(recpoint->GetTime()) ; //time-of-flight
1609 c->SetNExMax(recpoint->GetNExMax()); //number of local maxima
1610 Float_t elipAxis[2];
1611 recpoint->GetElipsAxis(elipAxis);
1612 c->SetM02(elipAxis[0]*elipAxis[0]) ;
1613 c->SetM20(elipAxis[1]*elipAxis[1]) ;
1614 c->SetCellsAbsId(absIds);
1615 c->SetCellsAmplitudeFraction(ratios);
1618 Int_t parentMult = 0;
1619 Int_t *parentList = recpoint->GetParents(parentMult);
1620 if (parentMult > 0) c->SetLabel(parentList, parentMult);
1625 //___________________________________________________________
1626 void AliEMCALTenderSupply::RemapMCLabelForAODs(Int_t & label)
1628 // MC label for Cells not remapped after ESD filtering, do it here.
1630 if(label < 0) return ;
1632 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (GetEvent()) ;
1635 TClonesArray * arr = dynamic_cast<TClonesArray*>(evt->FindListObject("mcparticles")) ;
1638 if(label < arr->GetEntriesFast())
1640 AliAODMCParticle * particle = dynamic_cast<AliAODMCParticle *>(arr->At(label));
1641 if(!particle) return ;
1643 if(label == particle->Label()) return ; // label already OK
1646 // loop on the particles list and check if there is one with the same label
1647 for(Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
1649 AliAODMCParticle * particle = dynamic_cast<AliAODMCParticle *>(arr->At(ind));
1650 if(!particle) continue ;
1652 if(label == particle->Label())
1663 //_____________________________________________________________________________________________
1664 void AliEMCALTenderSupply::SetClustersMCLabelFromOriginalClusters()
1666 // Get the original clusters that contribute to the new rec point cluster,
1667 // assign the labels of such clusters to the new rec point cluster.
1668 // Only approximatedly valid when output are V1 clusters, or input/output clusterizer
1669 // are the same handle with care
1670 // Copy from same method in AliAnalysisTaskEMCALClusterize, but here modify the recpoint and
1671 // not the output calocluster
1673 Int_t ncls = fClusterArr->GetEntriesFast();
1674 for(Int_t irp=0; irp < ncls; ++irp)
1676 TArrayI clArray(300) ; //Weird if more than a few clusters are in the origin ...
1679 Int_t nLabTotOrg = 0;
1683 AliEMCALRecPoint *clus = static_cast<AliEMCALRecPoint*>(fClusterArr->At(irp));
1685 //Find the clusters that originally had the cells
1686 const Int_t ncells = clus->GetMultiplicity();
1687 Int_t *digList = clus->GetDigitsList();
1689 for ( Int_t iLoopCell = 0 ; iLoopCell < ncells ; iLoopCell++ )
1691 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(digList[iLoopCell]));
1692 Int_t idCell = digit->GetId();
1696 Int_t idCluster = fOrgClusterCellId[idCell];
1698 for(Int_t icl =0; icl < nClu; icl++)
1700 if(((Int_t)clArray.GetAt(icl))==-1 ) continue;
1701 if( idCluster == ((Int_t)clArray.GetAt(icl)) ) set = kFALSE;
1703 if( set && idCluster >= 0)
1705 clArray.SetAt(idCluster,nClu++);
1706 nLabTotOrg+=(GetEvent()->GetCaloCluster(idCluster))->GetNLabels();
1708 //Search highest E cluster
1709 AliVCluster * clOrg = GetEvent()->GetCaloCluster(idCluster);
1710 if(emax < clOrg->E())
1719 // Put the first in the list the cluster with highest energy
1720 if(idMax != ((Int_t)clArray.GetAt(0))) // Max not at first position
1722 Int_t maxIndex = -1;
1723 Int_t firstCluster = ((Int_t)clArray.GetAt(0));
1724 for ( Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1726 if(idMax == ((Int_t)clArray.GetAt(iLoopCluster))) maxIndex = iLoopCluster;
1729 if(firstCluster >=0 && idMax >=0)
1731 clArray.SetAt(idMax,0);
1732 clArray.SetAt(firstCluster,maxIndex);
1736 // Get the labels list in the original clusters, assign all to the new cluster
1737 TArrayI clMCArray(nLabTotOrg) ;
1741 for ( Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1743 Int_t idCluster = (Int_t) clArray.GetAt(iLoopCluster);
1744 AliVCluster * clOrg = GetEvent()->GetCaloCluster(idCluster);
1745 Int_t nLab = clOrg->GetNLabels();
1747 for ( Int_t iLab = 0 ; iLab < nLab ; iLab++ )
1749 Int_t lab = clOrg->GetLabelAt(iLab) ;
1753 for(Int_t iLabTot =0; iLabTot < nLabTot; iLabTot++)
1755 if( lab == ((Int_t)clMCArray.GetAt(iLabTot)) ) set = kFALSE;
1757 if( set ) clMCArray.SetAt(lab,nLabTot++);
1762 // Set the final list of labels to rec point
1764 Int_t *labels = new Int_t[nLabTot];
1765 for(Int_t il = 0; il < nLabTot; il++) labels[il] = clMCArray.GetArray()[il];
1766 clus->SetParents(nLabTot,labels);
1768 } // rec point array
1772 //_____________________________________________________
1773 void AliEMCALTenderSupply::GetPass()
1775 // Get passx from filename
1777 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1778 fInputTree = mgr->GetTree();
1782 AliError("Pointer to tree = 0, returning");
1786 fInputFile = fInputTree->GetCurrentFile();
1788 AliError("Null pointer input file, returning");
1792 TString fname(fInputFile->GetName());
1793 if (fname.Contains("pass1")) fFilepass = TString("pass1");
1794 else if (fname.Contains("pass2")) fFilepass = TString("pass2");
1795 else if (fname.Contains("pass3")) fFilepass = TString("pass3");
1796 else if (fname.Contains("pass4")) fFilepass = TString("pass4");
1797 else if (fname.Contains("pass5")) fFilepass = TString("pass5");
1798 else if (fname.Contains("calo") || fname.Contains("high_lumi"))
1801 //printf("AliEMCALTenderSupply::GetPass() - Path contains <calo> or <high-lumi>, set as <pass1>\n");
1802 fFilepass = TString("pass1");
1806 AliError(Form("Pass number string not found: %s", fname.Data()));