Updated syst. uncertainty calculation for method 2
[u/mrichter/AliRoot.git] / PWG4 / CaloCalib / AliAnalysisTaskEMCALClusterizeFast.cxx
CommitLineData
2f7259cf 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18// --- Root ---
19#include <TClonesArray.h>
20#include <TGeoManager.h>
21#include <TObjArray.h>
22#include <TString.h>
23#include <TTree.h>
7a7d5a64 24
25// --- AliRoot ---
2f7259cf 26#include "AliAODCaloCluster.h"
27#include "AliAODEvent.h"
28#include "AliAnalysisManager.h"
29#include "AliCDBEntry.h"
30#include "AliCDBManager.h"
31#include "AliCaloCalibPedestal.h"
32#include "AliEMCALAfterBurnerUF.h"
33#include "AliEMCALCalibData.h"
34#include "AliEMCALClusterizerNxN.h"
35#include "AliEMCALClusterizerv1.h"
3786256f 36#include "AliEMCALClusterizerv2.h"
7a7d5a64 37#include "AliEMCALClusterizerFixedWindow.h"
38#include "AliEMCALFixedWindowClusterInfo.h"
2f7259cf 39#include "AliEMCALDigit.h"
40#include "AliEMCALGeometry.h"
41#include "AliEMCALRecParam.h"
42#include "AliEMCALRecPoint.h"
43#include "AliEMCALRecoUtils.h"
44#include "AliESDEvent.h"
6b7ed7bd 45#include "AliInputEventHandler.h"
2f7259cf 46#include "AliLog.h"
47
48#include "AliAnalysisTaskEMCALClusterizeFast.h"
49
50ClassImp(AliAnalysisTaskEMCALClusterizeFast)
51
52//________________________________________________________________________
2431b20f 53AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast()
54 : AliAnalysisTaskSE(),
349bf69e 55 fRun(-1),
2431b20f 56 fDigitsArr(0),
57 fClusterArr(0),
58 fRecParam(0),
59 fClusterizer(0),
60 fUnfolder(0),
61 fJustUnfold(kFALSE),
62 fGeomName(),
63 fGeomMatrixSet(kFALSE),
64 fLoadGeomMatrices(kFALSE),
65 fOCDBpath(),
66 fCalibData(0),
67 fPedestalData(0),
68 fOutputAODBranch(0),
69 fOutputAODBrName(),
70 fRecoUtils(0),
71 fLoadCalib(0),
4cf9204b 72 fLoadPed(0),
b0e354fe 73 fAttachClusters(0),
95f69c66 74 fRecalibOnly(0),
7a7d5a64 75 fSubBackground(0),
76 fCreatePattern(0),
77 fOverwrite(1),
78 fNewClusterArrayName("newCaloClusters"),
79 fNPhi(4),
80 fNEta(4),
81 fshiftPhi(2),
82 fshiftEta(2),
83 fTRUshift(0),
84 fStoreAdditionalInformation(0)
2431b20f 85{
86 // Constructor
87}
88
89//________________________________________________________________________
2f7259cf 90AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast(const char *name)
91 : AliAnalysisTaskSE(name),
349bf69e 92 fRun(-1),
2f7259cf 93 fDigitsArr(0),
94 fClusterArr(0),
95 fRecParam(new AliEMCALRecParam),
96 fClusterizer(0),
97 fUnfolder(0),
98 fJustUnfold(kFALSE),
99 fGeomName("EMCAL_FIRSTYEARV1"),
100 fGeomMatrixSet(kFALSE),
101 fLoadGeomMatrices(kFALSE),
102 fOCDBpath(),
103 fCalibData(0),
104 fPedestalData(0),
105 fOutputAODBranch(0),
106 fOutputAODBrName(),
10d33986 107 fRecoUtils(0),
108 fLoadCalib(0),
4cf9204b 109 fLoadPed(0),
b0e354fe 110 fAttachClusters(0),
95f69c66 111 fRecalibOnly(0),
7a7d5a64 112 fSubBackground(0),
113 fCreatePattern(0),
114 fOverwrite(1),
115 fNewClusterArrayName("newCaloClusters"),
116 fNPhi(4),
117 fNEta(4),
118 fshiftPhi(2),
119 fshiftEta(2),
120 fTRUshift(0),
121 fStoreAdditionalInformation(0)
2f7259cf 122{
123 // Constructor
124
01bc1ce8 125 fBranchNames = "ESD:AliESDHeader.,AliESDRun.,EMCALCells. AOD:header,emcalCells";
95f69c66 126 for(Int_t i = 0; i < 12; ++i)
2f7259cf 127 fGeomMatrix[i] = 0;
128}
129
130//________________________________________________________________________
131AliAnalysisTaskEMCALClusterizeFast::~AliAnalysisTaskEMCALClusterizeFast()
132{
133 // Destructor.
134
135 delete fDigitsArr;
136 delete fClusterizer;
137 delete fUnfolder;
138 delete fRecoUtils;
139}
140
141//-------------------------------------------------------------------
142void AliAnalysisTaskEMCALClusterizeFast::UserCreateOutputObjects()
143{
144 // Create output objects.
145
146 if (!fOutputAODBrName.IsNull()) {
147 fOutputAODBranch = new TClonesArray("AliAODCaloCluster", 0);
148 fOutputAODBranch->SetName(fOutputAODBrName);
149 AddAODBranch("TClonesArray", &fOutputAODBranch);
150 AliInfo(Form("Created Branch: %s",fOutputAODBrName.Data()));
151 }
152}
153
154//________________________________________________________________________
155void AliAnalysisTaskEMCALClusterizeFast::UserExec(Option_t *)
156{
157 // Main loop, called for each event
158
159 // remove the contents of output list set in the previous event
160 if (fOutputAODBranch)
161 fOutputAODBranch->Clear("C");
162
163 AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(InputEvent());
164 AliAODEvent *aodevent = dynamic_cast<AliAODEvent*>(InputEvent());
165
166 if (!esdevent&&!aodevent) {
167 Error("UserExec","Event not available");
168 return;
169 }
170
171 LoadBranches();
6b7ed7bd 172
173 UInt_t offtrigger = 0;
174 if (esdevent) {
9809ed8c 175 UInt_t mask1 = esdevent->GetESDRun()->GetDetectorsInDAQ();
176 UInt_t mask2 = esdevent->GetESDRun()->GetDetectorsInReco();
177 Bool_t desc1 = (mask1 >> 18) & 0x1;
178 Bool_t desc2 = (mask2 >> 18) & 0x1;
179 if (desc1==0 || desc2==0) { //AliDAQ::OfflineModuleName(180=="EMCAL"
180 AliError(Form("EMCAL not in DAQ/RECO: %u (%u)/%u (%u)",
181 mask1, esdevent->GetESDRun()->GetDetectorsInReco(),
182 mask2, esdevent->GetESDRun()->GetDetectorsInDAQ()));
6b7ed7bd 183 return;
184 }
185 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
186 offtrigger = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
187 } else if (aodevent) {
188 offtrigger = aodevent->GetHeader()->GetOfflineTrigger();
189 }
190 if (offtrigger & AliVEvent::kFastOnly) {
191 AliWarning(Form("EMCAL not in fast only partition"));
192 return;
193 }
2f7259cf 194
195 Init();
196
197 if (fJustUnfold) {
198 AliWarning("Unfolding not implemented");
84ccad86 199 return;
200 }
201
95f69c66 202 FillDigitsArray();
84ccad86 203
95f69c66 204 if (fRecalibOnly) {
205 UpdateCells();
206 return; // not requested to run clusterizer
84ccad86 207 }
7099ec08 208
95f69c66 209 Clusterize();
210 UpdateCells();
211 UpdateClusters();
7a7d5a64 212
213 if (fStoreAdditionalInformation)
214 StoreAdditionalInformation();
2431b20f 215
95f69c66 216 if (fOutputAODBranch)
217 RecPoints2Clusters(fOutputAODBranch);
2431b20f 218}
219
220//________________________________________________________________________
7a7d5a64 221void AliAnalysisTaskEMCALClusterizeFast::StoreAdditionalInformation()
222{
223 if (fClusterizer->ClassName() != TString("AliEMCALClusterizerFixedWindow"))
224 return;
225
226 TString addInfoName(fNewClusterArrayName);
227 addInfoName.Append("_AbsIds");
228
229 AliEMCALFixedWindowClusterInfo *clusInfo = dynamic_cast<AliEMCALFixedWindowClusterInfo*>(InputEvent()->FindListObject(addInfoName));
230
231 if(!clusInfo)
232 {
233 AliEMCALClusterizerFixedWindow *clusterizer = dynamic_cast<AliEMCALClusterizerFixedWindow*> (fClusterizer);
234 clusInfo = clusterizer->GetClustersInfo();
235 if (!clusInfo)
236 return;
237 clusInfo->SetName(addInfoName);
238 InputEvent()->AddObject(clusInfo);
239 }
240}
241
242//________________________________________________________________________
95f69c66 243void AliAnalysisTaskEMCALClusterizeFast::Clusterize()
2431b20f 244{
95f69c66 245 // Clusterize
7099ec08 246
95f69c66 247 if (fSubBackground) {
248 fClusterizer->SetInputCalibrated(kTRUE);
249 fClusterizer->SetCalibrationParameters(0);
2f7259cf 250 }
d3b5a5ec 251
95f69c66 252 fClusterizer->Digits2Clusters("");
253 if (fSubBackground) {
4889ed8b 254 if (fCalibData) {
255 fClusterizer->SetInputCalibrated(kFALSE);
256 fClusterizer->SetCalibrationParameters(fCalibData);
257 }
4cf9204b 258 }
4cf9204b 259}
260
261//________________________________________________________________________
95f69c66 262void AliAnalysisTaskEMCALClusterizeFast::FillDigitsArray()
2f7259cf 263{
7a7d5a64 264 if (fCreatePattern)
265 {
266
267 AliEMCALGeometry *fGeom = AliEMCALGeometry::GetInstance(fGeomName);
268
269 fDigitsArr->Clear("C");
270 Int_t maxd = fGeom->GetNCells() / 4;
271
272 for (Int_t idigit = 0; idigit < maxd; idigit++)
273 {
274 if (idigit % 24 == 12) idigit += 12;
275 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
276 digit->SetId(idigit * 4);
277 digit->SetTime(600);
278 digit->SetTimeR(600);
279 digit->SetIndexInList(idigit);
280 digit->SetType(AliEMCALDigit::kHG);
281 digit->SetAmplitude(0.1);
282
b0e354fe 283 }
7a7d5a64 284
2f7259cf 285 }
7a7d5a64 286 else
287 {
288
289 // Fill digits from cells.
290
291 fDigitsArr->Clear("C");
292 AliVCaloCells *cells = InputEvent()->GetEMCALCells();
293 Double_t avgE = 0; // for background subtraction
294 Int_t ncells = cells->GetNumberOfCells();
295 for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) {
296 Double_t cellAmplitude=0, cellTime=0;
297 Short_t cellNumber=0;
298 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime) != kTRUE)
299 break;
300 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
301 digit->SetId(cellNumber);
302 digit->SetTime(cellTime);
303 digit->SetTimeR(cellTime);
304 digit->SetIndexInList(idigit);
305 digit->SetType(AliEMCALDigit::kHG);
306 if (fRecalibOnly||fSubBackground) {
307 Float_t energy = cellAmplitude;
308 Float_t time = cellTime;
309 fClusterizer->Calibrate(energy,time,cellNumber);
95f69c66 310 digit->SetAmplitude(energy);
7a7d5a64 311 avgE += energy;
312 } else {
313 digit->SetAmplitude(cellAmplitude);
95f69c66 314 }
7a7d5a64 315 idigit++;
b0e354fe 316 }
7a7d5a64 317
318 if (fSubBackground) {
319 avgE /= AliEMCALGeometry::GetInstance(fGeomName)->GetNumberOfSuperModules()*48*24;
320 Int_t ndigis = fDigitsArr->GetEntries();
321 for (Int_t i = 0; i < ndigis; ++i) {
322 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(i));
323 Double_t energy = digit->GetAmplitude() - avgE;
324 if (energy<=0.001) {
325 digit->SetAmplitude(0);
326 } else {
327 digit->SetAmplitude(energy);
328 }
329 }
330 }
331 }
2f7259cf 332}
333
334//________________________________________________________________________________________
95f69c66 335void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
4cf9204b 336{
337 // Cluster energy, global position, cells and their amplitude fractions are restored.
338
95f69c66 339 Bool_t esdobjects = 0;
340 if (strcmp(clus->GetClass()->GetName(),"AliESDCaloCluster")==0)
341 esdobjects = 1;
342
b98487bc 343 AliVCaloCells *cells = InputEvent()->GetEMCALCells();
344 AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(fGeomName);
345
4cf9204b 346 Int_t Ncls = fClusterArr->GetEntriesFast();
347 for(Int_t i=0, nout=clus->GetEntries(); i < Ncls; ++i) {
348 AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
349 Int_t ncells_true = 0;
350 const Int_t ncells = recpoint->GetMultiplicity();
351 UShort_t absIds[ncells];
352 Double32_t ratios[ncells];
353 Int_t *dlist = recpoint->GetDigitsList();
354 Float_t *elist = recpoint->GetEnergiesList();
355 for (Int_t c = 0; c < ncells; ++c) {
356 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c]));
357 absIds[ncells_true] = digit->GetId();
358 ratios[ncells_true] = elist[c]/digit->GetAmplitude();
84ccad86 359 ++ncells_true;
4cf9204b 360 }
361
362 if (ncells_true < 1) {
363 AliWarning("Skipping cluster with no cells");
364 continue;
365 }
366
367 // calculate new cluster position
368 TVector3 gpos;
4cf9204b 369 recpoint->GetGlobalPosition(gpos);
84ccad86 370 Float_t g[3];
4cf9204b 371 gpos.GetXYZ(g);
372
95f69c66 373 AliVCluster *c = static_cast<AliVCluster*>(clus->New(nout++));
4cf9204b 374 c->SetType(AliVCluster::kEMCALClusterv1);
375 c->SetE(recpoint->GetEnergy());
376 c->SetPosition(g);
377 c->SetNCells(ncells_true);
4cf9204b 378 c->SetDispersion(recpoint->GetDispersion());
84ccad86 379 c->SetEmcCpvDistance(-1); //not yet implemented
4cf9204b 380 c->SetChi2(-1); //not yet implemented
381 c->SetTOF(recpoint->GetTime()) ; //time-of-flight
382 c->SetNExMax(recpoint->GetNExMax()); //number of local maxima
383 Float_t elipAxis[2];
384 recpoint->GetElipsAxis(elipAxis);
385 c->SetM02(elipAxis[0]*elipAxis[0]) ;
386 c->SetM20(elipAxis[1]*elipAxis[1]) ;
b98487bc 387 if (fRecoUtils && fRecoUtils->IsBadChannelsRemovalSwitchedOn()) {
388 fRecoUtils->RecalculateClusterDistanceToBadChannel(geom, cells, c);
389 } else {
390 if (fPedestalData)
391 recpoint->EvalDistanceToBadChannels(fPedestalData);
392 c->SetDistanceToBadChannel(recpoint->GetDistanceToBadTower());
393 }
394
95f69c66 395 if (esdobjects) {
396 AliESDCaloCluster *cesd = static_cast<AliESDCaloCluster*>(c);
397 cesd->SetCellsAbsId(absIds);
398 cesd->SetCellsAmplitudeFraction(ratios);
399 } else {
400 AliAODCaloCluster *caod = static_cast<AliAODCaloCluster*>(c);
401 caod->SetCellsAbsId(absIds);
402 caod->SetCellsAmplitudeFraction(ratios);
403 }
84ccad86 404 }
405
406 AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(InputEvent());
407 if (!esdevent)
408 return;
409 if (!fRecoUtils)
410 return;
411
95f69c66 412 AliAnalysisManager::GetAnalysisManager()->LoadBranch("Tracks");
84ccad86 413 fRecoUtils->FindMatches(esdevent,clus);
414
95f69c66 415 if (!esdobjects) {
416 Int_t Nclus = clus->GetEntries();
417 for(Int_t i=0; i < Nclus; ++i) {
418 AliAODCaloCluster *c = static_cast<AliAODCaloCluster*>(clus->At(i));
419 Int_t trackIndex = fRecoUtils->GetMatchedTrackIndex(i);
420 if(trackIndex >= 0) {
421 Float_t dR, dZ;
422 fRecoUtils->GetMatchedResiduals(i,dR, dZ);
423 c->AddTrackMatched(0x0); //esdevent->GetTrack(trackIndex));
424 c->SetTrackDistance(dR,dZ); // not implemented
425 c->SetEmcCpvDistance(dR);
426 c->SetChi2(dZ);
427 if(DebugLevel() > 1)
428 AliInfo(Form("Matched Track index %d to new cluster %d\n",trackIndex,i));
429 }
2f7259cf 430 }
95f69c66 431 } else {
84ccad86 432 Int_t Nclus = clus->GetEntries();
433 for(Int_t i=0; i < Nclus; ++i) {
434 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(clus->At(i));
2f7259cf 435 Int_t trackIndex = fRecoUtils->GetMatchedTrackIndex(i);
436 if(trackIndex >= 0) {
84ccad86 437 Float_t dR, dZ;
438 fRecoUtils->GetMatchedResiduals(i,dR, dZ);
439 c->SetTrackDistance(dR,dZ);
440 c->SetEmcCpvDistance(dR); //to be consistent with AODs
441 c->SetChi2(dZ); //to be consistent with AODs
4cf9204b 442 TArrayI tm(1,&trackIndex);
443 c->AddTracksMatched(tm);
2f7259cf 444 if(DebugLevel() > 1)
445 AliInfo(Form("Matched Track index %d to new cluster %d\n",trackIndex,i));
446 }
447 }
448 }
449}
450
95f69c66 451//________________________________________________________________________
452void AliAnalysisTaskEMCALClusterizeFast::UpdateCells()
453{
454 // Update cells in case re-calibration was done.
455
456 if (!fCalibData&&!fSubBackground)
457 return;
458
459 AliVCaloCells *cells = InputEvent()->GetEMCALCells();
460 Int_t ncells = cells->GetNumberOfCells();
461 Int_t ndigis = fDigitsArr->GetEntries();
462
463 if (ncells!=ndigis) {
464 cells->DeleteContainer();
465 cells->CreateContainer(ndigis);
466 }
467 for (Int_t idigit = 0; idigit < ndigis; ++idigit) {
468 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(idigit));
469 Double_t cellAmplitude = digit->GetCalibAmp();
470 Short_t cellNumber = digit->GetId();
471 Double_t cellTime = digit->GetTime();
472 cells->SetCell(idigit, cellNumber, cellAmplitude, cellTime);
473 }
474}
475
476//________________________________________________________________________
477void AliAnalysisTaskEMCALClusterizeFast::UpdateClusters()
478{
479 // Update cells in case re-calibration was done.
7a7d5a64 480
95f69c66 481 if (!fAttachClusters)
482 return;
7a7d5a64 483
484 TClonesArray *clus;
485
486 if (fOverwrite)
487 {
488 clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("caloClusters"));
489 if (!clus)
490 clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("CaloClusters"));
491 if(!clus)
492 return;
493
494 Int_t nents = clus->GetEntries();
495 for (Int_t i=0;i<nents;++i) {
496 AliVCluster *c = static_cast<AliVCluster*>(clus->At(i));
497 if (!c)
498 continue;
499 if (c->IsEMCAL())
500 delete clus->RemoveAt(i);
501 }
95f69c66 502 }
7a7d5a64 503 else
504 {
505 clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fNewClusterArrayName));
506 if(!clus)
507 {
508 clus = new TClonesArray("AliESDCaloCluster");
509 clus->SetName(fNewClusterArrayName);
510 InputEvent()->AddObject(clus);
511 }
512 else
513 {
514
515 Int_t nents = clus->GetEntries();
516 for (Int_t i=0;i<nents;++i) {
517 AliVCluster *c = static_cast<AliVCluster*>(clus->At(i));
518 if (!c)
519 continue;
520
521 delete clus->RemoveAt(i);
522 }
523 clus->Compress();
524 }
525 }
526
95f69c66 527 RecPoints2Clusters(clus);
528}
529
2f7259cf 530//________________________________________________________________________________________
531void AliAnalysisTaskEMCALClusterizeFast::Init()
532{
533 //Select clusterization/unfolding algorithm and set all the needed parameters
01bc1ce8 534
2f7259cf 535 AliVEvent * event = InputEvent();
536 if (!event) {
537 AliWarning("Event not available!!!");
538 return;
539 }
540
541 if (event->GetRunNumber()==fRun)
542 return;
543 fRun = event->GetRunNumber();
544
545 if (fJustUnfold){
546 // init the unfolding afterburner
547 delete fUnfolder;
548 fUnfolder = new AliEMCALAfterBurnerUF(fRecParam->GetW0(),fRecParam->GetLocMaxCut());
549 return;
550 }
551
2f7259cf 552 AliEMCALGeometry *geometry = AliEMCALGeometry::GetInstance(fGeomName);
553 if (!geometry) {
554 AliFatal("Geometry not available!!!");
555 return;
556 }
557
558 if (!fGeomMatrixSet) {
559 if (fLoadGeomMatrices) {
e51bc3f5 560 for(Int_t mod=0; mod < geometry->GetNumberOfSuperModules(); ++mod) {
2f7259cf 561 if(fGeomMatrix[mod]){
562 if(DebugLevel() > 2)
563 fGeomMatrix[mod]->Print();
564 geometry->SetMisalMatrix(fGeomMatrix[mod],mod);
565 }
566 }
29b496d5 567 } else { // get matrix from file (work around bug in aliroot)
2f7259cf 568 for(Int_t mod=0; mod < geometry->GetEMCGeometry()->GetNumberOfSuperModules(); ++mod) {
29b496d5 569 const TGeoHMatrix *gm = 0;
441c4d3c 570 AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(event);
29b496d5 571 if (esdevent) {
572 gm = esdevent->GetEMCALMatrix(mod);
573 } else {
574 AliAODHeader *aodheader = dynamic_cast<AliAODHeader*>(event->GetHeader());
575 if (aodheader) {
576 gm = aodheader->GetEMCALMatrix(mod);
577 }
578 }
579 if (gm) {
2f7259cf 580 if(DebugLevel() > 2)
29b496d5 581 gm->Print();
582 geometry->SetMisalMatrix(gm,mod);
2f7259cf 583 }
584 }
585 }
586 fGeomMatrixSet=kTRUE;
587 }
588
589 // setup digit array if needed
590 if (!fDigitsArr) {
591 fDigitsArr = new TClonesArray("AliEMCALDigit", 1000);
592 fDigitsArr->SetOwner(1);
593 }
594
595 // then setup clusterizer
596 delete fClusterizer;
597 if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
598 fClusterizer = new AliEMCALClusterizerv1(geometry);
599 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
600 fClusterizer = new AliEMCALClusterizerNxN(geometry);
3786256f 601 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
602 fClusterizer = new AliEMCALClusterizerv2(geometry);
7a7d5a64 603 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizer5x5) {
2f7259cf 604 AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(geometry);
605 clusterizer->SetNRowDiff(2);
606 clusterizer->SetNColDiff(2);
607 fClusterizer = clusterizer;
7a7d5a64 608 }
609 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerFW){
610 AliEMCALClusterizerFixedWindow *clusterizer = new AliEMCALClusterizerFixedWindow(geometry);
611 clusterizer->SetnPhi(fNPhi);
612 clusterizer->SetnEta(fNEta);
613 clusterizer->SetshiftPhi(fshiftPhi);
614 clusterizer->SetshiftEta(fshiftEta);
615 clusterizer->SetTRUshift(fTRUshift);
616 fClusterizer = clusterizer;
617 }
618 else{
2f7259cf 619 AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
620 }
621 fClusterizer->InitParameters(fRecParam);
01bc1ce8 622
623 if ((!fCalibData&&fLoadCalib) || (!fPedestalData&&fLoadPed)) {
624 AliCDBManager *cdb = AliCDBManager::Instance();
625 if (!cdb->IsDefaultStorageSet() && !fOCDBpath.IsNull())
626 cdb->SetDefaultStorage(fOCDBpath);
627 if (fRun!=cdb->GetRun())
628 cdb->SetRun(fRun);
629 }
349bf69e 630 if (!fCalibData&&fLoadCalib&&fRun>0) {
2f7259cf 631 AliCDBEntry *entry = static_cast<AliCDBEntry*>(AliCDBManager::Instance()->Get("EMCAL/Calib/Data"));
632 if (entry)
633 fCalibData = static_cast<AliEMCALCalibData*>(entry->GetObject());
634 if (!fCalibData)
635 AliFatal("Calibration parameters not found in CDB!");
636 }
349bf69e 637 if (!fPedestalData&&fLoadPed&&fRun>0) {
2f7259cf 638 AliCDBEntry *entry = static_cast<AliCDBEntry*>(AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"));
639 if (entry)
640 fPedestalData = static_cast<AliCaloCalibPedestal*>(entry->GetObject());
641 }
10d33986 642 if (fCalibData) {
643 fClusterizer->SetInputCalibrated(kFALSE);
644 fClusterizer->SetCalibrationParameters(fCalibData);
10d33986 645 } else {
646 fClusterizer->SetInputCalibrated(kTRUE);
647 }
441c4d3c 648 fClusterizer->SetCaloCalibPedestal(fPedestalData);
10d33986 649 fClusterizer->SetJustClusters(kTRUE);
2f7259cf 650 fClusterizer->SetDigitsArr(fDigitsArr);
651 fClusterizer->SetOutput(0);
652 fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
653}