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"
54 ClassImp(AliEMCALTenderSupply)
56 AliEMCALTenderSupply::AliEMCALTenderSupply() :
59 ,fEMCALGeoName("EMCAL_COMPLETEV1")
63 ,fNonLinearFunc(AliEMCALRecoUtils::kNoCorrection)
64 ,fNonLinearThreshold(30)
65 ,fReCalibCluster(kFALSE)
67 ,fRecalClusPos(kFALSE)
69 ,fNCellsFromEMCALBorder(1)
70 ,fRecalDistToBadChannels(kFALSE)
77 ,fCutEtaPhiSeparate(kFALSE)
82 ,fReClusterize(kFALSE)
84 ,fGeomMatrixSet(kFALSE)
85 ,fLoadGeomMatrices(kFALSE)
92 ,fMisalignSurvey(kdefault)
94 // Default constructor.
95 for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ;
98 //_____________________________________________________
99 AliEMCALTenderSupply::AliEMCALTenderSupply(const char *name, const AliTender *tender) :
100 AliTenderSupply(name,tender)
102 ,fEMCALGeoName("EMCAL_COMPLETEV1")
106 ,fNonLinearFunc(AliEMCALRecoUtils::kNoCorrection)
107 ,fNonLinearThreshold(30)
108 ,fReCalibCluster(kFALSE)
110 ,fRecalClusPos(kFALSE)
112 ,fNCellsFromEMCALBorder(1)
113 ,fRecalDistToBadChannels(kFALSE)
119 ,fCutEtaPhiSum(kTRUE)
120 ,fCutEtaPhiSeparate(kFALSE)
125 ,fReClusterize(kFALSE)
127 ,fGeomMatrixSet(kFALSE)
128 ,fLoadGeomMatrices(kFALSE)
130 ,fRecParamSet(kFALSE)
135 ,fMisalignSurvey(kdefault)
139 for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ;
141 fEMCALRecoUtils = new AliEMCALRecoUtils();
142 fRecParam = new AliEMCALRecParam;
143 fDigitsArr = new TClonesArray("AliEMCALDigit",1000);
146 //_____________________________________________________
147 AliEMCALTenderSupply::~AliEMCALTenderSupply()
151 delete fEMCALRecoUtils;
156 fDigitsArr->Clear("C");
161 //_____________________________________________________
162 void AliEMCALTenderSupply::Init()
164 // Initialise EMCAL tender.
167 AliInfo("Init EMCAL Tender supply");
169 if(fConfigName.Length()>0 && gROOT->LoadMacro(fConfigName) >=0) {
170 AliDebug(1, Form("Loading settings from macro %s", fConfigName.Data()));
171 AliEMCALTenderSupply *tender = (AliEMCALTenderSupply*)gInterpreter->ProcessLine("ConfigEMCALTenderSupply()");
172 fDebugLevel = tender->fDebugLevel;
173 fEMCALGeoName = tender->fEMCALGeoName;
174 fEMCALRecoUtils = tender->fEMCALRecoUtils;
175 fConfigName = tender->fConfigName;
176 fNonLinearFunc = tender->fNonLinearFunc;
177 fNonLinearThreshold = tender->fNonLinearThreshold;
178 fReCalibCluster = tender->fReCalibCluster;
179 fRecalClusPos = tender->fRecalClusPos;
180 fFiducial = tender->fFiducial;
181 fNCellsFromEMCALBorder = tender->fNCellsFromEMCALBorder;
182 fRecalDistToBadChannels = tender->fRecalDistToBadChannels;
183 fMass = tender->fMass;
184 fStep = tender->fStep;
185 fRcut = tender->fRcut;
186 fEtacut = tender->fEtacut;
187 fPhicut = tender->fPhicut;
188 fReClusterize = tender->fReClusterize;
189 fLoadGeomMatrices = tender->fLoadGeomMatrices;
190 fRecParam = tender->fRecParam;
191 fOCDBpath = tender->fOCDBpath;
192 for(Int_t i = 0; i < 10; i++)
193 fEMCALMatrix[i] = tender->fEMCALMatrix[i] ;
197 fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ;
199 // Initialising Non linearity parameters
200 fEMCALRecoUtils->SetNonLinearityThreshold(fNonLinearThreshold);
201 fEMCALRecoUtils->SetNonLinearityFunction(fNonLinearFunc);
203 // Setting mass, step size and residual cut
204 fEMCALRecoUtils->SetMass(fMass);
205 fEMCALRecoUtils->SetStep(fStep);
207 fEMCALRecoUtils->SwitchOnCutEtaPhiSum();
208 fEMCALRecoUtils->SetCutR(fRcut);
209 } else if (fCutEtaPhiSeparate) {
210 fEMCALRecoUtils->SwitchOnCutEtaPhiSeparate();
211 fEMCALRecoUtils->SetCutEta(fEtacut);
212 fEMCALRecoUtils->SetCutPhi(fPhicut);
216 //_____________________________________________________
217 void AliEMCALTenderSupply::ProcessEvent()
221 AliESDEvent *event = fTender->GetEvent();
223 AliError("ESD event ptr = 0, returning");
227 // Initialising parameters once per run number
228 if(fTender->RunChanged()){
231 Int_t fInitBC=InitBadChannels();
235 AliError("InitBadChannels returned false, returning");
240 AliInfo(Form("No external hot channel set: %d - %s", event->GetRunNumber(), fFilepass.Data()));
243 if (fReCalibCluster || fUpdateCell) {
244 Int_t fInitRecalib=InitRecalib();
247 AliError("InitRecalib returned false, returning");
252 AliInfo(Form("No recalibration available: %d - %s", event->GetRunNumber(), fFilepass.Data()));
253 fUpdateCell = kFALSE;
254 fReCalibCluster = kFALSE;
258 if (fRecalClusPos || fReClusterize || fUpdateCell) {
259 if (!InitMisalignMatrix()) {
260 AliError("InitMisalignmentMatrix returned false, returning");
265 if (fReClusterize || fUpdateCell) {
266 if (!InitClusterization()) {
267 AliError("InitClusterization returned false, returning");
273 fEMCALRecoUtils->Print("");
277 // Test if cells present
278 AliESDCaloCells *cells= event->GetEMCALCells();
279 if (cells->GetNumberOfCells()<=0) {
281 AliWarning(Form("Number of EMCAL cells = %d, returning", cells->GetNumberOfCells()));
286 AliInfo(Form("Re-calibrate cluster %d\n",fReCalibCluster));
292 fReClusterize = kTRUE;
298 fRecalClusPos = kFALSE; // Done in reclusterization, do nothing
299 fReCalibCluster= kFALSE; // Done in reclusterization, do nothing
305 // Store good clusters
306 TClonesArray *clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters"));
308 clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters"));
310 AliWarning(Form("No cluster array, number of cells in event = %d, returning", cells->GetNumberOfCells()));
314 Int_t nclusters = clusArr->GetEntriesFast();
316 for (Int_t icluster=0; icluster < nclusters; ++icluster) {
317 AliVCluster *clust = static_cast<AliVCluster*>(clusArr->At(icluster));
320 if (!clust->IsEMCAL())
322 if (fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo, clust->GetCellsAbsId(), clust->GetNCells())) {
323 delete clusArr->RemoveAt(icluster);
324 continue; //todo is it really needed to remove it? Or should we flag it?
328 if (!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, clust, cells)){
329 delete clusArr->RemoveAt(icluster);
330 continue; // todo it would be nice to store the distance
334 if(fRecalDistToBadChannels)
335 fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, cells, clust);
337 fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, clust, cells);
339 fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, cells, clust);
341 Float_t correctedEnergy = fEMCALRecoUtils->CorrectClusterEnergyLinearity(clust);
342 clust->SetE(correctedEnergy);
350 if (!TGeoGlobalMagField::Instance()->GetField()) {
351 const AliESDRun *erun = event->GetESDRun();
352 AliMagF *field = AliMagF::CreateFieldMap(erun->GetCurrentL3(),
353 erun->GetCurrentDip(),
356 erun->GetBeamEnergy(),
357 erun->GetBeamType());
358 TGeoGlobalMagField::Instance()->SetField(field);
361 fEMCALRecoUtils->FindMatches(event,0x0,fEMCALGeo);
363 fEMCALRecoUtils->SetClusterMatchedToTrack(event);
364 fEMCALRecoUtils->SetTracksMatchedToCluster(event);
368 //_____________________________________________________
369 Bool_t AliEMCALTenderSupply::InitMisalignMatrix()
371 // Initialising misalignment matrices
373 AliESDEvent *event = fTender->GetEvent();
377 if (fGeomMatrixSet) {
378 AliInfo("Misalignment matrix already set");
383 AliInfo("Initialising misalignment matrix");
385 fEMCALRecoUtils->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);
387 if (fLoadGeomMatrices) {
388 for(Int_t mod=0; mod < fEMCALGeo->GetNumberOfSuperModules(); ++mod) {
389 if (fEMCALMatrix[mod]){
391 fEMCALMatrix[mod]->Print();
392 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod);
395 fGeomMatrixSet = kTRUE;
399 Int_t runGM = event->GetRunNumber();
402 if(fMisalignSurvey == kdefault){ //take default alignment corresponding to run no
403 AliOADBContainer emcalgeoCont(Form("emcal"));
404 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
405 mobj=(TObjArray*)emcalgeoCont.GetObject(runGM,"EmcalMatrices");
408 if(fMisalignSurvey == kSurveybyS){ //take alignment at sector level
409 if (runGM <= 140000) { //2010 data
410 AliOADBContainer emcalgeoCont(Form("emcal2010"));
411 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
412 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10");
414 } else if (runGM>140000) { // 2011 LHC11a pass1 data
415 AliOADBContainer emcalgeoCont(Form("emcal2011"));
416 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
417 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byS");
421 if(fMisalignSurvey == kSurveybyM){ //take alignment at module level
422 if (runGM <= 140000) { //2010 data
423 AliOADBContainer emcalgeoCont(Form("emcal2010"));
424 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
425 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10");
427 } else if (runGM>140000) { // 2011 LHC11a pass1 data
429 AliOADBContainer emcalgeoCont(Form("emcal2011"));
430 emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo"));
431 mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byM");
435 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
436 fEMCALMatrix[mod] = (TGeoHMatrix*) mobj->At(mod);
437 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod);
438 fEMCALMatrix[mod]->Print();
443 //_____________________________________________________
444 Int_t AliEMCALTenderSupply::InitBadChannels()
446 // Initialising bad channel maps
447 AliESDEvent *event = fTender->GetEvent();
452 AliInfo("Initialising Bad channel map");
455 fEMCALRecoUtils->SetNumberOfCellsFromEMCALBorder(fNCellsFromEMCALBorder);
456 fEMCALRecoUtils->SwitchOnNoFiducialBorderInEMCALEta0();
459 fEMCALRecoUtils->SwitchOnBadChannelsRemoval();
460 if (fRecalDistToBadChannels)
461 fEMCALRecoUtils->SwitchOnDistToBadChannelRecalculation();
463 Int_t runBC = event->GetRunNumber();
465 AliOADBContainer *contBC=new AliOADBContainer("");
466 if(fBasePath!=""){ //if fBasePath specified in the ->SetBasePath()
467 if (fDebugLevel>0) AliInfo(Form("Loading Bad Channels OADB from given path %s",fBasePath.Data()));
468 TFile *fbad=new TFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"read");
469 if(fbad->IsZombie()){
470 AliFatal(Form("EMCALBadChannels.root was not found in the path provided: %s, aborting",fBasePath.Data()));
473 if(fbad) delete fbad;
474 contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"AliEMCALBadChannels");
476 else { // Else choose the one in the $ALICE_ROOT directory
477 if (fDebugLevel>0) AliInfo("Loading Bad Channels OADB from $ALICE_ROOT/OADB/EMCAL");
478 TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","read");
479 if(fbad->IsZombie()){
480 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root was not found, aborting");
483 if(fbad) delete fbad;
484 contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","AliEMCALBadChannels");
487 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC);
489 AliError(Form("No external hot channel set for run number: %d", runBC));
493 TObjArray *arrayBCpass=(TObjArray*)arrayBC->FindObject(fFilepass); // Here, it looks for a specific pass
495 AliError(Form("No external hot channel set for: %d -%s", runBC,fFilepass.Data()));
499 if(fDebugLevel>0) arrayBCpass->Print();
501 Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
502 for (Int_t i=0; i<sms; ++i) {
503 TH2I *h = fEMCALRecoUtils->GetEMCALChannelStatusMap(i);
506 h=(TH2I*)arrayBCpass->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
509 AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
513 fEMCALRecoUtils->SetEMCALChannelStatusMap(i,h);
520 //_____________________________________________________
521 Int_t AliEMCALTenderSupply::InitRecalib()
523 // Initialising recalibration factors.
525 AliESDEvent *event = fTender->GetEvent();
530 AliInfo("Initialising recalibration factors");
532 fEMCALRecoUtils->SwitchOnRecalibration();
533 Int_t runRC = event->GetRunNumber();
535 AliOADBContainer *contRF=new AliOADBContainer("");
536 if(fBasePath!="") { //if fBasePath specified in the ->SetBasePath()
537 if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data()));
538 TFile *fRecalib= new TFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"read");
539 if (fRecalib->IsZombie()) {
540 AliFatal(Form("EMCALRecalib.root not found in %s, aborting",fBasePath.Data()));
543 if(fRecalib) delete fRecalib;
544 contRF->InitFromFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"AliEMCALRecalib");
546 else{ // Else choose the one in the $ALICE_ROOT directory
547 if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL");
548 TFile *fRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","read");
549 if (fRecalib->IsZombie()) {
550 AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root was not found, aborting");
553 if(fRecalib) delete fRecalib;
554 contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","AliEMCALRecalib");
557 TObjArray *recal=(TObjArray*)contRF->GetObject(runRC); //GetObject(int runnumber)
559 AliError(Form("No Objects for run: %d",runRC));
563 TObjArray *recalpass=(TObjArray*)recal->FindObject(fFilepass);
565 AliError(Form("No Objects for run: %d - %s",runRC,fFilepass.Data()));
569 TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
571 AliError(Form("No Recalib histos found for %d - %s",runRC,fFilepass.Data()));
575 if(fDebugLevel>0) recalib->Print();
577 Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules();
578 for (Int_t i=0; i<sms; ++i) {
579 TH2F *h = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactors(i);
582 h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
584 AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
588 fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
593 //_____________________________________________________
594 void AliEMCALTenderSupply::UpdateCells()
596 //Remove bad cells from the cell list
597 //Recalibrate energy and time cells
598 //This is required for later reclusterization
600 AliESDCaloCells *cells = fTender->GetEvent()->GetEMCALCells();
601 Int_t bunchCrossNo = fTender->GetEvent()->GetBunchCrossNumber();
603 fEMCALRecoUtils->SwitchOnRecalibration();
604 fEMCALRecoUtils->SwitchOnTimeRecalibration();
606 fEMCALRecoUtils->RecalibrateCells(cells, bunchCrossNo);
610 //_____________________________________________________
611 void AliEMCALTenderSupply::InitRecParam()
614 AliInfo("Initialize the recParam");
615 fRecParam = new AliEMCALRecParam;
619 //_____________________________________________________
620 Bool_t AliEMCALTenderSupply::InitClusterization()
622 // Initialing clusterization/unfolding algorithm and set all the needed parameters.
624 AliESDEvent *event=fTender->GetEvent();
629 AliInfo(Form("Initialising reclustering parameters: Clusterizer-%d",fRecParam->GetClusterizerFlag()));
631 //---setup clusterizer
633 if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
634 fClusterizer = new AliEMCALClusterizerv1 (fEMCALGeo);
635 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
636 fClusterizer = new AliEMCALClusterizerv2(fEMCALGeo);
637 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN) {
638 AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(fEMCALGeo);
639 clusterizer->SetNRowDiff(fRecParam->GetNRowDiff());
640 clusterizer->SetNColDiff(fRecParam->GetNColDiff());
641 fClusterizer = clusterizer;
643 AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
647 // Set the clustering parameters
648 fClusterizer->SetECAClusteringThreshold( fRecParam->GetClusteringThreshold() );
649 fClusterizer->SetECALogWeight ( fRecParam->GetW0() );
650 fClusterizer->SetMinECut ( fRecParam->GetMinECut() );
651 fClusterizer->SetUnfolding ( fRecParam->GetUnfold() );
652 fClusterizer->SetECALocalMaxCut ( fRecParam->GetLocMaxCut() );
653 fClusterizer->SetTimeCut ( fRecParam->GetTimeCut() );
654 fClusterizer->SetTimeMin ( fRecParam->GetTimeMin() );
655 fClusterizer->SetTimeMax ( fRecParam->GetTimeMax() );
656 fClusterizer->SetInputCalibrated ( kTRUE );
657 fClusterizer->SetJustClusters ( kTRUE );
659 // In case of unfolding after clusterization is requested, set the corresponding parameters
660 if (fRecParam->GetUnfold()) {
661 for (Int_t i = 0; i < 8; ++i) {
662 fClusterizer->SetSSPars(i, fRecParam->GetSSPars(i));
664 for (Int_t i = 0; i < 3; ++i) {
665 fClusterizer->SetPar5 (i, fRecParam->GetPar5(i));
666 fClusterizer->SetPar6 (i, fRecParam->GetPar6(i));
668 fClusterizer->InitClusterUnfolding();
671 fClusterizer->SetDigitsArr(fDigitsArr);
672 fClusterizer->SetOutput(0);
673 fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
677 //_____________________________________________________
678 void AliEMCALTenderSupply::FillDigitsArray()
680 // Fill digits from cells to a TClonesArray.
682 AliESDEvent *event = fTender->GetEvent();
686 fDigitsArr->Clear("C");
687 AliESDCaloCells *cells = event->GetEMCALCells();
688 Int_t ncells = cells->GetNumberOfCells();
689 for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) {
690 Double_t cellAmplitude=0, cellTime=0;
691 Short_t cellNumber=0;
692 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime) != kTRUE)
695 // Do not add if already too low (some cells set to 0 if bad channels)
696 if(cellAmplitude < fRecParam->GetMinECut() )
699 // If requested, do not include exotic clusters
700 if(fEMCALRecoUtils->IsExoticCell(cellNumber,cells,event->GetBunchCrossNumber()))
703 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
704 digit->SetId(cellNumber);
705 digit->SetTime(cellTime);
706 digit->SetTimeR(cellTime);
707 digit->SetIndexInList(idigit);
708 digit->SetType(AliEMCALDigit::kHG);
709 digit->SetAmplitude(cellAmplitude);
714 //_____________________________________________________
715 void AliEMCALTenderSupply::Clusterize()
719 fClusterizer->Digits2Clusters("");
722 //_____________________________________________________
723 void AliEMCALTenderSupply::UpdateClusters()
725 // Update ESD cluster list.
727 AliESDEvent *event = fTender->GetEvent();
731 TClonesArray *clus = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters"));
733 clus = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters"));
735 AliError(" Null pointer to calo clusters array, returning");
739 Int_t nents = clus->GetEntriesFast();
740 for (Int_t i=0; i < nents; ++i) {
741 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(clus->At(i));
745 delete clus->RemoveAt(i);
748 RecPoints2Clusters(clus);
751 //_____________________________________________________
752 void AliEMCALTenderSupply::RecPoints2Clusters(TClonesArray *clus)
754 // Convert AliEMCALRecoPoints to AliESDCaloClusters.
755 // Cluster energy, global position, cells and their amplitude fractions are restored.
757 AliESDEvent *event = fTender->GetEvent();
761 Int_t ncls = fClusterArr->GetEntriesFast();
762 for(Int_t i=0, nout=clus->GetEntriesFast(); i < ncls; ++i) {
763 AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
765 Int_t ncells_true = 0;
766 const Int_t ncells = recpoint->GetMultiplicity();
767 UShort_t absIds[ncells];
768 Double32_t ratios[ncells];
769 Int_t *dlist = recpoint->GetDigitsList();
770 Float_t *elist = recpoint->GetEnergiesList();
771 for (Int_t c = 0; c < ncells; ++c) {
772 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c]));
773 absIds[ncells_true] = digit->GetId();
774 ratios[ncells_true] = elist[c]/digit->GetAmplitude();
775 if (ratios[ncells_true] < 0.001)
780 if (ncells_true < 1) {
781 AliWarning("Skipping cluster with no cells");
785 // calculate new cluster position
787 recpoint->GetGlobalPosition(gpos);
791 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(clus->New(nout++));
793 c->SetType(AliVCluster::kEMCALClusterv1);
794 c->SetE(recpoint->GetEnergy());
796 c->SetNCells(ncells_true);
797 c->SetDispersion(recpoint->GetDispersion());
798 c->SetEmcCpvDistance(-1); //not yet implemented
799 c->SetChi2(-1); //not yet implemented
800 c->SetTOF(recpoint->GetTime()) ; //time-of-flight
801 c->SetNExMax(recpoint->GetNExMax()); //number of local maxima
803 recpoint->GetElipsAxis(elipAxis);
804 c->SetM02(elipAxis[0]*elipAxis[0]) ;
805 c->SetM20(elipAxis[1]*elipAxis[1]) ;
806 AliESDCaloCluster *cesd = static_cast<AliESDCaloCluster*>(c);
807 cesd->SetCellsAbsId(absIds);
808 cesd->SetCellsAmplitudeFraction(ratios);
813 //_____________________________________________________
814 void AliEMCALTenderSupply::GetPass()
816 // Get passx from filename.
818 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
819 fInputTree = mgr->GetTree();
822 AliError("Pointer to tree = 0, returning");
826 fInputFile = fInputTree->GetCurrentFile();
828 AliError("Null pointer input file, returning");
832 TString fname(fInputFile->GetName());
833 if (fname.Contains("pass1")) fFilepass = TString("pass1");
834 else if(fname.Contains("pass2")) fFilepass = TString("pass2");
835 else if(fname.Contains("pass3")) fFilepass = TString("pass3");
837 AliError(Form("Pass number string not found: %s", fname.Data()));