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 //_________________________________________________________________________
17 // This analysis provides a new list of clusters to be used in other analysis
19 // Author: Constantin Loizides, Salvatore Aiola
20 // Adapted from analysis class from Deepa Thomas
23 //_________________________________________________________________________
26 #include <TClonesArray.h>
27 #include <TGeoManager.h>
28 #include <TObjArray.h>
34 #include "AliAODCaloCluster.h"
35 #include "AliAODEvent.h"
36 #include "AliAnalysisManager.h"
37 #include "AliCDBEntry.h"
38 #include "AliCDBManager.h"
39 #include "AliCaloCalibPedestal.h"
40 #include "AliEMCALAfterBurnerUF.h"
41 #include "AliEMCALCalibData.h"
42 #include "AliEMCALClusterizerNxN.h"
43 #include "AliEMCALClusterizerv1.h"
44 #include "AliEMCALClusterizerv2.h"
45 #include "AliEMCALClusterizerFixedWindow.h"
46 #include "AliEMCALDigit.h"
47 #include "AliEMCALGeometry.h"
48 #include "AliEMCALRecParam.h"
49 #include "AliEMCALRecPoint.h"
50 #include "AliEMCALRecoUtils.h"
51 #include "AliESDEvent.h"
52 #include "AliInputEventHandler.h"
55 #include "AliAnalysisTaskEMCALClusterizeFast.h"
57 ClassImp(AliAnalysisTaskEMCALClusterizeFast)
59 //________________________________________________________________________
60 AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast() :
65 fRecParam(new AliEMCALRecParam),
70 fGeomMatrixSet(kFALSE),
71 fLoadGeomMatrices(kFALSE),
80 fAttachClusters(kTRUE),
81 fSubBackground(kFALSE),
87 fInputCellType(kFEEData),
90 fCaloClustersName("newCaloClusters"),
91 fDoUpdateCells(kTRUE),
93 fClusterBadChannelCheck(kTRUE),
94 fRejectExoticClusters(kFALSE),
96 fDoNonLinearity(kFALSE),
97 fRecalDistToBadChannels(kTRUE),
106 for(Int_t i = 0; i < 12; ++i)
110 //________________________________________________________________________
111 AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast(const char *name) :
112 AliAnalysisTaskSE(name),
116 fRecParam(new AliEMCALRecParam),
121 fGeomMatrixSet(kFALSE),
122 fLoadGeomMatrices(kFALSE),
131 fAttachClusters(kTRUE),
132 fSubBackground(kFALSE),
138 fInputCellType(kFEEData),
141 fCaloClustersName("newCaloClusters"),
142 fDoUpdateCells(kTRUE),
143 fDoClusterize(kTRUE),
144 fClusterBadChannelCheck(kTRUE),
145 fRejectExoticClusters(kFALSE),
147 fDoNonLinearity(kFALSE),
148 fRecalDistToBadChannels(kTRUE),
157 fBranchNames = "ESD:AliESDHeader.,AliESDRun.,EMCALCells.,EMCALTrigger. AOD:header,emcalCells";
158 for(Int_t i = 0; i < 12; ++i)
162 //________________________________________________________________________
163 AliAnalysisTaskEMCALClusterizeFast::~AliAnalysisTaskEMCALClusterizeFast()
173 //________________________________________________________________________
174 void AliAnalysisTaskEMCALClusterizeFast::UserCreateOutputObjects()
176 // Create output objects.
178 if (!fOutputAODBrName.IsNull()) {
179 fOutputAODBranch = new TClonesArray("AliAODCaloCluster", 0);
180 fOutputAODBranch->SetName(fOutputAODBrName);
181 AddAODBranch("TClonesArray", &fOutputAODBranch);
182 AliInfo(Form("Created Branch: %s",fOutputAODBrName.Data()));
186 //________________________________________________________________________
187 void AliAnalysisTaskEMCALClusterizeFast::UserExec(Option_t *)
189 // Main loop, called for each event
191 // if no operation is requested, return
192 if (!fDoClusterize && !fDoUpdateCells)
195 // remove the contents of output list set in the previous event
196 if (fOutputAODBranch)
197 fOutputAODBranch->Clear("C");
199 fEsd = dynamic_cast<AliESDEvent*>(InputEvent());
200 fAod = dynamic_cast<AliAODEvent*>(InputEvent());
203 Error("UserExec","Event not available");
209 UInt_t offtrigger = 0;
211 UInt_t mask1 = fEsd->GetESDRun()->GetDetectorsInDAQ();
212 UInt_t mask2 = fEsd->GetESDRun()->GetDetectorsInReco();
213 Bool_t desc1 = (mask1 >> 18) & 0x1;
214 Bool_t desc2 = (mask2 >> 18) & 0x1;
215 if (desc1==0 || desc2==0) { //AliDAQ::OfflineModuleName(180=="EMCAL"
216 AliError(Form("EMCAL not in DAQ/RECO: %u (%u)/%u (%u)",
217 mask1, fEsd->GetESDRun()->GetDetectorsInReco(),
218 mask2, fEsd->GetESDRun()->GetDetectorsInDAQ()));
221 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
222 offtrigger = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
224 offtrigger = fAod->GetHeader()->GetOfflineTrigger();
228 if (offtrigger & AliVEvent::kFastOnly) {
229 AliError(Form("EMCAL not in fast only partition"));
237 AliWarning("Unfolding not implemented");
249 if (!fDoClusterize || (!fAttachClusters && !fOutputAODBranch) || !fCaloClusters)
255 if (fOutputAODBranch && fCaloClusters != fOutputAODBranch)
256 CopyClusters(fCaloClusters, fOutputAODBranch);
259 //________________________________________________________________________
260 void AliAnalysisTaskEMCALClusterizeFast::CopyClusters(TClonesArray *orig, TClonesArray *dest)
262 const Int_t Ncls = orig->GetEntries();
264 for(Int_t i=0; i < Ncls; ++i) {
265 AliVCluster *oc = static_cast<AliVCluster*>(orig->At(i));
273 AliVCluster *dc = static_cast<AliVCluster*>(dest->New(i));
274 dc->SetType(AliVCluster::kEMCALClusterv1);
276 Float_t pos[3] = {0};
277 oc->GetPosition(pos);
278 dc->SetPosition(pos);
279 dc->SetNCells(oc->GetNCells());
280 dc->SetCellsAbsId(oc->GetCellsAbsId());
281 dc->SetCellsAmplitudeFraction(oc->GetCellsAmplitudeFraction());
282 dc->SetID(oc->GetID());
283 dc->SetDispersion(oc->GetDispersion());
284 dc->SetEmcCpvDistance(-1);
286 dc->SetTOF(oc->GetTOF()); //time-of-flight
287 dc->SetNExMax(oc->GetNExMax()); //number of local maxima
288 dc->SetM02(oc->GetM02());
289 dc->SetM20(oc->GetM20());
290 dc->SetDistanceToBadChannel(oc->GetDistanceToBadChannel());
291 dc->SetMCEnergyFraction(oc->GetMCEnergyFraction());
294 UInt_t nlabels = oc->GetNLabels();
295 Int_t *labels = oc->GetLabels();
297 if (nlabels == 0 || !labels)
300 AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(dc);
302 TArrayI parents(nlabels, labels);
303 esdClus->AddLabels(parents);
306 AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(dc);
308 aodClus->SetLabel(labels, nlabels);
313 //________________________________________________________________________
314 void AliAnalysisTaskEMCALClusterizeFast::Clusterize()
318 if (fSubBackground) {
319 fClusterizer->SetInputCalibrated(kTRUE);
320 fClusterizer->SetCalibrationParameters(0);
323 fClusterizer->Digits2Clusters("");
325 if (fSubBackground) {
327 fClusterizer->SetInputCalibrated(kFALSE);
328 fClusterizer->SetCalibrationParameters(fCalibData);
333 //________________________________________________________________________
334 void AliAnalysisTaskEMCALClusterizeFast::FillDigitsArray()
338 fDigitsArr->Clear("C");
340 switch (fInputCellType) {
343 case kFEEDataMCOnly :
344 case kFEEDataExcludeMC :
346 Double_t avgE = 0; // for background subtraction
347 const Int_t ncells = fCaloCells->GetNumberOfCells();
348 for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) {
349 Double_t cellAmplitude=0, cellTime=0, cellEFrac = 0;
350 Short_t cellNumber=0;
351 Int_t cellMCLabel=-1;
352 if (fCaloCells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
355 if (cellMCLabel > 0 && cellEFrac < 1e-6)
358 if (cellAmplitude < 1e-6 || cellNumber < 0)
361 if (fInputCellType == kFEEDataMCOnly) {
362 if (cellMCLabel <= 0)
365 cellAmplitude *= cellEFrac;
369 else if (fInputCellType == kFEEDataExcludeMC) {
373 cellAmplitude *= 1 - cellEFrac;
378 AliEMCALDigit *digit = new((*fDigitsArr)[idigit]) AliEMCALDigit(cellMCLabel, cellMCLabel, cellNumber,
379 (Float_t)cellAmplitude, (Float_t)cellTime,
380 AliEMCALDigit::kHG,idigit, 0, 0, cellEFrac*cellAmplitude);
382 if (!fDoClusterize||fSubBackground) {
383 Float_t energy = cellAmplitude;
384 Float_t time = cellTime;
385 fClusterizer->Calibrate(energy,time,cellNumber);
386 digit->SetAmplitude(energy);
392 if (fSubBackground) {
393 avgE /= fGeom->GetNumberOfSuperModules()*48*24;
394 Int_t ndigis = fDigitsArr->GetEntries();
395 for (Int_t i = 0; i < ndigis; ++i) {
396 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(i));
397 Double_t energy = digit->GetAmplitude() - avgE;
399 digit->SetAmplitude(0);
401 digit->SetAmplitude(energy);
410 // Fill digits from a pattern
411 Int_t maxd = fGeom->GetNCells() / 4;
412 for (Int_t idigit = 0; idigit < maxd; idigit++){
413 if (idigit % 24 == 12) idigit += 12;
414 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
415 digit->SetId(idigit * 4);
417 digit->SetTimeR(600);
418 digit->SetIndexInList(idigit);
419 digit->SetType(AliEMCALDigit::kHG);
420 digit->SetAmplitude(0.1);
429 // Fill digits from FastORs
431 AliVCaloTrigger *triggers = InputEvent()->GetCaloTrigger("EMCAL");
433 if (!triggers || !(triggers->GetEntries() > 0))
439 while ((triggers->Next())) {
440 Float_t L0Amplitude = 0;
441 triggers->GetAmplitude(L0Amplitude);
443 if (L0Amplitude <= 0 && fInputCellType != kL1FastORs)
446 Int_t L1Amplitude = 0;
447 triggers->GetL1TimeSum(L1Amplitude);
449 if (L1Amplitude <= 0 && fInputCellType == kL1FastORs)
452 Int_t triggerTime = 0;
454 triggers->GetNL0Times(ntimes);
456 if (ntimes < 1 && fInputCellType == kL0FastORsTC)
461 triggers->GetL0Times(trgtimes);
462 triggerTime = trgtimes[0];
465 Int_t triggerCol = 0, triggerRow = 0;
466 triggers->GetPosition(triggerCol, triggerRow);
469 fGeom->GetAbsFastORIndexFromPositionInEMCAL(triggerCol, triggerRow, find);
474 Int_t cidx[4] = {-1};
475 Bool_t ret = fGeom->GetCellIndexFromFastORIndex(find, cidx);
480 Float_t triggerAmplitude = 0;
482 if (fInputCellType == kL1FastORs) {
483 triggerAmplitude = 0.25 * L1Amplitude; // it will add 4 cells for 1 amplitude
486 triggerAmplitude = L0Amplitude; // 10 bit truncated, so it is already divided by 4
489 for (Int_t idxpos = 0; idxpos < 4; idxpos++) {
490 Int_t triggerNumber = cidx[idxpos];
491 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
492 digit->SetId(triggerNumber);
493 digit->SetTime(triggerTime);
494 digit->SetTimeR(triggerTime);
495 digit->SetIndexInList(idigit);
496 digit->SetType(AliEMCALDigit::kHG);
497 digit->SetAmplitude(triggerAmplitude);
506 //________________________________________________________________________________________
507 void AliAnalysisTaskEMCALClusterizeFast::CalibrateClusters()
509 // Go through clusters one by one and process separate correction
510 // as those were defined or not
512 Int_t nclusters = fCaloClusters->GetEntriesFast();
513 for (Int_t icluster=0; icluster < nclusters; ++icluster) {
514 AliVCluster *clust = static_cast<AliVCluster*>(fCaloClusters->At(icluster));
517 if (!clust->IsEMCAL())
520 // REMOVE CLUSTERS WITH BAD CELLS -----------------------------
521 if (fClusterBadChannelCheck) {
522 // careful, the the ClusterContainsBadChannel is dependent on
523 // SwitchOnBadChannelsRemoval, switching it ON automatically
524 // and returning to original value after processing
525 Bool_t badRemoval = fRecoUtils->IsBadChannelsRemovalSwitchedOn();
526 fRecoUtils->SwitchOnBadChannelsRemoval();
528 Bool_t badResult = fRecoUtils->ClusterContainsBadChannel(fGeom, clust->GetCellsAbsId(), clust->GetNCells());
530 // switch the bad channels removal back
532 fRecoUtils->SwitchOffBadChannelsRemoval();
535 delete fCaloClusters->RemoveAt(icluster);
536 continue; //TODO is it really needed to remove it? Or should we flag it?
540 // REMOVE EXOTIC CLUSTERS -------------------------------------
541 // does process local cell recalibration energy and time without replacing
542 // the global cell values, in case of no cell recalib done yet
543 if (fRejectExoticClusters) {
544 // careful, the IsExoticCluster is dependent on
545 // SwitchOnRejectExoticCell, switching it ON automatically
546 // and returning to original value after processing
547 Bool_t exRemoval = fRecoUtils->IsRejectExoticCell();
548 fRecoUtils->SwitchOnRejectExoticCell();
550 // get bunch crossing
551 Int_t bunchCrossNo = InputEvent()->GetBunchCrossNumber();
553 Bool_t exResult = fRecoUtils->IsExoticCluster(clust, fCaloCells, bunchCrossNo);
555 // switch the exotic channels removal back
557 fRecoUtils->SwitchOffRejectExoticCell();
560 delete fCaloClusters->RemoveAt(icluster);
561 continue; //TODO is it really needed to remove it? Or should we flag it?
565 // FIDUCIAL CUT -----------------------------------------------
567 // depends on SetNumberOfCellsFromEMCALBorder
568 // SwitchOnNoFiducialBorderInEMCALEta0
569 if (!fRecoUtils->CheckCellFiducialRegion(fGeom, clust, fCaloCells)){
570 delete fCaloClusters->RemoveAt(icluster);
571 continue; //TODO it would be nice to store the distance
575 // NONLINEARITY -----------------------------------------------
576 if (fDoNonLinearity) {
577 Float_t correctedEnergy = fRecoUtils->CorrectClusterEnergyLinearity(clust);
578 clust->SetE(correctedEnergy);
581 // DISTANCE TO BAD CHANNELS -----------------------------------
582 if (fRecalDistToBadChannels)
583 fRecoUtils->RecalculateClusterDistanceToBadChannel(fGeom, fCaloCells, clust);
586 fCaloClusters->Compress();
589 //________________________________________________________________________________________
590 void AliAnalysisTaskEMCALClusterizeFast::TrackClusterMatching(AliVCluster *c, TClonesArray *tarr)
596 Double_t dEtaMin = 1e9;
597 Double_t dPhiMin = 1e9;
599 Double_t ceta = gpos.Eta();
600 Double_t cphi = gpos.Phi();
601 const Int_t ntrks = tarr->GetEntries();
602 for(Int_t t = 0; t<ntrks; ++t) {
603 AliVTrack *track = static_cast<AliVTrack*>(tarr->At(t));
606 const AliExternalTrackParam *outp = track->GetOuterParam();
609 Double_t trkPos[3] = {0.,0.,0.};
610 if (!outp->GetXYZ(trkPos))
612 TVector3 vec(trkPos[0],trkPos[1],trkPos[2]);
613 Double_t veta = vec.Eta();
614 Double_t vphi = vec.Phi();
616 vphi += 2*TMath::Pi();
617 if (TMath::Abs(veta)>0.75 || (vphi<70*TMath::DegToRad()) || (vphi>190*TMath::DegToRad()))
619 Double_t dR = vec.DeltaR(gpos);
622 Float_t tmpEta=0, tmpPhi=0;
624 AliExternalTrackParam trkParTemp(*outp); // retrieve the starting point every time before the extrapolation
625 Bool_t ret = fRecoUtils->ExtrapolateTrackToCluster(&trkParTemp, c, fRecoUtils->GetMass(), fRecoUtils->GetStep(), tmpEta, tmpPhi);
629 tmpEta = ceta - veta;
630 tmpPhi = cphi - vphi;
632 if (TMath::Abs(tmpEta)<TMath::Abs(dEtaMin) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMin)) {
638 c->SetEmcCpvDistance(imin);
639 c->SetTrackDistance(dPhiMin, dEtaMin);
642 //________________________________________________________________________________________
643 void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
645 // Cluster energy, global position, cells and their amplitude fractions are restored.
647 // tracks array for track/cluster matching
648 TClonesArray *tarr = 0;
649 if (!fTrackName.IsNull()) {
650 tarr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTrackName));
652 AliError(Form("Cannot get tracks named %s", fTrackName.Data()));
656 const Int_t Ncls = fClusterArr->GetEntries();
657 AliDebug(1, Form("total no of clusters %d", Ncls));
658 for(Int_t i=0, nout=clus->GetEntries(); i < Ncls; ++i) {
659 AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
660 Int_t ncells_true = 0;
661 const Int_t ncells = recpoint->GetMultiplicity();
662 UShort_t absIds[ncells];
663 Double32_t ratios[ncells];
664 Int_t *dlist = recpoint->GetDigitsList();
665 Float_t *elist = recpoint->GetEnergiesList();
666 Double_t mcEnergy = 0;
667 for (Int_t c = 0; c < ncells; ++c) {
668 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c]));
669 absIds[ncells_true] = digit->GetId();
670 ratios[ncells_true] = elist[c]/recpoint->GetEnergy();
671 if (digit->GetIparent(1) > 0)
672 mcEnergy += digit->GetDEParent(1)/recpoint->GetEnergy();
676 if (ncells_true < 1) {
677 AliWarning("Skipping cluster with no cells");
681 // calculate new cluster position
683 recpoint->GetGlobalPosition(gpos);
687 AliDebug(1, Form("energy %f", recpoint->GetEnergy()));
689 AliVCluster *c = static_cast<AliVCluster*>(clus->New(nout++));
690 c->SetType(AliVCluster::kEMCALClusterv1);
691 c->SetE(recpoint->GetEnergy());
693 c->SetNCells(ncells_true);
694 c->SetCellsAbsId(absIds);
695 c->SetCellsAmplitudeFraction(ratios);
696 c->SetID(recpoint->GetUniqueID());
697 c->SetDispersion(recpoint->GetDispersion());
698 c->SetEmcCpvDistance(-1);
700 c->SetTOF(recpoint->GetTime()) ; //time-of-flight
701 c->SetNExMax(recpoint->GetNExMax()); //number of local maxima
703 recpoint->GetElipsAxis(elipAxis);
704 c->SetM02(elipAxis[0]*elipAxis[0]);
705 c->SetM20(elipAxis[1]*elipAxis[1]);
706 c->SetMCEnergyFraction(mcEnergy);
709 AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(c);
711 Int_t parentMult = 0;
712 Int_t *parentList = recpoint->GetParents(parentMult);
713 if (parentMult > 0) {
714 TArrayI parents(parentMult, parentList);
715 esdClus->AddLabels(parents);
719 AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(c);
721 Int_t parentMult = 0;
722 Int_t *parentList = recpoint->GetParents(parentMult);
723 aodClus->SetLabel(parentList, parentMult);
728 TrackClusterMatching(c, tarr);
732 //________________________________________________________________________
733 void AliAnalysisTaskEMCALClusterizeFast::UpdateCells()
735 // Update cells in case re-calibration was done.
736 if (!fCalibData&&!fSubBackground)
739 const Int_t ncells = fCaloCells->GetNumberOfCells();
740 const Int_t ndigis = fDigitsArr->GetEntries();
741 if (ncells!=ndigis) {
742 fCaloCells->DeleteContainer();
743 fCaloCells->CreateContainer(ndigis);
745 for (Int_t idigit = 0; idigit < ndigis; ++idigit) {
746 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(idigit));
747 Double_t cellAmplitude = digit->GetCalibAmp();
748 Short_t cellNumber = digit->GetId();
749 Double_t cellTime = digit->GetTime();
750 fCaloCells->SetCell(idigit, cellNumber, cellAmplitude, cellTime);
754 //________________________________________________________________________
755 void AliAnalysisTaskEMCALClusterizeFast::UpdateClusters()
757 // Update cells in case re-calibration was done.
759 const Int_t nents = fCaloClusters->GetEntries();
760 for (Int_t i=0;i<nents;++i) {
761 AliVCluster *c = static_cast<AliVCluster*>(fCaloClusters->At(i));
765 delete fCaloClusters->RemoveAt(i);
768 fCaloClusters->Compress();
770 RecPoints2Clusters(fCaloClusters);
773 //________________________________________________________________________________________
774 void AliAnalysisTaskEMCALClusterizeFast::Init()
776 // Select clusterization/unfolding algorithm and set all the needed parameters.
778 if (InputEvent()->GetRunNumber()==fRun)
780 fRun = InputEvent()->GetRunNumber();
783 // init the unfolding afterburner
785 fUnfolder = new AliEMCALAfterBurnerUF(fRecParam->GetW0(),fRecParam->GetLocMaxCut(),fRecParam->GetMinECut());
789 if (fGeomName.Length()>0)
790 fGeom = AliEMCALGeometry::GetInstance(fGeomName);
792 fGeom = AliEMCALGeometry::GetInstance();
794 AliFatal("Geometry not available!!!");
798 if (!fGeomMatrixSet) {
799 if (fLoadGeomMatrices) {
800 for(Int_t mod=0; mod < fGeom->GetNumberOfSuperModules(); ++mod) {
801 if (fGeomMatrix[mod]){
802 if (DebugLevel() > 2)
803 fGeomMatrix[mod]->Print();
804 fGeom->SetMisalMatrix(fGeomMatrix[mod],mod);
807 } else { // get matrix from file (work around bug in aliroot)
808 for(Int_t mod=0; mod < fGeom->GetEMCGeometry()->GetNumberOfSuperModules(); ++mod) {
809 const TGeoHMatrix *gm = 0;
811 gm = fEsd->GetEMCALMatrix(mod);
813 AliAODHeader *aodheader = fAod->GetHeader();
815 gm = aodheader->GetEMCALMatrix(mod);
819 if (DebugLevel() > 2)
821 fGeom->SetMisalMatrix(gm,mod);
825 fGeomMatrixSet=kTRUE;
828 // setup digit array if needed
830 fDigitsArr = new TClonesArray("AliEMCALDigit", 1000);
831 fDigitsArr->SetOwner(1);
834 // then setup clusterizer
836 // avoid to delete digits array
837 fClusterizer->SetDigitsArr(0);
840 if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
841 fClusterizer = new AliEMCALClusterizerv1(fGeom);
842 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN) {
843 AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(fGeom);
844 clusterizer->SetNRowDiff(fRecParam->GetNRowDiff());
845 clusterizer->SetNColDiff(fRecParam->GetNColDiff());
846 fClusterizer = clusterizer;
848 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
849 fClusterizer = new AliEMCALClusterizerv2(fGeom);
850 else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerFW) {
851 AliEMCALClusterizerFixedWindow *clusterizer = new AliEMCALClusterizerFixedWindow(fGeom);
852 clusterizer->SetNphi(fNPhi);
853 clusterizer->SetNeta(fNEta);
854 clusterizer->SetShiftPhi(fShiftPhi);
855 clusterizer->SetShiftEta(fShiftEta);
856 clusterizer->SetTRUshift(fTRUShift);
857 fClusterizer = clusterizer;
860 AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
862 fClusterizer->InitParameters(fRecParam);
864 if ((!fCalibData&&fLoadCalib) || (!fPedestalData&&fLoadPed)) {
865 AliCDBManager *cdb = AliCDBManager::Instance();
866 if (!cdb->IsDefaultStorageSet() && !fOCDBpath.IsNull())
867 cdb->SetDefaultStorage(fOCDBpath);
868 if (fRun!=cdb->GetRun())
871 if (!fCalibData&&fLoadCalib&&fRun>0) {
872 AliCDBEntry *entry = static_cast<AliCDBEntry*>(AliCDBManager::Instance()->Get("EMCAL/Calib/Data"));
874 fCalibData = static_cast<AliEMCALCalibData*>(entry->GetObject());
876 AliFatal("Calibration parameters not found in CDB!");
878 if (!fPedestalData&&fLoadPed&&fRun>0) {
879 AliCDBEntry *entry = static_cast<AliCDBEntry*>(AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"));
881 fPedestalData = static_cast<AliCaloCalibPedestal*>(entry->GetObject());
884 fClusterizer->SetInputCalibrated(kFALSE);
885 fClusterizer->SetCalibrationParameters(fCalibData);
887 fClusterizer->SetInputCalibrated(kTRUE);
889 fClusterizer->SetCaloCalibPedestal(fPedestalData);
890 fClusterizer->SetJustClusters(kTRUE);
891 fClusterizer->SetDigitsArr(fDigitsArr);
892 fClusterizer->SetOutput(0);
893 fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
895 // Get the emcal cells
896 if ((fInputCellType == kFEEData || fInputCellType == kFEEDataMCOnly || fInputCellType == kFEEDataExcludeMC) && !fCaloCells) {
897 if (fCaloCellsName.IsNull()) {
898 fCaloCells = InputEvent()->GetEMCALCells();
901 fCaloCells = dynamic_cast<AliVCaloCells*>(InputEvent()->FindListObject(fCaloCellsName));
903 AliError(Form("%s: Could not retrieve cells %s!", GetName(), fCaloCellsName.Data()));
906 AliFatal("Could not get EMCal cells!");
909 // Set output clusters collection
910 if (!fAttachClusters) {
911 fCaloClusters = fOutputAODBranch;
915 if (!fCaloClusters) {
916 if (fCaloClustersName.IsNull()) { //overwrite mode
918 fCaloClusters = static_cast<TClonesArray*>(InputEvent()->FindListObject("CaloClusters"));
920 fCaloClusters = static_cast<TClonesArray*>(InputEvent()->FindListObject("caloClusters"));
923 fCaloClusters = static_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloClustersName));
925 if (!fCaloClusters) {
927 fCaloClusters = new TClonesArray("AliESDCaloCluster");
929 fCaloClusters = new TClonesArray("AliAODCaloCluster");
931 fCaloClusters->SetName(fCaloClustersName);
932 InputEvent()->AddObject(fCaloClusters);
937 AliFatal("Could not get cluster collection!");
939 TClass *cl = fCaloClusters->GetClass();
940 if (!cl->GetBaseClass("AliVCluster")) {
941 AliFatal(Form("%s: Collection %s does not contain AliVCluster objects!", GetName(), fCaloClusters->GetName()));