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 // remove the contents of output list set in the previous event
192 if (fOutputAODBranch)
193 fOutputAODBranch->Clear("C");
195 fEsd = dynamic_cast<AliESDEvent*>(InputEvent());
196 fAod = dynamic_cast<AliAODEvent*>(InputEvent());
199 Error("UserExec","Event not available");
205 UInt_t offtrigger = 0;
207 UInt_t mask1 = fEsd->GetESDRun()->GetDetectorsInDAQ();
208 UInt_t mask2 = fEsd->GetESDRun()->GetDetectorsInReco();
209 Bool_t desc1 = (mask1 >> 18) & 0x1;
210 Bool_t desc2 = (mask2 >> 18) & 0x1;
211 if (desc1==0 || desc2==0) { //AliDAQ::OfflineModuleName(180=="EMCAL"
212 AliError(Form("EMCAL not in DAQ/RECO: %u (%u)/%u (%u)",
213 mask1, fEsd->GetESDRun()->GetDetectorsInReco(),
214 mask2, fEsd->GetESDRun()->GetDetectorsInDAQ()));
217 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
218 offtrigger = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
220 offtrigger = fAod->GetHeader()->GetOfflineTrigger();
224 if (offtrigger & AliVEvent::kFastOnly) {
225 AliError(Form("EMCAL not in fast only partition"));
233 AliWarning("Unfolding not implemented");
245 if (!fDoClusterize || (!fAttachClusters && !fOutputAODBranch))
251 if (fCaloClusters && fOutputAODBranch && fCaloClusters != fOutputAODBranch)
252 CopyClusters(fCaloClusters, fOutputAODBranch);
255 //________________________________________________________________________
256 void AliAnalysisTaskEMCALClusterizeFast::CopyClusters(TClonesArray *orig, TClonesArray *dest)
258 const Int_t Ncls = orig->GetEntries();
260 for(Int_t i=0; i < Ncls; ++i) {
261 AliVCluster *oc = static_cast<AliVCluster*>(orig->At(i));
269 AliVCluster *dc = static_cast<AliVCluster*>(dest->New(i));
270 dc->SetType(AliVCluster::kEMCALClusterv1);
272 Float_t pos[3] = {0};
273 oc->GetPosition(pos);
274 dc->SetPosition(pos);
275 dc->SetNCells(oc->GetNCells());
276 dc->SetCellsAbsId(oc->GetCellsAbsId());
277 dc->SetCellsAmplitudeFraction(oc->GetCellsAmplitudeFraction());
278 dc->SetID(oc->GetID());
279 dc->SetDispersion(oc->GetDispersion());
280 dc->SetEmcCpvDistance(-1);
282 dc->SetTOF(oc->GetTOF()); //time-of-flight
283 dc->SetNExMax(oc->GetNExMax()); //number of local maxima
284 dc->SetM02(oc->GetM02());
285 dc->SetM20(oc->GetM20());
286 dc->SetDistanceToBadChannel(oc->GetDistanceToBadChannel());
289 UInt_t nlabels = oc->GetNLabels();
290 Int_t *labels = oc->GetLabels();
292 if (nlabels == 0 || !labels)
295 AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(dc);
297 TArrayI parents(nlabels, labels);
298 esdClus->AddLabels(parents);
301 AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(dc);
303 aodClus->SetLabel(labels, nlabels);
308 //________________________________________________________________________
309 void AliAnalysisTaskEMCALClusterizeFast::Clusterize()
313 if (fSubBackground) {
314 fClusterizer->SetInputCalibrated(kTRUE);
315 fClusterizer->SetCalibrationParameters(0);
318 fClusterizer->Digits2Clusters("");
320 if (fSubBackground) {
322 fClusterizer->SetInputCalibrated(kFALSE);
323 fClusterizer->SetCalibrationParameters(fCalibData);
328 //________________________________________________________________________
329 void AliAnalysisTaskEMCALClusterizeFast::FillDigitsArray()
333 fDigitsArr->Clear("C");
335 switch (fInputCellType) {
338 case kFEEDataMCOnly :
339 case kFEEDataExcludeMC :
341 Double_t avgE = 0; // for background subtraction
342 const Int_t ncells = fCaloCells->GetNumberOfCells();
343 for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) {
344 Double_t cellAmplitude=0, cellTime=0, cellEFrac = 0;
345 Short_t cellNumber=0;
346 Int_t cellMCLabel=-1;
347 if (fCaloCells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
350 if (fInputCellType == kFEEDataMCOnly) {
351 if (cellMCLabel <= 0)
354 cellAmplitude *= cellEFrac;
358 else if (fInputCellType == kFEEDataExcludeMC) {
362 cellAmplitude *= 1 - cellEFrac;
365 if (cellMCLabel > 0 && cellEFrac < 1e-6) cellEFrac = 1;
367 if (cellAmplitude < 1e-6 || cellNumber < 0)
370 AliEMCALDigit *digit = new((*fDigitsArr)[idigit]) AliEMCALDigit(cellMCLabel, cellMCLabel, cellNumber,
371 (Float_t)cellAmplitude, (Float_t)cellTime,
372 AliEMCALDigit::kHG,idigit, 0, 0, cellEFrac*cellAmplitude);
374 if (!fDoClusterize||fSubBackground) {
375 Float_t energy = cellAmplitude;
376 Float_t time = cellTime;
377 fClusterizer->Calibrate(energy,time,cellNumber);
378 digit->SetAmplitude(energy);
384 //fDigitsArr->Sort();
386 if (fSubBackground) {
387 avgE /= fGeom->GetNumberOfSuperModules()*48*24;
388 Int_t ndigis = fDigitsArr->GetEntries();
389 for (Int_t i = 0; i < ndigis; ++i) {
390 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(i));
391 Double_t energy = digit->GetAmplitude() - avgE;
393 digit->SetAmplitude(0);
395 digit->SetAmplitude(energy);
404 // Fill digits from a pattern
405 Int_t maxd = fGeom->GetNCells() / 4;
406 for (Int_t idigit = 0; idigit < maxd; idigit++){
407 if (idigit % 24 == 12) idigit += 12;
408 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
409 digit->SetId(idigit * 4);
411 digit->SetTimeR(600);
412 digit->SetIndexInList(idigit);
413 digit->SetType(AliEMCALDigit::kHG);
414 digit->SetAmplitude(0.1);
423 // Fill digits from FastORs
425 AliVCaloTrigger *triggers = InputEvent()->GetCaloTrigger("EMCAL");
427 if (!triggers || !(triggers->GetEntries() > 0))
433 while ((triggers->Next())) {
434 Float_t L0Amplitude = 0;
435 triggers->GetAmplitude(L0Amplitude);
437 if (L0Amplitude <= 0 && fInputCellType != kL1FastORs)
440 Int_t L1Amplitude = 0;
441 triggers->GetL1TimeSum(L1Amplitude);
443 if (L1Amplitude <= 0 && fInputCellType == kL1FastORs)
446 Int_t triggerTime = 0;
448 triggers->GetNL0Times(ntimes);
450 if (ntimes < 1 && fInputCellType == kL0FastORsTC)
455 triggers->GetL0Times(trgtimes);
456 triggerTime = trgtimes[0];
459 Int_t triggerCol = 0, triggerRow = 0;
460 triggers->GetPosition(triggerCol, triggerRow);
463 fGeom->GetAbsFastORIndexFromPositionInEMCAL(triggerCol, triggerRow, find);
468 Int_t cidx[4] = {-1};
469 Bool_t ret = fGeom->GetCellIndexFromFastORIndex(find, cidx);
474 Float_t triggerAmplitude = 0;
476 if (fInputCellType == kL1FastORs) {
477 triggerAmplitude = 0.25 * L1Amplitude; // it will add 4 cells for 1 amplitude
480 triggerAmplitude = L0Amplitude; // 10 bit truncated, so it is already divided by 4
483 for (Int_t idxpos = 0; idxpos < 4; idxpos++) {
484 Int_t triggerNumber = cidx[idxpos];
485 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
486 digit->SetId(triggerNumber);
487 digit->SetTime(triggerTime);
488 digit->SetTimeR(triggerTime);
489 digit->SetIndexInList(idigit);
490 digit->SetType(AliEMCALDigit::kHG);
491 digit->SetAmplitude(triggerAmplitude);
500 //________________________________________________________________________________________
501 void AliAnalysisTaskEMCALClusterizeFast::CalibrateClusters()
503 // PROCESS SINGLE CLUSTER RECALIBRATION -------------------------------------
504 // now go through clusters one by one and process separate correction
505 // as those were defined or not
506 Int_t nclusters = fCaloClusters->GetEntriesFast();
507 for (Int_t icluster=0; icluster < nclusters; ++icluster) {
508 AliVCluster *clust = static_cast<AliVCluster*>(fCaloClusters->At(icluster));
511 if (!clust->IsEMCAL())
514 // REMOVE CLUSTERS WITH BAD CELLS -----------------------------
515 if (fClusterBadChannelCheck) {
516 // careful, the the ClusterContainsBadChannel is dependent on
517 // SwitchOnBadChannelsRemoval, switching it ON automatically
518 // and returning to original value after processing
519 Bool_t badRemoval = fRecoUtils->IsBadChannelsRemovalSwitchedOn();
520 fRecoUtils->SwitchOnBadChannelsRemoval();
522 Bool_t badResult = fRecoUtils->ClusterContainsBadChannel(fGeom, clust->GetCellsAbsId(), clust->GetNCells());
524 // switch the bad channels removal back
526 fRecoUtils->SwitchOffBadChannelsRemoval();
529 delete fCaloClusters->RemoveAt(icluster);
530 continue; //TODO is it really needed to remove it? Or should we flag it?
534 // REMOVE EXOTIC CLUSTERS -------------------------------------
535 // does process local cell recalibration energy and time without replacing
536 // the global cell values, in case of no cell recalib done yet
537 if (fRejectExoticClusters) {
538 // careful, the IsExoticCluster is dependent on
539 // SwitchOnRejectExoticCell, switching it ON automatically
540 // and returning to original value after processing
541 Bool_t exRemoval = fRecoUtils->IsRejectExoticCell();
542 fRecoUtils->SwitchOnRejectExoticCell();
544 // get bunch crossing
545 Int_t bunchCrossNo = InputEvent()->GetBunchCrossNumber();
547 Bool_t exResult = fRecoUtils->IsExoticCluster(clust, fCaloCells, bunchCrossNo);
549 // switch the exotic channels removal back
551 fRecoUtils->SwitchOffRejectExoticCell();
554 delete fCaloClusters->RemoveAt(icluster);
555 continue; //TODO is it really needed to remove it? Or should we flag it?
559 // FIDUCIAL CUT -----------------------------------------------
561 // depends on SetNumberOfCellsFromEMCALBorder
562 // SwitchOnNoFiducialBorderInEMCALEta0
563 if (!fRecoUtils->CheckCellFiducialRegion(fGeom, clust, fCaloCells)){
564 delete fCaloClusters->RemoveAt(icluster);
565 continue; //TODO it would be nice to store the distance
569 // NONLINEARITY -----------------------------------------------
570 if (fDoNonLinearity) {
571 Float_t correctedEnergy = fRecoUtils->CorrectClusterEnergyLinearity(clust);
572 clust->SetE(correctedEnergy);
575 // DISTANCE TO BAD CHANNELS -----------------------------------
576 if (fRecalDistToBadChannels)
577 fRecoUtils->RecalculateClusterDistanceToBadChannel(fGeom, fCaloCells, clust);
580 fCaloClusters->Compress();
583 //________________________________________________________________________________________
584 void AliAnalysisTaskEMCALClusterizeFast::TrackClusterMatching(AliVCluster *c, TClonesArray *tarr)
590 Double_t dEtaMin = 1e9;
591 Double_t dPhiMin = 1e9;
593 Double_t ceta = gpos.Eta();
594 Double_t cphi = gpos.Phi();
595 const Int_t ntrks = tarr->GetEntries();
596 for(Int_t t = 0; t<ntrks; ++t) {
597 AliVTrack *track = static_cast<AliVTrack*>(tarr->At(t));
600 const AliExternalTrackParam *outp = track->GetOuterParam();
603 Double_t trkPos[3] = {0.,0.,0.};
604 if (!outp->GetXYZ(trkPos))
606 TVector3 vec(trkPos[0],trkPos[1],trkPos[2]);
607 Double_t veta = vec.Eta();
608 Double_t vphi = vec.Phi();
610 vphi += 2*TMath::Pi();
611 if (TMath::Abs(veta)>0.75 || (vphi<70*TMath::DegToRad()) || (vphi>190*TMath::DegToRad()))
613 Double_t dR = vec.DeltaR(gpos);
616 Float_t tmpEta=0, tmpPhi=0;
618 AliExternalTrackParam trkParTemp(*outp); // retrieve the starting point every time before the extrapolation
619 Bool_t ret = fRecoUtils->ExtrapolateTrackToCluster(&trkParTemp, c, fRecoUtils->GetMass(), fRecoUtils->GetStep(), tmpEta, tmpPhi);
623 tmpEta = ceta - veta;
624 tmpPhi = cphi - vphi;
626 if (TMath::Abs(tmpEta)<TMath::Abs(dEtaMin) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMin)) {
632 c->SetEmcCpvDistance(imin);
633 c->SetTrackDistance(dPhiMin, dEtaMin);
636 //________________________________________________________________________________________
637 void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
639 // Cluster energy, global position, cells and their amplitude fractions are restored.
641 // tracks array for track/cluster matching
642 TClonesArray *tarr = 0;
643 if (!fTrackName.IsNull()) {
644 tarr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTrackName));
646 AliError(Form("Cannot get tracks named %s", fTrackName.Data()));
650 const Int_t Ncls = fClusterArr->GetEntries();
651 AliDebug(1, Form("total no of clusters %d", Ncls));
652 for(Int_t i=0, nout=clus->GetEntries(); i < Ncls; ++i) {
653 AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
654 Int_t ncells_true = 0;
655 const Int_t ncells = recpoint->GetMultiplicity();
656 UShort_t absIds[ncells];
657 Double32_t ratios[ncells];
658 Int_t *dlist = recpoint->GetDigitsList();
659 Float_t *elist = recpoint->GetEnergiesList();
660 for (Int_t c = 0; c < ncells; ++c) {
661 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c]));
662 absIds[ncells_true] = digit->GetId();
663 ratios[ncells_true] = elist[c]/recpoint->GetEnergy();
667 if (ncells_true < 1) {
668 AliWarning("Skipping cluster with no cells");
672 // calculate new cluster position
674 recpoint->GetGlobalPosition(gpos);
678 AliDebug(1, Form("energy %f", recpoint->GetEnergy()));
680 AliVCluster *c = static_cast<AliVCluster*>(clus->New(nout++));
681 c->SetType(AliVCluster::kEMCALClusterv1);
682 c->SetE(recpoint->GetEnergy());
684 c->SetNCells(ncells_true);
685 c->SetCellsAbsId(absIds);
686 c->SetCellsAmplitudeFraction(ratios);
687 c->SetID(recpoint->GetUniqueID());
688 c->SetDispersion(recpoint->GetDispersion());
689 c->SetEmcCpvDistance(-1);
691 c->SetTOF(recpoint->GetTime()) ; //time-of-flight
692 c->SetNExMax(recpoint->GetNExMax()); //number of local maxima
694 recpoint->GetElipsAxis(elipAxis);
695 c->SetM02(elipAxis[0]*elipAxis[0]);
696 c->SetM20(elipAxis[1]*elipAxis[1]);
697 // Now it is done in CalibrateClusters()
700 c->SetDistanceToBadChannel(recpoint->GetDistanceToBadTower());
702 if (fRecoUtils && fRecoUtils->IsBadChannelsRemovalSwitchedOn()) {
703 fRecoUtils->RecalculateClusterDistanceToBadChannel(fGeom, fCaloCells, c);
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()));