]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/CaloCalib/AliAnalysisTaskEMCALClusterizeFast.cxx
Fitting macro suite now has options for anti-Lambda and also summed Lambda+anti-Lambd...
[u/mrichter/AliRoot.git] / PWG4 / CaloCalib / AliAnalysisTaskEMCALClusterizeFast.cxx
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>
24
25 // --- AliRoot ---
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"
36 #include "AliEMCALClusterizerv2.h"
37 #include "AliEMCALClusterizerFixedWindow.h"
38 #include "AliEMCALFixedWindowClusterInfo.h"
39 #include "AliEMCALDigit.h"
40 #include "AliEMCALGeometry.h"
41 #include "AliEMCALRecParam.h"
42 #include "AliEMCALRecPoint.h"
43 #include "AliEMCALRecoUtils.h"
44 #include "AliESDEvent.h"
45 #include "AliInputEventHandler.h"
46 #include "AliLog.h"
47
48 #include "AliAnalysisTaskEMCALClusterizeFast.h"
49
50 ClassImp(AliAnalysisTaskEMCALClusterizeFast)
51
52 //________________________________________________________________________
53 AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast() 
54   : AliAnalysisTaskSE(), 
55     fRun(-1),
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),
72     fLoadPed(0),
73     fAttachClusters(0),
74     fRecalibOnly(0),
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)
85
86   // Constructor
87 }
88
89 //________________________________________________________________________
90 AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast(const char *name) 
91   : AliAnalysisTaskSE(name), 
92     fRun(-1),
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(),
107     fRecoUtils(0),
108     fLoadCalib(0),
109     fLoadPed(0),
110     fAttachClusters(0),
111     fRecalibOnly(0),
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)
122
123   // Constructor
124
125   fBranchNames     = "ESD:AliESDHeader.,AliESDRun.,EMCALCells. AOD:header,emcalCells";
126   for(Int_t i = 0; i < 12; ++i) 
127     fGeomMatrix[i] = 0;
128 }
129
130 //________________________________________________________________________
131 AliAnalysisTaskEMCALClusterizeFast::~AliAnalysisTaskEMCALClusterizeFast()
132 {
133   // Destructor.
134
135   delete fDigitsArr; 
136   delete fClusterizer;
137   delete fUnfolder;   
138   delete fRecoUtils;
139 }
140
141 //-------------------------------------------------------------------
142 void 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 //________________________________________________________________________
155 void 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();
172
173   UInt_t offtrigger = 0;
174   if (esdevent) {
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()));
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   }
194   
195   Init();
196
197   if (fJustUnfold) {
198     AliWarning("Unfolding not implemented");
199     return;
200   }
201
202   FillDigitsArray();
203
204   if (fRecalibOnly) {
205     UpdateCells();
206     return; // not requested to run clusterizer
207   }
208
209   Clusterize();
210   UpdateCells();
211   UpdateClusters();
212   
213   if (fStoreAdditionalInformation)
214     StoreAdditionalInformation();
215
216   if (fOutputAODBranch)
217     RecPoints2Clusters(fOutputAODBranch);
218 }
219
220 //________________________________________________________________________
221 void 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     if (!clusterizer)
235       return;
236     clusInfo = clusterizer->GetClustersInfo();
237     if (!clusInfo)
238       return;
239     clusInfo->SetName(addInfoName);
240     InputEvent()->AddObject(clusInfo);
241   }
242 }
243
244 //________________________________________________________________________
245 void AliAnalysisTaskEMCALClusterizeFast::Clusterize()
246 {
247   // Clusterize
248
249   if (fSubBackground) {
250     fClusterizer->SetInputCalibrated(kTRUE);   
251     fClusterizer->SetCalibrationParameters(0);
252   }
253
254   fClusterizer->Digits2Clusters("");
255   if (fSubBackground) {
256     if (fCalibData) {
257       fClusterizer->SetInputCalibrated(kFALSE);   
258       fClusterizer->SetCalibrationParameters(fCalibData);
259     }
260   }
261 }
262
263 //________________________________________________________________________
264 void AliAnalysisTaskEMCALClusterizeFast::FillDigitsArray()
265 {
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       
285     }
286     
287   }
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);
312         digit->SetAmplitude(energy);
313         avgE += energy;
314       } else {
315         digit->SetAmplitude(cellAmplitude);
316       }
317       idigit++;
318     }
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         }
334 }
335
336 //________________________________________________________________________________________
337 void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
338 {
339   // Cluster energy, global position, cells and their amplitude fractions are restored.
340
341   Bool_t esdobjects = 0;
342   if (strcmp(clus->GetClass()->GetName(),"AliESDCaloCluster")==0)
343     esdobjects = 1;
344
345   AliVCaloCells *cells = InputEvent()->GetEMCALCells();
346   AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(fGeomName);
347   
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();
361       ++ncells_true;
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;
371     recpoint->GetGlobalPosition(gpos);
372     Float_t g[3];
373     gpos.GetXYZ(g);
374     
375     AliVCluster *c = static_cast<AliVCluster*>(clus->New(nout++));
376     c->SetType(AliVCluster::kEMCALClusterv1);
377     c->SetE(recpoint->GetEnergy());
378     c->SetPosition(g);
379     c->SetNCells(ncells_true);
380     c->SetDispersion(recpoint->GetDispersion());
381     c->SetEmcCpvDistance(-1);            //not yet implemented
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]) ;
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
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     }
406   }
407  
408   AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(InputEvent());
409   if (!esdevent)
410     return;
411   if (!fRecoUtils)
412     return;
413
414   AliAnalysisManager::GetAnalysisManager()->LoadBranch("Tracks");
415   fRecoUtils->FindMatches(esdevent,clus);
416   
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       }
432     }
433   } else {
434     Int_t Nclus = clus->GetEntries();
435     for(Int_t i=0; i < Nclus; ++i) {
436       AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(clus->At(i));
437       Int_t trackIndex = fRecoUtils->GetMatchedTrackIndex(i);
438       if(trackIndex >= 0) {
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
444         TArrayI tm(1,&trackIndex);
445         c->AddTracksMatched(tm);
446         if(DebugLevel() > 1) 
447           AliInfo(Form("Matched Track index %d to new cluster %d\n",trackIndex,i));
448       }
449     }
450   }
451 }
452
453 //________________________________________________________________________
454 void 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 //________________________________________________________________________
479 void AliAnalysisTaskEMCALClusterizeFast::UpdateClusters()
480 {
481   // Update cells in case re-calibration was done.
482   
483   if (!fAttachClusters)
484     return;
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     }
504   }
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   
529   RecPoints2Clusters(clus);
530 }
531
532 //________________________________________________________________________________________
533 void AliAnalysisTaskEMCALClusterizeFast::Init()
534 {
535   //Select clusterization/unfolding algorithm and set all the needed parameters
536
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
554   AliEMCALGeometry *geometry = AliEMCALGeometry::GetInstance(fGeomName);
555   if (!geometry) {
556     AliFatal("Geometry not available!!!");
557     return;
558   }
559
560   if (!fGeomMatrixSet) {
561     if (fLoadGeomMatrices) {
562       for(Int_t mod=0; mod < geometry->GetNumberOfSuperModules(); ++mod) {
563         if(fGeomMatrix[mod]){
564           if(DebugLevel() > 2) 
565             fGeomMatrix[mod]->Print();
566           geometry->SetMisalMatrix(fGeomMatrix[mod],mod);  
567         }
568       }
569     } else { // get matrix from file (work around bug in aliroot)
570       for(Int_t mod=0; mod < geometry->GetEMCGeometry()->GetNumberOfSuperModules(); ++mod) {
571         const TGeoHMatrix *gm = 0;
572         AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(event);
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) {
582           if(DebugLevel() > 2) 
583             gm->Print();
584           geometry->SetMisalMatrix(gm,mod);
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);
601   else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN) {
602    AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(geometry);
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);
608   else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerFW){
609     AliEMCALClusterizerFixedWindow *clusterizer = new AliEMCALClusterizerFixedWindow(geometry);
610     clusterizer->SetNphi(fNPhi);
611     clusterizer->SetNeta(fNEta);
612     clusterizer->SetShiftPhi(fShiftPhi);
613     clusterizer->SetShiftEta(fShiftEta);
614     clusterizer->SetTRUshift(fTRUShift);
615     fClusterizer = clusterizer;
616   }
617   else{
618     AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
619   }
620   fClusterizer->InitParameters(fRecParam);
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   }
629   if (!fCalibData&&fLoadCalib&&fRun>0) {
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   }
636   if (!fPedestalData&&fLoadPed&&fRun>0) {
637     AliCDBEntry *entry = static_cast<AliCDBEntry*>(AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"));
638     if (entry) 
639       fPedestalData =  static_cast<AliCaloCalibPedestal*>(entry->GetObject());
640   }
641   if (fCalibData) {
642     fClusterizer->SetInputCalibrated(kFALSE);   
643     fClusterizer->SetCalibrationParameters(fCalibData);
644   } else {
645     fClusterizer->SetInputCalibrated(kTRUE);   
646   }
647   fClusterizer->SetCaloCalibPedestal(fPedestalData);
648   fClusterizer->SetJustClusters(kTRUE);
649   fClusterizer->SetDigitsArr(fDigitsArr);
650   fClusterizer->SetOutput(0);
651   fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
652 }