Fitting macro suite now has options for anti-Lambda and also summed Lambda+anti-Lambd...
[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),
3c56da8f 81 fShiftPhi(2),
82 fShiftEta(2),
83 fTRUShift(0),
7a7d5a64 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),
3c56da8f 118 fShiftPhi(2),
119 fShiftEta(2),
120 fTRUShift(0),
7a7d5a64 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);
13b50cf4 234 if (!clusterizer)
235 return;
7a7d5a64 236 clusInfo = clusterizer->GetClustersInfo();
237 if (!clusInfo)
238 return;
239 clusInfo->SetName(addInfoName);
240 InputEvent()->AddObject(clusInfo);
241 }
242}
243
244//________________________________________________________________________
95f69c66 245void AliAnalysisTaskEMCALClusterizeFast::Clusterize()
2431b20f 246{
95f69c66 247 // Clusterize
7099ec08 248
95f69c66 249 if (fSubBackground) {
250 fClusterizer->SetInputCalibrated(kTRUE);
251 fClusterizer->SetCalibrationParameters(0);
2f7259cf 252 }
d3b5a5ec 253
95f69c66 254 fClusterizer->Digits2Clusters("");
255 if (fSubBackground) {
4889ed8b 256 if (fCalibData) {
257 fClusterizer->SetInputCalibrated(kFALSE);
258 fClusterizer->SetCalibrationParameters(fCalibData);
259 }
4cf9204b 260 }
4cf9204b 261}
262
263//________________________________________________________________________
95f69c66 264void AliAnalysisTaskEMCALClusterizeFast::FillDigitsArray()
2f7259cf 265{
7a7d5a64 266 if (fCreatePattern)
267 {
268
269 AliEMCALGeometry *fGeom = AliEMCALGeometry::GetInstance(fGeomName);
270
271 fDigitsArr->Clear("C");
272 Int_t maxd = fGeom->GetNCells() / 4;
273
274 for (Int_t idigit = 0; idigit < maxd; idigit++)
275 {
276 if (idigit % 24 == 12) idigit += 12;
277 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
278 digit->SetId(idigit * 4);
279 digit->SetTime(600);
280 digit->SetTimeR(600);
281 digit->SetIndexInList(idigit);
282 digit->SetType(AliEMCALDigit::kHG);
283 digit->SetAmplitude(0.1);
284
b0e354fe 285 }
7a7d5a64 286
2f7259cf 287 }
7a7d5a64 288 else
289 {
290
291 // Fill digits from cells.
292
293 fDigitsArr->Clear("C");
294 AliVCaloCells *cells = InputEvent()->GetEMCALCells();
295 Double_t avgE = 0; // for background subtraction
296 Int_t ncells = cells->GetNumberOfCells();
297 for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) {
298 Double_t cellAmplitude=0, cellTime=0;
299 Short_t cellNumber=0;
300 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime) != kTRUE)
301 break;
302 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
303 digit->SetId(cellNumber);
304 digit->SetTime(cellTime);
305 digit->SetTimeR(cellTime);
306 digit->SetIndexInList(idigit);
307 digit->SetType(AliEMCALDigit::kHG);
308 if (fRecalibOnly||fSubBackground) {
309 Float_t energy = cellAmplitude;
310 Float_t time = cellTime;
311 fClusterizer->Calibrate(energy,time,cellNumber);
95f69c66 312 digit->SetAmplitude(energy);
7a7d5a64 313 avgE += energy;
314 } else {
315 digit->SetAmplitude(cellAmplitude);
95f69c66 316 }
7a7d5a64 317 idigit++;
b0e354fe 318 }
7a7d5a64 319
320 if (fSubBackground) {
321 avgE /= AliEMCALGeometry::GetInstance(fGeomName)->GetNumberOfSuperModules()*48*24;
322 Int_t ndigis = fDigitsArr->GetEntries();
323 for (Int_t i = 0; i < ndigis; ++i) {
324 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(i));
325 Double_t energy = digit->GetAmplitude() - avgE;
326 if (energy<=0.001) {
327 digit->SetAmplitude(0);
328 } else {
329 digit->SetAmplitude(energy);
330 }
331 }
332 }
333 }
2f7259cf 334}
335
336//________________________________________________________________________________________
95f69c66 337void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
4cf9204b 338{
339 // Cluster energy, global position, cells and their amplitude fractions are restored.
340
95f69c66 341 Bool_t esdobjects = 0;
342 if (strcmp(clus->GetClass()->GetName(),"AliESDCaloCluster")==0)
343 esdobjects = 1;
344
b98487bc 345 AliVCaloCells *cells = InputEvent()->GetEMCALCells();
346 AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(fGeomName);
347
4cf9204b 348 Int_t Ncls = fClusterArr->GetEntriesFast();
349 for(Int_t i=0, nout=clus->GetEntries(); i < Ncls; ++i) {
350 AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
351 Int_t ncells_true = 0;
352 const Int_t ncells = recpoint->GetMultiplicity();
353 UShort_t absIds[ncells];
354 Double32_t ratios[ncells];
355 Int_t *dlist = recpoint->GetDigitsList();
356 Float_t *elist = recpoint->GetEnergiesList();
357 for (Int_t c = 0; c < ncells; ++c) {
358 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c]));
359 absIds[ncells_true] = digit->GetId();
360 ratios[ncells_true] = elist[c]/digit->GetAmplitude();
84ccad86 361 ++ncells_true;
4cf9204b 362 }
363
364 if (ncells_true < 1) {
365 AliWarning("Skipping cluster with no cells");
366 continue;
367 }
368
369 // calculate new cluster position
370 TVector3 gpos;
4cf9204b 371 recpoint->GetGlobalPosition(gpos);
84ccad86 372 Float_t g[3];
4cf9204b 373 gpos.GetXYZ(g);
374
95f69c66 375 AliVCluster *c = static_cast<AliVCluster*>(clus->New(nout++));
4cf9204b 376 c->SetType(AliVCluster::kEMCALClusterv1);
377 c->SetE(recpoint->GetEnergy());
378 c->SetPosition(g);
379 c->SetNCells(ncells_true);
4cf9204b 380 c->SetDispersion(recpoint->GetDispersion());
84ccad86 381 c->SetEmcCpvDistance(-1); //not yet implemented
4cf9204b 382 c->SetChi2(-1); //not yet implemented
383 c->SetTOF(recpoint->GetTime()) ; //time-of-flight
384 c->SetNExMax(recpoint->GetNExMax()); //number of local maxima
385 Float_t elipAxis[2];
386 recpoint->GetElipsAxis(elipAxis);
387 c->SetM02(elipAxis[0]*elipAxis[0]) ;
388 c->SetM20(elipAxis[1]*elipAxis[1]) ;
b98487bc 389 if (fRecoUtils && fRecoUtils->IsBadChannelsRemovalSwitchedOn()) {
390 fRecoUtils->RecalculateClusterDistanceToBadChannel(geom, cells, c);
391 } else {
392 if (fPedestalData)
393 recpoint->EvalDistanceToBadChannels(fPedestalData);
394 c->SetDistanceToBadChannel(recpoint->GetDistanceToBadTower());
395 }
396
95f69c66 397 if (esdobjects) {
398 AliESDCaloCluster *cesd = static_cast<AliESDCaloCluster*>(c);
399 cesd->SetCellsAbsId(absIds);
400 cesd->SetCellsAmplitudeFraction(ratios);
401 } else {
402 AliAODCaloCluster *caod = static_cast<AliAODCaloCluster*>(c);
403 caod->SetCellsAbsId(absIds);
404 caod->SetCellsAmplitudeFraction(ratios);
405 }
84ccad86 406 }
407
408 AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(InputEvent());
409 if (!esdevent)
410 return;
411 if (!fRecoUtils)
412 return;
413
95f69c66 414 AliAnalysisManager::GetAnalysisManager()->LoadBranch("Tracks");
84ccad86 415 fRecoUtils->FindMatches(esdevent,clus);
416
95f69c66 417 if (!esdobjects) {
418 Int_t Nclus = clus->GetEntries();
419 for(Int_t i=0; i < Nclus; ++i) {
420 AliAODCaloCluster *c = static_cast<AliAODCaloCluster*>(clus->At(i));
421 Int_t trackIndex = fRecoUtils->GetMatchedTrackIndex(i);
422 if(trackIndex >= 0) {
423 Float_t dR, dZ;
424 fRecoUtils->GetMatchedResiduals(i,dR, dZ);
425 c->AddTrackMatched(0x0); //esdevent->GetTrack(trackIndex));
426 c->SetTrackDistance(dR,dZ); // not implemented
427 c->SetEmcCpvDistance(dR);
428 c->SetChi2(dZ);
429 if(DebugLevel() > 1)
430 AliInfo(Form("Matched Track index %d to new cluster %d\n",trackIndex,i));
431 }
2f7259cf 432 }
95f69c66 433 } else {
84ccad86 434 Int_t Nclus = clus->GetEntries();
435 for(Int_t i=0; i < Nclus; ++i) {
436 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(clus->At(i));
2f7259cf 437 Int_t trackIndex = fRecoUtils->GetMatchedTrackIndex(i);
438 if(trackIndex >= 0) {
84ccad86 439 Float_t dR, dZ;
440 fRecoUtils->GetMatchedResiduals(i,dR, dZ);
441 c->SetTrackDistance(dR,dZ);
442 c->SetEmcCpvDistance(dR); //to be consistent with AODs
443 c->SetChi2(dZ); //to be consistent with AODs
4cf9204b 444 TArrayI tm(1,&trackIndex);
445 c->AddTracksMatched(tm);
2f7259cf 446 if(DebugLevel() > 1)
447 AliInfo(Form("Matched Track index %d to new cluster %d\n",trackIndex,i));
448 }
449 }
450 }
451}
452
95f69c66 453//________________________________________________________________________
454void AliAnalysisTaskEMCALClusterizeFast::UpdateCells()
455{
456 // Update cells in case re-calibration was done.
457
458 if (!fCalibData&&!fSubBackground)
459 return;
460
461 AliVCaloCells *cells = InputEvent()->GetEMCALCells();
462 Int_t ncells = cells->GetNumberOfCells();
463 Int_t ndigis = fDigitsArr->GetEntries();
464
465 if (ncells!=ndigis) {
466 cells->DeleteContainer();
467 cells->CreateContainer(ndigis);
468 }
469 for (Int_t idigit = 0; idigit < ndigis; ++idigit) {
470 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(idigit));
471 Double_t cellAmplitude = digit->GetCalibAmp();
472 Short_t cellNumber = digit->GetId();
473 Double_t cellTime = digit->GetTime();
474 cells->SetCell(idigit, cellNumber, cellAmplitude, cellTime);
475 }
476}
477
478//________________________________________________________________________
479void AliAnalysisTaskEMCALClusterizeFast::UpdateClusters()
480{
481 // Update cells in case re-calibration was done.
7a7d5a64 482
95f69c66 483 if (!fAttachClusters)
484 return;
7a7d5a64 485
486 TClonesArray *clus;
487
488 if (fOverwrite)
489 {
490 clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("caloClusters"));
491 if (!clus)
492 clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("CaloClusters"));
493 if(!clus)
494 return;
495
496 Int_t nents = clus->GetEntries();
497 for (Int_t i=0;i<nents;++i) {
498 AliVCluster *c = static_cast<AliVCluster*>(clus->At(i));
499 if (!c)
500 continue;
501 if (c->IsEMCAL())
502 delete clus->RemoveAt(i);
503 }
95f69c66 504 }
7a7d5a64 505 else
506 {
507 clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fNewClusterArrayName));
508 if(!clus)
509 {
510 clus = new TClonesArray("AliESDCaloCluster");
511 clus->SetName(fNewClusterArrayName);
512 InputEvent()->AddObject(clus);
513 }
514 else
515 {
516
517 Int_t nents = clus->GetEntries();
518 for (Int_t i=0;i<nents;++i) {
519 AliVCluster *c = static_cast<AliVCluster*>(clus->At(i));
520 if (!c)
521 continue;
522
523 delete clus->RemoveAt(i);
524 }
525 clus->Compress();
526 }
527 }
528
95f69c66 529 RecPoints2Clusters(clus);
530}
531
2f7259cf 532//________________________________________________________________________________________
533void AliAnalysisTaskEMCALClusterizeFast::Init()
534{
535 //Select clusterization/unfolding algorithm and set all the needed parameters
01bc1ce8 536
2f7259cf 537 AliVEvent * event = InputEvent();
538 if (!event) {
539 AliWarning("Event not available!!!");
540 return;
541 }
542
543 if (event->GetRunNumber()==fRun)
544 return;
545 fRun = event->GetRunNumber();
546
547 if (fJustUnfold){
548 // init the unfolding afterburner
549 delete fUnfolder;
550 fUnfolder = new AliEMCALAfterBurnerUF(fRecParam->GetW0(),fRecParam->GetLocMaxCut());
551 return;
552 }
553
2f7259cf 554 AliEMCALGeometry *geometry = AliEMCALGeometry::GetInstance(fGeomName);
555 if (!geometry) {
556 AliFatal("Geometry not available!!!");
557 return;
558 }
559
560 if (!fGeomMatrixSet) {
561 if (fLoadGeomMatrices) {
e51bc3f5 562 for(Int_t mod=0; mod < geometry->GetNumberOfSuperModules(); ++mod) {
2f7259cf 563 if(fGeomMatrix[mod]){
564 if(DebugLevel() > 2)
565 fGeomMatrix[mod]->Print();
566 geometry->SetMisalMatrix(fGeomMatrix[mod],mod);
567 }
568 }
29b496d5 569 } else { // get matrix from file (work around bug in aliroot)
2f7259cf 570 for(Int_t mod=0; mod < geometry->GetEMCGeometry()->GetNumberOfSuperModules(); ++mod) {
29b496d5 571 const TGeoHMatrix *gm = 0;
441c4d3c 572 AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(event);
29b496d5 573 if (esdevent) {
574 gm = esdevent->GetEMCALMatrix(mod);
575 } else {
576 AliAODHeader *aodheader = dynamic_cast<AliAODHeader*>(event->GetHeader());
577 if (aodheader) {
578 gm = aodheader->GetEMCALMatrix(mod);
579 }
580 }
581 if (gm) {
2f7259cf 582 if(DebugLevel() > 2)
29b496d5 583 gm->Print();
584 geometry->SetMisalMatrix(gm,mod);
2f7259cf 585 }
586 }
587 }
588 fGeomMatrixSet=kTRUE;
589 }
590
591 // setup digit array if needed
592 if (!fDigitsArr) {
593 fDigitsArr = new TClonesArray("AliEMCALDigit", 1000);
594 fDigitsArr->SetOwner(1);
595 }
596
597 // then setup clusterizer
598 delete fClusterizer;
599 if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
600 fClusterizer = new AliEMCALClusterizerv1(geometry);
3c56da8f 601 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN) {
2f7259cf 602 AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(geometry);
3c56da8f 603 clusterizer->SetNRowDiff(fRecParam->GetNRowDiff());
604 clusterizer->SetNColDiff(fRecParam->GetNColDiff());
605 fClusterizer = clusterizer;
606 } else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
607 fClusterizer = new AliEMCALClusterizerv2(geometry);
7a7d5a64 608 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerFW){
609 AliEMCALClusterizerFixedWindow *clusterizer = new AliEMCALClusterizerFixedWindow(geometry);
0fda97fe 610 clusterizer->SetNphi(fNPhi);
611 clusterizer->SetNeta(fNEta);
612 clusterizer->SetShiftPhi(fShiftPhi);
613 clusterizer->SetShiftEta(fShiftEta);
3c56da8f 614 clusterizer->SetTRUshift(fTRUShift);
7a7d5a64 615 fClusterizer = clusterizer;
616 }
617 else{
2f7259cf 618 AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
619 }
620 fClusterizer->InitParameters(fRecParam);
01bc1ce8 621
622 if ((!fCalibData&&fLoadCalib) || (!fPedestalData&&fLoadPed)) {
623 AliCDBManager *cdb = AliCDBManager::Instance();
624 if (!cdb->IsDefaultStorageSet() && !fOCDBpath.IsNull())
625 cdb->SetDefaultStorage(fOCDBpath);
626 if (fRun!=cdb->GetRun())
627 cdb->SetRun(fRun);
628 }
349bf69e 629 if (!fCalibData&&fLoadCalib&&fRun>0) {
2f7259cf 630 AliCDBEntry *entry = static_cast<AliCDBEntry*>(AliCDBManager::Instance()->Get("EMCAL/Calib/Data"));
631 if (entry)
632 fCalibData = static_cast<AliEMCALCalibData*>(entry->GetObject());
633 if (!fCalibData)
634 AliFatal("Calibration parameters not found in CDB!");
635 }
349bf69e 636 if (!fPedestalData&&fLoadPed&&fRun>0) {
2f7259cf 637 AliCDBEntry *entry = static_cast<AliCDBEntry*>(AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"));
638 if (entry)
639 fPedestalData = static_cast<AliCaloCalibPedestal*>(entry->GetObject());
640 }
10d33986 641 if (fCalibData) {
642 fClusterizer->SetInputCalibrated(kFALSE);
643 fClusterizer->SetCalibrationParameters(fCalibData);
10d33986 644 } else {
645 fClusterizer->SetInputCalibrated(kTRUE);
646 }
441c4d3c 647 fClusterizer->SetCaloCalibPedestal(fPedestalData);
10d33986 648 fClusterizer->SetJustClusters(kTRUE);
2f7259cf 649 fClusterizer->SetDigitsArr(fDigitsArr);
650 fClusterizer->SetOutput(0);
651 fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
652}