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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // EMCAL tender, apply corrections to EMCAl clusters //
20 // and do track matching. //
21 // Author: Deepa Thomas (Utrecht University) //
23 ///////////////////////////////////////////////////////////////////////////////
28 #include <TInterpreter.h>
29 #include <TObjArray.h>
30 #include <TClonesArray.h>
31 #include <TGeoGlobalMagField.h>
33 #include <AliESDEvent.h>
34 #include <AliAnalysisManager.h>
35 #include <AliTender.h>
36 #include "AliOADBContainer.h"
37 #include "AliCDBManager.h"
38 #include "AliCDBStorage.h"
39 #include "AliCDBEntry.h"
41 #include "AliESDCaloCluster.h"
42 #include "AliEMCALTenderSupply.h"
43 #include "AliEMCALGeometry.h"
44 #include "AliEMCALRecoUtils.h"
45 #include "AliEMCALClusterizer.h"
46 #include "AliEMCALRecParam.h"
47 #include "AliEMCALRecPoint.h"
48 #include "AliEMCALAfterBurnerUF.h"
49 #include "AliEMCALClusterizerNxN.h"
50 #include "AliEMCALClusterizerv1.h"
51 #include "AliEMCALClusterizerv2.h"
52 #include "AliEMCALDigit.h"
53 #include "AliEMCALRecParam.h"
55 ClassImp(AliEMCALTenderSupply)
57 AliEMCALTenderSupply::AliEMCALTenderSupply() :
60 ,fEMCALGeoName("EMCAL_COMPLETEV1")
64 ,fNonLinearFunc(AliEMCALRecoUtils::kNoCorrection)
65 ,fNonLinearThreshold(30)
66 ,fReCalibCluster(kFALSE)
68 ,fRecalClusPos(kFALSE)
70 ,fNCellsFromEMCALBorder(1)
71 ,fRecalDistToBadChannels(kFALSE)
78 ,fCutEtaPhiSeparate(kFALSE)
83 ,fReClusterize(kFALSE)
85 ,fGeomMatrixSet(kFALSE)
86 ,fLoadGeomMatrices(kFALSE)
89 ,fDoUpdateOnly(kFALSE)
93 ,fMisalignSurvey(kdefault)
95 // Default constructor.
96 for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ;
99 //_____________________________________________________
100 AliEMCALTenderSupply::AliEMCALTenderSupply(const char *name, const AliTender *tender) :
101 AliTenderSupply(name,tender)
103 ,fEMCALGeoName("EMCAL_COMPLETEV1")
107 ,fNonLinearFunc(AliEMCALRecoUtils::kNoCorrection)
108 ,fNonLinearThreshold(30)
109 ,fReCalibCluster(kFALSE)
111 ,fRecalClusPos(kFALSE)
113 ,fNCellsFromEMCALBorder(1)
114 ,fRecalDistToBadChannels(kFALSE)
120 ,fCutEtaPhiSum(kTRUE)
121 ,fCutEtaPhiSeparate(kFALSE)
126 ,fReClusterize(kFALSE)
128 ,fGeomMatrixSet(kFALSE)
129 ,fLoadGeomMatrices(kFALSE)
131 ,fDoTrackMatch(kTRUE)
132 ,fDoUpdateOnly(kFALSE)
136 ,fMisalignSurvey(kdefault)
140 for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ;
141 fEMCALRecoUtils = new AliEMCALRecoUtils;
142 fDigitsArr = new TClonesArray("AliEMCALDigit",1000);
145 //_____________________________________________________
146 AliEMCALTenderSupply::~AliEMCALTenderSupply()
150 delete fEMCALRecoUtils;
155 fDigitsArr->Clear("C");
160 //_____________________________________________________
161 void AliEMCALTenderSupply::Init()
163 // Initialise EMCAL tender.
166 AliInfo("Init EMCAL Tender supply");
168 if (fConfigName.Length()>0 && gROOT->LoadMacro(fConfigName) >=0) {
169 AliDebug(1, Form("Loading settings from macro %s", fConfigName.Data()));
170 AliEMCALTenderSupply *tender = (AliEMCALTenderSupply*)gInterpreter->ProcessLine("ConfigEMCALTenderSupply()");
171 fDebugLevel = tender->fDebugLevel;
172 fEMCALGeoName = tender->fEMCALGeoName;
173 fEMCALRecoUtils = tender->fEMCALRecoUtils;
174 fConfigName = tender->fConfigName;
175 fNonLinearFunc = tender->fNonLinearFunc;
176 fNonLinearThreshold = tender->fNonLinearThreshold;
177 fReCalibCluster = tender->fReCalibCluster;
178 fRecalClusPos = tender->fRecalClusPos;
179 fFiducial = tender->fFiducial;
180 fNCellsFromEMCALBorder = tender->fNCellsFromEMCALBorder;
181 fRecalDistToBadChannels = tender->fRecalDistToBadChannels;
182 fMass = tender->fMass;
183 fStep = tender->fStep;
184 fRcut = tender->fRcut;
185 fEtacut = tender->fEtacut;
186 fPhicut = tender->fPhicut;
187 fReClusterize = tender->fReClusterize;
188 fLoadGeomMatrices = tender->fLoadGeomMatrices;
189 fRecParam = tender->fRecParam;
190 for(Int_t i = 0; i < 10; i++)
191 fEMCALMatrix[i] = tender->fEMCALMatrix[i] ;
195 fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ;
197 // Initialising non-linearity parameters
198 fEMCALRecoUtils->SetNonLinearityThreshold(fNonLinearThreshold);
199 fEMCALRecoUtils->SetNonLinearityFunction(fNonLinearFunc);
201 // Setting mass, step size and residual cut
202 fEMCALRecoUtils->SetMass(fMass);
203 fEMCALRecoUtils->SetStep(fStep);
205 fEMCALRecoUtils->SwitchOnCutEtaPhiSum();
206 fEMCALRecoUtils->SetCutR(fRcut);
207 } else if (fCutEtaPhiSeparate) {
208 fEMCALRecoUtils->SwitchOnCutEtaPhiSeparate();
209 fEMCALRecoUtils->SetCutEta(fEtacut);
210 fEMCALRecoUtils->SetCutPhi(fPhicut);
214 //_____________________________________________________
215 void AliEMCALTenderSupply::ProcessEvent()
219 AliESDEvent *event = fTender->GetEvent();
221 AliError("ESD event ptr = 0, returning");
225 // Initialising parameters once per run number
226 if (fTender->RunChanged()){
234 Int_t fInitBC = InitBadChannels();
237 AliError("InitBadChannels returned false, returning");
243 AliInfo(Form("No external hot channel set: %d - %s", event->GetRunNumber(), fFilepass.Data()));
249 if (fReCalibCluster || fUpdateCell) {
250 Int_t fInitRecalib = InitRecalib();
253 AliError("InitRecalib returned false, returning");
258 AliInfo(Form("No recalibration available: %d - %s", event->GetRunNumber(), fFilepass.Data()));
259 fReCalibCluster = kFALSE;
263 if (fRecalClusPos || fReClusterize || fUpdateCell) {
264 if (!InitMisalignMatrix()) {
265 AliError("InitMisalignmentMatrix returned false, returning");
270 if (fReClusterize || fUpdateCell) {
271 if (!InitClusterization()) {
272 AliError("InitClusterization returned false, returning");
278 fEMCALRecoUtils->Print("");
281 // Test if cells present
282 AliESDCaloCells *cells= event->GetEMCALCells();
283 if (cells->GetNumberOfCells()<=0) {
285 AliWarning(Form("Number of EMCAL cells = %d, returning", cells->GetNumberOfCells()));
290 AliInfo(Form("Re-calibrate cluster %d\n",fReCalibCluster));
298 fReClusterize = kTRUE;
304 fRecalClusPos = kFALSE; // Done in reclusterization, do nothing
305 fReCalibCluster= kFALSE; // Done in reclusterization, do nothing
311 // Store good clusters
312 TClonesArray *clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters"));
314 clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters"));
316 AliWarning(Form("No cluster array, number of cells in event = %d, returning", cells->GetNumberOfCells()));
320 Int_t nclusters = clusArr->GetEntriesFast();
321 for (Int_t icluster=0; icluster < nclusters; ++icluster) {
322 AliVCluster *clust = static_cast<AliVCluster*>(clusArr->At(icluster));
325 if (!clust->IsEMCAL())
327 if (fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo, clust->GetCellsAbsId(), clust->GetNCells())) {
328 delete clusArr->RemoveAt(icluster);
329 continue; //todo is it really needed to remove it? Or should we flag it?
333 if (!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, clust, cells)){
334 delete clusArr->RemoveAt(icluster);
335 continue; // todo it would be nice to store the distance
339 if(fRecalDistToBadChannels)
340 fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, cells, clust);
342 fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, clust, cells);
344 fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, cells, clust);
346 Float_t correctedEnergy = fEMCALRecoUtils->CorrectClusterEnergyLinearity(clust);
347 clust->SetE(correctedEnergy);
356 if (!TGeoGlobalMagField::Instance()->GetField()) {
357 const AliESDRun *erun = event->GetESDRun();
358 AliMagF *field = AliMagF::CreateFieldMap(erun->GetCurrentL3(),
359 erun->GetCurrentDip(),
362 erun->GetBeamEnergy(),
363 erun->GetBeamType());
364 TGeoGlobalMagField::Instance()->SetField(field);
367 fEMCALRecoUtils->FindMatches(event,0x0,fEMCALGeo);
368 fEMCALRecoUtils->SetClusterMatchedToTrack(event);
369 fEMCALRecoUtils->SetTracksMatchedToCluster(event);
372 //_____________________________________________________
373 Bool_t AliEMCALTenderSupply::InitMisalignMatrix()
375 // Initialising misalignment matrices
377 AliESDEvent *event = fTender->GetEvent();
381 if (fGeomMatrixSet) {
382 AliInfo("Misalignment matrix already set");
387 AliInfo("Initialising misalignment matrix");
389 fEMCALRecoUtils->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);
391 if (fLoadGeomMatrices) {
392 for(Int_t mod=0; mod < fEMCALGeo->GetNumberOfSuperModules(); ++mod) {
393 if (fEMCALMatrix[mod]){
395 fEMCALMatrix[mod]->Print();
396 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod);
399 fGeomMatrixSet = kTRUE;
403 Int_t runGM = event->GetRunNumber();
406 if(fMisalignSurvey == kdefault){ //take default alignment corresponding to run no
407 AliOADBContainer emcalgeoCont(Form("emcal"));
408 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
409 mobj=(TObjArray*)emcalgeoCont.GetObject(runGM,"EmcalMatrices");
412 if(fMisalignSurvey == kSurveybyS){ //take alignment at sector level
413 if (runGM <= 140000) { //2010 data
414 AliOADBContainer emcalgeoCont(Form("emcal2010"));
415 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
416 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10");
418 } else if (runGM>140000) { // 2011 LHC11a pass1 data
419 AliOADBContainer emcalgeoCont(Form("emcal2011"));
420 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
421 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byS");
425 if(fMisalignSurvey == kSurveybyM){ //take alignment at module level
426 if (runGM <= 140000) { //2010 data
427 AliOADBContainer emcalgeoCont(Form("emcal2010"));
428 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
429 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10");
431 } else if (runGM>140000) { // 2011 LHC11a pass1 data
433 AliOADBContainer emcalgeoCont(Form("emcal2011"));
434 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
435 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byM");
440 AliFatal("Geometry matrix array not found");
444 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
445 fEMCALMatrix[mod] = (TGeoHMatrix*) mobj->At(mod);
446 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod);
447 fEMCALMatrix[mod]->Print();
453 //_____________________________________________________
454 Int_t AliEMCALTenderSupply::InitBadChannels()
456 // Initialising bad channel maps
457 AliESDEvent *event = fTender->GetEvent();
462 AliInfo("Initialising Bad channel map");
465 fEMCALRecoUtils->SetNumberOfCellsFromEMCALBorder(fNCellsFromEMCALBorder);
466 fEMCALRecoUtils->SwitchOnNoFiducialBorderInEMCALEta0();
469 fEMCALRecoUtils->SwitchOnBadChannelsRemoval();
470 if (fRecalDistToBadChannels)
471 fEMCALRecoUtils->SwitchOnDistToBadChannelRecalculation();
473 Int_t runBC = event->GetRunNumber();
475 AliOADBContainer *contBC = new AliOADBContainer("");
476 if (fBasePath!=""){ //if fBasePath specified in the ->SetBasePath()
477 if (fDebugLevel>0) AliInfo(Form("Loading Bad Channels OADB from given path %s",fBasePath.Data()));
479 TFile *fbad=new TFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"read");
480 if (!fbad || fbad->IsZombie()){
481 AliFatal(Form("EMCALBadChannels.root was not found in the path provided: %s",fBasePath.Data()));
485 if (fbad) delete fbad;
487 contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"AliEMCALBadChannels");
488 } else { // Else choose the one in the $ALICE_ROOT directory
489 if (fDebugLevel>0) AliInfo("Loading Bad Channels OADB from $ALICE_ROOT/OADB/EMCAL");
491 TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","read");
492 if (!fbad || fbad->IsZombie()){
493 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root was not found");
497 if (fbad) delete fbad;
499 contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","AliEMCALBadChannels");
502 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
504 AliError(Form("No external hot channel set for run number: %d", runBC));
508 TObjArray *arrayBCpass=(TObjArray*)arrayBC->FindObject(fFilepass); // Here, it looks for a specific pass
510 AliError(Form("No external hot channel set for: %d -%s", runBC,fFilepass.Data()));
514 if (fDebugLevel>0) arrayBCpass->Print();
516 Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
517 for (Int_t i=0; i<sms; ++i) {
518 TH2I *h = fEMCALRecoUtils->GetEMCALChannelStatusMap(i);
521 h=(TH2I*)arrayBCpass->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
524 AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
528 fEMCALRecoUtils->SetEMCALChannelStatusMap(i,h);
533 //_____________________________________________________
534 Int_t AliEMCALTenderSupply::InitRecalib()
536 // Initialising recalibration factors.
538 AliESDEvent *event = fTender->GetEvent();
543 AliInfo("Initialising recalibration factors");
545 fEMCALRecoUtils->SwitchOnRecalibration();
546 Int_t runRC = event->GetRunNumber();
548 AliOADBContainer *contRF=new AliOADBContainer("");
549 if (fBasePath!="") { //if fBasePath specified in the ->SetBasePath()
550 if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data()));
552 TFile *fRecalib= new TFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"read");
553 if (!fRecalib || fRecalib->IsZombie()) {
554 AliFatal(Form("EMCALRecalib.root not found in %s",fBasePath.Data()));
558 if (fRecalib) delete fRecalib;
560 contRF->InitFromFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"AliEMCALRecalib");
562 else{ // Else choose the one in the $ALICE_ROOT directory
563 if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL");
565 TFile *fRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","read");
566 if (!fRecalib || fRecalib->IsZombie()) {
567 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root was not found");
571 if (fRecalib) delete fRecalib;
573 contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","AliEMCALRecalib");
576 TObjArray *recal=(TObjArray*)contRF->GetObject(runRC); //GetObject(int runnumber)
578 AliError(Form("No Objects for run: %d",runRC));
582 TObjArray *recalpass=(TObjArray*)recal->FindObject(fFilepass);
584 AliError(Form("No Objects for run: %d - %s",runRC,fFilepass.Data()));
588 TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
590 AliError(Form("No Recalib histos found for %d - %s",runRC,fFilepass.Data()));
594 if (fDebugLevel>0) recalib->Print();
596 Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
597 for (Int_t i=0; i<sms; ++i) {
598 TH2F *h = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactors(i);
601 h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
603 AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
607 fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
612 //_____________________________________________________
613 void AliEMCALTenderSupply::UpdateCells()
615 //Remove bad cells from the cell list
616 //Recalibrate energy and time cells
617 //This is required for later reclusterization
619 AliESDCaloCells *cells = fTender->GetEvent()->GetEMCALCells();
620 Int_t bunchCrossNo = fTender->GetEvent()->GetBunchCrossNumber();
622 fEMCALRecoUtils->ResetCellsCalibrated();
623 fEMCALRecoUtils->SwitchOnRecalibration();
624 fEMCALRecoUtils->SwitchOnTimeRecalibration();
626 fEMCALRecoUtils->RecalibrateCells(cells, bunchCrossNo);
628 fEMCALRecoUtils->SwitchOffRecalibration();
629 fEMCALRecoUtils->SwitchOffTimeRecalibration();
634 //_____________________________________________________
635 void AliEMCALTenderSupply::InitRecParam()
638 AliInfo("Initialize the recParam");
640 fRecParam = new AliEMCALRecParam;
641 const AliESDRun *run = fTender->GetEvent()->GetESDRun();
642 TString bt(run->GetBeamType());
644 fRecParam->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv1);
645 fRecParam->SetClusteringThreshold(0.100);
646 fRecParam->SetMinECut(0.050);
648 fRecParam->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv2);
649 fRecParam->SetClusteringThreshold(0.100);
650 fRecParam->SetMinECut(0.050);
654 //_____________________________________________________
655 Bool_t AliEMCALTenderSupply::InitClusterization()
657 // Initialing clusterization/unfolding algorithm and set all the needed parameters.
659 AliESDEvent *event = fTender->GetEvent();
664 AliInfo(Form("Initialising reclustering parameters: Clusterizer type: %d",fRecParam->GetClusterizerFlag()));
666 //---setup clusterizer
668 if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
669 fClusterizer = new AliEMCALClusterizerv1 (fEMCALGeo);
670 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
671 fClusterizer = new AliEMCALClusterizerv2(fEMCALGeo);
672 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN) {
673 AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(fEMCALGeo);
674 clusterizer->SetNRowDiff(fRecParam->GetNRowDiff());
675 clusterizer->SetNColDiff(fRecParam->GetNColDiff());
676 fClusterizer = clusterizer;
678 AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
682 // Set the clustering parameters
683 fClusterizer->SetECAClusteringThreshold( fRecParam->GetClusteringThreshold() );
684 fClusterizer->SetECALogWeight ( fRecParam->GetW0() );
685 fClusterizer->SetMinECut ( fRecParam->GetMinECut() );
686 fClusterizer->SetUnfolding ( fRecParam->GetUnfold() );
687 fClusterizer->SetECALocalMaxCut ( fRecParam->GetLocMaxCut() );
688 fClusterizer->SetTimeCut ( fRecParam->GetTimeCut() );
689 fClusterizer->SetTimeMin ( fRecParam->GetTimeMin() );
690 fClusterizer->SetTimeMax ( fRecParam->GetTimeMax() );
691 fClusterizer->SetInputCalibrated ( kTRUE );
692 fClusterizer->SetJustClusters ( kTRUE );
694 // In case of unfolding after clusterization is requested, set the corresponding parameters
695 if (fRecParam->GetUnfold()) {
696 for (Int_t i = 0; i < 8; ++i) {
697 fClusterizer->SetSSPars(i, fRecParam->GetSSPars(i));
699 for (Int_t i = 0; i < 3; ++i) {
700 fClusterizer->SetPar5 (i, fRecParam->GetPar5(i));
701 fClusterizer->SetPar6 (i, fRecParam->GetPar6(i));
703 fClusterizer->InitClusterUnfolding();
706 fClusterizer->SetDigitsArr(fDigitsArr);
707 fClusterizer->SetOutput(0);
708 fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
712 //_____________________________________________________
713 void AliEMCALTenderSupply::FillDigitsArray()
715 // Fill digits from cells to a TClonesArray.
717 AliESDEvent *event = fTender->GetEvent();
721 fDigitsArr->Clear("C");
722 AliESDCaloCells *cells = event->GetEMCALCells();
723 Int_t ncells = cells->GetNumberOfCells();
724 for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) {
725 Double_t cellAmplitude=0, cellTime=0;
726 Short_t cellNumber=0;
728 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime) != kTRUE)
731 // Do not add if already too low (some cells set to 0 if bad channels)
732 if (cellAmplitude < fRecParam->GetMinECut() )
735 // If requested, do not include exotic cells
736 if (fEMCALRecoUtils->IsExoticCell(cellNumber,cells,event->GetBunchCrossNumber()))
739 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
740 digit->SetId(cellNumber);
741 digit->SetTime(cellTime);
742 digit->SetTimeR(cellTime);
743 digit->SetIndexInList(idigit);
744 digit->SetType(AliEMCALDigit::kHG);
745 digit->SetAmplitude(cellAmplitude);
750 //_____________________________________________________
751 void AliEMCALTenderSupply::Clusterize()
755 fClusterizer->Digits2Clusters("");
758 //_____________________________________________________
759 void AliEMCALTenderSupply::UpdateClusters()
761 // Update ESD cluster list.
763 AliESDEvent *event = fTender->GetEvent();
767 TClonesArray *clus = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters"));
769 clus = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters"));
771 AliError(" Null pointer to calo clusters array, returning");
775 Int_t nents = clus->GetEntriesFast();
776 for (Int_t i=0; i < nents; ++i) {
777 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(clus->At(i));
781 delete clus->RemoveAt(i);
784 RecPoints2Clusters(clus);
787 //_____________________________________________________
788 void AliEMCALTenderSupply::RecPoints2Clusters(TClonesArray *clus)
790 // Convert AliEMCALRecoPoints to AliESDCaloClusters.
791 // Cluster energy, global position, cells and their amplitude fractions are restored.
793 AliESDEvent *event = fTender->GetEvent();
797 Int_t ncls = fClusterArr->GetEntriesFast();
798 for(Int_t i=0, nout=clus->GetEntriesFast(); i < ncls; ++i) {
799 AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
801 Int_t ncellsTrue = 0;
802 const Int_t ncells = recpoint->GetMultiplicity();
803 UShort_t absIds[ncells];
804 Double32_t ratios[ncells];
805 Int_t *dlist = recpoint->GetDigitsList();
806 Float_t *elist = recpoint->GetEnergiesList();
807 for (Int_t c = 0; c < ncells; ++c) {
808 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c]));
809 absIds[ncellsTrue] = digit->GetId();
810 ratios[ncellsTrue] = elist[c]/digit->GetAmplitude();
811 if (ratios[ncellsTrue] < 0.001)
816 if (ncellsTrue < 1) {
817 AliWarning("Skipping cluster with no cells");
821 // calculate new cluster position
823 recpoint->GetGlobalPosition(gpos);
827 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(clus->New(nout++));
829 c->SetType(AliVCluster::kEMCALClusterv1);
830 c->SetE(recpoint->GetEnergy());
832 c->SetNCells(ncellsTrue);
833 c->SetDispersion(recpoint->GetDispersion());
834 c->SetEmcCpvDistance(-1); //not yet implemented
835 c->SetChi2(-1); //not yet implemented
836 c->SetTOF(recpoint->GetTime()) ; //time-of-flight
837 c->SetNExMax(recpoint->GetNExMax()); //number of local maxima
839 recpoint->GetElipsAxis(elipAxis);
840 c->SetM02(elipAxis[0]*elipAxis[0]) ;
841 c->SetM20(elipAxis[1]*elipAxis[1]) ;
842 AliESDCaloCluster *cesd = static_cast<AliESDCaloCluster*>(c);
843 cesd->SetCellsAbsId(absIds);
844 cesd->SetCellsAmplitudeFraction(ratios);
848 //_____________________________________________________
849 void AliEMCALTenderSupply::GetPass()
851 // Get passx from filename.
853 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
854 fInputTree = mgr->GetTree();
857 AliError("Pointer to tree = 0, returning");
861 fInputFile = fInputTree->GetCurrentFile();
863 AliError("Null pointer input file, returning");
867 TString fname(fInputFile->GetName());
868 if (fname.Contains("pass1")) fFilepass = TString("pass1");
869 else if (fname.Contains("pass2")) fFilepass = TString("pass2");
870 else if (fname.Contains("pass3")) fFilepass = TString("pass3");
872 AliError(Form("Pass number string not found: %s", fname.Data()));